Merge commit 'upstream/0.1.9'

This commit is contained in:
Ryan Niebur 2009-09-02 11:26:59 -07:00
commit 437102059b
27 changed files with 3217 additions and 2276 deletions

View file

@ -17,6 +17,7 @@ Contributors:
Johannes Reinhardt <jreinhardt@ist-dein-freund.de>
Jean-François Guchens <zcx000@gmail.com>
Jérôme Geulfucci <jeromeg@xfce.org>
Alexander Butenko <a.butenka@gmail.com>
Graphics:
extension: Nancy Runge <nancy@twotoasts.de>

View file

@ -1,5 +1,16 @@
This file is licensed under the terms of the expat license, see the file EXPAT.
v0.1.9:
+ Preserve navigation history with new tabs
+ Implement clearing private data when quitting
+ Ellipsize and show close icons in the tab panel
+ Allow hiding panel operating controls
+ Integrate Tools with the compact menu
+ Fix User scripts, User styles and Plugins panel
+ Remove the bookmarkbar popup
+ Add New Tab to the tab context menu
+ Implement minimizing tabs
v0.1.8:
+ Initial support for extension unit tests
+ Set a "browser" role on browser windows

View file

@ -1,5 +1,6 @@
/*
Copyright (C) 2009 Christian Dywan <christian@twotoasts.de>
Copyright (C) 2009 Alexander Butenko <a.butenka@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -19,6 +20,43 @@
#include <unistd.h>
#endif
static gchar *
adblock_fixup_regexp (gchar* src)
{
gchar* dst;
gchar* s;
/* FIXME: Avoid always allocating twice the string */
s = dst = g_malloc (strlen (src) * 2);
while (*src)
{
switch (*src)
{
case '*':
*s++ = '.';
break;
case '.':
*s++ = '\\';
break;
case '?':
*s++ = '\\';
break;
case '|':
*s++ = '\\';
break;
}
*s++ = *src;
src++;
}
*s = 0;
return dst;
}
static void
adblock_browser_populate_tool_menu_cb (MidoriBrowser* browser,
GtkWidget* menu,
MidoriExtension* extension);
static void
adblock_app_add_browser_cb (MidoriApp* app,
MidoriBrowser* browser,
@ -26,13 +64,14 @@ adblock_app_add_browser_cb (MidoriApp* app,
static void
adblock_deactivate_cb (MidoriExtension* extension,
GtkWidget* menuitem)
MidoriBrowser* browser)
{
MidoriApp* app = midori_extension_get_app (extension);
gtk_widget_destroy (menuitem);
g_signal_handlers_disconnect_by_func (
extension, adblock_deactivate_cb, menuitem);
browser, adblock_browser_populate_tool_menu_cb, extension);
g_signal_handlers_disconnect_by_func (
extension, adblock_deactivate_cb, browser);
g_signal_handlers_disconnect_by_func (
app, adblock_app_add_browser_cb, extension);
/* FIXME: Disconnect session callbacks */
@ -256,26 +295,28 @@ adblock_menu_configure_filters_activate_cb (GtkWidget* menuitem,
}
static void
adblock_app_add_browser_cb (MidoriApp* app,
MidoriBrowser* browser,
adblock_browser_populate_tool_menu_cb (MidoriBrowser* browser,
GtkWidget* menu,
MidoriExtension* extension)
{
GtkWidget* panel;
GtkWidget* menu;
GtkWidget* menuitem;
panel = katze_object_get_object (browser, "panel");
menu = katze_object_get_object (panel, "menu");
menuitem = gtk_menu_item_new_with_mnemonic (_("Configure _Advertisement filters..."));
g_signal_connect (menuitem, "activate",
G_CALLBACK (adblock_menu_configure_filters_activate_cb), extension);
gtk_widget_show (menuitem);
gtk_menu_shell_insert (GTK_MENU_SHELL (menu), menuitem, 3);
g_object_unref (menu);
g_object_unref (panel);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
}
static void
adblock_app_add_browser_cb (MidoriApp* app,
MidoriBrowser* browser,
MidoriExtension* extension)
{
g_signal_connect (browser, "populate-tool-menu",
G_CALLBACK (adblock_browser_populate_tool_menu_cb), extension);
g_signal_connect (extension, "deactivate",
G_CALLBACK (adblock_deactivate_cb), menuitem);
G_CALLBACK (adblock_deactivate_cb), browser);
}
static gboolean
@ -322,12 +363,7 @@ adblock_parse_line (gchar* line)
if (line[0] == '[')
return NULL;
g_strchomp (line);
/* TODO: Replace trailing '*' with '.*' */
if (line[0] == '*')
return g_strconcat (".", line, NULL);
else if (line[0] == '?')
return g_strconcat ("\\", line, NULL);
return g_strdup (line);
return adblock_fixup_regexp (line);
}
static GHashTable*
@ -469,11 +505,11 @@ test_adblock_parse (void)
g_assert_cmpstr (adblock_parse_line ("*foo"), ==, ".*foo");
g_assert_cmpstr (adblock_parse_line ("?foo"), ==, "\\?foo");
/* g_assert_cmpstr (adblock_parse_line ("foo*"), ==, "foo.*");
g_assert_cmpstr (adblock_parse_line ("foo?"), ==, "foo\\?"); */
g_assert_cmpstr (adblock_parse_line ("foo*"), ==, "foo.*");
g_assert_cmpstr (adblock_parse_line ("foo?"), ==, "foo\\?");
g_assert_cmpstr (adblock_parse_line (".*foo/bar"), ==, ".*foo/bar");
g_assert_cmpstr (adblock_parse_line ("http://bla.blub/.*"), ==, "http://bla.blub/.*");
g_assert_cmpstr (adblock_parse_line (".*foo/bar"), ==, "\\..*foo/bar");
g_assert_cmpstr (adblock_parse_line ("http://bla.blub/*"), ==, "http://bla\\.blub/.*");
}
static void
@ -486,10 +522,10 @@ test_adblock_pattern (void)
temp = g_file_open_tmp ("midori_adblock_match_test_XXXXXX", &filename, NULL);
g_file_set_contents (filename,
"*ads.foo.bar.*\n"
".*ads.bogus.name.*\n"
"http://ads.bla.blub/.*\n"
"http://ads.blub.boing/*.",
"*ads.foo.bar*\n"
"*ads.bogus.name*\n"
"http://ads.bla.blub/*\n"
"http://ads.blub.boing/*",
-1, NULL);
pattern = adblock_parse_file (filename);

View file

