Merge branch 'upstream-unstable'

This commit is contained in:
Yves-Alexis Perez 2011-11-13 20:31:57 +01:00
commit f604ffd388
92 changed files with 18404 additions and 17646 deletions

View file

@ -1,5 +1,37 @@
This file is licensed under the terms of the expat license, see the file EXPAT.
v0.4.2:
+ Improve -moz-document parsing in user stylesheets
+ Render verified secure sites in green, not yellow
+ Version details for extensions built against a different release
+ More detailed and more condensed about:version output
+ Refresh missing speed dial thumbnails automatically
+ Use faster global CSS mechanism for adblock and addons
+ Show crash dialog only if there's a session
+ Don't complete on a leading space or search token
+ Support user stylesheets on about: and file:// locations
+ Implement 'Always use my font choices' preferences
+ Allow smaller tabs when close buttons are disabled
+ Merge 'Closed Tabs' with 'History' in Clear Private Data
+ Correctly use user-home and bookmark-new icon names
+ Use versioned file speeddial-head-0.4.2.html
+ Split proxy server preference into host and port
+ Support localized 'next' and 'previous' links
+ Implement 'Only accept cookies cookies from sites you visit'
+ Fix crash in Add/ Import Bookmark feature
+ Fix size of tabs with GTK+ 3
+ Detect existing Firefox profiles for bookmark import
+ Work-around "omg!" in local directory browsing
+ Rework '--run' feature to allow window.open() and console.info()
+ Automatically clear finnished downloads from the transferbar
+ Add 'Create desktop shortcut' to the app menu
+ Require GLib 2.22 and libSoup 2.27.90
+ Don't register recent files in private browsing mode
+ Findbar and speed dial honor close button position
+ Use sqlite3-based backend for cookie storage
+ Make '--snapshot' create png images with GTK+ 2.20
+ Automatically resizing, embossed speed dial, close on hover
v0.4.1:
+ Experimental, unfinnished GTK+ 3 support
+ 'Automatic' identification with quirks

5
README
View file

@ -11,9 +11,10 @@ Midori is a lightweight web browser.
* Customizable and extensible interface.
* Extensions written in C.
Requirements: GTK+ 2.10, WebkitGTK+ 1.1.17, libXML2, libsoup 2.25.2, sqlite 3.0, Vala 0.10
Requirements: GLib 2.22, GTK+ 2.10, WebkitGTK+ 1.1.17, libXML2,
libsoup 2.27.90, sqlite 3.0, Vala 0.10
Optional: Unique 0.9, libidn, libnotify
Optional: GTK+ 3.0, Unique 0.9, libnotify
For installation instructions read INSTALL.

BIN
data/close.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -6,8 +6,8 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>midori:faq</title>
<meta name="generator" content="DokuWiki"/>
<meta name="robots" content="index,follow"/>
<meta name="date" content="2011-05-05T22:28:18+0200"/>
<meta name="robots" content="noindex,nofollow"/>
<meta name="date" content="2011-11-08T02:51:30+0100"/>
<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="/"/>
@ -19,9 +19,9 @@
<link rel="canonical" href="http://wiki.xfce.org/midori/faq"/>
<link rel="stylesheet" type="text/css" href="faq.css" />
<script type="text/javascript"><!--//--><![CDATA[//><!--
var NS='midori';var JSINFO = {"id":"midori:faq","namespace":"midori"};
var NS='midori';var SIG=' --- //[[christian@twotoasts.de|Christian Dywan]] 2011/11/11 00:07//';var JSINFO = {"id":"midori:faq","namespace":"midori"};
//--><!]]></script>
<script type="text/javascript" charset="utf-8" src="/lib/exe/js.php?tseed=1306663866"></script>
<script type="text/javascript" charset="utf-8" src="/lib/exe/js.php?tseed=1316333533"></script>
</head>
<body>
<div class="dokuwiki export">
@ -49,6 +49,7 @@ var NS='midori';var JSINFO = {"id":"midori:faq","namespace":"midori"};
<li class="level3"><div class="li"><span class="li"><a href="#following_links" class="toc">Following Links</a></span></div></li>
<li class="level3"><div class="li"><span class="li"><a href="#use_ctrl_shift_tab_to_switch_between_pages" class="toc">Use Ctrl(+Shift)+Tab to switch between pages</a></span></div></li>
<li class="level3"><div class="li"><span class="li"><a href="#customizing_keyboard_shortcuts" class="toc">Customizing keyboard shortcuts</a></span></div></li>
<li class="level3"><div class="li"><span class="li"><a href="#using_find" class="toc">Using Find</a></span></div></li>
</ul>
</li>
<li class="level2"><div class="li"><span class="li"><a href="#mouse_gestures" class="toc">Mouse Gestures</a></span></div></li>
@ -64,7 +65,6 @@ var NS='midori';var JSINFO = {"id":"midori:faq","namespace":"midori"};
<div class="level1">
<p>
<strong>This document is licensed under the <acronym title="GNU Lesser General Public License">LGPL</acronym> 2.1.</strong>
</p>
@ -128,7 +128,6 @@ Midori is basically very portable and should run on all platforms that its depen
<p>
Midori and all delivered artwork are licensed under the LGPL2.
</p>
</div>
@ -142,7 +141,6 @@ Midori and all delivered artwork are licensed under the LGPL2.
<div class="level4">
<p>
Some websites discriminate against your browser.
</p>
@ -186,20 +184,17 @@ If you don&#039;t have a desktop application that takes care of Gtk settings or
<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>
Enable changing hotkeys while hovering menu items:
</p>
<pre class="code">gtk-can-change-accels = 1</pre>
@ -236,7 +231,6 @@ You can either run that above line and run Midori in the same terminal afterward
<div class="level4">
<p>
Try searching for a package named nspluginwrapper or similar in your distribution repositories. It implements plugins in their own process so they can&#039;t drag down the whole browser.
</p>
@ -246,7 +240,6 @@ Try searching for a package named nspluginwrapper or similar in your distributio
<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>
@ -257,7 +250,6 @@ That&#039;s a problem with WebKit. You can work around it to some extent if you
<div class="level4">
<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>
@ -267,9 +259,7 @@ That&#039;s a problem with WebKit. You can work around it to some extent if you
<div class="level4">
<p>
You need to have GStreamer plugins installed which implement the codecs.
</p>
<ol>
<li class="level1"><div class="li"> You need gstreamer0.10-pulse if you&#039;re using PulseAudio.</div>
@ -294,7 +284,6 @@ You need to have GStreamer plugins installed which implement the codecs.
<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>
@ -308,9 +297,7 @@ icedtea6 version 1.8 and above has been known to crash midori. If this is the c
<div class="level4">
<p>
Currently only <acronym title="Hyper Text Transfer Protocol">HTTP</acronym> proxy servers are supported directly. A way to use SOCKS on Unix is to use tsocks with <acronym title="Secure Shell">SSH</acronym> as follows:
</p>
<ol>
<li class="level1"><div class="li"> Install &#039;tsocks&#039;</div>
@ -340,7 +327,6 @@ server_port = 5555</pre>
<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>
@ -351,7 +337,6 @@ Midori 0.3.2 disables the menubar by default.
<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>
@ -365,7 +350,6 @@ Try using &#039;g&#039; in front of the search terms, like &#039;g Ms.Marple&#03
<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>
@ -376,7 +360,6 @@ Since Midori 0.3.2 you can use Ctrl+Shift+R.
<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>
@ -386,7 +369,6 @@ Right-click the tab label, and click &#039;Minimize&#039; or &#039;Show Tab Icon
<div class="level4">
<p>
You need to set Preferences &gt; Network &gt; Identify As to Firefox.
</p>
@ -396,7 +378,6 @@ You need to set Preferences &gt; Network &gt; Identify As to Firefox.
<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>
@ -422,9 +403,7 @@ Place the following in ~/.mutt/mailcap or ~/.mailcap:
<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 <acronym title="Multipurpose Internet Mail Extension">MIME</acronym> 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>
@ -436,7 +415,6 @@ Midori opens files with GIO, and falls back to xdg-open, exo-open or gnome-open
</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>
@ -447,25 +425,20 @@ LXDE is unfortunately not supported yet, see <a href="https://bugs.freedesktop.o
<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>
@ -480,9 +453,7 @@ Note that incomplete .desktop files will silently fail and it will look as if it
<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>
@ -507,7 +478,6 @@ There are two closely related features to open websites as dedicated windows of
</ol>
<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>
@ -530,7 +500,6 @@ The same options available to -a/ app can be used for private browsing mode.
<div class="level2">
<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>
@ -540,7 +509,6 @@ By running a local proxy you can modify web content even before it has reached M
<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>
@ -554,7 +522,6 @@ Privoxy is a non-caching web proxy with filter capabilites and particular suppor
<div class="level4">
<p>
Mousehole is a scriptable proxy server written in Ruby.
</p>
@ -568,7 +535,6 @@ Mousehole is a scriptable proxy server written in Ruby.
<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.
@ -589,16 +555,13 @@ Mousehole is a scriptable proxy server written in Ruby.
<div class="level3">
<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>
@ -608,7 +571,6 @@ You can also use the arrow keys to do the same.
<div class="level3">
<p>
To enable Hints in Midori [similar to those vimperator provides in Firefox], press .
</p>
@ -622,7 +584,6 @@ With hints enabled, type the link number, and press Enter to open the link in th
<div class="level3">
<p>
Since Midori 0.3.5 Ctrl+Tab is supported by default.
</p>
@ -636,24 +597,46 @@ In older versions you can enable the History List extension under Tools → Exte
<div class="level3">
<p>
Enable the Shortcuts extension Tools → Extensions. To edit a keybinding Tools → Customize Shortcuts…
</p>
</div>
<!-- EDIT13 SECTION "Customizing keyboard shortcuts" [12013-12161] -->
<h2 class="sectionedit14"><a name="mouse_gestures" id="mouse_gestures">Mouse Gestures</a></h2>
<!-- EDIT13 SECTION "Customizing keyboard shortcuts" [12013-12162] -->
<h3 class="sectionedit14"><a name="using_find" id="using_find">Using Find</a></h3>
<div class="level3">
<p>
Default shortcuts for Find are:
</p>
<p>
Find: Ctrl+f ”/” and ”,”<br/>
FindNext: Ctrl+g<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>
<!-- EDIT14 SECTION "Using Find" [12163-12579] -->
<h2 class="sectionedit15"><a name="mouse_gestures" id="mouse_gestures">Mouse Gestures</a></h2>
<div class="level2">
<p>
By default the right mouse button initiates gestures.
</p>
<p>
You can change the button using a hidden option:
</p>
<ol>
<li class="level1"><div class="li"> Create a text file ~/.config/midori/extensions/libmouse-gestures.so/config .</div>
@ -665,7 +648,6 @@ You can change the button using a hidden option:
button=2</pre>
<p>
For a quick and dirty overview of the gestures in the current release take a look at the <a href="http://www.matthiaskruk.de/midori/mouse-gestures.pdf" class="urlextern" title="http://www.matthiaskruk.de/midori/mouse-gestures.pdf" rel="nofollow">preliminary manual</a>.
Further information is available at the <a href="http://www.matthiaskruk.de/midori" class="urlextern" title="http://www.matthiaskruk.de/midori" rel="nofollow">MGX website</a>.
</p>
@ -675,12 +657,11 @@ Additionally, there are programs allowing mouse gestures system-wide, for exampl
</p>
</div>
<!-- EDIT14 SECTION "Mouse Gestures" [12162-12835] -->
<h2 class="sectionedit15"><a name="spell_check" id="spell_check">Spell check</a></h2>
<!-- EDIT15 SECTION "Mouse Gestures" [12580-13253] -->
<h2 class="sectionedit16"><a name="spell_check" id="spell_check">Spell check</a></h2>
<div class="level2">
<p>
First enable spell checking:
Edit→Preferences→Behavior and check “Enable Spell Checking”.
</p>
@ -690,8 +671,8 @@ Now while typing any errors should get underlined in red. To get suggestions, hi
</p>
</div>
<!-- EDIT15 SECTION "Spell check" [12836-13125] -->
<h2 class="sectionedit16"><a name="user_scripts" id="user_scripts">User scripts</a></h2>
<!-- EDIT16 SECTION "Spell check" [13254-13543] -->
<h2 class="sectionedit17"><a name="user_scripts" id="user_scripts">User scripts</a></h2>
<div class="level2">
</div>
@ -700,7 +681,6 @@ Now while typing any errors should get underlined in red. To get suggestions, hi
<div class="level4">
<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>
@ -710,7 +690,6 @@ UserScripts are scripts applied on some, or on all web pages. They can modify p
<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>
@ -736,7 +715,6 @@ If the script is only shown as source code on the page, you first have to create
<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>
@ -746,7 +724,6 @@ As previously mentioned, Midori can use most scripts you will find. Midori suppo
<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>
@ -756,13 +733,12 @@ You can use <a href="http://userscripts.org/scripts/show/45343" class="urlextern
<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>
<!-- EDIT16 SECTION "User scripts" [13126-15686] -->
<h2 class="sectionedit17"><a name="user_styles" id="user_styles">User styles</a></h2>
<!-- EDIT17 SECTION "User scripts" [13544-16104] -->
<h2 class="sectionedit18"><a name="user_styles" id="user_styles">User styles</a></h2>
<div class="level2">
</div>
@ -771,7 +747,6 @@ You can also use <a href="http://rightfootin.blogspot.com/2009/04/flashblock-wan
<div class="level4">
<p>
User styles are <acronym title="Cascading Style Sheets">CSS</acronym> 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>
@ -781,7 +756,6 @@ User styles are <acronym title="Cascading Style Sheets">CSS</acronym> Cascading
<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>
@ -799,7 +773,6 @@ Note, if the style is only shown as source code on the page, you first have to c
<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>
@ -809,7 +782,6 @@ Open up the Preferences and use the file chooser button beside User Stylesheet t
<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>
@ -832,6 +804,6 @@ Customize as needed:
}</pre>
</div>
<!-- EDIT17 SECTION "User styles" [15687-] --></div>
<!-- EDIT18 SECTION "User styles" [16105-] --></div>
</body>
</html>

View file

