2008-03-10 21:26:09 +00:00
|
|
|
/*
|
2009-01-31 03:09:35 +00:00
|
|
|
Copyright (C) 2007-2009 Christian Dywan <christian@twotoasts.de>
|
2008-10-07 00:19:33 +00:00
|
|
|
Copyright (C) 2008 Dale Whittaker <dayul@users.sf.net>
|
2009-05-07 20:41:39 +00:00
|
|
|
Copyright (C) 2009 Jérôme Geulfucci <jeromeg@xfce.org>
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2008-08-14 23:57:48 +00:00
|
|
|
#if HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
#include "midori-browser.h"
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
#include "midori-view.h"
|
2008-04-20 01:30:24 +00:00
|
|
|
#include "midori-preferences.h"
|
2008-03-10 21:26:09 +00:00
|
|
|
#include "midori-panel.h"
|
2008-08-14 23:57:48 +00:00
|
|
|
#include "midori-locationaction.h"
|
2008-10-05 21:25:02 +00:00
|
|
|
#include "midori-searchaction.h"
|
2008-09-03 00:39:25 +00:00
|
|
|
#include "midori-stock.h"
|
|
|
|
|
|
|
|
#include "gtkiconentry.h"
|
2008-07-16 12:24:30 +00:00
|
|
|
#include "compat.h"
|
2009-05-09 13:55:10 +00:00
|
|
|
#include "marshal.h"
|
2008-09-03 00:39:25 +00:00
|
|
|
#include "sokoke.h"
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-04-16 23:38:22 +00:00
|
|
|
#include <glib/gi18n.h>
|
2008-10-10 21:19:37 +00:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
2008-03-10 21:26:09 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <string.h>
|
2008-10-20 19:32:25 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
struct _MidoriBrowser
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2009-01-27 01:57:40 +00:00
|
|
|
#if HAVE_HILDON
|
|
|
|
HildonWindow parent_instance;
|
|
|
|
#else
|
2008-06-19 18:39:00 +00:00
|
|
|
GtkWindow parent_instance;
|
2009-01-27 01:57:40 +00:00
|
|
|
#endif
|
2008-06-19 18:39:00 +00:00
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
GtkActionGroup* action_group;
|
|
|
|
GtkWidget* menubar;
|
|
|
|
GtkWidget* menu_tools;
|
|
|
|
GtkWidget* throbber;
|
|
|
|
GtkWidget* navigationbar;
|
|
|
|
GtkWidget* bookmarkbar;
|
2009-07-17 02:28:53 +00:00
|
|
|
GtkToolItem* homepage;
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
GtkWidget* panel;
|
|
|
|
GtkWidget* notebook;
|
|
|
|
|
2008-11-01 18:15:58 +00:00
|
|
|
GtkWidget* inspector;
|
|
|
|
GtkWidget* inspector_view;
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
GtkWidget* find;
|
|
|
|
GtkWidget* find_text;
|
|
|
|
GtkToolItem* find_case;
|
|
|
|
GtkToolItem* find_highlight;
|
2009-02-22 01:34:21 +00:00
|
|
|
GtkToolItem* find_close;
|
2009-02-22 01:17:58 +00:00
|
|
|
gboolean find_typing;
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
GtkWidget* statusbar;
|
2009-03-19 17:28:50 +00:00
|
|
|
GtkWidget* transferbar;
|
2009-04-19 17:05:05 +00:00
|
|
|
GtkWidget* transferbar_clear;
|
2008-03-10 21:26:09 +00:00
|
|
|
GtkWidget* progressbar;
|
|
|
|
gchar* statusbar_text;
|
|
|
|
|
2009-01-25 23:54:12 +00:00
|
|
|
guint alloc_timeout;
|
|
|
|
guint panel_timeout;
|
|
|
|
|
2009-05-22 21:53:54 +00:00
|
|
|
gint clear_private_data;
|
|
|
|
|
2008-10-10 20:31:37 +00:00
|
|
|
MidoriWebSettings* settings;
|
2008-09-26 21:13:46 +00:00
|
|
|
KatzeArray* proxy_array;
|
2008-10-10 20:31:37 +00:00
|
|
|
KatzeArray* bookmarks;
|
2008-08-25 23:19:38 +00:00
|
|
|
KatzeArray* trash;
|
|
|
|
KatzeArray* search_engines;
|
2008-10-07 00:19:33 +00:00
|
|
|
KatzeArray* history;
|
2009-06-22 21:48:41 +00:00
|
|
|
gboolean show_tabs;
|
2008-10-20 19:32:25 +00:00
|
|
|
|
2008-10-23 22:09:12 +00:00
|
|
|
KatzeNet* net;
|
2009-02-28 13:05:01 +00:00
|
|
|
|
|
|
|
gboolean show_navigationbar;
|
|
|
|
gboolean show_statusbar;
|
2009-05-10 14:07:28 +00:00
|
|
|
gboolean speed_dial_in_new_tabs;
|
2009-02-28 13:05:01 +00:00
|
|
|
gboolean progress_in_location;
|
|
|
|
gboolean remember_last_visited_pages;
|
2009-04-18 20:41:37 +00:00
|
|
|
gchar* location_entry_search;
|
2009-04-14 17:44:48 +00:00
|
|
|
gchar* news_aggregator;
|
2008-03-10 21:26:09 +00:00
|
|
|
};
|
|
|
|
|
2009-01-27 01:57:40 +00:00
|
|
|
#if HAVE_HILDON
|
|
|
|
G_DEFINE_TYPE (MidoriBrowser, midori_browser, HILDON_TYPE_WINDOW)
|
|
|
|
#else
|
2008-06-19 18:39:00 +00:00
|
|
|
G_DEFINE_TYPE (MidoriBrowser, midori_browser, GTK_TYPE_WINDOW)
|
2009-01-27 01:57:40 +00:00
|
|
|
#endif
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
|
2008-05-02 20:30:26 +00:00
|
|
|
PROP_MENUBAR,
|
|
|
|
PROP_NAVIGATIONBAR,
|
2008-11-18 01:02:59 +00:00
|
|
|
PROP_NOTEBOOK,
|
|
|
|
PROP_PANEL,
|
2008-07-23 18:17:13 +00:00
|
|
|
PROP_URI,
|
2008-05-02 20:30:26 +00:00
|
|
|
PROP_TAB,
|
2008-11-23 04:19:43 +00:00
|
|
|
PROP_LOAD_STATUS,
|
2008-05-02 20:30:26 +00:00
|
|
|
PROP_STATUSBAR,
|
2008-03-10 21:26:09 +00:00
|
|
|
PROP_STATUSBAR_TEXT,
|
2008-09-03 00:28:54 +00:00
|
|
|
PROP_SETTINGS,
|
|
|
|
PROP_BOOKMARKS,
|
2008-06-15 02:02:56 +00:00
|
|
|
PROP_TRASH,
|
2008-10-07 00:19:33 +00:00
|
|
|
PROP_SEARCH_ENGINES,
|
2009-06-22 21:48:41 +00:00
|
|
|
PROP_HISTORY,
|
|
|
|
PROP_SHOW_TABS,
|
2008-03-10 21:26:09 +00:00
|
|
|
};
|
|
|
|
|
2008-04-26 00:43:32 +00:00
|
|
|
enum
|
|
|
|
{
|
2008-04-28 20:38:57 +00:00
|
|
|
NEW_WINDOW,
|
2008-05-31 22:21:08 +00:00
|
|
|
ADD_TAB,
|
2008-07-23 18:17:13 +00:00
|
|
|
REMOVE_TAB,
|
2008-05-31 22:21:08 +00:00
|
|
|
ACTIVATE_ACTION,
|
2008-11-23 04:19:43 +00:00
|
|
|
CONTEXT_READY,
|
2009-03-22 14:24:40 +00:00
|
|
|
ADD_DOWNLOAD,
|
2009-05-09 13:55:10 +00:00
|
|
|
SEND_NOTIFICATION,
|
2009-07-24 21:55:57 +00:00
|
|
|
POPULATE_TOOL_MENU,
|
2008-05-31 22:21:08 +00:00
|
|
|
QUIT,
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint signals[LAST_SIGNAL];
|
|
|
|
|
2008-07-25 10:45:50 +00:00
|
|
|
static void
|
|
|
|
midori_browser_dispose (GObject* object);
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
midori_browser_finalize (GObject* object);
|
|
|
|
|
|
|
|
static void
|
2008-03-27 00:21:29 +00:00
|
|
|
midori_browser_set_property (GObject* object,
|
|
|
|
guint prop_id,
|
2008-03-10 21:26:09 +00:00
|
|
|
const GValue* value,
|
2008-03-27 00:21:29 +00:00
|
|
|
GParamSpec* pspec);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
static void
|
2008-03-27 00:21:29 +00:00
|
|
|
midori_browser_get_property (GObject* object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue* value,
|
2008-03-10 21:26:09 +00:00
|
|
|
GParamSpec* pspec);
|
|
|
|
|
2008-10-07 00:19:33 +00:00
|
|
|
static void
|
|
|
|
midori_browser_new_history_item (MidoriBrowser* browser,
|
|
|
|
KatzeItem* item);
|
2008-07-17 19:02:14 +00:00
|
|
|
|
2009-07-20 04:54:46 +00:00
|
|
|
static void
|
|
|
|
_midori_browser_set_toolbar_style (MidoriBrowser* browser,
|
|
|
|
MidoriToolbarStyle toolbar_style);
|
|
|
|
|
2009-07-24 21:55:57 +00:00
|
|
|
GtkWidget*
|
|
|
|
midori_panel_construct_menu_item (MidoriPanel* panel,
|
|
|
|
MidoriViewable* viewable);
|
|
|
|
|
2009-07-26 20:00:10 +00:00
|
|
|
static void
|
|
|
|
midori_browser_settings_notify (MidoriWebSettings* web_settings,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser);
|
|
|
|
|
2009-08-19 21:51:59 +00:00
|
|
|
static void
|
|
|
|
midori_browser_set_bookmarks (MidoriBrowser* browser,
|
|
|
|
KatzeArray* bookmarks);
|
|
|
|
|
2009-08-30 13:52:30 +00:00
|
|
|
static void
|
|
|
|
midori_browser_add_download_item (MidoriBrowser* browser,
|
|
|
|
WebKitDownload* download);
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static GtkAction*
|
|
|
|
_action_by_name (MidoriBrowser* browser,
|
|
|
|
const gchar* name)
|
|
|
|
{
|
2008-06-19 18:39:00 +00:00
|
|
|
return gtk_action_group_get_action (browser->action_group, name);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_set_sensitive (MidoriBrowser* browser,
|
|
|
|
const gchar* name,
|
|
|
|
gboolean sensitive)
|
|
|
|
{
|
|
|
|
gtk_action_set_sensitive (_action_by_name (browser, name), sensitive);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_set_active (MidoriBrowser* browser,
|
|
|
|
const gchar* name,
|
|
|
|
gboolean active)
|
|
|
|
{
|
|
|
|
GtkAction* action = _action_by_name (browser, name);
|
|
|
|
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), active);
|
|
|
|
}
|
|
|
|
|
2008-10-03 23:45:17 +00:00
|
|
|
static void
|
|
|
|
_toggle_tabbar_smartly (MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
guint n;
|
|
|
|
gboolean always_show_tabbar;
|
|
|
|
|
2009-06-22 21:48:41 +00:00
|
|
|
if (!browser->show_tabs)
|
|
|
|
return;
|
|
|
|
|
2008-10-03 23:45:17 +00:00
|
|
|
n = gtk_notebook_get_n_pages (GTK_NOTEBOOK (browser->notebook));
|
2009-02-21 23:12:18 +00:00
|
|
|
if (n < 2 && browser->settings)
|
2008-10-03 23:45:17 +00:00
|
|
|
{
|
|
|
|
g_object_get (browser->settings, "always-show-tabbar",
|
|
|
|
&always_show_tabbar, NULL);
|
|
|
|
if (always_show_tabbar)
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (browser->notebook), n > 1);
|
2009-07-13 20:15:45 +00:00
|
|
|
gtk_notebook_set_show_border (GTK_NOTEBOOK (browser->notebook), n > 1);
|
2008-10-03 23:45:17 +00:00
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
_midori_browser_update_actions (MidoriBrowser* browser)
|
|
|
|
{
|
2008-07-13 19:49:57 +00:00
|
|
|
guint n;
|
2008-08-25 23:19:38 +00:00
|
|
|
gboolean trash_empty;
|
2008-07-13 19:49:57 +00:00
|
|
|
|
2008-10-03 23:45:17 +00:00
|
|
|
_toggle_tabbar_smartly (browser);
|
2008-07-13 19:49:57 +00:00
|
|
|
n = gtk_notebook_get_n_pages (GTK_NOTEBOOK (browser->notebook));
|
2008-03-10 21:26:09 +00:00
|
|
|
_action_set_sensitive (browser, "TabClose", n > 1);
|
|
|
|
_action_set_sensitive (browser, "TabPrevious", n > 1);
|
|
|
|
_action_set_sensitive (browser, "TabNext", n > 1);
|
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
if (browser->trash)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-08-25 23:19:38 +00:00
|
|
|
trash_empty = katze_array_is_empty (browser->trash);
|
2008-03-10 21:26:09 +00:00
|
|
|
_action_set_sensitive (browser, "UndoTabClose", !trash_empty);
|
|
|
|
_action_set_sensitive (browser, "Trash", !trash_empty);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-28 13:05:01 +00:00
|
|
|
static gboolean
|
|
|
|
midori_browser_view_can_set_encoding (MidoriView* view)
|
|
|
|
{
|
|
|
|
static GParamSpec* pspec = NULL;
|
|
|
|
if (G_UNLIKELY (!pspec))
|
|
|
|
pspec = g_object_class_find_property (
|
|
|
|
g_type_class_peek (WEBKIT_TYPE_WEB_VIEW), "custom-encoding");
|
|
|
|
/* Web views and zoom, source views can't, so zoom means encoding */
|
|
|
|
return pspec && midori_view_can_zoom_in (view);
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
_midori_browser_update_interface (MidoriBrowser* browser)
|
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view;
|
2008-07-06 14:12:27 +00:00
|
|
|
gboolean loading;
|
2008-09-26 21:13:46 +00:00
|
|
|
gboolean can_reload;
|
2008-08-14 23:57:48 +00:00
|
|
|
GtkAction* action;
|
2008-07-13 19:49:57 +00:00
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
view = midori_browser_get_current_tab (browser);
|
|
|
|
loading = midori_view_get_load_status (MIDORI_VIEW (view))
|
2008-07-23 15:54:24 +00:00
|
|
|
!= MIDORI_LOAD_FINISHED;
|
2008-09-26 21:13:46 +00:00
|
|
|
can_reload = midori_view_can_reload (MIDORI_VIEW (view));
|
|
|
|
|
|
|
|
_action_set_sensitive (browser, "Reload", can_reload && !loading);
|
|
|
|
_action_set_sensitive (browser, "Stop", can_reload && loading);
|
|
|
|
_action_set_sensitive (browser, "Back",
|
|
|
|
midori_view_can_go_back (MIDORI_VIEW (view)));
|
|
|
|
_action_set_sensitive (browser, "Forward",
|
|
|
|
midori_view_can_go_forward (MIDORI_VIEW (view)));
|
|
|
|
|
2009-05-10 12:57:26 +00:00
|
|
|
gtk_action_set_visible (_action_by_name (browser, "AddSpeedDial"),
|
2009-05-22 22:07:52 +00:00
|
|
|
browser->speed_dial_in_new_tabs && !midori_view_is_blank (MIDORI_VIEW (view)));
|
2008-10-26 16:07:59 +00:00
|
|
|
/* Currently views that don't support source, don't support
|
2008-11-09 21:07:42 +00:00
|
|
|
saving either. If that changes, we need to think of something. */
|
2008-10-26 16:07:59 +00:00
|
|
|
_action_set_sensitive (browser, "SaveAs",
|
|
|
|
midori_view_can_view_source (MIDORI_VIEW (view)));
|
2008-09-26 21:13:46 +00:00
|
|
|
_action_set_sensitive (browser, "Print",
|
|
|
|
midori_view_can_print (MIDORI_VIEW (view)));
|
|
|
|
_action_set_sensitive (browser, "ZoomIn",
|
|
|
|
midori_view_can_zoom_in (MIDORI_VIEW (view)));
|
|
|
|
_action_set_sensitive (browser, "ZoomOut",
|
|
|
|
midori_view_can_zoom_out (MIDORI_VIEW (view)));
|
|
|
|
_action_set_sensitive (browser, "ZoomNormal",
|
2009-03-05 21:45:34 +00:00
|
|
|
midori_view_get_zoom_level (MIDORI_VIEW (view)) != 1.0f);
|
2009-02-27 22:09:36 +00:00
|
|
|
_action_set_sensitive (browser, "Encoding",
|
2009-02-28 13:05:01 +00:00
|
|
|
midori_browser_view_can_set_encoding (MIDORI_VIEW (view)));
|
2008-09-26 21:13:46 +00:00
|
|
|
_action_set_sensitive (browser, "SourceView",
|
|
|
|
midori_view_can_view_source (MIDORI_VIEW (view)));
|
|
|
|
_action_set_sensitive (browser, "Find",
|
|
|
|
midori_view_can_find (MIDORI_VIEW (view)));
|
|
|
|
_action_set_sensitive (browser, "FindNext",
|
|
|
|
midori_view_can_find (MIDORI_VIEW (view)));
|
|
|
|
_action_set_sensitive (browser, "FindPrevious",
|
|
|
|
midori_view_can_find (MIDORI_VIEW (view)));
|
2008-09-28 14:29:41 +00:00
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (browser->find_highlight),
|
|
|
|
midori_view_can_find (MIDORI_VIEW (view)));
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-08-14 23:57:48 +00:00
|
|
|
action = gtk_action_group_get_action (browser->action_group, "ReloadStop");
|
2008-03-10 21:26:09 +00:00
|
|
|
if (!loading)
|
|
|
|
{
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_widget_set_sensitive (browser->throbber, FALSE);
|
2008-03-10 21:26:09 +00:00
|
|
|
g_object_set (action,
|
|
|
|
"stock-id", GTK_STOCK_REFRESH,
|
2008-08-31 00:45:13 +00:00
|
|
|
"tooltip", _("Reload the current page"),
|
2008-09-26 21:13:46 +00:00
|
|
|
"sensitive", can_reload, NULL);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_widget_hide (browser->progressbar);
|
2009-02-28 13:05:01 +00:00
|
|
|
if (!browser->show_navigationbar && !browser->show_statusbar)
|
2008-10-21 22:26:20 +00:00
|
|
|
gtk_widget_hide (browser->navigationbar);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_widget_set_sensitive (browser->throbber, TRUE);
|
2008-03-10 21:26:09 +00:00
|
|
|
g_object_set (action,
|
|
|
|
"stock-id", GTK_STOCK_STOP,
|
2008-03-22 02:38:23 +00:00
|
|
|
"tooltip", _("Stop loading the current page"), NULL);
|
2009-04-12 12:09:06 +00:00
|
|
|
if (!browser->progress_in_location || !GTK_WIDGET_VISIBLE (browser->navigationbar))
|
|
|
|
gtk_widget_show (browser->progressbar);
|
2009-02-11 22:41:09 +00:00
|
|
|
if (!GTK_WIDGET_VISIBLE (browser->statusbar) &&
|
|
|
|
!GTK_WIDGET_VISIBLE (browser->navigationbar) &&
|
2009-02-28 13:05:01 +00:00
|
|
|
browser->progress_in_location)
|
2008-10-21 22:26:20 +00:00
|
|
|
gtk_widget_show (browser->navigationbar);
|
2009-02-28 13:05:01 +00:00
|
|
|
if (browser->progress_in_location)
|
2009-02-11 22:41:09 +00:00
|
|
|
{
|
|
|
|
action = _action_by_name (browser, "Location");
|
|
|
|
midori_location_action_set_progress (MIDORI_LOCATION_ACTION (action),
|
|
|
|
midori_view_get_progress (MIDORI_VIEW (view)));
|
|
|
|
}
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
2008-06-19 18:39:00 +00:00
|
|
|
katze_throbber_set_animated (KATZE_THROBBER (browser->throbber), loading);
|
2008-08-02 02:25:05 +00:00
|
|
|
|
2009-04-13 20:40:57 +00:00
|
|
|
action = _action_by_name (browser, "Location");
|
2009-06-13 01:45:11 +00:00
|
|
|
if (g_object_get_data (G_OBJECT (view), "news-feeds"))
|
2009-04-13 20:40:57 +00:00
|
|
|
midori_location_action_set_secondary_icon (
|
|
|
|
MIDORI_LOCATION_ACTION (action), STOCK_NEWS_FEED);
|
2008-08-02 02:25:05 +00:00
|
|
|
else
|
2009-04-13 20:40:57 +00:00
|
|
|
midori_location_action_set_secondary_icon (
|
2009-06-13 01:45:11 +00:00
|
|
|
MIDORI_LOCATION_ACTION (action), GTK_STOCK_JUMP_TO);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_midori_browser_set_statusbar_text (MidoriBrowser* browser,
|
|
|
|
const gchar* text)
|
|
|
|
{
|
2009-09-19 19:06:33 +00:00
|
|
|
GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
|
|
|
|
gboolean is_location = widget ?
|
|
|
|
MIDORI_IS_LOCATION_ENTRY (gtk_widget_get_parent (widget)) : FALSE;
|
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
katze_assign (browser->statusbar_text, g_strdup (text));
|
2009-07-17 02:06:44 +00:00
|
|
|
|
2009-09-19 19:06:33 +00:00
|
|
|
if (!GTK_WIDGET_VISIBLE (browser->statusbar) && !is_location)
|
2009-07-17 02:06:44 +00:00
|
|
|
{
|
|
|
|
GtkAction* action = _action_by_name (browser, "Location");
|
|
|
|
MidoriLocationAction* location_action = MIDORI_LOCATION_ACTION (action);
|
|
|
|
if (text && *text)
|
|
|
|
{
|
|
|
|
midori_location_action_set_uri (location_action, text);
|
2009-07-24 15:01:02 +00:00
|
|
|
midori_location_action_set_icon (location_action, NULL);
|
2009-07-17 02:06:44 +00:00
|
|
|
midori_location_action_set_secondary_icon (location_action, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
|
|
|
if (G_LIKELY (view))
|
|
|
|
{
|
|
|
|
if (g_object_get_data (G_OBJECT (view), "news-feeds"))
|
|
|
|
midori_location_action_set_secondary_icon (
|
|
|
|
location_action, STOCK_NEWS_FEED);
|
|
|
|
else
|
|
|
|
midori_location_action_set_secondary_icon (
|
|
|
|
location_action, GTK_STOCK_JUMP_TO);
|
|
|
|
midori_location_action_set_uri (location_action,
|
|
|
|
midori_view_get_display_uri (MIDORI_VIEW (view)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_statusbar_pop (GTK_STATUSBAR (browser->statusbar), 1);
|
|
|
|
gtk_statusbar_push (GTK_STATUSBAR (browser->statusbar), 1,
|
|
|
|
browser->statusbar_text ? browser->statusbar_text : "");
|
|
|
|
}
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2008-04-24 22:20:43 +00:00
|
|
|
static void
|
|
|
|
_midori_browser_set_current_page_smartly (MidoriBrowser* browser,
|
|
|
|
gint n)
|
|
|
|
{
|
2008-11-18 22:10:21 +00:00
|
|
|
if (!katze_object_get_boolean (browser->settings,
|
2008-07-16 16:08:47 +00:00
|
|
|
"open-tabs-in-the-background"))
|
2008-04-24 22:20:43 +00:00
|
|
|
midori_browser_set_current_page (browser, n);
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
_midori_browser_update_progress (MidoriBrowser* browser,
|
2008-09-26 21:13:46 +00:00
|
|
|
MidoriView* view)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-08-31 00:45:13 +00:00
|
|
|
MidoriLocationAction* action;
|
2008-07-23 15:54:24 +00:00
|
|
|
gdouble progress;
|
|
|
|
gchar* message;
|
|
|
|
|
2008-08-31 00:45:13 +00:00
|
|
|
action = MIDORI_LOCATION_ACTION (_action_by_name (browser, "Location"));
|
2008-09-26 21:13:46 +00:00
|
|
|
progress = midori_view_get_progress (view);
|
2008-08-31 00:45:13 +00:00
|
|
|
/* When we are finished, we don't want to *see* progress anymore */
|
2008-09-26 21:13:46 +00:00
|
|
|
if (midori_view_get_load_status (view) == MIDORI_LOAD_FINISHED)
|
2008-08-31 00:45:13 +00:00
|
|
|
progress = 0.0;
|
2008-07-23 15:54:24 +00:00
|
|
|
if (progress > 0.0)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (browser->progressbar),
|
2008-07-23 15:54:24 +00:00
|
|
|
progress);
|
|
|
|
message = g_strdup_printf (_("%d%% loaded"), (gint)(progress * 100));
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (browser->progressbar),
|
2008-03-10 21:26:09 +00:00
|
|
|
message);
|
|
|
|
g_free (message);
|
2009-02-28 13:05:01 +00:00
|
|
|
if (!browser->progress_in_location)
|
2009-02-11 22:41:09 +00:00
|
|
|
progress = 0.0;
|
2008-10-21 22:26:20 +00:00
|
|
|
midori_location_action_set_progress (action, progress);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-07-23 15:54:24 +00:00
|
|
|
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (browser->progressbar));
|
|
|
|
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (browser->progressbar),
|
|
|
|
NULL);
|
2008-08-31 00:45:13 +00:00
|
|
|
midori_location_action_set_progress (action, 0.0);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-28 20:38:57 +00:00
|
|
|
static void
|
2008-09-26 21:13:46 +00:00
|
|
|
_midori_browser_activate_action (MidoriBrowser* browser,
|
|
|
|
const gchar* name)
|
|
|
|
{
|
|
|
|
GtkAction* action = _action_by_name (browser, name);
|
|
|
|
if (action)
|
|
|
|
gtk_action_activate (action);
|
|
|
|
else
|
|
|
|
g_warning (_("Unexpected action '%s'."), name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_view_notify_icon_cb (MidoriView* view,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
2008-04-28 20:38:57 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
const gchar* uri;
|
|
|
|
GtkAction* action;
|
|
|
|
|
|
|
|
uri = midori_view_get_display_uri (MIDORI_VIEW (view));
|
|
|
|
action = _action_by_name (browser, "Location");
|
2009-02-28 13:05:01 +00:00
|
|
|
if (browser->remember_last_visited_pages)
|
2008-10-13 16:29:46 +00:00
|
|
|
midori_location_action_set_icon_for_uri (
|
2008-09-26 21:13:46 +00:00
|
|
|
MIDORI_LOCATION_ACTION (action), midori_view_get_icon (view), uri);
|
2008-04-28 20:38:57 +00:00
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_view_notify_load_status_cb (GtkWidget* view,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-07-23 15:54:24 +00:00
|
|
|
const gchar* uri;
|
2008-08-14 23:57:48 +00:00
|
|
|
GtkAction* action;
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
uri = midori_view_get_display_uri (MIDORI_VIEW (view));
|
2008-08-14 23:57:48 +00:00
|
|
|
action = _action_by_name (browser, "Location");
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
if (midori_view_get_load_status (MIDORI_VIEW (view))
|
2008-08-14 23:57:48 +00:00
|
|
|
== MIDORI_LOAD_COMMITTED)
|
2008-10-13 16:29:46 +00:00
|
|
|
{
|
2009-02-28 13:05:01 +00:00
|
|
|
if (browser->remember_last_visited_pages)
|
2008-10-13 16:29:46 +00:00
|
|
|
midori_location_action_add_uri (MIDORI_LOCATION_ACTION (action), uri);
|
|
|
|
}
|
2008-07-23 15:54:24 +00:00
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
if (view == midori_browser_get_current_tab (browser))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
if (midori_view_get_load_status (MIDORI_VIEW (view))
|
2008-07-23 15:54:24 +00:00
|
|
|
== MIDORI_LOAD_COMMITTED)
|
|
|
|
{
|
2008-08-14 23:57:48 +00:00
|
|
|
midori_location_action_set_uri (
|
|
|
|
MIDORI_LOCATION_ACTION (action), uri);
|
|
|
|
midori_location_action_set_secondary_icon (
|
2009-06-13 01:45:11 +00:00
|
|
|
MIDORI_LOCATION_ACTION (action), GTK_STOCK_JUMP_TO);
|
2008-07-23 18:17:13 +00:00
|
|
|
g_object_notify (G_OBJECT (browser), "uri");
|
2008-07-23 15:54:24 +00:00
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
_midori_browser_update_interface (browser);
|
|
|
|
_midori_browser_set_statusbar_text (browser, NULL);
|
2009-05-16 21:52:59 +00:00
|
|
|
|
|
|
|
/* This is a hack to ensure that the address entry is focussed
|
|
|
|
with speed dial open. */
|
2009-05-26 05:41:17 +00:00
|
|
|
if (midori_view_is_blank (MIDORI_VIEW (view)))
|
|
|
|
gtk_action_activate (_action_by_name (browser, "Location"));
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
2008-11-23 04:19:43 +00:00
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (browser), "load-status");
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_view_notify_progress_cb (GtkWidget* view,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
if (view == midori_browser_get_current_tab (browser))
|
|
|
|
_midori_browser_update_progress (browser, MIDORI_VIEW (view));
|
|
|
|
}
|
|
|
|
|
2008-10-15 01:07:38 +00:00
|
|
|
static void
|
2008-11-23 04:19:43 +00:00
|
|
|
midori_view_context_ready_cb (GtkWidget* view,
|
|
|
|
JSContextRef js_context,
|
|
|
|
MidoriBrowser* browser)
|
2008-10-15 01:07:38 +00:00
|
|
|
{
|
2008-11-23 04:19:43 +00:00
|
|
|
g_signal_emit (browser, signals[CONTEXT_READY], 0, js_context);
|
2008-10-15 01:07:38 +00:00
|
|
|
}
|
|
|
|
|
2009-05-14 23:18:14 +00:00
|
|
|
static void
|
|
|
|
midori_view_notify_uri_cb (GtkWidget* view,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-05-15 15:30:54 +00:00
|
|
|
if (view == midori_browser_get_current_tab (browser))
|
|
|
|
{
|
|
|
|
const gchar* uri = midori_view_get_display_uri (MIDORI_VIEW (view));
|
|
|
|
GtkAction* action = _action_by_name (browser, "Location");
|
|
|
|
midori_location_action_set_uri (MIDORI_LOCATION_ACTION (action), uri);
|
|
|
|
_midori_browser_update_interface (browser);
|
|
|
|
}
|
2009-05-14 23:18:14 +00:00
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_view_notify_title_cb (GtkWidget* view,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-08-14 23:57:48 +00:00
|
|
|
const gchar* uri;
|
|
|
|
const gchar* title;
|
|
|
|
GtkAction* action;
|
|
|
|
gchar* window_title;
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
uri = midori_view_get_display_uri (MIDORI_VIEW (view));
|
|
|
|
title = midori_view_get_display_title (MIDORI_VIEW (view));
|
2008-08-14 23:57:48 +00:00
|
|
|
action = _action_by_name (browser, "Location");
|
2009-02-28 13:05:01 +00:00
|
|
|
if (browser->remember_last_visited_pages)
|
2008-10-13 16:29:46 +00:00
|
|
|
midori_location_action_set_title_for_uri (
|
2008-08-14 23:57:48 +00:00
|
|
|
MIDORI_LOCATION_ACTION (action), title, uri);
|
2008-10-07 00:19:33 +00:00
|
|
|
if (midori_view_get_load_status (MIDORI_VIEW (view)) == MIDORI_LOAD_COMMITTED)
|
|
|
|
{
|
2009-01-26 02:43:59 +00:00
|
|
|
KatzeItem* item;
|
|
|
|
KatzeItem* proxy;
|
|
|
|
|
2009-02-28 13:05:01 +00:00
|
|
|
if (browser->history && browser->remember_last_visited_pages)
|
2009-01-26 02:43:59 +00:00
|
|
|
{
|
2009-02-21 22:59:02 +00:00
|
|
|
item = g_object_get_data (G_OBJECT (view), "history-item-added");
|
|
|
|
proxy = midori_view_get_proxy_item (MIDORI_VIEW (view));
|
|
|
|
if (item && katze_item_get_added (item) == katze_item_get_added (proxy))
|
|
|
|
katze_item_set_name (item, katze_item_get_name (proxy));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
katze_object_assign (item, katze_item_copy (proxy));
|
|
|
|
midori_browser_new_history_item (browser, g_object_ref (item));
|
|
|
|
g_object_set_data_full (G_OBJECT (view), "history-item-added",
|
|
|
|
item, (GDestroyNotify)g_object_unref);
|
|
|
|
}
|
2009-01-26 02:43:59 +00:00
|
|
|
}
|
2008-10-07 00:19:33 +00:00
|
|
|
}
|
2008-08-14 23:57:48 +00:00
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
if (view == midori_browser_get_current_tab (browser))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-08-14 23:57:48 +00:00
|
|
|
window_title = g_strconcat (title, " - ",
|
2008-03-10 21:26:09 +00:00
|
|
|
g_get_application_name (), NULL);
|
|
|
|
gtk_window_set_title (GTK_WINDOW (browser), window_title);
|
|
|
|
g_free (window_title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-21 23:51:08 +00:00
|
|
|
static void
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_view_notify_zoom_level_cb (GtkWidget* view,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
2008-07-21 23:51:08 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
if (view == midori_browser_get_current_tab (browser))
|
2008-07-21 23:51:08 +00:00
|
|
|
_action_set_sensitive (browser, "ZoomNormal",
|
2009-03-05 21:45:34 +00:00
|
|
|
midori_view_get_zoom_level (MIDORI_VIEW (view)) != 1.0f);
|
2008-07-19 02:06:10 +00:00
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_view_notify_statusbar_text_cb (MidoriView* view,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
2008-07-16 16:08:47 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
gchar* text;
|
2008-07-16 16:08:47 +00:00
|
|
|
|
2009-08-28 21:54:06 +00:00
|
|
|
if ((GtkWidget*)view == midori_browser_get_current_tab (browser))
|
|
|
|
{
|
|
|
|
g_object_get (view, "statusbar-text", &text, NULL);
|
|
|
|
_midori_browser_set_statusbar_text (browser, text);
|
|
|
|
g_free (text);
|
|
|
|
}
|
2008-07-16 16:08:47 +00:00
|
|
|
}
|
|
|
|
|
2009-09-21 21:53:01 +00:00
|
|
|
static void
|
|
|
|
midori_browser_edit_bookmark_uri_changed_cb (GtkEntry* entry,
|
|
|
|
GtkDialog* dialog)
|
2009-09-19 15:25:10 +00:00
|
|
|
{
|
|
|
|
const gchar* uri = gtk_entry_get_text (entry);
|
|
|
|
gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_ACCEPT,
|
2009-09-21 21:53:01 +00:00
|
|
|
uri && g_str_has_prefix (uri, "http://")
|
|
|
|
|| g_str_has_prefix (uri, "https://"));
|
2009-09-19 15:25:10 +00:00
|
|
|
}
|
|
|
|
|
2009-02-22 02:11:40 +00:00
|
|
|
/* Private function, used by MidoriBookmarks and MidoriHistory */
|
2009-01-31 03:09:35 +00:00
|
|
|
/* static */ void
|
2008-06-15 11:29:30 +00:00
|
|
|
midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
|
2008-10-29 02:43:08 +00:00
|
|
|
KatzeItem* bookmark,
|
2009-02-22 02:11:40 +00:00
|
|
|
gboolean new_bookmark,
|
|
|
|
gboolean is_folder)
|
2008-06-15 11:29:30 +00:00
|
|
|
{
|
2009-02-22 02:11:40 +00:00
|
|
|
const gchar* title;
|
2008-10-01 02:00:16 +00:00
|
|
|
GtkWidget* dialog;
|
|
|
|
GtkSizeGroup* sizegroup;
|
|
|
|
GtkWidget* view;
|
|
|
|
GtkWidget* hbox;
|
|
|
|
GtkWidget* label;
|
|
|
|
const gchar* value;
|
|
|
|
GtkWidget* entry_title;
|
|
|
|
GtkWidget* entry_desc;
|
|
|
|
GtkWidget* entry_uri;
|
|
|
|
GtkWidget* combo_folder;
|
|
|
|
|
2009-02-28 13:05:01 +00:00
|
|
|
if (!browser->bookmarks || !GTK_WIDGET_VISIBLE (browser))
|
|
|
|
return;
|
|
|
|
|
2009-02-22 02:11:40 +00:00
|
|
|
if (is_folder)
|
|
|
|
title = new_bookmark ? _("New folder") : _("Edit folder");
|
|
|
|
else
|
|
|
|
title = new_bookmark ? _("New bookmark") : _("Edit bookmark");
|
2008-10-01 02:00:16 +00:00
|
|
|
dialog = gtk_dialog_new_with_buttons (
|
2009-02-22 02:11:40 +00:00
|
|
|
title, GTK_WINDOW (browser),
|
2008-06-15 11:29:30 +00:00
|
|
|
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
|
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
new_bookmark ? GTK_STOCK_ADD : GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
|
|
|
|
NULL);
|
|
|
|
gtk_window_set_icon_name (GTK_WINDOW (dialog),
|
|
|
|
new_bookmark ? GTK_STOCK_ADD : GTK_STOCK_REMOVE);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 5);
|
2008-10-01 02:00:16 +00:00
|
|
|
sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
2008-06-15 11:29:30 +00:00
|
|
|
|
2008-10-29 02:43:08 +00:00
|
|
|
if (!bookmark)
|
2008-06-15 11:29:30 +00:00
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
view = midori_browser_get_current_tab (browser);
|
2009-02-22 02:11:40 +00:00
|
|
|
if (is_folder)
|
|
|
|
{
|
2009-02-22 12:52:04 +00:00
|
|
|
bookmark = (KatzeItem*)katze_array_new (KATZE_TYPE_ARRAY);
|
2009-02-22 02:11:40 +00:00
|
|
|
katze_item_set_name (bookmark,
|
|
|
|
midori_view_get_display_title (MIDORI_VIEW (view)));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bookmark = g_object_new (KATZE_TYPE_ITEM,
|
|
|
|
"uri", midori_view_get_display_uri (MIDORI_VIEW (view)),
|
|
|
|
"name", midori_view_get_display_title (MIDORI_VIEW (view)), NULL);
|
2008-06-15 11:29:30 +00:00
|
|
|
}
|
|
|
|
|
2008-10-01 02:00:16 +00:00
|
|
|
hbox = gtk_hbox_new (FALSE, 8);
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
|
2008-10-01 02:00:16 +00:00
|
|
|
label = gtk_label_new_with_mnemonic (_("_Title:"));
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_size_group_add_widget (sizegroup, label);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
2008-10-01 02:00:16 +00:00
|
|
|
entry_title = gtk_entry_new ();
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_entry_set_activates_default (GTK_ENTRY (entry_title), TRUE);
|
2008-10-01 02:00:16 +00:00
|
|
|
value = katze_item_get_name (bookmark);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry_title), value ? value : "");
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), entry_title, TRUE, TRUE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox);
|
|
|
|
gtk_widget_show_all (hbox);
|
|
|
|
|
|
|
|
hbox = gtk_hbox_new (FALSE, 8);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
|
|
|
|
label = gtk_label_new_with_mnemonic (_("_Description:"));
|
|
|
|
gtk_size_group_add_widget (sizegroup, label);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
2008-10-01 02:00:16 +00:00
|
|
|
entry_desc = gtk_entry_new ();
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_entry_set_activates_default (GTK_ENTRY (entry_desc), TRUE);
|
2008-10-29 02:43:08 +00:00
|
|
|
if (bookmark)
|
2008-06-15 11:29:30 +00:00
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
value = katze_item_get_text (bookmark);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry_desc), value ? value : "");
|
2008-06-15 11:29:30 +00:00
|
|
|
}
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), entry_desc, TRUE, TRUE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox);
|
|
|
|
gtk_widget_show_all (hbox);
|
|
|
|
|
2008-10-01 02:00:16 +00:00
|
|
|
entry_uri = NULL;
|
|
|
|
if (!KATZE_IS_ARRAY (bookmark))
|
2008-06-15 11:29:30 +00:00
|
|
|
{
|
|
|
|
hbox = gtk_hbox_new (FALSE, 8);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
|
2009-01-04 18:21:25 +00:00
|
|
|
label = gtk_label_new_with_mnemonic (_("_Address:"));
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_size_group_add_widget (sizegroup, label);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
entry_uri = gtk_entry_new ();
|
|
|
|
gtk_entry_set_activates_default (GTK_ENTRY (entry_uri), TRUE);
|
2008-10-01 02:00:16 +00:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry_uri), katze_item_get_uri (bookmark));
|
2009-09-21 21:53:01 +00:00
|
|
|
midori_browser_edit_bookmark_uri_changed_cb (GTK_ENTRY (entry_uri),
|
|
|
|
GTK_DIALOG (dialog));
|
|
|
|
g_signal_connect (entry_uri, "changed",
|
|
|
|
G_CALLBACK (midori_browser_edit_bookmark_uri_changed_cb), dialog);
|
2008-08-31 00:45:13 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), entry_uri, TRUE, TRUE, 0);
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox);
|
|
|
|
gtk_widget_show_all (hbox);
|
|
|
|
}
|
|
|
|
|
2008-10-01 02:00:16 +00:00
|
|
|
combo_folder = NULL;
|
2009-02-23 23:17:21 +00:00
|
|
|
if (1)
|
2008-06-15 11:29:30 +00:00
|
|
|
{
|
2009-02-23 23:17:21 +00:00
|
|
|
KatzeItem* item;
|
2009-01-01 02:52:43 +00:00
|
|
|
guint i, n;
|
|
|
|
|
2008-06-15 11:29:30 +00:00
|
|
|
hbox = gtk_hbox_new (FALSE, 8);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
|
|
|
|
label = gtk_label_new_with_mnemonic (_("_Folder:"));
|
|
|
|
gtk_size_group_add_widget (sizegroup, label);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
combo_folder = gtk_combo_box_new_text ();
|
2009-01-04 18:21:25 +00:00
|
|
|
gtk_combo_box_append_text (GTK_COMBO_BOX (combo_folder),
|
|
|
|
_("Toplevel folder"));
|
2009-01-01 02:52:43 +00:00
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (combo_folder), 0);
|
2009-02-23 23:17:21 +00:00
|
|
|
|
|
|
|
i = 0;
|
|
|
|
n = 1;
|
|
|
|
while ((item = katze_array_get_nth_item (browser->bookmarks, i++)))
|
2009-01-01 02:52:43 +00:00
|
|
|
{
|
|
|
|
if (KATZE_IS_ARRAY (item))
|
|
|
|
{
|
|
|
|
const gchar* name = katze_item_get_name (item);
|
|
|
|
gtk_combo_box_append_text (GTK_COMBO_BOX (combo_folder), name);
|
2009-02-23 23:17:21 +00:00
|
|
|
if (katze_item_get_parent (bookmark) == item)
|
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (combo_folder), n);
|
|
|
|
n++;
|
2009-01-01 02:52:43 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-23 23:17:21 +00:00
|
|
|
if (!i)
|
2009-01-01 02:52:43 +00:00
|
|
|
gtk_widget_set_sensitive (combo_folder, FALSE);
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), combo_folder, TRUE, TRUE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox);
|
|
|
|
gtk_widget_show_all (hbox);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
|
|
|
|
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
|
|
|
|
{
|
2009-01-01 02:52:43 +00:00
|
|
|
gchar* selected;
|
|
|
|
KatzeArray* folder;
|
|
|
|
|
2008-10-01 02:00:16 +00:00
|
|
|
katze_item_set_name (bookmark,
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_entry_get_text (GTK_ENTRY (entry_title)));
|
2008-10-01 02:00:16 +00:00
|
|
|
katze_item_set_text (bookmark,
|
2008-08-31 00:45:13 +00:00
|
|
|
gtk_entry_get_text (GTK_ENTRY (entry_desc)));
|
2008-10-01 02:00:16 +00:00
|
|
|
if (!KATZE_IS_ARRAY (bookmark))
|
|
|
|
katze_item_set_uri (bookmark,
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_entry_get_text (GTK_ENTRY (entry_uri)));
|
|
|
|
|
2009-01-31 03:09:35 +00:00
|
|
|
folder = browser->bookmarks;
|
2009-02-23 23:17:21 +00:00
|
|
|
if (1)
|
2009-01-01 02:52:43 +00:00
|
|
|
{
|
2009-01-31 03:09:35 +00:00
|
|
|
selected = gtk_combo_box_get_active_text (GTK_COMBO_BOX (combo_folder));
|
|
|
|
if (g_strcmp0 (selected, _("Toplevel folder")))
|
2009-01-01 02:52:43 +00:00
|
|
|
{
|
2009-03-31 19:19:18 +00:00
|
|
|
guint i = 0;
|
|
|
|
KatzeItem* item;
|
|
|
|
while ((item = katze_array_get_nth_item (browser->bookmarks, i++)))
|
2009-01-31 03:09:35 +00:00
|
|
|
if (KATZE_IS_ARRAY (item))
|
|
|
|
if (!g_strcmp0 (katze_item_get_name (item), selected))
|
|
|
|
{
|
|
|
|
folder = KATZE_ARRAY (item);
|
|
|
|
break;
|
|
|
|
}
|
2009-01-01 02:52:43 +00:00
|
|
|
}
|
2009-01-31 03:09:35 +00:00
|
|
|
g_free (selected);
|
2009-02-23 23:17:21 +00:00
|
|
|
if (!new_bookmark)
|
|
|
|
katze_array_remove_item (katze_item_get_parent (bookmark), bookmark);
|
2009-01-01 02:52:43 +00:00
|
|
|
katze_array_add_item (folder, bookmark);
|
2008-06-15 11:29:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_view_add_bookmark_cb (GtkWidget* menuitem,
|
|
|
|
const gchar* uri,
|
|
|
|
GtkWidget* view)
|
2008-06-15 11:29:30 +00:00
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
KatzeItem* item;
|
2008-06-15 11:29:30 +00:00
|
|
|
MidoriBrowser* browser;
|
|
|
|
|
2008-10-01 02:00:16 +00:00
|
|
|
item = katze_item_new ();
|
|
|
|
katze_item_set_uri (item, uri);
|
2009-04-23 02:10:38 +00:00
|
|
|
browser = midori_browser_get_for_widget (menuitem);
|
2009-02-22 02:11:40 +00:00
|
|
|
midori_browser_edit_bookmark_dialog_new (browser, item, FALSE, FALSE);
|
2008-06-15 11:29:30 +00:00
|
|
|
}
|
|
|
|
|
2009-08-30 13:52:30 +00:00
|
|
|
#if !WEBKIT_CHECK_VERSION (1, 1, 3)
|
2008-11-09 21:07:42 +00:00
|
|
|
static void
|
|
|
|
midori_browser_save_transfer_cb (KatzeNetRequest* request,
|
|
|
|
gchar* filename)
|
|
|
|
{
|
|
|
|
FILE* fp;
|
2008-11-15 23:10:39 +00:00
|
|
|
size_t ret;
|
2008-11-09 21:07:42 +00:00
|
|
|
|
|
|
|
if (request->data)
|
|
|
|
{
|
|
|
|
if ((fp = fopen (filename, "wb")))
|
|
|
|
{
|
2008-11-15 23:10:39 +00:00
|
|
|
ret = fwrite (request->data, 1, request->length, fp);
|
2008-11-09 21:07:42 +00:00
|
|
|
fclose (fp);
|
2008-11-15 23:10:39 +00:00
|
|
|
if ((ret - request->length) != 0)
|
|
|
|
{
|
2008-11-18 22:18:53 +00:00
|
|
|
/* Once we have a download interface this should be
|
|
|
|
indicated graphically. */
|
|
|
|
g_warning ("Error writing to file %s "
|
|
|
|
"in midori_browser_save_transfer_cb", filename);
|
2008-11-15 23:10:39 +00:00
|
|
|
}
|
2008-11-09 21:07:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
g_free (filename);
|
|
|
|
}
|
2009-08-30 13:52:30 +00:00
|
|
|
#endif
|
2008-11-09 21:07:42 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_save_uri (MidoriBrowser* browser,
|
|
|
|
const gchar* uri)
|
|
|
|
{
|
|
|
|
static gchar* last_dir = NULL;
|
|
|
|
gboolean folder_set = FALSE;
|
|
|
|
GtkWidget* dialog;
|
|
|
|
gchar* filename;
|
|
|
|
gchar* dirname;
|
|
|
|
gchar* last_slash;
|
|
|
|
gchar* folder;
|
|
|
|
|
2009-02-28 13:05:01 +00:00
|
|
|
if (!GTK_WIDGET_VISIBLE (browser))
|
|
|
|
return;
|
|
|
|
|
2008-11-09 21:07:42 +00:00
|
|
|
dialog = gtk_file_chooser_dialog_new (
|
|
|
|
_("Save file as"), GTK_WINDOW (browser),
|
|
|
|
GTK_FILE_CHOOSER_ACTION_SAVE,
|
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
|
|
|
|
NULL);
|
|
|
|
gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_SAVE);
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (browser));
|
|
|
|
|
|
|
|
if (uri)
|
|
|
|
{
|
|
|
|
/* Base the start folder on the current view's uri if it is local */
|
|
|
|
filename = g_filename_from_uri (uri, NULL, NULL);
|
|
|
|
if (filename)
|
|
|
|
{
|
|
|
|
dirname = g_path_get_dirname (filename);
|
|
|
|
if (dirname && g_file_test (dirname, G_FILE_TEST_IS_DIR))
|
|
|
|
{
|
|
|
|
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), dirname);
|
|
|
|
folder_set = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (dirname);
|
|
|
|
g_free (filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Try to provide a good default filename */
|
|
|
|
filename = g_filename_from_uri (uri, NULL, NULL);
|
|
|
|
if (!filename && (last_slash = g_strrstr (uri, "/")))
|
|
|
|
{
|
|
|
|
if (last_slash[0] == '/')
|
|
|
|
last_slash++;
|
|
|
|
filename = g_strdup (last_slash);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
filename = g_strdup (uri);
|
|
|
|
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), filename);
|
|
|
|
g_free (filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!folder_set && last_dir && *last_dir)
|
|
|
|
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), last_dir);
|
|
|
|
|
|
|
|
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
|
|
|
|
{
|
2009-08-30 13:52:30 +00:00
|
|
|
#if WEBKIT_CHECK_VERSION (1, 1, 3)
|
|
|
|
WebKitNetworkRequest* request;
|
|
|
|
WebKitDownload* download;
|
|
|
|
gchar* destination;
|
|
|
|
#endif
|
|
|
|
|
2008-11-09 21:07:42 +00:00
|
|
|
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
|
|
|
|
folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
|
2009-08-30 13:52:30 +00:00
|
|
|
#if WEBKIT_CHECK_VERSION (1, 1, 3)
|
|
|
|
request = webkit_network_request_new (uri);
|
|
|
|
download = webkit_download_new (request);
|
|
|
|
g_object_unref (request);
|
|
|
|
destination = g_filename_to_uri (filename, NULL, NULL);
|
|
|
|
webkit_download_set_destination_uri (download, destination);
|
|
|
|
g_free (destination);
|
|
|
|
midori_browser_add_download_item (browser, download);
|
|
|
|
webkit_download_start (download);
|
|
|
|
#else
|
2008-11-09 21:07:42 +00:00
|
|
|
katze_net_load_uri (browser->net, uri, NULL,
|
|
|
|
(KatzeNetTransferCb)midori_browser_save_transfer_cb, filename);
|
2009-08-30 13:52:30 +00:00
|
|
|
#endif
|
2008-11-09 21:07:42 +00:00
|
|
|
|
|
|
|
g_free (last_dir);
|
|
|
|
last_dir = folder;
|
|
|
|
}
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_view_save_as_cb (GtkWidget* menuitem,
|
|
|
|
const gchar* uri,
|
|
|
|
GtkWidget* view)
|
|
|
|
{
|
|
|
|
MidoriBrowser* browser;
|
|
|
|
|
2009-04-23 02:10:38 +00:00
|
|
|
browser = midori_browser_get_for_widget (menuitem);
|
2008-11-09 21:07:42 +00:00
|
|
|
midori_browser_save_uri (browser, uri);
|
|
|
|
}
|
|
|
|
|
2009-05-10 12:39:20 +00:00
|
|
|
static gchar*
|
|
|
|
midori_browser_speed_dial_get_next_free_slot (void)
|
|
|
|
{
|
2009-05-13 21:56:55 +00:00
|
|
|
GRegex* regex;
|
|
|
|
GMatchInfo* match_info;
|
2009-05-10 12:39:20 +00:00
|
|
|
gchar* speed_dial_body;
|
|
|
|
gchar* body_fname;
|
|
|
|
gchar* slot_id = NULL;
|
|
|
|
|
2009-05-10 12:48:12 +00:00
|
|
|
body_fname = g_build_filename (sokoke_set_config_dir (NULL),
|
2009-05-13 21:56:55 +00:00
|
|
|
"speeddial.json", NULL);
|
|
|
|
|
2009-05-10 12:39:20 +00:00
|
|
|
if (!g_file_test (body_fname, G_FILE_TEST_EXISTS))
|
|
|
|
{
|
2009-07-20 06:43:23 +00:00
|
|
|
gchar* filename = g_build_filename ("midori", "res", "speeddial.json", NULL);
|
|
|
|
gchar* filepath = sokoke_find_data_filename (filename);
|
|
|
|
g_free (filename);
|
|
|
|
if (g_file_get_contents (filepath, &speed_dial_body, NULL, NULL))
|
2009-05-13 21:56:55 +00:00
|
|
|
{
|
|
|
|
g_file_set_contents (body_fname, speed_dial_body, -1, NULL);
|
|
|
|
|
|
|
|
g_free (speed_dial_body);
|
|
|
|
}
|
2009-07-20 06:43:23 +00:00
|
|
|
g_free (filepath);
|
2009-05-13 21:56:55 +00:00
|
|
|
g_free (body_fname);
|
|
|
|
return g_strdup ("s1");
|
2009-05-10 12:39:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
g_file_get_contents (body_fname, &speed_dial_body, NULL, NULL);
|
|
|
|
|
2009-05-23 21:59:22 +00:00
|
|
|
regex = g_regex_new ("\"id\":\"(s[1-9])\",\"href\":\"#\"",
|
2009-05-13 21:56:55 +00:00
|
|
|
G_REGEX_MULTILINE, 0, NULL);
|
2009-05-10 12:39:20 +00:00
|
|
|
|
2009-05-13 21:56:55 +00:00
|
|
|
if (g_regex_match (regex, speed_dial_body, 0, &match_info))
|
2009-05-10 12:39:20 +00:00
|
|
|
{
|
2009-05-13 21:56:55 +00:00
|
|
|
slot_id = g_match_info_fetch (match_info, 1);
|
|
|
|
g_match_info_free (match_info);
|
2009-05-10 12:39:20 +00:00
|
|
|
}
|
|
|
|
|
2009-05-13 21:56:55 +00:00
|
|
|
if (!g_strcmp0 (slot_id, ""))
|
|
|
|
g_free (slot_id);
|
|
|
|
|
2009-05-10 12:39:20 +00:00
|
|
|
g_free (body_fname);
|
|
|
|
g_free (speed_dial_body);
|
2009-05-13 21:56:55 +00:00
|
|
|
g_free (regex);
|
2009-05-10 12:39:20 +00:00
|
|
|
|
|
|
|
return slot_id;
|
|
|
|
}
|
|
|
|
|
2009-05-27 21:38:51 +00:00
|
|
|
GdkPixbuf*
|
|
|
|
midori_view_get_snapshot (MidoriView* view,
|
|
|
|
guint width,
|
|
|
|
guint height);
|
2009-05-10 12:39:20 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_add_speed_dial (MidoriBrowser* browser)
|
|
|
|
{
|
2009-05-21 17:14:46 +00:00
|
|
|
GdkPixbuf* img;
|
2009-05-10 12:39:20 +00:00
|
|
|
gchar* replace_from;
|
|
|
|
gchar* replace_by;
|
|
|
|
gsize len;
|
|
|
|
|
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
|
|
|
|
|
|
|
gchar* uri = g_strdup (midori_view_get_display_uri (MIDORI_VIEW (view)));
|
|
|
|
gchar* title = g_strdup (midori_view_get_display_title (MIDORI_VIEW (view)));
|
|
|
|
gchar* slot_id = midori_browser_speed_dial_get_next_free_slot ();
|
|
|
|
|
2009-05-15 21:49:01 +00:00
|
|
|
GRegex* reg_quotes = g_regex_new ("'", 0, 0, NULL);
|
|
|
|
GRegex* reg_others = g_regex_new ("[\\\"\\\\]", 0, 0, NULL);
|
|
|
|
gchar* temp_title = g_regex_replace_literal (reg_others, title,
|
|
|
|
-1, 0, " ", 0, NULL);
|
|
|
|
g_free (title);
|
|
|
|
title = g_regex_replace_literal (reg_quotes, temp_title, -1, 0,
|
|
|
|
"\\\\'", 0, NULL);
|
|
|
|
|
|
|
|
g_free (temp_title);
|
|
|
|
g_regex_unref (reg_quotes);
|
|
|
|
g_regex_unref (reg_others);
|
|
|
|
|
2009-05-10 12:39:20 +00:00
|
|
|
if (slot_id == NULL)
|
|
|
|
{
|
|
|
|
g_free (uri);
|
|
|
|
g_free (title);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((len = g_utf8_strlen (title, -1)) > 15)
|
|
|
|
{
|
2009-05-15 21:49:01 +00:00
|
|
|
/**
|
|
|
|
* The case when a quote was escaped with a backslash and the
|
|
|
|
* backslash becomes the last character of the ellipsized string.
|
|
|
|
* This causes JSON parsing to fail.
|
|
|
|
* For example: "My Foo Bar \'b\..."
|
|
|
|
**/
|
|
|
|
GRegex* reg_unsafe = g_regex_new ("([\\\\]+\\.)", 0, 0, NULL);
|
|
|
|
|
|
|
|
gchar* temp;
|
|
|
|
gchar* ellipsized = g_malloc0 ( len + 1);
|
|
|
|
|
2009-05-10 12:39:20 +00:00
|
|
|
g_utf8_strncpy (ellipsized, title, 15);
|
|
|
|
g_free (title);
|
2009-05-15 21:49:01 +00:00
|
|
|
|
|
|
|
temp = g_strdup_printf ("%s...", ellipsized);
|
2009-05-10 12:39:20 +00:00
|
|
|
g_free (ellipsized);
|
2009-05-15 21:49:01 +00:00
|
|
|
|
|
|
|
title = g_regex_replace_literal (reg_unsafe, temp, -1, 0, ".", 0, NULL);
|
|
|
|
g_free (temp);
|
|
|
|
|
|
|
|
g_regex_unref (reg_unsafe);
|
2009-05-10 12:39:20 +00:00
|
|
|
}
|
|
|
|
|
2009-05-21 17:14:46 +00:00
|
|
|
if ((img = midori_view_get_snapshot (MIDORI_VIEW (view), 160, 107)))
|
2009-05-10 12:39:20 +00:00
|
|
|
{
|
|
|
|
GRegex* regex;
|
|
|
|
gchar* replace;
|
|
|
|
gchar* file_content;
|
|
|
|
gchar* encoded;
|
|
|
|
gchar* speed_dial_body;
|
|
|
|
gchar* body_fname;
|
|
|
|
gsize sz;
|
|
|
|
|
2009-05-10 12:48:12 +00:00
|
|
|
body_fname = g_build_filename (sokoke_set_config_dir (NULL),
|
2009-05-13 21:56:55 +00:00
|
|
|
"speeddial.json", NULL);
|
2009-05-10 12:39:20 +00:00
|
|
|
|
2009-05-13 21:56:55 +00:00
|
|
|
if (g_file_get_contents (body_fname, &speed_dial_body, NULL, NULL))
|
|
|
|
{
|
2009-06-02 17:16:59 +00:00
|
|
|
gint i;
|
|
|
|
|
2009-05-13 21:56:55 +00:00
|
|
|
gdk_pixbuf_save_to_buffer (img, &file_content, &sz, "png", NULL, NULL);
|
|
|
|
encoded = g_base64_encode ((guchar *)file_content, sz);
|
|
|
|
|
|
|
|
replace_from = g_strdup_printf (
|
2009-05-23 21:59:22 +00:00
|
|
|
"\\{\"id\":\"%s\",\"href\":\"#\",\"title\":\"\",\"img\":\"\"\\}",
|
|
|
|
slot_id);
|
2009-05-13 21:56:55 +00:00
|
|
|
replace_by = g_strdup_printf (
|
|
|
|
"{\"id\":\"%s\",\"href\":\"%s\",\"title\":\"%s\",\"img\":\"%s\"}",
|
|
|
|
slot_id, uri, title, encoded);
|
|
|
|
|
|
|
|
regex = g_regex_new (replace_from, G_REGEX_MULTILINE, 0, NULL);
|
|
|
|
replace = g_regex_replace (regex, speed_dial_body, -1,
|
|
|
|
1, replace_by, 0, NULL);
|
2009-05-15 21:49:01 +00:00
|
|
|
|
2009-05-13 21:56:55 +00:00
|
|
|
g_file_set_contents (body_fname, replace, -1, NULL);
|
|
|
|
|
2009-06-02 17:16:59 +00:00
|
|
|
i = 0;
|
|
|
|
while ((view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (
|
|
|
|
browser->notebook), i++)))
|
|
|
|
if (midori_view_is_blank (MIDORI_VIEW (view)))
|
|
|
|
midori_view_reload (MIDORI_VIEW (view), FALSE);
|
|
|
|
|
2009-05-13 21:56:55 +00:00
|
|
|
g_object_unref (img);
|
|
|
|
g_regex_unref (regex);
|
|
|
|
g_free (encoded);
|
|
|
|
g_free (file_content);
|
|
|
|
g_free (speed_dial_body);
|
|
|
|
g_free (replace_from);
|
|
|
|
g_free (replace_by);
|
|
|
|
g_free (replace);
|
|
|
|
}
|
2009-05-10 12:39:20 +00:00
|
|
|
g_free (body_fname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_view_add_speed_dial_cb (GtkWidget* menuitem,
|
|
|
|
const gchar* uri,
|
|
|
|
GtkWidget* view)
|
|
|
|
{
|
|
|
|
MidoriBrowser* browser;
|
|
|
|
|
|
|
|
browser = midori_browser_get_for_widget (menuitem);
|
|
|
|
midori_browser_add_speed_dial (browser);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static gboolean
|
2008-07-13 19:49:57 +00:00
|
|
|
midori_browser_tab_leave_notify_event_cb (GtkWidget* widget,
|
|
|
|
GdkEventCrossing* event,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
|
|
|
_midori_browser_set_statusbar_text (browser, NULL);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_view_activate_action_cb (GtkWidget* view,
|
|
|
|
const gchar* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
_midori_browser_activate_action (browser, action);
|
|
|
|
}
|
|
|
|
|
2008-11-01 18:15:58 +00:00
|
|
|
static void
|
|
|
|
midori_view_attach_inspector_cb (GtkWidget* view,
|
|
|
|
GtkWidget* inspector_view,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkWidget* scrolled = gtk_widget_get_parent (browser->inspector_view);
|
|
|
|
gtk_container_remove (GTK_CONTAINER (scrolled), browser->inspector_view);
|
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled), inspector_view);
|
|
|
|
browser->inspector_view = inspector_view;
|
|
|
|
}
|
|
|
|
|
2009-07-30 21:38:14 +00:00
|
|
|
static void
|
|
|
|
midori_browser_view_copy_history (GtkWidget* view_to,
|
2009-07-31 10:41:10 +00:00
|
|
|
GtkWidget* view_from,
|
|
|
|
gboolean omit_last)
|
2009-07-30 21:38:14 +00:00
|
|
|
{
|
|
|
|
WebKitWebView* copy_from;
|
|
|
|
WebKitWebBackForwardList* list_from;
|
|
|
|
WebKitWebView* copy_to;
|
|
|
|
WebKitWebBackForwardList* list_to;
|
|
|
|
guint length_from;
|
2009-07-31 10:31:41 +00:00
|
|
|
gint i;
|
2009-07-30 21:38:14 +00:00
|
|
|
|
|
|
|
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));
|
|
|
|
|
2009-07-31 10:41:10 +00:00
|
|
|
for (i = -length_from; i <= (omit_last ? -1 : 0); i++)
|
2009-07-30 21:38:14 +00:00
|
|
|
{
|
|
|
|
webkit_web_back_forward_list_add_item (list_to,
|
|
|
|
webkit_web_back_forward_list_get_nth_item (list_from, i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
static void
|
|
|
|
midori_view_new_tab_cb (GtkWidget* view,
|
|
|
|
const gchar* uri,
|
2008-10-02 22:49:16 +00:00
|
|
|
gboolean background,
|
2008-09-26 21:13:46 +00:00
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-05-31 22:21:08 +00:00
|
|
|
gint n = midori_browser_add_uri (browser, uri);
|
2009-07-30 21:38:14 +00:00
|
|
|
midori_browser_view_copy_history (midori_browser_get_nth_tab (browser, n),
|
2009-07-31 10:41:10 +00:00
|
|
|
view, FALSE);
|
2009-07-30 21:38:14 +00:00
|
|
|
|
2009-07-22 21:55:05 +00:00
|
|
|
if (!background)
|
|
|
|
midori_browser_set_current_page (browser, n);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_view_new_window_cb (GtkWidget* view,
|
|
|
|
const gchar* uri,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2009-05-17 18:29:31 +00:00
|
|
|
MidoriBrowser* new_browser = g_object_new (MIDORI_TYPE_BROWSER, NULL);
|
|
|
|
g_signal_emit (browser, signals[NEW_WINDOW], 0, new_browser);
|
2009-05-22 21:15:53 +00:00
|
|
|
midori_browser_add_uri (new_browser, uri);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2008-12-03 03:16:19 +00:00
|
|
|
static void
|
|
|
|
midori_view_new_view_cb (GtkWidget* view,
|
|
|
|
GtkWidget* new_view,
|
|
|
|
MidoriNewView where,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-07-31 10:41:10 +00:00
|
|
|
midori_browser_view_copy_history (new_view, view, TRUE);
|
2008-12-03 03:16:19 +00:00
|
|
|
if (where == MIDORI_NEW_VIEW_WINDOW)
|
|
|
|
{
|
2009-05-17 18:29:31 +00:00
|
|
|
MidoriBrowser* new_browser = g_object_new (MIDORI_TYPE_BROWSER, NULL);
|
2009-05-22 21:15:53 +00:00
|
|
|
g_signal_emit (browser, signals[NEW_WINDOW], 0, new_browser);
|
2009-05-17 18:29:31 +00:00
|
|
|
midori_browser_add_tab (new_browser, new_view);
|
|
|
|
midori_browser_set_current_tab (new_browser, new_view);
|
2008-12-03 03:16:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gint n = midori_browser_add_tab (browser, new_view);
|
|
|
|
if (where != MIDORI_NEW_VIEW_BACKGROUND)
|
|
|
|
midori_browser_set_current_page (browser, n);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-19 17:28:50 +00:00
|
|
|
#if WEBKIT_CHECK_VERSION (1, 1, 3)
|
|
|
|
static void
|
|
|
|
midori_browser_download_notify_progress_cb (WebKitDownload* download,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
GtkWidget* progress)
|
|
|
|
{
|
2009-08-08 21:57:51 +00:00
|
|
|
gchar* current;
|
|
|
|
gchar* total;
|
|
|
|
gchar* size_text;
|
|
|
|
gchar* text;
|
|
|
|
|
2009-03-19 17:28:50 +00:00
|
|
|
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress),
|
|
|
|
webkit_download_get_progress (download));
|
2009-08-08 21:57:51 +00:00
|
|
|
|
|
|
|
current = g_format_size_for_display (webkit_download_get_current_size (download));
|
|
|
|
total = g_format_size_for_display (webkit_download_get_total_size (download));
|
|
|
|
size_text = g_strdup_printf (_("%s of %s"), current, total);
|
|
|
|
g_free (current);
|
|
|
|
g_free (total);
|
|
|
|
text = g_strdup_printf ("%s (%s)",
|
|
|
|
gtk_progress_bar_get_text (GTK_PROGRESS_BAR (progress)),
|
|
|
|
size_text);
|
|
|
|
gtk_widget_set_tooltip_text (progress, text);
|
2009-03-19 17:28:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_download_notify_status_cb (WebKitDownload* download,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
GtkWidget* button)
|
|
|
|
{
|
2009-03-21 19:08:37 +00:00
|
|
|
GtkWidget* icon;
|
|
|
|
|
2009-03-19 17:28:50 +00:00
|
|
|
switch (webkit_download_get_status (download))
|
|
|
|
{
|
|
|
|
case WEBKIT_DOWNLOAD_STATUS_FINISHED:
|
2009-04-26 22:22:16 +00:00
|
|
|
{
|
|
|
|
MidoriBrowser* browser = midori_browser_get_for_widget (button);
|
|
|
|
|
2009-03-19 17:28:50 +00:00
|
|
|
icon = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU);
|
|
|
|
gtk_button_set_image (GTK_BUTTON (button), icon);
|
2009-03-21 14:06:57 +00:00
|
|
|
if (g_object_get_data (G_OBJECT (download), "open-download"))
|
2009-03-21 09:46:25 +00:00
|
|
|
gtk_button_clicked (GTK_BUTTON (button));
|
2009-04-19 17:05:05 +00:00
|
|
|
else
|
|
|
|
g_object_set_data (G_OBJECT (gtk_widget_get_parent (button)),
|
|
|
|
"done", (void*)1);
|
2009-04-26 22:22:16 +00:00
|
|
|
|
|
|
|
if (browser->settings && katze_object_get_boolean (
|
|
|
|
browser->settings, "notify-transfer-completed"))
|
|
|
|
{
|
2009-06-01 17:41:03 +00:00
|
|
|
const gchar* uri = webkit_download_get_destination_uri (download);
|
|
|
|
gchar* path = soup_uri_decode (uri);
|
|
|
|
gchar* filename = g_strrstr (path, "/") + 1;
|
2009-05-09 13:55:10 +00:00
|
|
|
gchar* msg = g_strdup_printf (
|
2009-07-22 21:53:29 +00:00
|
|
|
_("The file '<b>%s</b>' has been downloaded."), filename);
|
2009-06-01 17:41:03 +00:00
|
|
|
g_free (path);
|
2009-05-09 13:55:10 +00:00
|
|
|
|
|
|
|
g_signal_emit (browser, signals[SEND_NOTIFICATION], 0,
|
|
|
|
_("Transfer completed"), msg);
|
|
|
|
|
|
|
|
g_free (msg);
|
2009-04-26 22:22:16 +00:00
|
|
|
}
|
2009-03-19 17:28:50 +00:00
|
|
|
break;
|
2009-05-09 13:55:10 +00:00
|
|
|
}
|
2009-03-19 17:28:50 +00:00
|
|
|
case WEBKIT_DOWNLOAD_STATUS_CANCELLED:
|
|
|
|
case WEBKIT_DOWNLOAD_STATUS_ERROR:
|
2009-03-21 19:08:37 +00:00
|
|
|
icon = gtk_image_new_from_stock (GTK_STOCK_CLEAR, GTK_ICON_SIZE_MENU);
|
|
|
|
gtk_button_set_image (GTK_BUTTON (button), icon);
|
2009-04-19 17:05:05 +00:00
|
|
|
g_object_set_data (G_OBJECT (gtk_widget_get_parent (button)),
|
|
|
|
"done", (void*)1);
|
2009-03-19 17:28:50 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_download_button_clicked_cb (GtkWidget* button,
|
|
|
|
WebKitDownload* download)
|
|
|
|
{
|
2009-04-19 17:05:05 +00:00
|
|
|
MidoriBrowser* browser;
|
|
|
|
GList* buttons;
|
|
|
|
|
2009-04-23 02:10:38 +00:00
|
|
|
browser = midori_browser_get_for_widget (button);
|
2009-04-19 17:05:05 +00:00
|
|
|
|
2009-03-19 17:28:50 +00:00
|
|
|
switch (webkit_download_get_status (download))
|
|
|
|
{
|
|
|
|
case WEBKIT_DOWNLOAD_STATUS_STARTED:
|
|
|
|
webkit_download_cancel (download);
|
2009-04-19 17:05:05 +00:00
|
|
|
g_object_set_data (G_OBJECT (gtk_widget_get_parent (button)),
|
|
|
|
"done", (void*)1);
|
2009-03-19 17:28:50 +00:00
|
|
|
break;
|
2009-03-20 23:08:22 +00:00
|
|
|
case WEBKIT_DOWNLOAD_STATUS_FINISHED:
|
|
|
|
{
|
|
|
|
const gchar* uri = webkit_download_get_destination_uri (download);
|
2009-04-20 17:10:13 +00:00
|
|
|
if (sokoke_show_uri (gtk_widget_get_screen (button),
|
|
|
|
uri, gtk_get_current_event_time (), NULL))
|
2009-03-20 23:11:29 +00:00
|
|
|
gtk_widget_destroy (gtk_widget_get_parent (button));
|
2009-03-20 23:08:22 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-03-21 19:08:37 +00:00
|
|
|
case WEBKIT_DOWNLOAD_STATUS_CANCELLED:
|
|
|
|
gtk_widget_destroy (gtk_widget_get_parent (button));
|
2009-03-19 17:28:50 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-04-19 17:05:05 +00:00
|
|
|
|
|
|
|
buttons = gtk_container_get_children (GTK_CONTAINER (browser->transferbar));
|
|
|
|
if (g_list_length (buttons) == 1)
|
|
|
|
gtk_widget_hide (browser->transferbar_clear);
|
|
|
|
g_list_free (buttons);
|
2009-03-19 17:28:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_add_download_item (MidoriBrowser* browser,
|
|
|
|
WebKitDownload* download)
|
|
|
|
{
|
|
|
|
GtkWidget* box;
|
|
|
|
GtkWidget* icon;
|
|
|
|
GtkWidget* button;
|
|
|
|
GtkWidget* progress;
|
2009-06-01 18:04:31 +00:00
|
|
|
const gchar* uri;
|
2009-03-21 19:17:23 +00:00
|
|
|
gint width;
|
2009-03-19 17:28:50 +00:00
|
|
|
|
|
|
|
box = gtk_hbox_new (FALSE, 0);
|
|
|
|
/* icon = gtk_image_new_from_stock (STOCK_TRANSFER, GTK_ICON_SIZE_MENU);
|
|
|
|
gtk_box_pack_start (GTK_BOX (box), icon, FALSE, FALSE, 0); */
|
|
|
|
progress = gtk_progress_bar_new ();
|
|
|
|
gtk_progress_bar_set_ellipsize (GTK_PROGRESS_BAR (progress),
|
|
|
|
PANGO_ELLIPSIZE_MIDDLE);
|
2009-06-01 18:04:31 +00:00
|
|
|
if ((uri = webkit_download_get_destination_uri (download)))
|
|
|
|
{
|
|
|
|
gchar* path = soup_uri_decode (uri);
|
|
|
|
gchar* filename = g_strrstr (path, "/") + 1;
|
|
|
|
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress), filename);
|
|
|
|
g_free (path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress),
|
|
|
|
webkit_download_get_suggested_filename (download));
|
2009-03-21 19:17:23 +00:00
|
|
|
sokoke_widget_get_text_size (progress, "M", &width, NULL);
|
|
|
|
gtk_widget_set_size_request (progress, width * 10, -1);
|
2009-03-19 17:28:50 +00:00
|
|
|
/* Avoid a bug in WebKit */
|
|
|
|
if (webkit_download_get_status (download) != WEBKIT_DOWNLOAD_STATUS_CREATED)
|
|
|
|
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress),
|
|
|
|
webkit_download_get_progress (download));
|
|
|
|
gtk_box_pack_start (GTK_BOX (box), progress, FALSE, FALSE, 0);
|
|
|
|
icon = gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_MENU);
|
|
|
|
button = gtk_button_new ();
|
|
|
|
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
|
|
|
|
gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
|
|
|
|
gtk_container_add (GTK_CONTAINER (button), icon);
|
|
|
|
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show_all (box);
|
2009-03-21 19:17:23 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (browser->transferbar), box, FALSE, FALSE, 0);
|
2009-04-19 17:05:05 +00:00
|
|
|
gtk_widget_show (browser->transferbar_clear);
|
2009-03-19 17:28:50 +00:00
|
|
|
|
|
|
|
g_signal_connect (download, "notify::progress",
|
|
|
|
G_CALLBACK (midori_browser_download_notify_progress_cb), progress);
|
|
|
|
g_signal_connect (download, "notify::status",
|
|
|
|
G_CALLBACK (midori_browser_download_notify_status_cb), button);
|
|
|
|
g_signal_connect (button, "clicked",
|
|
|
|
G_CALLBACK (midori_browser_download_button_clicked_cb), download);
|
|
|
|
}
|
|
|
|
|
2009-06-01 17:33:44 +00:00
|
|
|
static void
|
|
|
|
midori_view_download_save_as_response_cb (GtkWidget* dialog,
|
|
|
|
gint response,
|
2009-06-02 23:15:36 +00:00
|
|
|
MidoriBrowser* browser)
|
2009-06-01 17:33:44 +00:00
|
|
|
{
|
2009-06-02 23:15:36 +00:00
|
|
|
WebKitDownload* download = g_object_get_data (G_OBJECT (dialog), "download");
|
2009-06-01 17:33:44 +00:00
|
|
|
if (response == GTK_RESPONSE_ACCEPT)
|
|
|
|
{
|
|
|
|
gchar* uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
|
|
|
|
webkit_download_set_destination_uri (download, uri);
|
2009-06-01 18:04:31 +00:00
|
|
|
midori_browser_add_download_item (browser, download);
|
2009-06-01 17:33:44 +00:00
|
|
|
g_free (uri);
|
|
|
|
webkit_download_start (download);
|
|
|
|
}
|
2009-06-01 17:57:43 +00:00
|
|
|
else
|
|
|
|
g_object_unref (download);
|
2009-06-02 23:15:36 +00:00
|
|
|
gtk_widget_hide (dialog);
|
2009-06-01 17:33:44 +00:00
|
|
|
}
|
|
|
|
|
2009-03-19 17:28:50 +00:00
|
|
|
static gboolean
|
|
|
|
midori_view_download_requested_cb (GtkWidget* view,
|
|
|
|
WebKitDownload* download,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-03-22 14:24:40 +00:00
|
|
|
g_signal_emit (browser, signals[ADD_DOWNLOAD], 0, download);
|
2009-03-21 14:06:57 +00:00
|
|
|
if (!webkit_download_get_destination_uri (download))
|
2009-03-20 23:40:03 +00:00
|
|
|
{
|
2009-06-02 23:15:36 +00:00
|
|
|
gchar* folder;
|
2009-06-01 17:33:44 +00:00
|
|
|
if (g_object_get_data (G_OBJECT (download), "save-as-download"))
|
|
|
|
{
|
2009-06-02 23:15:36 +00:00
|
|
|
static GtkWidget* dialog = NULL;
|
|
|
|
|
|
|
|
if (!dialog)
|
|
|
|
{
|
|
|
|
dialog = gtk_file_chooser_dialog_new (
|
|
|
|
_("Save file"), GTK_WINDOW (browser),
|
|
|
|
GTK_FILE_CHOOSER_ACTION_SAVE,
|
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
|
|
|
|
NULL);
|
|
|
|
gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_SAVE);
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (browser));
|
|
|
|
gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
|
|
|
|
folder = katze_object_get_string (browser->settings, "download-folder");
|
|
|
|
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), folder);
|
|
|
|
g_free (folder);
|
|
|
|
g_signal_connect (dialog, "response",
|
|
|
|
G_CALLBACK (midori_view_download_save_as_response_cb), browser);
|
|
|
|
}
|
|
|
|
g_object_set_data (G_OBJECT (dialog), "download", download);
|
2009-06-02 22:59:41 +00:00
|
|
|
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog),
|
|
|
|
webkit_download_get_suggested_filename (download));
|
2009-06-01 17:33:44 +00:00
|
|
|
gtk_widget_show (dialog);
|
|
|
|
}
|
2009-03-31 19:19:48 +00:00
|
|
|
else
|
2009-06-01 17:33:44 +00:00
|
|
|
{
|
2009-06-02 23:13:24 +00:00
|
|
|
gchar* filename;
|
|
|
|
gchar* uri;
|
|
|
|
|
2009-06-01 17:33:44 +00:00
|
|
|
if (g_object_get_data (G_OBJECT (download), "open-download"))
|
|
|
|
folder = g_strdup (g_get_tmp_dir ());
|
|
|
|
else
|
|
|
|
folder = katze_object_get_string (browser->settings, "download-folder");
|
|
|
|
filename = g_build_filename (folder,
|
|
|
|
webkit_download_get_suggested_filename (download), NULL);
|
|
|
|
g_free (folder);
|
|
|
|
uri = g_filename_to_uri (filename, NULL, NULL);
|
|
|
|
g_free (filename);
|
|
|
|
webkit_download_set_destination_uri (download, uri);
|
|
|
|
g_free (uri);
|
2009-06-01 17:57:43 +00:00
|
|
|
midori_browser_add_download_item (browser, download);
|
2009-06-01 17:33:44 +00:00
|
|
|
}
|
2009-03-20 23:40:03 +00:00
|
|
|
}
|
2009-03-21 14:06:57 +00:00
|
|
|
return TRUE;
|
2009-03-19 17:28:50 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-04-19 17:05:05 +00:00
|
|
|
static void
|
|
|
|
midori_browser_transferbar_clear_clicked_cb (GtkWidget* button,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GList* buttons;
|
|
|
|
guint i;
|
|
|
|
GtkWidget* item;
|
|
|
|
|
|
|
|
buttons = gtk_container_get_children (GTK_CONTAINER (browser->transferbar));
|
|
|
|
i = 0;
|
|
|
|
while ((item = g_list_nth_data (buttons, i++)))
|
|
|
|
if (g_object_get_data (G_OBJECT (item), "done"))
|
|
|
|
gtk_widget_destroy (item);
|
|
|
|
g_list_free (buttons);
|
|
|
|
buttons = gtk_container_get_children (GTK_CONTAINER (browser->transferbar));
|
|
|
|
if (g_list_length (buttons) == 1)
|
|
|
|
gtk_widget_hide (browser->transferbar_clear);
|
|
|
|
g_list_free (buttons);
|
|
|
|
}
|
|
|
|
|
2008-09-28 14:29:41 +00:00
|
|
|
static void
|
|
|
|
midori_view_search_text_cb (GtkWidget* view,
|
|
|
|
gboolean found,
|
2009-02-22 00:45:22 +00:00
|
|
|
gchar* typing,
|
2008-09-28 14:29:41 +00:00
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
const gchar* text;
|
|
|
|
gboolean case_sensitive;
|
|
|
|
gboolean highlight;
|
|
|
|
|
2009-02-22 00:45:22 +00:00
|
|
|
if (typing)
|
|
|
|
{
|
|
|
|
gint position = -1;
|
|
|
|
|
2009-02-22 01:17:58 +00:00
|
|
|
browser->find_typing = TRUE;
|
2009-02-22 01:34:21 +00:00
|
|
|
gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (
|
|
|
|
browser->find_highlight), TRUE);
|
|
|
|
gtk_widget_hide (GTK_WIDGET (browser->find_case));
|
|
|
|
gtk_widget_hide (GTK_WIDGET (browser->find_highlight));
|
|
|
|
gtk_widget_hide (GTK_WIDGET (browser->find_close));
|
|
|
|
if (!GTK_WIDGET_VISIBLE (browser->find))
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (browser->find_text), "");
|
2009-02-22 00:45:22 +00:00
|
|
|
gtk_widget_show (browser->find);
|
|
|
|
gtk_window_set_focus (GTK_WINDOW (browser), browser->find_text);
|
|
|
|
gtk_editable_insert_text (GTK_EDITABLE (browser->find_text), typing, -1, &position);
|
|
|
|
gtk_editable_set_position (GTK_EDITABLE (browser->find_text), -1);
|
|
|
|
}
|
2009-02-22 15:12:58 +00:00
|
|
|
if (GTK_WIDGET_VISIBLE (browser->find) && !typing)
|
2008-09-28 14:29:41 +00:00
|
|
|
{
|
|
|
|
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (browser->find_text),
|
|
|
|
GTK_ICON_ENTRY_PRIMARY, (found) ? GTK_STOCK_FIND : GTK_STOCK_STOP);
|
|
|
|
text = gtk_entry_get_text (GTK_ENTRY (browser->find_text));
|
|
|
|
case_sensitive = gtk_toggle_tool_button_get_active (
|
|
|
|
GTK_TOGGLE_TOOL_BUTTON (browser->find_case));
|
|
|
|
midori_view_mark_text_matches (MIDORI_VIEW (view), text, case_sensitive);
|
|
|
|
highlight = gtk_toggle_tool_button_get_active (
|
|
|
|
GTK_TOGGLE_TOOL_BUTTON (browser->find_highlight));
|
|
|
|
midori_view_set_highlight_text_matches (MIDORI_VIEW (view), highlight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-13 19:49:57 +00:00
|
|
|
static gboolean
|
|
|
|
midori_browser_tab_destroy_cb (GtkWidget* widget,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
KatzeItem* item;
|
2008-07-13 19:49:57 +00:00
|
|
|
const gchar* uri;
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
if (browser->proxy_array && MIDORI_IS_VIEW (widget))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
item = midori_view_get_proxy_item (MIDORI_VIEW (widget));
|
|
|
|
uri = katze_item_get_uri (item);
|
2008-10-10 20:50:56 +00:00
|
|
|
if (browser->trash && !midori_view_is_blank (MIDORI_VIEW (widget)))
|
2008-09-26 21:13:46 +00:00
|
|
|
katze_array_add_item (browser->trash, item);
|
|
|
|
katze_array_remove_item (browser->proxy_array, item);
|
|
|
|
g_object_unref (item);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_midori_browser_update_actions (browser);
|
2008-07-25 10:45:50 +00:00
|
|
|
|
|
|
|
/* This callback must only be called once, but we need to ensure
|
|
|
|
that "remove-tab" is emitted in any case */
|
|
|
|
g_signal_handlers_disconnect_by_func (widget,
|
|
|
|
midori_browser_tab_destroy_cb, browser);
|
|
|
|
|
|
|
|
g_signal_emit (browser, signals[REMOVE_TAB], 0, widget);
|
2008-10-03 23:45:17 +00:00
|
|
|
|
|
|
|
/* We don't ever want to be in a situation with no tabs,
|
2008-10-10 20:31:37 +00:00
|
|
|
so just create an empty one if the last one is closed.
|
|
|
|
The only exception is when we are closing the window,
|
|
|
|
which is indicated by the proxy array having been unset. */
|
|
|
|
if (browser->proxy_array && !midori_browser_get_current_tab (browser))
|
2008-10-03 23:45:17 +00:00
|
|
|
midori_browser_add_uri (browser, "");
|
2008-07-13 19:49:57 +00:00
|
|
|
return FALSE;
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2008-07-23 18:17:13 +00:00
|
|
|
static void
|
2008-06-15 02:02:56 +00:00
|
|
|
_midori_browser_add_tab (MidoriBrowser* browser,
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view)
|
2008-06-15 02:02:56 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* tab_label;
|
|
|
|
KatzeItem* item;
|
2008-06-15 02:02:56 +00:00
|
|
|
guint n;
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (view),
|
2008-06-15 02:02:56 +00:00
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
2008-09-26 21:13:46 +00:00
|
|
|
GTK_WIDGET_SET_FLAGS (view, GTK_CAN_FOCUS);
|
|
|
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (view),
|
2008-07-23 12:42:27 +00:00
|
|
|
GTK_SHADOW_ETCHED_IN);
|
2008-06-15 02:02:56 +00:00
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
tab_label = midori_view_get_proxy_tab_label (MIDORI_VIEW (view));
|
|
|
|
|
2008-10-10 20:31:37 +00:00
|
|
|
item = midori_view_get_proxy_item (MIDORI_VIEW (view));
|
|
|
|
g_object_ref (item);
|
|
|
|
katze_array_add_item (browser->proxy_array, item);
|
2008-09-26 21:13:46 +00:00
|
|
|
|
|
|
|
g_object_connect (view,
|
|
|
|
"signal::notify::icon",
|
|
|
|
midori_view_notify_icon_cb, browser,
|
|
|
|
"signal::notify::load-status",
|
|
|
|
midori_view_notify_load_status_cb, browser,
|
|
|
|
"signal::notify::progress",
|
|
|
|
midori_view_notify_progress_cb, browser,
|
2008-11-23 04:19:43 +00:00
|
|
|
"signal::context-ready",
|
|
|
|
midori_view_context_ready_cb, browser,
|
2009-05-14 23:18:14 +00:00
|
|
|
"signal::notify::uri",
|
|
|
|
midori_view_notify_uri_cb, browser,
|
2008-09-26 21:13:46 +00:00
|
|
|
"signal::notify::title",
|
|
|
|
midori_view_notify_title_cb, browser,
|
|
|
|
"signal::notify::zoom-level",
|
|
|
|
midori_view_notify_zoom_level_cb, browser,
|
|
|
|
"signal::notify::statusbar-text",
|
|
|
|
midori_view_notify_statusbar_text_cb, browser,
|
|
|
|
"signal::activate-action",
|
|
|
|
midori_view_activate_action_cb, browser,
|
2008-11-01 18:15:58 +00:00
|
|
|
"signal::attach-inspector",
|
|
|
|
midori_view_attach_inspector_cb, browser,
|
2008-09-26 21:13:46 +00:00
|
|
|
"signal::new-tab",
|
|
|
|
midori_view_new_tab_cb, browser,
|
|
|
|
"signal::new-window",
|
|
|
|
midori_view_new_window_cb, browser,
|
2008-12-03 03:16:19 +00:00
|
|
|
"signal::new-view",
|
|
|
|
midori_view_new_view_cb, browser,
|
2009-03-19 17:28:50 +00:00
|
|
|
#if WEBKIT_CHECK_VERSION (1, 1, 3)
|
|
|
|
"signal::download-requested",
|
|
|
|
midori_view_download_requested_cb, browser,
|
|
|
|
#endif
|
2008-09-28 14:29:41 +00:00
|
|
|
"signal::search-text",
|
|
|
|
midori_view_search_text_cb, browser,
|
2008-09-26 21:13:46 +00:00
|
|
|
"signal::add-bookmark",
|
|
|
|
midori_view_add_bookmark_cb, browser,
|
2008-11-09 21:07:42 +00:00
|
|
|
"signal::save-as",
|
|
|
|
midori_view_save_as_cb, browser,
|
2009-05-10 12:39:20 +00:00
|
|
|
"signal::add-speed-dial",
|
|
|
|
midori_view_add_speed_dial_cb, browser,
|
2008-12-03 03:16:19 +00:00
|
|
|
"signal::leave-notify-event",
|
|
|
|
midori_browser_tab_leave_notify_event_cb, browser,
|
2008-09-26 21:13:46 +00:00
|
|
|
NULL);
|
2008-07-13 19:49:57 +00:00
|
|
|
|
2009-05-17 14:49:46 +00:00
|
|
|
if (!g_object_get_data (G_OBJECT (view), "midori-view-append") &&
|
|
|
|
browser->settings &&
|
2009-02-28 13:05:01 +00:00
|
|
|
katze_object_get_boolean (browser->settings, "open-tabs-next-to-current"))
|
2008-08-15 18:38:27 +00:00
|
|
|
{
|
|
|
|
n = gtk_notebook_get_current_page (GTK_NOTEBOOK (browser->notebook));
|
2008-09-26 21:13:46 +00:00
|
|
|
gtk_notebook_insert_page (GTK_NOTEBOOK (browser->notebook), view,
|
|
|
|
tab_label, n + 1);
|
2008-08-15 18:38:27 +00:00
|
|
|
}
|
|
|
|
else
|
2008-09-26 21:13:46 +00:00
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (browser->notebook), view,
|
|
|
|
tab_label);
|
2008-08-15 18:38:27 +00:00
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (browser->notebook),
|
2008-09-26 21:13:46 +00:00
|
|
|
view, TRUE);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (browser->notebook),
|
2008-09-26 21:13:46 +00:00
|
|
|
view, TRUE);
|
2008-07-13 19:49:57 +00:00
|
|
|
|
|
|
|
/* We want the tab to be removed if the widget is destroyed */
|
2008-09-26 21:13:46 +00:00
|
|
|
g_signal_connect (view, "destroy",
|
2008-07-13 19:49:57 +00:00
|
|
|
G_CALLBACK (midori_browser_tab_destroy_cb), browser);
|
|
|
|
|
2008-06-15 02:02:56 +00:00
|
|
|
_midori_browser_update_actions (browser);
|
|
|
|
}
|
|
|
|
|
2008-07-23 18:17:13 +00:00
|
|
|
static void
|
|
|
|
_midori_browser_remove_tab (MidoriBrowser* browser,
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view)
|
2008-06-15 02:02:56 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
gtk_widget_destroy (view);
|
2008-06-15 02:02:56 +00:00
|
|
|
}
|
|
|
|
|
2009-04-22 19:53:14 +00:00
|
|
|
/**
|
|
|
|
* midori_browser_foreach:
|
|
|
|
* @browser: a #MidoriBrowser
|
|
|
|
* @callback: a #GtkCallback
|
|
|
|
* @callback_data: custom data
|
|
|
|
*
|
|
|
|
* Calls the specified callback for each view contained
|
|
|
|
* in the browser.
|
|
|
|
*
|
|
|
|
* Since: 0.1.7
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
midori_browser_foreach (MidoriBrowser* browser,
|
|
|
|
GtkCallback callback,
|
|
|
|
gpointer callback_data)
|
|
|
|
{
|
|
|
|
g_return_if_fail (MIDORI_IS_BROWSER (browser));
|
|
|
|
|
|
|
|
gtk_container_foreach (GTK_CONTAINER (browser->notebook),
|
|
|
|
callback, callback_data);
|
|
|
|
}
|
|
|
|
|
2008-06-15 02:02:56 +00:00
|
|
|
static void
|
|
|
|
_midori_browser_quit (MidoriBrowser* browser)
|
2008-06-07 23:25:57 +00:00
|
|
|
{
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Nothing to do */
|
2008-06-07 23:25:57 +00:00
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
midori_browser_class_init (MidoriBrowserClass* class)
|
|
|
|
{
|
2008-10-25 22:54:57 +00:00
|
|
|
GObjectClass* gobject_class;
|
|
|
|
GParamFlags flags;
|
|
|
|
|
2009-05-17 18:29:31 +00:00
|
|
|
/**
|
|
|
|
* MidoriBrowser::new-window:
|
|
|
|
* @browser: the object on which the signal is emitted
|
|
|
|
* @window: a new browser window
|
|
|
|
*
|
|
|
|
* Emitted when a new browser window was created.
|
|
|
|
*
|
|
|
|
* Note: Before 0.1.7 the second argument was an URI string.
|
|
|
|
*/
|
2008-05-31 22:21:08 +00:00
|
|
|
signals[NEW_WINDOW] = g_signal_new (
|
|
|
|
"new-window",
|
|
|
|
G_TYPE_FROM_CLASS (class),
|
|
|
|
(GSignalFlags)(G_SIGNAL_RUN_LAST),
|
|
|
|
G_STRUCT_OFFSET (MidoriBrowserClass, new_window),
|
|
|
|
0,
|
|
|
|
NULL,
|
2009-05-17 18:29:31 +00:00
|
|
|
g_cclosure_marshal_VOID__OBJECT,
|
2008-05-31 22:21:08 +00:00
|
|
|
G_TYPE_NONE, 1,
|
2009-05-17 18:29:31 +00:00
|
|
|
MIDORI_TYPE_BROWSER);
|
2008-05-31 22:21:08 +00:00
|
|
|
|
|
|
|
signals[ADD_TAB] = g_signal_new (
|
|
|
|
"add-tab",
|
2008-03-24 13:15:23 +00:00
|
|
|
G_TYPE_FROM_CLASS (class),
|
2008-03-10 21:26:09 +00:00
|
|
|
(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
|
2008-05-31 22:21:08 +00:00
|
|
|
G_STRUCT_OFFSET (MidoriBrowserClass, add_tab),
|
2008-03-10 21:26:09 +00:00
|
|
|
0,
|
2008-05-31 22:21:08 +00:00
|
|
|
NULL,
|
2008-07-23 18:17:13 +00:00
|
|
|
g_cclosure_marshal_VOID__OBJECT,
|
|
|
|
G_TYPE_NONE, 1,
|
2008-05-31 22:21:08 +00:00
|
|
|
GTK_TYPE_WIDGET);
|
|
|
|
|
2008-07-23 18:17:13 +00:00
|
|
|
signals[REMOVE_TAB] = g_signal_new (
|
|
|
|
"remove-tab",
|
2008-05-31 22:21:08 +00:00
|
|
|
G_TYPE_FROM_CLASS (class),
|
|
|
|
(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
|
2008-07-23 18:17:13 +00:00
|
|
|
G_STRUCT_OFFSET (MidoriBrowserClass, remove_tab),
|
2008-03-10 21:26:09 +00:00
|
|
|
0,
|
|
|
|
NULL,
|
2008-07-23 18:17:13 +00:00
|
|
|
g_cclosure_marshal_VOID__OBJECT,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
GTK_TYPE_WIDGET);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-05-31 22:21:08 +00:00
|
|
|
signals[ACTIVATE_ACTION] = g_signal_new (
|
|
|
|
"activate-action",
|
2008-03-24 13:15:23 +00:00
|
|
|
G_TYPE_FROM_CLASS (class),
|
2008-05-31 22:21:08 +00:00
|
|
|
(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
|
|
|
|
G_STRUCT_OFFSET (MidoriBrowserClass, activate_action),
|
2008-03-10 21:26:09 +00:00
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
g_cclosure_marshal_VOID__STRING,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
G_TYPE_STRING);
|
|
|
|
|
2008-11-23 04:19:43 +00:00
|
|
|
signals[CONTEXT_READY] = g_signal_new (
|
|
|
|
"context-ready",
|
|
|
|
G_TYPE_FROM_CLASS (class),
|
|
|
|
(GSignalFlags)(G_SIGNAL_RUN_LAST),
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
g_cclosure_marshal_VOID__POINTER,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
G_TYPE_POINTER);
|
|
|
|
|
2009-03-22 14:24:40 +00:00
|
|
|
/**
|
2009-04-22 19:53:14 +00:00
|
|
|
* MidoriBrowser::add-download:
|
|
|
|
* @browser: the object on which the signal is emitted
|
2009-03-22 14:24:40 +00:00
|
|
|
* @download: a new download
|
|
|
|
*
|
|
|
|
* Emitted when a new download was accepted and is
|
|
|
|
* about to start, before the browser adds items
|
|
|
|
* to the transferbar.
|
|
|
|
*
|
|
|
|
* Emitting this signal manually is equal to a
|
|
|
|
* user initiating and confirming a download
|
|
|
|
*
|
2009-04-22 19:53:14 +00:00
|
|
|
* Note: This requires WebKitGTK+ 1.1.3.
|
2009-03-22 14:24:40 +00:00
|
|
|
*
|
|
|
|
* Since: 0.1.5
|
|
|
|
*/
|
|
|
|
signals[ADD_DOWNLOAD] = g_signal_new (
|
|
|
|
"add-download",
|
|
|
|
G_TYPE_FROM_CLASS (class),
|
|
|
|
(GSignalFlags)(G_SIGNAL_RUN_LAST),
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
g_cclosure_marshal_VOID__OBJECT,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
G_TYPE_OBJECT);
|
|
|
|
|
2009-05-09 13:55:10 +00:00
|
|
|
/**
|
|
|
|
* MidoriBrowser::send-notification:
|
|
|
|
* @browser: the object on which the signal is emitted
|
|
|
|
* @title: the title for the notification
|
|
|
|
* @message: the message for the notification
|
|
|
|
*
|
|
|
|
* Emitted when a browser wants to display a notification message,
|
|
|
|
* e.g. when a download has been completed.
|
|
|
|
*
|
|
|
|
* Since: 0.1.7
|
|
|
|
*/
|
|
|
|
signals[SEND_NOTIFICATION] = g_signal_new (
|
|
|
|
"send-notification",
|
|
|
|
G_TYPE_FROM_CLASS (class),
|
|
|
|
(GSignalFlags)(G_SIGNAL_RUN_LAST),
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
midori_cclosure_marshal_VOID__STRING_STRING,
|
|
|
|
G_TYPE_NONE, 2,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING);
|
|
|
|
|
2009-07-24 21:55:57 +00:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
2008-05-31 22:21:08 +00:00
|
|
|
signals[QUIT] = g_signal_new (
|
|
|
|
"quit",
|
|
|
|
G_TYPE_FROM_CLASS (class),
|
|
|
|
(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
|
|
|
|
G_STRUCT_OFFSET (MidoriBrowserClass, quit),
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
2008-06-15 02:02:56 +00:00
|
|
|
class->add_tab = _midori_browser_add_tab;
|
2008-07-23 18:17:13 +00:00
|
|
|
class->remove_tab = _midori_browser_remove_tab;
|
2008-06-15 02:02:56 +00:00
|
|
|
class->activate_action = _midori_browser_activate_action;
|
|
|
|
class->quit = _midori_browser_quit;
|
2008-05-31 22:21:08 +00:00
|
|
|
|
2008-10-25 22:54:57 +00:00
|
|
|
gobject_class = G_OBJECT_CLASS (class);
|
2008-07-25 10:45:50 +00:00
|
|
|
gobject_class->dispose = midori_browser_dispose;
|
2008-03-10 21:26:09 +00:00
|
|
|
gobject_class->finalize = midori_browser_finalize;
|
|
|
|
gobject_class->set_property = midori_browser_set_property;
|
|
|
|
gobject_class->get_property = midori_browser_get_property;
|
|
|
|
|
2009-01-16 04:19:43 +00:00
|
|
|
flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS;
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-05-02 20:30:26 +00:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_MENUBAR,
|
|
|
|
g_param_spec_object (
|
|
|
|
"menubar",
|
2008-10-15 01:32:11 +00:00
|
|
|
"Menubar",
|
|
|
|
"The menubar",
|
2008-05-02 20:30:26 +00:00
|
|
|
GTK_TYPE_MENU_BAR,
|
2009-01-16 04:19:43 +00:00
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
2008-05-02 20:30:26 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_NAVIGATIONBAR,
|
|
|
|
g_param_spec_object (
|
|
|
|
"navigationbar",
|
2008-10-15 01:32:11 +00:00
|
|
|
"Navigationbar",
|
|
|
|
"The navigationbar",
|
2008-05-02 20:30:26 +00:00
|
|
|
GTK_TYPE_TOOLBAR,
|
2009-01-16 04:19:43 +00:00
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
2008-05-02 20:30:26 +00:00
|
|
|
|
2008-11-18 01:02:59 +00:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_NOTEBOOK,
|
|
|
|
g_param_spec_object (
|
|
|
|
"notebook",
|
|
|
|
"Notebook",
|
|
|
|
"The notebook containing the views",
|
|
|
|
GTK_TYPE_NOTEBOOK,
|
2009-01-16 04:19:43 +00:00
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
2008-11-18 01:02:59 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_PANEL,
|
|
|
|
g_param_spec_object (
|
|
|
|
"panel",
|
|
|
|
"Panel",
|
|
|
|
"The side panel embedded in the browser",
|
|
|
|
MIDORI_TYPE_PANEL,
|
2009-01-16 04:19:43 +00:00
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
2008-11-18 01:02:59 +00:00
|
|
|
|
2008-07-23 18:17:13 +00:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_URI,
|
|
|
|
g_param_spec_string (
|
|
|
|
"uri",
|
2008-10-15 01:32:11 +00:00
|
|
|
"URI",
|
|
|
|
"The current URI",
|
2009-02-22 12:52:04 +00:00
|
|
|
"",
|
2009-01-16 04:19:43 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2008-07-23 18:17:13 +00:00
|
|
|
|
2008-05-02 20:30:26 +00:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_TAB,
|
|
|
|
g_param_spec_object (
|
|
|
|
"tab",
|
2008-10-15 01:32:11 +00:00
|
|
|
"Tab",
|
|
|
|
"The current tab",
|
2008-05-02 20:30:26 +00:00
|
|
|
GTK_TYPE_WIDGET,
|
2009-01-16 04:19:43 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2008-05-02 20:30:26 +00:00
|
|
|
|
2008-11-23 04:19:43 +00:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_LOAD_STATUS,
|
|
|
|
g_param_spec_enum (
|
|
|
|
"load-status",
|
|
|
|
"Load Status",
|
|
|
|
"The current load status",
|
|
|
|
MIDORI_TYPE_LOAD_STATUS,
|
|
|
|
MIDORI_LOAD_FINISHED,
|
2009-01-16 04:19:43 +00:00
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
2008-11-23 04:19:43 +00:00
|
|
|
|
2008-05-02 20:30:26 +00:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_STATUSBAR,
|
|
|
|
g_param_spec_object (
|
|
|
|
"statusbar",
|
2008-10-15 01:32:11 +00:00
|
|
|
"Statusbar",
|
|
|
|
"The statusbar",
|
2008-05-02 20:30:26 +00:00
|
|
|
GTK_TYPE_STATUSBAR,
|
2009-01-16 04:19:43 +00:00
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
2008-05-02 20:30:26 +00:00
|
|
|
|
2008-09-03 00:28:54 +00:00
|
|
|
/**
|
|
|
|
* MidoriBrowser:statusbar-text:
|
|
|
|
*
|
|
|
|
* The text that is displayed in the statusbar.
|
|
|
|
*
|
|
|
|
* This value reflects changes to the text visible in the statusbar, such
|
|
|
|
* as the uri of a hyperlink the mouse hovers over or the description of
|
|
|
|
* a menuitem.
|
|
|
|
*
|
|
|
|
* Setting this value changes the displayed text until the next change.
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_STATUSBAR_TEXT,
|
|
|
|
g_param_spec_string (
|
|
|
|
"statusbar-text",
|
2008-10-15 01:32:11 +00:00
|
|
|
"Statusbar Text",
|
|
|
|
"The text that is displayed in the statusbar",
|
2008-09-03 00:28:54 +00:00
|
|
|
"",
|
|
|
|
flags));
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
/**
|
2008-05-31 22:21:08 +00:00
|
|
|
* MidoriBrowser:settings:
|
2008-03-10 21:26:09 +00:00
|
|
|
*
|
|
|
|
* An associated settings instance that is shared among all web views.
|
|
|
|
*
|
|
|
|
* Setting this value is propagated to every present web view. Also
|
|
|
|
* every newly created web view will use this instance automatically.
|
2008-09-03 00:28:54 +00:00
|
|
|
*
|
|
|
|
* If no settings are specified a default will be used.
|
2008-03-10 21:26:09 +00:00
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_SETTINGS,
|
|
|
|
g_param_spec_object (
|
|
|
|
"settings",
|
2008-10-15 01:32:11 +00:00
|
|
|
"Settings",
|
|
|
|
"The associated settings",
|
2008-03-10 21:26:09 +00:00
|
|
|
MIDORI_TYPE_WEB_SETTINGS,
|
2009-01-16 04:19:43 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
/**
|
2008-09-03 00:28:54 +00:00
|
|
|
* MidoriBrowser:bookmarks:
|
2008-03-10 21:26:09 +00:00
|
|
|
*
|
2008-09-03 00:28:54 +00:00
|
|
|
* The bookmarks folder, containing all bookmarks.
|
2008-03-10 21:26:09 +00:00
|
|
|
*
|
2008-09-03 00:28:54 +00:00
|
|
|
* This is actually a reference to a bookmarks instance,
|
|
|
|
* so if bookmarks should be used it must be initially set.
|
2008-03-10 21:26:09 +00:00
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class,
|
2008-09-03 00:28:54 +00:00
|
|
|
PROP_BOOKMARKS,
|
|
|
|
g_param_spec_object (
|
|
|
|
"bookmarks",
|
2008-10-15 01:32:11 +00:00
|
|
|
"Bookmarks",
|
|
|
|
"The bookmarks folder, containing all bookmarks",
|
2008-10-01 02:00:16 +00:00
|
|
|
KATZE_TYPE_ARRAY,
|
2009-01-16 04:19:43 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
/**
|
2008-05-31 22:21:08 +00:00
|
|
|
* MidoriBrowser:trash:
|
2008-03-10 21:26:09 +00:00
|
|
|
*
|
|
|
|
* The trash, that collects all closed tabs and windows.
|
|
|
|
*
|
|
|
|
* This is actually a reference to a trash instance, so if a trash should
|
|
|
|
* be used it must be initially set.
|
|
|
|
*
|
|
|
|
* Note: In the future the trash might collect other types of items.
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_TRASH,
|
|
|
|
g_param_spec_object (
|
|
|
|
"trash",
|
2008-10-15 01:32:11 +00:00
|
|
|
"Trash",
|
|
|
|
"The trash, collecting recently closed tabs and windows",
|
2008-08-25 23:19:38 +00:00
|
|
|
KATZE_TYPE_ARRAY,
|
2009-01-16 04:19:43 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-06-15 02:02:56 +00:00
|
|
|
/**
|
|
|
|
* MidoriBrowser:search-engines:
|
|
|
|
*
|
|
|
|
* The list of search engines to be used for web search.
|
2008-09-03 00:28:54 +00:00
|
|
|
*
|
|
|
|
* This is actually a reference to a search engines instance,
|
|
|
|
* so if search engines should be used it must be initially set.
|
2008-06-15 02:02:56 +00:00
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_SEARCH_ENGINES,
|
|
|
|
g_param_spec_object (
|
|
|
|
"search-engines",
|
2008-10-15 01:32:11 +00:00
|
|
|
"Search Engines",
|
|
|
|
"The list of search engines to be used for web search",
|
2008-08-25 23:19:38 +00:00
|
|
|
KATZE_TYPE_ARRAY,
|
2009-01-16 04:19:43 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2008-10-07 00:19:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* MidoriBrowser:history:
|
|
|
|
*
|
|
|
|
* The list of history items.
|
|
|
|
*
|
|
|
|
* This is actually a reference to a history instance,
|
|
|
|
* so if history should be used it must be initially set.
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_HISTORY,
|
|
|
|
g_param_spec_object (
|
|
|
|
"history",
|
2008-10-15 01:32:11 +00:00
|
|
|
"History",
|
|
|
|
"The list of history items",
|
2008-10-07 00:19:33 +00:00
|
|
|
KATZE_TYPE_ARRAY,
|
2008-11-09 18:26:48 +00:00
|
|
|
flags));
|
2009-01-12 20:52:33 +00:00
|
|
|
|
2009-06-22 21:48:41 +00:00
|
|
|
/**
|
|
|
|
* MidoriBrowser:show-tabs:
|
|
|
|
*
|
|
|
|
* Whether or not to show tabs.
|
|
|
|
*
|
|
|
|
* If disabled, no tab labels are shown. This is intended for
|
|
|
|
* extensions that want to provide alternative tab labels.
|
|
|
|
*
|
|
|
|
* Since 0.1.8
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_SHOW_TABS,
|
|
|
|
g_param_spec_boolean (
|
|
|
|
"show-tabs",
|
|
|
|
"Show Tabs",
|
|
|
|
"Whether or not to show tabs",
|
|
|
|
TRUE,
|
|
|
|
flags));
|
|
|
|
|
2009-01-12 20:52:33 +00:00
|
|
|
/* Add 2px space between tool buttons */
|
|
|
|
gtk_rc_parse_string (
|
|
|
|
"style \"tool-button-style\"\n {\n"
|
|
|
|
"GtkToolButton::icon-spacing = 2\n }\n"
|
|
|
|
"widget \"MidoriBrowser.*.MidoriBookmarkbar.Gtk*ToolButton\" "
|
|
|
|
"style \"tool-button-style\"\n"
|
|
|
|
"widget \"MidoriBrowser.*.MidoriFindbar.Gtk*ToolButton\" "
|
|
|
|
"style \"tool-button-style\"\n");
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_window_new_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-05-17 18:29:31 +00:00
|
|
|
MidoriBrowser* new_browser = g_object_new (MIDORI_TYPE_BROWSER, NULL);
|
|
|
|
g_signal_emit (browser, signals[NEW_WINDOW], 0, new_browser);
|
2009-05-22 21:15:53 +00:00
|
|
|
midori_browser_add_uri (new_browser, "");
|
2009-05-26 05:41:17 +00:00
|
|
|
midori_browser_activate_action (new_browser, "Location");
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_tab_new_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-05-31 22:21:08 +00:00
|
|
|
gint n = midori_browser_add_uri (browser, "");
|
2008-04-24 22:20:43 +00:00
|
|
|
midori_browser_set_current_page (browser, n);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_open_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-05-20 01:01:54 +00:00
|
|
|
static gchar* last_dir = NULL;
|
|
|
|
gchar* uri = NULL;
|
|
|
|
gboolean folder_set = FALSE;
|
2008-07-13 19:49:57 +00:00
|
|
|
GtkWidget* dialog;
|
|
|
|
|
2009-02-28 13:05:01 +00:00
|
|
|
if (!GTK_WIDGET_VISIBLE (browser))
|
|
|
|
return;
|
|
|
|
|
2008-07-13 19:49:57 +00:00
|
|
|
dialog = gtk_file_chooser_dialog_new (
|
2008-11-02 23:17:43 +00:00
|
|
|
_("Open file"), GTK_WINDOW (browser),
|
2008-03-10 21:26:09 +00:00
|
|
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
|
|
|
|
NULL);
|
|
|
|
gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_OPEN);
|
2008-05-20 01:01:54 +00:00
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (browser));
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
/* base the start folder on the current view's uri if it is local */
|
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
|
|
|
if ((uri = (gchar*)midori_view_get_display_uri (MIDORI_VIEW (view))))
|
2008-05-20 01:01:54 +00:00
|
|
|
{
|
|
|
|
gchar* filename = g_filename_from_uri (uri, NULL, NULL);
|
|
|
|
if (filename)
|
|
|
|
{
|
|
|
|
gchar* dirname = g_path_get_dirname (filename);
|
|
|
|
if (dirname && g_file_test (dirname, G_FILE_TEST_IS_DIR))
|
|
|
|
{
|
|
|
|
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), dirname);
|
|
|
|
folder_set = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (dirname);
|
|
|
|
g_free (filename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!folder_set && last_dir && *last_dir)
|
|
|
|
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), last_dir);
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
|
|
|
|
{
|
2008-11-16 01:00:17 +00:00
|
|
|
gchar* folder;
|
|
|
|
|
|
|
|
folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
|
2008-05-20 01:01:54 +00:00
|
|
|
uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
|
2008-10-20 06:50:16 +00:00
|
|
|
midori_browser_set_current_uri (browser, uri);
|
2008-05-20 01:01:54 +00:00
|
|
|
|
|
|
|
g_free (last_dir);
|
|
|
|
last_dir = folder;
|
2008-03-10 21:26:09 +00:00
|
|
|
g_free (uri);
|
|
|
|
}
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
}
|
|
|
|
|
2008-10-26 16:07:59 +00:00
|
|
|
static void
|
|
|
|
_action_save_as_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-11-09 21:07:42 +00:00
|
|
|
midori_browser_save_uri (browser, midori_browser_get_current_uri (browser));
|
2008-10-26 16:07:59 +00:00
|
|
|
}
|
|
|
|
|
2009-05-10 12:39:20 +00:00
|
|
|
static void
|
|
|
|
_action_add_speed_dial_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
midori_browser_add_speed_dial (browser);
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
_action_tab_close_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-05-02 20:30:26 +00:00
|
|
|
GtkWidget* widget = midori_browser_get_current_tab (browser);
|
2008-07-13 19:49:57 +00:00
|
|
|
gtk_widget_destroy (widget);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_window_close_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
gtk_widget_destroy (GTK_WIDGET (browser));
|
|
|
|
}
|
|
|
|
|
2008-06-01 09:43:55 +00:00
|
|
|
static void
|
|
|
|
_action_print_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-04-05 09:28:42 +00:00
|
|
|
GtkWidget* view;
|
|
|
|
|
|
|
|
if (!GTK_WIDGET_VISIBLE (browser))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ((view = midori_browser_get_current_tab (browser)))
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_view_print (MIDORI_VIEW (view));
|
2008-06-01 09:43:55 +00:00
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
_action_quit_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-05-22 22:17:10 +00:00
|
|
|
g_signal_emit (browser, signals[QUIT], 0);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-03-27 00:21:29 +00:00
|
|
|
_action_edit_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
|
|
|
GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
|
2009-09-10 00:17:18 +00:00
|
|
|
#if WEBKIT_CHECK_VERSION (1, 1, 14)
|
|
|
|
gboolean can_undo = FALSE, can_redo = FALSE;
|
|
|
|
#endif
|
2008-03-10 21:26:09 +00:00
|
|
|
gboolean can_cut = FALSE, can_copy = FALSE, can_paste = FALSE;
|
2008-07-13 19:49:57 +00:00
|
|
|
gboolean has_selection, can_select_all = FALSE;
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-11-23 00:44:40 +00:00
|
|
|
if (WEBKIT_IS_WEB_VIEW (widget))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-11-23 00:44:40 +00:00
|
|
|
WebKitWebView* view = WEBKIT_WEB_VIEW (widget);
|
2009-09-10 00:17:18 +00:00
|
|
|
#if WEBKIT_CHECK_VERSION (1, 1, 14)
|
|
|
|
can_undo = webkit_web_view_can_undo (view);
|
|
|
|
can_redo = webkit_web_view_can_redo (view);
|
|
|
|
#endif
|
2008-11-23 00:44:40 +00:00
|
|
|
can_cut = webkit_web_view_can_cut_clipboard (view);
|
|
|
|
can_copy = webkit_web_view_can_copy_clipboard (view);
|
|
|
|
can_paste = webkit_web_view_can_paste_clipboard (view);
|
2008-07-13 19:49:57 +00:00
|
|
|
can_select_all = TRUE;
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
else if (GTK_IS_EDITABLE (widget))
|
|
|
|
{
|
|
|
|
GtkEditable* editable = GTK_EDITABLE (widget);
|
|
|
|
has_selection = gtk_editable_get_selection_bounds (editable, NULL, NULL);
|
|
|
|
can_cut = has_selection && gtk_editable_get_editable (editable);
|
|
|
|
can_copy = has_selection;
|
|
|
|
can_paste = gtk_editable_get_editable (editable);
|
2008-07-13 19:49:57 +00:00
|
|
|
can_select_all = TRUE;
|
|
|
|
}
|
|
|
|
else if (GTK_IS_TEXT_VIEW (widget))
|
|
|
|
{
|
|
|
|
GtkTextView* text_view = GTK_TEXT_VIEW (widget);
|
|
|
|
GtkTextBuffer* buffer = gtk_text_view_get_buffer (text_view);
|
|
|
|
has_selection = gtk_text_buffer_get_has_selection (buffer);
|
|
|
|
can_cut = gtk_text_view_get_editable (text_view);
|
|
|
|
can_copy = has_selection;
|
|
|
|
can_paste = gtk_text_view_get_editable (text_view) && has_selection;
|
|
|
|
can_select_all = TRUE;
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2009-09-10 00:17:18 +00:00
|
|
|
#if WEBKIT_CHECK_VERSION (1, 1, 14)
|
|
|
|
_action_set_sensitive (browser, "Undo", can_undo);
|
|
|
|
_action_set_sensitive (browser, "Redo", can_redo);
|
|
|
|
#endif
|
2008-03-10 21:26:09 +00:00
|
|
|
_action_set_sensitive (browser, "Cut", can_cut);
|
|
|
|
_action_set_sensitive (browser, "Copy", can_copy);
|
|
|
|
_action_set_sensitive (browser, "Paste", can_paste);
|
|
|
|
_action_set_sensitive (browser, "Delete", can_cut);
|
2008-07-13 19:49:57 +00:00
|
|
|
_action_set_sensitive (browser, "SelectAll", can_select_all);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2009-09-10 00:17:18 +00:00
|
|
|
#if WEBKIT_CHECK_VERSION (1, 1, 14)
|
|
|
|
static void
|
|
|
|
_action_undo_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
|
|
|
|
if (WEBKIT_IS_WEB_VIEW (widget))
|
|
|
|
webkit_web_view_undo (WEBKIT_WEB_VIEW (widget));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_redo_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
|
|
|
|
if (WEBKIT_IS_WEB_VIEW (widget))
|
|
|
|
webkit_web_view_redo (WEBKIT_WEB_VIEW (widget));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
2008-03-27 00:21:29 +00:00
|
|
|
_action_cut_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
|
|
|
GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
|
2009-02-28 13:05:01 +00:00
|
|
|
if (G_LIKELY (widget) && g_signal_lookup ("cut-clipboard", G_OBJECT_TYPE (widget)))
|
2008-03-10 21:26:09 +00:00
|
|
|
g_signal_emit_by_name (widget, "cut-clipboard");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-03-27 00:21:29 +00:00
|
|
|
_action_copy_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
|
|
|
GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
|
2009-02-28 13:05:01 +00:00
|
|
|
if (G_LIKELY (widget) && g_signal_lookup ("copy-clipboard", G_OBJECT_TYPE (widget)))
|
2008-03-10 21:26:09 +00:00
|
|
|
g_signal_emit_by_name (widget, "copy-clipboard");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-03-27 00:21:29 +00:00
|
|
|
_action_paste_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
|
|
|
GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
|
2009-02-28 13:05:01 +00:00
|
|
|
if (G_LIKELY (widget) && g_signal_lookup ("paste-clipboard", G_OBJECT_TYPE (widget)))
|
2008-03-10 21:26:09 +00:00
|
|
|
g_signal_emit_by_name (widget, "paste-clipboard");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-03-27 00:21:29 +00:00
|
|
|
_action_delete_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
|
|
|
GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
|
|
|
|
if (G_LIKELY (widget))
|
|
|
|
{
|
|
|
|
if (WEBKIT_IS_WEB_VIEW (widget))
|
|
|
|
webkit_web_view_delete_selection (WEBKIT_WEB_VIEW (widget));
|
2008-07-13 19:49:57 +00:00
|
|
|
else if (GTK_IS_EDITABLE (widget))
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_editable_delete_selection (GTK_EDITABLE (widget));
|
2008-07-13 19:49:57 +00:00
|
|
|
else if (GTK_IS_TEXT_VIEW (widget))
|
|
|
|
gtk_text_buffer_delete_selection (
|
|
|
|
gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget)), TRUE, FALSE);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-03-27 00:21:29 +00:00
|
|
|
_action_select_all_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
|
|
|
GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
|
|
|
|
if (G_LIKELY (widget))
|
|
|
|
{
|
2008-03-27 00:21:29 +00:00
|
|
|
if (GTK_IS_EDITABLE (widget))
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1);
|
2009-02-28 13:05:01 +00:00
|
|
|
else if (g_signal_lookup ("select-all", G_OBJECT_TYPE (widget)))
|
2009-05-28 21:01:56 +00:00
|
|
|
{
|
|
|
|
if (GTK_IS_TEXT_VIEW (widget))
|
|
|
|
g_signal_emit_by_name (widget, "select-all", TRUE);
|
|
|
|
else if (GTK_IS_TREE_VIEW (widget))
|
|
|
|
{
|
|
|
|
gboolean dummy;
|
|
|
|
g_signal_emit_by_name (widget, "select-all", &dummy);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
g_signal_emit_by_name (widget, "select-all");
|
|
|
|
}
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-08-31 00:45:13 +00:00
|
|
|
_action_find_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2009-01-24 14:34:31 +00:00
|
|
|
if (!GTK_WIDGET_VISIBLE (browser->find))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-07-17 19:02:14 +00:00
|
|
|
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (browser->find_text),
|
|
|
|
GTK_ICON_ENTRY_PRIMARY, GTK_STOCK_FIND);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (browser->find_text), "");
|
2009-02-22 01:34:21 +00:00
|
|
|
gtk_widget_show (GTK_WIDGET (browser->find_case));
|
|
|
|
gtk_widget_show (GTK_WIDGET (browser->find_highlight));
|
|
|
|
gtk_widget_show (GTK_WIDGET (browser->find_close));
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_widget_show (browser->find);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
2009-01-24 14:34:31 +00:00
|
|
|
|
|
|
|
gtk_widget_grab_focus (GTK_WIDGET (browser->find_text));
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_midori_browser_find (MidoriBrowser* browser,
|
|
|
|
gboolean forward)
|
|
|
|
{
|
2008-09-28 14:29:41 +00:00
|
|
|
const gchar* text;
|
|
|
|
gboolean case_sensitive;
|
|
|
|
GtkWidget* view;
|
|
|
|
|
2009-02-28 13:05:01 +00:00
|
|
|
if (!(view = midori_browser_get_current_tab (browser)))
|
|
|
|
return;
|
|
|
|
|
2008-09-28 14:29:41 +00:00
|
|
|
text = gtk_entry_get_text (GTK_ENTRY (browser->find_text));
|
|
|
|
case_sensitive = gtk_toggle_tool_button_get_active (
|
2008-08-31 00:45:13 +00:00
|
|
|
GTK_TOGGLE_TOOL_BUTTON (browser->find_case));
|
2008-09-28 14:29:41 +00:00
|
|
|
midori_view_search_text (MIDORI_VIEW (view), text, case_sensitive, forward);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2009-02-22 14:36:41 +00:00
|
|
|
static void
|
|
|
|
_midori_browser_find_done (MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
|
|
|
midori_view_unmark_text_matches (MIDORI_VIEW (view));
|
|
|
|
gtk_widget_hide (browser->find);
|
|
|
|
browser->find_typing = FALSE;
|
|
|
|
gtk_window_set_focus (GTK_WINDOW (browser),
|
|
|
|
gtk_bin_get_child (GTK_BIN (view)) ?
|
|
|
|
gtk_bin_get_child (GTK_BIN (view)) : view);
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
_action_find_next_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
_midori_browser_find (browser, TRUE);
|
|
|
|
}
|
|
|
|
|
2009-02-22 01:17:58 +00:00
|
|
|
static void
|
2009-02-22 14:36:41 +00:00
|
|
|
midori_browser_find_text_changed_cb (GtkWidget* entry,
|
|
|
|
MidoriBrowser* browser)
|
2009-02-22 01:17:58 +00:00
|
|
|
{
|
|
|
|
if (browser->find_typing)
|
2009-02-22 15:12:58 +00:00
|
|
|
{
|
2009-02-22 15:17:32 +00:00
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
2009-02-22 15:12:58 +00:00
|
|
|
const gchar* text = gtk_entry_get_text (GTK_ENTRY (entry));
|
2009-02-22 15:17:32 +00:00
|
|
|
midori_view_unmark_text_matches (MIDORI_VIEW (view));
|
2009-02-22 15:12:58 +00:00
|
|
|
if (g_utf8_strlen (text, -1) > 2)
|
|
|
|
_midori_browser_find (browser, TRUE);
|
|
|
|
}
|
2009-02-22 01:17:58 +00:00
|
|
|
}
|
|
|
|
|
2009-02-22 14:36:41 +00:00
|
|
|
static gboolean
|
|
|
|
midori_browser_find_text_focus_out_event_cb (GtkWidget* entry,
|
|
|
|
GdkEventFocus* event,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
if (browser->find_typing)
|
|
|
|
_midori_browser_find_done (browser);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
_action_find_previous_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
_midori_browser_find (browser, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_find_highlight_toggled (GtkToggleToolButton* toolitem,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-09-28 14:29:41 +00:00
|
|
|
GtkWidget* view;
|
|
|
|
gboolean highlight;
|
|
|
|
|
|
|
|
view = midori_browser_get_current_tab (browser);
|
|
|
|
highlight = gtk_toggle_tool_button_get_active (toolitem);
|
|
|
|
midori_view_set_highlight_text_matches (MIDORI_VIEW (view), highlight);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2009-01-24 14:34:31 +00:00
|
|
|
static gboolean
|
2009-01-24 21:15:37 +00:00
|
|
|
midori_browser_find_key_press_event_cb (GtkWidget* toolbar,
|
|
|
|
GdkEventKey* event,
|
|
|
|
MidoriBrowser* browser)
|
2009-01-24 14:34:31 +00:00
|
|
|
{
|
|
|
|
if (event->keyval == GDK_Escape)
|
|
|
|
{
|
2009-02-22 14:36:41 +00:00
|
|
|
_midori_browser_find_done (browser);
|
2009-01-24 14:34:31 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
midori_browser_find_button_close_clicked_cb (GtkWidget* widget,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-02-22 14:36:41 +00:00
|
|
|
_midori_browser_find_done (browser);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_navigationbar_notify_style_cb (GObject* object,
|
|
|
|
GParamSpec* arg1,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-04-16 23:38:22 +00:00
|
|
|
MidoriToolbarStyle toolbar_style;
|
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
g_object_get (browser->settings, "toolbar-style", &toolbar_style, NULL);
|
2009-07-20 04:54:46 +00:00
|
|
|
_midori_browser_set_toolbar_style (browser, toolbar_style);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2009-01-18 02:58:05 +00:00
|
|
|
static gboolean
|
|
|
|
midori_browser_toolbar_item_button_press_event_cb (GtkWidget* toolitem,
|
|
|
|
GdkEventButton* event,
|
|
|
|
MidoriBrowser* browser);
|
|
|
|
|
2009-01-27 01:57:40 +00:00
|
|
|
#if !HAVE_HILDON
|
2009-01-18 03:38:46 +00:00
|
|
|
static void
|
|
|
|
_midori_browser_save_toolbar_items (MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GString* toolbar_items;
|
|
|
|
GList* children;
|
|
|
|
gchar* items;
|
|
|
|
|
|
|
|
toolbar_items = g_string_new (NULL);
|
|
|
|
children = gtk_container_get_children (GTK_CONTAINER (browser->navigationbar));
|
|
|
|
for (; children != NULL; children = g_list_next (children))
|
|
|
|
{
|
|
|
|
GtkAction* action = gtk_widget_get_action (GTK_WIDGET (children->data));
|
2009-01-28 23:56:07 +00:00
|
|
|
/* If a widget has no action that is actually a bug, so warn about it */
|
|
|
|
g_warn_if_fail (action != NULL);
|
2009-05-30 21:59:37 +00:00
|
|
|
if (action)
|
2009-01-18 03:38:46 +00:00
|
|
|
{
|
|
|
|
g_string_append (toolbar_items, gtk_action_get_name (action));
|
|
|
|
g_string_append (toolbar_items, ",");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
items = g_string_free (toolbar_items, FALSE);
|
|
|
|
g_object_set (browser->settings, "toolbar-items", items, NULL);
|
|
|
|
g_free (items);
|
|
|
|
}
|
2009-01-27 01:57:40 +00:00
|
|
|
#endif
|
2009-01-17 22:56:23 +00:00
|
|
|
|
2009-07-10 15:37:44 +00:00
|
|
|
/**
|
|
|
|
* midori_browser_get_toolbar_actions:
|
|
|
|
*
|
|
|
|
* Retrieves a list of actions which are suitable for use in a toolbar.
|
|
|
|
*
|
|
|
|
* Return value: a NULL-terminated array of strings with actions
|
|
|
|
*
|
|
|
|
* Since: 0.1.8
|
|
|
|
**/
|
|
|
|
const gchar**
|
|
|
|
midori_browser_get_toolbar_actions (MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
static const gchar* actions[] = {
|
|
|
|
"WindowNew", "TabNew", "Open", "SaveAs", "Print", "Find",
|
|
|
|
"Fullscreen", "Preferences", "Window", "Bookmarks",
|
2009-07-26 21:40:34 +00:00
|
|
|
"RecentlyVisited", "ReloadStop", "ZoomIn", "TabClose",
|
2009-07-10 15:37:44 +00:00
|
|
|
"ZoomOut", "Separator", "Back", "Forward", "Homepage",
|
|
|
|
"Panel", "Trash", "Search", NULL };
|
|
|
|
|
|
|
|
return actions;
|
|
|
|
}
|
|
|
|
|
2008-10-12 16:14:57 +00:00
|
|
|
static gboolean
|
2009-01-17 22:56:23 +00:00
|
|
|
midori_browser_toolbar_popup_context_menu_cb (GtkWidget* widget,
|
2008-10-12 16:14:57 +00:00
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint button,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkWidget* menu;
|
|
|
|
GtkWidget* menuitem;
|
|
|
|
|
2009-04-13 02:38:01 +00:00
|
|
|
/* Unsupported trick used for web app mode */
|
|
|
|
if (g_object_get_data (G_OBJECT (browser), "locked"))
|
|
|
|
return FALSE;
|
|
|
|
|
2008-10-12 16:14:57 +00:00
|
|
|
menu = gtk_menu_new ();
|
2008-10-12 20:09:49 +00:00
|
|
|
menuitem = sokoke_action_create_popup_menu_item (
|
|
|
|
_action_by_name (browser, "Menubar"));
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
2008-10-12 16:14:57 +00:00
|
|
|
menuitem = sokoke_action_create_popup_menu_item (
|
|
|
|
_action_by_name (browser, "Navigationbar"));
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
menuitem = sokoke_action_create_popup_menu_item (
|
|
|
|
_action_by_name (browser, "Bookmarkbar"));
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
2009-03-20 22:55:38 +00:00
|
|
|
menuitem = sokoke_action_create_popup_menu_item (
|
2008-10-21 22:28:49 +00:00
|
|
|
_action_by_name (browser, "Transferbar"));
|
2009-03-20 22:55:38 +00:00
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
2008-10-21 22:28:49 +00:00
|
|
|
menuitem = sokoke_action_create_popup_menu_item (
|
|
|
|
_action_by_name (browser, "Statusbar"));
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
2008-10-12 16:14:57 +00:00
|
|
|
|
2009-01-17 22:56:23 +00:00
|
|
|
katze_widget_popup (widget, GTK_MENU (menu), NULL,
|
2008-10-12 16:14:57 +00:00
|
|
|
button == -1 ? KATZE_MENU_POSITION_LEFT : KATZE_MENU_POSITION_CURSOR);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
2008-10-10 20:31:37 +00:00
|
|
|
_action_trash_populate_popup (GtkAction* action,
|
|
|
|
GtkMenu* menu,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-10-10 20:31:37 +00:00
|
|
|
GtkWidget* menuitem;
|
2008-09-26 21:13:46 +00:00
|
|
|
|
2008-10-10 20:31:37 +00:00
|
|
|
menuitem = gtk_separator_menu_item_new ();
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
2008-10-12 19:44:00 +00:00
|
|
|
menuitem = gtk_action_create_menu_item (
|
2008-10-10 20:31:37 +00:00
|
|
|
_action_by_name (browser, "TrashEmpty"));
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_trash_activate_item (GtkAction* action,
|
|
|
|
KatzeItem* item,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-05-05 21:22:39 +00:00
|
|
|
midori_browser_set_current_uri (browser, katze_item_get_uri (item));
|
2008-08-25 23:19:38 +00:00
|
|
|
katze_array_remove_item (browser->trash, item);
|
2008-08-02 03:29:38 +00:00
|
|
|
_midori_browser_update_actions (browser);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2009-05-05 21:22:39 +00:00
|
|
|
static gboolean
|
|
|
|
_action_trash_activate_item_alt (GtkAction* action,
|
|
|
|
KatzeItem* item,
|
|
|
|
guint button,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
if (button == 2)
|
|
|
|
{
|
|
|
|
gint n;
|
|
|
|
|
|
|
|
n = midori_browser_add_uri (browser, katze_item_get_uri (item));
|
|
|
|
|
2009-05-08 11:09:14 +00:00
|
|
|
_midori_browser_set_current_page_smartly (browser, n);
|
2009-05-05 21:22:39 +00:00
|
|
|
|
|
|
|
katze_array_remove_item (browser->trash, item);
|
|
|
|
_midori_browser_update_actions (browser);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
2008-10-10 20:31:37 +00:00
|
|
|
_action_history_populate_popup (GtkAction* action,
|
|
|
|
GtkMenu* menu,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
/* Nothing to do */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_history_activate_item (GtkAction* action,
|
|
|
|
KatzeItem* item,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-10-20 06:50:16 +00:00
|
|
|
midori_browser_set_current_uri (browser, katze_item_get_uri (item));
|
2008-10-10 20:31:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_bookmarks_populate_popup (GtkAction* action,
|
|
|
|
GtkMenu* menu,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-03-28 19:57:42 +00:00
|
|
|
GtkWidget* menuitem;
|
|
|
|
|
|
|
|
if (katze_array_get_nth_item (browser->bookmarks, 0))
|
|
|
|
{
|
|
|
|
menuitem = gtk_separator_menu_item_new ();
|
|
|
|
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
}
|
2009-04-10 20:28:36 +00:00
|
|
|
menuitem = gtk_action_create_menu_item (
|
|
|
|
_action_by_name (browser, "BookmarkFolderAdd"));
|
|
|
|
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
2008-10-12 19:44:00 +00:00
|
|
|
menuitem = gtk_action_create_menu_item (
|
2008-10-10 20:31:37 +00:00
|
|
|
_action_by_name (browser, "BookmarkAdd"));
|
|
|
|
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_bookmarks_activate_item (GtkAction* action,
|
|
|
|
KatzeItem* item,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-10-20 06:50:16 +00:00
|
|
|
midori_browser_set_current_uri (browser, katze_item_get_uri (item));
|
2008-10-17 21:15:37 +00:00
|
|
|
gtk_widget_grab_focus (midori_browser_get_current_tab (browser));
|
2008-10-10 20:31:37 +00:00
|
|
|
}
|
|
|
|
|
2009-07-24 21:55:57 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-03 10:42:47 +00:00
|
|
|
static gboolean
|
2009-05-05 21:22:39 +00:00
|
|
|
_action_menus_activate_item_alt (GtkAction* action,
|
|
|
|
KatzeItem* item,
|
|
|
|
guint button,
|
|
|
|
MidoriBrowser* browser)
|
2009-05-03 10:42:47 +00:00
|
|
|
{
|
|
|
|
if (button == 2)
|
|
|
|
{
|
2009-05-08 11:09:14 +00:00
|
|
|
gint n = midori_browser_add_uri (browser, katze_item_get_uri (item));
|
|
|
|
_midori_browser_set_current_page_smartly (browser, n);
|
2009-05-03 10:42:47 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-10-10 20:31:37 +00:00
|
|
|
static void
|
|
|
|
_action_window_populate_popup (GtkAction* action,
|
|
|
|
GtkMenu* menu,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkWidget* menuitem = gtk_separator_menu_item_new ();
|
|
|
|
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
2008-10-12 19:44:00 +00:00
|
|
|
menuitem = gtk_action_create_menu_item (
|
2008-10-10 20:31:37 +00:00
|
|
|
_action_by_name (browser, "TabPrevious"));
|
|
|
|
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
2008-10-12 19:44:00 +00:00
|
|
|
menuitem = gtk_action_create_menu_item (
|
2008-10-10 20:31:37 +00:00
|
|
|
_action_by_name (browser, "TabNext"));
|
|
|
|
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_window_activate_item (GtkAction* action,
|
|
|
|
KatzeItem* item,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-09-07 01:39:25 +00:00
|
|
|
guint i, n;
|
2008-10-10 20:31:37 +00:00
|
|
|
GtkWidget* view;
|
2008-09-07 01:39:25 +00:00
|
|
|
|
2008-10-10 20:31:37 +00:00
|
|
|
n = katze_array_get_length (browser->proxy_array);
|
2008-03-10 21:26:09 +00:00
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
2008-10-10 20:31:37 +00:00
|
|
|
view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), i);
|
|
|
|
if (midori_view_get_proxy_item (MIDORI_VIEW (view)) == item)
|
|
|
|
gtk_notebook_set_current_page (GTK_NOTEBOOK (browser->notebook), i);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-22 19:47:42 +00:00
|
|
|
static void
|
|
|
|
_action_compact_menu_populate_popup (GtkAction* action,
|
|
|
|
GtkMenu* menu,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
static const GtkActionEntry actions[] = {
|
|
|
|
{ "TabNew" },
|
|
|
|
{ "WindowNew" },
|
|
|
|
{ "Open" },
|
2009-07-17 17:37:49 +00:00
|
|
|
{ "Print" },
|
2009-07-24 21:55:57 +00:00
|
|
|
{ "PrivateBrowsing" },
|
2009-06-22 19:47:42 +00:00
|
|
|
{ NULL },
|
|
|
|
{ "Bookmarkbar" },
|
|
|
|
{ "Panel" },
|
|
|
|
{ "Statusbar" },
|
|
|
|
{ NULL },
|
2009-07-24 21:55:57 +00:00
|
|
|
{ "-" },
|
2009-07-24 14:43:55 +00:00
|
|
|
{ "ClearPrivateData" },
|
2009-06-22 19:47:42 +00:00
|
|
|
{ "Fullscreen" },
|
|
|
|
{ "Preferences" },
|
|
|
|
};
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (actions); i++)
|
|
|
|
{
|
|
|
|
GtkWidget* menuitem;
|
|
|
|
if (actions[i].name != NULL)
|
2009-07-24 21:55:57 +00:00
|
|
|
{
|
|
|
|
if (actions[i].name[0] == '-')
|
|
|
|
{
|
|
|
|
g_signal_emit (browser, signals[POPULATE_TOOL_MENU], 0, menu);
|
|
|
|
continue;
|
|
|
|
}
|
2009-06-22 19:47:42 +00:00
|
|
|
menuitem = sokoke_action_create_popup_menu_item (
|
|
|
|
_action_by_name (browser, actions[i].name));
|
2009-07-24 21:55:57 +00:00
|
|
|
}
|
2009-06-22 19:47:42 +00:00
|
|
|
else
|
|
|
|
menuitem = gtk_separator_menu_item_new ();
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
2009-07-24 21:55:57 +00:00
|
|
|
gtk_widget_show (menuitem);
|
2009-06-22 19:47:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-03 22:46:54 +00:00
|
|
|
static void
|
|
|
|
midori_preferences_response_help_cb (GtkWidget* preferences,
|
|
|
|
gint response,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
if (response == GTK_RESPONSE_HELP)
|
|
|
|
gtk_action_activate (_action_by_name (browser, "HelpContents"));
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
_action_preferences_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
static GtkWidget* dialog = NULL;
|
2009-02-28 13:05:01 +00:00
|
|
|
|
|
|
|
if (!browser->settings || !GTK_WIDGET_VISIBLE (browser))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!dialog)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-04-20 01:30:24 +00:00
|
|
|
dialog = midori_preferences_new (GTK_WINDOW (browser),
|
2008-06-19 18:39:00 +00:00
|
|
|
browser->settings);
|
2008-10-03 22:46:54 +00:00
|
|
|
g_signal_connect (dialog, "response",
|
|
|
|
G_CALLBACK (midori_preferences_response_help_cb), browser);
|
2009-02-28 13:05:01 +00:00
|
|
|
g_signal_connect (dialog, "destroy",
|
|
|
|
G_CALLBACK (gtk_widget_destroyed), &dialog);
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_widget_show (dialog);
|
|
|
|
}
|
2009-02-28 13:05:01 +00:00
|
|
|
else
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2008-10-12 20:09:49 +00:00
|
|
|
static void
|
|
|
|
_action_menubar_activate (GtkToggleAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
gboolean active = gtk_toggle_action_get_active (action);
|
2009-02-28 13:05:01 +00:00
|
|
|
if (browser->settings)
|
|
|
|
g_object_set (browser->settings, "show-menubar", active, NULL);
|
2009-01-27 01:57:40 +00:00
|
|
|
#if !HAVE_HILDON
|
2008-10-12 20:09:49 +00:00
|
|
|
sokoke_widget_set_visible (browser->menubar, active);
|
2009-06-22 19:47:42 +00:00
|
|
|
if (browser->settings)
|
|
|
|
{
|
|
|
|
if (active)
|
|
|
|
{
|
|
|
|
GtkContainer* navigationbar = GTK_CONTAINER (browser->navigationbar);
|
|
|
|
GList* children = gtk_container_get_children (navigationbar);
|
|
|
|
GtkAction* menu_action = _action_by_name (browser, "CompactMenu");
|
|
|
|
for (; children != NULL; children = g_list_next (children))
|
|
|
|
{
|
|
|
|
GtkAction* action_;
|
|
|
|
action_ = gtk_widget_get_action (GTK_WIDGET (children->data));
|
|
|
|
if (action_ == menu_action)
|
|
|
|
{
|
|
|
|
gtk_container_remove (navigationbar,
|
|
|
|
GTK_WIDGET (children->data));
|
|
|
|
_midori_browser_save_toolbar_items (browser);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GtkAction* widget_action = _action_by_name (browser, "CompactMenu");
|
|
|
|
GtkWidget* toolitem = gtk_action_create_tool_item (widget_action);
|
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->navigationbar),
|
|
|
|
GTK_TOOL_ITEM (toolitem), -1);
|
|
|
|
g_signal_connect (gtk_bin_get_child (GTK_BIN (toolitem)),
|
|
|
|
"button-press-event",
|
|
|
|
G_CALLBACK (midori_browser_toolbar_item_button_press_event_cb),
|
|
|
|
browser);
|
|
|
|
_midori_browser_save_toolbar_items (browser);
|
|
|
|
}
|
|
|
|
}
|
2009-01-27 01:57:40 +00:00
|
|
|
#endif
|
2008-10-12 20:09:49 +00:00
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
_action_navigationbar_activate (GtkToggleAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-04-16 23:38:22 +00:00
|
|
|
gboolean active = gtk_toggle_action_get_active (action);
|
2009-02-28 13:05:01 +00:00
|
|
|
if (browser->settings)
|
|
|
|
g_object_set (browser->settings, "show-navigationbar", active, NULL);
|
2008-06-19 18:39:00 +00:00
|
|
|
sokoke_widget_set_visible (browser->navigationbar, active);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_bookmarkbar_activate (GtkToggleAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-04-16 23:38:22 +00:00
|
|
|
gboolean active = gtk_toggle_action_get_active (action);
|
2009-02-28 13:05:01 +00:00
|
|
|
if (browser->settings)
|
|
|
|
g_object_set (browser->settings, "show-bookmarkbar", active, NULL);
|
2008-06-19 18:39:00 +00:00
|
|
|
sokoke_widget_set_visible (browser->bookmarkbar, active);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2009-03-20 22:55:38 +00:00
|
|
|
static void
|
|
|
|
_action_transferbar_activate (GtkToggleAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
gboolean active = gtk_toggle_action_get_active (action);
|
|
|
|
if (browser->settings)
|
|
|
|
g_object_set (browser->settings, "show-transferbar", active, NULL);
|
|
|
|
sokoke_widget_set_visible (browser->transferbar, active);
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
_action_statusbar_activate (GtkToggleAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-04-16 23:38:22 +00:00
|
|
|
gboolean active = gtk_toggle_action_get_active (action);
|
2009-02-28 13:05:01 +00:00
|
|
|
if (browser->settings)
|
|
|
|
g_object_set (browser->settings, "show-statusbar", active, NULL);
|
2009-01-27 01:57:40 +00:00
|
|
|
#if !HAVE_HILDON
|
2008-06-19 18:39:00 +00:00
|
|
|
sokoke_widget_set_visible (browser->statusbar, active);
|
2009-01-27 01:57:40 +00:00
|
|
|
#endif
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_reload_stop_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
gchar* stock_id;
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view;
|
|
|
|
GdkModifierType state = (GdkModifierType)0;
|
|
|
|
gint x, y;
|
|
|
|
gboolean from_cache;
|
|
|
|
|
2009-02-28 13:05:01 +00:00
|
|
|
if (!(view = midori_browser_get_current_tab (browser)))
|
|
|
|
return;
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
g_object_get (action, "stock-id", &stock_id, NULL);
|
2008-09-26 21:13:46 +00:00
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Refresh or stop, depending on the stock id */
|
2008-03-10 21:26:09 +00:00
|
|
|
if (!strcmp (stock_id, GTK_STOCK_REFRESH))
|
|
|
|
{
|
|
|
|
gdk_window_get_pointer (NULL, &x, &y, &state);
|
2008-09-26 21:13:46 +00:00
|
|
|
from_cache = state & GDK_SHIFT_MASK;
|
|
|
|
midori_view_reload (MIDORI_VIEW (view), !from_cache);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
else
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_view_stop_loading (MIDORI_VIEW (view));
|
2008-03-10 21:26:09 +00:00
|
|
|
g_free (stock_id);
|
|
|
|
}
|
|
|
|
|
2008-06-01 09:26:10 +00:00
|
|
|
static void
|
2008-03-10 21:26:09 +00:00
|
|
|
_action_zoom_in_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
|
|
|
if (view)
|
|
|
|
midori_view_set_zoom_level (MIDORI_VIEW (view),
|
|
|
|
midori_view_get_zoom_level (MIDORI_VIEW (view)) + 0.25f);
|
2008-06-01 09:26:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-03-10 21:26:09 +00:00
|
|
|
_action_zoom_out_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
|
|
|
if (view)
|
|
|
|
midori_view_set_zoom_level (MIDORI_VIEW (view),
|
|
|
|
midori_view_get_zoom_level (MIDORI_VIEW (view)) - 0.25f);
|
2008-06-01 09:26:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-03-10 21:26:09 +00:00
|
|
|
_action_zoom_normal_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
|
|
|
if (view)
|
|
|
|
midori_view_set_zoom_level (MIDORI_VIEW (view), 1.0f);
|
2008-06-01 09:26:10 +00:00
|
|
|
}
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2009-02-27 22:09:36 +00:00
|
|
|
static void
|
|
|
|
_action_view_encoding_activate (GtkAction* action,
|
2009-06-22 20:55:23 +00:00
|
|
|
GtkAction* current,
|
2009-02-27 22:09:36 +00:00
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
2009-02-28 13:05:01 +00:00
|
|
|
if (view && midori_browser_view_can_set_encoding (MIDORI_VIEW (view)))
|
2009-02-27 22:09:36 +00:00
|
|
|
{
|
|
|
|
const gchar* name;
|
|
|
|
GtkWidget* web_view;
|
|
|
|
|
2009-06-22 20:55:23 +00:00
|
|
|
name = gtk_action_get_name (current);
|
2009-02-27 22:09:36 +00:00
|
|
|
web_view = gtk_bin_get_child (GTK_BIN (view));
|
|
|
|
if (!strcmp (name, "EncodingAutomatic"))
|
|
|
|
g_object_set (web_view, "custom-encoding", NULL, NULL);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const gchar* encoding;
|
|
|
|
if (!strcmp (name, "EncodingChinese"))
|
|
|
|
encoding = "BIG5";
|
|
|
|
else if (!strcmp (name, "EncodingJapanese"))
|
|
|
|
encoding = "SHIFT_JIS";
|
|
|
|
else if (!strcmp (name, "EncodingRussian"))
|
|
|
|
encoding = "KOI8-R";
|
|
|
|
else if (!strcmp (name, "EncodingUnicode"))
|
|
|
|
encoding = "UTF-8";
|
|
|
|
else if (!strcmp (name, "EncodingWestern"))
|
|
|
|
encoding = "ISO-8859-1";
|
|
|
|
else
|
|
|
|
g_assert_not_reached ();
|
|
|
|
g_object_set (web_view, "custom-encoding", encoding, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-23 23:15:43 +00:00
|
|
|
static gchar*
|
|
|
|
midori_browser_get_uri_extension (const gchar* uri)
|
|
|
|
{
|
|
|
|
gchar* extension;
|
|
|
|
gchar* slash;
|
|
|
|
gchar* period;
|
|
|
|
gchar* ext_end;
|
|
|
|
gchar* tmp = g_strdup (uri);
|
|
|
|
|
|
|
|
/* Find the last slash in the URI and search for the last period
|
|
|
|
*after* the last slash. This is not completely accurate
|
|
|
|
but should cover most (simple) URIs */
|
|
|
|
slash = strrchr (tmp, '/');
|
|
|
|
/* Huh, URI without slashes? */
|
|
|
|
if (!slash)
|
|
|
|
return g_strdup ("");
|
|
|
|
|
|
|
|
ext_end = period = strrchr (slash, '.');
|
|
|
|
if (!period)
|
|
|
|
return g_strdup ("");
|
|
|
|
|
|
|
|
/* Skip the period */
|
|
|
|
ext_end++;
|
|
|
|
/* If *ext_end is 0 here, the URI ended with a period, so skip */
|
|
|
|
if (!*ext_end)
|
|
|
|
return g_strdup ("");
|
|
|
|
|
|
|
|
/* Find the end of the extension */
|
|
|
|
while (*ext_end && g_ascii_isalnum (*ext_end))
|
|
|
|
ext_end++;
|
|
|
|
|
|
|
|
*ext_end = 0;
|
|
|
|
extension = g_strdup (period);
|
|
|
|
|
|
|
|
g_free (tmp);
|
|
|
|
|
|
|
|
return extension;
|
|
|
|
}
|
|
|
|
|
2008-10-20 19:32:25 +00:00
|
|
|
static void
|
2008-10-26 16:07:59 +00:00
|
|
|
midori_browser_source_transfer_cb (KatzeNetRequest* request,
|
|
|
|
MidoriBrowser* browser)
|
2008-10-20 19:32:25 +00:00
|
|
|
{
|
|
|
|
gchar* filename;
|
2008-10-23 23:15:43 +00:00
|
|
|
gchar* extension;
|
2008-10-20 19:32:25 +00:00
|
|
|
gchar* unique_filename;
|
|
|
|
gchar* text_editor;
|
|
|
|
gint fd;
|
|
|
|
FILE* fp;
|
2008-11-15 23:10:39 +00:00
|
|
|
size_t ret;
|
2008-10-20 19:32:25 +00:00
|
|
|
|
2008-10-23 22:09:12 +00:00
|
|
|
if (request->data)
|
2008-10-20 19:32:25 +00:00
|
|
|
{
|
2008-10-23 23:15:43 +00:00
|
|
|
extension = midori_browser_get_uri_extension (request->uri);
|
|
|
|
filename = g_strdup_printf ("%uXXXXXX%s",
|
|
|
|
g_str_hash (request->uri), extension);
|
|
|
|
g_free (extension);
|
2008-10-20 19:32:25 +00:00
|
|
|
if (((fd = g_file_open_tmp (filename, &unique_filename, NULL)) != -1))
|
|
|
|
{
|
|
|
|
if ((fp = fdopen (fd, "w")))
|
|
|
|
{
|
2008-11-15 23:10:39 +00:00
|
|
|
ret = fwrite (request->data, 1, request->length, fp);
|
2008-10-20 19:32:25 +00:00
|
|
|
fclose (fp);
|
2008-11-15 23:10:39 +00:00
|
|
|
if ((ret - request->length) != 0)
|
|
|
|
{
|
2008-11-18 22:18:53 +00:00
|
|
|
/* FIXME: Show an error in the graphical interface */
|
|
|
|
g_warning ("Error writing to file %s "
|
|
|
|
"in midori_browser_source_transfer_cb()", filename);
|
2008-11-15 23:10:39 +00:00
|
|
|
}
|
2008-10-20 19:32:25 +00:00
|
|
|
g_object_get (browser->settings,
|
|
|
|
"text-editor", &text_editor, NULL);
|
2009-03-17 20:35:05 +00:00
|
|
|
if (text_editor && *text_editor)
|
2009-04-26 22:22:16 +00:00
|
|
|
sokoke_spawn_program (text_editor, unique_filename, TRUE);
|
2009-03-17 20:35:05 +00:00
|
|
|
else
|
2009-04-20 17:10:13 +00:00
|
|
|
sokoke_show_uri (NULL, unique_filename,
|
|
|
|
gtk_get_current_event_time (), NULL);
|
2009-03-17 20:35:05 +00:00
|
|
|
|
2008-10-20 19:32:25 +00:00
|
|
|
g_free (unique_filename);
|
|
|
|
g_free (text_editor);
|
|
|
|
}
|
|
|
|
close (fd);
|
|
|
|
}
|
|
|
|
g_free (filename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-13 19:49:57 +00:00
|
|
|
static void
|
2008-03-10 21:26:09 +00:00
|
|
|
_action_source_view_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view;
|
2009-03-17 20:35:05 +00:00
|
|
|
gchar* text_editor;
|
|
|
|
const gchar* uri;
|
2008-07-13 19:49:57 +00:00
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
if (!(view = midori_browser_get_current_tab (browser)))
|
2008-07-13 19:49:57 +00:00
|
|
|
return;
|
|
|
|
|
2009-02-28 13:05:01 +00:00
|
|
|
if (browser->settings)
|
|
|
|
g_object_get (browser->settings, "text-editor", &text_editor, NULL);
|
|
|
|
else
|
|
|
|
text_editor = NULL;
|
2009-03-17 20:35:05 +00:00
|
|
|
uri = midori_view_get_display_uri (MIDORI_VIEW (view));
|
2009-02-28 13:05:01 +00:00
|
|
|
|
2009-09-14 21:57:57 +00:00
|
|
|
if (!(text_editor && *text_editor))
|
2008-10-20 19:32:25 +00:00
|
|
|
{
|
2009-09-14 21:57:57 +00:00
|
|
|
#if WEBKIT_CHECK_VERSION (1, 1, 14)
|
|
|
|
GtkWidget* source;
|
|
|
|
GtkWidget* web_view;
|
2009-03-17 20:35:05 +00:00
|
|
|
|
2009-09-14 21:57:57 +00:00
|
|
|
source = midori_view_new (browser->net);
|
|
|
|
midori_view_set_uri (MIDORI_VIEW (source), "");
|
|
|
|
web_view = gtk_bin_get_child (GTK_BIN (source));
|
|
|
|
webkit_web_view_set_view_source_mode (WEBKIT_WEB_VIEW (web_view), TRUE);
|
|
|
|
webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), uri);
|
|
|
|
gtk_widget_show (source);
|
|
|
|
midori_browser_add_tab (browser, source);
|
|
|
|
return;
|
|
|
|
#else
|
|
|
|
GFile* file = g_file_new_for_uri (uri);
|
2009-03-17 20:35:05 +00:00
|
|
|
gchar* content_type;
|
|
|
|
GAppInfo* app_info;
|
|
|
|
GList* files;
|
|
|
|
gpointer context;
|
|
|
|
|
|
|
|
#if GLIB_CHECK_VERSION (2, 18, 0)
|
|
|
|
content_type = g_content_type_from_mime_type ("text/plain");
|
|
|
|
#else
|
|
|
|
content_type = g_strdup ("text/plain");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
app_info = g_app_info_get_default_for_type (content_type,
|
|
|
|
!g_str_has_prefix (uri, "file://"));
|
|
|
|
g_free (content_type);
|
|
|
|
files = g_list_prepend (NULL, file);
|
|
|
|
#if GTK_CHECK_VERSION (2, 14, 0)
|
|
|
|
context = gdk_app_launch_context_new ();
|
|
|
|
gdk_app_launch_context_set_screen (context, gtk_widget_get_screen (view));
|
|
|
|
gdk_app_launch_context_set_timestamp (context, gtk_get_current_event_time ());
|
|
|
|
#else
|
|
|
|
context = g_app_launch_context_new ();
|
|
|
|
#endif
|
|
|
|
if (g_app_info_launch (app_info, files, context, NULL))
|
|
|
|
{
|
|
|
|
g_object_unref (app_info);
|
|
|
|
g_list_free (files);
|
|
|
|
g_object_unref (file);
|
|
|
|
g_free (text_editor);
|
|
|
|
return;
|
|
|
|
}
|
2009-09-14 21:57:57 +00:00
|
|
|
#endif
|
2008-10-20 19:32:25 +00:00
|
|
|
}
|
2009-03-17 20:35:05 +00:00
|
|
|
|
|
|
|
katze_net_load_uri (browser->net, uri, NULL,
|
|
|
|
(KatzeNetTransferCb)midori_browser_source_transfer_cb, browser);
|
2008-10-20 19:32:25 +00:00
|
|
|
g_free (text_editor);
|
2008-07-13 19:49:57 +00:00
|
|
|
}
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
_action_fullscreen_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-02-28 13:05:01 +00:00
|
|
|
if (!GTK_WIDGET (browser)->window)
|
|
|
|
return;
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
GdkWindowState state = gdk_window_get_state (GTK_WIDGET (browser)->window);
|
|
|
|
if (state & GDK_WINDOW_STATE_FULLSCREEN)
|
|
|
|
gtk_window_unfullscreen (GTK_WINDOW (browser));
|
|
|
|
else
|
|
|
|
gtk_window_fullscreen (GTK_WINDOW (browser));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_back_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-05-17 11:38:42 +00:00
|
|
|
if (g_object_get_data (G_OBJECT (action), "midori-middle-click"))
|
|
|
|
{
|
|
|
|
g_object_set_data (G_OBJECT (action), "midori-middle-click", (void*)0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
|
|
|
if (view)
|
|
|
|
midori_view_go_back (MIDORI_VIEW (view));
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_forward_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-05-17 11:38:42 +00:00
|
|
|
if (g_object_get_data (G_OBJECT (action), "midori-middle-click"))
|
|
|
|
{
|
|
|
|
g_object_set_data (G_OBJECT (action), "midori-middle-click", (void*)0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
|
|
|
if (view)
|
|
|
|
midori_view_go_forward (MIDORI_VIEW (view));
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-05-20 01:21:11 +00:00
|
|
|
_action_homepage_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2009-05-17 11:38:42 +00:00
|
|
|
if (g_object_get_data (G_OBJECT (action), "midori-middle-click"))
|
|
|
|
{
|
|
|
|
g_object_set_data (G_OBJECT (action), "midori-middle-click", (void*)0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-04-16 23:38:22 +00:00
|
|
|
gchar* homepage;
|
|
|
|
|
2009-02-28 13:05:01 +00:00
|
|
|
if (!browser->settings)
|
|
|
|
return;
|
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
g_object_get (browser->settings, "homepage", &homepage, NULL);
|
2008-10-20 06:50:16 +00:00
|
|
|
midori_browser_set_current_uri (browser, homepage);
|
2008-04-16 23:38:22 +00:00
|
|
|
g_free (homepage);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2008-07-17 19:02:14 +00:00
|
|
|
static void
|
2008-08-14 23:57:48 +00:00
|
|
|
_action_location_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-02-28 13:05:01 +00:00
|
|
|
if (!browser->show_navigationbar)
|
2008-08-14 23:57:48 +00:00
|
|
|
gtk_widget_show (browser->navigationbar);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_location_active_changed (GtkAction* action,
|
2009-01-09 21:54:40 +00:00
|
|
|
gint idx,
|
2008-08-14 23:57:48 +00:00
|
|
|
MidoriBrowser* browser)
|
2008-07-17 19:02:14 +00:00
|
|
|
{
|
|
|
|
const gchar* uri;
|
|
|
|
|
2009-01-09 21:54:40 +00:00
|
|
|
if (idx > -1)
|
2008-07-17 19:02:14 +00:00
|
|
|
{
|
2008-08-14 23:57:48 +00:00
|
|
|
uri = midori_location_action_get_uri (MIDORI_LOCATION_ACTION (action));
|
2008-10-20 06:50:16 +00:00
|
|
|
midori_browser_set_current_uri (browser, uri);
|
2008-07-17 19:02:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-17 15:36:03 +00:00
|
|
|
static void
|
|
|
|
midori_browser_bookmark_homepage_clicked_cb (GtkToolItem* button,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
gchar* homepage;
|
|
|
|
g_object_get (browser->settings, "homepage", &homepage, NULL);
|
|
|
|
midori_browser_set_current_uri (browser, homepage);
|
|
|
|
g_free (homepage);
|
|
|
|
gtk_widget_grab_focus (midori_browser_get_current_tab (browser));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
browser_bookmarks_add_item_cb (KatzeArray* array,
|
|
|
|
KatzeItem* item,
|
|
|
|
GtkWidget* toolbar);
|
|
|
|
|
2009-06-13 01:45:11 +00:00
|
|
|
static void
|
|
|
|
_action_location_focus_in (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
midori_location_action_set_secondary_icon (
|
|
|
|
MIDORI_LOCATION_ACTION (action), GTK_STOCK_JUMP_TO);
|
|
|
|
}
|
|
|
|
|
2008-08-14 23:57:48 +00:00
|
|
|
static void
|
|
|
|
_action_location_focus_out (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2009-06-13 01:45:11 +00:00
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
|
|
|
|
2009-02-28 13:05:01 +00:00
|
|
|
if (!browser->show_navigationbar)
|
2008-08-14 23:57:48 +00:00
|
|
|
gtk_widget_hide (browser->navigationbar);
|
2009-06-13 01:45:11 +00:00
|
|
|
|
|
|
|
if (g_object_get_data (G_OBJECT (view), "news-feeds"))
|
|
|
|
midori_location_action_set_secondary_icon (
|
|
|
|
MIDORI_LOCATION_ACTION (action), STOCK_NEWS_FEED);
|
|
|
|
else
|
|
|
|
midori_location_action_set_secondary_icon (
|
|
|
|
MIDORI_LOCATION_ACTION (action), GTK_STOCK_JUMP_TO);
|
2008-08-14 23:57:48 +00:00
|
|
|
}
|
2008-04-20 19:44:56 +00:00
|
|
|
|
2008-08-14 23:57:48 +00:00
|
|
|
static void
|
|
|
|
_action_location_reset_uri (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
const gchar* uri;
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
uri = midori_browser_get_current_uri (browser);
|
2008-08-14 23:57:48 +00:00
|
|
|
midori_location_action_set_uri (MIDORI_LOCATION_ACTION (action), uri);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-08-14 23:57:48 +00:00
|
|
|
_action_location_submit_uri (GtkAction* action,
|
|
|
|
const gchar* uri,
|
2008-08-31 01:21:29 +00:00
|
|
|
gboolean new_tab,
|
2008-08-14 23:57:48 +00:00
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2009-06-11 21:31:02 +00:00
|
|
|
gchar* stripped_uri;
|
2008-08-14 23:57:48 +00:00
|
|
|
gchar* new_uri;
|
2008-08-31 01:21:29 +00:00
|
|
|
gint n;
|
2008-08-14 23:57:48 +00:00
|
|
|
|
2009-06-11 21:31:02 +00:00
|
|
|
stripped_uri = g_strdup (uri);
|
|
|
|
g_strstrip (stripped_uri);
|
|
|
|
new_uri = sokoke_magic_uri (stripped_uri, browser->search_engines);
|
2009-04-18 22:47:02 +00:00
|
|
|
if (!new_uri)
|
2009-06-11 21:38:07 +00:00
|
|
|
new_uri = sokoke_search_uri (browser->location_entry_search, stripped_uri);
|
|
|
|
g_free (stripped_uri);
|
2009-04-18 20:41:37 +00:00
|
|
|
|
2008-08-31 01:21:29 +00:00
|
|
|
if (new_tab)
|
|
|
|
{
|
|
|
|
n = midori_browser_add_uri (browser, new_uri);
|
|
|
|
midori_browser_set_current_page (browser, n);
|
|
|
|
}
|
|
|
|
else
|
2008-10-20 06:50:16 +00:00
|
|
|
midori_browser_set_current_uri (browser, new_uri);
|
2008-08-14 23:57:48 +00:00
|
|
|
g_free (new_uri);
|
|
|
|
gtk_widget_grab_focus (midori_browser_get_current_tab (browser));
|
2008-04-22 21:36:37 +00:00
|
|
|
}
|
|
|
|
|
2009-08-16 21:35:29 +00:00
|
|
|
static gboolean
|
2008-08-14 23:57:48 +00:00
|
|
|
_action_location_secondary_icon_released (GtkAction* action,
|
|
|
|
GtkWidget* widget,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-04-13 20:40:57 +00:00
|
|
|
GtkWidget* view;
|
2008-08-14 23:57:48 +00:00
|
|
|
|
2009-04-13 20:40:57 +00:00
|
|
|
if ((view = midori_browser_get_current_tab (browser)))
|
2008-08-14 23:57:48 +00:00
|
|
|
{
|
2009-04-13 20:40:57 +00:00
|
|
|
const gchar* uri = midori_view_get_display_uri (MIDORI_VIEW (view));
|
2009-06-13 01:45:11 +00:00
|
|
|
if (gtk_window_get_focus (GTK_WINDOW (browser)) == widget)
|
|
|
|
_action_location_submit_uri (action, uri, FALSE, browser);
|
2009-08-14 21:28:18 +00:00
|
|
|
else if ((uri = g_object_get_data (G_OBJECT (view), "news-feeds")))
|
|
|
|
{
|
|
|
|
if (browser->news_aggregator && *browser->news_aggregator)
|
|
|
|
sokoke_spawn_program (browser->news_aggregator, uri, TRUE);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GtkWidget* dialog = gtk_message_dialog_new (
|
|
|
|
GTK_WINDOW (browser), 0, GTK_MESSAGE_INFO,
|
|
|
|
GTK_BUTTONS_OK, "%s", _("New feed"));
|
|
|
|
gtk_message_dialog_format_secondary_text (
|
|
|
|
GTK_MESSAGE_DIALOG (dialog), "%s", uri);
|
|
|
|
gtk_widget_show (dialog);
|
|
|
|
g_signal_connect_swapped (dialog, "response",
|
|
|
|
G_CALLBACK (gtk_widget_destroy), dialog);
|
|
|
|
}
|
|
|
|
}
|
2009-06-13 01:45:11 +00:00
|
|
|
else
|
|
|
|
_action_location_submit_uri (action, uri, FALSE, browser);
|
2009-08-16 21:35:29 +00:00
|
|
|
return TRUE;
|
2008-08-14 23:57:48 +00:00
|
|
|
}
|
2009-08-16 21:35:29 +00:00
|
|
|
|
|
|
|
return FALSE;
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2008-10-05 21:25:02 +00:00
|
|
|
static void
|
|
|
|
_action_search_submit (GtkAction* action,
|
|
|
|
const gchar* keywords,
|
|
|
|
gboolean new_tab,
|
|
|
|
MidoriBrowser* browser)
|
2008-04-22 21:36:37 +00:00
|
|
|
{
|
2008-10-05 21:25:02 +00:00
|
|
|
guint last_web_search;
|
|
|
|
KatzeItem* item;
|
|
|
|
const gchar* url;
|
|
|
|
gchar* search;
|
2008-10-01 02:00:16 +00:00
|
|
|
|
2009-05-01 22:23:43 +00:00
|
|
|
if (!browser->settings)
|
|
|
|
return;
|
|
|
|
|
2008-10-05 21:25:02 +00:00
|
|
|
g_object_get (browser->settings, "last-web-search", &last_web_search, NULL);
|
|
|
|
item = katze_array_get_nth_item (browser->search_engines, last_web_search);
|
|
|
|
if (item)
|
|
|
|
url = katze_item_get_uri (item);
|
|
|
|
else /* The location entry search is our fallback */
|
2009-04-18 20:41:37 +00:00
|
|
|
url = browser->location_entry_search;
|
|
|
|
|
2009-04-19 22:39:36 +00:00
|
|
|
search = sokoke_search_uri (url, keywords);
|
2008-10-05 21:25:02 +00:00
|
|
|
|
|
|
|
if (new_tab)
|
|
|
|
midori_browser_add_uri (browser, search);
|
|
|
|
else
|
2008-10-20 06:50:16 +00:00
|
|
|
midori_browser_set_current_uri (browser, search);
|
2008-10-05 21:25:02 +00:00
|
|
|
|
|
|
|
g_free (search);
|
|
|
|
}
|
|
|
|
|
2009-04-29 22:43:47 +00:00
|
|
|
static void
|
|
|
|
_action_search_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GSList* proxies = gtk_action_get_proxies (action);
|
|
|
|
guint i = 0;
|
|
|
|
GtkWidget* proxy;
|
2009-05-06 00:41:17 +00:00
|
|
|
const gchar* uri;
|
|
|
|
gchar* search;
|
|
|
|
|
2009-04-29 22:43:47 +00:00
|
|
|
while (((proxy = g_slist_nth_data (proxies, i++))))
|
|
|
|
if (GTK_IS_TOOL_ITEM (proxy))
|
|
|
|
{
|
|
|
|
if (!GTK_WIDGET_VISIBLE (browser->navigationbar))
|
|
|
|
gtk_widget_show (browser->navigationbar);
|
|
|
|
return;
|
|
|
|
}
|
2009-05-06 00:41:17 +00:00
|
|
|
|
|
|
|
/* Load default search engine in current tab */
|
|
|
|
uri = browser->location_entry_search;
|
|
|
|
search = sokoke_search_uri (uri ? uri : "", "");
|
|
|
|
midori_browser_set_current_uri (browser, search);
|
2009-04-29 22:43:47 +00:00
|
|
|
gtk_widget_grab_focus (midori_browser_get_current_tab (browser));
|
2009-05-06 00:41:17 +00:00
|
|
|
g_free (search);
|
2009-04-29 22:43:47 +00:00
|
|
|
}
|
|
|
|
|
2008-10-05 21:25:02 +00:00
|
|
|
static void
|
|
|
|
_action_search_notify_current_item (GtkAction* action,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
MidoriSearchAction* search_action;
|
|
|
|
KatzeItem* item;
|
2009-01-09 21:54:40 +00:00
|
|
|
guint idx;
|
2008-10-05 21:25:02 +00:00
|
|
|
|
|
|
|
search_action = MIDORI_SEARCH_ACTION (action);
|
|
|
|
item = midori_search_action_get_current_item (search_action);
|
|
|
|
if (item)
|
2009-01-09 21:54:40 +00:00
|
|
|
idx = katze_array_get_item_index (browser->search_engines, item);
|
2008-10-05 21:25:02 +00:00
|
|
|
else
|
2009-01-09 21:54:40 +00:00
|
|
|
idx = 0;
|
2008-10-05 21:25:02 +00:00
|
|
|
|
2009-01-09 21:54:40 +00:00
|
|
|
g_object_set (browser->settings, "last-web-search", idx, NULL);
|
2008-10-05 21:25:02 +00:00
|
|
|
}
|
|
|
|
|
2009-04-18 20:41:37 +00:00
|
|
|
static void
|
|
|
|
_action_search_notify_default_item (GtkAction* action,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
MidoriSearchAction* search_action;
|
|
|
|
KatzeItem* item;
|
|
|
|
|
|
|
|
search_action = MIDORI_SEARCH_ACTION (action);
|
|
|
|
item = midori_search_action_get_default_item (search_action);
|
|
|
|
if (item)
|
|
|
|
g_object_set (browser->settings, "location-entry-search",
|
|
|
|
katze_item_get_uri (item), NULL);
|
|
|
|
}
|
|
|
|
|
2008-10-05 21:25:02 +00:00
|
|
|
static void
|
|
|
|
_action_search_focus_out (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-02-28 13:05:01 +00:00
|
|
|
if (GTK_WIDGET_VISIBLE (browser->statusbar) && !browser->show_navigationbar)
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_widget_hide (browser->navigationbar);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-10-30 01:19:52 +00:00
|
|
|
midori_browser_bookmark_popup_item (GtkWidget* menu,
|
|
|
|
const gchar* stock_id,
|
2008-11-02 23:17:43 +00:00
|
|
|
const gchar* label,
|
2008-10-30 01:19:52 +00:00
|
|
|
KatzeItem* item,
|
|
|
|
gpointer callback,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
const gchar* uri;
|
|
|
|
GtkWidget* menuitem;
|
|
|
|
|
|
|
|
uri = katze_item_get_uri (item);
|
|
|
|
|
|
|
|
menuitem = gtk_image_menu_item_new_from_stock (stock_id, NULL);
|
2008-11-02 23:17:43 +00:00
|
|
|
if (label)
|
|
|
|
gtk_label_set_text_with_mnemonic (GTK_LABEL (gtk_bin_get_child (
|
|
|
|
GTK_BIN (menuitem))), label);
|
2008-10-30 01:19:52 +00:00
|
|
|
if (!strcmp (stock_id, GTK_STOCK_EDIT))
|
|
|
|
gtk_widget_set_sensitive (menuitem,
|
|
|
|
KATZE_IS_ARRAY (item) || uri != NULL);
|
2009-02-27 20:52:51 +00:00
|
|
|
else if (!KATZE_IS_ARRAY (item) && strcmp (stock_id, GTK_STOCK_DELETE))
|
2008-10-30 01:19:52 +00:00
|
|
|
gtk_widget_set_sensitive (menuitem, uri != NULL);
|
|
|
|
g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item);
|
|
|
|
g_signal_connect (menuitem, "activate", G_CALLBACK (callback), browser);
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_bookmark_open_activate_cb (GtkWidget* menuitem,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
KatzeItem* item;
|
|
|
|
const gchar* uri;
|
|
|
|
|
|
|
|
item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
|
|
|
|
uri = katze_item_get_uri (item);
|
|
|
|
|
|
|
|
if (uri && *uri)
|
|
|
|
midori_browser_set_current_uri (browser, uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_bookmark_open_in_tab_activate_cb (GtkWidget* menuitem,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
KatzeItem* item;
|
|
|
|
const gchar* uri;
|
|
|
|
guint n;
|
|
|
|
|
|
|
|
item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
|
2009-02-27 20:52:51 +00:00
|
|
|
if (KATZE_IS_ARRAY (item))
|
|
|
|
{
|
|
|
|
KatzeItem* child;
|
|
|
|
guint i = 0;
|
2008-10-30 01:19:52 +00:00
|
|
|
|
2009-02-27 20:52:51 +00:00
|
|
|
while ((child = katze_array_get_nth_item (KATZE_ARRAY (item), i)))
|
|
|
|
{
|
|
|
|
if ((uri = katze_item_get_uri (child)) && *uri)
|
|
|
|
{
|
|
|
|
n = midori_browser_add_item (browser, child);
|
|
|
|
_midori_browser_set_current_page_smartly (browser, n);
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2008-10-30 01:19:52 +00:00
|
|
|
{
|
2009-02-27 20:52:51 +00:00
|
|
|
if ((uri = katze_item_get_uri (item)) && *uri)
|
|
|
|
{
|
|
|
|
n = midori_browser_add_item (browser, item);
|
|
|
|
_midori_browser_set_current_page_smartly (browser, n);
|
|
|
|
}
|
2008-10-30 01:19:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_bookmark_open_in_window_activate_cb (GtkWidget* menuitem,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
KatzeItem* item;
|
|
|
|
const gchar* uri;
|
|
|
|
|
|
|
|
item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
|
|
|
|
uri = katze_item_get_uri (item);
|
|
|
|
|
|
|
|
if (uri && *uri)
|
2009-05-17 18:29:31 +00:00
|
|
|
{
|
|
|
|
MidoriBrowser* new_browser = g_object_new (MIDORI_TYPE_BROWSER, NULL);
|
|
|
|
g_signal_emit (browser, signals[NEW_WINDOW], 0, new_browser);
|
2009-05-22 21:15:53 +00:00
|
|
|
midori_browser_add_uri (new_browser, uri);
|
2009-05-17 18:29:31 +00:00
|
|
|
}
|
2008-10-30 01:19:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_bookmark_edit_activate_cb (GtkWidget* menuitem,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-10-30 01:19:52 +00:00
|
|
|
KatzeItem* item;
|
2008-10-01 02:00:16 +00:00
|
|
|
const gchar* uri;
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-10-30 01:19:52 +00:00
|
|
|
item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
|
2008-10-01 02:00:16 +00:00
|
|
|
uri = katze_item_get_uri (item);
|
|
|
|
|
2009-02-22 02:11:40 +00:00
|
|
|
if (KATZE_IS_ARRAY (item))
|
|
|
|
midori_browser_edit_bookmark_dialog_new (browser, item, FALSE, TRUE);
|
|
|
|
else if (uri && *uri)
|
|
|
|
midori_browser_edit_bookmark_dialog_new (browser, item, FALSE, FALSE);
|
2008-10-30 01:19:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_bookmark_delete_activate_cb (GtkWidget* menuitem,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
KatzeItem* item;
|
|
|
|
const gchar* uri;
|
|
|
|
KatzeItem* parent;
|
|
|
|
|
|
|
|
item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
|
|
|
|
uri = katze_item_get_uri (item);
|
|
|
|
|
2008-10-31 00:38:18 +00:00
|
|
|
/* FIXME: Even toplevel items should technically have a parent */
|
|
|
|
g_return_if_fail (katze_item_get_parent (item));
|
|
|
|
|
2009-01-28 23:56:07 +00:00
|
|
|
parent = katze_item_get_parent (item);
|
|
|
|
katze_array_remove_item (KATZE_ARRAY (parent), item);
|
2008-10-30 01:19:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_bookmark_popup (GtkWidget* widget,
|
|
|
|
GdkEventButton* event,
|
|
|
|
KatzeItem* item,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkWidget* menu;
|
|
|
|
GtkWidget* menuitem;
|
|
|
|
|
|
|
|
menu = gtk_menu_new ();
|
2009-02-27 20:52:51 +00:00
|
|
|
if (KATZE_IS_ARRAY (item))
|
|
|
|
midori_browser_bookmark_popup_item (menu,
|
|
|
|
STOCK_TAB_NEW, _("Open all in _Tabs"),
|
|
|
|
item, midori_browser_bookmark_open_in_tab_activate_cb, browser);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
midori_browser_bookmark_popup_item (menu, GTK_STOCK_OPEN, NULL,
|
|
|
|
item, midori_browser_bookmark_open_activate_cb, browser);
|
|
|
|
midori_browser_bookmark_popup_item (menu,
|
|
|
|
STOCK_TAB_NEW, _("Open in New _Tab"),
|
|
|
|
item, midori_browser_bookmark_open_in_tab_activate_cb, browser);
|
|
|
|
midori_browser_bookmark_popup_item (menu,
|
|
|
|
STOCK_WINDOW_NEW, _("Open in New _Window"),
|
|
|
|
item, midori_browser_bookmark_open_in_window_activate_cb, browser);
|
|
|
|
}
|
2008-10-30 01:19:52 +00:00
|
|
|
menuitem = gtk_separator_menu_item_new ();
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
2009-02-21 22:59:02 +00:00
|
|
|
midori_browser_bookmark_popup_item (menu, GTK_STOCK_EDIT, NULL,
|
|
|
|
item, midori_browser_bookmark_edit_activate_cb, browser);
|
|
|
|
midori_browser_bookmark_popup_item (menu, GTK_STOCK_DELETE, NULL,
|
|
|
|
item, midori_browser_bookmark_delete_activate_cb, browser);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-10-30 01:19:52 +00:00
|
|
|
sokoke_widget_popup (widget, GTK_MENU (menu),
|
2008-06-19 18:39:00 +00:00
|
|
|
event, SOKOKE_MENU_POSITION_CURSOR);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_menu_bookmarks_item_activate_cb (GtkWidget* widget,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
KatzeItem* item;
|
|
|
|
|
|
|
|
item = (KatzeItem*)g_object_get_data (G_OBJECT (widget), "KatzeItem");
|
2008-10-20 06:50:16 +00:00
|
|
|
midori_browser_set_current_uri (browser, katze_item_get_uri (item));
|
2008-07-13 19:49:57 +00:00
|
|
|
gtk_widget_grab_focus (midori_browser_get_current_tab (browser));
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2009-05-07 20:41:39 +00:00
|
|
|
static gboolean
|
|
|
|
midori_browser_menu_button_press_event_cb (GtkWidget* toolitem,
|
|
|
|
GdkEventButton* event,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
if (event->button == 3)
|
|
|
|
{
|
|
|
|
midori_browser_toolbar_popup_context_menu_cb (
|
|
|
|
GTK_IS_BIN (toolitem) && gtk_bin_get_child (GTK_BIN (toolitem)) ?
|
|
|
|
gtk_widget_get_parent (toolitem) : toolitem,
|
|
|
|
event->x, event->y, event->button, browser);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2009-05-09 11:57:52 +00:00
|
|
|
midori_browser_menu_middle_click_on_navigation_action (MidoriBrowser* browser,
|
|
|
|
GtkAction* action)
|
2009-05-07 20:41:39 +00:00
|
|
|
{
|
2009-05-09 11:57:52 +00:00
|
|
|
const gchar* name;
|
|
|
|
gchar* homepage;
|
2009-05-07 20:41:39 +00:00
|
|
|
|
2009-05-09 11:57:52 +00:00
|
|
|
g_return_val_if_fail (action != NULL, FALSE);
|
2009-05-07 20:41:39 +00:00
|
|
|
|
2009-05-09 11:57:52 +00:00
|
|
|
if (!browser->settings)
|
|
|
|
return FALSE;
|
2009-05-07 20:41:39 +00:00
|
|
|
|
2009-05-09 11:57:52 +00:00
|
|
|
g_object_get (browser->settings, "homepage", &homepage, NULL);
|
2009-05-07 20:41:39 +00:00
|
|
|
|
2009-05-09 11:57:52 +00:00
|
|
|
name = gtk_action_get_name (action);
|
2009-05-07 20:41:39 +00:00
|
|
|
|
2009-05-17 11:38:42 +00:00
|
|
|
/* We use a trick here to implement middle click and prevent the default
|
|
|
|
"activate" callback from being invoked. We set "midori-middle-click"
|
|
|
|
as GObject data and check the value in the "activate" callback. */
|
|
|
|
|
2009-05-09 11:57:52 +00:00
|
|
|
if (g_str_equal (name, "Homepage"))
|
|
|
|
{
|
|
|
|
gint n;
|
2009-05-07 20:41:39 +00:00
|
|
|
|
2009-05-09 11:57:52 +00:00
|
|
|
n = midori_browser_add_uri (browser, homepage);
|
|
|
|
_midori_browser_set_current_page_smartly (browser, n);
|
2009-05-07 20:41:39 +00:00
|
|
|
|
2009-05-17 11:38:42 +00:00
|
|
|
g_object_set_data (G_OBJECT (action), "midori-middle-click", (void*)1);
|
|
|
|
|
2009-05-09 11:57:52 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (g_str_equal (name, "Back"))
|
|
|
|
{
|
|
|
|
GtkWidget* view;
|
|
|
|
WebKitWebBackForwardList* back_forward_list;
|
|
|
|
WebKitWebHistoryItem* back_item;
|
|
|
|
const gchar* back_uri;
|
|
|
|
gint n;
|
2009-05-07 20:41:39 +00:00
|
|
|
|
2009-05-09 11:57:52 +00:00
|
|
|
view = gtk_bin_get_child (GTK_BIN (midori_browser_get_current_tab (browser)));
|
2009-05-07 20:41:39 +00:00
|
|
|
|
2009-05-09 11:57:52 +00:00
|
|
|
back_forward_list =
|
|
|
|
webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (view));
|
2009-05-07 20:41:39 +00:00
|
|
|
|
2009-05-09 11:57:52 +00:00
|
|
|
back_item = webkit_web_back_forward_list_get_back_item (back_forward_list);
|
|
|
|
back_uri = webkit_web_history_item_get_uri (back_item);
|
2009-05-07 20:41:39 +00:00
|
|
|
|
2009-05-09 11:57:52 +00:00
|
|
|
n = midori_browser_add_uri (browser, back_uri);
|
|
|
|
_midori_browser_set_current_page_smartly (browser, n);
|
2009-05-07 20:41:39 +00:00
|
|
|
|
2009-05-17 11:38:42 +00:00
|
|
|
g_object_set_data (G_OBJECT (action), "midori-middle-click", (void*)1);
|
|
|
|
|
2009-05-09 11:57:52 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (g_str_equal (name, "Forward"))
|
|
|
|
{
|
|
|
|
GtkWidget *view;
|
|
|
|
WebKitWebBackForwardList *back_forward_list;
|
|
|
|
WebKitWebHistoryItem *forward_item;
|
|
|
|
const gchar *forward_uri;
|
|
|
|
gint n;
|
2009-05-07 20:41:39 +00:00
|
|
|
|
2009-05-09 11:57:52 +00:00
|
|
|
view = gtk_bin_get_child (GTK_BIN (midori_browser_get_current_tab (browser)));
|
2009-05-07 20:41:39 +00:00
|
|
|
|
2009-05-09 11:57:52 +00:00
|
|
|
back_forward_list =
|
|
|
|
webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (view));
|
2009-05-07 20:41:39 +00:00
|
|
|
|
2009-05-09 11:57:52 +00:00
|
|
|
forward_item =
|
|
|
|
webkit_web_back_forward_list_get_forward_item (back_forward_list);
|
|
|
|
forward_uri = webkit_web_history_item_get_uri (forward_item);
|
2009-05-07 20:41:39 +00:00
|
|
|
|
2009-05-09 11:57:52 +00:00
|
|
|
n = midori_browser_add_uri (browser, forward_uri);
|
|
|
|
_midori_browser_set_current_page_smartly (browser, n);
|
2009-05-07 20:41:39 +00:00
|
|
|
|
2009-05-17 11:38:42 +00:00
|
|
|
g_object_set_data (G_OBJECT (action), "midori-middle-click", (void*)1);
|
|
|
|
|
2009-05-09 11:57:52 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2009-05-07 20:41:39 +00:00
|
|
|
|
2009-05-09 11:57:52 +00:00
|
|
|
g_free (homepage);
|
2009-05-07 20:41:39 +00:00
|
|
|
|
2009-05-09 11:57:52 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2009-05-07 20:41:39 +00:00
|
|
|
|
2009-05-09 11:57:52 +00:00
|
|
|
static gboolean
|
|
|
|
midori_browser_menu_item_middle_click_event_cb (GtkWidget* toolitem,
|
|
|
|
GdkEventButton* event,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
if (event->button == 2)
|
|
|
|
{
|
|
|
|
GtkAction* action = gtk_widget_get_action (toolitem);
|
|
|
|
|
|
|
|
return midori_browser_menu_middle_click_on_navigation_action (browser, action);
|
2009-05-07 20:41:39 +00:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-10-26 17:39:06 +00:00
|
|
|
static gboolean
|
|
|
|
midori_browser_bookmarkbar_item_button_press_event_cb (GtkWidget* toolitem,
|
|
|
|
GdkEventButton* event,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
KatzeItem* item;
|
|
|
|
gint n;
|
|
|
|
|
|
|
|
if (event->button == 2)
|
|
|
|
{
|
|
|
|
item = (KatzeItem*)g_object_get_data (G_OBJECT (toolitem), "KatzeItem");
|
2008-10-26 21:22:26 +00:00
|
|
|
if (katze_item_get_uri (item))
|
|
|
|
{
|
|
|
|
n = midori_browser_add_uri (browser, katze_item_get_uri (item));
|
2009-05-08 11:09:14 +00:00
|
|
|
_midori_browser_set_current_page_smartly (browser, n);
|
|
|
|
|
2008-10-26 21:22:26 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2008-10-26 17:39:06 +00:00
|
|
|
}
|
|
|
|
else if (event->button == 3)
|
|
|
|
{
|
2008-10-30 01:19:52 +00:00
|
|
|
item = (KatzeItem*)g_object_get_data (G_OBJECT (toolitem), "KatzeItem");
|
2009-02-21 22:59:02 +00:00
|
|
|
midori_browser_bookmark_popup (toolitem, NULL, item, browser);
|
2008-10-26 17:39:06 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
2008-06-01 14:40:44 +00:00
|
|
|
_action_bookmark_add_activate (GtkAction* action,
|
2008-03-10 21:26:09 +00:00
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-02-22 02:11:40 +00:00
|
|
|
midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, FALSE);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2009-04-10 20:28:36 +00:00
|
|
|
static void
|
|
|
|
_action_bookmark_folder_add_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, TRUE);
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
_action_manage_search_engines_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-02-28 13:05:01 +00:00
|
|
|
static GtkWidget* dialog = NULL;
|
2008-06-15 02:02:56 +00:00
|
|
|
|
2009-02-28 13:05:01 +00:00
|
|
|
if (!GTK_WIDGET_VISIBLE (browser))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!dialog)
|
|
|
|
{
|
|
|
|
dialog = midori_search_action_get_dialog (
|
|
|
|
MIDORI_SEARCH_ACTION (_action_by_name (browser, "Search")));
|
|
|
|
g_signal_connect (dialog, "destroy",
|
|
|
|
G_CALLBACK (gtk_widget_destroyed), &dialog);
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_widget_show (dialog);
|
2009-02-28 13:05:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2009-04-11 03:14:53 +00:00
|
|
|
static void
|
|
|
|
midori_browser_clear_private_data_response_cb (GtkWidget* dialog,
|
|
|
|
gint response_id,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
if (response_id == GTK_RESPONSE_ACCEPT)
|
|
|
|
{
|
|
|
|
GtkToggleButton* button;
|
2009-05-22 21:53:54 +00:00
|
|
|
gint clear_prefs = MIDORI_CLEAR_NONE;
|
|
|
|
gint saved_prefs = MIDORI_CLEAR_NONE;
|
|
|
|
|
|
|
|
g_object_get (browser->settings, "clear-private-data", &saved_prefs, NULL);
|
2009-04-11 03:14:53 +00:00
|
|
|
|
|
|
|
button = g_object_get_data (G_OBJECT (dialog), "history");
|
|
|
|
if (gtk_toggle_button_get_active (button))
|
2009-05-22 21:53:54 +00:00
|
|
|
{
|
2009-04-11 03:14:53 +00:00
|
|
|
katze_array_clear (browser->history);
|
2009-05-22 21:53:54 +00:00
|
|
|
clear_prefs |= MIDORI_CLEAR_HISTORY;
|
|
|
|
}
|
2009-04-11 03:14:53 +00:00
|
|
|
button = g_object_get_data (G_OBJECT (dialog), "cookies");
|
|
|
|
if (gtk_toggle_button_get_active (button))
|
|
|
|
{
|
|
|
|
SoupSession* session = katze_net_get_session (browser->net);
|
|
|
|
SoupSessionFeature* jar = soup_session_get_feature (session,
|
|
|
|
SOUP_TYPE_COOKIE_JAR);
|
|
|
|
GSList* cookies = soup_cookie_jar_all_cookies (SOUP_COOKIE_JAR (jar));
|
|
|
|
SoupCookie* cookie;
|
|
|
|
gsize i = 0;
|
|
|
|
while ((cookie = g_slist_nth_data (cookies, i++)))
|
|
|
|
{
|
|
|
|
soup_cookie_jar_delete_cookie (SOUP_COOKIE_JAR (jar), cookie);
|
|
|
|
soup_cookie_free (cookie);
|
|
|
|
}
|
|
|
|
g_slist_free (cookies);
|
2009-05-22 21:53:54 +00:00
|
|
|
clear_prefs |= MIDORI_CLEAR_COOKIES;
|
2009-04-11 03:14:53 +00:00
|
|
|
}
|
|
|
|
button = g_object_get_data (G_OBJECT (dialog), "flash-cookies");
|
|
|
|
if (gtk_toggle_button_get_active (button))
|
|
|
|
{
|
|
|
|
gchar* cache = g_build_filename (g_get_home_dir (), ".macromedia",
|
|
|
|
"Flash_Player", NULL);
|
|
|
|
sokoke_remove_path (cache, TRUE);
|
|
|
|
g_free (cache);
|
2009-05-22 21:53:54 +00:00
|
|
|
clear_prefs |= MIDORI_CLEAR_FLASH_COOKIES;
|
2009-04-11 03:14:53 +00:00
|
|
|
}
|
|
|
|
button = g_object_get_data (G_OBJECT (dialog), "website-icons");
|
|
|
|
if (gtk_toggle_button_get_active (button))
|
|
|
|
{
|
|
|
|
gchar* cache = g_build_filename (g_get_user_cache_dir (),
|
|
|
|
PACKAGE_NAME, "icons", NULL);
|
|
|
|
sokoke_remove_path (cache, TRUE);
|
|
|
|
g_free (cache);
|
2009-05-22 21:53:54 +00:00
|
|
|
clear_prefs |= MIDORI_CLEAR_WEBSITE_ICONS;
|
2009-04-11 03:14:53 +00:00
|
|
|
}
|
2009-05-22 00:16:58 +00:00
|
|
|
button = g_object_get_data (G_OBJECT (dialog), "trash");
|
|
|
|
if (gtk_toggle_button_get_active (button))
|
|
|
|
{
|
|
|
|
if (browser->trash)
|
|
|
|
{
|
|
|
|
katze_array_clear (browser->trash);
|
|
|
|
_midori_browser_update_actions (browser);
|
|
|
|
}
|
2009-05-22 21:53:54 +00:00
|
|
|
clear_prefs |= MIDORI_CLEAR_TRASH;
|
2009-05-22 00:16:58 +00:00
|
|
|
}
|
2009-05-22 21:53:54 +00:00
|
|
|
|
|
|
|
if (clear_prefs != saved_prefs)
|
|
|
|
g_object_set (browser->settings, "clear-private-data", clear_prefs, NULL);
|
2009-04-11 03:14:53 +00:00
|
|
|
}
|
|
|
|
if (response_id != GTK_RESPONSE_DELETE_EVENT)
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
}
|
|
|
|
|
2009-07-28 21:12:35 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2009-04-11 03:14:53 +00:00
|
|
|
static void
|
|
|
|
_action_clear_private_data_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
static GtkWidget* dialog = NULL;
|
|
|
|
|
|
|
|
if (!GTK_WIDGET_VISIBLE (browser))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!dialog)
|
|
|
|
{
|
|
|
|
GdkScreen* screen;
|
|
|
|
GtkIconTheme* icon_theme;
|
|
|
|
GtkSizeGroup* sizegroup;
|
|
|
|
GtkWidget* hbox;
|
2009-05-25 16:41:54 +00:00
|
|
|
GtkWidget* alignment;
|
2009-04-11 03:14:53 +00:00
|
|
|
GtkWidget* vbox;
|
|
|
|
GtkWidget* icon;
|
|
|
|
GtkWidget* label;
|
|
|
|
GtkWidget* button;
|
|
|
|
|
2009-05-22 21:53:54 +00:00
|
|
|
gint clear_prefs = MIDORI_CLEAR_NONE;
|
|
|
|
g_object_get (browser->settings, "clear-private-data", &clear_prefs, NULL);
|
|
|
|
|
2009-04-11 03:14:53 +00:00
|
|
|
dialog = gtk_dialog_new_with_buttons (_("Clear Private Data"),
|
2009-05-25 16:41:54 +00:00
|
|
|
GTK_WINDOW (browser),
|
|
|
|
GTK_DIALOG_NO_SEPARATOR | GTK_DIALOG_DESTROY_WITH_PARENT,
|
2009-04-11 03:14:53 +00:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
2009-04-13 21:35:31 +00:00
|
|
|
_("_Clear private data"), GTK_RESPONSE_ACCEPT, NULL);
|
2009-04-11 03:14:53 +00:00
|
|
|
gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog), FALSE);
|
|
|
|
screen = gtk_widget_get_screen (GTK_WIDGET (browser));
|
|
|
|
if (screen)
|
|
|
|
{
|
|
|
|
icon_theme = gtk_icon_theme_get_for_screen (screen);
|
|
|
|
gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_CLEAR);
|
|
|
|
}
|
|
|
|
sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
|
|
|
icon = gtk_image_new_from_stock (GTK_STOCK_CLEAR, GTK_ICON_SIZE_DIALOG);
|
|
|
|
gtk_size_group_add_widget (sizegroup, icon);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
|
|
|
|
label = gtk_label_new (_("Clear the following data:"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
|
2009-05-25 16:41:54 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0);
|
2009-04-11 03:14:53 +00:00
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
|
|
|
icon = gtk_image_new ();
|
|
|
|
gtk_size_group_add_widget (sizegroup, icon);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
|
|
|
|
vbox = gtk_vbox_new (TRUE, 4);
|
2009-05-25 16:41:54 +00:00
|
|
|
alignment = gtk_alignment_new (0, 0, 1, 1);
|
|
|
|
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 6, 12, 0);
|
2009-04-11 03:14:53 +00:00
|
|
|
button = gtk_check_button_new_with_mnemonic (_("History"));
|
2009-05-22 21:53:54 +00:00
|
|
|
if ((clear_prefs & MIDORI_CLEAR_HISTORY) == MIDORI_CLEAR_HISTORY)
|
2009-05-25 16:41:54 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
2009-04-11 03:14:53 +00:00
|
|
|
g_object_set_data (G_OBJECT (dialog), "history", button);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
|
|
|
|
button = gtk_check_button_new_with_mnemonic (_("Cookies"));
|
2009-05-22 21:53:54 +00:00
|
|
|
if ((clear_prefs & MIDORI_CLEAR_COOKIES) == MIDORI_CLEAR_COOKIES)
|
2009-05-25 16:41:54 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
2009-04-11 03:14:53 +00:00
|
|
|
g_object_set_data (G_OBJECT (dialog), "cookies", button);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
|
|
|
|
button = gtk_check_button_new_with_mnemonic (_("'Flash' Cookies"));
|
2009-05-22 21:53:54 +00:00
|
|
|
if ((clear_prefs & MIDORI_CLEAR_FLASH_COOKIES) == MIDORI_CLEAR_FLASH_COOKIES)
|
2009-05-25 16:41:54 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
2009-04-11 03:14:53 +00:00
|
|
|
g_object_set_data (G_OBJECT (dialog), "flash-cookies", button);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
|
|
|
|
button = gtk_check_button_new_with_mnemonic (_("Website icons"));
|
2009-05-22 21:53:54 +00:00
|
|
|
if ((clear_prefs & MIDORI_CLEAR_WEBSITE_ICONS) == MIDORI_CLEAR_WEBSITE_ICONS)
|
2009-05-25 16:41:54 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
2009-04-11 03:14:53 +00:00
|
|
|
g_object_set_data (G_OBJECT (dialog), "website-icons", button);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
|
2009-07-22 22:06:55 +00:00
|
|
|
button = gtk_check_button_new_with_mnemonic (_("_Closed Tabs"));
|
2009-05-22 21:53:54 +00:00
|
|
|
if ((clear_prefs & MIDORI_CLEAR_TRASH) == MIDORI_CLEAR_TRASH)
|
2009-05-25 16:41:54 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
2009-05-22 00:16:58 +00:00
|
|
|
g_object_set_data (G_OBJECT (dialog), "trash", button);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
|
2009-05-25 16:41:54 +00:00
|
|
|
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);
|
2009-07-28 21:12:35 +00:00
|
|
|
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);
|
2009-04-11 03:14:53 +00:00
|
|
|
gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);
|
|
|
|
|
|
|
|
g_signal_connect (dialog, "response",
|
|
|
|
G_CALLBACK (midori_browser_clear_private_data_response_cb), browser);
|
|
|
|
g_signal_connect (dialog, "destroy",
|
|
|
|
G_CALLBACK (gtk_widget_destroyed), &dialog);
|
|
|
|
gtk_widget_show (dialog);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
_action_tab_previous_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-06-19 18:39:00 +00:00
|
|
|
gint n = gtk_notebook_get_current_page (GTK_NOTEBOOK (browser->notebook));
|
|
|
|
gtk_notebook_set_current_page (GTK_NOTEBOOK (browser->notebook), n - 1);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_tab_next_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Advance one tab or jump to the first one if we are at the last one */
|
2008-06-19 18:39:00 +00:00
|
|
|
gint n = gtk_notebook_get_current_page (GTK_NOTEBOOK (browser->notebook));
|
|
|
|
if (n == gtk_notebook_get_n_pages (GTK_NOTEBOOK (browser->notebook)) - 1)
|
2008-03-10 21:26:09 +00:00
|
|
|
n = -1;
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_notebook_set_current_page (GTK_NOTEBOOK (browser->notebook), n + 1);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const gchar* credits_authors[] = {
|
|
|
|
"Christian Dywan <christian@twotoasts.de>", NULL };
|
2008-10-03 20:23:00 +00:00
|
|
|
static const gchar* credits_documenters[] = {
|
2008-10-25 22:54:57 +00:00
|
|
|
"Christian Dywan <christian@twotoasts.de>", NULL };
|
2008-03-10 21:26:09 +00:00
|
|
|
static const gchar* credits_artists[] = {
|
|
|
|
"Nancy Runge <nancy@twotoasts.de>", NULL };
|
|
|
|
|
|
|
|
static const gchar* license =
|
|
|
|
"This library is free software; you can redistribute it and/or\n"
|
|
|
|
"modify it under the terms of the GNU Lesser General Public\n"
|
|
|
|
"License as published by the Free Software Foundation; either\n"
|
|
|
|
"version 2.1 of the License, or (at your option) any later version.\n";
|
|
|
|
|
2008-10-03 20:23:00 +00:00
|
|
|
static void
|
|
|
|
_action_about_activate_link (GtkAboutDialog* about,
|
2009-01-09 21:54:40 +00:00
|
|
|
const gchar* uri,
|
2008-10-03 20:23:00 +00:00
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
MidoriBrowser* browser;
|
|
|
|
gint n;
|
|
|
|
|
|
|
|
browser = MIDORI_BROWSER (user_data);
|
2009-01-09 21:54:40 +00:00
|
|
|
n = midori_browser_add_uri (browser, uri);
|
2008-10-03 20:23:00 +00:00
|
|
|
midori_browser_set_current_page (browser, n);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_about_activate_email (GtkAboutDialog* about,
|
2009-01-09 21:54:40 +00:00
|
|
|
const gchar* uri,
|
2008-10-03 20:23:00 +00:00
|
|
|
gpointer user_data)
|
|
|
|
{
|
2009-09-08 21:58:58 +00:00
|
|
|
/* Some email clients need the 'mailto' to function properly */
|
|
|
|
gchar* newuri = NULL;
|
|
|
|
if (!g_str_has_prefix (uri, "mailto:"))
|
|
|
|
newuri = g_strconcat ("mailto:", uri, NULL);
|
|
|
|
|
|
|
|
sokoke_show_uri (NULL, newuri ? newuri : uri, GDK_CURRENT_TIME, NULL);
|
|
|
|
g_free (newuri);
|
2008-10-03 20:23:00 +00:00
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
_action_about_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-08-17 17:22:33 +00:00
|
|
|
gchar* comments = g_strdup_printf ("GTK+ %d.%d.%d, WebKitGTK+ %d.%d.%d\n%s",
|
|
|
|
GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION,
|
|
|
|
WEBKIT_MAJOR_VERSION, WEBKIT_MINOR_VERSION, WEBKIT_MICRO_VERSION,
|
|
|
|
_("A lightweight web browser."));
|
|
|
|
|
2008-10-03 20:23:00 +00:00
|
|
|
gtk_about_dialog_set_email_hook (_action_about_activate_email, NULL, NULL);
|
|
|
|
gtk_about_dialog_set_url_hook (_action_about_activate_link, browser, NULL);
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_show_about_dialog (GTK_WINDOW (browser),
|
|
|
|
"logo-icon-name", gtk_window_get_icon_name (GTK_WINDOW (browser)),
|
|
|
|
"name", PACKAGE_NAME,
|
|
|
|
"version", PACKAGE_VERSION,
|
2009-08-17 17:22:33 +00:00
|
|
|
"comments", comments,
|
2009-03-01 20:00:06 +00:00
|
|
|
"copyright", "Copyright © 2007-2009 Christian Dywan",
|
2008-08-02 02:25:05 +00:00
|
|
|
"website", "http://www.twotoasts.de",
|
2008-03-10 21:26:09 +00:00
|
|
|
"authors", credits_authors,
|
|
|
|
"documenters", credits_documenters,
|
|
|
|
"artists", credits_artists,
|
|
|
|
"license", license,
|
|
|
|
"wrap-license", TRUE,
|
2008-03-22 02:38:23 +00:00
|
|
|
"translator-credits", _("translator-credits"),
|
2008-03-10 21:26:09 +00:00
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2008-09-07 20:41:03 +00:00
|
|
|
static void
|
2008-10-03 20:23:00 +00:00
|
|
|
_action_help_link_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
2008-09-07 20:41:03 +00:00
|
|
|
{
|
2008-10-03 20:23:00 +00:00
|
|
|
const gchar* action_name;
|
|
|
|
const gchar* uri;
|
2008-09-07 20:41:03 +00:00
|
|
|
gint n;
|
|
|
|
|
2008-10-03 20:23:00 +00:00
|
|
|
action_name = gtk_action_get_name (action);
|
|
|
|
if (!strncmp ("HelpContents", action_name, 12))
|
|
|
|
{
|
|
|
|
#ifdef DOCDIR
|
2009-02-21 23:04:28 +00:00
|
|
|
uri = "file://" DOCDIR "/midori/user/midori.html";
|
|
|
|
if (!g_file_test (DOCDIR "/midori/user/midori.html", G_FILE_TEST_EXISTS))
|
2008-10-03 20:23:00 +00:00
|
|
|
#endif
|
2009-02-21 23:04:28 +00:00
|
|
|
uri = "error:nodocs " DOCDIR "/midori/user/midori.html";
|
2008-10-03 20:23:00 +00:00
|
|
|
}
|
|
|
|
else if (!strncmp ("HelpFAQ", action_name, 7))
|
|
|
|
uri = "http://wiki.xfce.org/_export/xhtml/midori_faq";
|
|
|
|
else if (!strncmp ("HelpBugs", action_name, 8))
|
|
|
|
uri = "http://www.twotoasts.de/bugs/";
|
|
|
|
else
|
|
|
|
uri = NULL;
|
|
|
|
|
|
|
|
if (uri)
|
|
|
|
{
|
|
|
|
n = midori_browser_add_uri (browser, uri);
|
|
|
|
midori_browser_set_current_page (browser, n);
|
|
|
|
}
|
|
|
|
|
2008-09-07 20:41:03 +00:00
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
_action_panel_activate (GtkToggleAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-04-16 23:38:22 +00:00
|
|
|
gboolean active = gtk_toggle_action_get_active (action);
|
2009-02-28 13:05:01 +00:00
|
|
|
if (browser->settings)
|
|
|
|
g_object_set (browser->settings, "show-panel", active, NULL);
|
2008-06-19 18:39:00 +00:00
|
|
|
sokoke_widget_set_visible (browser->panel, active);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2009-01-25 23:54:12 +00:00
|
|
|
static gboolean
|
|
|
|
midori_browser_panel_timeout (GtkWidget* hpaned)
|
|
|
|
{
|
|
|
|
gboolean position = gtk_paned_get_position (GTK_PANED (hpaned));
|
2009-04-23 02:10:38 +00:00
|
|
|
MidoriBrowser* browser = midori_browser_get_for_widget (hpaned);
|
2009-02-28 13:05:01 +00:00
|
|
|
if (browser->settings)
|
|
|
|
g_object_set (browser->settings, "last-panel-position", position, NULL);
|
2009-01-25 23:54:12 +00:00
|
|
|
browser->panel_timeout = 0;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
2009-01-25 23:54:12 +00:00
|
|
|
midori_panel_notify_position_cb (GObject* hpaned,
|
|
|
|
GParamSpec* pspec,
|
2008-03-10 21:26:09 +00:00
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-01-25 23:54:12 +00:00
|
|
|
if (!browser->panel_timeout)
|
|
|
|
browser->panel_timeout = g_timeout_add_full (G_PRIORITY_LOW, 5000,
|
|
|
|
(GSourceFunc)midori_browser_panel_timeout, hpaned, NULL);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2009-06-22 22:25:09 +00:00
|
|
|
static void
|
|
|
|
midori_panel_notify_page_cb (MidoriPanel* panel,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
gint page = katze_object_get_boolean (panel, "page");
|
|
|
|
if (browser->settings && page > -1)
|
|
|
|
g_object_set (browser->settings, "last-panel-page", page, NULL);
|
|
|
|
}
|
|
|
|
|
2009-07-26 20:00:10 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-22 18:23:45 +00:00
|
|
|
static void
|
|
|
|
midori_panel_notify_right_aligned_cb (MidoriPanel* panel,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
gboolean right_aligned = katze_object_get_boolean (panel, "right-aligned");
|
|
|
|
GtkWidget* hpaned = gtk_widget_get_parent (browser->panel);
|
|
|
|
GtkWidget* vpaned = gtk_widget_get_parent (browser->notebook);
|
2009-05-30 22:22:23 +00:00
|
|
|
gint paned_position = gtk_paned_get_position (GTK_PANED (hpaned));
|
|
|
|
gint paned_size = hpaned->allocation.width;
|
2009-02-22 18:23:45 +00:00
|
|
|
|
2009-02-28 13:05:01 +00:00
|
|
|
if (browser->settings)
|
|
|
|
g_object_set (browser->settings, "right-align-sidepanel",
|
|
|
|
right_aligned, NULL);
|
2009-02-22 18:23:45 +00:00
|
|
|
|
|
|
|
g_object_ref (browser->panel);
|
|
|
|
g_object_ref (vpaned);
|
|
|
|
gtk_container_remove (GTK_CONTAINER (hpaned), browser->panel);
|
|
|
|
gtk_container_remove (GTK_CONTAINER (hpaned), vpaned);
|
|
|
|
if (right_aligned)
|
|
|
|
{
|
|
|
|
gtk_paned_pack1 (GTK_PANED (hpaned), vpaned, FALSE, FALSE);
|
|
|
|
gtk_paned_pack2 (GTK_PANED (hpaned), browser->panel, FALSE, FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_paned_pack1 (GTK_PANED (hpaned), browser->panel, FALSE, FALSE);
|
|
|
|
gtk_paned_pack2 (GTK_PANED (hpaned), vpaned, FALSE, FALSE);
|
|
|
|
}
|
2009-05-30 22:22:23 +00:00
|
|
|
gtk_paned_set_position (GTK_PANED (hpaned), paned_size - paned_position);
|
2009-02-22 18:23:45 +00:00
|
|
|
g_object_unref (browser->panel);
|
|
|
|
g_object_unref (vpaned);
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static gboolean
|
|
|
|
midori_panel_close_cb (MidoriPanel* panel,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-04-06 23:15:09 +00:00
|
|
|
_action_set_active (browser, "Panel", FALSE);
|
2008-03-10 21:26:09 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-07-13 19:49:57 +00:00
|
|
|
gtk_notebook_switch_page_cb (GtkWidget* notebook,
|
2008-03-10 21:26:09 +00:00
|
|
|
GtkNotebookPage* page,
|
|
|
|
guint page_num,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view;
|
2008-07-13 19:49:57 +00:00
|
|
|
const gchar* uri;
|
2008-08-14 23:57:48 +00:00
|
|
|
GtkAction* action;
|
2008-07-13 19:49:57 +00:00
|
|
|
const gchar* title;
|
|
|
|
gchar* window_title;
|
|
|
|
|
2009-04-01 21:53:45 +00:00
|
|
|
if (!(view = midori_browser_get_current_tab (browser)))
|
|
|
|
return;
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
uri = midori_view_get_display_uri (MIDORI_VIEW (view));
|
2008-08-14 23:57:48 +00:00
|
|
|
action = _action_by_name (browser, "Location");
|
|
|
|
midori_location_action_set_uri (MIDORI_LOCATION_ACTION (action), uri);
|
2008-11-10 23:51:28 +00:00
|
|
|
midori_location_action_set_icon (MIDORI_LOCATION_ACTION (action),
|
|
|
|
midori_view_get_icon (MIDORI_VIEW (view)));
|
2008-07-17 19:02:14 +00:00
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
title = midori_view_get_display_title (MIDORI_VIEW (view));
|
2008-11-12 01:15:52 +00:00
|
|
|
window_title = g_strconcat (title, " - ", g_get_application_name (), NULL);
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_window_set_title (GTK_WINDOW (browser), window_title);
|
|
|
|
g_free (window_title);
|
2008-07-23 18:17:13 +00:00
|
|
|
|
2009-07-18 13:30:03 +00:00
|
|
|
if (browser->proxy_array)
|
|
|
|
katze_item_set_meta_integer (KATZE_ITEM (browser->proxy_array), "current",
|
|
|
|
midori_browser_get_current_page (browser));
|
2008-07-23 18:17:13 +00:00
|
|
|
g_object_notify (G_OBJECT (browser), "uri");
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
_midori_browser_set_statusbar_text (browser, NULL);
|
|
|
|
_midori_browser_update_interface (browser);
|
2008-09-26 21:13:46 +00:00
|
|
|
_midori_browser_update_progress (browser, MIDORI_VIEW (view));
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2009-03-24 22:54:37 +00:00
|
|
|
static void
|
|
|
|
midori_browser_notebook_page_reordered_cb (GtkNotebook* notebook,
|
|
|
|
MidoriView* view,
|
|
|
|
guint page_num,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
KatzeItem* item = midori_view_get_proxy_item (view);
|
|
|
|
katze_array_move_item (browser->proxy_array, item, page_num);
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (browser), "uri");
|
|
|
|
}
|
|
|
|
|
2009-01-13 19:50:17 +00:00
|
|
|
static gboolean
|
2009-06-25 21:49:41 +00:00
|
|
|
midori_browser_notebook_button_press_event_after_cb (GtkNotebook* notebook,
|
|
|
|
GdkEventButton* event,
|
|
|
|
MidoriBrowser* browser)
|
2009-01-13 19:50:17 +00:00
|
|
|
{
|
2009-06-25 21:49:41 +00:00
|
|
|
if (event->window != notebook->event_window)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* FIXME: Handle double click only when it wasn't handled by GtkNotebook */
|
|
|
|
|
2009-01-13 19:50:17 +00:00
|
|
|
/* Open a new tab on double click or middle mouse click */
|
2009-06-25 21:49:41 +00:00
|
|
|
if (/*(event->type == GDK_2BUTTON_PRESS && event->button == 1)
|
|
|
|
|| */(event->type == GDK_BUTTON_PRESS && event->button == 2))
|
2009-01-13 19:50:17 +00:00
|
|
|
{
|
2009-05-17 14:49:46 +00:00
|
|
|
gint n;
|
|
|
|
GtkWidget* view;
|
|
|
|
|
|
|
|
if (browser->settings)
|
|
|
|
view = g_object_new (MIDORI_TYPE_VIEW,
|
|
|
|
"settings", browser->settings,
|
|
|
|
"net", browser->net, NULL);
|
|
|
|
else
|
|
|
|
view = midori_view_new (browser->net);
|
|
|
|
midori_view_set_uri (MIDORI_VIEW (view), "");
|
|
|
|
gtk_widget_show (view);
|
|
|
|
g_object_set_data (G_OBJECT (view), "midori-view-append", (void*)1);
|
|
|
|
n = midori_browser_add_tab (browser, view);
|
|
|
|
midori_browser_set_current_page (browser, n);
|
2009-01-13 19:50:17 +00:00
|
|
|
|
2009-05-17 14:49:46 +00:00
|
|
|
return TRUE;
|
2009-01-13 19:50:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
2008-03-10 21:48:12 +00:00
|
|
|
_action_undo_tab_close_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-08-24 01:05:00 +00:00
|
|
|
guint last;
|
2008-09-26 21:13:46 +00:00
|
|
|
KatzeItem* item;
|
2008-08-24 01:05:00 +00:00
|
|
|
guint n;
|
|
|
|
|
2009-02-28 13:05:01 +00:00
|
|
|
if (!browser->trash)
|
|
|
|
return;
|
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Reopen the most recent trash item */
|
2008-08-25 23:19:38 +00:00
|
|
|
last = katze_array_get_length (browser->trash) - 1;
|
|
|
|
item = katze_array_get_nth_item (browser->trash, last);
|
2008-09-26 21:13:46 +00:00
|
|
|
n = midori_browser_add_item (browser, item);
|
2008-04-24 22:20:43 +00:00
|
|
|
midori_browser_set_current_page (browser, n);
|
2008-08-25 23:19:38 +00:00
|
|
|
katze_array_remove_item (browser->trash, item);
|
2008-03-10 21:26:09 +00:00
|
|
|
_midori_browser_update_actions (browser);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_trash_empty_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-02-28 13:05:01 +00:00
|
|
|
if (browser->trash)
|
|
|
|
{
|
|
|
|
katze_array_clear (browser->trash);
|
|
|
|
_midori_browser_update_actions (browser);
|
|
|
|
}
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const GtkActionEntry entries[] = {
|
2008-03-22 02:38:23 +00:00
|
|
|
{ "File", NULL, N_("_File") },
|
2009-07-25 20:53:09 +00:00
|
|
|
{ "WindowNew", STOCK_WINDOW_NEW,
|
2009-07-24 14:43:55 +00:00
|
|
|
N_("New _Window"), "<Ctrl>n",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Open a new window"), G_CALLBACK (_action_window_new_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "TabNew", STOCK_TAB_NEW,
|
|
|
|
NULL, "<Ctrl>t",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Open a new tab"), G_CALLBACK (_action_tab_new_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Open", GTK_STOCK_OPEN,
|
|
|
|
NULL, "<Ctrl>o",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Open a file"), G_CALLBACK (_action_open_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "SaveAs", GTK_STOCK_SAVE_AS,
|
|
|
|
NULL, "<Ctrl>s",
|
2008-10-26 16:07:59 +00:00
|
|
|
N_("Save to a file"), G_CALLBACK (_action_save_as_activate) },
|
2009-05-10 12:39:20 +00:00
|
|
|
{ "AddSpeedDial", NULL,
|
2009-05-10 14:07:28 +00:00
|
|
|
N_("Add to Speed _dial"), "<Ctrl>h",
|
|
|
|
N_("Add shortcut to speed dial"), G_CALLBACK (_action_add_speed_dial_activate) },
|
2009-07-24 14:43:55 +00:00
|
|
|
{ "TabClose", GTK_STOCK_CLOSE,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("_Close Tab"), "<Ctrl>w",
|
|
|
|
N_("Close the current tab"), G_CALLBACK (_action_tab_close_activate) },
|
|
|
|
{ "WindowClose", NULL,
|
|
|
|
N_("C_lose Window"), "<Ctrl><Shift>w",
|
|
|
|
N_("Close this window"), G_CALLBACK (_action_window_close_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Print", GTK_STOCK_PRINT,
|
|
|
|
NULL, "<Ctrl>p",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Print the current page"), G_CALLBACK (_action_print_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Quit", GTK_STOCK_QUIT,
|
|
|
|
NULL, "<Ctrl>q",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Quit the application"), G_CALLBACK (_action_quit_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-03-22 02:38:23 +00:00
|
|
|
{ "Edit", NULL, N_("_Edit"), NULL, NULL, G_CALLBACK (_action_edit_activate) },
|
2009-09-10 00:17:18 +00:00
|
|
|
#if WEBKIT_CHECK_VERSION (1, 1, 14)
|
|
|
|
{ "Undo", GTK_STOCK_UNDO,
|
|
|
|
NULL, "<Ctrl>z",
|
|
|
|
N_("Undo the last modification"), G_CALLBACK (_action_undo_activate) },
|
|
|
|
{ "Redo", GTK_STOCK_REDO,
|
|
|
|
NULL, "<Ctrl><Shift>z",
|
|
|
|
N_("Redo the last modification"), G_CALLBACK (_action_redo_activate) },
|
|
|
|
#endif
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Cut", GTK_STOCK_CUT,
|
|
|
|
NULL, "<Ctrl>x",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Cut the selected text"), G_CALLBACK (_action_cut_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Copy", GTK_STOCK_COPY,
|
|
|
|
NULL, "<Ctrl>c",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Copy the selected text"), G_CALLBACK (_action_copy_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Copy_", GTK_STOCK_COPY,
|
|
|
|
NULL, "<Ctrl>c",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Copy the selected text"), G_CALLBACK (_action_copy_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Paste", GTK_STOCK_PASTE,
|
|
|
|
NULL, "<Ctrl>v",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Paste text from the clipboard"), G_CALLBACK (_action_paste_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Delete", GTK_STOCK_DELETE,
|
|
|
|
NULL, NULL,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Delete the selected text"), G_CALLBACK (_action_delete_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "SelectAll", GTK_STOCK_SELECT_ALL,
|
|
|
|
NULL, "<Ctrl>a",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Select all text"), G_CALLBACK (_action_select_all_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Find", GTK_STOCK_FIND,
|
|
|
|
NULL, "<Ctrl>f",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Find a word or phrase in the page"), G_CALLBACK (_action_find_activate) },
|
2009-07-24 14:43:55 +00:00
|
|
|
{ "FindNext", NULL,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Find _Next"), "<Ctrl>g",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Find the next occurrence of a word or phrase"), G_CALLBACK (_action_find_next_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "FindPrevious", GTK_STOCK_GO_BACK,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Find _Previous"), "<Ctrl><Shift>g",
|
2008-11-01 18:15:58 +00:00
|
|
|
N_("Find the previous occurrence of a word or phrase"),
|
|
|
|
G_CALLBACK (_action_find_previous_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Preferences", GTK_STOCK_PREFERENCES,
|
|
|
|
NULL, "<Ctrl><Alt>p",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Configure the application preferences"), G_CALLBACK (_action_preferences_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-03-22 02:38:23 +00:00
|
|
|
{ "View", NULL, N_("_View") },
|
|
|
|
{ "Toolbars", NULL, N_("_Toolbars") },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Reload", GTK_STOCK_REFRESH,
|
|
|
|
NULL, "<Ctrl>r",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Reload the current page"), G_CALLBACK (_action_reload_stop_activate) },
|
2008-04-03 21:33:32 +00:00
|
|
|
{ "Stop", GTK_STOCK_STOP,
|
|
|
|
NULL, "Escape",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Stop loading the current page"), G_CALLBACK (_action_reload_stop_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "ReloadStop", GTK_STOCK_STOP,
|
|
|
|
NULL, "<Ctrl>r",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Reload the current page"), G_CALLBACK (_action_reload_stop_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "ZoomIn", GTK_STOCK_ZOOM_IN,
|
|
|
|
NULL, "<Ctrl>plus",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Increase the zoom level"), G_CALLBACK (_action_zoom_in_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "ZoomOut", GTK_STOCK_ZOOM_OUT,
|
|
|
|
NULL, "<Ctrl>minus",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Decrease the zoom level"), G_CALLBACK (_action_zoom_out_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "ZoomNormal", GTK_STOCK_ZOOM_100,
|
|
|
|
NULL, "<Ctrl>0",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Reset the zoom level"), G_CALLBACK (_action_zoom_normal_activate) },
|
2009-02-27 22:09:36 +00:00
|
|
|
{ "Encoding", NULL, N_("_Encoding") },
|
2008-03-19 13:46:08 +00:00
|
|
|
{ "SourceView", NULL,
|
2009-06-11 21:57:42 +00:00
|
|
|
N_("View So_urce"), "<Ctrl>U",
|
2008-07-13 19:49:57 +00:00
|
|
|
N_("View the source code of the page"), G_CALLBACK (_action_source_view_activate) },
|
2008-03-19 13:46:08 +00:00
|
|
|
{ "SelectionSourceView", NULL,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("View Selection Source"), "",
|
2008-11-01 18:15:58 +00:00
|
|
|
N_("View the source code of the selection"),
|
|
|
|
NULL/*G_CALLBACK (_action_selection_source_view_activate)*/ },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Fullscreen", GTK_STOCK_FULLSCREEN,
|
|
|
|
NULL, "F11",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Toggle fullscreen view"), G_CALLBACK (_action_fullscreen_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-03-22 02:38:23 +00:00
|
|
|
{ "Go", NULL, N_("_Go") },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Back", GTK_STOCK_GO_BACK,
|
|
|
|
NULL, "<Alt>Left",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Go back to the previous page"), G_CALLBACK (_action_back_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Forward", GTK_STOCK_GO_FORWARD,
|
|
|
|
NULL, "<Alt>Right",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Go forward to the next page"), G_CALLBACK (_action_forward_activate) },
|
2008-05-20 01:21:11 +00:00
|
|
|
{ "Homepage", STOCK_HOMEPAGE,
|
2008-03-10 21:26:09 +00:00
|
|
|
NULL, "<Alt>Home",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Go to your homepage"), G_CALLBACK (_action_homepage_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "TrashEmpty", GTK_STOCK_CLEAR,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Empty Trash"), "",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Delete the contents of the trash"), G_CALLBACK (_action_trash_empty_activate) },
|
2008-03-10 21:48:12 +00:00
|
|
|
{ "UndoTabClose", GTK_STOCK_UNDELETE,
|
2009-06-11 21:57:42 +00:00
|
|
|
N_("Undo _Close Tab"), "<Ctrl><Shift>t",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Open the last closed tab"), G_CALLBACK (_action_undo_tab_close_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-06-01 14:40:44 +00:00
|
|
|
{ "BookmarkAdd", STOCK_BOOKMARK_ADD,
|
2008-03-10 21:26:09 +00:00
|
|
|
NULL, "<Ctrl>d",
|
2008-06-01 14:40:44 +00:00
|
|
|
N_("Add a new bookmark"), G_CALLBACK (_action_bookmark_add_activate) },
|
2009-07-24 14:43:55 +00:00
|
|
|
{ "BookmarkFolderAdd", NULL,
|
2009-06-11 21:57:42 +00:00
|
|
|
N_("Add a new _folder"), "",
|
2009-04-10 20:28:36 +00:00
|
|
|
N_("Add a new bookmark folder"), G_CALLBACK (_action_bookmark_folder_add_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "ManageSearchEngines", GTK_STOCK_PROPERTIES,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("_Manage Search Engines"), "<Ctrl><Alt>s",
|
|
|
|
N_("Add, edit and remove search engines..."),
|
2008-03-10 21:26:09 +00:00
|
|
|
G_CALLBACK (_action_manage_search_engines_activate) },
|
2009-07-24 14:43:55 +00:00
|
|
|
{ "ClearPrivateData", NULL,
|
2009-04-11 03:14:53 +00:00
|
|
|
N_("_Clear Private Data"), "<Ctrl><Shift>Delete",
|
|
|
|
N_("Clear private data..."),
|
|
|
|
G_CALLBACK (_action_clear_private_data_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
{ "TabPrevious", GTK_STOCK_GO_BACK,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("_Previous Tab"), "<Ctrl>Page_Up",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Switch to the previous tab"), G_CALLBACK (_action_tab_previous_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "TabNext", GTK_STOCK_GO_FORWARD,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("_Next Tab"), "<Ctrl>Page_Down",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Switch to the next tab"), G_CALLBACK (_action_tab_next_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-03-22 02:38:23 +00:00
|
|
|
{ "Help", NULL, N_("_Help") },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "HelpContents", GTK_STOCK_HELP,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("_Contents"), "F1",
|
2008-10-03 20:23:00 +00:00
|
|
|
N_("Show the documentation"), G_CALLBACK (_action_help_link_activate) },
|
|
|
|
{ "HelpFAQ", NULL,
|
2009-01-16 04:50:01 +00:00
|
|
|
N_("_Frequent Questions"), NULL,
|
2008-10-03 20:23:00 +00:00
|
|
|
N_("Show the Frequently Asked Questions"), G_CALLBACK (_action_help_link_activate) },
|
|
|
|
{ "HelpBugs", NULL,
|
2009-01-16 04:50:01 +00:00
|
|
|
N_("_Report a Bug"), NULL,
|
2008-10-03 20:23:00 +00:00
|
|
|
N_("Open Midori's bug tracker"), G_CALLBACK (_action_help_link_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "About", GTK_STOCK_ABOUT,
|
|
|
|
NULL, "",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Show information about the program"), G_CALLBACK (_action_about_activate) },
|
2008-10-12 19:44:00 +00:00
|
|
|
{ "Dummy", NULL, "Dummy" },
|
2008-03-10 21:26:09 +00:00
|
|
|
};
|
2008-03-24 13:15:23 +00:00
|
|
|
static const guint entries_n = G_N_ELEMENTS (entries);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
static const GtkToggleActionEntry toggle_entries[] = {
|
|
|
|
{ "PrivateBrowsing", NULL,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("P_rivate Browsing"), "",
|
2008-11-01 18:15:58 +00:00
|
|
|
N_("Don't save any private data while browsing"),
|
|
|
|
NULL/*G_CALLBACK (_action_private_browsing_activate)*/,
|
2008-03-10 21:26:09 +00:00
|
|
|
FALSE },
|
|
|
|
|
2008-10-12 20:09:49 +00:00
|
|
|
{ "Menubar", NULL,
|
|
|
|
N_("_Menubar"), "",
|
|
|
|
N_("Show menubar"), G_CALLBACK (_action_menubar_activate),
|
|
|
|
FALSE },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Navigationbar", NULL,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("_Navigationbar"), "",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Show navigationbar"), G_CALLBACK (_action_navigationbar_activate),
|
2008-03-10 21:26:09 +00:00
|
|
|
FALSE },
|
2008-10-15 01:32:11 +00:00
|
|
|
{ "Panel", GTK_STOCK_INDENT,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Side_panel"), "F9",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Show sidepanel"), G_CALLBACK (_action_panel_activate),
|
2008-03-10 21:26:09 +00:00
|
|
|
FALSE },
|
|
|
|
{ "Bookmarkbar", NULL,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("_Bookmarkbar"), "",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Show bookmarkbar"), G_CALLBACK (_action_bookmarkbar_activate),
|
2008-03-10 21:26:09 +00:00
|
|
|
FALSE },
|
2009-03-20 22:55:38 +00:00
|
|
|
{ "Transferbar", NULL,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("_Transferbar"), "",
|
2009-03-19 17:28:50 +00:00
|
|
|
N_("Show transferbar"), G_CALLBACK (_action_transferbar_activate),
|
2009-03-20 22:55:38 +00:00
|
|
|
FALSE },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Statusbar", NULL,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("_Statusbar"), "",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Show statusbar"), G_CALLBACK (_action_statusbar_activate),
|
2008-03-10 21:26:09 +00:00
|
|
|
FALSE },
|
|
|
|
};
|
2008-03-24 13:15:23 +00:00
|
|
|
static const guint toggle_entries_n = G_N_ELEMENTS (toggle_entries);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2009-06-22 20:55:23 +00:00
|
|
|
static const GtkRadioActionEntry encoding_entries[] = {
|
|
|
|
{ "EncodingAutomatic", NULL,
|
|
|
|
N_("_Automatic"), "",
|
|
|
|
NULL, 1 },
|
|
|
|
{ "EncodingChinese", NULL,
|
|
|
|
N_("Chinese (BIG5)"), "",
|
|
|
|
NULL, 1 },
|
|
|
|
{ "EncodingJapanese", NULL,
|
|
|
|
/* i18n: A double underscore "__" is used to prevent an unwanted mnemonic */
|
|
|
|
N_("Japanese (SHIFT__JIS)"), "",
|
|
|
|
NULL, 1 },
|
|
|
|
{ "EncodingRussian", NULL,
|
|
|
|
N_("Russian (KOI8-R)"), "",
|
|
|
|
NULL, 1 },
|
|
|
|
{ "EncodingUnicode", NULL,
|
|
|
|
N_("Unicode (UTF-8)"), "",
|
|
|
|
NULL, 1 },
|
|
|
|
{ "EncodingWestern", NULL,
|
|
|
|
N_("Western (ISO-8859-1)"), "",
|
|
|
|
NULL, 1 },
|
|
|
|
{ "EncodingCustom", NULL,
|
|
|
|
N_("Custom..."), "",
|
|
|
|
NULL, 1 },
|
|
|
|
};
|
|
|
|
static const guint encoding_entries_n = G_N_ELEMENTS (encoding_entries);
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
midori_browser_window_state_event_cb (MidoriBrowser* browser,
|
|
|
|
GdkEventWindowState* event)
|
|
|
|
{
|
2009-01-20 22:27:19 +00:00
|
|
|
MidoriWindowState window_state = MIDORI_WINDOW_NORMAL;
|
|
|
|
if (event->new_window_state & GDK_WINDOW_STATE_ICONIFIED)
|
|
|
|
window_state = MIDORI_WINDOW_MINIMIZED;
|
|
|
|
else if (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED)
|
|
|
|
window_state = MIDORI_WINDOW_MAXIMIZED;
|
|
|
|
else if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)
|
|
|
|
window_state = MIDORI_WINDOW_FULLSCREEN;
|
|
|
|
g_object_set (browser->settings, "last-window-state", window_state, NULL);
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
|
|
|
|
{
|
|
|
|
if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)
|
|
|
|
{
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_widget_hide (browser->menubar);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-12-06 03:53:30 +00:00
|
|
|
if (katze_object_get_boolean (browser->settings, "show-menubar"))
|
|
|
|
gtk_widget_show (browser->menubar);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-25 23:54:12 +00:00
|
|
|
static gboolean
|
|
|
|
midori_browser_alloc_timeout (MidoriBrowser* browser)
|
|
|
|
{
|
2009-02-22 13:42:27 +00:00
|
|
|
GtkWidget* widget = GTK_WIDGET (browser);
|
|
|
|
GdkWindowState state = gdk_window_get_state (widget->window);
|
|
|
|
|
|
|
|
if (!(state &
|
|
|
|
(GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)))
|
|
|
|
g_object_set (browser->settings,
|
|
|
|
"last-window-width", widget->allocation.width,
|
|
|
|
"last-window-height", widget->allocation.height, NULL);
|
|
|
|
|
2009-01-25 23:54:12 +00:00
|
|
|
browser->alloc_timeout = 0;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
midori_browser_size_allocate_cb (MidoriBrowser* browser,
|
|
|
|
GtkAllocation* allocation)
|
|
|
|
{
|
|
|
|
GtkWidget* widget = GTK_WIDGET (browser);
|
|
|
|
|
|
|
|
if (GTK_WIDGET_REALIZED (widget))
|
|
|
|
{
|
2009-06-22 22:25:09 +00:00
|
|
|
gpointer last_page;
|
2008-03-10 21:26:09 +00:00
|
|
|
GdkWindowState state = gdk_window_get_state (widget->window);
|
2009-06-22 22:25:09 +00:00
|
|
|
|
|
|
|
if ((last_page = g_object_get_data (G_OBJECT (browser), "last-page")))
|
|
|
|
{
|
|
|
|
midori_panel_set_current_page (MIDORI_PANEL (browser->panel),
|
|
|
|
GPOINTER_TO_INT (last_page));
|
|
|
|
g_object_set_data (G_OBJECT (browser), "last-page", NULL);
|
|
|
|
}
|
|
|
|
|
2009-01-25 23:54:12 +00:00
|
|
|
if (!(state &
|
|
|
|
(GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN))
|
|
|
|
&& !browser->alloc_timeout)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2009-01-25 23:54:12 +00:00
|
|
|
browser->alloc_timeout = g_timeout_add_full (G_PRIORITY_LOW, 5000,
|
|
|
|
(GSourceFunc)midori_browser_alloc_timeout, browser, NULL);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-22 22:17:10 +00:00
|
|
|
static void
|
|
|
|
midori_browser_destroy_cb (MidoriBrowser* browser)
|
|
|
|
{
|
2009-08-19 21:51:59 +00:00
|
|
|
if (browser->bookmarks)
|
|
|
|
midori_browser_set_bookmarks (browser, NULL);
|
|
|
|
|
2009-02-24 21:59:18 +00:00
|
|
|
if (G_UNLIKELY (browser->panel_timeout))
|
|
|
|
g_source_remove (browser->panel_timeout);
|
|
|
|
if (G_UNLIKELY (browser->alloc_timeout))
|
|
|
|
g_source_remove (browser->alloc_timeout);
|
|
|
|
|
2009-01-20 21:17:04 +00:00
|
|
|
/* Destroy panel first, so panels don't need special care */
|
|
|
|
gtk_widget_destroy (browser->panel);
|
|
|
|
/* Destroy tabs second, so child widgets don't need special care */
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_container_foreach (GTK_CONTAINER (browser->notebook),
|
2008-05-31 12:20:36 +00:00
|
|
|
(GtkCallback) gtk_widget_destroy, NULL);
|
2008-05-22 22:17:10 +00:00
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static const gchar* ui_markup =
|
|
|
|
"<ui>"
|
|
|
|
"<menubar>"
|
|
|
|
"<menu action='File'>"
|
|
|
|
"<menuitem action='WindowNew'/>"
|
|
|
|
"<menuitem action='TabNew'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='Open'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='SaveAs'/>"
|
2009-05-14 20:29:59 +00:00
|
|
|
"<menuitem action='AddSpeedDial'/>"
|
2008-03-10 21:26:09 +00:00
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='TabClose'/>"
|
|
|
|
"<menuitem action='WindowClose'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='Print'/>"
|
|
|
|
"<menuitem action='PrivateBrowsing'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='Quit'/>"
|
|
|
|
"</menu>"
|
|
|
|
"<menu action='Edit'>"
|
2009-09-10 00:17:18 +00:00
|
|
|
#if WEBKIT_CHECK_VERSION (1, 1, 14)
|
|
|
|
"<menuitem action='Undo'/>"
|
|
|
|
"<menuitem action='Redo'/>"
|
|
|
|
"<separator/>"
|
|
|
|
#endif
|
2008-03-10 21:26:09 +00:00
|
|
|
"<menuitem action='Cut'/>"
|
|
|
|
"<menuitem action='Copy'/>"
|
|
|
|
"<menuitem action='Paste'/>"
|
|
|
|
"<menuitem action='Delete'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='SelectAll'/>"
|
|
|
|
"<separator/>"
|
2008-10-03 23:00:34 +00:00
|
|
|
"<menuitem action='Find'/>"
|
|
|
|
"<menuitem action='FindNext'/>"
|
2009-07-20 06:13:29 +00:00
|
|
|
#ifndef G_OS_WIN32
|
2008-10-03 23:00:34 +00:00
|
|
|
"<separator/>"
|
2008-03-10 21:26:09 +00:00
|
|
|
"<menuitem action='Preferences'/>"
|
2009-07-20 06:13:29 +00:00
|
|
|
#endif
|
2008-03-10 21:26:09 +00:00
|
|
|
"</menu>"
|
|
|
|
"<menu action='View'>"
|
|
|
|
"<menu action='Toolbars'>"
|
2008-10-12 20:09:49 +00:00
|
|
|
"<menuitem action='Menubar'/>"
|
2008-03-10 21:26:09 +00:00
|
|
|
"<menuitem action='Navigationbar'/>"
|
|
|
|
"<menuitem action='Bookmarkbar'/>"
|
2009-03-20 22:55:38 +00:00
|
|
|
"<menuitem action='Transferbar'/>"
|
2008-03-10 21:26:09 +00:00
|
|
|
"<menuitem action='Statusbar'/>"
|
|
|
|
"</menu>"
|
|
|
|
"<menuitem action='Panel'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='Reload'/>"
|
|
|
|
"<menuitem action='Stop'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='ZoomIn'/>"
|
|
|
|
"<menuitem action='ZoomOut'/>"
|
|
|
|
"<menuitem action='ZoomNormal'/>"
|
|
|
|
"<separator/>"
|
2009-02-27 22:09:36 +00:00
|
|
|
"<menu action='Encoding'>"
|
|
|
|
"<menuitem action='EncodingAutomatic'/>"
|
|
|
|
"<menuitem action='EncodingChinese'/>"
|
|
|
|
"<menuitem action='EncodingJapanese'/>"
|
|
|
|
"<menuitem action='EncodingRussian'/>"
|
|
|
|
"<menuitem action='EncodingUnicode'/>"
|
|
|
|
"<menuitem action='EncodingWestern'/>"
|
|
|
|
"<menuitem action='EncodingCustom'/>"
|
|
|
|
"</menu>"
|
2008-03-10 21:26:09 +00:00
|
|
|
"<menuitem action='SourceView'/>"
|
|
|
|
"<menuitem action='Fullscreen'/>"
|
|
|
|
"</menu>"
|
|
|
|
"<menu action='Go'>"
|
|
|
|
"<menuitem action='Back'/>"
|
|
|
|
"<menuitem action='Forward'/>"
|
2008-05-20 01:21:11 +00:00
|
|
|
"<menuitem action='Homepage'/>"
|
2008-03-10 21:26:09 +00:00
|
|
|
"<menuitem action='Location'/>"
|
|
|
|
"<menuitem action='Search'/>"
|
2008-10-10 20:31:37 +00:00
|
|
|
"<menuitem action='Trash'/>"
|
2009-03-07 13:00:14 +00:00
|
|
|
"<menuitem action='RecentlyVisited'/>"
|
2008-03-10 21:26:09 +00:00
|
|
|
"</menu>"
|
2008-10-10 20:31:37 +00:00
|
|
|
"<menuitem action='Bookmarks'/>"
|
2009-07-24 21:55:57 +00:00
|
|
|
"<menuitem action='Tools'/>"
|
2008-10-10 20:31:37 +00:00
|
|
|
"<menuitem action='Window'/>"
|
2008-03-10 21:26:09 +00:00
|
|
|
"<menu action='Help'>"
|
|
|
|
"<menuitem action='HelpContents'/>"
|
2008-10-03 20:23:00 +00:00
|
|
|
"<menuitem action='HelpFAQ'/>"
|
|
|
|
"<menuitem action='HelpBugs'/>"
|
|
|
|
"<separator/>"
|
2008-03-10 21:26:09 +00:00
|
|
|
"<menuitem action='About'/>"
|
|
|
|
"</menu>"
|
2008-10-12 19:44:00 +00:00
|
|
|
/* For accelerators to work all actions need to be used
|
|
|
|
*somewhere* in the UI definition */
|
|
|
|
"<menu action='Dummy'>"
|
|
|
|
"<menuitem action='FindPrevious'/>"
|
2009-03-28 20:00:11 +00:00
|
|
|
"<menuitem action='BookmarkAdd'/>"
|
2009-04-10 20:28:36 +00:00
|
|
|
"<menuitem action='BookmarkFolderAdd'/>"
|
2009-07-24 21:55:57 +00:00
|
|
|
"<menuitem action='ManageSearchEngines'/>"
|
|
|
|
"<menuitem action='ClearPrivateData'/>"
|
2008-10-12 19:44:00 +00:00
|
|
|
"<menuitem action='TabPrevious'/>"
|
|
|
|
"<menuitem action='TabNext'/>"
|
2008-10-17 21:53:20 +00:00
|
|
|
"<menuitem action='UndoTabClose'/>"
|
2008-10-12 19:44:00 +00:00
|
|
|
"<menuitem action='TrashEmpty'/>"
|
2009-07-24 21:55:57 +00:00
|
|
|
"<menuitem action='Preferences'/>"
|
2008-10-12 19:44:00 +00:00
|
|
|
"</menu>"
|
2008-03-10 21:26:09 +00:00
|
|
|
"</menubar>"
|
|
|
|
"<toolbar name='toolbar_navigation'>"
|
|
|
|
"</toolbar>"
|
|
|
|
"</ui>";
|
|
|
|
|
2008-05-31 12:20:36 +00:00
|
|
|
static void
|
2008-07-27 05:39:39 +00:00
|
|
|
midori_browser_realize_cb (GtkStyle* style,
|
|
|
|
MidoriBrowser* browser)
|
2008-05-31 12:20:36 +00:00
|
|
|
{
|
2008-07-27 05:39:39 +00:00
|
|
|
GdkScreen* screen;
|
|
|
|
GtkIconTheme* icon_theme;
|
|
|
|
|
|
|
|
screen = gtk_widget_get_screen (GTK_WIDGET (browser));
|
2008-05-31 12:20:36 +00:00
|
|
|
if (screen)
|
|
|
|
{
|
2008-07-27 05:39:39 +00:00
|
|
|
icon_theme = gtk_icon_theme_get_for_screen (screen);
|
2008-05-31 12:20:36 +00:00
|
|
|
if (gtk_icon_theme_has_icon (icon_theme, "midori"))
|
|
|
|
gtk_window_set_icon_name (GTK_WINDOW (browser), "midori");
|
|
|
|
else
|
|
|
|
gtk_window_set_icon_name (GTK_WINDOW (browser), "web-browser");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-17 19:02:14 +00:00
|
|
|
static void
|
|
|
|
midori_browser_entry_clear_icon_released_cb (GtkIconEntry* entry,
|
|
|
|
gint icon_pos,
|
|
|
|
gint button,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
if (icon_pos == GTK_ICON_ENTRY_SECONDARY)
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry), "");
|
|
|
|
}
|
|
|
|
|
2008-11-09 18:26:48 +00:00
|
|
|
static void
|
|
|
|
midori_browser_new_history_item (MidoriBrowser* browser,
|
|
|
|
KatzeItem* item)
|
|
|
|
{
|
|
|
|
KatzeArray* parent;
|
|
|
|
gint i;
|
|
|
|
gboolean found;
|
|
|
|
time_t now;
|
2009-01-23 21:38:39 +00:00
|
|
|
gint64 day;
|
|
|
|
gint64 pday;
|
|
|
|
gint64 newage;
|
2009-01-11 18:30:43 +00:00
|
|
|
gchar token[50];
|
2008-11-09 18:26:48 +00:00
|
|
|
|
|
|
|
now = time (NULL);
|
|
|
|
katze_item_set_added (item, now);
|
2009-01-23 21:38:39 +00:00
|
|
|
day = sokoke_time_t_to_julian (&now);
|
2008-11-09 18:26:48 +00:00
|
|
|
|
|
|
|
found = FALSE;
|
|
|
|
i = 0;
|
2009-02-21 22:59:02 +00:00
|
|
|
while ((parent = katze_array_get_nth_item (browser->history, i++)))
|
2008-11-09 18:26:48 +00:00
|
|
|
{
|
2009-01-23 21:38:39 +00:00
|
|
|
pday = katze_item_get_added (KATZE_ITEM (parent));
|
|
|
|
newage = day - pday;
|
2008-11-09 18:26:48 +00:00
|
|
|
if (newage == 0)
|
|
|
|
{
|
|
|
|
found = TRUE;
|
|
|
|
katze_array_add_item (parent, item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
{
|
2009-02-28 22:03:23 +00:00
|
|
|
strftime (token, sizeof (token), "%x", localtime (&now));
|
2008-11-09 18:26:48 +00:00
|
|
|
parent = katze_array_new (KATZE_TYPE_ARRAY);
|
2009-01-23 21:38:39 +00:00
|
|
|
katze_item_set_added (KATZE_ITEM (parent), day);
|
2009-03-07 13:00:14 +00:00
|
|
|
katze_item_set_name (KATZE_ITEM (parent), token);
|
2008-11-09 18:26:48 +00:00
|
|
|
katze_array_add_item (browser->history, parent);
|
|
|
|
katze_array_add_item (parent, item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-21 22:59:02 +00:00
|
|
|
static void
|
|
|
|
midori_browser_history_remove_item_cb (KatzeArray* folder,
|
|
|
|
KatzeItem* item,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-06-01 03:14:36 +00:00
|
|
|
GtkAction* action = _action_by_name (browser, "RecentlyVisited");
|
2009-03-07 13:00:14 +00:00
|
|
|
if ((KatzeArray*)item == katze_array_action_get_array (KATZE_ARRAY_ACTION (action)))
|
|
|
|
g_object_set (action, "array", NULL, NULL);
|
2009-02-21 22:59:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-09 18:26:48 +00:00
|
|
|
static void
|
2008-12-21 18:21:04 +00:00
|
|
|
midori_browser_history_clear_cb (KatzeArray* history,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-02-21 22:59:02 +00:00
|
|
|
GtkAction* location_action = _action_by_name (browser, "Location");
|
2008-12-21 18:21:04 +00:00
|
|
|
midori_location_action_clear (MIDORI_LOCATION_ACTION (location_action));
|
2009-03-07 13:00:14 +00:00
|
|
|
g_object_set (_action_by_name (browser, "RecentlyVisited"),
|
|
|
|
"array", NULL, NULL);
|
2008-12-21 18:21:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_set_history (MidoriBrowser* browser,
|
|
|
|
KatzeArray* history)
|
2008-11-09 18:26:48 +00:00
|
|
|
{
|
2009-03-07 13:00:14 +00:00
|
|
|
KatzeItem* recently_visited;
|
2009-01-23 21:38:39 +00:00
|
|
|
time_t now;
|
|
|
|
gint64 day;
|
2008-11-09 18:26:48 +00:00
|
|
|
|
2008-12-21 18:21:04 +00:00
|
|
|
if (browser->history == history)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (browser->history)
|
|
|
|
g_signal_handlers_disconnect_by_func (browser->history,
|
|
|
|
midori_browser_history_clear_cb,
|
|
|
|
browser);
|
|
|
|
if (history)
|
|
|
|
g_object_ref (history);
|
|
|
|
katze_object_assign (browser->history, history);
|
|
|
|
|
2009-03-07 13:00:14 +00:00
|
|
|
midori_browser_history_clear_cb (history, browser);
|
2008-11-09 18:26:48 +00:00
|
|
|
|
2009-03-07 13:00:14 +00:00
|
|
|
if (history && ((recently_visited = katze_array_get_nth_item (history,
|
|
|
|
katze_array_get_length (KATZE_ARRAY (history)) - 1))))
|
|
|
|
g_object_set (_action_by_name (browser, "RecentlyVisited"),
|
|
|
|
"array", recently_visited, NULL);
|
|
|
|
else
|
|
|
|
g_object_set (_action_by_name (browser, "RecentlyVisited"),
|
|
|
|
"array", NULL, NULL);
|
2008-11-09 18:26:48 +00:00
|
|
|
|
2009-03-07 13:00:14 +00:00
|
|
|
if (!history)
|
2008-11-09 18:26:48 +00:00
|
|
|
return;
|
|
|
|
|
2009-06-02 23:32:22 +00:00
|
|
|
g_signal_connect (browser->history, "remove-item",
|
|
|
|
G_CALLBACK (midori_browser_history_remove_item_cb), browser);
|
2008-12-21 19:44:31 +00:00
|
|
|
g_signal_connect (browser->history, "clear",
|
|
|
|
G_CALLBACK (midori_browser_history_clear_cb), browser);
|
|
|
|
|
2009-01-23 21:38:39 +00:00
|
|
|
now = time (NULL);
|
|
|
|
day = sokoke_time_t_to_julian (&now);
|
|
|
|
|
2009-06-01 03:14:36 +00:00
|
|
|
g_object_set (_action_by_name (browser, "Location"), "history",
|
|
|
|
browser->history, NULL);
|
2008-11-09 18:26:48 +00:00
|
|
|
}
|
|
|
|
|
2009-06-12 00:02:55 +00:00
|
|
|
static void
|
|
|
|
midori_browser_accel_switch_tab_activate_cb (GtkAccelGroup* accel_group,
|
|
|
|
GObject* acceleratable,
|
|
|
|
guint keyval,
|
|
|
|
GdkModifierType modifiers)
|
|
|
|
{
|
|
|
|
GtkAccelGroupEntry* entry;
|
|
|
|
|
|
|
|
if ((entry = gtk_accel_group_query (accel_group, keyval, modifiers, NULL)))
|
|
|
|
{
|
|
|
|
gint n;
|
|
|
|
MidoriBrowser* browser;
|
|
|
|
GtkWidget* view;
|
|
|
|
|
|
|
|
n = keyval - GDK_0;
|
|
|
|
if (n == 0)
|
|
|
|
n = 10;
|
|
|
|
browser = g_object_get_data (G_OBJECT (accel_group), "midori-browser");
|
|
|
|
if ((view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook),
|
|
|
|
n - 1)))
|
|
|
|
midori_browser_set_current_tab (browser, view);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
midori_browser_init (MidoriBrowser* browser)
|
|
|
|
{
|
2008-11-01 18:15:58 +00:00
|
|
|
GtkWidget* vbox;
|
|
|
|
GtkUIManager* ui_manager;
|
2009-06-12 00:02:55 +00:00
|
|
|
GtkAccelGroup* accel_group;
|
|
|
|
guint i;
|
2008-11-01 18:15:58 +00:00
|
|
|
GError* error;
|
|
|
|
GtkAction* action;
|
|
|
|
GtkWidget* menuitem;
|
2009-05-07 20:41:39 +00:00
|
|
|
GtkWidget* homepage;
|
|
|
|
GtkWidget* back;
|
|
|
|
GtkWidget* forward;
|
2009-01-27 01:57:40 +00:00
|
|
|
#if HAVE_HILDON
|
|
|
|
GtkWidget* menu;
|
|
|
|
GList* children;
|
|
|
|
#endif
|
2008-11-01 18:15:58 +00:00
|
|
|
GtkSettings* gtk_settings;
|
|
|
|
GtkWidget* hpaned;
|
|
|
|
GtkWidget* vpaned;
|
2008-08-14 23:57:48 +00:00
|
|
|
GtkToolItem* toolitem;
|
2008-07-23 12:42:27 +00:00
|
|
|
GtkRcStyle* rcstyle;
|
2008-11-01 18:15:58 +00:00
|
|
|
GtkWidget* scrolled;
|
2009-04-19 17:05:05 +00:00
|
|
|
GtkWidget* icon;
|
2008-07-23 12:42:27 +00:00
|
|
|
|
2008-10-23 22:09:12 +00:00
|
|
|
browser->net = katze_net_new ();
|
2008-10-20 19:32:25 +00:00
|
|
|
|
2008-09-03 00:28:54 +00:00
|
|
|
browser->settings = midori_web_settings_new ();
|
2008-10-10 20:31:37 +00:00
|
|
|
browser->proxy_array = katze_array_new (KATZE_TYPE_ARRAY);
|
2008-09-03 00:28:54 +00:00
|
|
|
browser->bookmarks = NULL;
|
|
|
|
browser->trash = NULL;
|
|
|
|
browser->search_engines = NULL;
|
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Setup the window metrics */
|
2008-05-31 12:20:36 +00:00
|
|
|
g_signal_connect (browser, "realize",
|
|
|
|
G_CALLBACK (midori_browser_realize_cb), browser);
|
2008-03-10 21:26:09 +00:00
|
|
|
g_signal_connect (browser, "window-state-event",
|
|
|
|
G_CALLBACK (midori_browser_window_state_event_cb), NULL);
|
|
|
|
g_signal_connect (browser, "size-allocate",
|
|
|
|
G_CALLBACK (midori_browser_size_allocate_cb), NULL);
|
2008-05-22 22:17:10 +00:00
|
|
|
g_signal_connect (browser, "destroy",
|
|
|
|
G_CALLBACK (midori_browser_destroy_cb), NULL);
|
2009-07-16 12:00:47 +00:00
|
|
|
gtk_window_set_role (GTK_WINDOW (browser), "browser");
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_window_set_icon_name (GTK_WINDOW (browser), "web-browser");
|
|
|
|
gtk_window_set_title (GTK_WINDOW (browser), g_get_application_name ());
|
2008-11-01 18:15:58 +00:00
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (browser), vbox);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Let us see some ui manager magic */
|
2008-06-19 18:39:00 +00:00
|
|
|
browser->action_group = gtk_action_group_new ("Browser");
|
|
|
|
gtk_action_group_set_translation_domain (browser->action_group, GETTEXT_PACKAGE);
|
|
|
|
gtk_action_group_add_actions (browser->action_group,
|
2008-03-10 21:26:09 +00:00
|
|
|
entries, entries_n, browser);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_action_group_add_toggle_actions (browser->action_group,
|
2008-03-10 21:26:09 +00:00
|
|
|
toggle_entries, toggle_entries_n, browser);
|
2009-06-22 20:55:23 +00:00
|
|
|
gtk_action_group_add_radio_actions (browser->action_group,
|
|
|
|
encoding_entries, encoding_entries_n, 0,
|
|
|
|
G_CALLBACK (_action_view_encoding_activate), browser);
|
2008-11-01 18:15:58 +00:00
|
|
|
ui_manager = gtk_ui_manager_new ();
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_ui_manager_insert_action_group (ui_manager, browser->action_group, 0);
|
2009-06-12 00:02:55 +00:00
|
|
|
accel_group = gtk_ui_manager_get_accel_group (ui_manager);
|
|
|
|
gtk_window_add_accel_group (GTK_WINDOW (browser), accel_group);
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (accel_group), "midori-browser", browser);
|
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
{
|
|
|
|
gchar* accel_path = g_strdup_printf ("<Manual>/Browser/SwitchTab%d", i);
|
|
|
|
GClosure* closure = g_cclosure_new (
|
|
|
|
G_CALLBACK (midori_browser_accel_switch_tab_activate_cb),
|
|
|
|
browser, NULL);
|
|
|
|
gtk_accel_map_add_entry (accel_path, GDK_0 + i, GDK_MOD1_MASK);
|
|
|
|
gtk_accel_group_connect_by_path (accel_group, accel_path, closure);
|
|
|
|
g_free (accel_path);
|
|
|
|
}
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-11-01 18:15:58 +00:00
|
|
|
error = NULL;
|
2008-08-02 02:25:05 +00:00
|
|
|
if (!gtk_ui_manager_add_ui_from_string (ui_manager, ui_markup, -1, &error))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-06-14 00:23:33 +00:00
|
|
|
/* TODO: Should this be a message dialog? When does this happen? */
|
2008-03-10 21:26:09 +00:00
|
|
|
g_message ("User interface couldn't be created: %s", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
|
2008-10-12 19:44:00 +00:00
|
|
|
/* Hide the 'Dummy' which only holds otherwise unused actions */
|
|
|
|
g_object_set (_action_by_name (browser, "Dummy"), "visible", FALSE, NULL);
|
|
|
|
|
2009-01-28 23:56:07 +00:00
|
|
|
action = g_object_new (KATZE_TYPE_SEPARATOR_ACTION,
|
|
|
|
"name", "Separator",
|
|
|
|
"label", _("_Separator"),
|
|
|
|
NULL);
|
|
|
|
gtk_action_group_add_action (browser->action_group, action);
|
|
|
|
g_object_unref (action);
|
|
|
|
|
2008-08-14 23:57:48 +00:00
|
|
|
action = g_object_new (MIDORI_TYPE_LOCATION_ACTION,
|
|
|
|
"name", "Location",
|
|
|
|
"label", _("_Location..."),
|
2009-07-25 20:53:09 +00:00
|
|
|
"stock-id", GTK_STOCK_JUMP_TO,
|
2008-08-14 23:57:48 +00:00
|
|
|
"tooltip", _("Open a particular location"),
|
|
|
|
NULL);
|
|
|
|
g_object_connect (action,
|
|
|
|
"signal::activate",
|
|
|
|
_action_location_activate, browser,
|
|
|
|
"signal::active-changed",
|
|
|
|
_action_location_active_changed, browser,
|
2009-06-13 01:45:11 +00:00
|
|
|
"signal::focus-in",
|
|
|
|
_action_location_focus_in, browser,
|
2008-08-14 23:57:48 +00:00
|
|
|
"signal::focus-out",
|
|
|
|
_action_location_focus_out, browser,
|
|
|
|
"signal::reset-uri",
|
|
|
|
_action_location_reset_uri, browser,
|
|
|
|
"signal::submit-uri",
|
|
|
|
_action_location_submit_uri, browser,
|
2009-08-16 21:35:29 +00:00
|
|
|
"signal-after::secondary-icon-released",
|
2008-08-14 23:57:48 +00:00
|
|
|
_action_location_secondary_icon_released, browser,
|
|
|
|
NULL);
|
|
|
|
gtk_action_group_add_action_with_accel (browser->action_group,
|
|
|
|
action, "<Ctrl>L");
|
|
|
|
g_object_unref (action);
|
|
|
|
|
2008-10-05 21:25:02 +00:00
|
|
|
action = g_object_new (MIDORI_TYPE_SEARCH_ACTION,
|
|
|
|
"name", "Search",
|
|
|
|
"label", _("_Web Search..."),
|
|
|
|
"stock-id", GTK_STOCK_FIND,
|
|
|
|
"tooltip", _("Run a web search"),
|
|
|
|
NULL);
|
|
|
|
g_object_connect (action,
|
|
|
|
"signal::activate",
|
|
|
|
_action_search_activate, browser,
|
|
|
|
"signal::submit",
|
|
|
|
_action_search_submit, browser,
|
|
|
|
"signal::focus-out",
|
|
|
|
_action_search_focus_out, browser,
|
|
|
|
"signal::notify::current-item",
|
|
|
|
_action_search_notify_current_item, browser,
|
2009-04-18 20:41:37 +00:00
|
|
|
"signal::notify::default-item",
|
|
|
|
_action_search_notify_default_item, browser,
|
2008-10-05 21:25:02 +00:00
|
|
|
NULL);
|
|
|
|
gtk_action_group_add_action_with_accel (browser->action_group,
|
|
|
|
action, "<Ctrl>K");
|
|
|
|
g_object_unref (action);
|
|
|
|
|
2008-10-10 20:31:37 +00:00
|
|
|
action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
|
|
|
|
"name", "Trash",
|
|
|
|
"stock-id", STOCK_USER_TRASH,
|
|
|
|
"tooltip", _("Reopen a previously closed tab or window"),
|
|
|
|
NULL);
|
|
|
|
g_object_connect (action,
|
|
|
|
"signal::populate-popup",
|
|
|
|
_action_trash_populate_popup, browser,
|
|
|
|
"signal::activate-item",
|
|
|
|
_action_trash_activate_item, browser,
|
2009-05-05 21:22:39 +00:00
|
|
|
"signal::activate-item-alt",
|
|
|
|
_action_trash_activate_item_alt, browser,
|
2008-10-10 20:31:37 +00:00
|
|
|
NULL);
|
2008-11-23 00:44:40 +00:00
|
|
|
gtk_action_group_add_action_with_accel (browser->action_group, action, "");
|
2008-10-10 20:31:37 +00:00
|
|
|
g_object_unref (action);
|
|
|
|
|
|
|
|
action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
|
|
|
|
"name", "RecentlyVisited",
|
|
|
|
"label", _("_Recently visited pages"),
|
|
|
|
"stock-id", STOCK_HISTORY,
|
2008-11-02 23:17:43 +00:00
|
|
|
"tooltip", _("Reopen pages that you visited earlier"),
|
2008-10-10 20:31:37 +00:00
|
|
|
NULL);
|
|
|
|
g_object_connect (action,
|
|
|
|
"signal::populate-popup",
|
|
|
|
_action_history_populate_popup, browser,
|
|
|
|
"signal::activate-item",
|
|
|
|
_action_history_activate_item, browser,
|
2009-05-05 21:22:39 +00:00
|
|
|
"signal::activate-item-alt",
|
|
|
|
_action_menus_activate_item_alt, browser,
|
2008-10-10 20:31:37 +00:00
|
|
|
NULL);
|
2008-11-23 00:44:40 +00:00
|
|
|
gtk_action_group_add_action_with_accel (browser->action_group, action, "");
|
2008-10-10 20:31:37 +00:00
|
|
|
g_object_unref (action);
|
|
|
|
|
|
|
|
action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
|
|
|
|
"name", "Bookmarks",
|
|
|
|
"label", _("_Bookmarks"),
|
|
|
|
"stock-id", STOCK_BOOKMARKS,
|
2008-11-02 23:17:43 +00:00
|
|
|
"tooltip", _("Show the saved bookmarks"),
|
2008-10-10 20:31:37 +00:00
|
|
|
NULL);
|
|
|
|
g_object_connect (action,
|
|
|
|
"signal::populate-popup",
|
|
|
|
_action_bookmarks_populate_popup, browser,
|
|
|
|
"signal::activate-item",
|
|
|
|
_action_bookmarks_activate_item, browser,
|
2009-05-03 10:42:47 +00:00
|
|
|
"signal::activate-item-alt",
|
2009-05-05 21:22:39 +00:00
|
|
|
_action_menus_activate_item_alt, browser,
|
2008-10-10 20:31:37 +00:00
|
|
|
NULL);
|
2008-11-23 00:44:40 +00:00
|
|
|
gtk_action_group_add_action_with_accel (browser->action_group, action, "");
|
2008-10-10 20:31:37 +00:00
|
|
|
g_object_unref (action);
|
|
|
|
|
2009-07-24 21:55:57 +00:00
|
|
|
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);
|
|
|
|
|
2008-10-10 20:31:37 +00:00
|
|
|
action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
|
|
|
|
"name", "Window",
|
2008-11-02 23:17:43 +00:00
|
|
|
"label", _("_Window"),
|
2008-10-10 20:31:37 +00:00
|
|
|
"stock-id", GTK_STOCK_INDEX,
|
|
|
|
"tooltip", _("Show a list of all open tabs"),
|
|
|
|
"array", browser->proxy_array,
|
|
|
|
NULL);
|
|
|
|
g_object_connect (action,
|
|
|
|
"signal::populate-popup",
|
|
|
|
_action_window_populate_popup, browser,
|
|
|
|
"signal::activate-item",
|
|
|
|
_action_window_activate_item, browser,
|
|
|
|
NULL);
|
2008-11-23 00:44:40 +00:00
|
|
|
gtk_action_group_add_action_with_accel (browser->action_group, action, "");
|
2008-10-10 20:31:37 +00:00
|
|
|
g_object_unref (action);
|
|
|
|
|
2009-06-22 19:47:42 +00:00
|
|
|
action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
|
|
|
|
"name", "CompactMenu",
|
|
|
|
"label", _("_Menu"),
|
|
|
|
"stock-id", STOCK_WEB_BROWSER,
|
2009-06-27 21:56:01 +00:00
|
|
|
"tooltip", _("Menu"),
|
2009-06-22 19:47:42 +00:00
|
|
|
"array", katze_array_new (KATZE_TYPE_ITEM),
|
|
|
|
NULL);
|
|
|
|
g_object_connect (action,
|
|
|
|
"signal::populate-popup",
|
|
|
|
_action_compact_menu_populate_popup, browser,
|
|
|
|
NULL);
|
|
|
|
gtk_action_group_add_action (browser->action_group, action);
|
|
|
|
g_object_unref (action);
|
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Create the menubar */
|
2008-06-19 18:39:00 +00:00
|
|
|
browser->menubar = gtk_ui_manager_get_widget (ui_manager, "/menubar");
|
2009-01-27 01:57:40 +00:00
|
|
|
#if HAVE_HILDON
|
|
|
|
menu = gtk_menu_new ();
|
|
|
|
children = gtk_container_get_children (GTK_CONTAINER (browser->menubar));
|
|
|
|
while (children)
|
|
|
|
{
|
|
|
|
menuitem = GTK_WIDGET (children->data);
|
|
|
|
gtk_widget_reparent (menuitem, menu);
|
|
|
|
children = g_list_next (children);
|
|
|
|
}
|
|
|
|
browser->menubar = menu;
|
|
|
|
hildon_window_set_menu (HILDON_WINDOW (browser), GTK_MENU (browser->menubar));
|
|
|
|
hildon_program_add_window (hildon_program_get_instance (),
|
|
|
|
HILDON_WINDOW (browser));
|
|
|
|
#else
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), browser->menubar, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_hide (browser->menubar);
|
|
|
|
g_signal_connect (browser->menubar, "button-press-event",
|
2009-05-07 20:41:39 +00:00
|
|
|
G_CALLBACK (midori_browser_menu_button_press_event_cb), browser);
|
2009-01-27 01:57:40 +00:00
|
|
|
#endif
|
2008-11-01 18:15:58 +00:00
|
|
|
menuitem = gtk_menu_item_new ();
|
2009-01-27 01:57:40 +00:00
|
|
|
#if !HAVE_HILDON
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_widget_show (menuitem);
|
2009-01-27 01:57:40 +00:00
|
|
|
#endif
|
2008-08-31 00:45:13 +00:00
|
|
|
browser->throbber = katze_throbber_new ();
|
|
|
|
gtk_widget_show (browser->throbber);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (menuitem), browser->throbber);
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_widget_set_sensitive (menuitem, FALSE);
|
|
|
|
gtk_menu_item_set_right_justified (GTK_MENU_ITEM (menuitem), TRUE);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (browser->menubar), menuitem);
|
2009-07-24 21:55:57 +00:00
|
|
|
browser->menu_tools = gtk_menu_new ();
|
2008-10-12 20:09:49 +00:00
|
|
|
|
2009-07-25 20:53:09 +00:00
|
|
|
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);
|
|
|
|
|
2009-05-07 20:41:39 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
_action_set_sensitive (browser, "PrivateBrowsing", FALSE);
|
2009-01-27 01:57:40 +00:00
|
|
|
#if HAVE_HILDON
|
|
|
|
g_object_set (_action_by_name (browser, "Menubar"), "visible", FALSE, NULL);
|
|
|
|
g_object_set (_action_by_name (browser, "Statusbar"), "visible", FALSE, NULL);
|
|
|
|
#endif
|
2009-03-20 22:55:38 +00:00
|
|
|
#if !WEBKIT_CHECK_VERSION (1, 1, 3)
|
|
|
|
_action_set_sensitive (browser, "Transferbar", FALSE);
|
|
|
|
#endif
|
2009-02-27 22:09:36 +00:00
|
|
|
_action_set_sensitive (browser, "EncodingCustom", FALSE);
|
2008-10-12 19:44:00 +00:00
|
|
|
_action_set_sensitive (browser, "SelectionSourceView", FALSE);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Create the navigationbar */
|
2008-06-19 18:39:00 +00:00
|
|
|
browser->navigationbar = gtk_ui_manager_get_widget (
|
2008-03-10 21:26:09 +00:00
|
|
|
ui_manager, "/toolbar_navigation");
|
2008-11-23 00:44:40 +00:00
|
|
|
/* FIXME: Settings should be connected with screen changes */
|
2008-11-01 18:15:58 +00:00
|
|
|
gtk_settings = gtk_widget_get_settings (GTK_WIDGET (browser));
|
2008-04-16 23:38:22 +00:00
|
|
|
if (gtk_settings)
|
|
|
|
g_signal_connect (gtk_settings, "notify::gtk-toolbar-style",
|
|
|
|
G_CALLBACK (midori_browser_navigationbar_notify_style_cb), browser);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_toolbar_set_show_arrow (GTK_TOOLBAR (browser->navigationbar), TRUE);
|
2008-03-10 21:26:09 +00:00
|
|
|
g_object_set (_action_by_name (browser, "Back"), "is-important", TRUE, NULL);
|
2008-08-10 16:28:08 +00:00
|
|
|
gtk_widget_hide (browser->navigationbar);
|
2008-10-12 16:14:57 +00:00
|
|
|
g_signal_connect (browser->navigationbar, "popup-context-menu",
|
|
|
|
G_CALLBACK (midori_browser_toolbar_popup_context_menu_cb), browser);
|
2009-01-27 01:57:40 +00:00
|
|
|
#if HAVE_HILDON
|
|
|
|
hildon_window_add_toolbar (HILDON_WINDOW (browser),
|
|
|
|
GTK_TOOLBAR (browser->navigationbar));
|
|
|
|
#else
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), browser->navigationbar, FALSE, FALSE, 0);
|
|
|
|
#endif
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Bookmarkbar */
|
2008-06-19 18:39:00 +00:00
|
|
|
browser->bookmarkbar = gtk_toolbar_new ();
|
2009-01-12 20:52:33 +00:00
|
|
|
gtk_widget_set_name (browser->bookmarkbar, "MidoriBookmarkbar");
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_toolbar_set_icon_size (GTK_TOOLBAR (browser->bookmarkbar),
|
2008-03-10 21:26:09 +00:00
|
|
|
GTK_ICON_SIZE_MENU);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_toolbar_set_style (GTK_TOOLBAR (browser->bookmarkbar),
|
2008-03-10 21:26:09 +00:00
|
|
|
GTK_TOOLBAR_BOTH_HORIZ);
|
2009-07-17 02:28:53 +00:00
|
|
|
browser->homepage = gtk_tool_button_new_from_stock (STOCK_HOMEPAGE);
|
|
|
|
gtk_tool_item_set_is_important (browser->homepage, TRUE);
|
|
|
|
gtk_widget_show (GTK_WIDGET (browser->homepage));
|
|
|
|
g_signal_connect (browser->homepage, "clicked",
|
|
|
|
G_CALLBACK (midori_browser_bookmark_homepage_clicked_cb), browser);
|
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->bookmarkbar), browser->homepage, -1);
|
2009-01-27 01:57:40 +00:00
|
|
|
#if HAVE_HILDON
|
|
|
|
hildon_window_add_toolbar (HILDON_WINDOW (browser),
|
|
|
|
GTK_TOOLBAR (browser->bookmarkbar));
|
|
|
|
#else
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), browser->bookmarkbar, FALSE, FALSE, 0);
|
2009-01-27 01:57:40 +00:00
|
|
|
#endif
|
2008-10-12 16:14:57 +00:00
|
|
|
g_signal_connect (browser->bookmarkbar, "popup-context-menu",
|
|
|
|
G_CALLBACK (midori_browser_toolbar_popup_context_menu_cb), browser);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Create the panel */
|
2008-11-01 18:15:58 +00:00
|
|
|
hpaned = gtk_hpaned_new ();
|
2008-03-10 21:26:09 +00:00
|
|
|
g_signal_connect (hpaned, "notify::position",
|
|
|
|
G_CALLBACK (midori_panel_notify_position_cb),
|
|
|
|
browser);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hpaned, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (hpaned);
|
2008-06-19 18:39:00 +00:00
|
|
|
browser->panel = g_object_new (MIDORI_TYPE_PANEL,
|
2009-02-22 18:23:45 +00:00
|
|
|
"menu", browser->menu_tools,
|
|
|
|
NULL);
|
2009-07-26 20:00:10 +00:00
|
|
|
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);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_paned_pack1 (GTK_PANED (hpaned), browser->panel, FALSE, FALSE);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
/* Notebook, containing all views */
|
2008-11-01 18:15:58 +00:00
|
|
|
vpaned = gtk_vpaned_new ();
|
|
|
|
gtk_paned_pack2 (GTK_PANED (hpaned), vpaned, FALSE, FALSE);
|
|
|
|
gtk_widget_show (vpaned);
|
2008-06-19 18:39:00 +00:00
|
|
|
browser->notebook = gtk_notebook_new ();
|
2008-07-23 12:42:27 +00:00
|
|
|
/* Remove the inner border between scrollbars and the window border */
|
|
|
|
rcstyle = gtk_rc_style_new ();
|
2009-04-12 19:57:20 +00:00
|
|
|
rcstyle->xthickness = 0;
|
2008-07-23 12:42:27 +00:00
|
|
|
gtk_widget_modify_style (browser->notebook, rcstyle);
|
|
|
|
g_object_unref (rcstyle);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_notebook_set_scrollable (GTK_NOTEBOOK (browser->notebook), TRUE);
|
2008-11-01 18:15:58 +00:00
|
|
|
gtk_paned_pack2 (GTK_PANED (vpaned), browser->notebook, FALSE, FALSE);
|
2008-06-19 18:39:00 +00:00
|
|
|
g_signal_connect_after (browser->notebook, "switch-page",
|
2008-03-10 21:26:09 +00:00
|
|
|
G_CALLBACK (gtk_notebook_switch_page_cb),
|
|
|
|
browser);
|
2009-03-24 22:54:37 +00:00
|
|
|
g_signal_connect (browser->notebook, "page-reordered",
|
|
|
|
G_CALLBACK (midori_browser_notebook_page_reordered_cb),
|
|
|
|
browser);
|
2009-06-25 21:49:41 +00:00
|
|
|
g_signal_connect_after (browser->notebook, "button-press-event",
|
|
|
|
G_CALLBACK (midori_browser_notebook_button_press_event_after_cb),
|
2009-01-13 19:50:17 +00:00
|
|
|
browser);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_widget_show (browser->notebook);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-11-01 18:15:58 +00:00
|
|
|
/* Inspector container */
|
|
|
|
browser->inspector = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_paned_pack2 (GTK_PANED (vpaned), browser->inspector, TRUE, TRUE);
|
|
|
|
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
|
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
|
|
|
GTK_WIDGET_SET_FLAGS (scrolled, GTK_CAN_FOCUS);
|
|
|
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
|
|
|
|
GTK_SHADOW_ETCHED_IN);
|
|
|
|
gtk_box_pack_start (GTK_BOX (browser->inspector),
|
|
|
|
scrolled, TRUE, TRUE, 0);
|
|
|
|
browser->inspector_view = webkit_web_view_new ();
|
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled), browser->inspector_view);
|
|
|
|
gtk_widget_show_all (browser->inspector);
|
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Incremental findbar */
|
2008-06-19 18:39:00 +00:00
|
|
|
browser->find = gtk_toolbar_new ();
|
2009-01-12 20:52:33 +00:00
|
|
|
gtk_widget_set_name (browser->find, "MidoriFindbar");
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_toolbar_set_icon_size (GTK_TOOLBAR (browser->find), GTK_ICON_SIZE_MENU);
|
|
|
|
gtk_toolbar_set_style (GTK_TOOLBAR (browser->find), GTK_TOOLBAR_BOTH_HORIZ);
|
2009-01-24 14:34:31 +00:00
|
|
|
g_signal_connect (browser->find, "key-press-event",
|
2009-01-24 21:15:37 +00:00
|
|
|
G_CALLBACK (midori_browser_find_key_press_event_cb), browser);
|
2008-03-10 21:26:09 +00:00
|
|
|
toolitem = gtk_tool_item_new ();
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (toolitem), 6);
|
|
|
|
gtk_container_add (GTK_CONTAINER (toolitem),
|
2008-11-08 02:05:30 +00:00
|
|
|
/* i18n: A panel at the bottom, to search text in pages */
|
2009-01-16 04:50:01 +00:00
|
|
|
gtk_label_new_with_mnemonic (_("_Inline Find:")));
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->find), toolitem, -1);
|
2008-07-17 19:02:14 +00:00
|
|
|
browser->find_text = gtk_icon_entry_new ();
|
2008-08-25 23:59:02 +00:00
|
|
|
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (browser->find_text),
|
2008-07-17 19:02:14 +00:00
|
|
|
GTK_ICON_ENTRY_PRIMARY,
|
|
|
|
GTK_STOCK_FIND);
|
|
|
|
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (browser->find_text),
|
|
|
|
GTK_ICON_ENTRY_SECONDARY,
|
|
|
|
GTK_STOCK_CLEAR);
|
2008-07-22 12:53:25 +00:00
|
|
|
gtk_icon_entry_set_icon_highlight (GTK_ICON_ENTRY (browser->find_text),
|
|
|
|
GTK_ICON_ENTRY_SECONDARY, TRUE);
|
2009-04-11 05:05:28 +00:00
|
|
|
g_signal_connect (browser->find_text, "icon-release",
|
2008-07-17 19:02:14 +00:00
|
|
|
G_CALLBACK (midori_browser_entry_clear_icon_released_cb), NULL);
|
2008-06-19 18:39:00 +00:00
|
|
|
g_signal_connect (browser->find_text, "activate",
|
2008-03-10 21:26:09 +00:00
|
|
|
G_CALLBACK (_action_find_next_activate), browser);
|
2009-02-22 01:17:58 +00:00
|
|
|
g_signal_connect (browser->find_text, "changed",
|
2009-02-22 14:36:41 +00:00
|
|
|
G_CALLBACK (midori_browser_find_text_changed_cb), browser);
|
|
|
|
g_signal_connect (browser->find_text, "focus-out-event",
|
|
|
|
G_CALLBACK (midori_browser_find_text_focus_out_event_cb), browser);
|
2008-03-10 21:26:09 +00:00
|
|
|
toolitem = gtk_tool_item_new ();
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (toolitem), browser->find_text);
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_tool_item_set_expand (GTK_TOOL_ITEM (toolitem), TRUE);
|
2008-08-25 23:59:02 +00:00
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->find), toolitem, -1);
|
2008-07-13 19:49:57 +00:00
|
|
|
toolitem = (GtkToolItem*)gtk_action_create_tool_item
|
|
|
|
(_action_by_name (browser, "FindPrevious"));
|
2009-01-16 04:50:01 +00:00
|
|
|
gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem), _("Previous"));
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_tool_item_set_is_important (toolitem, TRUE);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->find), toolitem, -1);
|
2008-07-13 19:49:57 +00:00
|
|
|
toolitem = (GtkToolItem*)gtk_action_create_tool_item
|
|
|
|
(_action_by_name (browser, "FindNext"));
|
2009-01-16 04:50:01 +00:00
|
|
|
gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem), _("Next"));
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_tool_item_set_is_important (toolitem, TRUE);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->find), toolitem, -1);
|
|
|
|
browser->find_case = gtk_toggle_tool_button_new_from_stock (
|
2008-03-10 21:26:09 +00:00
|
|
|
GTK_STOCK_SPELL_CHECK);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_tool_button_set_label (GTK_TOOL_BUTTON (browser->find_case), _("Match Case"));
|
|
|
|
gtk_tool_item_set_is_important (GTK_TOOL_ITEM (browser->find_case), TRUE);
|
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->find), browser->find_case, -1);
|
|
|
|
browser->find_highlight = gtk_toggle_tool_button_new_from_stock (
|
2008-03-10 21:26:09 +00:00
|
|
|
GTK_STOCK_SELECT_ALL);
|
2008-06-19 18:39:00 +00:00
|
|
|
g_signal_connect (browser->find_highlight, "toggled",
|
2008-03-10 21:26:09 +00:00
|
|
|
G_CALLBACK (_find_highlight_toggled), browser);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_tool_button_set_label (GTK_TOOL_BUTTON (browser->find_highlight),
|
2008-09-07 01:39:25 +00:00
|
|
|
_("Highlight Matches"));
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_tool_item_set_is_important (GTK_TOOL_ITEM (browser->find_highlight), TRUE);
|
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->find), browser->find_highlight, -1);
|
2008-03-10 21:26:09 +00:00
|
|
|
toolitem = gtk_separator_tool_item_new ();
|
|
|
|
gtk_separator_tool_item_set_draw (
|
|
|
|
GTK_SEPARATOR_TOOL_ITEM (toolitem), FALSE);
|
|
|
|
gtk_tool_item_set_expand (GTK_TOOL_ITEM (toolitem), TRUE);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->find), toolitem, -1);
|
2009-02-22 01:34:21 +00:00
|
|
|
browser->find_close = gtk_tool_button_new_from_stock (GTK_STOCK_CLOSE);
|
|
|
|
gtk_tool_button_set_label (GTK_TOOL_BUTTON (browser->find_close),
|
|
|
|
_("Close Findbar"));
|
|
|
|
g_signal_connect (browser->find_close, "clicked",
|
2008-03-10 21:26:09 +00:00
|
|
|
G_CALLBACK (midori_browser_find_button_close_clicked_cb), browser);
|
2009-01-09 21:54:40 +00:00
|
|
|
#if HAVE_OSX
|
2009-02-22 01:34:21 +00:00
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->find), browser->find_close, 0);
|
2008-10-25 22:54:57 +00:00
|
|
|
#else
|
2009-02-22 01:34:21 +00:00
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->find), browser->find_close, -1);
|
2008-10-25 22:54:57 +00:00
|
|
|
#endif
|
2008-06-19 18:39:00 +00:00
|
|
|
sokoke_container_show_children (GTK_CONTAINER (browser->find));
|
2009-01-27 01:57:40 +00:00
|
|
|
#if HAVE_HILDON
|
|
|
|
hildon_window_add_toolbar (HILDON_WINDOW (browser),
|
|
|
|
GTK_TOOLBAR (browser->find));
|
|
|
|
#else
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), browser->find, FALSE, FALSE, 0);
|
2009-01-27 01:57:40 +00:00
|
|
|
#endif
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Statusbar */
|
2008-06-19 18:39:00 +00:00
|
|
|
browser->statusbar = gtk_statusbar_new ();
|
2008-07-23 16:23:21 +00:00
|
|
|
/* Adjust the statusbar's padding to avoid child overlapping */
|
|
|
|
rcstyle = gtk_rc_style_new ();
|
|
|
|
rcstyle->xthickness = rcstyle->ythickness = -4;
|
|
|
|
gtk_widget_modify_style (browser->statusbar, rcstyle);
|
|
|
|
g_object_unref (rcstyle);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), browser->statusbar, FALSE, FALSE, 0);
|
2009-03-19 17:28:50 +00:00
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
browser->progressbar = gtk_progress_bar_new ();
|
2008-07-23 16:23:21 +00:00
|
|
|
/* Set the progressbar's height to 1 to fit it in the statusbar */
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_widget_set_size_request (browser->progressbar, -1, 1);
|
|
|
|
gtk_box_pack_start (GTK_BOX (browser->statusbar), browser->progressbar,
|
2008-03-10 21:26:09 +00:00
|
|
|
FALSE, FALSE, 3);
|
|
|
|
|
2009-03-19 17:28:50 +00:00
|
|
|
browser->transferbar = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (browser->statusbar), browser->transferbar,
|
|
|
|
FALSE, FALSE, 3);
|
|
|
|
gtk_widget_show (browser->transferbar);
|
2009-08-11 15:23:30 +00:00
|
|
|
browser->transferbar_clear = gtk_button_new_with_label (_("Clear All"));
|
2009-04-19 17:05:05 +00:00
|
|
|
icon = gtk_image_new_from_stock (GTK_STOCK_CLEAR, GTK_ICON_SIZE_MENU);
|
|
|
|
gtk_button_set_image (GTK_BUTTON (browser->transferbar_clear), icon);
|
|
|
|
g_signal_connect (browser->transferbar_clear, "clicked",
|
|
|
|
G_CALLBACK (midori_browser_transferbar_clear_clicked_cb), browser);
|
|
|
|
gtk_box_pack_end (GTK_BOX (browser->transferbar), browser->transferbar_clear,
|
|
|
|
FALSE, FALSE, 0);
|
2009-03-20 22:55:38 +00:00
|
|
|
g_signal_connect (browser->statusbar, "button-press-event",
|
2009-05-07 20:41:39 +00:00
|
|
|
G_CALLBACK (midori_browser_menu_button_press_event_cb), browser);
|
2009-03-19 17:28:50 +00:00
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
g_object_unref (ui_manager);
|
|
|
|
}
|
|
|
|
|
2008-07-25 10:45:50 +00:00
|
|
|
static void
|
|
|
|
midori_browser_dispose (GObject* object)
|
|
|
|
{
|
|
|
|
MidoriBrowser* browser = MIDORI_BROWSER (object);
|
|
|
|
|
|
|
|
/* We are done, the session mustn't change anymore */
|
2008-10-10 20:31:37 +00:00
|
|
|
katze_object_assign (browser->proxy_array, NULL);
|
2008-07-25 10:45:50 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (midori_browser_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
midori_browser_finalize (GObject* object)
|
|
|
|
{
|
|
|
|
MidoriBrowser* browser = MIDORI_BROWSER (object);
|
|
|
|
|
2009-08-09 13:07:09 +00:00
|
|
|
if (browser->settings)
|
|
|
|
g_signal_handlers_disconnect_by_func (browser->settings,
|
|
|
|
midori_browser_settings_notify,
|
|
|
|
browser);
|
|
|
|
|
2008-11-23 00:44:40 +00:00
|
|
|
katze_assign (browser->statusbar_text, NULL);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-10-23 22:09:12 +00:00
|
|
|
katze_object_assign (browser->settings, NULL);
|
|
|
|
katze_object_assign (browser->bookmarks, NULL);
|
|
|
|
katze_object_assign (browser->trash, NULL);
|
|
|
|
katze_object_assign (browser->search_engines, NULL);
|
|
|
|
katze_object_assign (browser->history, NULL);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-10-23 22:09:12 +00:00
|
|
|
katze_object_assign (browser->net, NULL);
|
2008-10-20 19:32:25 +00:00
|
|
|
|
2009-04-14 17:44:48 +00:00
|
|
|
katze_assign (browser->news_aggregator, NULL);
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
G_OBJECT_CLASS (midori_browser_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2008-04-16 23:38:22 +00:00
|
|
|
static void
|
2008-04-22 20:19:24 +00:00
|
|
|
_midori_browser_set_toolbar_style (MidoriBrowser* browser,
|
|
|
|
MidoriToolbarStyle toolbar_style)
|
|
|
|
{
|
2009-01-27 01:57:40 +00:00
|
|
|
#if HAVE_HILDON
|
|
|
|
GtkToolbarStyle gtk_toolbar_style = GTK_TOOLBAR_ICONS;
|
|
|
|
#else
|
2008-04-22 20:19:24 +00:00
|
|
|
GtkToolbarStyle gtk_toolbar_style;
|
|
|
|
GtkSettings* gtk_settings = gtk_widget_get_settings (GTK_WIDGET (browser));
|
|
|
|
if (toolbar_style == MIDORI_TOOLBAR_DEFAULT && gtk_settings)
|
2009-07-20 04:54:46 +00:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
gtk_toolbar_style = GTK_TOOLBAR_ICONS;
|
|
|
|
#else
|
2008-04-22 20:19:24 +00:00
|
|
|
g_object_get (gtk_settings, "gtk-toolbar-style", >k_toolbar_style, NULL);
|
2009-07-20 04:54:46 +00:00
|
|
|
#endif
|
2008-04-22 20:19:24 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (toolbar_style)
|
|
|
|
{
|
|
|
|
case MIDORI_TOOLBAR_ICONS:
|
|
|
|
gtk_toolbar_style = GTK_TOOLBAR_ICONS;
|
|
|
|
break;
|
|
|
|
case MIDORI_TOOLBAR_TEXT:
|
|
|
|
gtk_toolbar_style = GTK_TOOLBAR_TEXT;
|
|
|
|
break;
|
|
|
|
case MIDORI_TOOLBAR_BOTH:
|
|
|
|
gtk_toolbar_style = GTK_TOOLBAR_BOTH;
|
|
|
|
break;
|
|
|
|
case MIDORI_TOOLBAR_BOTH_HORIZ:
|
|
|
|
case MIDORI_TOOLBAR_DEFAULT:
|
|
|
|
gtk_toolbar_style = GTK_TOOLBAR_BOTH_HORIZ;
|
|
|
|
}
|
|
|
|
}
|
2009-01-27 01:57:40 +00:00
|
|
|
#endif
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_toolbar_set_style (GTK_TOOLBAR (browser->navigationbar),
|
2008-04-22 20:19:24 +00:00
|
|
|
gtk_toolbar_style);
|
|
|
|
}
|
|
|
|
|
2008-10-12 16:14:57 +00:00
|
|
|
static gboolean
|
|
|
|
midori_browser_toolbar_item_button_press_event_cb (GtkWidget* toolitem,
|
|
|
|
GdkEventButton* event,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-05-03 19:35:05 +00:00
|
|
|
if (event->button == 2)
|
|
|
|
{
|
|
|
|
GtkWidget* parent = gtk_widget_get_parent (toolitem);
|
|
|
|
GtkAction* action = gtk_widget_get_action (parent);
|
|
|
|
|
2009-05-09 11:57:52 +00:00
|
|
|
return midori_browser_menu_middle_click_on_navigation_action (browser, action);
|
2009-05-03 19:35:05 +00:00
|
|
|
}
|
|
|
|
else if (event->button == 3)
|
2008-10-12 16:14:57 +00:00
|
|
|
{
|
2009-01-17 22:56:23 +00:00
|
|
|
midori_browser_toolbar_popup_context_menu_cb (
|
2009-01-31 03:09:35 +00:00
|
|
|
GTK_IS_BIN (toolitem) && gtk_bin_get_child (GTK_BIN (toolitem)) ?
|
2009-01-28 23:56:07 +00:00
|
|
|
gtk_widget_get_parent (toolitem) : toolitem,
|
2008-10-12 16:14:57 +00:00
|
|
|
event->x, event->y, event->button, browser);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-04-22 20:19:24 +00:00
|
|
|
static void
|
2008-10-12 16:14:57 +00:00
|
|
|
_midori_browser_set_toolbar_items (MidoriBrowser* browser,
|
|
|
|
const gchar* items)
|
2008-04-16 23:38:22 +00:00
|
|
|
{
|
2008-10-12 16:14:57 +00:00
|
|
|
gchar** names;
|
|
|
|
gchar** name;
|
|
|
|
GtkAction* action;
|
|
|
|
GtkWidget* toolitem;
|
|
|
|
|
2009-01-27 01:57:40 +00:00
|
|
|
#if HAVE_HILDON
|
|
|
|
items = "Bookmarks,Window,Back,Forward,ReloadStop,Location,Panel,Trash";
|
|
|
|
#endif
|
|
|
|
|
2008-10-12 16:14:57 +00:00
|
|
|
gtk_container_foreach (GTK_CONTAINER (browser->navigationbar),
|
|
|
|
(GtkCallback)gtk_widget_destroy, NULL);
|
|
|
|
|
|
|
|
names = g_strsplit (items ? items : "", ",", 0);
|
|
|
|
name = names;
|
|
|
|
while (*name)
|
|
|
|
{
|
|
|
|
action = _action_by_name (browser, *name);
|
|
|
|
if (action)
|
|
|
|
{
|
|
|
|
toolitem = gtk_action_create_tool_item (action);
|
2009-01-28 23:56:07 +00:00
|
|
|
if (gtk_bin_get_child (GTK_BIN (toolitem)))
|
|
|
|
g_signal_connect (gtk_bin_get_child (GTK_BIN (toolitem)),
|
|
|
|
"button-press-event",
|
|
|
|
G_CALLBACK (midori_browser_toolbar_item_button_press_event_cb),
|
|
|
|
browser);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_tool_item_set_use_drag_window (GTK_TOOL_ITEM (toolitem), TRUE);
|
|
|
|
g_signal_connect (toolitem,
|
|
|
|
"button-press-event",
|
|
|
|
G_CALLBACK (midori_browser_toolbar_item_button_press_event_cb),
|
|
|
|
browser);
|
|
|
|
}
|
2008-12-17 21:17:36 +00:00
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->navigationbar),
|
|
|
|
GTK_TOOL_ITEM (toolitem), -1);
|
|
|
|
}
|
2008-10-12 16:14:57 +00:00
|
|
|
name++;
|
|
|
|
}
|
|
|
|
g_strfreev (names);
|
|
|
|
}
|
2008-04-16 23:38:22 +00:00
|
|
|
|
2008-10-12 16:14:57 +00:00
|
|
|
static void
|
|
|
|
_midori_browser_update_settings (MidoriBrowser* browser)
|
|
|
|
{
|
2008-04-16 23:38:22 +00:00
|
|
|
gboolean remember_last_window_size;
|
|
|
|
gint last_window_width, last_window_height;
|
2009-01-20 22:27:19 +00:00
|
|
|
MidoriWindowState last_window_state;
|
2009-07-26 20:00:10 +00:00
|
|
|
gboolean compact_sidepanel, show_panel_controls, right_align_sidepanel;
|
2008-04-16 23:38:22 +00:00
|
|
|
gint last_panel_position, last_panel_page;
|
2009-02-28 13:05:01 +00:00
|
|
|
gboolean show_menubar, show_bookmarkbar;
|
2009-03-20 22:55:38 +00:00
|
|
|
gboolean show_panel, show_transferbar;
|
2009-07-17 02:28:53 +00:00
|
|
|
gchar* homepage;
|
2008-04-16 23:38:22 +00:00
|
|
|
MidoriToolbarStyle toolbar_style;
|
2008-10-12 16:14:57 +00:00
|
|
|
gchar* toolbar_items;
|
2008-04-16 23:38:22 +00:00
|
|
|
gint last_web_search;
|
2008-07-13 19:49:57 +00:00
|
|
|
gboolean close_buttons_on_tabs;
|
2008-10-12 16:14:57 +00:00
|
|
|
GdkScreen* screen;
|
|
|
|
gint default_width, default_height;
|
|
|
|
KatzeItem* item;
|
2008-07-13 19:49:57 +00:00
|
|
|
|
2009-04-14 17:44:48 +00:00
|
|
|
g_free (browser->news_aggregator);
|
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
g_object_get (browser->settings,
|
2008-04-16 23:38:22 +00:00
|
|
|
"remember-last-window-size", &remember_last_window_size,
|
|
|
|
"last-window-width", &last_window_width,
|
|
|
|
"last-window-height", &last_window_height,
|
2009-01-20 22:27:19 +00:00
|
|
|
"last-window-state", &last_window_state,
|
2008-10-21 22:01:01 +00:00
|
|
|
"compact-sidepanel", &compact_sidepanel,
|
2009-07-26 20:00:10 +00:00
|
|
|
"show-panel-controls", &show_panel_controls,
|
2009-02-22 02:51:10 +00:00
|
|
|
"right-align-sidepanel", &right_align_sidepanel,
|
2008-04-16 23:38:22 +00:00
|
|
|
"last-panel-position", &last_panel_position,
|
|
|
|
"last-panel-page", &last_panel_page,
|
2008-10-12 20:09:49 +00:00
|
|
|
"show-menubar", &show_menubar,
|
2009-02-28 13:05:01 +00:00
|
|
|
"show-navigationbar", &browser->show_navigationbar,
|
2008-04-16 23:38:22 +00:00
|
|
|
"show-bookmarkbar", &show_bookmarkbar,
|
|
|
|
"show-panel", &show_panel,
|
2009-03-20 22:55:38 +00:00
|
|
|
"show-transferbar", &show_transferbar,
|
2009-02-28 13:05:01 +00:00
|
|
|
"show-statusbar", &browser->show_statusbar,
|
2009-07-17 02:28:53 +00:00
|
|
|
"homepage", &homepage,
|
2009-05-10 14:07:28 +00:00
|
|
|
"speed-dial-in-new-tabs", &browser->speed_dial_in_new_tabs,
|
2008-04-16 23:38:22 +00:00
|
|
|
"toolbar-style", &toolbar_style,
|
2008-10-12 16:14:57 +00:00
|
|
|
"toolbar-items", &toolbar_items,
|
2008-04-16 23:38:22 +00:00
|
|
|
"last-web-search", &last_web_search,
|
2009-04-18 20:41:37 +00:00
|
|
|
"location-entry-search", &browser->location_entry_search,
|
2008-07-13 19:49:57 +00:00
|
|
|
"close-buttons-on-tabs", &close_buttons_on_tabs,
|
2009-02-28 13:05:01 +00:00
|
|
|
"progress-in-location", &browser->progress_in_location,
|
|
|
|
"remember-last-visited-pages", &browser->remember_last_visited_pages,
|
2009-04-14 17:44:48 +00:00
|
|
|
"news-aggregator", &browser->news_aggregator,
|
2008-04-16 23:38:22 +00:00
|
|
|
NULL);
|
|
|
|
|
2008-10-12 16:14:57 +00:00
|
|
|
screen = gtk_window_get_screen (GTK_WINDOW (browser));
|
|
|
|
default_width = gdk_screen_get_width (screen) / 1.7;
|
|
|
|
default_height = gdk_screen_get_height (screen) / 1.7;
|
2008-04-16 23:38:22 +00:00
|
|
|
|
|
|
|
if (remember_last_window_size)
|
|
|
|
{
|
|
|
|
if (last_window_width && last_window_height)
|
|
|
|
gtk_window_set_default_size (GTK_WINDOW (browser),
|
|
|
|
last_window_width, last_window_height);
|
|
|
|
else
|
|
|
|
gtk_window_set_default_size (GTK_WINDOW (browser),
|
|
|
|
default_width, default_height);
|
2009-01-20 22:27:19 +00:00
|
|
|
switch (last_window_state)
|
|
|
|
{
|
|
|
|
case MIDORI_WINDOW_MINIMIZED:
|
|
|
|
gtk_window_iconify (GTK_WINDOW (browser));
|
|
|
|
break;
|
|
|
|
case MIDORI_WINDOW_MAXIMIZED:
|
|
|
|
gtk_window_maximize (GTK_WINDOW (browser));
|
|
|
|
break;
|
|
|
|
case MIDORI_WINDOW_FULLSCREEN:
|
|
|
|
gtk_window_fullscreen (GTK_WINDOW (browser));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
;/* Do nothing. */
|
|
|
|
}
|
2008-04-16 23:38:22 +00:00
|
|
|
}
|
|
|
|
|
2008-04-22 20:19:24 +00:00
|
|
|
_midori_browser_set_toolbar_style (browser, toolbar_style);
|
2008-10-03 23:45:17 +00:00
|
|
|
_toggle_tabbar_smartly (browser);
|
2008-10-12 16:14:57 +00:00
|
|
|
_midori_browser_set_toolbar_items (browser, toolbar_items);
|
2008-04-16 23:38:22 +00:00
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
if (browser->search_engines)
|
2008-06-15 02:02:56 +00:00
|
|
|
{
|
2009-04-18 20:41:37 +00:00
|
|
|
guint i;
|
|
|
|
|
2008-08-25 23:19:38 +00:00
|
|
|
item = katze_array_get_nth_item (browser->search_engines,
|
|
|
|
last_web_search);
|
2008-08-23 16:32:53 +00:00
|
|
|
if (item)
|
2008-10-05 21:25:02 +00:00
|
|
|
midori_search_action_set_current_item (MIDORI_SEARCH_ACTION (
|
|
|
|
_action_by_name (browser, "Search")), item);
|
2009-04-18 20:41:37 +00:00
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while ((item = katze_array_get_nth_item (browser->search_engines, i++)))
|
|
|
|
if (!g_strcmp0 (katze_item_get_uri (item), browser->location_entry_search))
|
|
|
|
{
|
|
|
|
midori_search_action_set_default_item (MIDORI_SEARCH_ACTION (
|
|
|
|
_action_by_name (browser, "Search")), item);
|
|
|
|
break;
|
|
|
|
}
|
2008-06-15 02:02:56 +00:00
|
|
|
}
|
2008-04-16 23:38:22 +00:00
|
|
|
|
2009-07-26 20:00:10 +00:00
|
|
|
g_object_set (browser->panel, "show-titles", !compact_sidepanel,
|
|
|
|
"show-controls", show_panel_controls,
|
|
|
|
"right-aligned", right_align_sidepanel, NULL);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_paned_set_position (GTK_PANED (gtk_widget_get_parent (browser->panel)),
|
2008-04-16 23:38:22 +00:00
|
|
|
last_panel_position);
|
2009-06-22 22:25:09 +00:00
|
|
|
/* The browser may not yet be visible, which means that we can't set the
|
|
|
|
page. So we set it in midori_browser_size_allocate_cb */
|
|
|
|
if (GTK_WIDGET_VISIBLE (browser))
|
|
|
|
midori_panel_set_current_page (MIDORI_PANEL (browser->panel), last_panel_page);
|
|
|
|
else
|
|
|
|
g_object_set_data (G_OBJECT (browser), "last-page",
|
|
|
|
GINT_TO_POINTER (last_panel_page));
|
2008-04-16 23:38:22 +00:00
|
|
|
|
2008-10-12 20:09:49 +00:00
|
|
|
_action_set_active (browser, "Menubar", show_menubar);
|
2009-02-28 13:05:01 +00:00
|
|
|
_action_set_active (browser, "Navigationbar", browser->show_navigationbar);
|
2008-04-16 23:38:22 +00:00
|
|
|
_action_set_active (browser, "Bookmarkbar", show_bookmarkbar);
|
|
|
|
_action_set_active (browser, "Panel", show_panel);
|
2009-03-20 22:55:38 +00:00
|
|
|
#if WEBKIT_CHECK_VERSION (1, 1, 3)
|
|
|
|
_action_set_active (browser, "Transferbar", show_transferbar);
|
|
|
|
#endif
|
2009-02-28 13:05:01 +00:00
|
|
|
_action_set_active (browser, "Statusbar", browser->show_statusbar);
|
2008-04-16 23:38:22 +00:00
|
|
|
|
2009-07-19 16:28:50 +00:00
|
|
|
sokoke_widget_set_visible (GTK_WIDGET (browser->homepage),
|
|
|
|
homepage && *homepage);
|
2009-07-17 02:28:53 +00:00
|
|
|
|
|
|
|
g_free (homepage);
|
2008-10-12 16:14:57 +00:00
|
|
|
g_free (toolbar_items);
|
2008-04-16 23:38:22 +00:00
|
|
|
}
|
|
|
|
|
2008-04-22 20:19:24 +00:00
|
|
|
static void
|
|
|
|
midori_browser_settings_notify (MidoriWebSettings* web_settings,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-07-13 19:49:57 +00:00
|
|
|
const gchar* name;
|
2008-04-22 20:19:24 +00:00
|
|
|
GValue value = {0, };
|
|
|
|
|
2008-07-13 19:49:57 +00:00
|
|
|
name = g_intern_string (pspec->name);
|
2008-04-22 20:19:24 +00:00
|
|
|
g_value_init (&value, pspec->value_type);
|
2008-10-17 21:15:37 +00:00
|
|
|
g_object_get_property (G_OBJECT (web_settings), name, &value);
|
2008-04-22 20:19:24 +00:00
|
|
|
|
|
|
|
if (name == g_intern_string ("toolbar-style"))
|
|
|
|
_midori_browser_set_toolbar_style (browser, g_value_get_enum (&value));
|
2008-10-12 16:14:57 +00:00
|
|
|
else if (name == g_intern_string ("toolbar-items"))
|
|
|
|
_midori_browser_set_toolbar_items (browser, g_value_get_string (&value));
|
2008-10-21 22:01:01 +00:00
|
|
|
else if (name == g_intern_string ("compact-sidepanel"))
|
2009-08-09 13:07:09 +00:00
|
|
|
{
|
|
|
|
g_signal_handlers_block_by_func (browser->panel,
|
|
|
|
midori_panel_notify_show_titles_cb, browser);
|
2009-07-26 20:00:10 +00:00
|
|
|
g_object_set (browser->panel, "show-titles",
|
|
|
|
!g_value_get_boolean (&value), NULL);
|
2009-08-09 13:07:09 +00:00
|
|
|
g_signal_handlers_unblock_by_func (browser->panel,
|
|
|
|
midori_panel_notify_show_titles_cb, browser);
|
|
|
|
}
|
|
|
|
else if (name == g_intern_string ("show-panel-controls"))
|
|
|
|
{
|
|
|
|
g_signal_handlers_block_by_func (browser->panel,
|
|
|
|
midori_panel_notify_show_controls_cb, browser);
|
2009-07-26 20:00:10 +00:00
|
|
|
g_object_set (browser->panel, "show-controls",
|
|
|
|
g_value_get_boolean (&value), NULL);
|
2009-08-09 13:07:09 +00:00
|
|
|
g_signal_handlers_unblock_by_func (browser->panel,
|
|
|
|
midori_panel_notify_show_controls_cb, browser);
|
|
|
|
}
|
2008-10-03 23:45:17 +00:00
|
|
|
else if (name == g_intern_string ("always-show-tabbar"))
|
|
|
|
_toggle_tabbar_smartly (browser);
|
2009-02-28 13:05:01 +00:00
|
|
|
else if (name == g_intern_string ("show-navigationbar"))
|
|
|
|
browser->show_navigationbar = g_value_get_boolean (&value);
|
|
|
|
else if (name == g_intern_string ("show-statusbar"))
|
|
|
|
browser->show_statusbar = g_value_get_boolean (&value);
|
2009-05-10 14:07:28 +00:00
|
|
|
else if (name == g_intern_string ("speed-dial-in-new-tabs"))
|
|
|
|
browser->speed_dial_in_new_tabs = g_value_get_boolean (&value);
|
2009-02-28 13:05:01 +00:00
|
|
|
else if (name == g_intern_string ("progress-in-location"))
|
|
|
|
browser->progress_in_location = g_value_get_boolean (&value);
|
2009-07-17 02:28:53 +00:00
|
|
|
else if (name == g_intern_string ("homepage"))
|
|
|
|
sokoke_widget_set_visible (GTK_WIDGET (browser->homepage),
|
2009-07-19 16:28:50 +00:00
|
|
|
g_value_get_string (&value) && *g_value_get_string (&value));
|
2009-04-18 21:26:54 +00:00
|
|
|
else if (name == g_intern_string ("search-engines-in-completion"))
|
|
|
|
{
|
|
|
|
if (g_value_get_boolean (&value))
|
|
|
|
midori_location_action_set_search_engines (MIDORI_LOCATION_ACTION (
|
|
|
|
_action_by_name (browser, "Location")), browser->search_engines);
|
|
|
|
else
|
|
|
|
midori_location_action_set_search_engines (MIDORI_LOCATION_ACTION (
|
|
|
|
_action_by_name (browser, "Location")), NULL);
|
|
|
|
}
|
2009-04-18 20:41:37 +00:00
|
|
|
else if (name == g_intern_string ("location-entry-search"))
|
|
|
|
{
|
|
|
|
katze_assign (browser->location_entry_search, g_value_dup_string (&value));
|
|
|
|
}
|
2009-02-28 13:05:01 +00:00
|
|
|
else if (name == g_intern_string ("remember-last-visited-pages"))
|
|
|
|
browser->remember_last_visited_pages = g_value_get_boolean (&value);
|
2009-04-14 17:44:48 +00:00
|
|
|
else if (name == g_intern_string ("news-aggregator"))
|
|
|
|
{
|
|
|
|
katze_assign (browser->news_aggregator, g_value_dup_string (&value));
|
|
|
|
}
|
2008-04-22 20:19:24 +00:00
|
|
|
else if (!g_object_class_find_property (G_OBJECT_GET_CLASS (web_settings),
|
|
|
|
name))
|
2008-04-25 19:31:57 +00:00
|
|
|
g_warning (_("Unexpected setting '%s'"), name);
|
2008-04-22 20:19:24 +00:00
|
|
|
g_value_unset (&value);
|
|
|
|
}
|
|
|
|
|
2008-10-26 21:22:26 +00:00
|
|
|
static void
|
2009-07-17 15:36:03 +00:00
|
|
|
browser_bookmarks_add_item_cb (KatzeArray* array,
|
|
|
|
KatzeItem* item,
|
|
|
|
GtkWidget* toolbar)
|
2008-10-26 21:22:26 +00:00
|
|
|
{
|
2009-07-17 15:36:03 +00:00
|
|
|
MidoriBrowser* browser = midori_browser_get_for_widget (toolbar);
|
2008-10-26 21:22:26 +00:00
|
|
|
GtkToolItem* toolitem;
|
|
|
|
|
|
|
|
toolitem = katze_array_action_create_tool_item_for (
|
|
|
|
KATZE_ARRAY_ACTION (_action_by_name (browser, "Bookmarks")), item);
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (toolitem), "KatzeItem", item);
|
|
|
|
if (!KATZE_IS_ARRAY (item) && katze_item_get_uri (item))
|
|
|
|
g_signal_connect (toolitem, "clicked",
|
|
|
|
G_CALLBACK (midori_browser_menu_bookmarks_item_activate_cb),
|
|
|
|
browser);
|
|
|
|
if (KATZE_IS_ARRAY (item) || katze_item_get_uri (item))
|
|
|
|
{
|
|
|
|
g_signal_connect (gtk_bin_get_child (GTK_BIN (toolitem)),
|
|
|
|
"button-press-event",
|
|
|
|
G_CALLBACK (midori_browser_bookmarkbar_item_button_press_event_cb),
|
|
|
|
browser);
|
|
|
|
g_object_set_data (G_OBJECT (gtk_bin_get_child (GTK_BIN (toolitem))),
|
|
|
|
"KatzeItem", item);
|
|
|
|
}
|
2009-01-28 23:56:07 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_tool_item_set_use_drag_window (toolitem, TRUE);
|
|
|
|
g_signal_connect (toolitem,
|
|
|
|
"button-press-event",
|
|
|
|
G_CALLBACK (midori_browser_bookmarkbar_item_button_press_event_cb),
|
|
|
|
browser);
|
|
|
|
g_object_set_data (G_OBJECT (toolitem), "KatzeItem", item);
|
|
|
|
}
|
2008-10-26 21:22:26 +00:00
|
|
|
gtk_widget_show (GTK_WIDGET (toolitem));
|
2009-07-17 15:36:03 +00:00
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
|
2008-10-26 21:22:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
browser_bookmarks_remove_item_cb (KatzeArray* array,
|
|
|
|
KatzeItem* removed_item,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GList* children;
|
|
|
|
GtkWidget* toolitem;
|
|
|
|
KatzeItem* item;
|
|
|
|
|
|
|
|
children = gtk_container_get_children (GTK_CONTAINER (browser->bookmarkbar));
|
|
|
|
while (children != NULL)
|
|
|
|
{
|
|
|
|
toolitem = GTK_WIDGET (children->data);
|
|
|
|
item = (KatzeItem*)g_object_get_data (G_OBJECT (toolitem), "KatzeItem");
|
|
|
|
if (item == removed_item)
|
|
|
|
gtk_widget_destroy (toolitem);
|
|
|
|
children = g_list_next (children);
|
|
|
|
}
|
2008-12-21 19:44:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_set_bookmarks (MidoriBrowser* browser,
|
|
|
|
KatzeArray* bookmarks)
|
2008-09-03 00:28:54 +00:00
|
|
|
{
|
2009-03-31 19:19:18 +00:00
|
|
|
guint i;
|
2008-10-01 02:00:16 +00:00
|
|
|
KatzeItem* item;
|
2008-09-03 00:28:54 +00:00
|
|
|
|
2008-12-21 19:44:31 +00:00
|
|
|
if (browser->bookmarks == bookmarks)
|
|
|
|
return;
|
|
|
|
|
2009-08-19 21:51:59 +00:00
|
|
|
if (browser->bookmarks)
|
|
|
|
{
|
|
|
|
g_signal_handlers_disconnect_by_func (
|
|
|
|
browser->bookmarks, browser_bookmarks_add_item_cb, browser->bookmarkbar);
|
|
|
|
g_signal_handlers_disconnect_by_func (
|
2009-09-16 21:48:06 +00:00
|
|
|
browser->bookmarks, browser_bookmarks_remove_item_cb, browser);
|
2009-08-19 21:51:59 +00:00
|
|
|
}
|
|
|
|
|
2008-12-21 19:44:31 +00:00
|
|
|
if (bookmarks)
|
|
|
|
g_object_ref (bookmarks);
|
|
|
|
katze_object_assign (browser->bookmarks, bookmarks);
|
|
|
|
|
|
|
|
g_object_set (_action_by_name (browser, "Bookmarks"), "array",
|
|
|
|
browser->bookmarks, NULL);
|
2008-09-03 00:28:54 +00:00
|
|
|
|
|
|
|
_action_set_sensitive (browser, "BookmarkAdd", FALSE);
|
2009-04-10 20:28:36 +00:00
|
|
|
_action_set_sensitive (browser, "BookmarkFolderAdd", FALSE);
|
2008-09-03 00:28:54 +00:00
|
|
|
|
|
|
|
if (!browser->bookmarks)
|
|
|
|
return;
|
|
|
|
|
2009-03-31 19:19:18 +00:00
|
|
|
i = 0;
|
|
|
|
while ((item = katze_array_get_nth_item (browser->bookmarks, i++)))
|
2009-07-17 15:36:03 +00:00
|
|
|
browser_bookmarks_add_item_cb (browser->bookmarks, item, browser->bookmarkbar);
|
2008-10-26 21:22:26 +00:00
|
|
|
g_signal_connect (browser->bookmarks, "add-item",
|
2009-07-17 15:36:03 +00:00
|
|
|
G_CALLBACK (browser_bookmarks_add_item_cb), browser->bookmarkbar);
|
2008-10-26 21:22:26 +00:00
|
|
|
g_signal_connect (browser->bookmarks, "remove-item",
|
|
|
|
G_CALLBACK (browser_bookmarks_remove_item_cb), browser);
|
2008-09-03 00:28:54 +00:00
|
|
|
|
|
|
|
_action_set_sensitive (browser, "BookmarkAdd", TRUE);
|
2009-04-10 20:28:36 +00:00
|
|
|
_action_set_sensitive (browser, "BookmarkFolderAdd", TRUE);
|
2008-09-03 00:28:54 +00:00
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
midori_browser_set_property (GObject* object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue* value,
|
|
|
|
GParamSpec* pspec)
|
|
|
|
{
|
|
|
|
MidoriBrowser* browser = MIDORI_BROWSER (object);
|
2008-06-15 23:13:27 +00:00
|
|
|
guint last_web_search;
|
2008-08-23 16:32:53 +00:00
|
|
|
KatzeItem* item;
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2008-07-23 18:17:13 +00:00
|
|
|
case PROP_URI:
|
2008-10-20 06:50:16 +00:00
|
|
|
midori_browser_set_current_uri (browser, g_value_get_string (value));
|
2008-07-23 18:17:13 +00:00
|
|
|
break;
|
2008-05-02 20:30:26 +00:00
|
|
|
case PROP_TAB:
|
|
|
|
midori_browser_set_current_tab (browser, g_value_get_object (value));
|
|
|
|
break;
|
2008-03-10 21:26:09 +00:00
|
|
|
case PROP_STATUSBAR_TEXT:
|
|
|
|
_midori_browser_set_statusbar_text (browser, g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
case PROP_SETTINGS:
|
2008-06-19 18:39:00 +00:00
|
|
|
if (browser->settings)
|
|
|
|
g_signal_handlers_disconnect_by_func (browser->settings,
|
2008-04-22 20:19:24 +00:00
|
|
|
midori_browser_settings_notify,
|
|
|
|
browser);
|
2008-10-27 03:23:41 +00:00
|
|
|
katze_object_assign (browser->settings, g_value_dup_object (value));
|
2009-01-01 02:52:43 +00:00
|
|
|
if (browser->settings)
|
|
|
|
{
|
|
|
|
_midori_browser_update_settings (browser);
|
|
|
|
g_signal_connect (browser->settings, "notify",
|
|
|
|
G_CALLBACK (midori_browser_settings_notify), browser);
|
|
|
|
}
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_container_foreach (GTK_CONTAINER (browser->notebook),
|
2008-09-26 21:13:46 +00:00
|
|
|
(GtkCallback) midori_view_set_settings, browser->settings);
|
2008-03-10 21:26:09 +00:00
|
|
|
break;
|
2008-09-03 00:28:54 +00:00
|
|
|
case PROP_BOOKMARKS:
|
2008-12-21 19:44:31 +00:00
|
|
|
midori_browser_set_bookmarks (browser, g_value_get_object (value));
|
2008-09-03 00:28:54 +00:00
|
|
|
break;
|
2008-03-10 21:26:09 +00:00
|
|
|
case PROP_TRASH:
|
2008-11-09 18:26:48 +00:00
|
|
|
/* FIXME: Disconnect handlers */
|
2008-10-27 03:23:41 +00:00
|
|
|
katze_object_assign (browser->trash, g_value_dup_object (value));
|
2008-10-10 20:31:37 +00:00
|
|
|
g_object_set (_action_by_name (browser, "Trash"), "array",
|
|
|
|
browser->trash, NULL);
|
2008-06-14 00:23:33 +00:00
|
|
|
/* FIXME: Connect to updates */
|
2008-03-10 21:26:09 +00:00
|
|
|
_midori_browser_update_actions (browser);
|
|
|
|
break;
|
2008-06-15 02:02:56 +00:00
|
|
|
case PROP_SEARCH_ENGINES:
|
2008-11-09 18:26:48 +00:00
|
|
|
/* FIXME: Disconnect handlers */
|
2008-10-27 03:23:41 +00:00
|
|
|
katze_object_assign (browser->search_engines, g_value_dup_object (value));
|
2009-04-18 21:26:54 +00:00
|
|
|
if (browser->settings)
|
|
|
|
{
|
|
|
|
if (katze_object_get_boolean (browser->settings,
|
|
|
|
"search-engines-in-completion"))
|
|
|
|
midori_location_action_set_search_engines (MIDORI_LOCATION_ACTION (
|
|
|
|
_action_by_name (browser, "Location")), browser->search_engines);
|
|
|
|
else
|
|
|
|
midori_location_action_set_search_engines (MIDORI_LOCATION_ACTION (
|
|
|
|
_action_by_name (browser, "Location")), NULL);
|
|
|
|
}
|
2008-10-05 21:25:02 +00:00
|
|
|
midori_search_action_set_search_engines (MIDORI_SEARCH_ACTION (
|
|
|
|
_action_by_name (browser, "Search")), browser->search_engines);
|
2008-06-15 02:02:56 +00:00
|
|
|
/* FIXME: Connect to updates */
|
2008-06-19 18:39:00 +00:00
|
|
|
if (browser->settings)
|
2008-06-15 23:13:27 +00:00
|
|
|
{
|
2009-04-18 20:41:37 +00:00
|
|
|
guint i;
|
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
g_object_get (browser->settings, "last-web-search",
|
2008-06-15 23:13:27 +00:00
|
|
|
&last_web_search, NULL);
|
2008-08-25 23:19:38 +00:00
|
|
|
item = katze_array_get_nth_item (browser->search_engines,
|
|
|
|
last_web_search);
|
2008-10-05 21:25:02 +00:00
|
|
|
midori_search_action_set_current_item (MIDORI_SEARCH_ACTION (
|
|
|
|
_action_by_name (browser, "Search")), item);
|
2009-04-18 20:41:37 +00:00
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while ((item = katze_array_get_nth_item (browser->search_engines, i++)))
|
|
|
|
if (!g_strcmp0 (katze_item_get_uri (item), browser->location_entry_search))
|
|
|
|
{
|
|
|
|
midori_search_action_set_default_item (MIDORI_SEARCH_ACTION (
|
|
|
|
_action_by_name (browser, "Search")), item);
|
|
|
|
break;
|
|
|
|
}
|
2008-06-15 23:13:27 +00:00
|
|
|
}
|
2008-06-15 02:02:56 +00:00
|
|
|
break;
|
2008-10-07 00:19:33 +00:00
|
|
|
case PROP_HISTORY:
|
2008-12-21 18:21:04 +00:00
|
|
|
midori_browser_set_history (browser, g_value_get_object (value));
|
2008-10-07 00:19:33 +00:00
|
|
|
break;
|
2009-06-22 21:48:41 +00:00
|
|
|
case PROP_SHOW_TABS:
|
|
|
|
browser->show_tabs = g_value_get_boolean (value);
|
|
|
|
if (browser->show_tabs)
|
|
|
|
_toggle_tabbar_smartly (browser);
|
|
|
|
else
|
2009-07-13 20:15:45 +00:00
|
|
|
{
|
2009-06-22 21:48:41 +00:00
|
|
|
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (browser->notebook), FALSE);
|
2009-07-13 20:15:45 +00:00
|
|
|
gtk_notebook_set_show_border (GTK_NOTEBOOK (browser->notebook), FALSE);
|
|
|
|
}
|
2009-06-22 21:48:41 +00:00
|
|
|
break;
|
2008-03-10 21:26:09 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_get_property (GObject* object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue* value,
|
|
|
|
GParamSpec* pspec)
|
|
|
|
{
|
|
|
|
MidoriBrowser* browser = MIDORI_BROWSER (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2008-05-02 20:30:26 +00:00
|
|
|
case PROP_MENUBAR:
|
2008-06-19 18:39:00 +00:00
|
|
|
g_value_set_object (value, browser->menubar);
|
2008-05-02 20:30:26 +00:00
|
|
|
break;
|
|
|
|
case PROP_NAVIGATIONBAR:
|
2008-06-19 18:39:00 +00:00
|
|
|
g_value_set_object (value, browser->navigationbar);
|
2008-05-02 20:30:26 +00:00
|
|
|
break;
|
2008-11-18 01:02:59 +00:00
|
|
|
case PROP_NOTEBOOK:
|
|
|
|
g_value_set_object (value, browser->notebook);
|
|
|
|
break;
|
|
|
|
case PROP_PANEL:
|
|
|
|
g_value_set_object (value, browser->panel);
|
|
|
|
break;
|
2008-07-23 18:17:13 +00:00
|
|
|
case PROP_URI:
|
|
|
|
g_value_set_string (value, midori_browser_get_current_uri (browser));
|
|
|
|
break;
|
2008-05-02 20:30:26 +00:00
|
|
|
case PROP_TAB:
|
|
|
|
g_value_set_object (value, midori_browser_get_current_tab (browser));
|
|
|
|
break;
|
2009-02-22 12:52:04 +00:00
|
|
|
case PROP_LOAD_STATUS:
|
|
|
|
{
|
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
|
|
|
if (view)
|
|
|
|
g_value_set_enum (value,
|
|
|
|
midori_view_get_load_status (MIDORI_VIEW (view)));
|
|
|
|
else
|
|
|
|
g_value_set_enum (value, MIDORI_LOAD_FINISHED);
|
|
|
|
break;
|
|
|
|
}
|
2008-05-02 20:30:26 +00:00
|
|
|
case PROP_STATUSBAR:
|
2008-06-19 18:39:00 +00:00
|
|
|
g_value_set_object (value, browser->statusbar);
|
2008-05-02 20:30:26 +00:00
|
|
|
break;
|
2008-03-10 21:26:09 +00:00
|
|
|
case PROP_STATUSBAR_TEXT:
|
2008-06-19 18:39:00 +00:00
|
|
|
g_value_set_string (value, browser->statusbar_text);
|
2008-03-10 21:26:09 +00:00
|
|
|
break;
|
|
|
|
case PROP_SETTINGS:
|
2008-06-19 18:39:00 +00:00
|
|
|
g_value_set_object (value, browser->settings);
|
2008-03-10 21:26:09 +00:00
|
|
|
break;
|
2008-09-03 00:28:54 +00:00
|
|
|
case PROP_BOOKMARKS:
|
|
|
|
g_value_set_object (value, browser->bookmarks);
|
|
|
|
break;
|
2008-03-10 21:26:09 +00:00
|
|
|
case PROP_TRASH:
|
2008-06-19 18:39:00 +00:00
|
|
|
g_value_set_object (value, browser->trash);
|
2008-03-10 21:26:09 +00:00
|
|
|
break;
|
2008-06-15 02:02:56 +00:00
|
|
|
case PROP_SEARCH_ENGINES:
|
2008-06-19 18:39:00 +00:00
|
|
|
g_value_set_object (value, browser->search_engines);
|
2008-06-15 02:02:56 +00:00
|
|
|
break;
|
2008-10-07 00:19:33 +00:00
|
|
|
case PROP_HISTORY:
|
|
|
|
g_value_set_object (value, browser->history);
|
|
|
|
break;
|
2009-06-22 21:48:41 +00:00
|
|
|
case PROP_SHOW_TABS:
|
|
|
|
g_value_set_boolean (value, browser->show_tabs);
|
|
|
|
break;
|
2008-03-10 21:26:09 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* midori_browser_new:
|
|
|
|
*
|
|
|
|
* Creates a new browser widget.
|
|
|
|
*
|
2008-05-22 22:17:10 +00:00
|
|
|
* A browser is a window with a menubar, toolbars, a notebook, panels
|
|
|
|
* and a statusbar. You should mostly treat it as an opaque widget.
|
2008-03-10 21:26:09 +00:00
|
|
|
*
|
|
|
|
* Return value: a new #MidoriBrowser
|
|
|
|
**/
|
2008-05-22 22:17:10 +00:00
|
|
|
MidoriBrowser*
|
2008-03-10 21:26:09 +00:00
|
|
|
midori_browser_new (void)
|
|
|
|
{
|
|
|
|
MidoriBrowser* browser = g_object_new (MIDORI_TYPE_BROWSER,
|
|
|
|
NULL);
|
|
|
|
|
2008-05-22 22:17:10 +00:00
|
|
|
return browser;
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-05-31 22:21:08 +00:00
|
|
|
* midori_browser_add_tab:
|
2008-03-10 21:26:09 +00:00
|
|
|
* @browser: a #MidoriBrowser
|
2008-09-26 21:13:46 +00:00
|
|
|
* @widget: a view
|
2008-03-10 21:26:09 +00:00
|
|
|
*
|
2008-09-26 21:13:46 +00:00
|
|
|
* Appends a view in the form of a new tab and creates an
|
2008-03-10 21:26:09 +00:00
|
|
|
* according item in the Window menu.
|
|
|
|
*
|
|
|
|
* Return value: the index of the new tab, or -1 in case of an error
|
|
|
|
**/
|
|
|
|
gint
|
2008-05-31 22:21:08 +00:00
|
|
|
midori_browser_add_tab (MidoriBrowser* browser,
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-11-23 00:44:40 +00:00
|
|
|
g_return_val_if_fail (MIDORI_IS_BROWSER (browser), -1);
|
|
|
|
g_return_val_if_fail (GTK_IS_WIDGET (view), -1);
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
g_signal_emit (browser, signals[ADD_TAB], 0, view);
|
|
|
|
return gtk_notebook_page_num (GTK_NOTEBOOK (browser->notebook), view);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* midori_browser_remove_tab:
|
|
|
|
* @browser: a #MidoriBrowser
|
2008-09-26 21:13:46 +00:00
|
|
|
* @widget: a view
|
2008-03-10 21:26:09 +00:00
|
|
|
*
|
2008-09-26 21:13:46 +00:00
|
|
|
* Removes an existing view from the browser,
|
|
|
|
* including an associated menu item.
|
2008-03-10 21:26:09 +00:00
|
|
|
**/
|
|
|
|
void
|
|
|
|
midori_browser_remove_tab (MidoriBrowser* browser,
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-11-23 00:44:40 +00:00
|
|
|
g_return_if_fail (MIDORI_IS_BROWSER (browser));
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (view));
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
g_signal_emit (browser, signals[REMOVE_TAB], 0, view);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
/**
|
|
|
|
* midori_browser_add_item:
|
|
|
|
* @browser: a #MidoriBrowser
|
|
|
|
* @item: an item
|
|
|
|
*
|
|
|
|
* Appends a new view as described by @item.
|
|
|
|
*
|
|
|
|
* Return value: the index of the new tab, or -1 in case of an error
|
|
|
|
**/
|
|
|
|
gint
|
|
|
|
midori_browser_add_item (MidoriBrowser* browser,
|
|
|
|
KatzeItem* item)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
const gchar* uri;
|
|
|
|
const gchar* title;
|
|
|
|
GtkWidget* view;
|
2009-07-18 14:41:13 +00:00
|
|
|
gint page;
|
|
|
|
KatzeItem* proxy_item;
|
|
|
|
GList* keys;
|
2008-09-26 21:13:46 +00:00
|
|
|
|
2008-11-23 00:44:40 +00:00
|
|
|
g_return_val_if_fail (MIDORI_IS_BROWSER (browser), -1);
|
2008-09-26 21:13:46 +00:00
|
|
|
g_return_val_if_fail (KATZE_IS_ITEM (item), -1);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
uri = katze_item_get_uri (item);
|
|
|
|
title = katze_item_get_name (item);
|
|
|
|
view = g_object_new (MIDORI_TYPE_VIEW,
|
|
|
|
"title", title,
|
|
|
|
"settings", browser->settings,
|
2009-01-17 22:56:23 +00:00
|
|
|
"net", browser->net,
|
2008-09-26 21:13:46 +00:00
|
|
|
NULL);
|
|
|
|
midori_view_set_uri (MIDORI_VIEW (view), uri);
|
|
|
|
gtk_widget_show (view);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2009-07-18 14:41:13 +00:00
|
|
|
page = midori_browser_add_tab (browser, view);
|
|
|
|
proxy_item = midori_view_get_proxy_item (MIDORI_VIEW (view));
|
|
|
|
if ((keys = katze_item_get_meta_keys (item)))
|
|
|
|
{
|
|
|
|
guint i = 0;
|
|
|
|
const gchar* key;
|
|
|
|
while ((key = g_list_nth_data (keys, i++)))
|
|
|
|
katze_item_set_meta_string (proxy_item, key,
|
|
|
|
katze_item_get_meta_string (item, key));
|
|
|
|
g_list_free (keys);
|
|
|
|
}
|
|
|
|
return page;
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-05-31 22:21:08 +00:00
|
|
|
* midori_browser_add_uri:
|
2008-04-18 00:40:53 +00:00
|
|
|
* @browser: a #MidoriBrowser
|
|
|
|
* @uri: an URI
|
2008-03-10 21:26:09 +00:00
|
|
|
*
|
2008-09-26 21:13:46 +00:00
|
|
|
* Appends an uri in the form of a new view.
|
2008-03-10 21:26:09 +00:00
|
|
|
*
|
2008-09-26 21:13:46 +00:00
|
|
|
* Return value: the index of the new view, or -1
|
2008-03-10 21:26:09 +00:00
|
|
|
**/
|
|
|
|
gint
|
2008-05-31 22:21:08 +00:00
|
|
|
midori_browser_add_uri (MidoriBrowser* browser,
|
|
|
|
const gchar* uri)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view;
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-11-23 00:44:40 +00:00
|
|
|
g_return_val_if_fail (MIDORI_IS_BROWSER (browser), -1);
|
|
|
|
g_return_val_if_fail (uri != NULL, -1);
|
|
|
|
|
2009-02-28 13:05:01 +00:00
|
|
|
if (browser->settings)
|
|
|
|
view = g_object_new (MIDORI_TYPE_VIEW, "settings", browser->settings,
|
|
|
|
"net", browser->net, NULL);
|
|
|
|
else
|
|
|
|
view = midori_view_new (browser->net);
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_view_set_uri (MIDORI_VIEW (view), uri);
|
|
|
|
gtk_widget_show (view);
|
2008-07-23 18:17:13 +00:00
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
return midori_browser_add_tab (browser, view);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2008-04-25 19:31:57 +00:00
|
|
|
/**
|
|
|
|
* midori_browser_activate_action:
|
|
|
|
* @browser: a #MidoriBrowser
|
|
|
|
* @name: name of the action
|
|
|
|
*
|
|
|
|
* Activates the specified action.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
midori_browser_activate_action (MidoriBrowser* browser,
|
|
|
|
const gchar* name)
|
|
|
|
{
|
2008-11-23 00:44:40 +00:00
|
|
|
g_return_if_fail (MIDORI_IS_BROWSER (browser));
|
|
|
|
g_return_if_fail (name != NULL);
|
|
|
|
|
2008-06-15 02:02:56 +00:00
|
|
|
g_signal_emit (browser, signals[ACTIVATE_ACTION], 0, name);
|
2008-04-25 19:31:57 +00:00
|
|
|
}
|
|
|
|
|
2009-02-28 03:15:16 +00:00
|
|
|
/**
|
|
|
|
* midori_browser_get_action_group:
|
|
|
|
* @browser: a #MidoriBrowser
|
|
|
|
*
|
|
|
|
* Retrieves the action group holding all actions used
|
|
|
|
* by the browser. It allows obtaining individual
|
|
|
|
* actions and adding new actions.
|
|
|
|
*
|
|
|
|
* Return value: the action group of the browser
|
|
|
|
*
|
|
|
|
* Since: 0.1.4
|
|
|
|
**/
|
|
|
|
GtkActionGroup*
|
|
|
|
midori_browser_get_action_group (MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
|
|
|
|
|
|
|
|
return browser->action_group;
|
|
|
|
}
|
|
|
|
|
2008-10-20 06:50:16 +00:00
|
|
|
/**
|
|
|
|
* midori_browser_set_current_uri:
|
|
|
|
* @browser: a #MidoriBrowser
|
|
|
|
* @uri: an URI
|
|
|
|
*
|
|
|
|
* Loads the specified URI in the current view.
|
|
|
|
*
|
|
|
|
* If the current view is opaque, and cannot load
|
|
|
|
* new pages, it will automatically open a new tab.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
midori_browser_set_current_uri (MidoriBrowser* browser,
|
|
|
|
const gchar* uri)
|
|
|
|
{
|
|
|
|
GtkWidget* view;
|
|
|
|
|
|
|
|
g_return_if_fail (MIDORI_IS_BROWSER (browser));
|
2008-11-23 00:44:40 +00:00
|
|
|
g_return_if_fail (uri != NULL);
|
2008-10-20 06:50:16 +00:00
|
|
|
|
2009-02-22 12:52:04 +00:00
|
|
|
if ((view = midori_browser_get_current_tab (browser)))
|
|
|
|
midori_view_set_uri (MIDORI_VIEW (view), uri);
|
|
|
|
else
|
|
|
|
midori_browser_add_uri (browser, uri);
|
2008-10-20 06:50:16 +00:00
|
|
|
}
|
|
|
|
|
2008-07-23 18:17:13 +00:00
|
|
|
/**
|
|
|
|
* midori_browser_get_current_uri:
|
|
|
|
* @browser: a #MidoriBrowser
|
|
|
|
*
|
2008-09-26 21:13:46 +00:00
|
|
|
* Determines the URI loaded in the current view.
|
2008-07-23 18:17:13 +00:00
|
|
|
*
|
2008-09-26 21:13:46 +00:00
|
|
|
* If there is no view present at all, %NULL is returned.
|
2008-07-23 18:17:13 +00:00
|
|
|
*
|
|
|
|
* Return value: the current URI, or %NULL
|
|
|
|
**/
|
|
|
|
const gchar*
|
|
|
|
midori_browser_get_current_uri (MidoriBrowser* browser)
|
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view;
|
2008-07-23 18:17:13 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
|
|
|
|
|
2009-02-22 12:52:04 +00:00
|
|
|
if ((view = midori_browser_get_current_tab (browser)))
|
|
|
|
return midori_view_get_display_uri (MIDORI_VIEW (view));
|
|
|
|
return NULL;
|
2008-07-23 18:17:13 +00:00
|
|
|
}
|
|
|
|
|
2008-04-24 22:20:43 +00:00
|
|
|
/**
|
|
|
|
* midori_browser_set_current_page:
|
|
|
|
* @browser: a #MidoriBrowser
|
|
|
|
* @n: the index of a page
|
|
|
|
*
|
|
|
|
* Switches to the page with the index @n.
|
|
|
|
*
|
|
|
|
* The widget will also grab the focus automatically.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
midori_browser_set_current_page (MidoriBrowser* browser,
|
|
|
|
gint n)
|
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view;
|
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_notebook_set_current_page (GTK_NOTEBOOK (browser->notebook), n);
|
2008-09-26 21:13:46 +00:00
|
|
|
view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), n);
|
|
|
|
if (view && midori_view_is_blank (MIDORI_VIEW (view)))
|
2008-08-14 23:57:48 +00:00
|
|
|
gtk_action_activate (_action_by_name (browser, "Location"));
|
2009-07-19 16:46:03 +00:00
|
|
|
else if (view)
|
2008-09-26 21:13:46 +00:00
|
|
|
gtk_widget_grab_focus (view);
|
2008-04-24 22:20:43 +00:00
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
/**
|
|
|
|
* midori_browser_get_current_page:
|
|
|
|
* @browser: a #MidoriBrowser
|
|
|
|
*
|
|
|
|
* Determines the currently selected page.
|
|
|
|
*
|
|
|
|
* If there is no page present at all, %NULL is returned.
|
|
|
|
*
|
2008-05-02 20:30:26 +00:00
|
|
|
* Return value: the selected page, or -1
|
2008-03-10 21:26:09 +00:00
|
|
|
**/
|
2008-05-02 20:30:26 +00:00
|
|
|
gint
|
2008-03-10 21:26:09 +00:00
|
|
|
midori_browser_get_current_page (MidoriBrowser* browser)
|
2008-05-02 20:30:26 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (MIDORI_IS_BROWSER (browser), -1);
|
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
return gtk_notebook_get_current_page (GTK_NOTEBOOK (browser->notebook));
|
2008-05-02 20:30:26 +00:00
|
|
|
}
|
|
|
|
|
2009-07-28 20:55:34 +00:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
}
|
|
|
|
|
2008-05-02 20:30:26 +00:00
|
|
|
/**
|
|
|
|
* midori_browser_set_current_tab:
|
|
|
|
* @browser: a #MidoriBrowser
|
2008-09-26 21:13:46 +00:00
|
|
|
* @view: a #GtkWidget
|
2008-05-02 20:30:26 +00:00
|
|
|
*
|
2008-09-26 21:13:46 +00:00
|
|
|
* Switches to the page containing @view.
|
2008-05-02 20:30:26 +00:00
|
|
|
*
|
|
|
|
* The widget will also grab the focus automatically.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
midori_browser_set_current_tab (MidoriBrowser* browser,
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view)
|
2008-05-02 20:30:26 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
gint n;
|
|
|
|
|
|
|
|
g_return_if_fail (MIDORI_IS_BROWSER (browser));
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (view));
|
|
|
|
|
|
|
|
n = gtk_notebook_page_num (GTK_NOTEBOOK (browser->notebook), view);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_notebook_set_current_page (GTK_NOTEBOOK (browser->notebook), n);
|
2008-09-26 21:13:46 +00:00
|
|
|
if (view && midori_view_is_blank (MIDORI_VIEW (view)))
|
2008-08-14 23:57:48 +00:00
|
|
|
gtk_action_activate (_action_by_name (browser, "Location"));
|
2008-05-02 20:30:26 +00:00
|
|
|
else
|
2008-09-26 21:13:46 +00:00
|
|
|
gtk_widget_grab_focus (view);
|
2008-05-02 20:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* midori_browser_get_current_tab:
|
|
|
|
* @browser: a #MidoriBrowser
|
|
|
|
*
|
|
|
|
* Retrieves the currently selected tab.
|
|
|
|
*
|
|
|
|
* If there is no tab present at all, %NULL is returned.
|
|
|
|
*
|
2008-09-26 21:13:46 +00:00
|
|
|
* See also midori_browser_get_current_page().
|
|
|
|
*
|
2008-05-02 20:30:26 +00:00
|
|
|
* Return value: the selected tab, or %NULL
|
|
|
|
**/
|
|
|
|
GtkWidget*
|
|
|
|
midori_browser_get_current_tab (MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
gint n;
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
n = gtk_notebook_get_current_page (GTK_NOTEBOOK (browser->notebook));
|
2008-05-02 20:30:26 +00:00
|
|
|
if (n >= 0)
|
2008-09-26 21:13:46 +00:00
|
|
|
return gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), n);
|
2008-05-02 20:30:26 +00:00
|
|
|
else
|
|
|
|
return NULL;
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-09-26 21:13:46 +00:00
|
|
|
* midori_browser_get_proxy_array:
|
2008-03-10 21:26:09 +00:00
|
|
|
* @browser: a #MidoriBrowser
|
|
|
|
*
|
2008-09-26 21:13:46 +00:00
|
|
|
* Retrieves a proxy array representing the respective proxy items
|
|
|
|
* of the present views that can be used for session management.
|
2008-03-10 21:26:09 +00:00
|
|
|
*
|
2008-10-10 20:31:37 +00:00
|
|
|
* The array is updated automatically.
|
2008-03-10 21:26:09 +00:00
|
|
|
*
|
2008-07-25 10:45:50 +00:00
|
|
|
* Note: Calling this function doesn't add a reference and the browser
|
|
|
|
* may release its reference at some point.
|
|
|
|
*
|
2008-09-03 22:35:15 +00:00
|
|
|
* Return value: the proxy #KatzeArray
|
2008-03-10 21:26:09 +00:00
|
|
|
**/
|
2008-09-03 22:35:15 +00:00
|
|
|
KatzeArray*
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_browser_get_proxy_array (MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
return browser->proxy_array;
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
2008-05-31 22:21:08 +00:00
|
|
|
|
2009-04-23 02:10:38 +00:00
|
|
|
/**
|
|
|
|
* midori_browser_get_for_widget:
|
|
|
|
* @widget: a #GtkWidget
|
|
|
|
*
|
|
|
|
* Determines the browser appropriate for the specified widget.
|
|
|
|
*
|
|
|
|
* Return value: a #MidoriBrowser
|
|
|
|
*
|
|
|
|
* Since 0.1.7
|
|
|
|
**/
|
|
|
|
MidoriBrowser*
|
|
|
|
midori_browser_get_for_widget (GtkWidget* widget)
|
|
|
|
{
|
|
|
|
gpointer browser;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
|
|
|
|
|
|
|
browser = gtk_widget_get_toplevel (GTK_WIDGET (widget));
|
|
|
|
if (!MIDORI_IS_BROWSER (browser))
|
|
|
|
{
|
|
|
|
if (!GTK_IS_WINDOW (browser))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
browser = gtk_window_get_transient_for (GTK_WINDOW (browser));
|
|
|
|
if (!MIDORI_IS_BROWSER (browser))
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return MIDORI_BROWSER (browser);
|
|
|
|
}
|
|
|
|
|
2008-05-31 22:21:08 +00:00
|
|
|
/**
|
|
|
|
* midori_browser_quit:
|
|
|
|
* @browser: a #MidoriBrowser
|
|
|
|
*
|
|
|
|
* Quits the browser, including any other browser windows.
|
2008-06-15 02:02:56 +00:00
|
|
|
*
|
|
|
|
* This function relys on the application implementing
|
|
|
|
* the MidoriBrowser::quit signal. If the browser was added
|
|
|
|
* to the MidoriApp, this is handled automatically.
|
2008-05-31 22:21:08 +00:00
|
|
|
**/
|
|
|
|
void
|
|
|
|
midori_browser_quit (MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
g_return_if_fail (MIDORI_IS_BROWSER (browser));
|
|
|
|
|
|
|
|
g_signal_emit (browser, signals[QUIT], 0);
|
|
|
|
}
|