@ -14,6 +14,11 @@
#include <midori/sokoke.h>
#include "config.h"
static void
shortcuts_browser_populate_tool_menu_cb (MidoriBrowser* browser,
GtkWidget* menu,
MidoriExtension* extension);
static void
shortcuts_app_add_browser_cb (MidoriApp* app,
MidoriBrowser* browser,
@ -21,13 +26,14 @@ shortcuts_app_add_browser_cb (MidoriApp* app,
static void
shortcuts_deactivate_cb (MidoriExtension* extension,
GtkWidget* menuitem)
MidoriBrowser* browser)
{
MidoriApp* app = midori_extension_get_app (extension);
gtk_widget_destroy (menuitem);
g_signal_handlers_disconnect_by_func (
extension, shortcuts_deactivate_cb, menuitem);
browser, shortcuts_browser_populate_tool_menu_cb, extension);
g_signal_handlers_disconnect_by_func (
extension, shortcuts_deactivate_cb, browser);
g_signal_handlers_disconnect_by_func (
app, shortcuts_app_add_browser_cb, extension);
}
@ -163,7 +169,7 @@ shortcuts_get_preferences_dialog (MidoriExtension* extension)
app = midori_extension_get_app (extension);
browser = katze_object_get_object (app, "browser");
dialog_title = _("Configure Keyboard shortcuts");
dialog_title = _("Customize Keyboard shortcuts");
dialog = gtk_dialog_new_with_buttons (dialog_title, GTK_WINDOW (browser),
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
#if !HAVE_OSX
@ -248,27 +254,29 @@ shortcuts_menu_configure_shortcuts_activate_cb (GtkWidget* menuitem,
gtk_window_present (GTK_WINDOW (dialog));
}
static void
shortcuts_browser_populate_tool_menu_cb (MidoriBrowser* browser,
GtkWidget* menu,
MidoriExtension* extension)
{
GtkWidget* menuitem;
menuitem = gtk_menu_item_new_with_mnemonic (_("Customize Sh_ortcuts..."));
g_signal_connect (menuitem, "activate",
G_CALLBACK (shortcuts_menu_configure_shortcuts_activate_cb), extension);
gtk_widget_show (menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
}
static void
shortcuts_app_add_browser_cb (MidoriApp* app,
MidoriBrowser* browser,
MidoriExtension* extension)
{
GtkWidget* panel;
GtkWidget* menu;
GtkWidget* menuitem;
panel = katze_object_get_object (browser, "panel");
menu = katze_object_get_object (panel, "menu");
g_object_unref (panel);
menuitem = gtk_menu_item_new_with_mnemonic (_("Configure Sh_ortcuts..."));
g_signal_connect (menuitem, "activate",
G_CALLBACK (shortcuts_menu_configure_shortcuts_activate_cb), extension);
gtk_widget_show (menuitem);
gtk_menu_shell_insert (GTK_MENU_SHELL (menu), menuitem, 3);
g_object_unref (menu);
g_signal_connect (browser, "populate-tool-menu",
G_CALLBACK (shortcuts_browser_populate_tool_menu_cb), extension);
g_signal_connect (extension, "deactivate",
G_CALLBACK (shortcuts_deactivate_cb), menuitem);
G_CALLBACK (shortcuts_deactivate_cb), browser);
}
static void

View file

@ -19,6 +19,11 @@ tab_panel_app_add_browser_cb (MidoriApp* app,
MidoriBrowser* browser,
MidoriExtension* extension);
static void
tab_panel_settings_notify_cb (MidoriWebSettings* settings,
GParamSpec* pspec,
GtkTreeModel* model);
static void
tab_panel_deactivate_cb (MidoriExtension* extension,
GtkWidget* panel)
@ -37,6 +42,8 @@ tab_panel_deactivate_cb (MidoriExtension* extension,
extension, tab_panel_deactivate_cb, panel);
g_signal_handlers_disconnect_by_func (
app, tab_panel_app_add_browser_cb, extension);
g_signal_handlers_disconnect_by_func (
browser, tab_panel_settings_notify_cb, model);
}
static void
@ -46,6 +53,36 @@ midori_extension_cursor_or_row_changed_cb (GtkTreeView* treeview,
/* Nothing to do */
}
#if GTK_CHECK_VERSION (2, 12, 0)
static gboolean
tab_panel_treeview_query_tooltip_cb (GtkWidget* treeview,
gint x,
gint y,
gboolean keyboard_tip,
GtkTooltip* tooltip,
gpointer user_data)
{
GtkTreeIter iter;
GtkTreePath* path;
GtkTreeModel* model;
MidoriView* view;
if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (treeview),
&x, &y, keyboard_tip, &model, &path, &iter))
return FALSE;
gtk_tree_model_get (model, &iter, 0, &view, -1);
gtk_tooltip_set_text (tooltip, midori_view_get_display_title (view));
gtk_tree_view_set_tooltip_row (GTK_TREE_VIEW (treeview), tooltip, path);
gtk_tree_path_free (path);
g_object_unref (view);
return TRUE;
}
#endif
static void
midori_extension_treeview_render_icon_cb (GtkTreeViewColumn* column,
GtkCellRenderer* renderer,
@ -75,7 +112,8 @@ midori_extension_treeview_render_text_cb (GtkTreeViewColumn* column,
gtk_tree_model_get (model, iter, 0, &view, -1);
g_object_set (renderer, "text", midori_view_get_display_title (view), NULL);
g_object_set (renderer, "text", midori_view_get_display_title (view),
"ellipsize", midori_view_get_label_ellipsize (view), NULL);
g_object_unref (view);
}
@ -136,6 +174,12 @@ midori_extension_button_release_event_cb (GtkWidget* widget,
if (event->button == 1)
{
MidoriBrowser* browser = midori_browser_get_for_widget (widget);
GtkTreeViewColumn* column;
if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
event->x, event->y, NULL, &column, NULL, NULL)
&& column == gtk_tree_view_get_column (GTK_TREE_VIEW (widget), 1))
gtk_widget_destroy (view);
else
midori_browser_set_current_tab (browser, view);
}
else if (event->button == 2)
@ -176,6 +220,20 @@ midori_extension_popup_menu_cb (GtkWidget* widget,
}
}
static void
tab_panel_settings_notify_cb (MidoriWebSettings* settings,
GParamSpec* pspec,
GtkTreeModel* model)
{
gboolean buttons = katze_object_get_boolean (settings, "close-buttons-on-tabs");
guint i;
GtkTreeIter iter;
i = 0;
while (gtk_tree_model_iter_nth_child (model, &iter, NULL, i++))
gtk_tree_store_set (GTK_TREE_STORE (model), &iter, 2, buttons, -1);
}
static void
tab_panel_browser_add_tab_cb (MidoriBrowser* browser,
GtkWidget* view,
@ -185,9 +243,16 @@ tab_panel_browser_add_tab_cb (MidoriBrowser* browser,
GtkTreeIter iter;
GtkWidget* notebook = katze_object_get_object (browser, "notebook");
gint page = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), view);
g_object_unref (notebook);
MidoriWebSettings* settings = katze_object_get_object (browser, "settings");
gboolean buttons = katze_object_get_boolean (settings, "close-buttons-on-tabs");
gtk_tree_store_insert_with_values (GTK_TREE_STORE (model),
&iter, NULL, page, 0, view, -1);
&iter, NULL, page, 0, view, 1, GTK_STOCK_CLOSE, 2, buttons, -1);
g_signal_connect (settings, "notify::close-buttons-on-tabs",
G_CALLBACK (tab_panel_settings_notify_cb), model);
g_object_unref (notebook);
g_object_unref (settings);
}
static void
@ -247,6 +312,12 @@ tab_panel_app_add_browser_cb (MidoriApp* app,
model = g_object_get_data (G_OBJECT (extension), "treemodel");
treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
gtk_tree_view_set_show_expanders (GTK_TREE_VIEW (treeview), FALSE);
#if GTK_CHECK_VERSION (2, 12, 0)
g_signal_connect (treeview, "query-tooltip",
G_CALLBACK (tab_panel_treeview_query_tooltip_cb), NULL);
gtk_widget_set_has_tooltip (treeview, TRUE);
#endif
column = gtk_tree_view_column_new ();
renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
@ -254,10 +325,17 @@ tab_panel_app_add_browser_cb (MidoriApp* app,
(GtkTreeCellDataFunc)midori_extension_treeview_render_icon_cb,
treeview, NULL);
renderer_text = gtk_cell_renderer_text_new ();
gtk_tree_view_column_pack_start (column, renderer_text, FALSE);
gtk_tree_view_column_pack_start (column, renderer_text, TRUE);
gtk_tree_view_column_set_cell_data_func (column, renderer_text,
(GtkTreeCellDataFunc)midori_extension_treeview_render_text_cb,
treeview, NULL);
gtk_tree_view_column_set_expand (column, TRUE);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
column = gtk_tree_view_column_new ();
renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (column), renderer_pixbuf,
"stock-id", 1, "follow-state", 2, "visible", 2, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
g_object_connect (treeview,
"signal::row-activated",
@ -313,7 +391,8 @@ tab_panel_activate_cb (MidoriExtension* extension,
MidoriBrowser* browser;
guint i;
model = gtk_tree_store_new (1, MIDORI_TYPE_VIEW);
model = gtk_tree_store_new (3, MIDORI_TYPE_VIEW,
G_TYPE_STRING, G_TYPE_BOOLEAN);
g_object_set_data (G_OBJECT (extension), "treemodel", model);
browsers = katze_object_get_object (app, "browsers");

View file

@ -48,16 +48,17 @@ static const GtkTargetEntry tb_editor_dnd_targets[] =
};
static const gint tb_editor_dnd_targets_len = G_N_ELEMENTS(tb_editor_dnd_targets);
static void tb_editor_browser_populate_tool_menu_cb(MidoriBrowser *browser, GtkWidget *menu, MidoriExtension *ext);
static void tb_editor_app_add_browser_cb(MidoriApp *app, MidoriBrowser *browser, MidoriExtension *ext);
static void tb_editor_deactivate_cb(MidoriExtension *extension, GtkWidget *menuitem)
static void tb_editor_deactivate_cb(MidoriExtension *extension, MidoriBrowser *browser)
{
MidoriApp *app = midori_extension_get_app(extension);
gtk_widget_destroy(menuitem);
g_signal_handlers_disconnect_by_func(extension, tb_editor_deactivate_cb, menuitem);
g_signal_handlers_disconnect_by_func(browser, tb_editor_browser_populate_tool_menu_cb, extension);
g_signal_handlers_disconnect_by_func(extension, tb_editor_deactivate_cb, browser);
g_signal_handlers_disconnect_by_func(app, tb_editor_app_add_browser_cb, extension);
}
@ -571,24 +572,21 @@ static void tb_editor_menu_configure_toolbar_activate_cb(GtkWidget *menuitem, Mi
g_free(tbw);
}
static void tb_editor_browser_populate_tool_menu_cb(MidoriBrowser *browser, GtkWidget *menu, MidoriExtension *ext)
{
GtkWidget *menuitem;
menuitem = gtk_menu_item_new_with_mnemonic (_("Customize _Toolbar..."));
g_signal_connect (menuitem, "activate",
G_CALLBACK (tb_editor_menu_configure_toolbar_activate_cb), browser);
gtk_widget_show (menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
}
static void tb_editor_app_add_browser_cb(MidoriApp *app, MidoriBrowser *browser, MidoriExtension *ext)
{
GtkWidget *panel;
GtkWidget *menu;
GtkWidget *menuitem;
panel = katze_object_get_object(browser, "panel");
menu = katze_object_get_object(panel, "menu");
g_object_unref(panel);
menuitem = gtk_menu_item_new_with_mnemonic(_("Configure _Toolbar..."));
g_signal_connect(menuitem, "activate",
G_CALLBACK(tb_editor_menu_configure_toolbar_activate_cb), browser);
gtk_widget_show(menuitem);
gtk_menu_shell_insert(GTK_MENU_SHELL (menu), menuitem, 3);
g_object_unref(menu);
g_signal_connect(ext, "deactivate", G_CALLBACK(tb_editor_deactivate_cb), menuitem);
g_signal_connect(browser, "populate-tool-menu", G_CALLBACK(tb_editor_browser_populate_tool_menu_cb), ext);
g_signal_connect(ext, "deactivate", G_CALLBACK(tb_editor_deactivate_cb), browser);
}

View file

@ -6,9 +6,6 @@ import os
extensions = os.listdir ('extensions')
for extension in extensions:
# Adblock is incomplete and not ready for release
if extension == 'adblock.c':
continue
folder = 'extensions' + os.sep + extension
if os.path.isdir (folder):
files = os.listdir (folder)

View file

@ -307,6 +307,10 @@ 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 (GTK_MENU_SHELL (menu), menuitem);
g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item);
if (KATZE_IS_ARRAY (item))
@ -499,6 +503,10 @@ 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);
g_signal_connect (menuitem, "button-press-event",
G_CALLBACK (katze_array_action_menu_button_press_cb), array_action);

View file

@ -24,7 +24,7 @@
* several commonly needed properties.
*/
G_DEFINE_TYPE (KatzeItem, katze_item, G_TYPE_OBJECT)
G_DEFINE_TYPE (KatzeItem, katze_item, G_TYPE_OBJECT);
enum
{
@ -39,6 +39,14 @@ enum
PROP_PARENT
};
enum {
META_DATA_CHANGED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
static void
katze_item_finalize (GObject* object);
@ -60,6 +68,26 @@ katze_item_class_init (KatzeItemClass* class)
GObjectClass* gobject_class;
GParamFlags flags;
/**
* KatzeItem::meta-data-changed:
* @item: the object on which the signal is emitted
* @key: the key that changed
*
* Emitted when a meta data value was changed.
*
* Since: 0.1.9
*/
signals[META_DATA_CHANGED] = g_signal_new (
"meta-data-changed",
G_TYPE_FROM_CLASS (class),
(GSignalFlags)(G_SIGNAL_RUN_LAST),
0,
0,
NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING);
gobject_class = G_OBJECT_CLASS (class);
gobject_class->finalize = katze_item_finalize;
gobject_class->set_property = katze_item_set_property;
@ -482,7 +510,7 @@ katze_item_set_meta_data_value (KatzeItem* item,
g_hash_table_insert (item->metadata, g_strdup (&key[7]), value);
else
g_hash_table_insert (item->metadata, g_strdup (key), value);
/* TODO: Emit meta-key-changed */
g_signal_emit (item, signals[META_DATA_CHANGED], 0, key);
}
/**

View file

@ -1335,7 +1335,6 @@ midori_load_session (gpointer data)
return FALSE;
}
#ifdef HAVE_JSCORE
static gint
midori_run_script (const gchar* filename)
{
@ -1373,7 +1372,6 @@ midori_run_script (const gchar* filename)
g_print ("%s - Exception: %s\n", filename, exception);
return 1;
}
#endif
#if WEBKIT_CHECK_VERSION (1, 1, 6)
static void
@ -1415,6 +1413,20 @@ midori_web_app_browser_notify_load_status_cb (MidoriBrowser* browser,
}
}
static void
midori_remove_config_file (gint clear_prefs,
gint flag,
const gchar* filename)
{
if ((clear_prefs & flag) == flag)
{
gchar* config_file = build_config_filename (filename);
if (is_writable (config_file))
g_unlink (config_file);
g_free (config_file);
}
}
int
main (int argc,
char** argv)
@ -1435,10 +1447,8 @@ main (int argc,
N_("Run ADDRESS as a web application"), N_("ADDRESS") },
{ "config", 'c', 0, G_OPTION_ARG_FILENAME, &config,
N_("Use FOLDER as configuration folder"), N_("FOLDER") },
#ifdef HAVE_JSCORE
{ "run", 'r', 0, G_OPTION_ARG_NONE, &run,
N_("Run the specified filename as javascript"), NULL },
#endif
#if WEBKIT_CHECK_VERSION (1, 1, 6)
{ "snapshot", 's', 0, G_OPTION_ARG_STRING, &snapshot,
N_("Take a snapshot of the specified URI"), NULL },
@ -1472,6 +1482,7 @@ main (int argc,
#if HAVE_HILDON
osso_context_t* osso_context;
#endif
gint clear_prefs = MIDORI_CLEAR_NONE;
#if ENABLE_NLS
setlocale (LC_ALL, "");
@ -1589,11 +1600,9 @@ main (int argc,
return 0;
}
#ifdef HAVE_JSCORE
/* Standalone javascript support */
if (run)
return midori_run_script (uris ? *uris : NULL);
#endif
#if HAVE_HILDON
osso_context = osso_initialize (PACKAGE_NAME, PACKAGE_VERSION, FALSE, NULL);
@ -1931,12 +1940,35 @@ main (int argc,
osso_deinitialize (osso_context);
#endif
#if HAVE_SQLITE
settings = katze_object_get_object (app, "settings");
#if HAVE_SQLITE
g_object_get (settings, "maximum-history-age", &max_history_age, NULL);
g_object_unref (settings);
midori_history_terminate (db, max_history_age);
#endif
/* Clear data on quit, according to the Clear private data dialog */
g_object_get (settings, "clear-private-data", &clear_prefs, NULL);
#if HAVE_SQLITE
midori_remove_config_file (clear_prefs, MIDORI_CLEAR_HISTORY, "history.db");
#endif
midori_remove_config_file (clear_prefs, MIDORI_CLEAR_COOKIES, "cookies.txt");
if ((clear_prefs & MIDORI_CLEAR_FLASH_COOKIES) == MIDORI_CLEAR_FLASH_COOKIES)
{
gchar* cache = g_build_filename (g_get_home_dir (), ".macromedia",
"Flash_Player", NULL);
sokoke_remove_path (cache, TRUE);
g_free (cache);
}
if ((clear_prefs & MIDORI_CLEAR_WEBSITE_ICONS) == MIDORI_CLEAR_WEBSITE_ICONS)
{
gchar* cache = g_build_filename (g_get_user_cache_dir (),
PACKAGE_NAME, "icons", NULL);
sokoke_remove_path (cache, TRUE);
g_free (cache);
}
midori_remove_config_file (clear_prefs, MIDORI_CLEAR_TRASH, "tabtrash.xbel");
g_object_unref (settings);
g_object_unref (app);
g_free (config_file);
return 0;

View file

@ -50,7 +50,6 @@ struct _MidoriBrowser
GtkWidget* menu_tools;
GtkWidget* throbber;
GtkWidget* navigationbar;
GtkWidget* bookmark_popup;
GtkWidget* bookmarkbar;
GtkToolItem* homepage;
@ -133,21 +132,12 @@ enum
CONTEXT_READY,
ADD_DOWNLOAD,
SEND_NOTIFICATION,
POPULATE_TOOL_MENU,
QUIT,
LAST_SIGNAL
};
enum
{
MIDORI_CLEAR_NONE = 0,
MIDORI_CLEAR_HISTORY = 1,
MIDORI_CLEAR_COOKIES = 2,
MIDORI_CLEAR_FLASH_COOKIES = 4,
MIDORI_CLEAR_WEBSITE_ICONS = 8,
MIDORI_CLEAR_TRASH = 16
};
static guint signals[LAST_SIGNAL];
static void
@ -176,6 +166,15 @@ static void
_midori_browser_set_toolbar_style (MidoriBrowser* browser,
MidoriToolbarStyle toolbar_style);
GtkWidget*
midori_panel_construct_menu_item (MidoriPanel* panel,
MidoriViewable* viewable);
static void
midori_browser_settings_notify (MidoriWebSettings* web_settings,
GParamSpec* pspec,
MidoriBrowser* browser);
static GtkAction*
_action_by_name (MidoriBrowser* browser,
const gchar* name)
@ -353,12 +352,8 @@ _midori_browser_set_statusbar_text (MidoriBrowser* browser,
MidoriLocationAction* location_action = MIDORI_LOCATION_ACTION (action);
if (text && *text)
{
static GdkPixbuf* blank = NULL;
if (G_UNLIKELY (!blank))
blank = gdk_pixbuf_new_from_data ((guchar*)"",
GDK_COLORSPACE_RGB, TRUE, 8, 1, 1, 1, NULL, NULL);
midori_location_action_set_uri (location_action, text);
midori_location_action_set_icon (location_action, blank);
midori_location_action_set_icon (location_action, NULL);
midori_location_action_set_secondary_icon (location_action, NULL);
}
else
@ -1094,6 +1089,33 @@ midori_view_attach_inspector_cb (GtkWidget* view,
browser->inspector_view = inspector_view;
}
static void
midori_browser_view_copy_history (GtkWidget* view_to,
GtkWidget* view_from,
gboolean omit_last)
{
WebKitWebView* copy_from;
WebKitWebBackForwardList* list_from;
WebKitWebView* copy_to;
WebKitWebBackForwardList* list_to;
guint length_from;
gint i;
copy_from = WEBKIT_WEB_VIEW (gtk_bin_get_child (GTK_BIN (view_from)));
list_from = webkit_web_view_get_back_forward_list (copy_from);
copy_to = WEBKIT_WEB_VIEW (gtk_bin_get_child (GTK_BIN (view_to)));
list_to = webkit_web_view_get_back_forward_list (copy_to);
length_from = webkit_web_back_forward_list_get_back_length (list_from);
g_return_if_fail (!webkit_web_back_forward_list_get_back_length (list_to));
for (i = -length_from; i <= (omit_last ? -1 : 0); i++)
{
webkit_web_back_forward_list_add_item (list_to,
webkit_web_back_forward_list_get_nth_item (list_from, i));
}
}
static void
midori_view_new_tab_cb (GtkWidget* view,
const gchar* uri,
@ -1101,7 +1123,11 @@ midori_view_new_tab_cb (GtkWidget* view,
MidoriBrowser* browser)
{
gint n = midori_browser_add_uri (browser, uri);
_midori_browser_set_current_page_smartly (browser, n);
midori_browser_view_copy_history (midori_browser_get_nth_tab (browser, n),
view, FALSE);
if (!background)
midori_browser_set_current_page (browser, n);
}
static void
@ -1120,6 +1146,7 @@ midori_view_new_view_cb (GtkWidget* view,
MidoriNewView where,
MidoriBrowser* browser)
{
midori_browser_view_copy_history (new_view, view, TRUE);
if (where == MIDORI_NEW_VIEW_WINDOW)
{
MidoriBrowser* new_browser = g_object_new (MIDORI_TYPE_BROWSER, NULL);
@ -1173,7 +1200,7 @@ midori_browser_download_notify_status_cb (WebKitDownload* download,
gchar* path = soup_uri_decode (uri);
gchar* filename = g_strrstr (path, "/") + 1;
gchar* msg = g_strdup_printf (
_("The file <b>%s</b> has been downloaded."), filename);
_("The file '<b>%s</b>' has been downloaded."), filename);
g_free (path);
g_signal_emit (browser, signals[SEND_NOTIFICATION], 0,
@ -1699,6 +1726,27 @@ midori_browser_class_init (MidoriBrowserClass* class)
G_TYPE_STRING,
G_TYPE_STRING);
/**
* MidoriBrowser::populate-tool-menu:
* @browser: the object on which the signal is emitted
* @menu: the #GtkMenu to populate
*
* Emitted when a Tool menu is displayed, such as the
* toplevel Tools in the menubar or the compact menu.
*
* Since: 0.1.9
*/
signals[POPULATE_TOOL_MENU] = g_signal_new (
"populate-tool-menu",
G_TYPE_FROM_CLASS (class),
(GSignalFlags)(G_SIGNAL_RUN_LAST),
0,
0,
NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GTK_TYPE_MENU);
signals[QUIT] = g_signal_new (
"quit",
G_TYPE_FROM_CLASS (class),
@ -2345,7 +2393,7 @@ midori_browser_get_toolbar_actions (MidoriBrowser* browser)
static const gchar* actions[] = {
"WindowNew", "TabNew", "Open", "SaveAs", "Print", "Find",
"Fullscreen", "Preferences", "Window", "Bookmarks",
"RecentlyVisited", "ReloadStop", "ZoomIn",
"RecentlyVisited", "ReloadStop", "ZoomIn", "TabClose",
"ZoomOut", "Separator", "Back", "Forward", "Homepage",
"Panel", "Trash", "Search", NULL };
@ -2485,6 +2533,59 @@ _action_bookmarks_activate_item (GtkAction* action,
gtk_widget_grab_focus (midori_browser_get_current_tab (browser));
}
static void
_action_tools_populate_popup (GtkAction* action,
GtkMenu* menu,
MidoriBrowser* browser)
{
static const GtkActionEntry actions[] = {
{ "ManageSearchEngines" },
{ "ClearPrivateData" },
{ "-" },
{ NULL },
{ "p" },
#ifdef G_OS_WIN32
{ NULL },
{ "Preferences" },
#endif
};
guint i;
for (i = 0; i < G_N_ELEMENTS (actions); i++)
{
GtkWidget* menuitem;
if (actions[i].name != NULL)
{
if (actions[i].name[0] == '-')
{
g_signal_emit (browser, signals[POPULATE_TOOL_MENU], 0, menu);
continue;
}
else if (actions[i].name[0] == 'p')
{
MidoriPanel* panel;
gsize j;
GtkWidget* widget;
panel = MIDORI_PANEL (browser->panel);
j = 0;
while ((widget = midori_panel_get_nth_page (panel, j++)))
{
menuitem = midori_panel_construct_menu_item (panel, MIDORI_VIEWABLE (widget));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
}
continue;
}
menuitem = sokoke_action_create_popup_menu_item (
_action_by_name (browser, actions[i].name));
}
else
menuitem = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
}
}
static gboolean
_action_menus_activate_item_alt (GtkAction* action,
KatzeItem* item,
@ -2546,16 +2647,17 @@ _action_compact_menu_populate_popup (GtkAction* action,
{ "TabNew" },
{ "WindowNew" },
{ "Open" },
{ "PrivateBrowsing" },
{ "Print" },
{ "PrivateBrowsing" },
{ NULL },
{ "Bookmarkbar" },
{ "Panel" },
{ "Statusbar" },
{ NULL },
{ "-" },
{ "ClearPrivateData" },
{ "Fullscreen" },
{ "Preferences" },
{ "ClearPrivateData" },
};
guint i;
@ -2563,14 +2665,20 @@ _action_compact_menu_populate_popup (GtkAction* action,
{
GtkWidget* menuitem;
if (actions[i].name != NULL)
{
if (actions[i].name[0] == '-')
{
g_signal_emit (browser, signals[POPULATE_TOOL_MENU], 0, menu);
continue;
}
menuitem = sokoke_action_create_popup_menu_item (
_action_by_name (browser, actions[i].name));
}
else
menuitem = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
}
gtk_widget_show_all (GTK_WIDGET (menu));
}
static void
@ -3024,32 +3132,6 @@ midori_browser_bookmark_homepage_clicked_cb (GtkToolItem* button,
gtk_widget_grab_focus (midori_browser_get_current_tab (browser));
}
static void
midori_browser_position_popup (GtkWidget* popup,
GtkWidget* widget)
{
gint wx, wy;
GtkRequisition menu_req;
GtkRequisition widget_req;
if (GTK_WIDGET_NO_WINDOW (widget))
{
gdk_window_get_position (widget->window, &wx, &wy);
wx += widget->allocation.x;
wy += widget->allocation.y;
}
else
gdk_window_get_origin (widget->window, &wx, &wy);
gtk_widget_size_request (popup, &menu_req);
gtk_widget_size_request (widget, &widget_req);
gtk_widget_show_all (popup);
gtk_window_move (GTK_WINDOW (popup),
wx, wy + widget_req.height);
gtk_window_resize (GTK_WINDOW (popup),
widget->allocation.width, 1);
}
static void
browser_bookmarks_add_item_cb (KatzeArray* array,
KatzeItem* item,
@ -3061,53 +3143,6 @@ _action_location_focus_in (GtkAction* action,
{
midori_location_action_set_secondary_icon (
MIDORI_LOCATION_ACTION (action), GTK_STOCK_JUMP_TO);
if (!GTK_WIDGET_VISIBLE (browser->bookmarkbar))
{
GSList* proxies = gtk_action_get_proxies (action);
GtkWidget* proxy = g_slist_nth_data (proxies, 0);
if (G_UNLIKELY (!browser->bookmark_popup))
{
GtkWidget* popup = gtk_window_new (GTK_WINDOW_POPUP);
GtkWidget* box = gtk_toolbar_new ();
gchar* homepage = NULL;
guint i;
KatzeItem* item;
/* FIXME: Resize popup to avoid overflowing items */
/* FIXME: Take care of added and removed items */
if (browser->settings)
g_object_get (browser->settings, "homepage", &homepage, NULL);
if (homepage && homepage)
{
GtkToolItem* toolitem;
toolitem = gtk_tool_button_new_from_stock (STOCK_HOMEPAGE);
gtk_tool_item_set_is_important (toolitem, TRUE);
gtk_widget_show (GTK_WIDGET (toolitem));
g_signal_connect (toolitem, "clicked",
G_CALLBACK (midori_browser_bookmark_homepage_clicked_cb),
browser);
gtk_toolbar_insert (GTK_TOOLBAR (box), toolitem, -1);
}
gtk_container_add (GTK_CONTAINER (popup), box);
gtk_window_set_transient_for (GTK_WINDOW (popup), GTK_WINDOW (browser));
gtk_toolbar_set_icon_size (GTK_TOOLBAR (box), GTK_ICON_SIZE_MENU);
gtk_toolbar_set_style (GTK_TOOLBAR (box), GTK_TOOLBAR_BOTH_HORIZ);
i = 0;
if (browser->bookmarks)
while ((item = katze_array_get_nth_item (browser->bookmarks, i++)))
browser_bookmarks_add_item_cb (browser->bookmarks, item, box);
browser->bookmark_popup = popup;
g_signal_connect (popup, "destroy",
G_CALLBACK (gtk_widget_destroyed), &browser->bookmark_popup);
}
if (!GTK_IS_TOOL_ITEM (proxy))
proxy = g_slist_nth_data (proxies, 1);
midori_browser_position_popup (browser->bookmark_popup, proxy);
}
}
static void
@ -3116,9 +3151,6 @@ _action_location_focus_out (GtkAction* action,
{
GtkWidget* view = midori_browser_get_current_tab (browser);
if (browser->bookmark_popup)
gtk_widget_hide (browser->bookmark_popup);
if (!browser->show_navigationbar)
gtk_widget_hide (browser->navigationbar);
@ -3712,6 +3744,16 @@ midori_browser_clear_private_data_response_cb (GtkWidget* dialog,
gtk_widget_destroy (dialog);
}
static void
midori_browser_clear_on_quit_toggled_cb (GtkToggleButton* button,
MidoriWebSettings* settings)
{
gint clear_prefs = MIDORI_CLEAR_NONE;
g_object_get (settings, "clear-private-data", &clear_prefs, NULL);
clear_prefs ^= MIDORI_CLEAR_ON_QUIT;
g_object_set (settings, "clear-private-data", clear_prefs, NULL);
}
static void
_action_clear_private_data_activate (GtkAction* action,
MidoriBrowser* browser)
@ -3783,7 +3825,7 @@ _action_clear_private_data_activate (GtkAction* action,
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
g_object_set_data (G_OBJECT (dialog), "website-icons", button);
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
button = gtk_check_button_new_with_mnemonic (_("_Closed Tabs and Windows"));
button = gtk_check_button_new_with_mnemonic (_("_Closed Tabs"));
if ((clear_prefs & MIDORI_CLEAR_TRASH) == MIDORI_CLEAR_TRASH)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
g_object_set_data (G_OBJECT (dialog), "trash", button);
@ -3791,6 +3833,15 @@ _action_clear_private_data_activate (GtkAction* action,
gtk_container_add (GTK_CONTAINER (alignment), vbox);
gtk_box_pack_start (GTK_BOX (hbox), alignment, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0);
button = gtk_check_button_new_with_mnemonic (_("Clear private data when _quitting Midori"));
if ((clear_prefs & MIDORI_CLEAR_ON_QUIT) == MIDORI_CLEAR_ON_QUIT)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
g_signal_connect (button, "toggled",
G_CALLBACK (midori_browser_clear_on_quit_toggled_cb), browser->settings);
alignment = gtk_alignment_new (0, 0, 1, 1);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 2, 0);
gtk_container_add (GTK_CONTAINER (alignment), button);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), alignment, FALSE, FALSE, 0);
gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);
g_signal_connect (dialog, "response",
@ -3951,6 +4002,38 @@ midori_panel_notify_page_cb (MidoriPanel* panel,
g_object_set (browser->settings, "last-panel-page", page, NULL);
}
static void
midori_panel_notify_show_titles_cb (MidoriPanel* panel,
GParamSpec* pspec,
MidoriBrowser* browser)
{
gboolean show_titles = katze_object_get_boolean (panel, "show-titles");
if (browser->settings)
{
g_signal_handlers_block_by_func (browser->settings,
midori_browser_settings_notify, browser);
g_object_set (browser->settings, "compact-sidepanel", !show_titles, NULL);
g_signal_handlers_unblock_by_func (browser->settings,
midori_browser_settings_notify, browser);
}
}
static void
midori_panel_notify_show_controls_cb (MidoriPanel* panel,
GParamSpec* pspec,
MidoriBrowser* browser)
{
gboolean show_controls = katze_object_get_boolean (panel, "show-controls");
if (browser->settings)
{
g_signal_handlers_block_by_func (browser->settings,
midori_browser_settings_notify, browser);
g_object_set (browser->settings, "show-panel-controls", show_controls, NULL);
g_signal_handlers_unblock_by_func (browser->settings,
midori_browser_settings_notify, browser);
}
}
static void
midori_panel_notify_right_aligned_cb (MidoriPanel* panel,
GParamSpec* pspec,
@ -4110,7 +4193,7 @@ _action_trash_empty_activate (GtkAction* action,
static const GtkActionEntry entries[] = {
{ "File", NULL, N_("_File") },
{ "WindowNew", STOCK_WINDOW_NEW,
NULL, "<Ctrl>n",
N_("New _Window"), "<Ctrl>n",
N_("Open a new window"), G_CALLBACK (_action_window_new_activate) },
{ "TabNew", STOCK_TAB_NEW,
NULL, "<Ctrl>t",
@ -4124,7 +4207,7 @@ static const GtkActionEntry entries[] = {
{ "AddSpeedDial", NULL,
N_("Add to Speed _dial"), "<Ctrl>h",
N_("Add shortcut to speed dial"), G_CALLBACK (_action_add_speed_dial_activate) },
{ "TabClose", NULL,
{ "TabClose", GTK_STOCK_CLOSE,
N_("_Close Tab"), "<Ctrl>w",
N_("Close the current tab"), G_CALLBACK (_action_tab_close_activate) },
{ "WindowClose", NULL,
@ -4159,7 +4242,7 @@ static const GtkActionEntry entries[] = {
{ "Find", GTK_STOCK_FIND,
NULL, "<Ctrl>f",
N_("Find a word or phrase in the page"), G_CALLBACK (_action_find_activate) },
{ "FindNext", GTK_STOCK_GO_FORWARD,
{ "FindNext", NULL,
N_("Find _Next"), "<Ctrl>g",
N_("Find the next occurrence of a word or phrase"), G_CALLBACK (_action_find_next_activate) },
{ "FindPrevious", GTK_STOCK_GO_BACK,
@ -4222,15 +4305,14 @@ static const GtkActionEntry entries[] = {
{ "BookmarkAdd", STOCK_BOOKMARK_ADD,
NULL, "<Ctrl>d",
N_("Add a new bookmark"), G_CALLBACK (_action_bookmark_add_activate) },
{ "BookmarkFolderAdd", GTK_STOCK_DIRECTORY,
{ "BookmarkFolderAdd", NULL,
N_("Add a new _folder"), "",
N_("Add a new bookmark folder"), G_CALLBACK (_action_bookmark_folder_add_activate) },
{ "Tools", NULL, N_("_Tools") },
{ "ManageSearchEngines", GTK_STOCK_PROPERTIES,
N_("_Manage Search Engines"), "<Ctrl><Alt>s",
N_("Add, edit and remove search engines..."),
G_CALLBACK (_action_manage_search_engines_activate) },
{ "ClearPrivateData", GTK_STOCK_CLEAR,
{ "ClearPrivateData", NULL,
N_("_Clear Private Data"), "<Ctrl><Shift>Delete",
N_("Clear private data..."),
G_CALLBACK (_action_clear_private_data_activate) },
@ -4479,15 +4561,7 @@ static const gchar* ui_markup =
"<menuitem action='RecentlyVisited'/>"
"</menu>"
"<menuitem action='Bookmarks'/>"
"<menu action='Tools'>"
"<menuitem action='ManageSearchEngines'/>"
"<menuitem action='ClearPrivateData'/>"
/* Panel items shall be appended here */
#ifdef G_OS_WIN32
"<separator/>"
"<menuitem action='Preferences'/>"
#endif
"</menu>"
"<menuitem action='Tools'/>"
"<menuitem action='Window'/>"
"<menu action='Help'>"
"<menuitem action='HelpContents'/>"
@ -4502,10 +4576,13 @@ static const gchar* ui_markup =
"<menuitem action='FindPrevious'/>"
"<menuitem action='BookmarkAdd'/>"
"<menuitem action='BookmarkFolderAdd'/>"
"<menuitem action='ManageSearchEngines'/>"
"<menuitem action='ClearPrivateData'/>"
"<menuitem action='TabPrevious'/>"
"<menuitem action='TabNext'/>"
"<menuitem action='UndoTabClose'/>"
"<menuitem action='TrashEmpty'/>"
"<menuitem action='Preferences'/>"
"</menu>"
"</menubar>"
"<toolbar name='toolbar_navigation'>"
@ -4695,7 +4772,6 @@ midori_browser_init (MidoriBrowser* browser)
browser->net = katze_net_new ();
browser->bookmark_popup = NULL;
browser->settings = midori_web_settings_new ();
browser->proxy_array = katze_array_new (KATZE_TYPE_ARRAY);
browser->bookmarks = NULL;
@ -4861,6 +4937,18 @@ midori_browser_init (MidoriBrowser* browser)
gtk_action_group_add_action_with_accel (browser->action_group, action, "");
g_object_unref (action);
action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
"name", "Tools",
"label", _("_Tools"),
"array", katze_array_new (KATZE_TYPE_ITEM),
NULL);
g_object_connect (action,
"signal::populate-popup",
_action_tools_populate_popup, browser,
NULL);
gtk_action_group_add_action (browser->action_group, action);
g_object_unref (action);
action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
"name", "Window",
"label", _("_Window"),
@ -4922,20 +5010,19 @@ midori_browser_init (MidoriBrowser* browser)
gtk_widget_set_sensitive (menuitem, FALSE);
gtk_menu_item_set_right_justified (GTK_MENU_ITEM (menuitem), TRUE);
gtk_menu_shell_append (GTK_MENU_SHELL (browser->menubar), menuitem);
browser->menu_tools = gtk_menu_item_get_submenu (GTK_MENU_ITEM (
gtk_ui_manager_get_widget (ui_manager, "/menubar/Tools")));
menuitem = gtk_separator_menu_item_new ();
gtk_widget_show (menuitem);
gtk_menu_shell_insert (GTK_MENU_SHELL (browser->menu_tools), menuitem, 3);
browser->menu_tools = gtk_menu_new ();
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (
gtk_ui_manager_get_widget (ui_manager, "/menubar/File/WindowNew")), NULL);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (
gtk_ui_manager_get_widget (ui_manager, "/menubar/Go/Location")), NULL);
homepage = gtk_ui_manager_get_widget (ui_manager, "/menubar/Go/Homepage");
g_signal_connect (homepage, "button-press-event",
G_CALLBACK (midori_browser_menu_item_middle_click_event_cb), browser);
back = gtk_ui_manager_get_widget (ui_manager, "/menubar/Go/Back");
g_signal_connect (back, "button-press-event",
G_CALLBACK (midori_browser_menu_item_middle_click_event_cb), browser);
forward = gtk_ui_manager_get_widget (ui_manager, "/menubar/Go/Forward");
g_signal_connect (forward, "button-press-event",
G_CALLBACK (midori_browser_menu_item_middle_click_event_cb), browser);
@ -5004,12 +5091,18 @@ midori_browser_init (MidoriBrowser* browser)
browser->panel = g_object_new (MIDORI_TYPE_PANEL,
"menu", browser->menu_tools,
NULL);
g_signal_connect (browser->panel, "notify::page",
G_CALLBACK (midori_panel_notify_page_cb), browser);
g_signal_connect (browser->panel, "notify::right-aligned",
G_CALLBACK (midori_panel_notify_right_aligned_cb), browser);
g_signal_connect (browser->panel, "close",
G_CALLBACK (midori_panel_close_cb), browser);
g_object_connect (browser->panel,
"signal::notify::page",
midori_panel_notify_page_cb, browser,
"signal::notify::show-titles",
midori_panel_notify_show_titles_cb, browser,
"signal::notify::show-controls",
midori_panel_notify_show_controls_cb, browser,
"signal::notify::right-aligned",
midori_panel_notify_right_aligned_cb, browser,
"signal::close",
midori_panel_close_cb, browser,
NULL);
gtk_paned_pack1 (GTK_PANED (hpaned), browser->panel, FALSE, FALSE);
/* Notebook, containing all views */
@ -5307,7 +5400,7 @@ _midori_browser_update_settings (MidoriBrowser* browser)
gboolean remember_last_window_size;
gint last_window_width, last_window_height;
MidoriWindowState last_window_state;
gboolean compact_sidepanel, right_align_sidepanel;
gboolean compact_sidepanel, show_panel_controls, right_align_sidepanel;
gint last_panel_position, last_panel_page;
gboolean show_menubar, show_bookmarkbar;
gboolean show_panel, show_transferbar;
@ -5328,6 +5421,7 @@ _midori_browser_update_settings (MidoriBrowser* browser)
"last-window-height", &last_window_height,
"last-window-state", &last_window_state,
"compact-sidepanel", &compact_sidepanel,
"show-panel-controls", &show_panel_controls,
"right-align-sidepanel", &right_align_sidepanel,
"last-panel-position", &last_panel_position,
"last-panel-page", &last_panel_page,
@ -5401,9 +5495,9 @@ _midori_browser_update_settings (MidoriBrowser* browser)
}
}
midori_panel_set_compact (MIDORI_PANEL (browser->panel), compact_sidepanel);
midori_panel_set_right_aligned (MIDORI_PANEL (browser->panel),
right_align_sidepanel);
g_object_set (browser->panel, "show-titles", !compact_sidepanel,
"show-controls", show_panel_controls,
"right-aligned", right_align_sidepanel, NULL);
gtk_paned_set_position (GTK_PANED (gtk_widget_get_parent (browser->panel)),
last_panel_position);
/* The browser may not yet be visible, which means that we can't set the
@ -5447,8 +5541,11 @@ midori_browser_settings_notify (MidoriWebSettings* web_settings,
else if (name == g_intern_string ("toolbar-items"))
_midori_browser_set_toolbar_items (browser, g_value_get_string (&value));
else if (name == g_intern_string ("compact-sidepanel"))
midori_panel_set_compact (MIDORI_PANEL (browser->panel),
g_value_get_boolean (&value));
g_object_set (browser->panel, "show-titles",
!g_value_get_boolean (&value), NULL);
else if (name == g_intern_string ("show-controls"))
g_object_set (browser->panel, "show-controls",
g_value_get_boolean (&value), NULL);
else if (name == g_intern_string ("always-show-tabbar"))
_toggle_tabbar_smartly (browser);
else if (name == g_intern_string ("show-navigationbar"))
@ -6010,6 +6107,28 @@ midori_browser_get_current_page (MidoriBrowser* browser)
return gtk_notebook_get_current_page (GTK_NOTEBOOK (browser->notebook));
}
/**
* midori_browser_get_nth_tab:
* @browser: a #MidoriBrowser
* @page: the index of a tab
*
* Retrieves the tab at the position @page.
*
* If there is no page present at all, %NULL is returned.
*
* Return value: the selected page, or -1
*
* Since: 0.1.9
**/
GtkWidget*
midori_browser_get_nth_tab (MidoriBrowser* browser,
gint page)
{
g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
return gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), page);
}
/**
* midori_browser_set_current_tab:
* @browser: a #MidoriBrowser

View file

@ -122,6 +122,10 @@ midori_browser_set_current_page (MidoriBrowser* browser,
gint
midori_browser_get_current_page (MidoriBrowser* browser);
GtkWidget*
midori_browser_get_nth_tab (MidoriBrowser* browser,
gint n);
void
midori_browser_set_current_tab (MidoriBrowser* browser,
GtkWidget* widget);

View file

@ -1119,6 +1119,16 @@ midori_location_action_set_uri (MidoriLocationAction* location_action,
midori_location_action_set_text (location_action, uri);
}
/**
* midori_location_action_set_icon:
* @location_action: a #MidoriLocationAction
* @icon: a #GdkPixbuf or %NULL
*
* Sets the icon shown on the left hand side.
*
* Note: Since 0.1.8 %NULL can be passed to indicate that the
* visible URI refers to a target, not the current location.
**/
void
midori_location_action_set_icon (MidoriLocationAction* location_action,
GdkPixbuf* icon)
@ -1128,7 +1138,7 @@ midori_location_action_set_icon (MidoriLocationAction* location_action,
GtkWidget* entry;
g_return_if_fail (MIDORI_IS_LOCATION_ACTION (location_action));
g_return_if_fail (GDK_IS_PIXBUF (icon));
g_return_if_fail (!icon || GDK_IS_PIXBUF (icon));
proxies = gtk_action_get_proxies (GTK_ACTION (location_action));
@ -1138,8 +1148,12 @@ midori_location_action_set_icon (MidoriLocationAction* location_action,
location_entry = midori_location_action_entry_for_proxy (proxies->data);
entry = gtk_bin_get_child (GTK_BIN (location_entry));
if (icon)
gtk_icon_entry_set_icon_from_pixbuf (GTK_ICON_ENTRY (entry),
GTK_ICON_ENTRY_PRIMARY, icon);
else
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (entry),
GTK_ICON_ENTRY_PRIMARY, GTK_STOCK_JUMP_TO);
}
}

View file

@ -23,6 +23,7 @@ struct _MidoriPanel
{
GtkHBox parent_instance;
GtkWidget* labelbar;
GtkWidget* toolbar;
GtkToolItem* button_align;
GtkToolItem* button_detach;
@ -32,6 +33,8 @@ struct _MidoriPanel
GtkWidget* notebook;
GtkMenu* menu;
gboolean show_titles;
gboolean show_controls;
gboolean right_aligned;
};
@ -53,6 +56,8 @@ enum
PROP_SHADOW_TYPE,
PROP_MENU,
PROP_PAGE,
PROP_SHOW_TITLES,
PROP_SHOW_CONTROLS,
PROP_RIGHT_ALIGNED,
};
@ -133,6 +138,15 @@ midori_panel_class_init (MidoriPanelClass* class)
GTK_SHADOW_NONE,
flags));
/**
* MidoriWebSettings:menu:
*
* This is the menu that holds the panel menu items.
*
* You shouldn't use this menu or add items.
*
* Deprecated: 0.1.9
*/
g_object_class_install_property (gobject_class,
PROP_MENU,
g_param_spec_object (
@ -151,6 +165,38 @@ midori_panel_class_init (MidoriPanelClass* class)
-1, G_MAXINT, -1,
flags));
/**
* MidoriWebSettings:show-titles:
*
* Whether to show panel titles.
*
* Since: 0.1.9
*/
g_object_class_install_property (gobject_class,
PROP_SHOW_TITLES,
g_param_spec_boolean (
"show-titles",
"Show Titles",
"Whether to show panel titles",
TRUE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* MidoriWebSettings:show-controls:
*
* Whether to show operating controls.
*
* Since: 0.1.9
*/
g_object_class_install_property (gobject_class,
PROP_SHOW_CONTROLS,
g_param_spec_boolean (
"show-controls",
"Show Controls",
"Whether to show operating controls",
TRUE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* MidoriWebSettings:right-aligned:
*
@ -301,6 +347,8 @@ midori_panel_init (MidoriPanel* panel)
GtkWidget* labelbar;
GtkToolItem* toolitem;
panel->show_titles = TRUE;
panel->show_controls = TRUE;
panel->right_aligned = FALSE;
/* Create the sidebar */
@ -317,6 +365,7 @@ midori_panel_init (MidoriPanel* panel)
/* Create the titlebar */
labelbar = gtk_toolbar_new ();
panel->labelbar = labelbar;
gtk_toolbar_set_icon_size (GTK_TOOLBAR (labelbar), GTK_ICON_SIZE_MENU);
gtk_toolbar_set_style (GTK_TOOLBAR (labelbar), GTK_TOOLBAR_ICONS);
toolitem = gtk_tool_item_new ();
@ -329,6 +378,8 @@ midori_panel_init (MidoriPanel* panel)
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_FULLSCREEN);
gtk_widget_set_sensitive (GTK_WIDGET (toolitem), FALSE);
panel->button_detach = toolitem;
gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem),
_("Detach chosen panel from the window"));
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (toolitem),
_("Detach chosen panel from the window"));
g_signal_connect (toolitem, "clicked",
@ -339,6 +390,8 @@ midori_panel_init (MidoriPanel* panel)
gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, -1);
#endif
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_GO_FORWARD);
gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem),
_("Align sidepanel to the right"));
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (toolitem),
_("Align sidepanel to the right"));
g_signal_connect (toolitem, "clicked",
@ -404,11 +457,23 @@ midori_panel_set_property (GObject* object,
break;
case PROP_MENU:
katze_object_assign (panel->menu, g_value_dup_object (value));
/* FIXME: Move existing items to the new menu */
break;
case PROP_PAGE:
midori_panel_set_current_page (panel, g_value_get_int (value));
break;
case PROP_SHOW_TITLES:
panel->show_titles = g_value_get_boolean (value);
#if HAVE_HILDON
panel->show_titles = TRUE;
#endif
gtk_toolbar_set_style (GTK_TOOLBAR (panel->toolbar),
panel->show_titles ? GTK_TOOLBAR_BOTH : GTK_TOOLBAR_ICONS);
break;
case PROP_SHOW_CONTROLS:
panel->show_controls = g_value_get_boolean (value);
sokoke_widget_set_visible (panel->labelbar, panel->show_controls);
sokoke_widget_set_visible (panel->toolbar, panel->show_controls);
break;
case PROP_RIGHT_ALIGNED:
midori_panel_set_right_aligned (panel, g_value_get_boolean (value));
break;
@ -438,6 +503,12 @@ midori_panel_get_property (GObject* object,
case PROP_PAGE:
g_value_set_int (value, midori_panel_get_current_page (panel));
break;
case PROP_SHOW_TITLES:
g_value_set_boolean (value, panel->show_titles);
break;
case PROP_SHOW_CONTROLS:
g_value_set_boolean (value, panel->show_controls);
break;
case PROP_RIGHT_ALIGNED:
g_value_set_boolean (value, panel->right_aligned);
break;
@ -468,6 +539,8 @@ midori_panel_new (void)
* @compact: %TRUE if the panel should be compact
*
* Determines if the panel should be compact.
*
* Deprecated: 0.1.9
**/
void
midori_panel_set_compact (MidoriPanel* panel,
@ -475,11 +548,7 @@ midori_panel_set_compact (MidoriPanel* panel,
{
g_return_if_fail (MIDORI_IS_PANEL (panel));
#if HAVE_HILDON
compact = TRUE;
#endif
gtk_toolbar_set_style (GTK_TOOLBAR (panel->toolbar),
compact ? GTK_TOOLBAR_ICONS : GTK_TOOLBAR_BOTH);
g_object_set (panel, "show-titles", !compact, NULL);
}
/**
@ -504,6 +573,9 @@ midori_panel_set_right_aligned (MidoriPanel* panel,
gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON (panel->button_align),
right_aligned ? GTK_STOCK_GO_BACK : GTK_STOCK_GO_FORWARD);
panel->right_aligned = right_aligned;
gtk_tool_button_set_label (GTK_TOOL_BUTTON (panel->button_align),
!panel->right_aligned ? _("Align sidepanel to the right")
: _("Align sidepanel to the left"));
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (panel->button_align),
!panel->right_aligned ? _("Align sidepanel to the right")
: _("Align sidepanel to the left"));
@ -515,26 +587,46 @@ midori_panel_menu_item_activate_cb (GtkWidget* widget,
MidoriPanel* panel)
{
GtkWidget* child;
GtkToggleToolButton* toolitem;
GtkToolItem* toolitem;
guint n;
child = g_object_get_data (G_OBJECT (widget), "page");
toolitem = g_object_get_data (G_OBJECT (widget), "toolitem");
n = midori_panel_page_num (panel, child);
toolitem = gtk_toolbar_get_nth_item (GTK_TOOLBAR (panel->toolbar), n);
if (toolitem)
{
/* Unsetting the button before setting it ensures that
it will emit signals even if it was active before */
gtk_toggle_tool_button_set_active (toolitem, FALSE);
gtk_toggle_tool_button_set_active (toolitem, TRUE);
GtkToggleToolButton* button = GTK_TOGGLE_TOOL_BUTTON (toolitem);
g_signal_handlers_block_by_func (widget,
midori_panel_menu_item_activate_cb, panel);
gtk_toggle_tool_button_set_active (button, FALSE);
gtk_toggle_tool_button_set_active (button, TRUE);
g_signal_handlers_unblock_by_func (widget,
midori_panel_menu_item_activate_cb, panel);
}
else
{
n = midori_panel_page_num (panel, child);
midori_panel_set_current_page (panel, n);
g_signal_emit (panel, signals[SWITCH_PAGE], 0, n);
gtk_widget_show (GTK_WIDGET (panel));
}
}
/* Private function, used by MidoriBrowser */
/* static */ GtkWidget*
midori_panel_construct_menu_item (MidoriPanel* panel,
MidoriViewable* viewable)
{
const gchar* stock_id;
GtkWidget* menuitem;
stock_id = midori_viewable_get_stock_id (viewable);
menuitem = gtk_image_menu_item_new_from_stock (stock_id, NULL);
gtk_widget_show (menuitem);
g_object_set_data (G_OBJECT (menuitem), "page", viewable);
g_signal_connect (menuitem, "activate",
G_CALLBACK (midori_panel_menu_item_activate_cb), panel);
return menuitem;
}
static void
@ -582,6 +674,54 @@ midori_panel_construct_tool_item (MidoriPanel* panel,
return toolitem;
}
static void
midori_panel_show_titles_toggled_cb (GtkWidget* menuitem,
MidoriPanel* panel)
{
g_object_set (panel, "show-titles", !panel->show_titles, NULL);
}
static void
midori_panel_show_controls_toggled_cb (GtkWidget* menuitem,
MidoriPanel* panel)
{
g_object_set (panel, "show-controls", !panel->show_controls, NULL);
}
static void
midori_panel_options_clicked_cb (GtkToolItem* toolitem,
MidoriPanel* panel)
{
gint n;
GtkWidget* viewable;
GtkWidget* menu;
GtkWidget* menuitem;
n = midori_panel_get_current_page (panel);
viewable = midori_panel_get_nth_page (panel, n);
menu = gtk_menu_new ();
#if !HAVE_HILDON
menuitem = gtk_check_menu_item_new_with_mnemonic (_("Show panel _titles"));
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem),
panel->show_titles);
g_signal_connect (menuitem, "toggled",
G_CALLBACK (midori_panel_show_titles_toggled_cb), panel);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
#endif
menuitem = gtk_check_menu_item_new_with_mnemonic (_("Show operating _controls"));
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem),
panel->show_controls);
g_signal_connect (menuitem, "toggled",
G_CALLBACK (midori_panel_show_controls_toggled_cb), panel);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
g_signal_emit_by_name (viewable, "populate-option-menu", menu);
katze_widget_popup (GTK_WIDGET (toolitem), GTK_MENU (menu),
NULL, SOKOKE_MENU_POSITION_LEFT);
}
/**
* midori_panel_append_page:
* @panel: a #MidoriPanel
@ -608,10 +748,8 @@ midori_panel_append_page (MidoriPanel* panel,
GObjectClass* gobject_class;
GtkWidget* widget;
GtkWidget* toolbar;
const gchar* label;
const gchar* stock_id;
GtkToolItem* toolitem;
GtkWidget* menuitem;
const gchar* label;
guint n;
g_return_val_if_fail (MIDORI_IS_PANEL (panel), -1);
@ -641,6 +779,12 @@ midori_panel_append_page (MidoriPanel* panel,
gtk_container_add (GTK_CONTAINER (panel->notebook), scrolled);
toolbar = midori_viewable_get_toolbar (viewable);
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_PROPERTIES);
gtk_tool_item_set_tooltip_text (toolitem, _("Options"));
g_signal_connect (toolitem, "clicked",
G_CALLBACK (midori_panel_options_clicked_cb), panel);
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, 0);
gtk_widget_show (GTK_WIDGET (toolitem));
gtk_widget_show (toolbar);
gtk_container_add (GTK_CONTAINER (panel->toolbook), toolbar);
g_signal_connect (viewable, "destroy",
@ -648,26 +792,9 @@ midori_panel_append_page (MidoriPanel* panel,
n = midori_panel_page_num (panel, scrolled);
label = midori_viewable_get_label (viewable);
stock_id = midori_viewable_get_stock_id (viewable);
toolitem = midori_panel_construct_tool_item (panel, viewable);
if (panel->menu)
{
menuitem = gtk_image_menu_item_new_from_stock (stock_id, NULL);
gtk_widget_show (menuitem);
g_object_set_data (G_OBJECT (menuitem), "page", viewable);
g_object_set_data (G_OBJECT (menuitem), "toolitem", toolitem);
g_signal_connect (menuitem, "activate",
G_CALLBACK (midori_panel_menu_item_activate_cb),
panel);
gtk_menu_shell_insert (GTK_MENU_SHELL (panel->menu), menuitem, 4);
g_object_set_data (G_OBJECT (scrolled), "panel-menuitem", menuitem);
g_signal_connect (viewable, "destroy",
G_CALLBACK (midori_panel_widget_destroy_cb), menuitem);
}
g_object_set_data (G_OBJECT (viewable), "parent", scrolled);
midori_panel_construct_tool_item (panel, viewable);
g_signal_connect (viewable, "destroy",
G_CALLBACK (midori_panel_viewable_destroy_cb), panel);

View file

@ -562,11 +562,9 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
#if !HAVE_HILDON
button = katze_property_proxy (settings, "middle-click-opens-selection", NULL);
INDENTED_ADD (button, 0, 1, 3, 4);
button = katze_property_proxy (settings, "compact-sidepanel", NULL);
WIDGET_ADD (button, 1, 2, 3, 4);
button = katze_property_proxy (settings, "open-popups-in-tabs", NULL);
SPANNED_ADD (button, 1, 2, 3, 4);
#endif
/* button = katze_property_proxy (settings, "open-popups-in-tabs", NULL);
SPANNED_ADD (button, 0, 1, 4, 5);*/
button = katze_property_proxy (settings, "open-tabs-next-to-current", NULL);
WIDGET_ADD (button, 0, 1, 5, 6);
button = katze_property_proxy (settings, "close-buttons-on-tabs", NULL);

View file

@ -471,6 +471,10 @@ midori_search_action_icon_released_cb (GtkWidget* entry,
gtk_image_set_from_pixbuf (GTK_IMAGE (image), icon);
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 (GTK_MENU_SHELL (menu), menuitem);
g_object_set_data (G_OBJECT (menuitem), "engine", item);
g_signal_connect (menuitem, "activate",

View file

@ -52,6 +52,11 @@ midori_view_get_snapshot (MidoriView* view,
gint width,
gint height);
static void
midori_view_item_meta_data_changed (KatzeItem* item,
const gchar* key,
MidoriView* view);
struct _MidoriView
{
GtkScrolledWindow parent_instance;
@ -62,6 +67,7 @@ struct _MidoriView
GdkPixbuf* icon;
gdouble progress;
MidoriLoadStatus load_status;
gboolean minimized;
gchar* statusbar_text;
gchar* link_uri;
gboolean has_selection;
@ -144,6 +150,7 @@ enum
PROP_ICON,
PROP_LOAD_STATUS,
PROP_PROGRESS,
PROP_MINIMIZED,
PROP_ZOOM_LEVEL,
PROP_NEWS_FEEDS,
PROP_STATUSBAR_TEXT,
@ -464,6 +471,26 @@ midori_view_class_init (MidoriViewClass* class)
0.0, 1.0, 0.0,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/**
* MidoriView:minimized:
*
* Whether the view is minimized or in normal state.
*
* Minimizing a view indicates that only the icon should
* be advertised rather than the full blown tab label and
* it might otherwise be presented specially.
*
* Since: 0.1.8
*/
g_object_class_install_property (gobject_class,
PROP_MINIMIZED,
g_param_spec_boolean (
"minimized",
"Minimized",
"Whether the view is minimized or in normal state",
FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class,
PROP_ZOOM_LEVEL,
g_param_spec_float (
@ -1084,12 +1111,17 @@ static void
midori_web_view_menu_new_tab_activate_cb (GtkWidget* widget,
MidoriView* view)
{
gchar* uri = view->link_uri;
if (!uri)
uri = (gchar*)g_object_get_data (G_OBJECT (widget), "uri");
if (view->link_uri)
g_signal_emit (view, signals[NEW_TAB], 0, view->link_uri,
view->open_tabs_in_the_background);
else
{
gchar* data = (gchar*)g_object_get_data (G_OBJECT (widget), "uri");
gchar* uri = sokoke_magic_uri (data, NULL);
g_signal_emit (view, signals[NEW_TAB], 0, uri,
view->open_tabs_in_the_background);
g_free (uri);
}
}
static void
@ -1259,6 +1291,10 @@ webkit_web_view_populate_popup_cb (WebKitWebView* web_view,
icon = gtk_image_new_from_pixbuf (pixbuf);
g_object_unref (pixbuf);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), icon);
#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_insert (GTK_MENU_SHELL (sub_menu), menuitem, i - 1);
g_object_set_data (G_OBJECT (menuitem), "search",
(gchar*)katze_item_get_uri (item));
@ -1596,6 +1632,7 @@ midori_view_init (MidoriView* view)
GTK_ICON_SIZE_MENU, NULL);
view->progress = 0.0;
view->load_status = MIDORI_LOAD_FINISHED;
view->minimized = FALSE;
view->statusbar_text = NULL;
view->link_uri = NULL;
view->selected_text = NULL;
@ -1621,6 +1658,9 @@ midori_view_finalize (GObject* object)
if (view->settings)
g_signal_handlers_disconnect_by_func (view->settings,
midori_view_settings_notify_cb, view);
if (view->item)
g_signal_handlers_disconnect_by_func (view->item,
midori_view_item_meta_data_changed, view);
katze_assign (view->uri, NULL);
katze_assign (view->title, NULL);
@ -1657,6 +1697,20 @@ midori_view_set_property (GObject* object,
katze_assign (view->title, g_value_dup_string (value));
midori_view_update_title (view);
break;
case PROP_MINIMIZED:
view->minimized = g_value_get_boolean (value);
if (view->item)
{
g_signal_handlers_block_by_func (view->item,
midori_view_item_meta_data_changed, view);
katze_item_set_meta_integer (view->item, "minimized",
view->minimized ? 1 : -1);
g_signal_handlers_unblock_by_func (view->item,
midori_view_item_meta_data_changed, view);
}
if (view->tab_label)
sokoke_widget_set_visible (view->tab_title, !view->minimized);
break;
case PROP_ZOOM_LEVEL:
midori_view_set_zoom_level (view, g_value_get_float (value));
break;
@ -1705,6 +1759,9 @@ midori_view_get_property (GObject* object,
case PROP_LOAD_STATUS:
g_value_set_enum (value, midori_view_get_load_status (view));
break;
case PROP_MINIMIZED:
g_value_set_boolean (value, view->minimized);
break;
case PROP_ZOOM_LEVEL:
g_value_set_float (value, midori_view_get_zoom_level (view));
break;
@ -2427,6 +2484,13 @@ midori_view_get_proxy_menu_item (MidoriView* view)
return view->menu_item;
}
static void
midori_view_tab_label_menu_new_tab_cb (GtkWidget* menuitem,
MidoriView* view)
{
g_signal_emit (view, signals[NEW_TAB], 0, "", FALSE);
}
static void
midori_view_tab_label_menu_open_cb (GtkWidget* menuitem,
GtkWidget* view)
@ -2452,9 +2516,17 @@ midori_view_tab_label_menu_duplicate_tab_cb (GtkWidget* menuitem,
"net", view->net, "settings", view->settings, NULL);
midori_view_set_uri (MIDORI_VIEW (new_view),
midori_view_get_display_uri (view));
gtk_widget_show (new_view);
g_signal_emit (view, signals[NEW_VIEW], 0, new_view, where);
}
static void
midori_view_tab_label_menu_minimize_tab_cb (GtkWidget* menuitem,
MidoriView* view)
{
g_object_set (view, "minimized", !view->minimized, NULL);
}
static void
midori_view_tab_label_menu_close_cb (GtkWidget* menuitem,
GtkWidget* view)
@ -2482,6 +2554,12 @@ midori_view_get_tab_menu (MidoriView* view)
g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
menu = gtk_menu_new ();
menuitem = gtk_menu_item_new_with_mnemonic (_("New _Tab"));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
g_signal_connect (menuitem, "activate",
G_CALLBACK (midori_view_tab_label_menu_new_tab_cb), view);
menuitem = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_OPEN, NULL);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
g_signal_connect (menuitem, "activate",
@ -2494,6 +2572,11 @@ midori_view_get_tab_menu (MidoriView* view)
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
g_signal_connect (menuitem, "activate",
G_CALLBACK (midori_view_tab_label_menu_duplicate_tab_cb), view);
menuitem = gtk_menu_item_new_with_mnemonic (
view->minimized ? _("_Restore Tab") : _("_Minimize Tab"));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
g_signal_connect (menuitem, "activate",
G_CALLBACK (midori_view_tab_label_menu_minimize_tab_cb), view);
menuitem = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_CLOSE, NULL);
@ -2668,6 +2751,27 @@ midori_view_tab_label_query_tooltip_cb (GtkWidget* tab_label,
}
#endif
/**
* midori_view_get_label_ellipsize:
* @view: a #MidoriView
*
* Determines how labels representing the view should be
* ellipsized, which is helpful for alternative labels.
*
* Return value: how to ellipsize the label
*
* Since: 0.1.9
**/
PangoEllipsizeMode
midori_view_get_label_ellipsize (MidoriView* view)
{
g_return_val_if_fail (MIDORI_IS_VIEW (view), PANGO_ELLIPSIZE_END);
if (view->tab_label)
return gtk_label_get_ellipsize (GTK_LABEL (view->tab_title));
return PANGO_ELLIPSIZE_END;
}
/**
* midori_view_get_proxy_tab_label:
* @view: a #MidoriView
@ -2763,6 +2867,16 @@ midori_view_get_proxy_tab_label (MidoriView* view)
return view->tab_label;
}
static void
midori_view_item_meta_data_changed (KatzeItem* item,
const gchar* key,
MidoriView* view)
{
if (g_str_equal (key, "minimized"))
g_object_set (view, "minimized",
katze_item_get_meta_string (item, key) != NULL, NULL);
}
/**
* midori_view_get_proxy_item:
* @view: a #MidoriView
@ -2790,6 +2904,8 @@ midori_view_get_proxy_item (MidoriView* view)
katze_item_set_uri (view->item, uri);
title = midori_view_get_display_title (view);
katze_item_set_name (view->item, title);
g_signal_connect (view->item, "meta-data-changed",
G_CALLBACK (midori_view_item_meta_data_changed), view);
}
return view->item;
}

View file

@ -116,6 +116,9 @@ midori_view_get_proxy_menu_item (MidoriView* view);
GtkWidget*
midori_view_get_tab_menu (MidoriView* view);
PangoEllipsizeMode
midori_view_get_label_ellipsize (MidoriView* view);
GtkWidget*
midori_view_get_proxy_tab_label (MidoriView* view);

View file

@ -13,6 +13,14 @@
#include <glib/gi18n.h>
enum {
POPULATE_OPTION_MENU,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
static void
midori_viewable_base_init (MidoriViewableIface* iface);
@ -68,6 +76,27 @@ midori_viewable_base_init (MidoriViewableIface* iface)
if (initialized)
return;
/**
* MidoriViewable::populate-option-menu:
* @viewable: the object on which the signal is emitted
* @menu: the #GtkMenu to populate
*
* Emitted when an Option menu is displayed, for instance
* when the user clicks the Options button in the panel.
*
* Since: 0.1.9
*/
signals[POPULATE_OPTION_MENU] = g_signal_new (
"populate-option-menu",
G_TYPE_FROM_INTERFACE (iface),
(GSignalFlags)(G_SIGNAL_RUN_LAST),
0,
0,
NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GTK_TYPE_MENU);
iface->p = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
iface->get_stock_id = midori_viewable_default_get_stock_id;
@ -258,6 +287,6 @@ midori_viewable_get_toolbar (MidoriViewable* viewable)
toolbar = MIDORI_VIEWABLE_GET_IFACE (viewable)->get_toolbar (viewable);
if (!toolbar)
toolbar = gtk_event_box_new ();
toolbar = gtk_toolbar_new ();
return toolbar;
}

View file

@ -48,6 +48,7 @@ struct _MidoriWebSettings
gboolean search_engines_in_completion;
gchar* toolbar_items;
gboolean compact_sidepanel;
gboolean show_panel_controls;
gboolean right_align_sidepanel;
MidoriStartup load_on_startup;
@ -123,6 +124,7 @@ enum
PROP_SEARCH_ENGINES_IN_COMPLETION,
PROP_TOOLBAR_ITEMS,
PROP_COMPACT_SIDEPANEL,
PROP_SHOW_PANEL_CONTROLS,
PROP_RIGHT_ALIGN_SIDEPANEL,
PROP_LOAD_ON_STARTUP,
@ -192,9 +194,9 @@ midori_startup_get_type (void)
if (!type)
{
static const GEnumValue values[] = {
{ MIDORI_STARTUP_BLANK_PAGE, "MIDORI_STARTUP_BLANK_PAGE", N_("Blank page") },
{ MIDORI_STARTUP_HOMEPAGE, "MIDORI_STARTUP_HOMEPAGE", N_("Homepage") },
{ MIDORI_STARTUP_LAST_OPEN_PAGES, "MIDORI_STARTUP_LAST_OPEN_PAGES", N_("Last open pages") },
{ MIDORI_STARTUP_BLANK_PAGE, "MIDORI_STARTUP_BLANK_PAGE", N_("Show Blank page") },
{ MIDORI_STARTUP_HOMEPAGE, "MIDORI_STARTUP_HOMEPAGE", N_("Show Homepage") },
{ MIDORI_STARTUP_LAST_OPEN_PAGES, "MIDORI_STARTUP_LAST_OPEN_PAGES", N_("Show last open tabs") },
{ 0, NULL, NULL }
};
type = g_enum_register_static ("MidoriStartup", values);
@ -249,8 +251,8 @@ midori_toolbar_style_get_type (void)
{ MIDORI_TOOLBAR_DEFAULT, "MIDORI_TOOLBAR_DEFAULT", N_("Default") },
{ MIDORI_TOOLBAR_ICONS, "MIDORI_TOOLBAR_ICONS", N_("Icons") },
{ MIDORI_TOOLBAR_TEXT, "MIDORI_TOOLBAR_TEXT", N_("Text") },
{ MIDORI_TOOLBAR_BOTH, "MIDORI_TOOLBAR_BOTH", N_("Both") },
{ MIDORI_TOOLBAR_BOTH_HORIZ, "MIDORI_TOOLBAR_BOTH_HORIZ", N_("Both horizontal") },
{ MIDORI_TOOLBAR_BOTH, "MIDORI_TOOLBAR_BOTH", N_("Icons and text") },
{ MIDORI_TOOLBAR_BOTH_HORIZ, "MIDORI_TOOLBAR_BOTH_HORIZ", N_("Text beside icons") },
{ 0, NULL, NULL }
};
type = g_enum_register_static ("MidoriToolbarStyle", values);
@ -473,7 +475,7 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
PROP_TOOLBAR_STYLE,
g_param_spec_enum (
"toolbar-style",
_("Toolbar Style"),
_("Toolbar Style:"),
_("The style of the toolbar"),
MIDORI_TYPE_TOOLBAR_STYLE,
MIDORI_TOOLBAR_DEFAULT,
@ -529,6 +531,22 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
FALSE,
flags));
/**
* MidoriWebSettings:show-panel-controls:
*
* Whether to show the operating controls of the panel.
*
* Since: 0.1.9
*/
g_object_class_install_property (gobject_class,
PROP_SHOW_PANEL_CONTROLS,
g_param_spec_boolean (
"show-panel-controls",
_("Show operating controls of the panel"),
_("Whether to show the operating controls of the panel"),
TRUE,
flags));
/**
* MidoriWebSettings:right-sidepanel:
*
@ -550,8 +568,8 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
PROP_LOAD_ON_STARTUP,
g_param_spec_enum (
"load-on-startup",
_("Load on Startup"),
_("What to load on startup"),
_("When Midori starts:"),
_("What to do when Midori starts"),
MIDORI_TYPE_STARTUP,
MIDORI_STARTUP_LAST_OPEN_PAGES,
flags));
@ -560,7 +578,7 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
PROP_HOMEPAGE,
g_param_spec_string (
"homepage",
_("Homepage"),
_("Homepage:"),
_("The homepage"),
"http://www.google.com",
flags));
@ -602,7 +620,7 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
PROP_DOWNLOAD_FOLDER,
g_param_spec_string (
"download-folder",
_("Download Folder"),
_("Save downloaded files to:"),
_("The folder downloaded files are saved to"),
midori_get_download_dir (),
#if WEBKIT_CHECK_VERSION (1, 1, 3)
@ -727,7 +745,7 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
PROP_OPEN_NEW_PAGES_IN,
g_param_spec_enum (
"open-new-pages-in",
_("Open new pages in"),
_("Open new pages in:"),
_("Where to open new pages"),
MIDORI_TYPE_NEW_PAGE,
MIDORI_NEW_PAGE_TAB,
@ -737,7 +755,7 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
PROP_OPEN_EXTERNAL_PAGES_IN,
g_param_spec_enum (
"open-external-pages-in",
_("Open external pages in"),
_("Open external pages in:"),
_("Where to open externally opened pages"),
MIDORI_TYPE_NEW_PAGE,
MIDORI_NEW_PAGE_TAB,
@ -1000,6 +1018,7 @@ midori_web_settings_init (MidoriWebSettings* web_settings)
web_settings->notify_transfer_completed = TRUE;
web_settings->download_folder = g_strdup (midori_get_download_dir ());
web_settings->http_proxy = NULL;
web_settings->show_panel_controls = TRUE;
web_settings->open_popups_in_tabs = TRUE;
web_settings->remember_last_form_inputs = TRUE;
web_settings->remember_last_downloaded_files = TRUE;
@ -1174,6 +1193,9 @@ midori_web_settings_set_property (GObject* object,
case PROP_COMPACT_SIDEPANEL:
web_settings->compact_sidepanel = g_value_get_boolean (value);
break;
case PROP_SHOW_PANEL_CONTROLS:
web_settings->show_panel_controls = g_value_get_boolean (value);
break;
case PROP_RIGHT_ALIGN_SIDEPANEL:
web_settings->right_align_sidepanel = g_value_get_boolean (value);
break;
@ -1386,6 +1408,9 @@ midori_web_settings_get_property (GObject* object,
case PROP_COMPACT_SIDEPANEL:
g_value_set_boolean (value, web_settings->compact_sidepanel);
break;
case PROP_SHOW_PANEL_CONTROLS:
g_value_set_boolean (value, web_settings->show_panel_controls);
break;
case PROP_RIGHT_ALIGN_SIDEPANEL:
g_value_set_boolean (value, web_settings->right_align_sidepanel);
break;

View file

@ -34,6 +34,17 @@ G_BEGIN_DECLS
typedef struct _MidoriWebSettings MidoriWebSettings;
typedef struct _MidoriWebSettingsClass MidoriWebSettingsClass;
enum
{
MIDORI_CLEAR_NONE = 0,
MIDORI_CLEAR_HISTORY = 1,
MIDORI_CLEAR_COOKIES = 2,
MIDORI_CLEAR_FLASH_COOKIES = 4,
MIDORI_CLEAR_WEBSITE_ICONS = 8,
MIDORI_CLEAR_TRASH = 16,
MIDORI_CLEAR_ON_QUIT = 32,
};
typedef enum
{
MIDORI_WINDOW_NORMAL,

View file

@ -36,7 +36,6 @@
#include <idna.h>
#endif
#ifdef HAVE_JSCORE
static gchar*
sokoke_js_string_utf8 (JSStringRef js_string)
{
@ -50,22 +49,18 @@ sokoke_js_string_utf8 (JSStringRef js_string)
JSStringGetUTF8CString (js_string, string_utf8, size_utf8);
return string_utf8;
}
#endif
gchar*
sokoke_js_script_eval (JSContextRef js_context,
const gchar* script,
gchar** exception)
{
#ifdef HAVE_JSCORE
gchar* value;
JSStringRef js_value_string;
#endif
g_return_val_if_fail (js_context, FALSE);
g_return_val_if_fail (script, FALSE);
#ifdef HAVE_JSCORE
JSStringRef js_script = JSStringCreateWithUTF8CString (script);
JSValueRef js_exception = NULL;
JSValueRef js_value = JSEvaluateScript (js_context, js_script,
@ -84,9 +79,6 @@ sokoke_js_script_eval (JSContextRef js_context,
value = sokoke_js_string_utf8 (js_value_string);
JSStringRelease (js_value_string);
return value;
#else
return g_strdup ("");
#endif
}
static void
@ -873,7 +865,7 @@ sokoke_register_stock_items (void)
{ STOCK_TAB_NEW, N_("New _Tab"), 0, 0, GTK_STOCK_ADD },
{ STOCK_TRANSFERS, N_("_Transfers"), 0, 0, GTK_STOCK_SAVE },
{ STOCK_PLUGINS, N_("Netscape p_lugins"), 0, 0, GTK_STOCK_CONVERT },
{ STOCK_USER_TRASH, N_("_Closed Tabs and Windows"), 0, 0, "gtk-undo-ltr" },
{ STOCK_USER_TRASH, N_("_Closed Tabs"), 0, 0, "gtk-undo-ltr" },
{ STOCK_WINDOW_NEW, N_("New _Window"), 0, 0, GTK_STOCK_ADD },
};

887
po/de.po

File diff suppressed because it is too large Load diff

1045
po/el.po

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

1258
po/pt.po

File diff suppressed because it is too large Load diff

View file

@ -25,7 +25,7 @@ import misc
major = 0
minor = 1
micro = 8
micro = 9
APPNAME = 'midori'
VERSION = str (major) + '.' + str (minor) + '.' + str (micro)