@ -1,169 +1,102 @@
<!--
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.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{title}</title>
<style>
html, body, #content {
margin: 0px;
padding: 0px
* {
margin: 0;
padding: 0;
cursor: default;
font-size: 13px;
color: #4d4d4d;
}
body {
text-align: center;
background-color: #fefefe;
html, body {
font-family: sans-serif;
}
#wrap {
width: 660px;
height: 500px;
margin: 0px auto;
text-align: center;
width: 100%;
height: 100%;
outline: 0;
}
#content {
margin-top: 40px;
width: 100%;
height: 95%;
margin: 0 auto;
padding: 0;
}
div.shortcut {
width: 25%;
height: 33%;
float: left;
border: 1px solid #ccc;
}
div.shortcut .preview {
width: 70%;
height: 60%;
margin: 20% auto;
-webkit-box-shadow: 0 1px 6px rgba(0,0,0,.25), 0 0 2px #fff inset;
box-shadow: 0 1px 6px rgba(0,0,0,.25), 0 0 2px #fff inset;
background-image: -webkit-gradient(
linear, center top, center bottom,
from(#f6f6f6), to(#e3e3e3));
border: 1px solid #bebebe;
border-bottom-color: #a0a0a0;
position: relative;
margin: 20px 20px 0px 0px;
background-color: #fff;
-webkit-border-radius: 10px;
}
div.right {
margin-right: 0px;
margin-left: 0px;
}
div.top {
margin-top: 0px;
}
h1 {
font-size: 50px;
font-weight: bold;
margin: 0px;
padding: 10px 0px 0px 0px;
display: block;
}
h4 {
font-size: 11px;
font-weight: bold
margin: 10px 0px 0px 0px;
padding: 10px 5px 0px;
display: block;
}
h4 span:before {
content: "{click_to_add}";
font-size: 11px;
}
h4 span {
font-size: 11px;
}
div.shortcut a {
border: 1px solid #ccc;
display: block;
margin: 15px auto 0px;
background-color: #fafafa;
color: #aaa;
text-decoration: none;
}
div.shortcut a img {
div.shortcut .preview img {
width: 100%;
height: 98%;
cursor: pointer;
}
div.shortcut .preview.new .add {
display: block;
height: 100%;
width: 50%;
margin: 0 auto;
cursor: pointer;
}
div.shortcut a:hover {
border: 1px solid #999;
}
div.shortcut p {
font-size: 12px;
margin: 0px;
padding: 5px 0px 0px;
color: #222;
.title {
text-align: center;
margin-top: -17%;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
div.clear {
clear: both;
}
div.activated {
background-color: #f5f5f5;
cursor: text;
}
.cross {
height: 16px;
width: 16px;
margin-bottom: -17px;
margin-top: 2px;
background: url(stock://1/gtk-close) 98% 70% no-repeat;
cursor: pointer;
z-index: -4;
opacity: 0.6;
}
.cross:hover {
opacity: 1;
}
.activated p {
cursor: text;
background: url(stock://1/gtk-edit) 98% 70% no-repeat;
opacity: 0.6;
color: rgba(0,0,0,1);
}
.activated p:hover {
opacity: 1;
color: rgba(0,0,0,0.5);
}
div.config {
display: block;
width: 27px;
height: 27px;
top: -14px;
right: -14px;
background: url(res://close.png);
position: absolute;
top: 0px;
padding: 12px;
text-align: left;
}
div.config span {
color: #ccc;
margin-right: 10px;
margin-right: 10px;
}
div.config span.config_option:hover {
color: #999;
cursor: pointer;
visibility: hidden;
opacity: 0;
-webkit-transition: opacity 0.15s;
}
div.config span.config_label {
color: #ccc;
cursor: default;
margin-right: 0px;
div.shortcut .preview:hover .cross {
visibility: visible;
opacity: 1;
-webkit-transition-delay: 0.5s;
}
div.config span.config_option {
margin-left: 0px;
margin-right: 0px;
.box.added {
display:none;
}
div.osd {
@ -187,8 +120,8 @@
var getAction = function (id)
{
var host = document.getElementById(id).childNodes[3].host;
if (host)
var s = document.getElementById(id).childNodes[0];
if (s.className == 'preview')
return true;
var url = prompt ("{enter_shortcut_address}", "http://");
@ -196,16 +129,13 @@
if (url.indexOf ("://") == -1)
url = "http://" + url;
var name = prompt ("{enter_shortcut_name}", "");
if (!name) name = "";
console.log ("speed_dial-save-add " + id + " " + url + " " + name);
console.log ("speed_dial-save-add " + id + " " + url + " ");
return false;
}
var renameShortcut = function (id)
{
var old_name = document.getElementById(id).childNodes[5].textContent;
var old_name = document.getElementById(id).childNodes[1].textContent;
var name = prompt ("{enter_shortcut_name}", old_name);
if (!name) return;
@ -221,44 +151,6 @@
console.log ("speed_dial-save-delete " + id);
}
var setSize = function ()
{
var size = prompt ("{enter_dial_size}", columns + 'x' + rows);
if (!size) return;
var pos = size.indexOf('x');
if (pos <= 0)
{
alert ("{invalid_dial_size}");
return;
}
var cols = size.substr(0, pos);
rows = size.substr(pos+1);
if (isNaN (cols) || isNaN (rows) || cols == 0 || rows == 0)
{
alert ("{invalid_dial_size}");
return;
}
if (size.indexOf('.') >= 0)
{
alert ("{invalid_dial_size}");
return;
}
console.log ("speed_dial-save-size " + cols + " " + rows);
}
var setThumbSize = function (size)
{
console.log ("speed_dial-save-thumbsize " + size);
}
var key_id = 's';
var key_timeout;
@ -277,11 +169,11 @@
if (key_id.substr(1) > 9)
{
if (getAction (key_id))
document.location = div.childNodes[3].href;
document.location = div.childNodes[0].childNodes[1].href;
key_id = 's';
}
else
key_timeout = setTimeout ('if (getAction (key_id)) document.location = document.getElementById(key_id).childNodes[3].href; key_id = \'s\'', 1000);
key_timeout = setTimeout ('if (getAction (key_id)) document.location = document.getElementById(key_id).childNodes[0].childNodes[1].href; key_id = \'s\'', 1000);
}
else
key_id = 's';
@ -298,12 +190,4 @@
<div class="osd" >
<span id="dialing"></span>
</div>
<div class="config">
<span onclick="javascript:setSize()" class="config_option">{set_dial_size}</span>
<span class="config_label">{set_thumb_size}</span>
<span onclick="javascript:setThumbSize(80)" class="config_option">{set_thumb_small}</span>
<span onclick="javascript:setThumbSize(160)" class="config_option">{set_thumb_normal}</span>
<span onclick="javascript:setThumbSize(240)" class="config_option">{set_thumb_big}</span>
</div>
<div id="wrap">
<div id="content">
<div id="content">

View file

@ -11,11 +11,9 @@
*/
#include <midori/midori.h>
#include <midori/sokoke.h>
#include "config.h"
#include <glib/gstdio.h>
#include "config.h"
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
@ -51,9 +49,12 @@ static guint debug;
static gboolean
adblock_parse_file (gchar* path);
static void
adblock_reload_rules (MidoriExtension* extension,
gboolean custom_only);
static gchar*
adblock_build_js (const gchar* style,
const gchar* private)
adblock_build_js (const gchar* private)
{
return g_strdup_printf (
"window.addEventListener ('DOMContentLoaded',"
@ -62,7 +63,7 @@ adblock_build_js (const gchar* style,
" return;"
" var URL = location.href;"
" var sites = new Array(); %s;"
" var public = '%s';"
" var public = '.madblockplaceholder ';"
" for (var i in sites) {"
" if (URL.indexOf(i) != -1 && sites[i] ){"
" public += ', .'+sites[i];"
@ -76,11 +77,10 @@ adblock_build_js (const gchar* style,
" var head = document.getElementsByTagName('head')[0];"
" if (head) head.appendChild(mystyle);"
"}, true);",
private,
style);
private);
}
static gchar *
static GString*
adblock_fixup_regexp (const gchar* prefix,
gchar* src);
@ -108,17 +108,27 @@ adblock_init_db ()
}
static void
adblock_download_notify_status_cb (WebKitDownload* download,
GParamSpec* pspec,
gchar* path)
adblock_download_notify_status_cb (WebKitDownload* download,
GParamSpec* pspec,
MidoriExtension* extension)
{
gchar* path;
MidoriApp* app;
MidoriWebSettings* settings;
if (webkit_download_get_status (download) != WEBKIT_DOWNLOAD_STATUS_FINISHED)
return;
path = g_filename_from_uri (webkit_download_get_destination_uri (download), NULL, NULL);
adblock_parse_file (path);
katze_assign (blockscript, adblock_build_js (blockcss->str, blockcssprivate->str));
g_free (path);
/* g_object_unref (download); */
app = midori_extension_get_app (extension);
settings = katze_object_get_object (app, "settings");
g_string_append (blockcss, " {display: none !important}\n");
midori_web_settings_add_style (settings, "adblock-blockcss", blockcss->str);
katze_assign (blockscript, adblock_build_js (blockcssprivate->str));
g_object_unref (settings);
}
static gchar*
@ -154,6 +164,8 @@ adblock_reload_rules (MidoriExtension* extension,
gchar* custom_list;
gchar** filters;
guint i = 0;
MidoriApp* app = midori_extension_get_app (extension);
MidoriWebSettings* settings = katze_object_get_object (app, "settings");
adblock_init_db ();
@ -186,17 +198,19 @@ adblock_reload_rules (MidoriExtension* extension,
webkit_download_set_destination_uri (download, destination);
g_free (destination);
g_signal_connect (download, "notify::status",
G_CALLBACK (adblock_download_notify_status_cb), path);
G_CALLBACK (adblock_download_notify_status_cb), extension);
webkit_download_start (download);
}
else
g_free (path);
g_free (path);
i++;
}
}
g_strfreev (filters);
g_string_append (blockcss, " {display: none !important}\n");
katze_assign (blockscript, adblock_build_js (blockcss->str, blockcssprivate->str));
katze_assign (blockscript, adblock_build_js (blockcssprivate->str));
midori_web_settings_add_style (settings, "adblock-blockcss", blockcss->str);
g_object_unref (settings);
}
static void
@ -248,7 +262,7 @@ adblock_preferences_renderer_toggle_toggled_cb (GtkCellRendererToggle* renderer,
ADBLOCK_FILTER_SET (filter, TRUE);
if (gtk_cell_renderer_toggle_get_active (renderer))
{
if (!strncmp (filter, "http", 4))
if (midori_uri_is_http (filter))
{
gchar* filename = adblock_get_filename_for_uri (filter);
g_unlink (filename);
@ -394,6 +408,7 @@ adblock_get_preferences_dialog (MidoriExtension* extension)
GtkWidget* browser;
const gchar* dialog_title;
GtkWidget* dialog;
GtkWidget* content_area;
gint width, height;
GtkWidget* xfce_heading;
GtkWidget* hbox;
@ -417,11 +432,7 @@ adblock_get_preferences_dialog (MidoriExtension* extension)
dialog_title = _("Configure Advertisement filters");
dialog = gtk_dialog_new_with_buttons (dialog_title, GTK_WINDOW (browser),
#if GTK_CHECK_VERSION(3,0,0)
GTK_DIALOG_DESTROY_WITH_PARENT,
#else
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
#endif
#if !HAVE_OSX
#if !HAVE_HILDON
GTK_STOCK_HELP, GTK_RESPONSE_HELP,
@ -429,6 +440,7 @@ adblock_get_preferences_dialog (MidoriExtension* extension)
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
#endif
NULL);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
g_signal_connect (dialog, "destroy",
G_CALLBACK (gtk_widget_destroyed), &dialog);
gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_PROPERTIES);
@ -442,19 +454,9 @@ adblock_get_preferences_dialog (MidoriExtension* extension)
/* TODO: We need mnemonics */
if ((xfce_heading = sokoke_xfce_header_new (
gtk_window_get_icon_name (GTK_WINDOW (dialog)), dialog_title)))
#if GTK_CHECK_VERSION(3,0,0)
gtk_box_pack_start (gtk_dialog_get_content_area (GTK_DIALOG (dialog)),
xfce_heading, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (content_area), xfce_heading, FALSE, FALSE, 0);
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (gtk_dialog_get_content_area (GTK_DIALOG (dialog)), hbox,
TRUE, TRUE, 12);
#else
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
xfce_heading, FALSE, FALSE, 0);
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox,
TRUE, TRUE, 12);
#endif
gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 12);
vbox = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 4);
button = gtk_label_new (NULL);
@ -565,19 +567,10 @@ adblock_get_preferences_dialog (MidoriExtension* extension)
G_CALLBACK (adblock_preferences_help_clicked_cb), dialog); */
gtk_box_pack_end (GTK_BOX (hbox),
button, FALSE, FALSE, 4);
#if GTK_CHECK_VERSION(3,0,0)
gtk_box_pack_end (gtk_dialog_get_content_area(GTK_DIALOG (dialog)),
gtk_box_pack_end (GTK_BOX (content_area),
hbox, FALSE, FALSE, 0);
#else
gtk_box_pack_end (GTK_BOX (GTK_DIALOG (dialog)->vbox),
hbox, FALSE, FALSE, 0);
#endif
#endif
#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_show_all (gtk_dialog_get_content_area(GTK_DIALOG (dialog)));
#else
gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);
#endif
gtk_widget_show_all (content_area);
g_object_unref (browser);
@ -653,9 +646,12 @@ adblock_is_matched_by_key (const gchar* req_uri,
gint len;
int pos = 0;
GList* regex_bl = NULL;
GString* guri;
guri = adblock_fixup_regexp ("", (gchar*)req_uri);
uri = guri->str;
len = guri->len;
uri = adblock_fixup_regexp ("", (gchar*)req_uri);
len = strlen (uri);
for (pos = len - SIGNATURE_SIZE; pos >= 0; pos--)
{
gchar* sig = g_strndup (uri + pos, SIGNATURE_SIZE);
@ -686,7 +682,7 @@ adblock_is_matched_by_key (const gchar* req_uri,
}
g_free (sig);
}
g_free (uri);
g_string_free (guri, TRUE);
g_list_free (regex_bl);
return FALSE;
}
@ -775,7 +771,7 @@ adblock_resource_request_starting_cb (WebKitWebView* web_view,
page_uri = webkit_web_view_get_uri (web_view);
/* Skip checks on about: pages */
if (!(page_uri && *page_uri) || !strncmp (page_uri, "about:", 6))
if (midori_uri_is_blank (page_uri))
return;
/* Never filter the main page itself */
@ -784,21 +780,12 @@ adblock_resource_request_starting_cb (WebKitWebView* web_view,
return;
req_uri = webkit_network_request_get_uri (request);
if (!req_uri)
return;
if (!strncmp (req_uri, "data", 4) || !strncmp (req_uri, "file", 4))
return;
if (!strncmp (req_uri, "stock", 5) || !strncmp (req_uri, "res", 3))
return;
if (g_str_has_suffix (req_uri, "favicon.ico"))
if (!midori_uri_is_http (req_uri)
|| g_str_has_suffix (req_uri, "favicon.ico"))
return;
msg = webkit_network_request_get_message (request);
if (!msg)
return;
if (msg->method && !strncmp (msg->method, "POST", 4))
if (!(msg && !g_strcmp0 (msg->method, "GET")))
return;
#ifdef G_ENABLE_DEBUG
@ -828,6 +815,7 @@ adblock_custom_block_image_cb (GtkWidget* widget,
MidoriApp* app;
GtkWidget* browser;
GtkWidget* dialog;
GtkWidget* content_area;
GtkSizeGroup* sizegroup;
GtkWidget* hbox;
GtkWidget* label;
@ -839,21 +827,14 @@ adblock_custom_block_image_cb (GtkWidget* widget,
title = _("Edit rule");
dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (browser),
#if GTK_CHECK_VERSION(3,0,0)
GTK_DIALOG_DESTROY_WITH_PARENT,
#else
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
#endif
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_ADD, GTK_RESPONSE_ACCEPT,
NULL);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_ADD);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
#if GTK_CHECK_VERSION(3,0,0)
gtk_container_set_border_width (gtk_dialog_get_content_area (GTK_DIALOG (dialog)), 5);
#else
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 5);
#endif
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);
@ -866,11 +847,7 @@ adblock_custom_block_image_cb (GtkWidget* widget,
gtk_entry_set_text (GTK_ENTRY (entry),
g_object_get_data (G_OBJECT (widget), "uri"));
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
#if GTK_CHECK_VERSION(3,0,0)
gtk_container_add (gtk_dialog_get_content_area (GTK_DIALOG (dialog)), hbox);
#else
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox);
#endif
gtk_container_add (GTK_CONTAINER (content_area), hbox);
gtk_widget_show_all (hbox);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
@ -908,11 +885,7 @@ adblock_populate_popup_cb (WebKitWebView* web_view,
WebKitHitTestResultContext context;
WebKitHitTestResult* hit_test;
#if GTK_CHECK_VERSION(3,0,0)
gdk_window_get_pointer (gtk_widget_get_window(GTK_WIDGET (web_view)), &x, &y, NULL);
#else
gdk_window_get_pointer (GTK_WIDGET (web_view)->window, &x, &y, NULL);
#endif
event.x = x;
event.y = y;
hit_test = webkit_web_view_get_hit_test_result (web_view, &event);
@ -967,7 +940,7 @@ adblock_window_object_cleared_cb (WebKitWebView* web_view,
page_uri = webkit_web_view_get_uri (web_view);
/* Don't add adblock css into speeddial and about: pages */
if (!(page_uri && *page_uri) || !strncmp (page_uri, "about:", 6))
if (midori_uri_is_blank (page_uri))
return;
g_free (sokoke_js_script_eval (js_context, blockscript, NULL));
@ -1031,11 +1004,10 @@ adblock_app_add_browser_cb (MidoriApp* app,
g_object_unref (statusbar);
}
static gchar *
static GString*
adblock_fixup_regexp (const gchar* prefix,
gchar* src)
{
gchar* dst;
GString* str;
int len = 0;
@ -1056,14 +1028,12 @@ adblock_fixup_regexp (const gchar* prefix,
{
case '*':
g_string_append (str, ".*");
len += 2;
break;
/*case '.':
g_string_append (str, "\\.");
break;*/
case '?':
g_string_append (str, "\\?");
len += 2;
break;
case '|':
/* FIXME: We actually need to match :[0-9]+ or '/'. Sign means
@ -1074,31 +1044,36 @@ adblock_fixup_regexp (const gchar* prefix,
break;
default:
g_string_append_printf (str,"%c", *src);
len++;
break;
}
src++;
}
while (*src);
dst = g_string_free (str, FALSE);
len = str->len;
/* We dont need .* in the end of url. Thats stupid */
if (dst && dst[len-1] == '*' && dst[len-2] == '.')
dst[len-2] = '\0';
return dst;
if (str->str && str->str[len-1] == '*' && str->str[len-2] == '.')
g_string_erase (str, len-2, 2);
return str;
}
static void
adblock_compile_regexp (gchar* patt,
gchar* opts)
static gboolean
adblock_compile_regexp (GString* gpatt,
gchar* opts)
{
GRegex* regex;
GError* error = NULL;
int pos = 0;
gchar *sig;
gchar *patt;
int len;
if (!patt)
return;
if (!gpatt)
return FALSE;
patt = gpatt->str;
len = gpatt->len;
/* TODO: Play with optimization flags */
regex = g_regex_new (patt, G_REGEX_OPTIMIZE,
@ -1107,12 +1082,11 @@ adblock_compile_regexp (gchar* patt,
{
g_warning ("%s: %s", G_STRFUNC, error->message);
g_error_free (error);
return;
return TRUE;
}
if (!g_regex_match_simple ("^/.*[\\^\\$\\*].*/$", patt, G_REGEX_UNGREEDY, G_REGEX_MATCH_NOTEMPTY))
{
int len = strlen (patt);
int signature_count = 0;
for (pos = len - SIGNATURE_SIZE; pos >= 0; pos--) {
@ -1138,7 +1112,11 @@ adblock_compile_regexp (gchar* patt,
}
}
if (signature_count > 1 && g_hash_table_lookup (pattern, patt))
{
g_hash_table_steal (pattern, patt);
return TRUE;
}
return FALSE;
}
else
{
@ -1146,6 +1124,7 @@ adblock_compile_regexp (gchar* patt,
/* Pattern is a regexp chars */
g_hash_table_insert (pattern, patt, regex);
g_hash_table_insert (optslist, patt, g_strdup (opts));
return FALSE;
}
}
@ -1156,8 +1135,9 @@ adblock_add_url_pattern (gchar* prefix,
{
gchar** data;
gchar* patt;
gchar* format_patt;
GString* format_patt;
gchar* opts;
gboolean should_free;
data = g_strsplit (line, "$", -1);
if (!data || !data[0])
@ -1191,12 +1171,17 @@ adblock_add_url_pattern (gchar* prefix,
format_patt = adblock_fixup_regexp (prefix, patt);
adblock_debug ("got: %s opts %s", format_patt, opts);
adblock_compile_regexp (format_patt, opts);
adblock_debug ("got: %s opts %s", format_patt->str, opts);
should_free = adblock_compile_regexp (format_patt, opts);
g_free (opts);
g_free (patt);
return format_patt;
#if G_ENABLE_DEBUG
return g_string_free (format_patt, FALSE);
#else
return g_string_free (format_patt, should_free);
#endif
}
static inline void
@ -1354,6 +1339,7 @@ adblock_deactivate_cb (MidoriExtension* extension,
MidoriBrowser* browser)
{
MidoriApp* app = midori_extension_get_app (extension);
MidoriWebSettings* settings = katze_object_get_object (app, "settings");
g_signal_handlers_disconnect_by_func (
browser, adblock_open_preferences_cb, extension);
@ -1369,10 +1355,13 @@ adblock_deactivate_cb (MidoriExtension* extension,
g_string_free (blockcss, TRUE);
if (blockcssprivate)
g_string_free (blockcssprivate, TRUE);
midori_web_settings_remove_style (settings, "adblock-blockcss");
blockcssprivate = blockcss = NULL;
g_hash_table_destroy (pattern);
g_hash_table_destroy (optslist);
g_hash_table_destroy (urlcache);
g_object_unref (settings);
}
static void
@ -1502,7 +1491,7 @@ extension_init (void)
MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
"name", _("Advertisement blocker"),
"description", _("Block advertisements according to a filter list"),
"version", "0.5",
"version", "0.5" MIDORI_VERSION_SUFFIX,
"authors", "Christian Dywan <christian@twotoasts.de>",
NULL);
midori_extension_install_string_list (extension, "filters", NULL, G_MAXSIZE);

View file

@ -14,12 +14,9 @@
/* This extensions add support for user addons: userscripts and userstyles */
#include <midori/midori.h>
#include <midori/sokoke.h>
#include <glib.h>
#include <glib/gstdio.h>
#include "config.h"
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
@ -106,14 +103,13 @@ addons_install_response (GtkWidget* infobar,
const gchar* uri = midori_view_get_display_uri (view);
if (uri && *uri)
{
gchar** split_uri;
gchar* path, *filename, *hostname, *dest_path, *temp_uri, *folder_path;
gchar* hostname, *path;
gchar* dest_uri, *filename, *dest_path, *temp_uri, *folder_path;
const gchar* folder;
WebKitNetworkRequest* request;
WebKitDownload* download;
split_uri = g_strsplit (uri, "/", -1);
hostname = split_uri[2];
hostname = midori_uri_parse (uri, &path);
temp_uri = NULL;
filename = NULL;
folder = NULL;
@ -122,49 +118,51 @@ addons_install_response (GtkWidget* infobar,
folder = "scripts";
else if (g_str_has_suffix (uri, ".user.css"))
folder = "styles";
else if (!g_strcmp0 (hostname, "userscripts.org"))
else if (!strcmp (hostname, "userscripts.org"))
{
gchar* script_id;
const gchar* js_script;
WebKitWebView* web_view;
WebKitWebFrame* web_frame;
web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (view));
web_frame = webkit_web_view_get_main_frame (web_view);
js_script = "document.getElementById('heading').childNodes[3].childNodes[1].textContent";
if (WEBKIT_IS_WEB_FRAME (web_frame))
/* http://userscripts.org/scripts/ACTION/SCRIPT_ID/NAME */
gchar* subpage = strchr (strchr (path + 1, '/') + 1, '/');
if (subpage && subpage[0] == '/' && g_ascii_isdigit (subpage[1]))
{
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);
}
folder = "scripts";
script_id = split_uri[5];
/* rewrite uri to get source js */
temp_uri = g_strdup_printf ("http://%s/scripts/source/%s.user.js",
hostname, script_id);
uri = temp_uri;
}
else if (!g_strcmp0 (hostname, "userstyles.org"))
{
gchar* subpage = split_uri[4];
folder = "styles";
if ((subpage && *subpage) && g_ascii_isdigit (subpage[0]))
{
gchar* style_id;
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 (!strcmp (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);
@ -174,9 +172,11 @@ addons_install_response (GtkWidget* infobar,
g_free (value);
}
/* rewrite uri to get css */
style_id = split_uri[4];
temp_uri = g_strdup_printf ("http://%s/styles/%s.css", hostname, style_id);
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";
}
}
@ -187,22 +187,22 @@ addons_install_response (GtkWidget* infobar,
if (!g_file_test (folder_path, G_FILE_TEST_EXISTS))
katze_mkdir_with_parents (folder_path, 0700);
path = g_build_path (G_DIR_SEPARATOR_S, folder_path, filename, NULL);
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_path = g_filename_to_uri (path, NULL, NULL);
webkit_download_set_destination_uri (download, dest_path);
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 (path);
g_free (dest_uri);
g_free (temp_uri);
g_free (dest_path);
g_free (folder_path);
g_strfreev (split_uri);
g_free (hostname);
}
}
gtk_widget_destroy (GTK_WIDGET (infobar));
@ -256,27 +256,26 @@ addons_notify_load_status_cb (MidoriView* view,
addons_uri_install (view, ADDONS_USER_SCRIPTS);
else if (g_str_has_suffix (uri, ".user.css"))
addons_uri_install (view, ADDONS_USER_STYLES);
else if (g_str_has_prefix (uri, "http://userscripts.org/scripts/"))
else
{
gchar** split_uri = g_strsplit (uri, "/", -1);
gchar* subpage = split_uri[4];
/* userscripts.org script main (with desc) and "source view" pages */
if (!g_strcmp0 (subpage, "show") || !g_strcmp0 (subpage, "review"))
gchar* path;
gchar* hostname = midori_uri_parse (uri, &path);
if (!strcmp (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);
g_strfreev (split_uri);
}
else if (g_str_has_prefix (uri, "http://userstyles.org/styles/"))
{
gchar** split_uri = g_strsplit (uri, "/", -1);
gchar* subpage = split_uri[4];
/* userstyles.org style main page with style description */
if ((subpage && *subpage) && g_ascii_isdigit (subpage[0]))
addons_uri_install (view, ADDONS_USER_STYLES);
g_strfreev (split_uri);
}
else if (!strcmp (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);
}
}
}
@ -1021,19 +1020,19 @@ css_metadata_from_file (const gchar* filename,
rest_of_line = g_strdup (line);
rest_of_line = g_strstrip (rest_of_line);
line_has_meta = g_str_has_suffix (rest_of_line, "{") ? FALSE : TRUE;
line_has_meta = !g_str_has_suffix (rest_of_line, "{");
parts = g_strsplit (rest_of_line, " ", 0);
parts = g_strsplit_set (rest_of_line, " ,", 0);
i = 0;
while (parts[i] && (*parts[i] != '\0' && *parts[i] != '{'))
while (parts[i] && *parts[i] != '{')
{
gchar* value = NULL;
if (g_str_has_prefix (parts[i], "url-prefix("))
value = g_strdup (parts[i] + strlen ("url-prefix("));
value = &parts[i][strlen ("url-prefix(")];
else if (g_str_has_prefix (parts[i], "domain("))
value = g_strdup (parts[i] + strlen ("domain("));
value = &parts[i][strlen ("domain(")];
else if (g_str_has_prefix (parts[i], "url("))
value = g_strdup (parts[i] + strlen ("url("));
value = &parts[i][strlen ("url(")];
if (value)
{
guint begin, end;
@ -1048,14 +1047,14 @@ css_metadata_from_file (const gchar* filename,
++end;
domain = g_strndup (value + begin, end - begin * 2);
if (strncmp ("http", domain, 4))
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 (value);
g_free (domain);
}
i++;
@ -1077,6 +1076,7 @@ css_metadata_from_file (const gchar* filename,
static gboolean
addons_get_element_content (gchar* file_path,
AddonsKind kind,
gboolean has_metadata,
gchar** content)
{
gchar* file_content;
@ -1157,6 +1157,8 @@ addons_get_element_content (gchar* file_path,
g_string_append_c (content_chunks, file_content[i]);
}
if (has_metadata)
{
*content = g_strdup_printf (
"window.addEventListener ('DOMContentLoaded',"
"function () {"
@ -1170,6 +1172,12 @@ addons_get_element_content (gchar* file_path,
"}, 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)
@ -1253,7 +1261,7 @@ addons_update_elements (MidoriExtension* extension,
katze_assign (element->displayname, name);
if (!element->broken)
if (!addons_get_element_content (fullpath, kind,
if (!addons_get_element_content (fullpath, kind, FALSE,
&(element->script_content)))
element->broken = TRUE;
@ -1269,6 +1277,7 @@ addons_update_elements (MidoriExtension* extension,
if (!element->broken)
if (!addons_get_element_content (fullpath, kind,
element->includes || element->excludes,
&(element->script_content)))
element->broken = TRUE;
@ -1468,13 +1477,6 @@ addons_context_ready_cb (WebKitWebView* web_view,
return;
uri = katze_object_get_string (web_view, "uri");
/* Don't run scripts or styles on blank or special pages */
if (!(uri && *uri) || !strncmp (uri, "about:", 6))
{
g_free (uri);
return;
}
scripts_list = g_object_get_data (G_OBJECT (extension), "scripts-list");
scripts = scripts_list->elements;
while (scripts)
@ -1551,6 +1553,41 @@ addons_browser_destroy (MidoriBrowser* browser,
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)
{
@ -1573,6 +1610,10 @@ addons_new (AddonsKind kind, MidoriExtension* extension)
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;
}
@ -1673,12 +1714,14 @@ 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)
@ -1696,6 +1739,7 @@ addons_deactivate_cb (MidoriExtension* extension,
extension, addons_deactivate_cb, app);
g_object_unref (browsers);
g_object_unref (settings);
}
static gboolean
@ -1715,13 +1759,19 @@ addons_directory_monitor_changed (GFileMonitor* monitor,
GFileMonitorEvent flags,
MidoriExtension* extension)
{
char* basename;
GFileInfo* info;
GSource* source;
basename = g_file_get_basename (child);
if (g_str_has_prefix (basename, ".") ||
g_str_has_suffix (basename, "~")) /* Hidden or temporary files */
return;
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 */
@ -1782,18 +1832,24 @@ 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);
@ -1811,7 +1867,7 @@ extension_init (void)
MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
"name", _("User addons"),
"description", _("Support for userscripts and userstyles"),
"version", "0.1",
"version", "0.1" MIDORI_VERSION_SUFFIX,
"authors", "Arno Renevier <arno@renevier.net>",
NULL);
g_signal_connect (extension, "activate",

View file

@ -38,7 +38,7 @@ colorful_tabs_view_notify_uri_cb (MidoriView* view,
MidoriExtension* extension)
{
GtkWidget* label;
SoupURI* uri;
gchar* hostname;
gchar* colorstr;
GdkColor color;
GdkColor fgcolor;
@ -46,8 +46,9 @@ colorful_tabs_view_notify_uri_cb (MidoriView* view,
label = midori_view_get_proxy_tab_label (view);
if ((uri = soup_uri_new (midori_view_get_display_uri (view)))
&& uri->host && (katze_object_get_enum (view, "load-status") == MIDORI_LOAD_FINISHED))
if (!midori_uri_is_blank (midori_view_get_display_uri (view))
&& (hostname = midori_uri_parse (midori_view_get_display_uri (view), NULL))
&& katze_object_get_enum (view, "load-status") == MIDORI_LOAD_FINISHED)
{
icon = midori_view_get_icon (view);
@ -65,13 +66,13 @@ colorful_tabs_view_notify_uri_cb (MidoriView* view,
}
else
{
gchar* hash = g_compute_checksum_for_string (G_CHECKSUM_MD5, uri->host, 1);
gchar* hash = g_compute_checksum_for_string (G_CHECKSUM_MD5, hostname, 1);
colorstr = g_strndup (hash, 6 + 1);
g_free (hash);
colorstr[0] = '#';
gdk_color_parse (colorstr, &color);
}
soup_uri_free (uri);
g_free (hostname);
if ((color.red < 35000)
&& (color.green < 35000)
@ -200,7 +201,7 @@ extension_init (void)
MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
"name", _("Colorful Tabs"),
"description", _("Tint each tab distinctly"),
"version", "0.5",
"version", "0.5" MIDORI_VERSION_SUFFIX,
"authors", "Christian Dywan <christian@twotoasts.de>, Samuel Creshal <creshal@arcor.de>",
NULL);

View file

@ -9,12 +9,9 @@
See the file COPYING for the full license text.
*/
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <midori/midori.h>
#include <midori/gtkiconentry.h>
#include "katze/gtk3-compat.h"
#include <webkit/webkit.h>
#include <time.h>

View file

@ -34,7 +34,7 @@ MidoriExtension *extension_init(void)
MidoriExtension *extension = g_object_new(MIDORI_TYPE_EXTENSION,
"name", _("Cookie Manager"),
"description", _("List, view and delete cookies"),
"version", "0.2",
"version", "0.2" MIDORI_VERSION_SUFFIX,
"authors", "Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>",
NULL);

View file

@ -10,7 +10,6 @@
*/
#include <midori/midori.h>
#include <midori/sokoke.h>
static void
copy_tabs_apply_cb (GtkWidget* menuitem,
@ -95,7 +94,7 @@ 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",
"version", "0.1" MIDORI_VERSION_SUFFIX,
"authors", "MonkeyOfDoom <pixelmonkey@ensellitis.com>",
NULL);

View file

@ -12,13 +12,8 @@
#include "feed-panel.h"
#include <midori/midori.h>
#include <midori/sokoke.h>
#include <time.h>
#if HAVE_CONFIG_H
#include <config.h>
#endif
#define STOCK_FEED_PANEL "feed-panel"
struct _FeedPanel

View file

@ -363,21 +363,13 @@ panel_add_feed_cb (FeedPanel* panel,
dialog = gtk_dialog_new_with_buttons (
_("New feed"), GTK_WINDOW (priv->browser),
#if GTK_CHECK_VERSION(3,0,0)
GTK_DIALOG_DESTROY_WITH_PARENT,
#else
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
#endif
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);
#if GTK_CHECK_VERSION(3,0,0)
gtk_container_set_border_width (GTK_CONTAINER(gtk_dialog_get_content_area( GTK_DIALOG (dialog))), 5);
#else
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 5);
#endif
sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
hbox = gtk_hbox_new (FALSE, 8);
@ -389,11 +381,7 @@ panel_add_feed_cb (FeedPanel* panel,
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);
#if GTK_CHECK_VERSION(3,0,0)
gtk_container_add (GTK_CONTAINER(gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox);
#else
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox);
#endif
gtk_widget_show_all (hbox);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
@ -529,7 +517,7 @@ extension_init (void)
extension = g_object_new (MIDORI_TYPE_EXTENSION,
"name", _("Feed Panel"),
"description", _("Read Atom/ RSS feeds"),
"version", "0.1",
"version", "0.1" MIDORI_VERSION_SUFFIX,
"authors", "Dale Whittaker <dayul@users.sf.net>",
NULL);

View file

@ -12,11 +12,9 @@
#define MINCHARS 2
#include <midori/midori.h>
#include <glib/gstdio.h>
#include "config.h"
#include "midori/sokoke.h"
#include <glib/gstdio.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
@ -32,27 +30,22 @@ formhistory_toggle_state_cb (GtkAction* action,
static gboolean
formhistory_prepare_js ()
{
gchar* data_path;
gchar* autosuggest;
gchar* style;
guint i;
gchar* file;
data_path = g_build_filename (PACKAGE_NAME, "res", "autosuggestcontrol.js", NULL);
file = sokoke_find_data_filename (data_path);
file = sokoke_find_data_filename ("autosuggestcontrol.js", TRUE);
if (!g_file_get_contents (file, &autosuggest, NULL, NULL))
{
g_free (data_path);
g_free (file);
return FALSE;
}
g_strchomp (autosuggest);
katze_assign (data_path, g_build_filename (PACKAGE_NAME, "res", "autosuggestcontrol.css", NULL));
katze_assign (file, sokoke_find_data_filename (data_path));
katze_assign (file, sokoke_find_data_filename ("autosuggestcontrol.css", TRUE));
if (!g_file_get_contents (file, &style, NULL, NULL))
{
g_free (data_path);
g_free (file);
return FALSE;
}
@ -83,7 +76,6 @@ formhistory_prepare_js ()
autosuggest,
style);
g_strstrip (jsforms);
g_free (data_path);
g_free (file);
g_free (style);
g_free (autosuggest);
@ -572,7 +564,7 @@ extension_init (void)
if (formhistory_prepare_js ())
{
ver = "1.0";
ver = "1.0" MIDORI_VERSION_SUFFIX;
desc = g_strdup (_("Stores history of entered form data"));
}
else
@ -590,12 +582,11 @@ extension_init (void)
"authors", "Alexander V. Butenko <a.butenka@gmail.com>",
NULL);
midori_extension_install_boolean (extension, "always-load", TRUE);
g_free (desc);
if (should_init)
{
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",

View file

@ -133,8 +133,8 @@ namespace HistoryList {
int max_lines = 10;
#if HAVE_GTK3
requisition = Requisition();
get_preferred_width(out requisition.width, null);
get_preferred_height(out requisition.height, null);
this.treeview.get_preferred_width(out requisition.width, null);
this.treeview.get_preferred_height(out requisition.height, null);
#else
this.treeview.size_request (out requisition);
#endif
@ -233,9 +233,8 @@ namespace HistoryList {
this.hl_manager = manager;
this.title = _("Preferences for %s").printf( _("History-List"));
#if !HAVE_GTK3
this.has_separator = false;
#endif
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);
@ -569,7 +568,7 @@ namespace HistoryList {
internal Manager () {
GLib.Object (name: _("History List"),
description: _("Move to the last used tab when switching or closing tabs"),
version: "0.4",
version: "0.4" + Midori.VERSION_SUFFIX,
authors: "André Stösel <andre@stoesel.de>");
this.install_integer ("TabClosingBehavior", TabClosingBehavior.LAST);

View file

@ -300,7 +300,7 @@ extension_init (void)
MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
"name", _("Mouse Gestures"),
"description", _("Control Midori by moving the mouse"),
"version", "0.1",
"version", "0.1" MIDORI_VERSION_SUFFIX,
"authors", "Matthias Kruk <mkruk@matthiaskruk.de>", NULL);
midori_extension_install_integer (extension, "button", MOUSE_BUTTON_RIGHT);

View file

@ -11,7 +11,6 @@
#include <midori/midori.h>
#include <midori/sokoke.h>
#include "config.h"
static void
@ -176,11 +175,7 @@ shortcuts_get_preferences_dialog (MidoriExtension* extension)
dialog_title = _("Customize Keyboard shortcuts");
dialog = gtk_dialog_new_with_buttons (dialog_title, GTK_WINDOW (browser),
#if GTK_CHECK_VERSION(3,0,0)
GTK_DIALOG_DESTROY_WITH_PARENT,
#else
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
#endif
#if !HAVE_OSX
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
#endif
@ -193,11 +188,7 @@ shortcuts_get_preferences_dialog (MidoriExtension* extension)
g_signal_connect (dialog, "response",
G_CALLBACK (shortcuts_preferences_response_cb), NULL);
#if GTK_CHECK_VERSION(3,0,0)
dialog_vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
#else
dialog_vbox = GTK_DIALOG (dialog)->vbox;
#endif
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),
@ -260,11 +251,7 @@ shortcuts_get_preferences_dialog (MidoriExtension* extension)
0, GTK_SORT_ASCENDING);
g_object_unref (model);
#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_show_all (gtk_dialog_get_content_area(GTK_DIALOG (dialog)));
#else
gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);
#endif
g_object_unref (browser);
@ -334,7 +321,7 @@ extension_init (void)
MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
"name", _("Shortcuts"),
"description", _("View and edit keyboard shortcuts"),
"version", "0.1",
"version", "0.1" MIDORI_VERSION_SUFFIX,
"authors", "Christian Dywan <christian@twotoasts.de>",
NULL);

View file

@ -173,7 +173,7 @@ 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",
"version", "0.1" MIDORI_VERSION_SUFFIX,
"authors", "Arno Renevier <arno@renevier.net>",
NULL);
midori_extension_install_string (extension, "format", DEFAULT_FORMAT);

View file

@ -10,7 +10,6 @@
*/
#include <midori/midori.h>
#include <midori/sokoke.h>
typedef struct
{
@ -154,10 +153,10 @@ statusbar_features_app_add_browser_cb (MidoriApp* app,
gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
button = katze_property_proxy (settings, "identify-as", "custom-user-agent");
gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
button = gtk_combo_box_entry_new_text ();
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_append_text (GTK_COMBO_BOX (button), zoom_levels[i].label);
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (button), zoom_levels[i].label);
gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
g_signal_connect (button, "changed",
G_CALLBACK (statusbar_features_zoom_level_changed_cb), browser);
@ -192,7 +191,7 @@ 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",
"version", "0.1" MIDORI_VERSION_SUFFIX,
"authors", "Christian Dywan <christian@twotoasts.de>",
NULL);

View file

@ -10,7 +10,6 @@
*/
#include <midori/midori.h>
#include <midori/sokoke.h>
#define STOCK_TAB_PANEL "tab-panel"
@ -683,7 +682,7 @@ extension_init (void)
extension = g_object_new (MIDORI_TYPE_EXTENSION,
"name", _("Tab Panel"),
"description", _("Show tabs in a vertical panel"),
"version", "0.1",
"version", "0.1" MIDORI_VERSION_SUFFIX,
"authors", "Christian Dywan <christian@twotoasts.de>",
NULL);

View file

@ -10,7 +10,6 @@
*/
#include <midori/midori.h>
#include <midori/sokoke.h>
static void
tabs_minimized_app_add_browser_cb (MidoriApp* app,
@ -76,7 +75,7 @@ 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",
"version", "0.1" MIDORI_VERSION_SUFFIX,
"authors", "MonkeyOfDoom <pixelmonkey@ensellitis.com>",
NULL);

View file

@ -630,7 +630,7 @@ MidoriExtension *extension_init(void)
MidoriExtension* extension = g_object_new(MIDORI_TYPE_EXTENSION,
"name", _("Toolbar Editor"),
"description", _("Easily edit the toolbar layout"),
"version", "0.1",
"version", "0.1" MIDORI_VERSION_SUFFIX,
"authors", "Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>",
NULL);

View file

@ -11,12 +11,10 @@
*/
#include <midori/midori.h>
#include <midori/sokoke.h>
#include "config.h"
#include <glib/gstdio.h>
#include <stdlib.h>
#include "config.h"
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
@ -330,14 +328,8 @@ web_cache_mesage_got_headers_cb (SoupMessage* msg,
if (!web_cache_save_headers (msg, filename))
return;
#if GLIB_CHECK_VERSION (2, 20, 0)
ostream = (GOutputStream*)g_file_append_to (file,
G_FILE_CREATE_PRIVATE | G_FILE_CREATE_REPLACE_DESTINATION, NULL, NULL);
#else
g_unlink (filename);
ostream = (GOutputStream*)g_file_append_to (file,
G_FILE_CREATE_PRIVATE, NULL, NULL);
#endif
g_object_unref (file);
if (!ostream)
@ -360,7 +352,7 @@ web_cache_session_request_queued_cb (SoupSession* session,
SoupURI* soup_uri = soup_message_get_uri (msg);
gchar* uri = soup_uri_to_string (soup_uri, FALSE);
if (uri && g_str_has_prefix (uri, "http") && !g_strcmp0 (msg->method, "GET"))
if (midori_uri_is_http (uri) && !g_strcmp0 (msg->method, "GET"))
{
gchar* filename = web_cache_get_cached_path (extension, uri);
GHashTable* cache_headers;
@ -469,7 +461,7 @@ extension_init (void)
MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
"name", _("Web Cache"),
"description", _("Cache HTTP communication on disk"),
"version", "0.1",
"version", "0.1" MIDORI_VERSION_SUFFIX,
"authors", "Christian Dywan <christian@twotoasts.de>",
NULL);

143
katze/gtk3-compat.c Normal file
View file

@ -0,0 +1,143 @@
#include "katze/gtk3-compat.h"
#if !GTK_CHECK_VERSION (3, 2, 0) && !defined (HAVE_HILDON_2_2)
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);
}
}
static gboolean
sokoke_on_entry_focus_in_event (GtkEntry* entry,
GdkEventFocus* event,
gpointer userdata)
{
gint has_default = GPOINTER_TO_INT (
g_object_get_data (G_OBJECT (entry), "sokoke_has_default"));
if (has_default)
{
gtk_entry_set_text (entry, "");
g_object_set_data (G_OBJECT (entry), "sokoke_has_default",
GINT_TO_POINTER (0));
sokoke_widget_set_pango_font_style (GTK_WIDGET (entry),
PANGO_STYLE_NORMAL);
}
return FALSE;
}
static gboolean
sokoke_on_entry_focus_out_event (GtkEntry* entry,
GdkEventFocus* event,
gpointer userdata)
{
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");
gtk_entry_set_text (entry, default_text);
g_object_set_data (G_OBJECT (entry),
"sokoke_has_default", GINT_TO_POINTER (1));
sokoke_widget_set_pango_font_style (GTK_WIDGET (entry),
PANGO_STYLE_ITALIC);
}
return FALSE;
}
static void
sokoke_on_entry_drag_data_received (GtkEntry* entry,
GdkDragContext* drag_context,
gint x,
gint y,
guint timestamp,
gpointer user_data)
{
sokoke_on_entry_focus_in_event (entry, NULL, NULL);
}
void
gtk_entry_set_placeholder_text (GtkEntry* entry,
const gchar* default_text)
{
/* Note: The default text initially overwrites any previous text */
gchar* old_value = g_object_get_data (G_OBJECT (entry),
"sokoke_default_text");
if (!old_value)
{
g_object_set_data (G_OBJECT (entry), "sokoke_has_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-data-received",
G_CALLBACK (sokoke_on_entry_drag_data_received), NULL);
g_signal_connect (entry, "focus-in-event",
G_CALLBACK (sokoke_on_entry_focus_in_event), NULL);
g_signal_connect (entry, "focus-out-event",
G_CALLBACK (sokoke_on_entry_focus_out_event), NULL);
}
else if (!gtk_widget_has_focus (GTK_WIDGET (entry)))
{
gint has_default = GPOINTER_TO_INT (
g_object_get_data (G_OBJECT (entry), "sokoke_has_default"));
if (has_default)
{
gtk_entry_set_text (entry, default_text);
sokoke_widget_set_pango_font_style (GTK_WIDGET (entry),
PANGO_STYLE_ITALIC);
}
}
g_object_set_data (G_OBJECT (entry), "sokoke_default_text",
(gpointer)default_text);
}
#endif
#if !GTK_CHECK_VERSION (2, 12, 0)
void
gtk_widget_set_has_tooltip (GtkWidget* widget,
gboolean has_tooltip)
{
/* Do nothing */
}
void
gtk_widget_set_tooltip_text (GtkWidget* widget,
const gchar* text)
{
if (text && *text)
{
static GtkTooltips* tooltips = NULL;
if (G_UNLIKELY (!tooltips))
tooltips = gtk_tooltips_new ();
gtk_tooltips_set_tip (tooltips, widget, text, NULL);
}
}
void
gtk_tool_item_set_tooltip_text (GtkToolItem* toolitem,
const gchar* text)
{
if (text && *text)
{
static GtkTooltips* tooltips = NULL;
if (G_UNLIKELY (!tooltips))
tooltips = gtk_tooltips_new ();
gtk_tool_item_set_tooltip (toolitem, tooltips, text, NULL);
}
}
#endif

View file

@ -4,9 +4,91 @@
#ifndef H_GTK3_COMPAT_20110110
#define H_GTK3_COMPAT_20110110
G_BEGIN_DECLS
#if !GLIB_CHECK_VERSION (2, 32, 0)
#define G_SOURCE_REMOVE FALSE
#define G_SOURCE_CONTINUE TRUE
#endif
#if !GLIB_CHECK_VERSION (2, 30, 0)
#define g_format_size(sz) g_format_size_for_display ((goffset)sz)
#endif
#if !GTK_CHECK_VERSION (2, 14, 0)
#define gtk_dialog_get_content_area(dlg) dlg->vbox
#define gtk_dialog_get_action_area(dlg) dlg->action_area
#define gtk_widget_get_window(wdgt) wdgt->window
#define gtk_adjustment_get_page_size(adj) adj->page_size
#define gtk_adjustment_get_upper(adj) adj->upper
#define gtk_adjustment_get_lower(adj) adj->lower
#define gtk_adjustment_get_value(adj) adj->value
#endif
#if !GTK_CHECK_VERSION (2, 16, 0)
#define GTK_ACTIVATABLE GTK_WIDGET
#define gtk_activatable_get_related_action gtk_widget_get_action
#define gtk_menu_item_set_label(menuitem, label) \
gtk_label_set_label (GTK_LABEL (GTK_BIN (menuitem)->child), \
label ? label : "");
#define gtk_image_menu_item_set_always_show_image(menuitem, yesno) ()
#endif
#if !GTK_CHECK_VERSION (2, 18, 0)
#define gtk_widget_is_toplevel(widget) GTK_WIDGET_TOPLEVEL (widget)
#define gtk_widget_has_focus(widget) GTK_WIDGET_HAS_FOCUS (widget)
#define gtk_widget_get_visible(widget) GTK_WIDGET_VISIBLE (widget)
#define gtk_widget_get_sensitive(widget) GTK_WIDGET_IS_SENSITIVE (widget)
#define gtk_widget_set_can_focus(widget,flag) \
GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS)
#define gtk_widget_get_allocation(wdgt, alloc) *alloc = wdgt->allocation
#define gtk_widget_get_has_window(wdgt) !GTK_WIDGET_NO_WINDOW (wdgt)
#define gtk_widget_get_allocation(wdgt, alloc) *alloc = wdgt->allocation
#define gtk_widget_set_window(wdgt, wndw) wdgt->window = wndw
#define gtk_widget_is_drawable GTK_WIDGET_DRAWABLE
#define gtk_widget_get_drawable GTK_WIDGET_VISIBLE
#define gtk_widget_set_has_window(wdgt, wnd) \
if (wnd) GTK_WIDGET_UNSET_FLAGS (wdgt, GTK_NO_WINDOW); \
else GTK_WIDGET_SET_FLAGS (wdgt, GTK_NO_WINDOW)
#endif
#if !GTK_CHECK_VERSION (2, 20, 0)
#define gtk_widget_get_realized(widget) GTK_WIDGET_REALIZED (widget)
#define gtk_widget_set_realized(wdgt, real) \
if (real) GTK_WIDGET_SET_FLAGS (wdgt, GTK_REALIZED); \
else GTK_WIDGET_UNSET_FLAGS (wdgt, GTK_REALIZED)
#endif
#if GTK_CHECK_VERSION (3, 0, 0)
#define GTK_DIALOG_NO_SEPARATOR 0
#endif
#if !GTK_CHECK_VERSION (3, 2, 0) && defined (HAVE_HILDON_2_2)
#define gtk_entry_set_placeholder_text hildon_gtk_entry_set_placeholder_text
#elif !GTK_CHECK_VERSION (3, 2, 0)
#define gtk_entry_set_placeholder_text sokoke_entry_set_default_text
#endif
#if !GTK_CHECK_VERSION(2, 12, 0)
void
gtk_widget_set_has_tooltip (GtkWidget* widget,
gboolean has_tooltip);
void
gtk_widget_set_tooltip_text (GtkWidget* widget,
const gchar* text);
void
gtk_tool_item_set_tooltip_text (GtkToolItem* toolitem,
const gchar* text);
#endif
#if !GTK_CHECK_VERSION (2, 24 ,0)
#define gtk_combo_box_text_append_text gtk_combo_box_append_text
#define gtk_combo_box_text_new gtk_combo_box_new_text
#define gtk_combo_box_text_new_with_entry gtk_combo_box_entry_new_text
#define gtk_combo_box_text_get_active_text gtk_combo_box_get_active_text
#define GTK_COMBO_BOX_TEXT GTK_COMBO_BOX
#define GtkComboBoxText GtkComboBox
@ -43,4 +125,6 @@
#define GDK_KEY_Return GDK_Return
#endif
G_END_DECLS
#endif

View file

@ -398,10 +398,8 @@ katze_array_action_generate_menu (KatzeArrayAction* array_action,
g_object_unref (icon);
}
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
#if GTK_CHECK_VERSION (2, 16, 0)
gtk_image_menu_item_set_always_show_image (
GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
#endif
gtk_menu_shell_append (menu, menuitem);
g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item);
if (KATZE_ITEM_IS_FOLDER (item))
@ -622,10 +620,8 @@ katze_array_action_proxy_create_menu_proxy_cb (GtkWidget* proxy,
g_object_unref (icon);
}
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
#if GTK_CHECK_VERSION (2, 16, 0)
gtk_image_menu_item_set_always_show_image (
GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
#endif
g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item);
if (KATZE_ITEM_IS_FOLDER (item))
{

View file

@ -14,16 +14,13 @@
#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>
#if !GTK_CHECK_VERSION (2, 14, 0)
#define gtk_dialog_get_content_area(dialog) dialog->vbox
#endif
struct _KatzeHttpAuth
{
GObject parent_instance;
@ -212,11 +209,7 @@ katze_http_auth_session_authenticate_cb (SoupSession* session,
dialog = gtk_dialog_new_with_buttons (_("Authentication Required"),
NULL,
#if GTK_CHECK_VERSION(3,0,0)
GTK_DIALOG_DESTROY_WITH_PARENT,
#else
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
#endif
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);

View file

@ -0,0 +1,298 @@
/*
Copyright (C) 2008-2010 Christian Dywan <christian@twotoasts.de>
Copyright (C) 2011 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.
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif
#include "katze-http-cookies-sqlite.h"
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <glib/gi18n.h>
#include <libsoup/soup.h>
#include <gtk/gtk.h>
#include <glib/gstdio.h>
#include <sqlite3.h>
#define QUERY_ALL "SELECT id, name, value, host, path, expiry, lastAccessed, isSecure, isHttpOnly FROM moz_cookies;"
#define CREATE_TABLE "CREATE TABLE moz_cookies (id INTEGER PRIMARY KEY, name TEXT, value TEXT, host TEXT, path TEXT,expiry INTEGER, lastAccessed INTEGER, isSecure INTEGER, isHttpOnly INTEGER)"
#define QUERY_INSERT "INSERT INTO moz_cookies VALUES(NULL, %Q, %Q, %Q, %Q, %d, NULL, %d, %d);"
#define QUERY_DELETE "DELETE FROM moz_cookies WHERE name=%Q AND host=%Q;"
enum {
COL_ID,
COL_NAME,
COL_VALUE,
COL_HOST,
COL_PATH,
COL_EXPIRY,
COL_LAST_ACCESS,
COL_SECURE,
COL_HTTP_ONLY,
N_COL,
};
struct _KatzeHttpCookiesSqlite
{
GObject parent_instance;
gchar* filename;
SoupCookieJar* jar;
sqlite3 *db;
guint counter;
};
struct _KatzeHttpCookiesSqliteClass
{
GObjectClass parent_class;
};
static void
katze_http_cookies_sqlite_session_feature_iface_init (SoupSessionFeatureInterface *iface,
gpointer data);
G_DEFINE_TYPE_WITH_CODE (KatzeHttpCookiesSqlite, katze_http_cookies_sqlite, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE,
katze_http_cookies_sqlite_session_feature_iface_init));
/* Cookie jar saving into sqlite database
Copyright (C) 2008 Diego Escalante Urrelo
Copyright (C) 2009 Collabora Ltd.
Mostly copied from libSoup 2.30, coding style retained */
static void
try_create_table (sqlite3 *db)
{
char *error = NULL;
if (sqlite3_exec (db, CREATE_TABLE, NULL, NULL, &error)) {
g_warning ("Failed to execute query: %s", error);
sqlite3_free (error);
}
}
static void
exec_query_with_try_create_table (sqlite3* db,
const char* sql,
int (*callback)(void*,int,char**,char**),
void *argument)
{
char *error = NULL;
gboolean try_create = TRUE;
try_exec:
if (sqlite3_exec (db, sql, callback, argument, &error)) {
if (try_create) {
try_create = FALSE;
try_create_table (db);
sqlite3_free (error);
error = NULL;
goto try_exec;
} else {
g_warning ("Failed to execute query: %s", error);
sqlite3_free (error);
}
}
}
static int
callback (void *data, int argc, char **argv, char **colname)
{
SoupCookie *cookie = NULL;
SoupCookieJar *jar = SOUP_COOKIE_JAR (data);
char *name, *value, *host, *path;
gint64 expire_time;
time_t now;
int max_age;
gboolean http_only = FALSE, secure = FALSE;
now = time (NULL);
name = argv[COL_NAME];
value = argv[COL_VALUE];
host = argv[COL_HOST];
path = argv[COL_PATH];
expire_time = g_ascii_strtoull (argv[COL_EXPIRY], NULL, 10);
if (now >= expire_time)
return 0;
max_age = (expire_time - now <= G_MAXINT ? expire_time - now : G_MAXINT);
http_only = (g_strcmp0 (argv[COL_HTTP_ONLY], "1") == 0);
secure = (g_strcmp0 (argv[COL_SECURE], "1") == 0);
cookie = soup_cookie_new (name, value, host, path, max_age);
if (secure)
soup_cookie_set_secure (cookie, TRUE);
if (http_only)
soup_cookie_set_http_only (cookie, TRUE);
soup_cookie_jar_add_cookie (jar, cookie);
return 0;
}
/* Follows sqlite3 convention; returns TRUE on error */
static gboolean
katze_http_cookies_sqlite_open_db (KatzeHttpCookiesSqlite* http_cookies)
{
char *error = NULL;
if (sqlite3_open (http_cookies->filename, &http_cookies->db)) {
sqlite3_close (http_cookies->db);
g_warning ("Can't open %s", http_cookies->filename);
return TRUE;
}
if (sqlite3_exec (http_cookies->db, "PRAGMA synchronous = OFF; PRAGMA secure_delete = 1;", NULL, NULL, &error)) {
g_warning ("Failed to execute query: %s", error);
sqlite3_free (error);
}
return FALSE;
}
static void
katze_http_cookies_sqlite_load (KatzeHttpCookiesSqlite* http_cookies)
{
if (http_cookies->db == NULL) {
if (katze_http_cookies_sqlite_open_db (http_cookies))
return;
}
exec_query_with_try_create_table (http_cookies->db, QUERY_ALL, callback, http_cookies->jar);
}
static void
katze_http_cookies_sqlite_jar_changed_cb (SoupCookieJar* jar,
SoupCookie* old_cookie,
SoupCookie* new_cookie,
KatzeHttpCookiesSqlite* http_cookies)
{
GObject* settings;
char *query;
time_t expires = 0; /* Avoid warning */
if (http_cookies->db == NULL) {
if (katze_http_cookies_sqlite_open_db (http_cookies))
return;
}
if (new_cookie && new_cookie->expires)
{
gint age;
expires = soup_date_to_time_t (new_cookie->expires);
settings = g_object_get_data (G_OBJECT (jar), "midori-settings");
age = katze_object_get_int (settings, "maximum-cookie-age");
if (age > 0)
{
SoupDate* max_date = soup_date_new_from_now (
age * SOUP_COOKIE_MAX_AGE_ONE_DAY);
if (soup_date_to_time_t (new_cookie->expires)
> soup_date_to_time_t (max_date))
soup_cookie_set_expires (new_cookie, max_date);
}
else
{
/* An age of 0 to SoupCookie means already-expired
A user choosing 0 days probably expects 1 hour. */
soup_cookie_set_max_age (new_cookie, SOUP_COOKIE_MAX_AGE_ONE_HOUR);
}
}
if (g_getenv ("MIDORI_COOKIES_DEBUG") != NULL)
http_cookies->counter++;
if (old_cookie) {
query = sqlite3_mprintf (QUERY_DELETE,
old_cookie->name,
old_cookie->domain);
exec_query_with_try_create_table (http_cookies->db, query, NULL, NULL);
sqlite3_free (query);
}
if (new_cookie && new_cookie->expires) {
query = sqlite3_mprintf (QUERY_INSERT,
new_cookie->name,
new_cookie->value,
new_cookie->domain,
new_cookie->path,
expires,
new_cookie->secure,
new_cookie->http_only);
exec_query_with_try_create_table (http_cookies->db, query, NULL, NULL);
sqlite3_free (query);
}
}
static void
katze_http_cookies_sqlite_attach (SoupSessionFeature* feature,
SoupSession* session)
{
KatzeHttpCookiesSqlite* http_cookies = (KatzeHttpCookiesSqlite*)feature;
const gchar* filename = g_object_get_data (G_OBJECT (feature), "filename");
SoupSessionFeature* jar = soup_session_get_feature (session, SOUP_TYPE_COOKIE_JAR);
g_return_if_fail (jar != NULL);
g_return_if_fail (filename != NULL);
katze_assign (http_cookies->filename, g_strdup (filename));
http_cookies->jar = g_object_ref (jar);
katze_http_cookies_sqlite_open_db (http_cookies);
katze_http_cookies_sqlite_load (http_cookies);
g_signal_connect (jar, "changed",
G_CALLBACK (katze_http_cookies_sqlite_jar_changed_cb), feature);
}
static void
katze_http_cookies_sqlite_detach (SoupSessionFeature* feature,
SoupSession* session)
{
KatzeHttpCookiesSqlite* http_cookies = (KatzeHttpCookiesSqlite*)feature;
katze_assign (http_cookies->filename, NULL);
katze_object_assign (http_cookies->jar, NULL);
sqlite3_close (http_cookies->db);
}
static void
katze_http_cookies_sqlite_session_feature_iface_init (SoupSessionFeatureInterface *iface,
gpointer data)
{
iface->attach = katze_http_cookies_sqlite_attach;
iface->detach = katze_http_cookies_sqlite_detach;
}
static void
katze_http_cookies_sqlite_finalize (GObject* object)
{
katze_http_cookies_sqlite_detach ((SoupSessionFeature*)object, NULL);
}
static void
katze_http_cookies_sqlite_class_init (KatzeHttpCookiesSqliteClass* class)
{
GObjectClass* gobject_class = (GObjectClass*)class;
gobject_class->finalize = katze_http_cookies_sqlite_finalize;
}
static void
katze_http_cookies_sqlite_init (KatzeHttpCookiesSqlite* http_cookies)
{
http_cookies->filename = NULL;
http_cookies->jar = NULL;
http_cookies->db = NULL;
http_cookies->counter = 0;
}

View file

@ -0,0 +1,42 @@
/*
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_COOKIES_SQLITE_H__
#define __KATZE_HTTP_COOKIES_SQLITE_H__
#include "katze-utils.h"
#include <glib-object.h>
G_BEGIN_DECLS
#define KATZE_TYPE_HTTP_COOKIES_SQLITE \
(katze_http_cookies_sqlite_get_type ())
#define KATZE_HTTP_COOKIES_SQLITE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), KATZE_TYPE_HTTP_COOKIES_SQLITE, KatzeHttpCookiesSqlite))
#define KATZE_HTTP_COOKIES_SQLITE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), KATZE_TYPE_HTTP_COOKIES_SQLITE, KatzeHttpCookiesSqliteClass))
#define KATZE_IS_HTTP_COOKIES_SQLITE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), KATZE_TYPE_HTTP_COOKIES_SQLITE))
#define KATZE_IS_HTTP_COOKIES_SQLITE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), KATZE_TYPE_HTTP_COOKIES_SQLITE))
#define KATZE_HTTP_COOKIES_SQLITE_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), KATZE_TYPE_HTTP_COOKIES_SQLITE, KatzeHttpCookiesSqliteClass))
typedef struct _KatzeHttpCookiesSqlite KatzeHttpCookiesSqlite;
typedef struct _KatzeHttpCookiesSqliteClass KatzeHttpCookiesSqliteClass;
GType
katze_http_cookies_sqlite_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __KATZE_HTTP_COOKIES_SQLITE_H__ */

View file

@ -18,6 +18,7 @@
#endif
#include "katze-net.h"
#include "midori-core.h"
#include <glib/gstdio.h>
#include <libsoup/soup.h>
@ -283,7 +284,7 @@ katze_net_load_uri (KatzeNet* net,
priv->user_data = user_data;
priv->request = request;
if (g_str_has_prefix (uri, "http://") || g_str_has_prefix (uri, "https://"))
if (midori_uri_is_http (uri))
{
msg = soup_message_new ("GET", uri);
if (status_cb)

View file

@ -23,10 +23,6 @@
#include <string.h>
#include <glib/gi18n.h>
#if !GTK_CHECK_VERSION (2, 14, 0)
#define gtk_dialog_get_content_area(dialog) dialog->vbox
#endif
struct _KatzePreferencesPrivate
{
#if HAVE_HILDON

View file

@ -18,26 +18,6 @@
#include "katze-scrolled.h"
#include "katze-utils.h"
#if !GTK_CHECK_VERSION (2, 14, 0)
#define gtk_adjustment_get_page_size(adj) adj->page_size
#define gtk_adjustment_get_upper(adj) adj->upper
#define gtk_adjustment_get_lower(adj) adj->lower
#define gtk_adjustment_get_value(adj) adj->value
#define gtk_widget_get_window(wdgt) wdgt->window
#endif
#if !GTK_CHECK_VERSION (2, 18, 0)
#define gtk_widget_set_window(wdgt, wndw) wdgt->window = wndw
#define gtk_widget_get_allocation(wdgt, alloc) *alloc = wdgt->allocation
#define gtk_widget_is_drawable GTK_WIDGET_DRAWABLE
#define gtk_widget_get_drawable GTK_WIDGET_VISIBLE
#define gtk_widget_get_visible(wdgt) GTK_WIDGET_VISIBLE (wdgt)
#endif
#if !GTK_CHECK_VERSION (2, 19, 6)
#define gtk_widget_set_realized(wdgt, real) \
if (real) GTK_WIDGET_SET_FLAGS (wdgt, GTK_REALIZED); \
else GTK_WIDGET_UNSET_FLAGS (wdgt, GTK_REALIZED)
#endif
#define DEFAULT_INTERVAL 50
#define DEFAULT_DECELERATION 0.7
#define DEFAULT_DRAGGING_STOPPED_DELAY 100

View file

@ -18,13 +18,6 @@
#define HAVE_SPINNER GTK_CHECK_VERSION (2, 20, 0)
#if !GTK_CHECK_VERSION (2, 18, 0)
#define gtk_widget_get_allocation(wdgt, alloc) *alloc = wdgt->allocation
#define gtk_widget_set_has_window(wdgt, wnd) \
if (wnd) GTK_WIDGET_UNSET_FLAGS (wdgt, GTK_NO_WINDOW); \
else GTK_WIDGET_SET_FLAGS (wdgt, GTK_NO_WINDOW)
#endif
struct _KatzeThrobber
{
#if HAVE_SPINNER

View file

@ -13,6 +13,7 @@
#include "katze-utils.h"
#include "katze-array.h"
#include "midori-core.h"
#include <glib/gstdio.h>
#include <glib/gi18n.h>
@ -32,14 +33,6 @@
#include <hildon/hildon.h>
#endif
#if !GTK_CHECK_VERSION (2, 14, 0)
#define gtk_widget_get_window(wdgt) wdgt->window
#endif
#if !GTK_CHECK_VERSION (2, 18, 0)
#define gtk_widget_get_has_window(wdgt) !GTK_WIDGET_NO_WINDOW (wdgt)
#define gtk_widget_get_allocation(wdgt, alloc) *alloc = wdgt->allocation
#endif
#define I_ g_intern_static_string
static void
@ -101,11 +94,7 @@ katze_app_info_get_commandline (GAppInfo* info)
{
const gchar* exe;
#if GLIB_CHECK_VERSION (2, 20, 0)
exe = g_app_info_get_commandline (info);
#else
exe = g_object_get_data (G_OBJECT (info), "katze-cmdline");
#endif
if (!exe)
exe = g_app_info_get_executable (info);
if (!exe)
@ -371,95 +360,6 @@ katze_app_info_get_all_for_category (const gchar* category)
return apps;
}
#if !GLIB_CHECK_VERSION (2, 20, 0)
/* Icon tokenization, for Glib < 2.20 */
static gboolean
g_icon_to_string_tokenized (GIcon *icon,
GString *s)
{
GPtrArray *tokens;
guint i;
if (G_IS_THEMED_ICON (icon))
{
guint n;
const char * const *names;
tokens = g_ptr_array_new ();
g_object_get (icon, "names", &names, NULL);
for (n = 0; names[n] != NULL; n++)
g_ptr_array_add (tokens, g_strdup (names[n]));
}
else if (G_IS_FILE_ICON (icon))
{
tokens = g_ptr_array_new ();
g_ptr_array_add (tokens,
g_file_get_uri (g_file_icon_get_file (G_FILE_ICON (icon))));
}
else
return FALSE;
g_string_append (s, g_type_name_from_instance ((GTypeInstance *)icon));
for (i = 0; i < tokens->len; i++)
{
char *token = g_ptr_array_index (tokens, i);
g_string_append_c (s, ' ');
g_string_append_uri_escaped (s, token, "!$&'()*+,;=:@/", TRUE);
g_free (token);
}
g_ptr_array_free (tokens, TRUE);
return TRUE;
}
/* GIcon serialization, for Glib < 2.20 */
static gchar *
g_icon_to_string (GIcon *icon)
{
gchar *ret = NULL;
g_return_val_if_fail (G_IS_ICON (icon), NULL);
if (G_IS_FILE_ICON (icon))
{
GFile *file = g_file_icon_get_file (G_FILE_ICON (icon));
if (g_file_is_native (file))
{
ret = g_file_get_path (file);
if (!g_utf8_validate (ret, -1, NULL))
{
g_free (ret);
ret = NULL;
}
}
else
ret = g_file_get_uri (file);
}
else if (G_IS_THEMED_ICON (icon))
{
const char * const *names;
g_object_get (icon, "names", &names, NULL);
if (names && names[0] && names[0][0] != '.' &&
g_utf8_validate (names[0], -1, NULL) && names[1] == NULL)
ret = g_strdup (names[0]);
}
if (ret == NULL)
{
GString *s = g_string_new (". ");
if (g_icon_to_string_tokenized (icon, s))
ret = g_string_free (s, FALSE);
else
g_string_free (s, TRUE);
}
return ret;
}
#endif
/**
* katze_property_proxy:
* @object: a #GObject
@ -744,9 +644,6 @@ katze_property_proxy (gpointer object,
info = g_app_info_create_from_commandline (string,
NULL, G_APP_INFO_CREATE_NONE, NULL);
#if !GLIB_CHECK_VERSION (2, 20, 0)
g_object_set_data (G_OBJECT (info), "katze-cmdline", string);
#endif
entry = gtk_entry_new ();
exe = g_app_info_get_executable (info);
if (exe && *exe && strcmp (exe, "%f"))
@ -1575,7 +1472,7 @@ katze_load_cached_icon (const gchar* uri,
g_return_val_if_fail (uri != NULL, NULL);
if (g_str_has_prefix (uri, "http://") || g_str_has_prefix (uri,"https://"))
if (midori_uri_is_http (uri))
{
guint i;
gchar* icon_uri;
@ -1622,12 +1519,7 @@ katze_uri_entry_changed_cb (GtkWidget* entry,
GtkWidget* other_widget)
{
const gchar* uri = gtk_entry_get_text (GTK_ENTRY (entry));
gboolean valid = g_str_has_prefix (uri, "http://")
|| g_str_has_prefix (uri, "https://")
|| g_str_has_prefix (uri, "file://")
|| g_str_has_prefix (uri, "data:")
|| g_str_has_prefix (uri, "about:")
|| g_str_has_prefix (uri, "javascript:");
gboolean valid = midori_uri_is_location (uri);
if (*uri && !valid)
{
GdkColor bg_color = { 0 };
@ -1644,7 +1536,7 @@ katze_uri_entry_changed_cb (GtkWidget* entry,
}
if (other_widget != NULL)
gtk_widget_set_sensitive (other_widget, *uri && valid);
gtk_widget_set_sensitive (other_widget, valid);
}
/**

View file

@ -14,6 +14,7 @@
#include "katze-http-auth.h"
#include "katze-http-cookies.h"
#include "katze-http-cookies-sqlite.h"
#include "katze-throbber.h"
#include "katze-utils.h"
#include "katze-item.h"

156
katze/midori-uri.vala Normal file
View file

@ -0,0 +1,156 @@
/*
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 {
public static string parse (string? uri, out string path) {
/* path may be null.
If there's no hostname, the original URI is returned */
if (uri == null)
return uri;
unowned string? hostname = uri.chr (-1, '/');
if (hostname == null || hostname[1] != '/'
|| hostname.chr (-1, ' ') != null)
return uri;
hostname = hostname.offset (2);
if (&path != null) {
if ((path = hostname.chr (-1, '/')) != null)
return hostname.split ("/")[0];
}
return hostname;
}
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 (uri, out path);
string encoded = hostname_to_ascii (hostname);
if (encoded != null) {
return (proto ?? "")
+ (proto != null ? "://" : "")
+ encoded + path;
}
return uri;
}
public static string unescape (string uri) {
/* Unescape, pass through + and %20 */
if (uri.chr (-1, '%') != null || uri.chr (-1, ' ') != null) {
/* Preserve %20 for pasting URLs into other windows */
string? unescaped = GLib.Uri.unescape_string (uri, "+");
if (unescaped == null)
return uri;
return unescaped.replace (" ", "%20");
}
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);
if (unescaped == null)
return uri;
else if (!unescaped.validate ())
return uri;
string path;
string hostname = parse (unescaped, out path);
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);
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)
|| 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_email (string? uri) {
return uri != null
&& (uri.chr (-1, '@') != null || uri.has_prefix ("mailto:"))
/* :// and @ together would mean login credentials */
&& uri.str ("://") == null;
}
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. */
return uri != null && uri[0].isdigit ()
&& (uri.chr (4, '.') != null || uri.chr (4, ':') != null);
}
public static bool is_valid (string? uri) {
return uri != null
&& uri.chr (-1, ' ') == null
&& (URI.is_location (uri) || uri.chr (-1, '.') != 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 delimiter = "#!md5!";
unowned string display = _("MD5-Checksum:");
GLib.ChecksumType type = GLib.ChecksumType.MD5;
unowned string? fragment = uri.str (delimiter);
if (fragment == null) {
delimiter = "#!sha1!";
display = _("SHA1-Checksum:");
type = GLib.ChecksumType.SHA1;
fragment = uri.str (delimiter);
}
if (fragment == null) {
type = (GLib.ChecksumType)int.MAX;
display = null;
}
if (&checksum != null)
checksum = fragment != null
? fragment.offset (delimiter.length) : null;
if (&label != null)
label = display;
return type;
}
}
}

View file

@ -1419,8 +1419,6 @@ icon_theme_changed (GtkIconEntry *entry)
gtk_icon_entry_set_icon_from_icon_name (entry, i, priv->icons[i].icon_name);
}
#if GLIB_CHECK_VERSION (2, 16, 0)
else if (priv->icons[i].storage_type == _GTK_IMAGE_GICON)
{
g_object_unref (priv->icons[i].pixbuf);
@ -1428,7 +1426,6 @@ icon_theme_changed (GtkIconEntry *entry)
gtk_icon_entry_set_icon_from_gicon (entry, i, priv->icons[i].gicon);
}
#endif
}
gtk_widget_queue_draw (GTK_WIDGET (entry));

View file

@ -21,10 +21,6 @@
#ifndef __GTK_ICON_ENTRY_H__
#define __GTK_ICON_ENTRY_H__
#if HAVE_CONFIG_H
#include <config.h>
#endif
#include <gio/gio.h>
#include <gtk/gtk.h>

View file

@ -10,19 +10,19 @@
See the file COPYING for the full license text.
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif
#include "midori.h"
#include "midori-app.h"
#include "midori-array.h"
#include "midori-bookmarks.h"
#include "midori-extension.h"
#include "midori-extensions.h"
#include "midori-history.h"
#include "midori-transfers.h"
#include "midori-panel.h"
#include "midori-platform.h"
#include "midori-preferences.h"
#include <midori/midori-core.h>
#include "sokoke.h"
#include <config.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
@ -31,6 +31,7 @@
#include <stdlib.h>
#include <string.h>
#include <glib/gstdio.h>
#include <glib/gi18n-lib.h>
#include <webkit/webkit.h>
#include <sqlite3.h>
@ -39,11 +40,6 @@
#include <libsoup/soup-cache.h>
#endif
#if ENABLE_NLS
#include <libintl.h>
#include <locale.h>
#endif
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
@ -61,12 +57,6 @@
#include <gdk/gdkx.h>
#endif
#ifdef G_OS_WIN32
#define LIBPREFIX ""
#else
#define LIBPREFIX "lib"
#endif
static gchar*
build_config_filename (const gchar* filename)
{
@ -212,6 +202,19 @@ settings_save_to_file (MidoriWebSettings* settings,
{
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 (!string)
string = g_strdup ("");
@ -613,6 +616,7 @@ settings_notify_cb (MidoriWebSettings* settings,
/* Skip state related properties to avoid disk IO */
if ((pspec && g_str_has_prefix (pspec->name, "last-window-"))
|| (pspec && g_str_has_prefix (pspec->name, "user-stylesheet-uri"))
|| (pspec && g_str_has_prefix (pspec->name, "last-panel-")))
return;
@ -726,13 +730,13 @@ midori_browser_show_preferences_cb (MidoriBrowser* browser,
}
g_object_unref (array);
scrolled = katze_scrolled_new (NULL, NULL);
addon = g_object_new (MIDORI_TYPE_EXTENSIONS, NULL);
scrolled = g_object_new (KATZE_TYPE_SCROLLED, "visible", TRUE, NULL);
/* For lack of a better way of keeping descriptions visible */
g_object_set (scrolled, "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);
g_object_set (addon, "app", app, NULL);
gtk_widget_show (scrolled);
page = katze_preferences_add_category (preferences,
_("Extensions"), STOCK_EXTENSIONS);
gtk_box_pack_start (GTK_BOX (page), scrolled, TRUE, TRUE, 4);
@ -754,6 +758,10 @@ midori_browser_privacy_preferences_cb (MidoriBrowser* browser,
katze_preferences_add_widget (preferences, button, "indented");
button = katze_property_proxy (settings, "maximum-cookie-age", "days");
katze_preferences_add_widget (preferences, button, "spanned");
#ifdef HAVE_LIBSOUP_2_29_91
button = katze_property_proxy (settings, "first-party-cookies-only", NULL);
katze_preferences_add_widget (preferences, button, "filled");
#endif
markup = g_strdup_printf ("<span size=\"smaller\">%s</span>",
_("Cookies store login data, saved games, "
@ -766,10 +774,8 @@ midori_browser_privacy_preferences_cb (MidoriBrowser* browser,
katze_preferences_add_widget (preferences, button, "indented");
button = katze_property_proxy (settings, "enable-html5-local-storage", NULL);
katze_preferences_add_widget (preferences, button, "spanned");
#if HAVE_LIBSOUP_2_27_90
button = katze_property_proxy (settings, "strip-referer", NULL);
katze_preferences_add_widget (preferences, button, "indented");
#endif
katze_preferences_add_widget (preferences, gtk_label_new (NULL), "indented");
button = katze_property_label (settings, "maximum-history-age");
katze_preferences_add_widget (preferences, button, "indented");
@ -787,19 +793,13 @@ midori_app_add_browser_cb (MidoriApp* app,
panel = katze_object_get_object (browser, "panel");
/* Bookmarks */
addon = g_object_new (MIDORI_TYPE_BOOKMARKS, "app", app, NULL);
gtk_widget_show (addon);
addon = g_object_new (MIDORI_TYPE_BOOKMARKS, "app", app, "visible", TRUE, NULL);
midori_panel_append_page (MIDORI_PANEL (panel), MIDORI_VIEWABLE (addon));
/* History */
addon = g_object_new (MIDORI_TYPE_HISTORY, "app", app, NULL);
gtk_widget_show (addon);
addon = g_object_new (MIDORI_TYPE_HISTORY, "app", app, "visible", TRUE, NULL);
midori_panel_append_page (MIDORI_PANEL (panel), MIDORI_VIEWABLE (addon));
/* Transfers */
addon = g_object_new (MIDORI_TYPE_TRANSFERS, "app", app, NULL);
gtk_widget_show (addon);
addon = g_object_new (MIDORI_TYPE_TRANSFERS, "app", app, "visible", TRUE, NULL);
midori_panel_append_page (MIDORI_PANEL (panel), MIDORI_VIEWABLE (addon));
/* Extensions */
@ -872,7 +872,7 @@ midori_soup_session_set_proxy_uri (SoupSession* session,
SoupURI* proxy_uri;
/* soup_uri_new expects a non-NULL string with a protocol */
if (uri && g_str_has_prefix (uri, "http://"))
if (midori_uri_is_http (uri))
proxy_uri = soup_uri_new (uri);
else if (uri && *uri)
{
@ -915,14 +915,31 @@ soup_session_settings_notify_http_proxy_cb (MidoriWebSettings* settings,
}
else if (proxy_type == MIDORI_PROXY_HTTP)
{
gchar* http_proxy = katze_object_get_string (settings, "http-proxy");
midori_soup_session_set_proxy_uri (session, http_proxy);
g_free (http_proxy);
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
midori_soup_session_set_proxy_uri (session, NULL);
}
#ifdef HAVE_LIBSOUP_2_29_91
static void
soup_session_settings_notify_first_party_cb (MidoriWebSettings* settings,
GParamSpec* pspec,
SoupSession* session)
{
void* jar = soup_session_get_feature (session, SOUP_TYPE_COOKIE_JAR);
gboolean yes = katze_object_get_boolean (settings, "first-party-cookies-only");
g_object_set (jar, "accept-policy",
yes ? SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY
: SOUP_COOKIE_JAR_ACCEPT_ALWAYS, NULL);
}
#endif
static void
midori_soup_session_settings_accept_language_cb (SoupSession* session,
SoupMessage* msg,
@ -950,7 +967,6 @@ midori_soup_session_settings_accept_language_cb (SoupSession* session,
soup_message_headers_append (msg->request_headers, "Accept-Language", accpt);
g_free (accpt);
#if HAVE_LIBSOUP_2_27_90
if (katze_object_get_boolean (settings, "strip-referer"))
{
const gchar* referer
@ -971,7 +987,6 @@ midori_soup_session_settings_accept_language_cb (SoupSession* session,
g_free (stripped_referer);
}
}
#endif
}
static void
@ -999,7 +1014,8 @@ midori_load_soup_session (gpointer settings)
"/etc/pki/tls/certs/ca-bundle.crt",
"/etc/ssl/certs/ca-certificates.crt",
"/etc/ssl/certs/ca-bundle.crt",
"/usr/local/share/certs/ca-root-nss.crt",
"/usr/local/share/certs/ca-root-nss.crt", /* FreeBSD */
"/var/lib/ca-certificates/ca-bundle.pem", /* openSUSE */
NULL
};
guint i;
@ -1030,6 +1046,12 @@ midori_load_soup_session (gpointer settings)
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);
#ifdef HAVE_LIBSOUP_2_29_91
if (g_object_class_find_property (G_OBJECT_GET_CLASS (settings),
"enable-file-access-from-file-uris")) /* WebKitGTK+ >= 1.1.21 */
g_signal_connect (settings, "notify::first-party-cookies-only",
G_CALLBACK (soup_session_settings_notify_first_party_cb), session);
#endif
g_signal_connect (session, "request-queued",
G_CALLBACK (midori_soup_session_settings_accept_language_cb), settings);
@ -1158,12 +1180,13 @@ midori_load_soup_session_full (gpointer settings)
SoupCookieJar* jar;
gchar* config_file;
SoupSessionFeature* feature;
gboolean have_new_cookies;
SoupSessionFeature* feature_import;
midori_load_soup_session (settings);
config_file = build_config_filename ("logins");
feature = g_object_new (KATZE_TYPE_HTTP_AUTH, "filename", config_file, NULL);
g_free (config_file);
soup_session_add_feature (session, feature);
g_object_unref (feature);
@ -1172,23 +1195,38 @@ midori_load_soup_session_full (gpointer settings)
soup_session_add_feature (session, SOUP_SESSION_FEATURE (jar));
g_object_unref (jar);
feature = g_object_new (KATZE_TYPE_HTTP_COOKIES, NULL);
config_file = build_config_filename ("cookies.txt");
katze_assign (config_file, build_config_filename ("cookies.db"));
have_new_cookies = g_access (config_file, F_OK) == 0;
feature = g_object_new (KATZE_TYPE_HTTP_COOKIES_SQLITE, NULL);
g_object_set_data_full (G_OBJECT (feature), "filename",
config_file, (GDestroyNotify)g_free);
soup_session_add_feature (session, feature);
g_object_unref (feature);
if (!have_new_cookies)
{
katze_assign (config_file, build_config_filename ("cookies.txt"));
if (g_access (config_file, F_OK) == 0)
{
g_message ("Importing cookies from txt to sqlite3");
feature_import = g_object_new (KATZE_TYPE_HTTP_COOKIES, NULL);
g_object_set_data_full (G_OBJECT (feature_import), "filename",
config_file, (GDestroyNotify)g_free);
soup_session_add_feature (session, SOUP_SESSION_FEATURE (feature_import));
soup_session_remove_feature (session, SOUP_SESSION_FEATURE (feature_import));
}
}
#if WEBKIT_CHECK_VERSION (1, 3, 11)
config_file = g_build_filename (g_get_user_cache_dir (),
PACKAGE_NAME, "web", NULL);
katze_assign (config_file, g_build_filename (g_get_user_cache_dir (),
PACKAGE_NAME, "web", NULL));
feature = SOUP_SESSION_FEATURE (soup_cache_new (config_file, 0));
g_free (config_file);
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));
#endif
g_free (config_file);
return FALSE;
}
@ -1393,7 +1431,7 @@ midori_load_session (gpointer data)
item = katze_array_get_nth_item (_session, 0);
}
midori_browser_set_current_page (browser, current);
if (!g_strcmp0 (katze_item_get_uri (item), ""))
if (midori_uri_is_blank (katze_item_get_uri (item)))
midori_browser_activate_action (browser, "Location");
g_object_unref (settings);
@ -1420,48 +1458,19 @@ midori_load_session (gpointer data)
return FALSE;
}
static gint
midori_run_script (const gchar* filename)
{
gchar* exception;
gchar* script;
GError* error;
if (!(filename))
{
g_print ("%s - %s\n", _("Midori"), _("No filename specified"));
return 1;
}
error = NULL;
if (g_file_get_contents (filename, &script, NULL, &error))
{
JSGlobalContextRef js_context = JSGlobalContextCreateInGroup (NULL, NULL);
if (sokoke_js_script_eval (js_context, script, &exception))
exception = NULL;
g_free (script);
JSGlobalContextRelease (js_context);
}
else if (error)
{
exception = g_strdup (error->message);
g_error_free (error);
}
else
exception = g_strdup (_("An unknown error occured."));
if (!exception)
return 0;
g_print ("%s - Exception: %s\n", filename, exception);
return 1;
}
#define HAVE_OFFSCREEN GTK_CHECK_VERSION (2, 20, 0)
static void
snapshot_load_finished_cb (GtkWidget* web_view,
WebKitWebFrame* web_frame,
gchar* filename)
{
#if HAVE_OFFSCREEN
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);
#else
GError* error;
GtkPrintOperation* operation = gtk_print_operation_new ();
@ -1477,6 +1486,7 @@ snapshot_load_finished_cb (GtkWidget* web_view,
}
g_object_unref (operation);
#endif
g_print (_("Snapshot saved to: %s\n"), filename);
gtk_main_quit ();
}
@ -1496,6 +1506,20 @@ midori_web_app_browser_notify_load_status_cb (MidoriBrowser* browser,
}
}
static MidoriBrowser*
midori_web_app_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_remove_config_file (gint clear_prefs,
gint flag,
@ -1529,9 +1553,9 @@ midori_prepare_uri (const gchar *uri)
uri_ready = sokoke_magic_uri (uri);
if (uri_ready)
return sokoke_uri_to_ascii (uri_ready);
return midori_uri_to_ascii (uri_ready);
return sokoke_uri_to_ascii (uri);
return midori_uri_to_ascii (uri);
}
#ifdef HAVE_SIGNAL_H
@ -1782,7 +1806,7 @@ midori_clear_saved_logins_cb (void)
g_unlink (path);
/* Form History database, written by the extension */
katze_assign (path, g_build_filename (sokoke_set_config_dir (NULL),
"extensions", LIBPREFIX "formhistory." G_MODULE_SUFFIX, "forms.db", NULL));
"extensions", MIDORI_MODULE_PREFIX "formhistory." G_MODULE_SUFFIX, "forms.db", NULL));
if (sqlite3_open (path, &db) == SQLITE_OK)
{
sqlite3_exec (db, "DELETE FROM forms", NULL, NULL, NULL);
@ -1948,24 +1972,6 @@ main (int argc,
#define midori_startup_timer(tmrmsg)
#endif
#if ENABLE_NLS
setlocale (LC_ALL, "");
if (g_getenv ("MIDORI_NLSPATH"))
bindtextdomain (GETTEXT_PACKAGE, g_getenv ("MIDORI_NLSPATH"));
else
#ifdef G_OS_WIN32
{
gchar* path = sokoke_find_data_filename ("locale");
bindtextdomain (GETTEXT_PACKAGE, path);
g_free (path);
}
#else
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
#endif
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
#endif
#ifdef HAVE_SIGNAL_H
#ifdef SIGHUP
signal (SIGHUP, &signal_handler);
@ -1981,8 +1987,7 @@ main (int argc,
#endif
#endif
/* Preserve argument vector */
sokoke_get_argv (argv);
midori_app_setup (argv);
/* Parse cli options */
webapp = NULL;
@ -2008,10 +2013,6 @@ main (int argc,
return 1;
}
/* libSoup uses threads, so we need to initialize threads. */
if (!g_thread_supported ()) g_thread_init (NULL);
sokoke_register_stock_items ();
if (config && !g_path_is_absolute (config))
{
g_critical (_("The specified configuration folder is invalid."));
@ -2082,8 +2083,14 @@ main (int argc,
gchar* filename;
gint fd;
GtkWidget* web_view;
#if HAVE_OFFSCREEN
GtkWidget* offscreen;
GdkScreen* screen;
fd = g_file_open_tmp ("snapshot-XXXXXX.png", &filename, &error);
#else
fd = g_file_open_tmp ("snapshot-XXXXXX.pdf", &filename, &error);
#endif
close (fd);
error = NULL;
@ -2100,6 +2107,16 @@ main (int argc,
}
web_view = webkit_web_view_new ();
#if HAVE_OFFSCREEN
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);
#endif
g_signal_connect (web_view, "load-finished",
G_CALLBACK (snapshot_load_finished_cb), filename);
webkit_web_view_open (WEBKIT_WEB_VIEW (web_view), snapshot);
@ -2129,17 +2146,23 @@ main (int argc,
#if WEBKIT_CHECK_VERSION (1, 3, 11)
sokoke_register_privacy_item ("web-cache", _("Web Cache"),
G_CALLBACK (midori_clear_web_cache_cb));
#endif
#if WEBKIT_CHECK_VERSION (1, 3, 13)
sokoke_register_privacy_item ("offline-appcache", _("Offline Application Cache"),
G_CALLBACK (midori_clear_offline_appcache_cb));
#endif
/* Web Application or Private Browsing support */
if (webapp || private)
if (webapp || private || run)
{
SoupSession* session = webkit_get_default_session ();
MidoriBrowser* browser = midori_browser_new ();
/* Update window icon according to page */
g_signal_connect (browser, "notify::load-status",
G_CALLBACK (midori_web_app_browser_notify_load_status_cb), NULL);
g_signal_connect (browser, "new-window",
G_CALLBACK (midori_web_app_browser_new_window_cb), NULL);
g_object_set_data (G_OBJECT (webkit_get_default_session ()),
"pass-through-console", (void*)1);
midori_startup_timer ("Browser: \t%f");
if (config)
@ -2164,12 +2187,17 @@ main (int argc,
g_object_set (settings,
"preferred-languages", "en",
"enable-private-browsing", TRUE,
#ifdef HAVE_LIBSOUP_2_29_91
"first-party-cookies-only", TRUE,
#endif
"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. */
#if WEBKIT_CHECK_VERSION (1, 3, 11)
"enable-dns-prefetching", FALSE,
#endif
"strip-referer", TRUE, NULL);
midori_browser_set_action_visible (browser, "Tools", FALSE);
midori_browser_set_action_visible (browser, "ClearPrivateData", FALSE);
@ -2187,23 +2215,59 @@ main (int argc,
G_CALLBACK (midori_soup_session_block_uris_cb),
g_strdup (block_uris));
if (run)
{
gchar* script = NULL;
error = NULL;
if (g_file_get_contents (uris ? *uris : NULL, &script, NULL, &error))
{
#if 0 /* HAVE_OFFSCREEN */
GtkWidget* offscreen = gtk_offscreen_window_new ();
#endif
gchar* msg = NULL;
GtkWidget* view = midori_view_new_with_title (NULL, settings, FALSE);
g_object_set (settings, "open-new-pages-in", MIDORI_NEW_PAGE_WINDOW, NULL);
midori_browser_add_tab (browser, view);
#if 0 /* HAVE_OFFSCREEN */
gtk_container_add (GTK_CONTAINER (offscreen), GTK_WIDGET (browser));
gtk_widget_show_all (offscreen);
#else
gtk_widget_show_all (GTK_WIDGET (browser));
gtk_widget_hide (GTK_WIDGET (browser));
#endif
midori_view_execute_script (MIDORI_VIEW (view), script, &msg);
if (msg != NULL)
{
g_error ("%s\n", msg);
g_free (msg);
}
}
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);
}
if (webapp)
{
gchar* tmp_uri = midori_prepare_uri (webapp);
midori_browser_set_action_visible (browser, "Menubar", FALSE);
midori_browser_add_uri (browser, tmp_uri);
g_object_set (settings, "homepage", tmp_uri, NULL);
g_free (tmp_uri);
g_object_set (settings,
"show-menubar", FALSE,
"show-navigationbar", FALSE,
"toolbar-items", "Back,Forward,ReloadStop,Location,Homepage",
"homepage", tmp_uri,
"show-statusbar", FALSE,
"enable-developer-extras", FALSE,
NULL);
midori_browser_set_action_visible (browser, "Menubar", FALSE);
midori_browser_add_uri (browser, tmp_uri);
g_free (tmp_uri);
/* Update window icon according to page */
g_signal_connect (browser, "notify::load-status",
G_CALLBACK (midori_web_app_browser_notify_load_status_cb), NULL);
}
g_object_set (settings, "show-panel", FALSE,
@ -2217,8 +2281,11 @@ main (int argc,
G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (browser, "destroy",
G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_show (GTK_WIDGET (browser));
midori_browser_activate_action (browser, "Location");
if (!run)
{
gtk_widget_show (GTK_WIDGET (browser));
midori_browser_activate_action (browser, "Location");
}
if (execute)
{
for (i = 0; uris[i] != NULL; i++)
@ -2247,22 +2314,7 @@ main (int argc,
if (inactivity_reset > 0)
g_error ("--inactivity-reset is currently only supported with --app.");
/* Standalone javascript support */
if (run)
return midori_run_script (uris ? *uris : NULL);
sokoke_set_config_dir (config);
if (config)
{
gchar* name_hash;
gchar* app_name;
name_hash = g_compute_checksum_for_string (G_CHECKSUM_MD5, config, -1);
app_name = g_strconcat ("midori", "_", name_hash, NULL);
g_free (name_hash);
app = g_object_new (MIDORI_TYPE_APP, "name", app_name, NULL);
g_free (app_name);
}
else
app = midori_app_new ();
katze_assign (config, (gchar*)sokoke_set_config_dir (NULL));
midori_startup_timer ("App created: \t%f");
@ -2497,7 +2549,9 @@ main (int argc,
else
g_file_set_contents (config_file, "RUNNING", -1, NULL);
if (back_from_crash && katze_object_get_boolean (settings, "show-crash-dialog"))
if (back_from_crash
&& katze_object_get_boolean (settings, "show-crash-dialog")
&& !katze_array_is_empty (_session))
diagnostic_dialog = TRUE;
if (diagnostic_dialog)
@ -2554,7 +2608,7 @@ main (int argc,
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_TRASH, "tabtrash.xbel");
midori_remove_config_file (clear_prefs, MIDORI_CLEAR_HISTORY, "tabtrash.xbel");
for (; data_items != NULL; data_items = g_list_next (data_items))
{

View file

@ -14,12 +14,17 @@
#endif
#include "midori-app.h"
#include "sokoke.h"
#include "midori-platform.h"
#include <string.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#if ENABLE_NLS
#include <libintl.h>
#include <locale.h>
#endif
#if HAVE_HILDON
#include <libosso.h>
#ifdef HAVE_HILDON_2_2
@ -669,8 +674,7 @@ midori_app_io_channel_watch_cb (GIOChannel* channel,
#endif
static MidoriAppInstance
midori_app_create_instance (MidoriApp* app,
const gchar* name)
midori_app_create_instance (MidoriApp* app)
{
MidoriAppInstance instance;
@ -706,8 +710,15 @@ midori_app_create_instance (MidoriApp* app,
GIOChannel* channel;
#endif
if (!name)
name = "midori";
if (!app->name)
{
const gchar* config = sokoke_set_config_dir (NULL);
gchar* name_hash;
name_hash = g_compute_checksum_for_string (G_CHECKSUM_MD5, config, -1);
app->name = g_strconcat ("midori", "_", name_hash, NULL);
g_free (name_hash);
g_object_notify (G_OBJECT (app), "name");
}
if (!(display = gdk_display_get_default ()))
return MidoriAppInstanceNull;
@ -715,10 +726,9 @@ midori_app_create_instance (MidoriApp* app,
display_name = g_strdup (gdk_display_get_name (display));
n = strlen (display_name);
for (i = 0; i < n; i++)
if (display_name[i] == ':' || display_name[i] == '.'
|| display_name[i] == '\\')
if (strchr (":.\\/", display_name[i]))
display_name[i] = '_';
instance_name = g_strdup_printf ("de.twotoasts.%s_%s", name, display_name);
instance_name = g_strdup_printf ("de.twotoasts.%s_%s", app->name, display_name);
#if HAVE_UNIQUE
instance = unique_app_new (instance_name, NULL);
@ -895,8 +905,6 @@ midori_app_get_property (GObject* object,
*
* Instantiates a new #MidoriApp singleton.
*
* Subsequent calls will ref the initial instance.
*
* Return value: a new #MidoriApp
**/
MidoriApp*
@ -926,7 +934,7 @@ midori_app_instance_is_running (MidoriApp* app)
g_return_val_if_fail (MIDORI_IS_APP (app), FALSE);
if (app->instance == MidoriAppInstanceNull)
app->instance = midori_app_create_instance (app, app->name);
app->instance = midori_app_create_instance (app);
#if HAVE_HILDON
/* FIXME: Determine if application is running already */
@ -1277,3 +1285,151 @@ midori_app_send_notification (MidoriApp* app,
}
#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 (gchar** argument_vector)
{
GtkIconSource* icon_source;
GtkIconSet* icon_set;
GtkIconFactory* factory;
gsize i;
typedef struct
{
const gchar* stock_id;
const gchar* label;
GdkModifierType modifier;
guint keyval;
const gchar* fallback;
} FatStockItem;
static FatStockItem items[] =
{
{ STOCK_EXTENSION, NULL, 0, 0, GTK_STOCK_CONVERT },
{ STOCK_IMAGE, NULL, 0, 0, GTK_STOCK_ORIENTATION_PORTRAIT },
{ STOCK_WEB_BROWSER, NULL, 0, 0, "gnome-web-browser" },
{ STOCK_NEWS_FEED, NULL, 0, 0, GTK_STOCK_INDEX },
{ STOCK_SCRIPT, NULL, 0, 0, GTK_STOCK_EXECUTE },
{ STOCK_STYLE, NULL, 0, 0, GTK_STOCK_SELECT_COLOR },
{ STOCK_TRANSFER, NULL, 0, 0, GTK_STOCK_SAVE },
{ STOCK_BOOKMARK, N_("_Bookmark"), 0, 0, GTK_STOCK_FILE },
{ STOCK_BOOKMARKS, N_("_Bookmarks"), GDK_CONTROL_MASK | GDK_SHIFT_MASK, GDK_KEY_B, GTK_STOCK_DIRECTORY },
{ STOCK_BOOKMARK_ADD, N_("Add Boo_kmark"), 0, 0, "stock_add-bookmark" },
{ STOCK_CONSOLE, N_("_Console"), 0, 0, GTK_STOCK_DIALOG_WARNING },
{ STOCK_EXTENSIONS, N_("_Extensions"), 0, 0, GTK_STOCK_CONVERT },
{ STOCK_HISTORY, N_("_History"), GDK_CONTROL_MASK | GDK_SHIFT_MASK, GDK_KEY_H, GTK_STOCK_SORT_ASCENDING },
{ STOCK_HOMEPAGE, N_("_Homepage"), 0, 0, GTK_STOCK_HOME },
{ STOCK_SCRIPTS, N_("_Userscripts"), 0, 0, GTK_STOCK_EXECUTE },
{ STOCK_TAB_NEW, N_("New _Tab"), 0, 0, GTK_STOCK_ADD },
{ STOCK_TRANSFERS, N_("_Transfers"), GDK_CONTROL_MASK | GDK_SHIFT_MASK, GDK_KEY_J, GTK_STOCK_SAVE },
{ STOCK_PLUGINS, N_("Netscape p_lugins"), 0, 0, GTK_STOCK_CONVERT },
{ STOCK_USER_TRASH, N_("_Closed Tabs"), 0, 0, "gtk-undo-ltr" },
{ STOCK_WINDOW_NEW, N_("New _Window"), 0, 0, GTK_STOCK_ADD },
{ GTK_STOCK_DIRECTORY, N_("New _Folder"), 0, 0, NULL },
};
/* Preserve argument vector */
sokoke_get_argv (argument_vector);
/* libSoup uses threads, therefore if WebKit is built with libSoup
* or Midori is using it, we need to initialize threads. */
if (!g_thread_supported ()) g_thread_init (NULL);
#if ENABLE_NLS
setlocale (LC_ALL, "");
if (g_getenv ("MIDORI_NLSPATH"))
bindtextdomain (GETTEXT_PACKAGE, g_getenv ("MIDORI_NLSPATH"));
else
#ifdef G_OS_WIN32
{
gchar* path = sokoke_find_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
g_type_init ();
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 ();
if (items[i].fallback)
{
gtk_icon_source_set_icon_name (icon_source, items[i].fallback);
items[i].fallback = NULL;
gtk_icon_set_add_source (icon_set, icon_source);
}
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 HAVE_HILDON
/* Maemo doesn't theme stock icons. So we map platform icons
to stock icons. These are all monochrome toolbar icons. */
typedef struct
{
const gchar* stock_id;
const gchar* icon_name;
} CompatItem;
static CompatItem compat_items[] =
{
{ GTK_STOCK_ADD, "general_add" },
{ GTK_STOCK_BOLD, "general_bold" },
{ GTK_STOCK_CLOSE, "general_close_b" },
{ GTK_STOCK_DELETE, "general_delete" },
{ GTK_STOCK_DIRECTORY, "general_toolbar_folder" },
{ GTK_STOCK_FIND, "general_search" },
{ GTK_STOCK_FULLSCREEN, "general_fullsize_b" },
{ GTK_STOCK_GO_BACK, "general_back" },
{ GTK_STOCK_GO_FORWARD, "general_forward" },
{ GTK_STOCK_GO_UP, "filemanager_folder_up" },
{ GTK_STOCK_GOTO_FIRST, "pdf_viewer_first_page" },
{ GTK_STOCK_GOTO_LAST, "pdf_viewer_last_page" },
{ GTK_STOCK_INFO, "general_information" },
{ GTK_STOCK_ITALIC, "general_italic" },
{ GTK_STOCK_JUMP_TO, "general_move_to_folder" },
{ GTK_STOCK_PREFERENCES,"general_settings" },
{ GTK_STOCK_REFRESH, "general_refresh" },
{ GTK_STOCK_SAVE, "notes_save" },
{ GTK_STOCK_STOP, "general_stop" },
{ GTK_STOCK_UNDERLINE, "notes_underline" },
{ GTK_STOCK_ZOOM_IN, "pdf_zoomin" },
{ GTK_STOCK_ZOOM_OUT, "pdf_zoomout" },
};
factory = gtk_icon_factory_new ();
for (i = 0; i < G_N_ELEMENTS (compat_items); i++)
{
icon_set = gtk_icon_set_new ();
icon_source = gtk_icon_source_new ();
gtk_icon_source_set_icon_name (icon_source, compat_items[i].icon_name);
gtk_icon_set_add_source (icon_set, icon_source);
gtk_icon_source_free (icon_source);
gtk_icon_factory_add (factory, compat_items[i].stock_id, icon_set);
gtk_icon_set_unref (icon_set);
}
gtk_icon_factory_add_default (factory);
g_object_unref (factory);
#endif
}

View file

@ -79,6 +79,9 @@ midori_app_send_notification (MidoriApp* app,
const gchar* title,
const gchar* message);
void
midori_app_setup (gchar** argument_vector);
G_END_DECLS
#endif /* __MIDORI_APP_H__ */

File diff suppressed because it is too large Load diff

View file

@ -12,12 +12,8 @@
#include "midori-extension.h"
#if HAVE_CONFIG_H
#include <config.h>
#endif
#include <katze/katze.h>
#include "sokoke.h"
#include "midori-platform.h"
#include <glib/gi18n.h>
G_DEFINE_TYPE (MidoriExtension, midori_extension, G_TYPE_OBJECT);
@ -294,7 +290,16 @@ midori_extension_activate_cb (MidoriExtension* extension,
if (error->code == G_FILE_ERROR_NOENT)
{
gchar* filename = g_object_get_data (G_OBJECT (extension), "filename");
gchar* folder = g_strconcat ("extensions/", filename, NULL);
gchar* folder;
if (g_str_has_prefix (filename, MIDORI_MODULE_PREFIX))
filename = &filename[strlen (MIDORI_MODULE_PREFIX)];
if (g_str_has_suffix (filename, G_MODULE_SUFFIX))
filename = g_strndup (filename,
strlen (filename) - strlen ("." G_MODULE_SUFFIX));
else
filename = g_strdup (filename);
folder = g_strconcat ("extensions/", filename, NULL);
g_free (filename);
katze_assign (config_file,
sokoke_find_config_filename (folder, "config"));
g_free (folder);
@ -420,8 +425,21 @@ midori_extension_set_property (GObject* object,
katze_assign (extension->priv->description, g_value_dup_string (value));
break;
case PROP_VERSION:
katze_assign (extension->priv->version, g_value_dup_string (value));
{
/* 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;

View file

@ -1,4 +1,4 @@
public class Midori.ExtensionsCoumn : Gtk.TreeViewColumn {
public class Midori.ExtensionsColumn : Gtk.TreeViewColumn {
public signal void row_clicked (Gtk.TreeView view, Gtk.TreePath path);
}

View file

@ -12,14 +12,13 @@
#include "midori-locationaction.h"
#include "gtk3-compat.h"
#include "gtkiconentry.h"
#include "marshal.h"
#include "sokoke.h"
#include "midori-browser.h"
#include "midori-searchaction.h"
#include "midori-platform.h"
#include <midori/midori-core.h>
#include "config.h"
#include <string.h>
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
@ -291,6 +290,15 @@ midori_location_action_popup_position (GtkWidget* popup,
GtkAllocation allocation;
gdk_window_get_origin (window, &wx, &wy);
if (!gtk_widget_get_has_window (widget))
{
GtkAllocation alloc;
gtk_widget_get_allocation (widget, &alloc);
wx += alloc.x;
wy += alloc.y;
}
gtk_widget_size_request (popup, &menu_req);
gtk_widget_size_request (widget, &widget_req);
@ -356,7 +364,22 @@ midori_location_action_popup_timeout_cb (gpointer data)
if (!action->entry || !gtk_widget_has_focus (action->entry) || !action->history)
return FALSE;
if (!(action->key && *action->key))
/* No completion when typing a search token */
if (action->search_engines != NULL)
{
gchar** parts = g_strsplit (action->key, " ", 2);
if (parts && *parts && parts[1]
&& katze_array_find_token (action->search_engines, *parts))
{
g_strfreev (parts);
midori_location_action_popdown_completion (action);
return FALSE;
}
g_strfreev (parts);
}
/* Empaty string or starting with a space means: no completion */
if (!(action->key && *action->key && *action->key != ' '))
{
midori_location_action_popdown_completion (action);
return FALSE;
@ -508,7 +531,7 @@ midori_location_action_popup_timeout_cb (gpointer data)
gchar* title;
GdkPixbuf* icon;
uri = sokoke_search_uri (katze_item_get_uri (item), action->key);
uri = midori_uri_for_search (katze_item_get_uri (item), action->key);
title = g_strdup_printf (_("Search with %s"), katze_item_get_name (item));
icon = midori_search_action_get_icon (item, action->treeview, NULL, FALSE);
gtk_list_store_insert_with_values (store, NULL, matches + i,
@ -731,6 +754,9 @@ midori_location_action_create_tool_item (GtkAction* action)
entry = gtk_icon_entry_new ();
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (entry),
GTK_ICON_ENTRY_PRIMARY, GTK_STOCK_FILE);
/* Work-around icon being activatable by default */
gtk_icon_entry_set_icon_highlight (GTK_ICON_ENTRY (entry),
GTK_ICON_ENTRY_PRIMARY, FALSE);
gtk_icon_entry_set_icon_highlight (GTK_ICON_ENTRY (entry),
GTK_ICON_ENTRY_SECONDARY, TRUE);
#endif
@ -1076,7 +1102,7 @@ midori_location_entry_render_text_cb (GtkCellLayout* layout,
keys = g_strsplit_set (key, " %", -1);
g_free (key);
uri_temp = sokoke_uri_unescape_string (uri_escaped);
uri_temp = midori_uri_unescape (uri_escaped);
g_free (uri_escaped);
uri = g_strescape (uri_temp, NULL);
g_free (uri_temp);
@ -1258,7 +1284,8 @@ midori_location_action_populate_popup_cb (GtkWidget* entry,
/* i18n: Right-click on Location, Open an URL from the clipboard */
menuitem = gtk_menu_item_new_with_mnemonic (_("Paste and p_roceed"));
gtk_widget_show (menuitem);
gtk_menu_shell_append (menu, menuitem);
/* Insert menu item after default Paste menu item */
gtk_menu_shell_insert (menu, menuitem, 3);
g_signal_connect (menuitem, "activate",
G_CALLBACK (midori_location_action_paste_proceed_cb), location_action);
}
@ -1503,14 +1530,6 @@ midori_location_action_set_icon_for_uri (MidoriLocationAction* location_action,
#endif
}
void
midori_location_action_set_title_for_uri (MidoriLocationAction* location_action,
const gchar* title,
const gchar* uri)
{
/* Nothing to do */
}
/**
* midori_location_action_set_search_engines:
* @location_action: a #MidoriLocationAction
@ -1589,27 +1608,6 @@ midori_location_action_set_secondary_icon (MidoriLocationAction* location_action
#endif
}
/**
* midori_location_action_delete_item_from_uri:
* @location_action: a #MidoriLocationAction
* @uri: a string
*
* Finds the item from the list matching @uri
* and removes it if it is the last instance.
**/
void
midori_location_action_delete_item_from_uri (MidoriLocationAction* location_action,
const gchar* uri)
{
/* Nothing to do */
}
void
midori_location_action_clear (MidoriLocationAction* location_action)
{
g_return_if_fail (MIDORI_IS_LOCATION_ACTION (location_action));
}
/**
* midori_location_action_set_security_hint:
* @location_action: a #MidoriLocationAction
@ -1656,7 +1654,7 @@ midori_location_action_set_security_hint (MidoriLocationAction* location_action,
}
else if (hint == MIDORI_SECURITY_TRUSTED)
{
gdk_color_parse ("#fcf19a", &bg_color);
gdk_color_parse ("#d1eeb9", &bg_color);
gdk_color_parse ("#000", &fg_color);
#if !HAVE_HILDON
if (gtk_icon_theme_has_icon (icon_theme, "lock-secure"))

View file

@ -11,17 +11,15 @@
#include "midori-panel.h"
#include "midori-browser.h"
#include "midori-platform.h"
#include "midori-view.h"
#include "midori-browser.h"
#include "marshal.h"
#include "sokoke.h"
#include <glib/gi18n.h>
#include "config.h"
#ifdef HAVE_HILDON_2_2
#include <hildon/hildon.h>
#endif

View file

@ -12,7 +12,10 @@
#ifndef __MIDORI_PLATFORM_H__
#define __MIDORI_PLATFORM_H__ 1
#include <gtk/gtk.h>
#include "midori/midori-stock.h"
#include "katze/gtk3-compat.h"
#include "midori/gtkiconentry.h"
#include "midori/sokoke.h"
/* Common behavior modifiers */
#define MIDORI_MOD_NEW_WINDOW(state) (state & GDK_SHIFT_MASK)
@ -34,4 +37,11 @@
&& MIDORI_MOD_NEW_TAB(((GdkEventButton*)evt)->state)) \
|| (((GdkEventButton*)evt)->button == 2))
#ifndef G_OS_WIN32
#define MIDORI_MODULE_PREFIX "lib"
#else
#define MIDORI_MODULE_PREFIX ""
#endif
#endif /* !__MIDORI_PLATFORM_H__ */

View file

@ -11,12 +11,7 @@
#include "midori-preferences.h"
#if HAVE_CONFIG_H
#include <config.h>
#endif
#include "sokoke.h"
#include "midori-stock.h"
#include "midori-platform.h"
#include <string.h>
#include <glib/gi18n.h>
@ -27,6 +22,7 @@
#include <libsoup/soup-cache.h>
#endif
#include <config.h>
#if HAVE_LIBNOTIFY
#include <libnotify/notify.h>
#endif
@ -296,7 +292,7 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
#define SPANNED_ADD(__widget) \
katze_preferences_add_widget (_preferences, __widget, "spanned")
/* Page "General" */
if (sokoke_is_app_or_private ())
if (!sokoke_is_app_or_private ())
{
PAGE_NEW (GTK_STOCK_HOME, _("Startup"));
FRAME_NEW (NULL);
@ -351,6 +347,8 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
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);
#endif
label = katze_property_label (settings, "preferred-encoding");
INDENTED_ADD (label);
@ -461,6 +459,14 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
g_signal_connect (settings, "notify::proxy-type",
G_CALLBACK (midori_preferences_notify_proxy_type_cb), entry);
midori_preferences_notify_proxy_type_cb (settings, NULL, entry);
label = katze_property_label (settings, "http-proxy-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 (settings, "notify::proxy-type",
G_CALLBACK (midori_preferences_notify_proxy_type_cb), entry);
midori_preferences_notify_proxy_type_cb (settings, NULL, entry);
#endif
#if WEBKIT_CHECK_VERSION (1, 3, 11)
if (soup_session_get_feature (webkit_get_default_session (), SOUP_TYPE_CACHE))

View file

@ -11,12 +11,11 @@
#include "midori-searchaction.h"
#include "gtk3-compat.h"
#include "gtkiconentry.h"
#include "marshal.h"
#include "sokoke.h"
#include "midori-platform.h"
#include "midori-core.h"
#include "config.h"
#include <string.h>
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
@ -407,11 +406,11 @@ midori_search_action_get_icon (KatzeItem* item,
const gchar** icon_name,
gboolean in_entry)
{
const gchar* icon;
const gchar* icon = katze_item_get_uri (item);
GdkScreen* screen;
GtkIconTheme* icon_theme;
if ((icon = katze_item_get_uri (item)) && (g_strstr_len (icon, 8, "://")))
if (midori_uri_is_resource (icon))
return katze_load_cached_icon (icon, widget);
if (icon_name == NULL)
@ -474,10 +473,8 @@ midori_search_action_icon_released_cb (GtkWidget* entry,
gtk_image_set_from_icon_name (GTK_IMAGE (image), icon_name,
GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
#if GTK_CHECK_VERSION (2, 16, 0)
gtk_image_menu_item_set_always_show_image (
GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
#endif
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
g_object_set_data (G_OBJECT (menuitem), "engine", item);
g_signal_connect (menuitem, "activate",
@ -539,7 +536,7 @@ midori_search_action_set_entry_icon (MidoriSearchAction* search_action,
else
gtk_icon_entry_set_icon_from_icon_name (GTK_ICON_ENTRY (entry),
GTK_ICON_ENTRY_PRIMARY, icon_name);
sokoke_entry_set_default_text (GTK_ENTRY (entry),
gtk_entry_set_placeholder_text (GTK_ENTRY (entry),
katze_item_get_name (search_action->current_item));
}
else
@ -547,7 +544,7 @@ midori_search_action_set_entry_icon (MidoriSearchAction* search_action,
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (entry),
GTK_ICON_ENTRY_PRIMARY,
GTK_STOCK_FIND);
sokoke_entry_set_default_text (GTK_ENTRY (entry), "");
gtk_entry_set_placeholder_text (GTK_ENTRY (entry), "");
}
}
@ -909,11 +906,7 @@ midori_search_action_get_editor (MidoriSearchAction* search_action,
dialog = gtk_dialog_new_with_buttons (
new_engine ? _("Add search engine") : _("Edit search engine"),
toplevel ? GTK_WINDOW (toplevel) : NULL,
#if GTK_CHECK_VERSION(3,0,0)
GTK_DIALOG_DESTROY_WITH_PARENT,
#else
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
#endif
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
new_engine ? GTK_STOCK_ADD : GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL);
@ -1308,11 +1301,7 @@ midori_search_action_get_dialog (MidoriSearchAction* search_action)
gtk_widget_get_toplevel (search_action->last_proxy) : NULL;
dialog = gtk_dialog_new_with_buttons (dialog_title,
toplevel ? GTK_WINDOW (toplevel) : NULL,
#if GTK_CHECK_VERSION(3,0,0)
GTK_DIALOG_DESTROY_WITH_PARENT,
#else
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
#endif
#if !HAVE_OSX
#if !HAVE_HILDON
GTK_STOCK_HELP, GTK_RESPONSE_HELP,

View file

@ -12,8 +12,6 @@
#ifndef __MIDORI_STOCK_H__
#define __MIDORI_STOCK_H__ 1
#include <gtk/gtk.h>
/* Custom stock items
We should distribute these
@ -32,8 +30,8 @@
#define STOCK_TRANSFERS "package"
#define STOCK_PLUGINS "gnome-mime-application-x-shockwave-flash"
#define STOCK_BOOKMARK_ADD "stock_add-bookmark"
#define STOCK_HOMEPAGE GTK_STOCK_HOME
#define STOCK_BOOKMARK_ADD "bookmark-new"
#define STOCK_HOMEPAGE "go-home"
#define STOCK_IMAGE "gnome-mime-image"
#define STOCK_NETWORK_OFFLINE "network-offline"
#define STOCK_SCRIPT "stock_script"

File diff suppressed because it is too large Load diff

View file

@ -18,18 +18,11 @@
G_BEGIN_DECLS
typedef enum
{
MIDORI_LOAD_PROVISIONAL,
MIDORI_LOAD_COMMITTED,
MIDORI_LOAD_FINISHED
} MidoriLoadStatus;
GType
midori_load_status_get_type (void) G_GNUC_CONST;
#define MIDORI_TYPE_LOAD_STATUS \
(midori_load_status_get_type ())
#define MIDORI_LOAD_PROVISIONAL WEBKIT_LOAD_PROVISIONAL
#define MIDORI_LOAD_COMMITTED WEBKIT_LOAD_COMMITTED
#define MIDORI_LOAD_FINISHED WEBKIT_LOAD_FINISHED
#define MidoriLoadStatus WebKitLoadStatus
#define MIDORI_TYPE_LOAD_STATUS WEBKIT_TYPE_LOAD_STATUS
typedef enum
{

View file

@ -1,5 +1,6 @@
/*
Copyright (C) 2008-2010 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
@ -17,14 +18,10 @@
#include <glib/gstdio.h>
#include <string.h>
#include <config.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#if HAVE_CONFIG_H
#include <config.h>
#endif
#if defined (G_OS_UNIX)
#include <sys/utsname.h>
#endif
@ -58,7 +55,7 @@ struct _MidoriWebSettings
gboolean zoom_text_and_images : 1;
gboolean find_while_typing : 1;
gboolean kinetic_scrolling : 1;
gboolean original_cookies_only : 1;
gboolean first_party_cookies_only : 1;
gboolean remember_last_visited_pages : 1;
MidoriProxy proxy_type : 2;
MidoriIdentity identify_as : 3;
@ -78,6 +75,7 @@ struct _MidoriWebSettings
gchar* news_aggregator;
gchar* location_entry_search;
gchar* http_proxy;
gint http_proxy_port;
#if WEBKIT_CHECK_VERSION (1, 3, 11)
gint maximum_cache_size;
#endif
@ -90,7 +88,11 @@ struct _MidoriWebSettings
gboolean enable_dns_prefetching;
#endif
gboolean strip_referer;
gboolean enforce_font_family;
gboolean flash_window_on_bg_tabs;
gchar* user_stylesheet_uri;
gchar* user_stylesheet_uri_cached;
GHashTable* user_stylesheets;
};
struct _MidoriWebSettingsClass
@ -156,11 +158,13 @@ enum
PROP_FIND_WHILE_TYPING,
PROP_KINETIC_SCROLLING,
PROP_MAXIMUM_COOKIE_AGE,
PROP_FIRST_PARTY_COOKIES_ONLY,
PROP_MAXIMUM_HISTORY_AGE,
PROP_PROXY_TYPE,
PROP_HTTP_PROXY,
PROP_HTTP_PROXY_PORT,
PROP_MAXIMUM_CACHE_SIZE,
PROP_IDENTIFY_AS,
PROP_USER_AGENT,
@ -170,6 +174,8 @@ enum
PROP_CLEAR_DATA,
PROP_ENABLE_DNS_PREFETCHING,
PROP_STRIP_REFERER,
PROP_ENFORCE_FONT_FAMILY,
PROP_USER_STYLESHEET_URI,
};
GType
@ -837,6 +843,28 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
0, G_MAXINT, 30,
flags));
/**
* MidoriWebSettings:first-party-cookies-only:
*
* Whether only first party cookies should be accepted.
* WebKitGTK+ 1.1.21 is required for this to work.
*
* Since: 0.4.2
*/
g_object_class_install_property (gobject_class,
PROP_FIRST_PARTY_COOKIES_ONLY,
g_param_spec_boolean (
"first-party-cookies-only",
_("Only accept Cookies from sites you visit"),
_("Block cookies sent by third-party websites"),
#ifdef HAVE_LIBSOUP_2_29_91
TRUE,
g_object_class_find_property (gobject_class, /* WebKitGTK+ >= 1.1.21 */
"enable-file-access-from-file-uris") ? flags : G_PARAM_READABLE));
#else
FALSE,
G_PARAM_READABLE));
#endif
g_object_class_install_property (gobject_class,
PROP_MAXIMUM_HISTORY_AGE,
@ -873,6 +901,23 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
NULL,
flags));
/**
* MidoriWebSettings:http-proxy-port:
*
* The proxy server port used for HTTP connections
*
* Since: 0.4.2
*/
g_object_class_install_property (gobject_class,
PROP_HTTP_PROXY_PORT,
g_param_spec_int (
"http-proxy-port",
_("Port"),
_("The proxy server port used for HTTP connections"),
1, 65535, 8080,
flags
));
#if WEBKIT_CHECK_VERSION (1, 3, 11)
/**
* MidoriWebSettings:maximum-cache-size:
@ -1008,7 +1053,30 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
_("Whether the \"Referer\" header should be shortened to the hostname"),
FALSE,
flags));
/**
* MidoriWebSettings:enforc-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_USER_STYLESHEET_URI,
g_param_spec_string (
"user-stylesheet-uri",
"User stylesheet URI",
"Load stylesheets from a local URI",
NULL,
flags));
}
static void
@ -1041,6 +1109,13 @@ notify_default_encoding_cb (GObject* object,
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)
{
@ -1048,9 +1123,13 @@ midori_web_settings_init (MidoriWebSettings* web_settings)
web_settings->http_proxy = NULL;
web_settings->open_popups_in_tabs = TRUE;
web_settings->kinetic_scrolling = TRUE;
web_settings->user_stylesheet_uri = web_settings->user_stylesheet_uri_cached = NULL;
web_settings->user_stylesheets = NULL;
g_signal_connect (web_settings, "notify::default-encoding",
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
@ -1068,15 +1147,20 @@ midori_web_settings_finalize (GObject* object)
katze_assign (web_settings->location_entry_search, NULL);
katze_assign (web_settings->http_proxy, 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);
}
#if (!HAVE_OSX && defined (G_OS_UNIX)) || defined (G_OS_WIN32)
static gchar*
get_sys_name (void)
get_sys_name (gchar** architecture)
{
static gchar* sys_name = NULL;
static gchar* sys_architecture = NULL;
if (!sys_name)
{
@ -1087,20 +1171,42 @@ get_sys_name (void)
#else
struct utsname name;
if (uname (&name) != -1)
sys_name = g_strdup(name.sysname);
{
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
static gchar*
generate_ident_string (MidoriWebSettings* web_settings,
MidoriIdentity identify_as)
/**
* midori_web_settings_get_system_name:
* @architecture: location of a string, or %NULL
* @platform: location of a string, or %NULL
*
* Determines the system name, architecture and platform.
* @architecturce can have a %NULL value.
*
* Returns: a string
*
* Since: 0.4.2
**/
const gchar*
midori_web_settings_get_system_name (gchar** architecture,
gchar** platform)
{
const gchar* platform =
if (architecture != NULL)
*architecture = NULL;
if (platform != NULL)
*platform =
#if HAVE_HILDON
"Maemo;"
#elif defined (G_OS_WIN32)
@ -1113,25 +1219,28 @@ generate_ident_string (MidoriWebSettings* web_settings,
"X11;";
#endif
const gchar* os =
return
#if HAVE_OSX
"Mac OS X";
#elif defined (G_OS_UNIX) || defined (G_OS_WIN32)
get_sys_name ();
get_sys_name (architecture);
#else
"Linux";
#endif
}
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 WEBKIT_USER_AGENT_MAJOR_VERSION
#define WEBKIT_USER_AGENT_MAJOR_VERSION 532
#define WEBKIT_USER_AGENT_MINOR_VERSION 1
#endif
const int webcore_major = WEBKIT_USER_AGENT_MAJOR_VERSION;
const int webcore_minor = WEBKIT_USER_AGENT_MINOR_VERSION;
@ -1166,6 +1275,14 @@ generate_ident_string (MidoriWebSettings* web_settings,
}
}
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,
@ -1354,6 +1471,9 @@ midori_web_settings_set_property (GObject* object,
case PROP_MAXIMUM_COOKIE_AGE:
web_settings->maximum_cookie_age = g_value_get_int (value);
break;
case PROP_FIRST_PARTY_COOKIES_ONLY:
web_settings->first_party_cookies_only = g_value_get_boolean (value);
break;
case PROP_MAXIMUM_HISTORY_AGE:
web_settings->maximum_history_age = g_value_get_int (value);
@ -1365,6 +1485,9 @@ midori_web_settings_set_property (GObject* object,
case PROP_HTTP_PROXY:
katze_assign (web_settings->http_proxy, g_value_dup_string (value));
break;
case PROP_HTTP_PROXY_PORT:
web_settings->http_proxy_port = g_value_get_int (value);
break;
#if WEBKIT_CHECK_VERSION (1, 3, 11)
case PROP_MAXIMUM_CACHE_SIZE:
web_settings->maximum_cache_size = g_value_get_int (value);
@ -1404,9 +1527,44 @@ midori_web_settings_set_property (GObject* object,
case PROP_STRIP_REFERER:
web_settings->strip_referer = g_value_get_boolean (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* css = g_strdup_printf ("* { font-family: %s !important; }",
font_family);
midori_web_settings_add_style (web_settings, "enforce-font-family", css);
g_free (font_family);
g_free (css);
}
else
midori_web_settings_remove_style (web_settings, "enforce-font-family");
break;
case PROP_FLASH_WINDOW_ON_BG_TABS:
web_settings->flash_window_on_bg_tabs = g_value_get_boolean (value);
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;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -1612,6 +1770,9 @@ midori_web_settings_get_property (GObject* object,
case PROP_MAXIMUM_COOKIE_AGE:
g_value_set_int (value, web_settings->maximum_cookie_age);
break;
case PROP_FIRST_PARTY_COOKIES_ONLY:
g_value_set_boolean (value, web_settings->first_party_cookies_only);
break;
case PROP_MAXIMUM_HISTORY_AGE:
g_value_set_int (value, web_settings->maximum_history_age);
@ -1623,6 +1784,9 @@ midori_web_settings_get_property (GObject* object,
case PROP_HTTP_PROXY:
g_value_set_string (value, web_settings->http_proxy);
break;
case PROP_HTTP_PROXY_PORT:
g_value_set_int (value, web_settings->http_proxy_port);
break;
#if WEBKIT_CHECK_VERSION (1, 3, 11)
case PROP_MAXIMUM_CACHE_SIZE:
g_value_set_int (value, web_settings->maximum_cache_size);
@ -1656,9 +1820,16 @@ midori_web_settings_get_property (GObject* object,
case PROP_STRIP_REFERER:
g_value_set_boolean (value, web_settings->strip_referer);
break;
case PROP_ENFORCE_FONT_FAMILY:
g_value_set_boolean (value, web_settings->enforce_font_family);
break;
case PROP_FLASH_WINDOW_ON_BG_TABS:
g_value_set_boolean (value, web_settings->flash_window_on_bg_tabs);
break;
case PROP_USER_STYLESHEET_URI:
g_value_take_string (value, katze_object_get_string (web_settings,
"WebKitWebSettings::user-stylesheet-uri"));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -1682,3 +1853,114 @@ midori_web_settings_new (void)
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);
g_object_set (G_OBJECT (settings), "WebKitWebSettings::user-stylesheet-uri", encoded, NULL);
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:
* @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:
* @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);
}
}
}

View file

@ -41,7 +41,7 @@ enum
MIDORI_CLEAR_COOKIES = 2, /* deprecated */
MIDORI_CLEAR_FLASH_COOKIES = 4, /* deprecated */
MIDORI_CLEAR_WEBSITE_ICONS = 8, /* deprecated */
MIDORI_CLEAR_TRASH = 16,
MIDORI_CLEAR_TRASH = 16, /* deprecated */
MIDORI_CLEAR_ON_QUIT = 32,
MIDORI_CLEAR_WEB_CACHE = 64, /* deprecated */
MIDORI_CLEAR_SESSION = 128,
@ -158,6 +158,19 @@ 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);
G_END_DECLS
#endif /* __MIDORI_WEB_SETTINGS_H__ */

View file

@ -20,11 +20,11 @@
#include "midori-panel.h"
#include "midori-preferences.h"
#include "midori-searchaction.h"
#include "midori-stock.h"
#include "midori-view.h"
#include "midori-viewable.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>

View file

@ -3,6 +3,8 @@
[CCode (cprefix = "Midori", lower_case_cprefix = "midori_")]
namespace Midori {
public const string VERSION_SUFFIX;
[CCode (cheader_filename = "midori/midori.h")]
public class App : GLib.Object {
public App ();

View file

@ -12,11 +12,8 @@
#ifndef __SYLPH_SOCKET_H__
#define __SYLPH_SOCKET_H__
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <glib.h>
#include "config.h"
#if HAVE_NETDB_H
# include <netdb.h>
#endif

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2007-2009 Christian Dywan <christian@twotoasts.de>
Copyright (C) 2007-2011 Christian Dywan <christian@twotoasts.de>
Copyright (C) 2009 Dale Whittaker <dayul@users.sf.net>
Copyright (C) 2009 Alexander Butenko <a.butenka@gmail.com>
@ -12,14 +12,11 @@
*/
#include "sokoke.h"
#include "gtk3-compat.h"
#if HAVE_CONFIG_H
#include <config.h>
#endif
#include "midori-stock.h"
#include "midori-core.h"
#include "midori-platform.h"
#include <config.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
@ -35,12 +32,6 @@
#include <glib/gprintf.h>
#include <glib/gstdio.h>
#if HAVE_LIBIDN
#include <stringprep.h>
#include <punycode.h>
#include <idna.h>
#endif
#ifdef HAVE_HILDON_FM
#include <hildon/hildon-file-chooser-dialog.h>
#endif
@ -52,44 +43,6 @@
#include <hildon-uri.h>
#endif
#if !GTK_CHECK_VERSION(2, 12, 0)
void
gtk_widget_set_has_tooltip (GtkWidget* widget,
gboolean has_tooltip)
{
/* Do nothing */
}
void
gtk_widget_set_tooltip_text (GtkWidget* widget,
const gchar* text)
{
if (text && *text)
{
static GtkTooltips* tooltips = NULL;
if (G_UNLIKELY (!tooltips))
tooltips = gtk_tooltips_new ();
gtk_tooltips_set_tip (tooltips, widget, text, NULL);
}
}
void
gtk_tool_item_set_tooltip_text (GtkToolItem* toolitem,
const gchar* text)
{
if (text && *text)
{
static GtkTooltips* tooltips = NULL;
if (G_UNLIKELY (!tooltips))
tooltips = gtk_tooltips_new ();
gtk_tool_item_set_tooltip (toolitem, tooltips, text, NULL);
}
}
#endif
static gchar*
sokoke_js_string_utf8 (JSStringRef js_string)
{
@ -615,162 +568,6 @@ sokoke_spawn_app (const gchar* uri,
g_free (command);
}
/**
* sokoke_hostname_from_uri:
* @uri: an URI string
* @path: location of a string, or %NULL
*
* Returns the hostname of the specified URI.
*
* If there is a path, it is stored in @path.
*
* Return value: a newly allocated hostname
**/
gchar*
sokoke_hostname_from_uri (const gchar* uri,
gchar** path)
{
gchar* hostname;
if ((hostname = strchr (uri, '/')))
{
gchar* pathname;
if (hostname[1] == '/')
hostname += 2;
if ((pathname = strchr (hostname, '/')))
{
if (path != NULL)
*path = pathname;
return g_strndup (hostname, pathname - hostname);
}
else
return g_strdup (hostname);
}
return g_strdup (uri);
}
/**
* sokoke_hostname_to_ascii:
* @uri: an URI string
*
* The specified hostname is encoded if it is not ASCII.
*
* If no IDN support is available at compile time,
* the hostname will be returned unaltered.
*
* Return value: a newly allocated hostname
**/
static gchar*
sokoke_hostname_to_ascii (const gchar* hostname)
{
#ifdef HAVE_LIBSOUP_2_27_90
return g_hostname_to_ascii (hostname);
#elif HAVE_LIBIDN
uint32_t* q;
char* encoded;
int rc;
if ((q = stringprep_utf8_to_ucs4 (hostname, -1, NULL)))
{
rc = idna_to_ascii_4z (q, &encoded, IDNA_ALLOW_UNASSIGNED);
free (q);
if (rc == IDNA_SUCCESS)
return encoded;
}
#endif
return g_strdup (hostname);
}
/**
* sokoke_uri_to_ascii:
* @uri: an URI string
*
* The specified URI is parsed and the hostname
* part of it is encoded if it is not ASCII.
*
* If no IDN support is available at compile time,
* the URI will be returned unaltered.
*
* Return value: a newly allocated URI
**/
gchar*
sokoke_uri_to_ascii (const gchar* uri)
{
gchar* proto = NULL;
gchar* path = NULL;
gchar* hostname;
gchar* encoded;
if (strchr (uri, '/') && (proto = strchr (uri, ':')))
{
gulong offset;
gchar* buffer;
offset = g_utf8_pointer_to_offset (uri, proto);
buffer = g_malloc0 (offset + 1);
g_utf8_strncpy (buffer, uri, offset);
proto = buffer;
}
hostname = sokoke_hostname_from_uri (uri, &path);
encoded = sokoke_hostname_to_ascii (hostname);
if (encoded)
{
gchar* res = g_strconcat (proto ? proto : "", proto ? "://" : "",
encoded, path, NULL);
g_free (encoded);
return res;
}
g_free (hostname);
return g_strdup (uri);
}
static gchar*
sokoke_idn_to_punycode (gchar* uri)
{
#if HAVE_LIBIDN
gchar* result = sokoke_uri_to_ascii (uri);
g_free (uri);
return result;
#else
return uri;
#endif
}
/**
* sokoke_search_uri:
* @uri: a search URI with or without %s
* @keywords: keywords
*
* Takes a search engine URI and inserts the specified
* keywords. The @keywords are percent encoded. If the
* search URI contains a %s they keywords are inserted
* in that place, otherwise appended to the URI.
*
* Return value: a newly allocated search URI
**/
gchar* sokoke_search_uri (const gchar* uri,
const gchar* keywords)
{
gchar* escaped;
gchar* search;
g_return_val_if_fail (keywords != NULL, NULL);
if (!uri)
return g_strdup (keywords);
escaped = g_uri_escape_string (keywords, ":/", TRUE);
if (strstr (uri, "%s"))
search = g_strdup_printf (uri, escaped);
else
search = g_strconcat (uri, escaped, NULL);
g_free (escaped);
return search;
}
static void
sokoke_resolve_hostname_cb (SoupAddress *address,
guint status,
@ -846,13 +643,6 @@ sokoke_magic_uri (const gchar* uri)
g_return_val_if_fail (uri, NULL);
/* Just return if it's a javascript: or mailto: uri */
if (!strncmp (uri, "javascript:", 11)
|| !strncmp (uri, "mailto:", 7)
|| sokoke_external_uri (uri)
|| !strncmp (uri, "data:", 5)
|| !strncmp (uri, "about:", 6))
return g_strdup (uri);
/* Add file:// if we have a local path */
if (g_path_is_absolute (uri))
return g_strconcat ("file://", uri, NULL);
@ -883,18 +673,15 @@ sokoke_magic_uri (const gchar* uri)
g_free (longitude);
return geo;
}
/* Do we have a protocol? */
if (g_strstr_len (uri, 8, "://"))
return sokoke_idn_to_punycode (g_strdup (uri));
/* Do we have an IP address? */
if (g_ascii_isdigit (uri[0]) && g_strstr_len (uri, 4, "."))
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_isalpha (search[1]))
return sokoke_idn_to_punycode (g_strconcat ("http://", uri, NULL));
return g_strconcat ("http://", uri, NULL);
if ((!strcmp (uri, "localhost") || strchr (uri, '/'))
&& sokoke_resolve_hostname (uri))
return g_strconcat ("http://", uri, NULL);
@ -908,7 +695,7 @@ sokoke_magic_uri (const gchar* uri)
{
search = g_strconcat ("http://", uri, NULL);
g_strfreev (parts);
return sokoke_idn_to_punycode (search);
return search;
}
}
g_strfreev (parts);
@ -916,94 +703,6 @@ sokoke_magic_uri (const gchar* uri)
return NULL;
}
/**
* sokoke_uri_unescape_string:
* @uri: an URI string
*
* Unescape @uri if needed, and pass through '+' and '%20'.
*
* Return value: a newly allocated URI
**/
gchar*
sokoke_uri_unescape_string (const gchar* uri)
{
if (strchr (uri,'%') || strchr (uri, ' '))
{
/* Preserve %20 for pasting URLs into other windows */
gchar* unescaped = g_uri_unescape_string (uri, "+");
if (!unescaped)
return g_strdup (uri);
gchar* spaced = sokoke_replace_variables (unescaped, " ", "%20", NULL);
g_free (unescaped);
return spaced;
}
return g_strdup (uri);
}
/**
* sokoke_format_uri_for_display:
* @uri: an URI string
*
* Formats an URI for display, for instance by converting
* percent encoded characters and by decoding punycode.
*
* Return value: a newly allocated URI
**/
gchar*
sokoke_format_uri_for_display (const gchar* uri)
{
if (uri && g_str_has_prefix (uri, "http://"))
{
gchar* unescaped = sokoke_uri_unescape_string (uri);
#ifdef HAVE_LIBSOUP_2_27_90
gchar* path = NULL;
gchar* hostname;
gchar* decoded;
if (!unescaped)
return g_strdup (uri);
else if (!g_utf8_validate (unescaped, -1, NULL))
{
g_free (unescaped);
return g_strdup (uri);
}
hostname = sokoke_hostname_from_uri (unescaped, &path);
decoded = g_hostname_to_unicode (hostname);
if (decoded)
{
gchar* result = g_strconcat ("http://", decoded, path, NULL);
g_free (unescaped);
g_free (decoded);
g_free (hostname);
return result;
}
g_free (hostname);
return unescaped;
#elif HAVE_LIBIDN
gchar* decoded;
if (!unescaped)
return g_strdup (uri);
else if (!g_utf8_validate (unescaped, -1, NULL))
{
g_free (unescaped);
return g_strdup (uri);
}
if (!idna_to_unicode_8z8z (unescaped, &decoded, 0) == IDNA_SUCCESS)
return unescaped;
g_free (unescaped);
return decoded;
#else
return unescaped;
#endif
}
return g_strdup (uri);
}
void
sokoke_combo_box_add_strings (GtkComboBox* combobox,
const gchar* label_first, ...)
@ -1030,13 +729,6 @@ void sokoke_widget_set_visible (GtkWidget* widget, gboolean visible)
gtk_widget_hide (widget);
}
void
sokoke_container_show_children (GtkContainer* container)
{
/* Show every child but not the container itself */
gtk_container_foreach (container, (GtkCallback)(gtk_widget_show_all), NULL);
}
typedef enum
{
SOKOKE_DESKTOP_UNTESTED,
@ -1158,107 +850,6 @@ sokoke_xfce_header_new (const gchar* icon,
return NULL;
}
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);
}
}
static gboolean
sokoke_on_entry_focus_in_event (GtkEntry* entry,
GdkEventFocus* event,
gpointer userdata)
{
gint has_default = GPOINTER_TO_INT (
g_object_get_data (G_OBJECT (entry), "sokoke_has_default"));
if (has_default)
{
gtk_entry_set_text (entry, "");
g_object_set_data (G_OBJECT (entry), "sokoke_has_default",
GINT_TO_POINTER (0));
sokoke_widget_set_pango_font_style (GTK_WIDGET (entry),
PANGO_STYLE_NORMAL);
}
return FALSE;
}
static gboolean
sokoke_on_entry_focus_out_event (GtkEntry* entry,
GdkEventFocus* event,
gpointer userdata)
{
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");
gtk_entry_set_text (entry, default_text);
g_object_set_data (G_OBJECT (entry),
"sokoke_has_default", GINT_TO_POINTER (1));
sokoke_widget_set_pango_font_style (GTK_WIDGET (entry),
PANGO_STYLE_ITALIC);
}
return FALSE;
}
static void
sokoke_on_entry_drag_data_received (GtkEntry* entry,
GdkDragContext* drag_context,
gint x,
gint y,
guint timestamp,
gpointer user_data)
{
sokoke_on_entry_focus_in_event (entry, NULL, NULL);
}
void
sokoke_entry_set_default_text (GtkEntry* entry,
const gchar* default_text)
{
/* Note: The default text initially overwrites any previous text */
gchar* old_value = g_object_get_data (G_OBJECT (entry),
"sokoke_default_text");
if (!old_value)
{
g_object_set_data (G_OBJECT (entry), "sokoke_has_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-data-received",
G_CALLBACK (sokoke_on_entry_drag_data_received), NULL);
g_signal_connect (entry, "focus-in-event",
G_CALLBACK (sokoke_on_entry_focus_in_event), NULL);
g_signal_connect (entry, "focus-out-event",
G_CALLBACK (sokoke_on_entry_focus_out_event), NULL);
}
else if (!gtk_widget_has_focus (GTK_WIDGET (entry)))
{
gint has_default = GPOINTER_TO_INT (
g_object_get_data (G_OBJECT (entry), "sokoke_has_default"));
if (has_default)
{
gtk_entry_set_text (entry, default_text);
sokoke_widget_set_pango_font_style (GTK_WIDGET (entry),
PANGO_STYLE_ITALIC);
}
}
g_object_set_data (G_OBJECT (entry), "sokoke_default_text",
(gpointer)default_text);
}
gchar*
sokoke_key_file_get_string_default (GKeyFile* key_file,
const gchar* group,
@ -1482,124 +1073,6 @@ sokoke_days_between (const time_t* day1,
return age;
}
/**
* sokoke_register_stock_items:
*
* Registers several custom stock items used throughout Midori.
**/
void
sokoke_register_stock_items (void)
{
GtkIconSource* icon_source;
GtkIconSet* icon_set;
GtkIconFactory* factory;
gsize i;
typedef struct
{
const gchar* stock_id;
const gchar* label;
GdkModifierType modifier;
guint keyval;
const gchar* fallback;
} FatStockItem;
static FatStockItem items[] =
{
{ STOCK_EXTENSION, NULL, 0, 0, GTK_STOCK_CONVERT },
{ STOCK_IMAGE, NULL, 0, 0, GTK_STOCK_ORIENTATION_PORTRAIT },
{ STOCK_WEB_BROWSER, NULL, 0, 0, "gnome-web-browser" },
{ STOCK_NEWS_FEED, NULL, 0, 0, GTK_STOCK_INDEX },
{ STOCK_SCRIPT, NULL, 0, 0, GTK_STOCK_EXECUTE },
{ STOCK_STYLE, NULL, 0, 0, GTK_STOCK_SELECT_COLOR },
{ STOCK_TRANSFER, NULL, 0, 0, GTK_STOCK_SAVE },
{ STOCK_BOOKMARK, N_("_Bookmark"), 0, 0, GTK_STOCK_FILE },
{ STOCK_BOOKMARKS, N_("_Bookmarks"), GDK_CONTROL_MASK | GDK_SHIFT_MASK, GDK_KEY_B, GTK_STOCK_DIRECTORY },
{ STOCK_BOOKMARK_ADD, N_("Add Boo_kmark"), 0, 0, GTK_STOCK_ADD },
{ STOCK_CONSOLE, N_("_Console"), 0, 0, GTK_STOCK_DIALOG_WARNING },
{ STOCK_EXTENSIONS, N_("_Extensions"), 0, 0, GTK_STOCK_CONVERT },
{ STOCK_HISTORY, N_("_History"), GDK_CONTROL_MASK | GDK_SHIFT_MASK, GDK_KEY_H, GTK_STOCK_SORT_ASCENDING },
{ STOCK_HOMEPAGE, N_("_Homepage"), 0, 0, GTK_STOCK_HOME },
{ STOCK_SCRIPTS, N_("_Userscripts"), 0, 0, GTK_STOCK_EXECUTE },
{ STOCK_TAB_NEW, N_("New _Tab"), 0, 0, GTK_STOCK_ADD },
{ STOCK_TRANSFERS, N_("_Transfers"), GDK_CONTROL_MASK | GDK_SHIFT_MASK, GDK_KEY_J, GTK_STOCK_SAVE },
{ STOCK_PLUGINS, N_("Netscape p_lugins"), 0, 0, GTK_STOCK_CONVERT },
{ STOCK_USER_TRASH, N_("_Closed Tabs"), 0, 0, "gtk-undo-ltr" },
{ STOCK_WINDOW_NEW, N_("New _Window"), 0, 0, GTK_STOCK_ADD },
{ GTK_STOCK_DIRECTORY, N_("New _Folder"), 0, 0, NULL },
};
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 ();
if (items[i].fallback)
{
gtk_icon_source_set_icon_name (icon_source, items[i].fallback);
items[i].fallback = NULL;
gtk_icon_set_add_source (icon_set, icon_source);
}
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 HAVE_HILDON
/* Maemo doesn't theme stock icons. So we map platform icons
to stock icons. These are all monochrome toolbar icons. */
typedef struct
{
const gchar* stock_id;
const gchar* icon_name;
} CompatItem;
static CompatItem compat_items[] =
{
{ GTK_STOCK_ADD, "general_add" },
{ GTK_STOCK_BOLD, "general_bold" },
{ GTK_STOCK_CLOSE, "general_close_b" },
{ GTK_STOCK_DELETE, "general_delete" },
{ GTK_STOCK_DIRECTORY, "general_toolbar_folder" },
{ GTK_STOCK_FIND, "general_search" },
{ GTK_STOCK_FULLSCREEN, "general_fullsize_b" },
{ GTK_STOCK_GO_BACK, "general_back" },
{ GTK_STOCK_GO_FORWARD, "general_forward" },
{ GTK_STOCK_GO_UP, "filemanager_folder_up" },
{ GTK_STOCK_GOTO_FIRST, "pdf_viewer_first_page" },
{ GTK_STOCK_GOTO_LAST, "pdf_viewer_last_page" },
{ GTK_STOCK_INFO, "general_information" },
{ GTK_STOCK_ITALIC, "general_italic" },
{ GTK_STOCK_JUMP_TO, "general_move_to_folder" },
{ GTK_STOCK_PREFERENCES,"general_settings" },
{ GTK_STOCK_REFRESH, "general_refresh" },
{ GTK_STOCK_SAVE, "notes_save" },
{ GTK_STOCK_STOP, "general_stop" },
{ GTK_STOCK_UNDERLINE, "notes_underline" },
{ GTK_STOCK_ZOOM_IN, "pdf_zoomin" },
{ GTK_STOCK_ZOOM_OUT, "pdf_zoomout" },
};
factory = gtk_icon_factory_new ();
for (i = 0; i < G_N_ELEMENTS (compat_items); i++)
{
icon_set = gtk_icon_set_new ();
icon_source = gtk_icon_source_new ();
gtk_icon_source_set_icon_name (icon_source, compat_items[i].icon_name);
gtk_icon_set_add_source (icon_set, icon_source);
gtk_icon_source_free (icon_source);
gtk_icon_factory_add (factory, compat_items[i].stock_id, icon_set);
gtk_icon_set_unref (icon_set);
}
gtk_icon_factory_add_default (factory);
g_object_unref (factory);
#endif
}
/**
* sokoke_set_config_dir:
* @new_config_dir: an absolute path, or %NULL
@ -1633,7 +1106,7 @@ sokoke_set_config_dir (const gchar* new_config_dir)
gboolean
sokoke_is_app_or_private (void)
{
return strcmp ("/", sokoke_set_config_dir (NULL));
return !strcmp ("/", sokoke_set_config_dir (NULL));
}
/**
@ -1765,8 +1238,11 @@ gchar* sokoke_find_lib_path (const gchar* folder)
* Return value: a newly allocated full path
**/
gchar*
sokoke_find_data_filename (const gchar* filename)
sokoke_find_data_filename (const gchar* filename,
gboolean res)
{
const gchar* res1 = res ? PACKAGE_NAME : "";
const gchar* res2 = res ? "res" : "";
const gchar* const* data_dirs = g_get_system_data_dirs ();
guint i = 0;
const gchar* data_dir;
@ -1774,7 +1250,7 @@ sokoke_find_data_filename (const gchar* filename)
#ifdef G_OS_WIN32
gchar* install_path = g_win32_get_package_installation_directory_of_module (NULL);
path = g_build_filename (install_path, "share", filename, NULL);
path = g_build_filename (install_path, "share", res1, res2, filename, NULL);
g_free (install_path);
if (g_access (path, F_OK) == 0)
return path;
@ -1782,19 +1258,19 @@ sokoke_find_data_filename (const gchar* filename)
g_free (path);
#endif
path = g_build_filename (g_get_user_data_dir (), filename, NULL);
path = g_build_filename (g_get_user_data_dir (), res1, res2, filename, NULL);
if (g_access (path, F_OK) == 0)
return path;
g_free (path);
while ((data_dir = data_dirs[i++]))
{
path = g_build_filename (data_dir, filename, NULL);
path = g_build_filename (data_dir, res1, res2, filename, NULL);
if (g_access (path, F_OK) == 0)
return path;
g_free (path);
}
return g_build_filename (MDATADIR, filename, NULL);
return g_build_filename (MDATADIR, res1, res2, filename, NULL);
}
/**
@ -1969,42 +1445,28 @@ sokoke_prefetch_uri (MidoriWebSettings* settings,
#define MAXHOSTS 50
static gchar* hosts = NULL;
static gint host_count = G_MAXINT;
SoupURI* s_uri;
if (!uri)
return FALSE;
gchar* hostname;
if (settings && !katze_object_get_boolean (settings, "enable-dns-prefetching"))
return FALSE;
s_uri = soup_uri_new (uri);
if (!s_uri || !s_uri->host)
return FALSE;
#if GLIB_CHECK_VERSION (2, 22, 0)
if (g_hostname_is_ip_address (s_uri->host))
#else
if (g_ascii_isdigit (s_uri->host[0]) && g_strstr_len (s_uri->host, 4, "."))
#endif
if (!(hostname = midori_uri_parse (uri, NULL))
|| !strcmp (hostname, uri)
|| g_hostname_is_ip_address (hostname)
|| !midori_uri_is_http (uri))
{
soup_uri_free (s_uri);
return FALSE;
}
if (!g_str_has_prefix (uri, "http"))
{
soup_uri_free (s_uri);
g_free (hostname);
return FALSE;
}
if (!hosts ||
!g_regex_match_simple (s_uri->host, hosts,
!g_regex_match_simple (hostname, hosts,
G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY))
{
SoupAddress* address;
gchar* new_hosts;
address = soup_address_new (s_uri->host, SOUP_ADDRESS_ANY_PORT);
address = soup_address_new (hostname, SOUP_ADDRESS_ANY_PORT);
soup_address_resolve_async (address, 0, 0, callback, user_data);
g_object_unref (address);
@ -2014,12 +1476,12 @@ sokoke_prefetch_uri (MidoriWebSettings* settings,
host_count = 0;
}
host_count++;
new_hosts = g_strdup_printf ("%s|%s", hosts, s_uri->host);
new_hosts = g_strdup_printf ("%s|%s", hosts, hostname);
katze_assign (hosts, new_hosts);
}
else if (callback)
callback (NULL, SOUP_STATUS_OK, user_data);
soup_uri_free (s_uri);
g_free (hostname);
return TRUE;
}
@ -2181,9 +1643,9 @@ sokoke_widget_copy_clipboard (GtkWidget* widget,
GtkClipboard* clipboard;
clipboard = gtk_clipboard_get_for_display (display, GDK_SELECTION_CLIPBOARD);
gtk_clipboard_set_text (clipboard, text, -1);
gtk_clipboard_set_text (clipboard, text ? text : "", -1);
clipboard = gtk_clipboard_get_for_display (display, GDK_SELECTION_PRIMARY);
gtk_clipboard_set_text (clipboard, text, -1);
gtk_clipboard_set_text (clipboard, text ? text : "", -1);
}
gchar*
@ -2230,8 +1692,8 @@ midori_download_prepare_tooltip_text (WebKitDownload* download)
minutes_str = g_strdup_printf (ngettext ("%d minute", "%d minutes", minutes_left), minutes_left);
seconds_str = g_strdup_printf (ngettext ("%d second", "%d seconds", seconds_left), seconds_left);
current = g_format_size_for_display (current_size);
total = g_format_size_for_display (total_size);
current = g_format_size (current_size);
total = g_format_size (total_size);
last_time = g_object_get_data (G_OBJECT (download), "last-time");
last_size = g_object_get_data (G_OBJECT (download), "last-size");
@ -2241,7 +1703,7 @@ midori_download_prepare_tooltip_text (WebKitDownload* download)
g_free (total);
if (time_elapsed != *last_time)
download_speed = g_format_size_for_display (
download_speed = g_format_size (
(current_size - *last_size) / (time_elapsed - *last_time));
else
/* i18n: Unknown number of bytes, used for transfer rate like ?B/s */

View file

@ -15,59 +15,7 @@
#include <JavaScriptCore/JavaScript.h>
#include <midori/midori-websettings.h>
#if !GLIB_CHECK_VERSION (2, 14, 0)
#define G_PARAM_STATIC_STRINGS \
(G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)
#endif
#if !GLIB_CHECK_VERSION (2, 18, 0)
#define g_content_type_from_mime_type(mtp) g_strdup (mtp)
#endif
#if !GTK_CHECK_VERSION (2, 14, 0)
#define gtk_dialog_get_content_area(dlg) dlg->vbox
#define gtk_dialog_get_action_area(dlg) dlg->action_area
#define gtk_widget_get_window(wdgt) wdgt->window
#endif
#if !GTK_CHECK_VERSION (2, 16, 0)
#define GTK_ACTIVATABLE GTK_WIDGET
#define gtk_activatable_get_related_action gtk_widget_get_action
#define gtk_menu_item_set_label(menuitem, label) \
gtk_label_set_label (GTK_LABEL (GTK_BIN (menuitem)->child), \
label ? label : "");
#endif
#if !GTK_CHECK_VERSION (2, 18, 0)
#define gtk_widget_is_toplevel(widget) GTK_WIDGET_TOPLEVEL (widget)
#define gtk_widget_has_focus(widget) GTK_WIDGET_HAS_FOCUS (widget)
#define gtk_widget_get_visible(widget) GTK_WIDGET_VISIBLE (widget)
#define gtk_widget_get_sensitive(widget) GTK_WIDGET_IS_SENSITIVE (widget)
#define gtk_widget_set_can_focus(widget,flag) \
GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS)
#define gtk_widget_get_allocation(wdgt, alloc) *alloc = wdgt->allocation
#endif
#if !GTK_CHECK_VERSION (2, 20, 0)
#define gtk_widget_get_realized(widget) GTK_WIDGET_REALIZED (widget)
#endif
#if !GTK_CHECK_VERSION(2, 12, 0)
void
gtk_widget_set_has_tooltip (GtkWidget* widget,
gboolean has_tooltip);
void
gtk_widget_set_tooltip_text (GtkWidget* widget,
const gchar* text);
void
gtk_tool_item_set_tooltip_text (GtkToolItem* toolitem,
const gchar* text);
#endif
#include <katze/gtk3-compat.h>
gchar*
sokoke_js_script_eval (JSContextRef js_context,
@ -101,28 +49,12 @@ void
sokoke_spawn_app (const gchar* uri,
gboolean inherit_config);
gchar* sokoke_search_uri (const gchar* uri,
const gchar* keywords);
gchar*
sokoke_hostname_from_uri (const gchar* uri,
gchar** path);
gchar*
sokoke_uri_to_ascii (const gchar* uri);
gboolean
sokoke_external_uri (const gchar* uri);
gchar*
sokoke_magic_uri (const gchar* uri);
gchar*
sokoke_uri_unescape_string (const gchar* uri);
gchar*
sokoke_format_uri_for_display (const gchar* uri);
void
sokoke_combo_box_add_strings (GtkComboBox* combobox,
const gchar* label_first,
@ -132,17 +64,10 @@ void
sokoke_widget_set_visible (GtkWidget* widget,
gboolean visible);
void
sokoke_container_show_children (GtkContainer* container);
GtkWidget*
sokoke_xfce_header_new (const gchar* icon,
const gchar* title);
void
sokoke_widget_set_pango_font_style (GtkWidget* widget,
PangoStyle style);
void
sokoke_entry_set_default_text (GtkEntry* entry,
const gchar* default_text);
@ -205,9 +130,6 @@ gint
sokoke_days_between (const time_t* day1,
const time_t* day2);
void
sokoke_register_stock_items (void);
const gchar*
sokoke_set_config_dir (const gchar* new_config_dir);
@ -226,7 +148,8 @@ gchar*
sokoke_find_lib_path (const gchar* folder);
gchar*
sokoke_find_data_filename (const gchar* filename);
sokoke_find_data_filename (const gchar* filename,
gboolean res);
gchar**
sokoke_get_argv (gchar** argument_vector);

View file

@ -10,18 +10,14 @@
*/
#include "midori-bookmarks.h"
#include "gtk3-compat.h"
#include "midori-array.h"
#include "midori-app.h"
#include "midori-browser.h"
#include "midori-stock.h"
#include "midori-platform.h"
#include "midori-view.h"
#include "midori-viewable.h"
#include "sokoke.h"
#include "gtkiconentry.h"
#include <glib/gi18n.h>
#include <string.h>
@ -1032,19 +1028,3 @@ midori_bookmarks_finalize (GObject* object)
g_object_unref (bookmarks->app);
}
/**
* midori_bookmarks_new:
*
* Creates a new empty bookmarks.
*
* Return value: a new #MidoriBookmarks
*
* Since: 0.1.3
**/
GtkWidget*
midori_bookmarks_new (void)
{
MidoriBookmarks* bookmarks = g_object_new (MIDORI_TYPE_BOOKMARKS, NULL);
return GTK_WIDGET (bookmarks);
}

View file

@ -12,8 +12,6 @@
#ifndef __MIDORI_BOOKMARKS_H__
#define __MIDORI_BOOKMARKS_H__
#include "config.h"
#include <sqlite3.h>
#include <gtk/gtk.h>
#include <katze/katze.h>

View file

@ -13,12 +13,10 @@
#include "midori-app.h"
#include "midori-extension.h"
#include "midori-stock.h"
#include "midori-platform.h"
#include "midori-viewable.h"
#include "midori-core.h"
#include "midori-extensions-column.c"
#include "sokoke.h"
#include <glib/gi18n.h>
struct _MidoriExtensions
@ -404,7 +402,7 @@ midori_extensions_treeview_button_pressed_cb (GtkWidget* view,
{
if (path != NULL)
{
if (MIDORI_IS_EXTENSIONS_COUMN (column))
if (MIDORI_IS_EXTENSIONS_COLUMN (column))
{
signal_id = g_signal_lookup ("row-clicked", G_OBJECT_TYPE (column));
@ -464,7 +462,7 @@ midori_extensions_init (MidoriExtensions* extensions)
(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_coumn_new ());
column = GTK_TREE_VIEW_COLUMN (midori_extensions_column_new ());
g_signal_connect (column,
"row-clicked",
G_CALLBACK (midori_extensions_treeview_column_preference_clicked_cb),
@ -506,20 +504,3 @@ midori_extensions_finalize (GObject* object)
g_object_unref (array);
}
/**
* midori_extensions_new:
*
* Creates a new empty extensions.
*
* Return value: a new #MidoriExtensions
*
* Since: 0.1.2
**/
GtkWidget*
midori_extensions_new (void)
{
MidoriExtensions* extensions = g_object_new (MIDORI_TYPE_EXTENSIONS,
NULL);
return GTK_WIDGET (extensions);
}

View file

@ -10,21 +10,16 @@
*/
#include "midori-history.h"
#include "gtk3-compat.h"
#include "midori-app.h"
#include "midori-array.h"
#include "midori-browser.h"
#include "midori-stock.h"
#include "midori-platform.h"
#include "midori-view.h"
#include "midori-viewable.h"
#include "sokoke.h"
#include "gtkiconentry.h"
#include <glib/gi18n.h>
#include <string.h>
#include <gdk/gdkkeysyms.h>
#define COMPLETION_DELAY 200
@ -1026,19 +1021,3 @@ midori_history_finalize (GObject* object)
katze_assign (history->filter, NULL);
}
/**
* midori_history_new:
*
* Creates a new empty history.
*
* Return value: a new #MidoriHistory
*
* Since: 0.1.3
**/
GtkWidget*
midori_history_new (void)
{
MidoriHistory* history = g_object_new (MIDORI_TYPE_HISTORY, NULL);
return GTK_WIDGET (history);
}

View file

@ -13,10 +13,9 @@
#include "midori-app.h"
#include "midori-browser.h"
#include "midori-stock.h"
#include "midori-platform.h"
#include "midori-view.h"
#include "sokoke.h"
#include <glib/gi18n.h>
struct _MidoriTransfers
@ -263,8 +262,8 @@ midori_transfers_treeview_render_text_cb (GtkTreeViewColumn* column,
gtk_tree_model_get (model, iter, 1, &download, -1);
/* FIXME: Ellipsize filename */
current = g_format_size_for_display (webkit_download_get_current_size (download));
total = g_format_size_for_display (webkit_download_get_total_size (download));
current = g_format_size (webkit_download_get_current_size (download));
total = g_format_size (webkit_download_get_total_size (download));
size_text = g_strdup_printf (_("%s of %s"), current, total);
g_free (current);
g_free (total);
@ -562,19 +561,3 @@ midori_transfers_init (MidoriTransfers* transfers)
G_CALLBACK (midori_transfers_hierarchy_changed_cb), NULL);
}
/**
* midori_transfers_new:
*
* Creates a new empty transfers.
*
* Return value: a new #MidoriTransfers
*
* Since 0.1.5
**/
GtkWidget*
midori_transfers_new (void)
{
MidoriTransfers* transfers = g_object_new (MIDORI_TYPE_TRANSFERS, NULL);
return GTK_WIDGET (transfers);
}

View file

@ -1,6 +1,7 @@
# 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

1869
po/cs.po

File diff suppressed because it is too large Load diff

1495
po/da.po

File diff suppressed because it is too large Load diff

1663
po/de.po

File diff suppressed because it is too large Load diff

1876
po/es.po

File diff suppressed because it is too large Load diff

2144
po/fr.po

File diff suppressed because it is too large Load diff

1586
po/gl.po

File diff suppressed because it is too large Load diff

1817
po/hr.po

File diff suppressed because it is too large Load diff

2090
po/ja.po

File diff suppressed because it is too large Load diff

1732
po/ko.po

File diff suppressed because it is too large Load diff

1179
po/lt.po

File diff suppressed because it is too large Load diff

1736
po/nl.po

File diff suppressed because it is too large Load diff

1473
po/pt.po

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

1477
po/ro.po

File diff suppressed because it is too large Load diff

1756
po/ru.po

File diff suppressed because it is too large Load diff

1502
po/sk.po

File diff suppressed because it is too large Load diff

1706
po/uk.po

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -9,13 +9,7 @@
See the file COPYING for the full license text.
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif
#include "midori.h"
#include "midori-stock.h"
#include "sokoke.h"
static void
browser_create (void)
@ -49,18 +43,69 @@ browser_create (void)
g_object_unref (app);
}
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");
}
int
main (int argc,
char** argv)
{
/* libSoup uses threads, therefore if WebKit is built with libSoup
or Midori is using it, we need to initialize threads. */
if (!g_thread_supported ()) g_thread_init (NULL);
midori_app_setup (argv);
g_object_set_data (G_OBJECT (webkit_get_default_session ()),
"midori-session-initialized", (void*)1);
g_test_init (&argc, &argv, NULL);
gtk_init_check (&argc, &argv);
sokoke_register_stock_items ();
g_test_add_func ("/browser/create", browser_create);
g_test_add_func ("/browser/tooltips", browser_tooltips);
return g_test_run ();
}

View file

@ -9,10 +9,6 @@
See the file COPYING for the full license text.
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif
#include "midori.h"
const gpointer magic = (gpointer)0xdeadbeef;
@ -172,6 +168,7 @@ extension_activate (gconstpointer data)
{
MidoriApp* app = midori_app_new ();
MidoriExtension* extension = MIDORI_EXTENSION (data);
g_object_set (app, "settings", midori_web_settings_new (), NULL);
g_signal_emit_by_name (extension, "activate", app);
midori_extension_deactivate (extension);
g_object_unref (app);
@ -234,9 +231,9 @@ int
main (int argc,
char** argv)
{
midori_app_setup (argv);
g_test_init (&argc, &argv, NULL);
gtk_init_check (&argc, &argv);
if (!g_thread_supported ()) g_thread_init (NULL);
soup_session_add_feature_by_type (webkit_get_default_session (),
SOUP_TYPE_COOKIE_JAR);

View file

@ -10,11 +10,7 @@
See the file COPYING for the full license text.
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif
#include "sokoke.h"
#include <midori/midori.h>
#define SM "http://www.searchmash.com/search/"
@ -76,7 +72,7 @@ test_input (const gchar* input,
}
g_strfreev (parts);
uri = keywords ? sokoke_search_uri (search_uri, keywords) : NULL;
uri = keywords ? midori_uri_for_search (search_uri, keywords) : NULL;
g_free (keywords);
}
@ -121,19 +117,11 @@ magic_uri_idn (void)
} URIItem;
static const URIItem items[] = {
#if HAVE_LIBIDN || defined (HAVE_LIBSOUP_2_27_90)
{ "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" },
#else
{ "http://www.münchhausen.at", NULL },
{ "http://www.خداوند.com/", NULL },
{ "айкидо.com", NULL },
{ "http://東京理科大学.jp", NULL },
{ "https://青のネコ.co.jp", NULL },
#endif
{ "http://en.wikipedia.org/wiki/Kölsch_language", NULL },
{ "file:///home/mark/frühstück", NULL },
{ "about:version", NULL },
@ -142,17 +130,13 @@ magic_uri_idn (void)
for (i = 0; i < G_N_ELEMENTS (items); i++)
{
gchar* result = sokoke_uri_to_ascii (items[i].before);
gchar* result = midori_uri_to_ascii (items[i].before);
const gchar* after = items[i].after ? items[i].after : items[i].before;
sokoke_assert_str_equal (items[i].before, result, after);
g_free (result);
}
#if HAVE_LIBIDN
test_input ("айкидо.com", "http://xn--80aildf0a.com");
#else
test_input ("айкидо.com", "http://айкидо.com");
#endif
test_input ("sm Küchenzubehör", SM "Küchenzubehör");
test_input ("sm 東京理科大学", SM "東京理科大学");
}
@ -224,6 +208,22 @@ magic_uri_performance (void)
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);
}
static void
magic_uri_format (void)
{
@ -248,7 +248,7 @@ magic_uri_format (void)
for (i = 0; i < G_N_ELEMENTS (items); i++)
{
gchar* result = sokoke_format_uri_for_display (items[i].before);
gchar* result = midori_uri_format_for_display (items[i].before);
const gchar* after = items[i].after ? items[i].after : items[i].before;
sokoke_assert_str_equal (items[i].before, result, after);
g_free (result);
@ -276,9 +276,7 @@ int
main (int argc,
char** argv)
{
/* libSoup uses threads, therefore if WebKit is built with libSoup
or Midori is using it, we need to initialize threads. */
if (!g_thread_supported ()) g_thread_init (NULL);
midori_app_setup (argv);
g_test_init (&argc, &argv, NULL);
gtk_init_check (&argc, &argv);
@ -287,6 +285,7 @@ main (int argc,
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/format", magic_uri_format);
g_test_add_func ("/magic-uri/prefetch", magic_uri_prefetch);

View file

@ -9,13 +9,8 @@
See the file COPYING for the full license text.
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif
#include "midori.h"
#include "midori-bookmarks.h"
#include "sokoke.h"
typedef struct
{
@ -193,12 +188,11 @@ int
main (int argc,
char** argv)
{
/* libSoup uses threads, therefore if WebKit is built with libSoup
or Midori is using it, we need to initialize threads. */
if (!g_thread_supported ()) g_thread_init (NULL);
midori_app_setup (argv);
g_object_set_data (G_OBJECT (webkit_get_default_session ()),
"midori-session-initialized", (void*)1);
g_test_init (&argc, &argv, NULL);
gtk_init_check (&argc, &argv);
sokoke_register_stock_items ();
g_test_add_data_func ("/properties/app",
(gconstpointer)MIDORI_TYPE_APP, properties_type_test);

View file

@ -10,19 +10,15 @@
*/
#include "midori-findbar.h"
#include "gtk3-compat.h"
#include "midori-browser.h"
#include "gtkiconentry.h"
#include "sokoke.h"
#include "midori-platform.h"
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include "config.h"
struct _MidoriFindbar
{
@ -112,15 +108,12 @@ static void
midori_findbar_entry_clear_icon_released_cb (GtkIconEntry* entry,
gint icon_pos,
gint button,
gpointer user_data)
MidoriFindbar*findbar)
{
if (icon_pos == GTK_ICON_ENTRY_SECONDARY)
{
gtk_entry_set_text (GTK_ENTRY (entry), "");
#if !HAVE_HILDON
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (entry),
GTK_ICON_ENTRY_PRIMARY, GTK_STOCK_FIND);
#endif
midori_findbar_set_icon (findbar, GTK_ICON_ENTRY_PRIMARY, "edit-find");
}
}
@ -255,6 +248,10 @@ midori_findbar_init (MidoriFindbar* findbar)
GtkToolItem* toolitem;
gtk_widget_set_name (GTK_WIDGET (findbar), "MidoriFindbar");
#if GTK_CHECK_VERSION (3, 0, 0)
gtk_style_context_add_class (
gtk_widget_get_style_context (GTK_WIDGET (findbar)), "bottom-toolbar");
#endif
gtk_toolbar_set_icon_size (GTK_TOOLBAR (findbar), GTK_ICON_SIZE_MENU);
gtk_toolbar_set_style (GTK_TOOLBAR (findbar), GTK_TOOLBAR_BOTH_HORIZ);
g_signal_connect (findbar, "key-press-event",
@ -271,7 +268,7 @@ midori_findbar_init (MidoriFindbar* findbar)
gtk_icon_entry_set_icon_highlight (GTK_ICON_ENTRY (findbar->find_text),
GTK_ICON_ENTRY_SECONDARY, TRUE);
g_signal_connect (findbar->find_text, "icon-release",
G_CALLBACK (midori_findbar_entry_clear_icon_released_cb), NULL);
G_CALLBACK (midori_findbar_entry_clear_icon_released_cb), findbar);
g_signal_connect (findbar->find_text, "activate",
G_CALLBACK (midori_findbar_next_activate_cb), findbar);
g_signal_connect (findbar->find_text, "preedit-changed",
@ -324,12 +321,9 @@ midori_findbar_init (MidoriFindbar* findbar)
_("Close Findbar"));
g_signal_connect (findbar->find_close, "clicked",
G_CALLBACK (midori_findbar_button_close_clicked_cb), findbar);
#if HAVE_OSX
gtk_toolbar_insert (GTK_TOOLBAR (findbar), findbar->find_close, 0);
#else
gtk_toolbar_insert (GTK_TOOLBAR (findbar), findbar->find_close, -1);
#endif
sokoke_container_show_children (GTK_CONTAINER (findbar));
gtk_container_foreach (GTK_CONTAINER (findbar),
(GtkCallback)(gtk_widget_show_all), NULL);
}
void
@ -382,4 +376,15 @@ midori_findbar_search_text (MidoriFindbar* findbar,
}
}
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);
}

View file

@ -57,6 +57,10 @@ midori_findbar_search_text (MidoriFindbar* findbar,
gboolean found,
gchar* typing);
void
midori_findbar_set_close_button_left (MidoriFindbar* findbar,
gboolean close_button_left);
G_END_DECLS
#endif /* __MIDORI_FINDBAR_H__ */

View file

@ -12,6 +12,7 @@
#include "midori-transferbar.h"
#include "midori-browser.h"
#include "midori-core.h"
#include "sokoke.h"
#include <glib/gi18n.h>
@ -103,7 +104,8 @@ midori_transferbar_download_notify_status_cb (WebKitDownload* download,
MidoriBrowser* browser = midori_browser_get_for_widget (button);
WebKitNetworkRequest* request;
const gchar* original_uri;
gchar** fingerprint;
GChecksumType checksum_type;
gchar* fingerprint;
gboolean verified = TRUE;
icon = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU);
@ -129,48 +131,30 @@ midori_transferbar_download_notify_status_cb (WebKitDownload* download,
original_uri = g_object_get_data (G_OBJECT (request), "midori-original-uri");
if (!original_uri)
original_uri = webkit_download_get_uri (download);
fingerprint = g_strsplit (original_uri, "#!md5!", 2);
if (fingerprint && fingerprint[0] && fingerprint[1])
checksum_type = midori_uri_get_fingerprint (original_uri, &fingerprint, NULL);
if (fingerprint != NULL)
{
gchar* filename = g_filename_from_uri (
webkit_download_get_destination_uri (download), NULL, NULL);
gchar* contents;
gsize length;
gboolean y = g_file_get_contents (filename, &contents, &length, NULL);
gchar* checksum = g_compute_checksum_for_data (G_CHECKSUM_MD5,
gchar* checksum = g_compute_checksum_for_data (checksum_type,
(guchar*)contents, length);
g_free (filename);
g_free (contents);
/* Checksums are case-insensitive */
if (!y || g_ascii_strcasecmp (fingerprint[1], checksum) != 0)
if (!y || g_ascii_strcasecmp (fingerprint, checksum) != 0)
verified = FALSE;
g_free (checksum);
}
else
{
gchar* filename = g_filename_from_uri (
webkit_download_get_destination_uri (download), NULL, NULL);
g_strfreev (fingerprint);
fingerprint = g_strsplit (original_uri, "#!sha1!", 2);
if (fingerprint && fingerprint[0] && fingerprint[1])
{
gchar* contents;
gsize length;
gboolean y = g_file_get_contents (filename, &contents, &length, NULL);
gchar* checksum = g_compute_checksum_for_data (G_CHECKSUM_SHA1,
(guchar*)contents, length);
g_free (contents);
/* Checksums are case-insensitive */
if (!y || g_ascii_strcasecmp (fingerprint[1], checksum) != 0)
verified = FALSE;
g_free (checksum);
}
g_free (filename);
}
g_strfreev (fingerprint);
g_free (fingerprint);
if (verified)
gtk_recent_manager_add_item (gtk_recent_manager_get_default (),
webkit_download_get_destination_uri (download));
{
if (!sokoke_is_app_or_private ())
gtk_recent_manager_add_item (gtk_recent_manager_get_default (),
webkit_download_get_destination_uri (download));
}
else
gtk_image_set_from_stock (GTK_IMAGE (icon),
GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_MENU);
@ -224,6 +208,35 @@ midori_transferbar_download_button_clicked_cb (GtkWidget* button,
}
}
void
midori_transferbar_check_size (GtkWidget* statusbar,
MidoriTransferbar* transferbar)
{
GtkWidget* window;
GtkRequisition req;
gint reqwidth, winwidth;
gtk_widget_size_request (statusbar, &req);
reqwidth = req.width;
window = gtk_widget_get_toplevel (GTK_WIDGET(transferbar));
gtk_window_get_size (GTK_WINDOW(window), &winwidth, NULL);
if (reqwidth > winwidth)
{
GList* list;
for (list = transferbar->infos; list != NULL; list = g_list_next (list))
{
TransferInfo* info = list->data;
WebKitDownloadStatus status = webkit_download_get_status (info->download);
if (status == WEBKIT_DOWNLOAD_STATUS_ERROR
|| status == WEBKIT_DOWNLOAD_STATUS_CANCELLED
|| status == WEBKIT_DOWNLOAD_STATUS_FINISHED)
{
gtk_widget_destroy (info->button);
}
}
}
}
void
midori_transferbar_add_download_item (MidoriTransferbar* transferbar,
WebKitDownload* download)

View file

@ -22,8 +22,8 @@ mingw32-gettext-tools
mingw32-glib2
mingw32-glib2-devel
mingw32-glib-networking
#mingw32-gst-plugins-base-devel
#mingw32-gstreamer-devel
mingw32-gst-plugins-base-devel
mingw32-gstreamer-devel
mingw32-gtk2
mingw32-gtk2-devel
mingw32-hunspell
@ -63,8 +63,8 @@ mingw32-libtasn1
mingw32-libtasn1-devel
mingw32-libtiff
mingw32-libtiff-devel
#mingw32-libwebkitgtk
#mingw32-libwebkitgtk-devel
mingw32-libwebkitgtk
mingw32-libwebkitgtk-devel
mingw32-webkit-tools
mingw32-libxml2
mingw32-libxml2-devel
@ -86,3 +86,4 @@ mingw32-zlib
mingw32-zlib-devel
mingw32-libunique
mingw32-libunique-devel
mingw32-libffi

103
wscript
View file

@ -29,16 +29,18 @@ from Configure import find_program_impl
major = 0
minor = 4
micro = 1
micro = 2
APPNAME = 'midori'
VERSION = str (major) + '.' + str (minor) + '.' + str (micro)
VERSION = VERSION_FULL = str (major) + '.' + str (minor) + '.' + str (micro)
VERSION_SUFFIX = ' (%s)' % VERSION
try:
if os.path.isdir ('.git'):
git = Utils.cmd_output (['git', 'describe'], silent=True)
if git:
VERSION = git.strip ()
VERSION_FULL = git.strip ()
VERSION_SUFFIX = VERSION_FULL.replace (VERSION, '')
except:
pass
@ -164,13 +166,28 @@ def configure (conf):
atleast_version=version, mandatory=mandatory)
return conf.env['HAVE_' + var]
if option_enabled ('unique') and not option_enabled('gtk3'):
check_pkg ('unique-1.0', '0.9', False)
def check_version (given_version, major, minor, micro):
if '.' in given_version:
given_major, given_minor, given_micro = given_version.split ('.')
else:
given_major, given_minor, given_micro = given_version
return int(given_major) > major or \
int(given_major) == major and int(given_minor) > minor or \
int(given_major) == major and int(given_minor) == minor and int(given_micro) >= micro
if option_enabled ('unique'):
if option_enabled('gtk3'): unique_pkg = 'unique-3.0'
else: unique_pkg = 'unique-1.0'
check_pkg (unique_pkg, '0.9', False)
unique = ['N/A', 'yes'][conf.env['HAVE_UNIQUE'] == 1]
if unique != 'yes':
option_checkfatal ('unique', 'single instance')
conf.define ('UNIQUE_VERSION', 'No')
else:
conf.define ('UNIQUE_VERSION', conf.check_cfg (modversion=unique_pkg))
else:
unique = 'no '
conf.define ('UNIQUE_VERSION', 'No')
conf.define ('HAVE_UNIQUE', [0,1][unique == 'yes'])
if option_enabled ('libnotify'):
@ -178,14 +195,18 @@ def configure (conf):
libnotify = ['N/A','yes'][conf.env['HAVE_LIBNOTIFY'] == 1]
if libnotify != 'yes':
option_checkfatal ('libnotify', 'notifications')
conf.define ('LIBNOTIFY_VERSION', 'No')
else:
conf.define ('LIBNOTIFY_VERSION', conf.check_cfg (modversion='libnotify'))
else:
libnotify = 'no '
conf.define ('LIBNOTIFY_VERSION', 'No')
conf.define ('HAVE_LIBNOTIFY', [0,1][libnotify == 'yes'])
conf.check (lib='m', mandatory=True)
check_pkg ('gmodule-2.0', '2.8.0', False)
check_pkg ('gthread-2.0', '2.8.0', False)
check_pkg ('gio-2.0', '2.16.0')
check_pkg ('gio-2.0', '2.22.0')
args = ''
if Options.platform == 'win32':
args = '--define-variable=target=win32'
@ -196,42 +217,36 @@ def configure (conf):
includes='/usr/X11R6/include', mandatory=False)
conf.check (lib='Xss', libpath='/usr/X11R6/lib', mandatory=False)
if option_enabled ('gtk3'):
if option_enabled ('addons') and not check_version (conf.env['VALAC_VERSION'], 0, 13, 2):
Utils.pprint ('RED', 'Vala 0.13.2 or later is required ' \
'to build with GTK+ 3 and extensions.\n' \
'Pass --disable-addons to build without extensions.\n' \
'Pass --disable-gtk3 to build with extensions and GTK+ 2.')
sys.exit (1)
check_pkg ('gtk+-3.0', '3.0.0', var='GTK', mandatory=False)
check_pkg ('webkitgtk-3.0', '1.1.17', var='WEBKIT', mandatory=False)
if not conf.env['HAVE_GTK'] or not conf.env['HAVE_WEBKIT']:
Utils.pprint ('RED', 'GTK+3 was not found.\n' \
'Pass --disable-gtk3 to build without GTK+3.')
sys.exit (1)
if check_version (conf.check_cfg (modversion='webkitgtk-3.0'), 1, 5, 1):
check_pkg ('javascriptcoregtk-1.0', '1.5.1', args=args)
conf.env.append_value ('VALAFLAGS', '-D HAVE_GTK3')
else:
check_pkg ('gtk+-2.0', '2.10.0', var='GTK')
check_pkg ('webkit-1.0', '1.1.17', args=args)
if check_version (conf.check_cfg (modversion='webkit-1.0'), 1, 5, 1):
check_pkg ('javascriptcoregtk-1.0', '1.5.1', args=args)
conf.env['HAVE_GTK3'] = option_enabled ('gtk3')
webkit_version = conf.check_cfg (modversion='webkit-1.0').split ('.')
if int(webkit_version[0]) >= 1 and int(webkit_version[1]) >= 5 and int(webkit_version[2]) >= 1:
check_pkg ('javascriptcoregtk-1.0', '1.1.17', args=args)
check_pkg ('libsoup-2.4', '2.25.2')
check_pkg ('libsoup-2.4', '2.27.90')
conf.define ('HAVE_LIBSOUP_2_25_2', 1)
check_pkg ('libsoup-2.4', '2.27.90', False, var='LIBSOUP_2_27_90')
conf.define ('HAVE_LIBSOUP_2_27_90', 1)
check_pkg ('libsoup-2.4', '2.29.3', False, var='LIBSOUP_2_29_3')
check_pkg ('libsoup-2.4', '2.29.91', False, var='LIBSOUP_2_29_91')
conf.define ('LIBSOUP_VERSION', conf.check_cfg (modversion='libsoup-2.4'))
check_pkg ('libxml-2.0', '2.6')
check_pkg ('sqlite3', '3.0', True, var='SQLITE')
if conf.env['HAVE_LIBSOUP_2_27_90']:
idn = 'yes'
conf.define ('HAVE_LIBIDN', 0)
else:
if option_enabled ('libidn'):
check_pkg ('libidn', '1.0', False)
idn = ['N/A','yes'][conf.env['HAVE_LIBIDN'] == 1]
if idn != 'yes':
option_checkfatal ('libidn', 'international domain names')
else:
idn = 'no '
conf.define ('HAVE_LIBIDN', [0,1][idn == 'yes'])
if option_enabled ('hildon'):
if check_pkg ('hildon-1', mandatory=False, var='HILDON'):
check_pkg ('libosso', var='HILDON')
@ -269,16 +284,15 @@ def configure (conf):
else:
conf.check (header_name='signal.h')
conf.define ('PACKAGE_VERSION', VERSION)
conf.define ('PACKAGE_NAME', APPNAME)
conf.define ('PACKAGE_BUGREPORT', 'https://bugs.launchpad.net/midori')
conf.define ('GETTEXT_PACKAGE', APPNAME)
conf.define ('MIDORI_VERSION', VERSION)
conf.define ('MIDORI_MAJOR_VERSION', major)
conf.define ('MIDORI_MINOR_VERSION', minor)
conf.define ('MIDORI_MICRO_VERSION', micro)
conf.write_config_header ('config.h')
conf.env.append_value ('CCFLAGS', '-DHAVE_CONFIG_H -include config.h'.split ())
debug_level = Options.options.debug_level
compiler = conf.env['CC_NAME']
@ -287,6 +301,15 @@ def configure (conf):
sys.exit (1)
elif debug_level == '':
debug_level = 'debug'
if debug_level == 'full':
conf.define ('PACKAGE_VERSION', '%s (debug)' % VERSION_FULL)
conf.env.append_value ('CCFLAGS', '-DMIDORI_VERSION_SUFFIX="%s (debug)"' % VERSION_SUFFIX)
else:
conf.define ('PACKAGE_VERSION', VERSION_FULL)
conf.env.append_value ('CCFLAGS', '-DMIDORI_VERSION_SUFFIX="%s"' % VERSION_SUFFIX)
conf.write_config_header ('config.h')
if compiler == 'gcc':
if debug_level == 'none':
if 'CCFLAGS' in os.environ:
@ -314,15 +337,17 @@ def configure (conf):
'-DGTK_DISABLE_DEPRECATED -DPANGO_DISABLE_DEPRECATED '
'-DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE'.split ())
if debug_level == 'full':
conf.env.append_value ('VALAFLAGS', '--enable-checking'.split ())
conf.env.append_value ('VALAFLAGS', '--debug --enable-checking'.split ())
elif debug_level == 'debug':
conf.env.append_value ('VALAFLAGS', '--debug'.split ())
elif debug_level == 'none':
conf.env.append_value ('VALAFLAGS', '--disable-assert')
conf.env.append_value ('VALAFLAGS', '--enable-deprecated')
print ('''
Localization: %(nls)s (intltool)
Icon optimizations: %(icons)s (rsvg-convert)
Notifications: %(libnotify)s (libnotify)
IDN support: %(idn)s (libidn or libsoup 2.27.90)
API documentation: %(api_docs)s (gtk-doc)
''' % locals ())
if unique == 'yes' and conf.check_cfg (modversion='unique-1.0') == '1.0.4':
@ -366,7 +391,6 @@ def set_options (opt):
group = opt.add_option_group ('Optional features', '')
add_enable_option ('unique', 'single instance support', group)
add_enable_option ('libidn', 'international domain name support', group)
add_enable_option ('libnotify', 'notification support', group)
add_enable_option ('addons', 'building of extensions', group)
add_enable_option ('tests', 'building of tests', group, disable=True)
@ -472,30 +496,23 @@ def build (bld):
else:
Utils.pprint ('BLUE', "logo-shade could not be rasterized.")
bld.install_files ('${MDATADIR}/' + APPNAME + '/res', 'data/error.html')
bld.install_files ('${MDATADIR}/' + APPNAME + '/res', 'data/speeddial-head.html')
for res_file in ['error.html', 'close.png']:
bld.install_files ('${MDATADIR}/' + APPNAME + '/res', 'data/' + res_file)
bld.install_as ( \
'${MDATADIR}/' + APPNAME + '/res/speeddial-head-%s.html' % VERSION, \
'data/speeddial-head.html')
if bld.env['addons']:
bld.install_files ('${MDATADIR}/' + APPNAME + '/res', 'data/autosuggestcontrol.js')
bld.install_files ('${MDATADIR}/' + APPNAME + '/res', 'data/autosuggestcontrol.css')
# FIXME: Determine the library naming for other platforms
if bld.env['platform'] == 'win32':
if 1:
extensions = os.listdir ('data/extensions')
for extension in extensions:
folder = 'lib' + extension + '.dll'
source = 'data/extensions/' + extension + '/config'
if os.path.exists (source):
bld.install_files ('${SYSCONFDIR}/xdg/' + APPNAME + \
'/extensions/' + folder, source)
elif Options.platform == 'linux':
extensions = os.listdir ('data/extensions')
for extension in extensions:
folder = 'lib' + extension + '.so'
source = 'data/extensions/' + extension + '/config'
if os.path.exists (source):
bld.install_files ('${SYSCONFDIR}/xdg/' + APPNAME + \
'/extensions/' + folder, source)
'/extensions/' + extension, source)
if Options.commands['check'] or bld.env['tests']:
bld.add_subdirs ('tests')