2008-03-10 21:26:09 +00:00
|
|
|
/*
|
2011-04-03 21:59:29 +00:00
|
|
|
Copyright (C) 2007-2011 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "midori-browser.h"
|
|
|
|
|
2009-11-15 16:49:09 +00:00
|
|
|
#include "midori-array.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"
|
2010-06-20 18:13:39 +00:00
|
|
|
#include "midori-findbar.h"
|
2010-06-17 18:03:11 +00:00
|
|
|
#include "midori-transferbar.h"
|
2008-09-03 00:39:25 +00:00
|
|
|
|
|
|
|
#include "gtkiconentry.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>
|
2009-12-19 09:39:24 +00:00
|
|
|
#include <glib/gstdio.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
|
|
|
|
|
2011-05-30 15:55:02 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
2009-11-27 22:42:07 +00:00
|
|
|
#ifdef HAVE_HILDON_2_2
|
|
|
|
#include <dbus/dbus.h>
|
|
|
|
#include <mce/mode-names.h>
|
|
|
|
#include <mce/dbus-names.h>
|
|
|
|
#define MCE_SIGNAL_MATCH "type='signal'," \
|
|
|
|
"sender='" MCE_SERVICE "'," \
|
|
|
|
"path='" MCE_SIGNAL_PATH "'," \
|
|
|
|
"interface='" MCE_SIGNAL_IF "'"
|
2009-11-29 14:09:00 +00:00
|
|
|
#include <gdk/gdkx.h>
|
|
|
|
#include <X11/Xatom.h>
|
2009-11-27 22:42:07 +00:00
|
|
|
#endif
|
|
|
|
|
2010-07-17 19:31:29 +00:00
|
|
|
#include <sqlite3.h>
|
2010-02-03 21:12:19 +00:00
|
|
|
|
2010-06-20 18:13:39 +00:00
|
|
|
#if HAVE_CONFIG_H
|
|
|
|
#include <config.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;
|
|
|
|
|
|
|
|
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* statusbar;
|
2009-10-27 22:55:17 +00:00
|
|
|
GtkWidget* statusbar_contents;
|
2009-03-19 17:28:50 +00:00
|
|
|
GtkWidget* transferbar;
|
2008-03-10 21:26:09 +00:00
|
|
|
gchar* statusbar_text;
|
|
|
|
|
2010-02-07 22:42:39 +00:00
|
|
|
gint last_window_width, last_window_height;
|
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;
|
2011-03-14 19:07:18 +00:00
|
|
|
GKeyFile* speeddial;
|
2009-06-22 21:48:41 +00:00
|
|
|
gboolean show_tabs;
|
2008-10-20 19:32:25 +00:00
|
|
|
|
2009-02-28 13:05:01 +00:00
|
|
|
gboolean show_navigationbar;
|
|
|
|
gboolean show_statusbar;
|
2009-11-14 17:29:29 +00:00
|
|
|
guint maximum_history_age;
|
2009-04-18 20:41:37 +00:00
|
|
|
gchar* location_entry_search;
|
2011-05-15 19:40:39 +00:00
|
|
|
guint last_web_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,
|
2011-03-14 19:07:18 +00:00
|
|
|
PROP_SPEED_DIAL,
|
2009-06-22 21:48:41 +00:00
|
|
|
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,
|
2011-03-07 21:56:20 +00:00
|
|
|
MOVE_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,
|
2011-04-17 20:43:54 +00:00
|
|
|
POPULATE_TOOLBAR_MENU,
|
2008-05-31 22:21:08 +00:00
|
|
|
QUIT,
|
2011-04-14 01:29:50 +00:00
|
|
|
SHOW_PREFERENCES,
|
2008-05-31 22:21:08 +00:00
|
|
|
|
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);
|
|
|
|
|
2010-07-02 03:55:41 +00:00
|
|
|
void
|
|
|
|
midori_bookmarks_import_array_db (sqlite3* db,
|
|
|
|
KatzeArray* array,
|
|
|
|
gchar* folder);
|
|
|
|
|
2010-07-23 17:51:28 +00:00
|
|
|
void
|
|
|
|
midori_bookmarks_export_array_db (sqlite3* db,
|
|
|
|
KatzeArray* array,
|
|
|
|
const gchar* folder);
|
|
|
|
|
2010-08-14 18:58:38 +00:00
|
|
|
void
|
|
|
|
midori_browser_open_bookmark (MidoriBrowser* browser,
|
|
|
|
KatzeItem* item);
|
|
|
|
|
2010-07-19 18:55:59 +00:00
|
|
|
static void
|
|
|
|
midori_bookmarkbar_populate (MidoriBrowser* browser);
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_bookmarkbar_clear (GtkWidget* toolbar);
|
|
|
|
|
2008-10-07 00:19:33 +00:00
|
|
|
static void
|
|
|
|
midori_browser_new_history_item (MidoriBrowser* browser,
|
2010-07-21 19:28:45 +00:00
|
|
|
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);
|
|
|
|
|
2010-07-29 13:18:27 +00:00
|
|
|
void
|
|
|
|
midori_panel_set_toolbar_style (MidoriPanel* panel,
|
|
|
|
GtkToolbarStyle style);
|
|
|
|
|
2009-08-19 21:51:59 +00:00
|
|
|
static void
|
|
|
|
midori_browser_set_bookmarks (MidoriBrowser* browser,
|
|
|
|
KatzeArray* bookmarks);
|
|
|
|
|
2010-05-18 21:16:14 +00:00
|
|
|
static void
|
|
|
|
midori_browser_add_speed_dial (MidoriBrowser* browser);
|
|
|
|
|
2010-06-17 18:03:11 +00:00
|
|
|
gboolean
|
|
|
|
midori_transferbar_confirm_delete (MidoriTransferbar* transferbar);
|
|
|
|
|
2011-04-03 21:59:29 +00:00
|
|
|
static void
|
|
|
|
_midori_browser_update_notebook (MidoriBrowser* browser);
|
|
|
|
|
2010-06-17 18:03:11 +00:00
|
|
|
void
|
|
|
|
midori_transferbar_add_download_item (MidoriTransferbar* transferbar,
|
|
|
|
WebKitDownload* download);
|
|
|
|
|
2010-01-28 22:50:44 +00:00
|
|
|
#define _action_by_name(brwsr, nme) \
|
|
|
|
gtk_action_group_get_action (brwsr->action_group, nme)
|
|
|
|
#define _action_set_sensitive(brwsr, nme, snstv) \
|
|
|
|
gtk_action_set_sensitive (_action_by_name (brwsr, nme), snstv);
|
|
|
|
#define _action_set_visible(brwsr, nme, vsbl) \
|
|
|
|
gtk_action_set_visible (_action_by_name (brwsr, nme), vsbl);
|
|
|
|
#define _action_set_active(brwsr, nme, actv) \
|
|
|
|
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION ( \
|
|
|
|
_action_by_name (brwsr, nme)), actv);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-10-03 23:45:17 +00:00
|
|
|
static void
|
|
|
|
_toggle_tabbar_smartly (MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
guint n;
|
|
|
|
|
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-11-13 17:27:49 +00:00
|
|
|
if (n < 2)
|
2008-10-03 23:45:17 +00:00
|
|
|
{
|
2011-04-25 23:29:26 +00:00
|
|
|
if (katze_object_get_boolean (browser->settings, "always-show-tabbar"))
|
2008-10-03 23:45:17 +00:00
|
|
|
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, "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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_midori_browser_update_interface (MidoriBrowser* browser)
|
|
|
|
{
|
2010-08-16 19:01:02 +00:00
|
|
|
GtkWidget* widget = midori_browser_get_current_tab (browser);
|
|
|
|
MidoriView* view = MIDORI_VIEW (widget);
|
|
|
|
gboolean loading = midori_view_get_load_status (view) != MIDORI_LOAD_FINISHED;
|
|
|
|
gboolean can_reload = midori_view_can_reload (view);
|
2008-08-14 23:57:48 +00:00
|
|
|
GtkAction* action;
|
2008-07-13 19:49:57 +00:00
|
|
|
|
2009-11-18 18:36:37 +00:00
|
|
|
_action_set_sensitive (browser, "Reload", can_reload);
|
2008-09-26 21:13:46 +00:00
|
|
|
_action_set_sensitive (browser, "Stop", can_reload && loading);
|
2009-09-29 20:25:09 +00:00
|
|
|
_action_set_sensitive (browser, "Back", midori_view_can_go_back (view));
|
|
|
|
_action_set_sensitive (browser, "Forward", midori_view_can_go_forward (view));
|
2009-12-26 22:12:36 +00:00
|
|
|
_action_set_sensitive (browser, "Previous",
|
|
|
|
midori_view_get_previous_page (view) != NULL);
|
|
|
|
_action_set_sensitive (browser, "Next",
|
|
|
|
midori_view_get_next_page (view) != NULL);
|
2008-09-26 21:13:46 +00:00
|
|
|
|
2009-05-10 12:57:26 +00:00
|
|
|
gtk_action_set_visible (_action_by_name (browser, "AddSpeedDial"),
|
2011-03-22 23:26:51 +00:00
|
|
|
!midori_view_is_blank (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. */
|
2009-09-29 20:25:09 +00:00
|
|
|
_action_set_sensitive (browser, "SaveAs", midori_view_can_view_source (view));
|
|
|
|
_action_set_sensitive (browser, "Print", midori_view_can_print (view));
|
|
|
|
_action_set_sensitive (browser, "ZoomIn", midori_view_can_zoom_in (view));
|
|
|
|
_action_set_sensitive (browser, "ZoomOut", midori_view_can_zoom_out (view));
|
2008-09-26 21:13:46 +00:00
|
|
|
_action_set_sensitive (browser, "ZoomNormal",
|
2009-09-29 20:25:09 +00:00
|
|
|
midori_view_get_zoom_level (view) != 1.0f);
|
2009-02-27 22:09:36 +00:00
|
|
|
_action_set_sensitive (browser, "Encoding",
|
2010-06-07 19:27:03 +00:00
|
|
|
midori_view_can_view_source (view));
|
2008-09-26 21:13:46 +00:00
|
|
|
_action_set_sensitive (browser, "SourceView",
|
2009-09-29 20:25:09 +00:00
|
|
|
midori_view_can_view_source (view));
|
2008-09-26 21:13:46 +00:00
|
|
|
_action_set_sensitive (browser, "Find",
|
2009-09-29 20:25:09 +00:00
|
|
|
midori_view_can_find (view));
|
2008-09-26 21:13:46 +00:00
|
|
|
_action_set_sensitive (browser, "FindNext",
|
2009-09-29 20:25:09 +00:00
|
|
|
midori_view_can_find (view));
|
2008-09-26 21:13:46 +00:00
|
|
|
_action_set_sensitive (browser, "FindPrevious",
|
2009-09-29 20:25:09 +00:00
|
|
|
midori_view_can_find (view));
|
2010-06-20 18:13:39 +00:00
|
|
|
midori_findbar_set_can_find (MIDORI_FINDBAR (browser->find),
|
2009-09-29 20:25:09 +00:00
|
|
|
midori_view_can_find (view));
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2010-08-16 19:01:02 +00:00
|
|
|
action = _action_by_name (browser, "ReloadStop");
|
2008-03-10 21:26:09 +00:00
|
|
|
if (!loading)
|
|
|
|
{
|
|
|
|
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);
|
2011-02-13 17:34:22 +00:00
|
|
|
if (!browser->show_navigationbar)
|
2008-10-21 22:26:20 +00:00
|
|
|
gtk_widget_hide (browser->navigationbar);
|
2011-02-23 21:36:03 +00:00
|
|
|
|
|
|
|
katze_item_set_meta_integer (midori_view_get_proxy_item (view), "dont-write-history", 0);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_object_set (action,
|
|
|
|
"stock-id", GTK_STOCK_STOP,
|
2008-03-22 02:38:23 +00:00
|
|
|
"tooltip", _("Stop loading the current page"), NULL);
|
2011-02-13 17:34:22 +00:00
|
|
|
if (!gtk_widget_get_visible (browser->navigationbar))
|
2008-10-21 22:26:20 +00:00
|
|
|
gtk_widget_show (browser->navigationbar);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
2009-10-13 21:56:02 +00:00
|
|
|
|
|
|
|
#if HAVE_HILDON
|
|
|
|
#if HILDON_CHECK_VERSION (2, 2, 0)
|
|
|
|
hildon_gtk_window_set_progress_indicator (GTK_WINDOW (browser), loading);
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
gtk_widget_set_sensitive (browser->throbber, loading);
|
2008-06-19 18:39:00 +00:00
|
|
|
katze_throbber_set_animated (KATZE_THROBBER (browser->throbber), loading);
|
2009-10-13 21:56:02 +00:00
|
|
|
#endif
|
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-10-12 20:57:35 +00:00
|
|
|
{
|
2009-04-13 20:40:57 +00:00
|
|
|
midori_location_action_set_secondary_icon (
|
|
|
|
MIDORI_LOCATION_ACTION (action), STOCK_NEWS_FEED);
|
2009-10-12 20:57:35 +00:00
|
|
|
gtk_action_set_sensitive (_action_by_name (browser, "AddNewsFeed"), TRUE);
|
|
|
|
}
|
2008-08-02 02:25:05 +00:00
|
|
|
else
|
2009-10-12 20:57:35 +00:00
|
|
|
{
|
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);
|
2009-10-12 20:57:35 +00:00
|
|
|
gtk_action_set_sensitive (_action_by_name (browser, "AddNewsFeed"), FALSE);
|
|
|
|
}
|
2010-04-20 21:32:28 +00:00
|
|
|
midori_location_action_set_security_hint (
|
|
|
|
MIDORI_LOCATION_ACTION (action), midori_view_get_security (view));
|
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));
|
2011-04-30 23:18:53 +00:00
|
|
|
gboolean is_location = widget && GTK_IS_ENTRY (widget)
|
|
|
|
&& GTK_IS_ALIGNMENT (gtk_widget_get_parent (widget));
|
2009-09-19 19:06:33 +00:00
|
|
|
|
2009-10-05 18:50:08 +00:00
|
|
|
katze_assign (browser->statusbar_text, sokoke_format_uri_for_display (text));
|
2009-07-17 02:06:44 +00:00
|
|
|
|
2010-09-12 18:14:48 +00:00
|
|
|
if (!browser->show_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)
|
|
|
|
{
|
2010-07-31 11:59:48 +00:00
|
|
|
midori_location_action_set_text (location_action, browser->statusbar_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);
|
2010-07-31 11:59:48 +00:00
|
|
|
midori_location_action_set_text (location_action,
|
2009-07-17 02:06:44 +00:00
|
|
|
midori_view_get_display_uri (MIDORI_VIEW (view)));
|
2009-12-26 13:03:29 +00:00
|
|
|
midori_location_action_set_icon (location_action,
|
|
|
|
midori_view_get_icon (MIDORI_VIEW (view)));
|
2009-07-17 02:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-07-03 07:28:03 +00:00
|
|
|
void
|
|
|
|
midori_browser_set_current_page_smartly (MidoriBrowser* browser,
|
|
|
|
gint n)
|
2008-04-24 22:20:43 +00:00
|
|
|
{
|
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;
|
|
|
|
|
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;
|
2011-02-20 19:09:57 +00:00
|
|
|
/* When loading we want to see at minimum 10% progress */
|
|
|
|
else
|
|
|
|
progress = CLAMP (progress, 0.1, 1.0);
|
2010-08-16 19:01:02 +00:00
|
|
|
midori_location_action_set_progress (action, progress);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2010-02-03 21:12:19 +00:00
|
|
|
static void
|
|
|
|
midori_browser_update_history_title (MidoriBrowser* browser,
|
|
|
|
KatzeItem* item)
|
|
|
|
{
|
|
|
|
sqlite3* db;
|
2010-02-04 18:13:16 +00:00
|
|
|
static sqlite3_stmt* stmt = NULL;
|
2010-02-03 21:12:19 +00:00
|
|
|
|
2010-07-22 13:28:18 +00:00
|
|
|
g_return_if_fail (katze_item_get_uri (item) != NULL);
|
|
|
|
|
2010-02-03 21:12:19 +00:00
|
|
|
db = g_object_get_data (G_OBJECT (browser->history), "db");
|
2010-12-24 15:44:49 +00:00
|
|
|
g_return_if_fail (db != NULL);
|
2010-02-04 18:13:16 +00:00
|
|
|
if (!stmt)
|
2010-02-03 21:12:19 +00:00
|
|
|
{
|
2010-02-04 18:13:16 +00:00
|
|
|
const gchar* sqlcmd;
|
|
|
|
|
|
|
|
sqlcmd = "UPDATE history SET title=? WHERE uri = ? and date=?";
|
|
|
|
sqlite3_prepare_v2 (db, sqlcmd, -1, &stmt, NULL);
|
2010-02-03 21:12:19 +00:00
|
|
|
}
|
2010-02-04 18:13:16 +00:00
|
|
|
sqlite3_bind_text (stmt, 1, katze_item_get_name (item), -1, 0);
|
|
|
|
sqlite3_bind_text (stmt, 2, katze_item_get_uri (item), -1, 0);
|
|
|
|
sqlite3_bind_int64 (stmt, 3, katze_item_get_added (item));
|
|
|
|
|
|
|
|
if (sqlite3_step (stmt) != SQLITE_DONE)
|
|
|
|
g_printerr (_("Failed to update title: %s\n"), sqlite3_errmsg (db));
|
|
|
|
sqlite3_reset (stmt);
|
|
|
|
sqlite3_clear_bindings (stmt);
|
2010-02-03 21:12:19 +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;
|
|
|
|
|
2009-12-26 13:03:29 +00:00
|
|
|
if (midori_browser_get_current_tab (browser) != (GtkWidget*)view)
|
|
|
|
return;
|
|
|
|
|
|
|
|
uri = midori_view_get_display_uri (view);
|
2008-09-26 21:13:46 +00:00
|
|
|
action = _action_by_name (browser, "Location");
|
2009-11-14 17:29:29 +00:00
|
|
|
if (browser->maximum_history_age)
|
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);
|
2009-12-26 13:03:29 +00:00
|
|
|
midori_location_action_set_icon (MIDORI_LOCATION_ACTION (action),
|
|
|
|
midori_view_get_icon (view));
|
2008-04-28 20:38:57 +00:00
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
2009-09-29 20:25:09 +00:00
|
|
|
midori_view_notify_load_status_cb (GtkWidget* widget,
|
2008-09-26 21:13:46 +00:00
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2009-09-29 20:25:09 +00:00
|
|
|
MidoriView* view = MIDORI_VIEW (widget);
|
2010-08-16 19:01:02 +00:00
|
|
|
MidoriLoadStatus load_status = midori_view_get_load_status (view);
|
2008-07-23 15:54:24 +00:00
|
|
|
const gchar* uri;
|
2008-08-14 23:57:48 +00:00
|
|
|
GtkAction* action;
|
|
|
|
|
2009-09-29 20:25:09 +00:00
|
|
|
uri = midori_view_get_display_uri (view);
|
2008-08-14 23:57:48 +00:00
|
|
|
action = _action_by_name (browser, "Location");
|
|
|
|
|
2010-08-16 19:01:02 +00:00
|
|
|
if (load_status == MIDORI_LOAD_COMMITTED)
|
2010-01-28 22:56:54 +00:00
|
|
|
midori_location_action_add_uri (MIDORI_LOCATION_ACTION (action), uri);
|
2008-07-23 15:54:24 +00:00
|
|
|
|
2009-09-29 20:25:09 +00:00
|
|
|
if (widget == midori_browser_get_current_tab (browser))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2010-08-16 19:01:02 +00:00
|
|
|
if (load_status == MIDORI_LOAD_COMMITTED)
|
2008-07-23 15:54:24 +00:00
|
|
|
{
|
2010-07-31 11:59:48 +00:00
|
|
|
midori_location_action_set_text (
|
2008-08-14 23:57:48 +00:00
|
|
|
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-09-29 20:25:09 +00:00
|
|
|
if (midori_view_is_blank (view))
|
2009-05-26 05:41:17 +00:00
|
|
|
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
|
2011-02-27 00:48:06 +00:00
|
|
|
midori_view_notify_uri_cb (GtkWidget* widget,
|
2009-05-14 23:18:14 +00:00
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2011-02-27 00:48:06 +00:00
|
|
|
if (widget == midori_browser_get_current_tab (browser))
|
2009-05-15 15:30:54 +00:00
|
|
|
{
|
2011-02-27 00:48:06 +00:00
|
|
|
MidoriView* view = MIDORI_VIEW (widget);
|
|
|
|
const gchar* uri = midori_view_get_display_uri (view);
|
2009-05-15 15:30:54 +00:00
|
|
|
GtkAction* action = _action_by_name (browser, "Location");
|
2010-07-31 11:59:48 +00:00
|
|
|
midori_location_action_set_text (MIDORI_LOCATION_ACTION (action), uri);
|
2011-02-27 00:48:06 +00:00
|
|
|
_action_set_sensitive (browser, "Back", midori_view_can_go_back (view));
|
|
|
|
_action_set_sensitive (browser, "Forward", midori_view_can_go_forward (view));
|
2009-05-15 15:30:54 +00:00
|
|
|
}
|
2009-05-14 23:18:14 +00:00
|
|
|
}
|
|
|
|
|
2011-04-25 15:53:33 +00:00
|
|
|
static void
|
|
|
|
midori_browser_set_title (MidoriBrowser* browser,
|
|
|
|
const gchar* title)
|
|
|
|
{
|
|
|
|
if (katze_object_get_boolean (browser->settings, "enable-private-browsing"))
|
|
|
|
{
|
2011-05-17 20:15:11 +00:00
|
|
|
gchar* window_title = g_strdup_printf (_("%s (Private Browsing)"), title);
|
2011-04-25 15:53:33 +00:00
|
|
|
gtk_window_set_title (GTK_WINDOW (browser), window_title);
|
|
|
|
g_free (window_title);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
gtk_window_set_title (GTK_WINDOW (browser), title);
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
2009-09-29 20:25:09 +00:00
|
|
|
midori_view_notify_title_cb (GtkWidget* widget,
|
2008-09-26 21:13:46 +00:00
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2009-09-29 20:25:09 +00:00
|
|
|
MidoriView* view = MIDORI_VIEW (widget);
|
2008-08-14 23:57:48 +00:00
|
|
|
const gchar* title;
|
|
|
|
|
2009-09-29 20:25:09 +00:00
|
|
|
title = midori_view_get_display_title (view);
|
2010-07-21 14:35:47 +00:00
|
|
|
|
2009-09-29 20:25:09 +00:00
|
|
|
if (midori_view_get_load_status (view) == MIDORI_LOAD_COMMITTED)
|
2008-10-07 00:19:33 +00:00
|
|
|
{
|
2009-01-26 02:43:59 +00:00
|
|
|
KatzeItem* proxy;
|
2009-11-14 17:29:29 +00:00
|
|
|
if (browser->history && browser->maximum_history_age)
|
2009-01-26 02:43:59 +00:00
|
|
|
{
|
2010-07-23 15:19:38 +00:00
|
|
|
const gchar* proxy_uri;
|
2009-09-29 20:25:09 +00:00
|
|
|
proxy = midori_view_get_proxy_item (view);
|
2010-07-23 15:19:38 +00:00
|
|
|
proxy_uri = katze_item_get_uri (proxy);
|
|
|
|
if (proxy_uri && *proxy_uri && proxy_uri[1] &&
|
2010-07-23 21:11:38 +00:00
|
|
|
!g_str_has_prefix (proxy_uri, "about:") &&
|
|
|
|
(katze_item_get_meta_integer (proxy, "history-step") == -1))
|
2010-02-03 21:12:19 +00:00
|
|
|
{
|
2011-02-23 21:36:03 +00:00
|
|
|
if (!katze_item_get_meta_boolean (proxy, "dont-write-history"))
|
|
|
|
{
|
|
|
|
midori_browser_new_history_item (browser, proxy);
|
|
|
|
katze_item_set_meta_integer (proxy, "history-step", 1);
|
|
|
|
}
|
2010-02-03 21:12:19 +00:00
|
|
|
}
|
2010-07-21 19:28:45 +00:00
|
|
|
else if (katze_item_get_name (proxy) &&
|
2010-07-23 21:11:38 +00:00
|
|
|
!g_str_has_prefix (proxy_uri, "about:") &&
|
|
|
|
(katze_item_get_meta_integer (proxy, "history-step") == 1))
|
2009-02-21 22:59:02 +00:00
|
|
|
{
|
2010-07-21 19:28:45 +00:00
|
|
|
midori_browser_update_history_title (browser, proxy);
|
2010-07-23 21:11:38 +00:00
|
|
|
katze_item_set_meta_integer (proxy, "history-step", 2);
|
2009-02-21 22:59:02 +00:00
|
|
|
}
|
2009-01-26 02:43:59 +00:00
|
|
|
}
|
2008-10-07 00:19:33 +00:00
|
|
|
}
|
2008-08-14 23:57:48 +00:00
|
|
|
|
2009-09-29 20:25:09 +00:00
|
|
|
if (widget == midori_browser_get_current_tab (browser))
|
2011-04-25 15:53:33 +00:00
|
|
|
midori_browser_set_title (browser, title);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2011-04-03 21:59:29 +00:00
|
|
|
static void
|
|
|
|
midori_view_notify_minimized_cb (GtkWidget* widget,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
if (katze_object_get_boolean (widget, "minimized"))
|
|
|
|
{
|
|
|
|
GtkNotebook* notebook = GTK_NOTEBOOK (browser->notebook);
|
|
|
|
GtkWidget* label = gtk_notebook_get_tab_label (notebook, widget);
|
|
|
|
gtk_widget_set_size_request (label, -1, -1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_midori_browser_update_notebook (browser);
|
|
|
|
}
|
|
|
|
|
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
|
2009-09-29 20:25:09 +00:00
|
|
|
midori_view_notify_statusbar_text_cb (GtkWidget* view,
|
2008-09-26 21:13:46 +00:00
|
|
|
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-09-29 20:25:09 +00:00
|
|
|
if (view == midori_browser_get_current_tab (browser))
|
2009-08-28 21:54:06 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-07-19 18:47:33 +00:00
|
|
|
static void
|
|
|
|
midori_browser_edit_bookmark_title_changed_cb (GtkEntry* entry,
|
|
|
|
GtkDialog* dialog)
|
|
|
|
{
|
|
|
|
const gchar* title = gtk_entry_get_text (entry);
|
|
|
|
gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_ACCEPT,
|
|
|
|
title != NULL && title[0] != '\0');
|
|
|
|
}
|
|
|
|
|
2010-05-18 21:16:14 +00:00
|
|
|
static void
|
|
|
|
midori_browser_edit_bookmark_add_speed_dial_cb (GtkWidget* button,
|
|
|
|
KatzeItem* bookmark)
|
|
|
|
{
|
|
|
|
MidoriBrowser* browser = midori_browser_get_for_widget (button);
|
|
|
|
gtk_widget_set_sensitive (button, FALSE);
|
|
|
|
midori_browser_add_speed_dial (browser);
|
|
|
|
}
|
|
|
|
|
2009-02-22 02:11:40 +00:00
|
|
|
/* Private function, used by MidoriBookmarks and MidoriHistory */
|
2010-07-02 04:50:14 +00:00
|
|
|
/* static */ gboolean
|
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;
|
2010-02-19 18:05:29 +00:00
|
|
|
GtkWidget* content_area;
|
2008-10-01 02:00:16 +00:00
|
|
|
GtkSizeGroup* sizegroup;
|
|
|
|
GtkWidget* view;
|
|
|
|
GtkWidget* hbox;
|
|
|
|
GtkWidget* label;
|
|
|
|
const gchar* value;
|
|
|
|
GtkWidget* entry_title;
|
|
|
|
GtkWidget* entry_uri;
|
|
|
|
GtkWidget* combo_folder;
|
2009-11-23 19:46:00 +00:00
|
|
|
GtkWidget* check_toolbar;
|
2009-11-18 22:10:47 +00:00
|
|
|
GtkWidget* check_app;
|
2010-07-02 04:50:14 +00:00
|
|
|
gboolean return_status = FALSE;
|
2010-06-14 07:00:05 +00:00
|
|
|
sqlite3* db;
|
2008-10-01 02:00:16 +00:00
|
|
|
|
2010-04-02 16:38:56 +00:00
|
|
|
if (!browser->bookmarks || !gtk_widget_get_visible (GTK_WIDGET (browser)))
|
2010-07-02 04:50:14 +00:00
|
|
|
return FALSE;
|
2009-02-28 13:05:01 +00:00
|
|
|
|
2010-06-14 07:00:05 +00:00
|
|
|
db = g_object_get_data (G_OBJECT (browser->bookmarks), "db");
|
|
|
|
|
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);
|
2010-02-19 18:05:29 +00:00
|
|
|
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
|
2008-06-15 11:29:30 +00:00
|
|
|
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);
|
2010-02-19 18:05:29 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (content_area), 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);
|
2009-11-23 19:46:00 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
|
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 : "");
|
2010-07-19 18:47:33 +00:00
|
|
|
midori_browser_edit_bookmark_title_changed_cb (GTK_ENTRY (entry_title),
|
|
|
|
GTK_DIALOG (dialog));
|
|
|
|
g_signal_connect (entry_title, "changed",
|
|
|
|
G_CALLBACK (midori_browser_edit_bookmark_title_changed_cb), dialog);
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), entry_title, TRUE, TRUE, 0);
|
2010-02-19 18:05:29 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (content_area), hbox);
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_widget_show_all (hbox);
|
|
|
|
|
2008-10-01 02:00:16 +00:00
|
|
|
entry_uri = NULL;
|
2010-07-01 01:19:15 +00:00
|
|
|
if (!is_folder)
|
2008-06-15 11:29:30 +00:00
|
|
|
{
|
|
|
|
hbox = gtk_hbox_new (FALSE, 8);
|
2009-11-23 19:46:00 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
|
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);
|
2011-05-15 14:45:14 +00:00
|
|
|
entry_uri = katze_uri_entry_new (
|
|
|
|
#if GTK_CHECK_VERSION (2, 20, 0)
|
|
|
|
gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT));
|
|
|
|
#else
|
|
|
|
NULL);
|
|
|
|
#endif
|
2009-11-28 18:39:47 +00:00
|
|
|
#if HAVE_HILDON
|
|
|
|
HildonGtkInputMode mode = hildon_gtk_entry_get_input_mode (GTK_ENTRY (entry_uri));
|
|
|
|
mode &= ~HILDON_GTK_INPUT_MODE_AUTOCAP;
|
|
|
|
hildon_gtk_entry_set_input_mode (GTK_ENTRY (entry_uri), mode);
|
|
|
|
#endif
|
2008-06-15 11:29:30 +00:00
|
|
|
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));
|
2008-08-31 00:45:13 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), entry_uri, TRUE, TRUE, 0);
|
2010-02-19 18:05:29 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (content_area), hbox);
|
2008-06-15 11:29:30 +00:00
|
|
|
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-11-23 19:46:00 +00:00
|
|
|
GtkListStore* model;
|
|
|
|
GtkCellRenderer* renderer;
|
2011-04-29 01:41:04 +00:00
|
|
|
guint n;
|
2010-06-14 07:00:05 +00:00
|
|
|
sqlite3_stmt* statement;
|
|
|
|
gint result;
|
|
|
|
const gchar* sqlcmd;
|
2009-01-01 02:52:43 +00:00
|
|
|
|
2008-06-15 11:29:30 +00:00
|
|
|
hbox = gtk_hbox_new (FALSE, 8);
|
2009-11-23 19:46:00 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
|
2008-06-15 11:29:30 +00:00
|
|
|
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);
|
2009-11-23 19:46:00 +00:00
|
|
|
model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
|
|
|
|
combo_folder = gtk_combo_box_new_with_model (GTK_TREE_MODEL (model));
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
|
|
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_folder), renderer, TRUE);
|
|
|
|
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo_folder), renderer, "text", 0);
|
|
|
|
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo_folder), renderer, "ellipsize", 1);
|
|
|
|
gtk_list_store_insert_with_values (model, NULL, G_MAXINT,
|
|
|
|
0, _("Toplevel folder"), 1, PANGO_ELLIPSIZE_END, -1);
|
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
|
|
|
|
|
|
|
n = 1;
|
2010-07-01 21:03:24 +00:00
|
|
|
sqlcmd = "SELECT title from bookmarks where uri=''";
|
2010-06-14 07:00:05 +00:00
|
|
|
result = sqlite3_prepare_v2 (db, sqlcmd, -1, &statement, NULL);
|
|
|
|
while ((result = sqlite3_step (statement)) == SQLITE_ROW)
|
2009-01-01 02:52:43 +00:00
|
|
|
{
|
2010-06-14 07:00:05 +00:00
|
|
|
const unsigned char* name = sqlite3_column_text (statement, 0);
|
2009-11-23 19:46:00 +00:00
|
|
|
gtk_list_store_insert_with_values (model, NULL, G_MAXINT,
|
|
|
|
0, name, 1, PANGO_ELLIPSIZE_END, -1);
|
2010-07-19 19:42:15 +00:00
|
|
|
if (!new_bookmark && katze_item_get_meta_string (bookmark, "folder")
|
2010-07-02 15:08:08 +00:00
|
|
|
&& g_str_equal (katze_item_get_meta_string (bookmark, "folder"), name))
|
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (combo_folder), n);
|
2009-02-23 23:17:21 +00:00
|
|
|
n++;
|
2009-01-01 02:52:43 +00:00
|
|
|
}
|
2009-11-23 19:46:00 +00:00
|
|
|
if (n < 2)
|
2009-01-01 02:52:43 +00:00
|
|
|
gtk_widget_set_sensitive (combo_folder, FALSE);
|
2010-06-14 07:00:05 +00:00
|
|
|
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), combo_folder, TRUE, TRUE, 0);
|
2010-02-19 18:05:29 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (content_area), hbox);
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_widget_show_all (hbox);
|
|
|
|
}
|
|
|
|
|
2010-05-18 21:16:14 +00:00
|
|
|
if (new_bookmark && !is_folder)
|
|
|
|
{
|
|
|
|
hbox = gtk_hbox_new (FALSE, 8);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 1);
|
|
|
|
label = gtk_label_new (NULL);
|
|
|
|
gtk_size_group_add_widget (sizegroup, label);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
label = gtk_button_new_with_mnemonic (_("Add to _Speed Dial"));
|
|
|
|
g_signal_connect (label, "clicked",
|
|
|
|
G_CALLBACK (midori_browser_edit_bookmark_add_speed_dial_cb), bookmark);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (content_area), hbox);
|
|
|
|
gtk_widget_show_all (hbox);
|
|
|
|
}
|
|
|
|
|
2009-11-23 19:46:00 +00:00
|
|
|
hbox = gtk_hbox_new (FALSE, 8);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 1);
|
|
|
|
label = gtk_label_new (NULL);
|
|
|
|
gtk_size_group_add_widget (sizegroup, label);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
check_toolbar = gtk_check_button_new_with_mnemonic (_("Show in the tool_bar"));
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_toolbar),
|
2010-07-01 05:24:17 +00:00
|
|
|
katze_item_get_meta_boolean (bookmark, "toolbar"));
|
2009-11-23 19:46:00 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), check_toolbar, TRUE, TRUE, 0);
|
2010-02-19 18:05:29 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (content_area), hbox);
|
2009-11-23 19:46:00 +00:00
|
|
|
gtk_widget_show_all (hbox);
|
|
|
|
|
2009-11-18 22:10:47 +00:00
|
|
|
check_app = NULL;
|
2010-07-01 01:19:15 +00:00
|
|
|
if (!is_folder)
|
2009-11-18 22:10:47 +00:00
|
|
|
{
|
|
|
|
hbox = gtk_hbox_new (FALSE, 8);
|
2009-11-23 19:46:00 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 1);
|
2009-11-18 22:10:47 +00:00
|
|
|
label = gtk_label_new (NULL);
|
|
|
|
gtk_size_group_add_widget (sizegroup, label);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
check_app = gtk_check_button_new_with_mnemonic (_("Run as _web application"));
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_app),
|
2010-07-01 05:24:17 +00:00
|
|
|
katze_item_get_meta_boolean (bookmark, "app"));
|
2009-11-18 22:10:47 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), check_app, TRUE, TRUE, 0);
|
2010-02-19 18:05:29 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (content_area), hbox);
|
2009-11-18 22:10:47 +00:00
|
|
|
gtk_widget_show_all (hbox);
|
|
|
|
}
|
|
|
|
|
2008-06-15 11:29:30 +00:00
|
|
|
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;
|
2010-07-19 20:58:18 +00:00
|
|
|
|
|
|
|
if (!new_bookmark)
|
2010-08-10 21:46:49 +00:00
|
|
|
katze_array_remove_item (browser->bookmarks, bookmark);
|
2009-01-01 02:52:43 +00:00
|
|
|
|
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)));
|
2009-11-23 19:46:00 +00:00
|
|
|
katze_item_set_meta_integer (bookmark, "toolbar",
|
2010-06-19 13:56:50 +00:00
|
|
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_toolbar)));
|
2010-07-01 01:19:15 +00:00
|
|
|
if (!is_folder)
|
2009-11-18 22:10:47 +00:00
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
katze_item_set_uri (bookmark,
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_entry_get_text (GTK_ENTRY (entry_uri)));
|
2009-11-18 22:10:47 +00:00
|
|
|
katze_item_set_meta_integer (bookmark, "app",
|
2010-06-19 13:56:50 +00:00
|
|
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_app)));
|
2009-11-18 22:10:47 +00:00
|
|
|
}
|
2008-06-15 11:29:30 +00:00
|
|
|
|
2009-11-18 22:10:47 +00:00
|
|
|
selected = gtk_combo_box_get_active_text (GTK_COMBO_BOX (combo_folder));
|
2010-06-13 20:33:23 +00:00
|
|
|
if (!strcmp (selected, _("Toplevel folder")))
|
2010-11-21 15:49:20 +00:00
|
|
|
katze_assign (selected, g_strdup (""));
|
|
|
|
katze_item_set_meta_string (bookmark, "folder", selected);
|
|
|
|
katze_array_add_item (browser->bookmarks, bookmark);
|
2010-06-25 04:24:53 +00:00
|
|
|
|
|
|
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_toolbar)))
|
2010-11-21 15:49:20 +00:00
|
|
|
if (!gtk_widget_get_visible (browser->bookmarkbar))
|
2010-06-25 04:24:53 +00:00
|
|
|
_action_set_active (browser, "Bookmarkbar", TRUE);
|
2009-11-18 22:10:47 +00:00
|
|
|
g_free (selected);
|
2010-07-02 04:50:14 +00:00
|
|
|
return_status = TRUE;
|
2008-06-15 11:29:30 +00:00
|
|
|
}
|
2010-07-19 18:55:59 +00:00
|
|
|
if (gtk_widget_get_visible (browser->bookmarkbar))
|
|
|
|
midori_bookmarkbar_populate (browser);
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_widget_destroy (dialog);
|
2010-07-02 04:50:14 +00:00
|
|
|
return return_status;
|
2008-06-15 11:29:30 +00:00
|
|
|
}
|
|
|
|
|
2010-04-30 19:36:33 +00:00
|
|
|
static gboolean
|
|
|
|
midori_browser_prepare_download (MidoriBrowser* browser,
|
|
|
|
WebKitDownload* download,
|
|
|
|
const gchar* uri)
|
|
|
|
|
|
|
|
{
|
|
|
|
guint64 total_size = webkit_download_get_total_size (download);
|
|
|
|
GFile* file = g_file_new_for_uri (uri);
|
|
|
|
GFile* folder = g_file_get_parent (file);
|
|
|
|
GError* error = NULL;
|
|
|
|
GFileInfo* info = g_file_query_filesystem_info (folder,
|
|
|
|
G_FILE_ATTRIBUTE_FILESYSTEM_FREE, NULL, &error);
|
|
|
|
guint64 free_space = g_file_info_get_attribute_uint64 (info,
|
|
|
|
G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
|
2010-09-30 23:12:12 +00:00
|
|
|
gchar* path = g_file_get_path (folder);
|
|
|
|
gboolean can_write = g_access (path, W_OK) == 0;
|
|
|
|
g_free (path);
|
2010-04-30 19:36:33 +00:00
|
|
|
g_object_unref (file);
|
|
|
|
g_object_unref (folder);
|
2010-09-30 23:12:12 +00:00
|
|
|
if (free_space < total_size || !can_write)
|
2010-04-30 19:36:33 +00:00
|
|
|
{
|
2010-09-30 23:12:12 +00:00
|
|
|
gchar* message;
|
|
|
|
gchar* detailed_message;
|
|
|
|
|
|
|
|
if (!can_write)
|
|
|
|
{
|
|
|
|
message = g_strdup_printf (
|
|
|
|
_("The file \"%s\" can't be saved in this folder."), &uri[7]);
|
|
|
|
detailed_message = g_strdup_printf (
|
|
|
|
_("You don't have permission to write in this location."));
|
|
|
|
}
|
|
|
|
else if (free_space < total_size)
|
|
|
|
{
|
|
|
|
gchar* total_size_string = g_format_size_for_display (total_size);
|
|
|
|
gchar* free_space_string = g_format_size_for_display (free_space);
|
|
|
|
message = g_strdup_printf (
|
|
|
|
_("There is not enough free space to download \"%s\"."),
|
|
|
|
&uri[7]);
|
|
|
|
detailed_message = g_strdup_printf (
|
|
|
|
_("The file needs %s but only %s are left."),
|
|
|
|
total_size_string, free_space_string);
|
|
|
|
g_free (total_size_string);
|
|
|
|
g_free (free_space_string);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
2011-02-02 00:10:02 +00:00
|
|
|
sokoke_message_dialog (GTK_MESSAGE_ERROR, message, detailed_message, FALSE);
|
2010-04-30 19:36:33 +00:00
|
|
|
g_free (message);
|
|
|
|
g_free (detailed_message);
|
|
|
|
g_object_unref (download);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
webkit_download_set_destination_uri (download, uri);
|
2011-03-06 16:20:18 +00:00
|
|
|
g_signal_emit (browser, signals[ADD_DOWNLOAD], 0, download);
|
2010-06-17 18:03:11 +00:00
|
|
|
midori_transferbar_add_download_item (MIDORI_TRANSFERBAR (browser->transferbar), download);
|
2010-04-30 19:36:33 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2008-11-09 21:07:42 +00:00
|
|
|
|
2011-05-30 15:55:02 +00:00
|
|
|
static gchar*
|
|
|
|
midori_browser_save_source (const gchar* uri,
|
|
|
|
const gchar* data,
|
|
|
|
const size_t len,
|
|
|
|
const gchar* outfile);
|
|
|
|
|
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;
|
|
|
|
|
2010-04-02 16:38:56 +00:00
|
|
|
if (!gtk_widget_get_visible (GTK_WIDGET (browser)))
|
2009-02-28 13:05:01 +00:00
|
|
|
return;
|
|
|
|
|
2009-11-14 16:38:16 +00:00
|
|
|
dialog = sokoke_file_chooser_dialog_new (_("Save file as"),
|
|
|
|
GTK_WINDOW (browser), GTK_FILE_CHOOSER_ACTION_SAVE);
|
2010-06-11 20:52:51 +00:00
|
|
|
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
|
2008-11-09 21:07:42 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2009-11-14 16:38:16 +00:00
|
|
|
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
|
2008-11-09 21:07:42 +00:00
|
|
|
{
|
2011-05-30 15:55:02 +00:00
|
|
|
GtkWidget* view;
|
|
|
|
GtkWidget* web_view;
|
|
|
|
WebKitWebDataSource *data_source;
|
|
|
|
WebKitWebFrame *frame;
|
|
|
|
const GString *data;
|
2009-08-30 13:52:30 +00:00
|
|
|
|
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));
|
2011-05-30 15:55:02 +00:00
|
|
|
view = midori_browser_get_current_tab (browser);
|
|
|
|
web_view = midori_view_get_web_view (MIDORI_VIEW (view));
|
|
|
|
frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
|
|
|
|
data_source = webkit_web_frame_get_data_source (frame);
|
|
|
|
data = webkit_web_data_source_get_data (data_source);
|
2011-06-08 22:37:25 +00:00
|
|
|
if (data)
|
|
|
|
midori_browser_save_source (uri, data->str, data->len, filename);
|
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*
|
2011-03-22 21:59:56 +00:00
|
|
|
midori_browser_speed_dial_get_next_free_slot (MidoriView* view)
|
2009-05-10 12:39:20 +00:00
|
|
|
{
|
2011-03-22 21:59:56 +00:00
|
|
|
MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (view));
|
|
|
|
GKeyFile* key_file;
|
|
|
|
guint cols, rows, slot = 1;
|
|
|
|
|
|
|
|
g_object_get (browser, "speed-dial", &key_file, NULL);
|
|
|
|
rows = g_key_file_get_integer (key_file, "settings", "rows", NULL);
|
|
|
|
cols = g_key_file_get_integer (key_file, "settings", "columns", NULL);
|
|
|
|
while (slot <= cols * rows)
|
2009-05-10 12:39:20 +00:00
|
|
|
{
|
2011-03-22 21:59:56 +00:00
|
|
|
gchar* dial_id = g_strdup_printf ("Dial %d", slot);
|
|
|
|
if (!g_key_file_has_group (key_file, dial_id))
|
2009-05-13 21:56:55 +00:00
|
|
|
{
|
2011-03-22 21:59:56 +00:00
|
|
|
g_free (dial_id);
|
|
|
|
return g_strdup_printf ("s%d", slot);
|
2009-05-13 21:56:55 +00:00
|
|
|
}
|
2011-03-22 21:59:56 +00:00
|
|
|
g_free (dial_id);
|
|
|
|
slot++;
|
2009-05-10 12:39:20 +00:00
|
|
|
}
|
2011-03-22 21:59:56 +00:00
|
|
|
return NULL;
|
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
|
|
|
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)));
|
2011-03-22 21:59:56 +00:00
|
|
|
gchar* slot_id = midori_browser_speed_dial_get_next_free_slot (MIDORI_VIEW (view));
|
2009-05-15 21:49:01 +00:00
|
|
|
|
2009-05-10 12:39:20 +00:00
|
|
|
if (slot_id == NULL)
|
|
|
|
{
|
|
|
|
g_free (uri);
|
|
|
|
g_free (title);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-03-22 21:59:56 +00:00
|
|
|
if ((img = midori_view_get_snapshot (MIDORI_VIEW (view), 240, 160)))
|
2009-05-10 12:39:20 +00:00
|
|
|
{
|
2011-03-22 21:59:56 +00:00
|
|
|
gint i;
|
|
|
|
GKeyFile* key_file;
|
|
|
|
gchar* dial_id = g_strdup_printf ("Dial %s", slot_id + 1);
|
|
|
|
gchar* config_file = g_build_filename (sokoke_set_config_dir (NULL),
|
|
|
|
"speeddial", NULL);
|
2011-04-08 19:18:41 +00:00
|
|
|
gchar* file_path = sokoke_build_thumbnail_path (uri);
|
2011-04-05 17:52:59 +00:00
|
|
|
gchar* thumb_dir = g_build_path (G_DIR_SEPARATOR_S, g_get_user_cache_dir (),
|
|
|
|
PACKAGE_NAME, "thumbnails", NULL);
|
2011-03-22 21:59:56 +00:00
|
|
|
g_object_get (browser, "speed-dial", &key_file, NULL);
|
2009-05-15 21:49:01 +00:00
|
|
|
|
2011-03-22 21:59:56 +00:00
|
|
|
g_key_file_set_string (key_file, dial_id, "uri", uri);
|
|
|
|
g_key_file_set_string (key_file, dial_id, "title", title);
|
2009-05-15 21:49:01 +00:00
|
|
|
|
2011-04-05 17:52:59 +00:00
|
|
|
if (!g_file_test (thumb_dir, G_FILE_TEST_EXISTS))
|
|
|
|
katze_mkdir_with_parents (thumb_dir, 0700);
|
|
|
|
|
2011-03-22 21:59:56 +00:00
|
|
|
gdk_pixbuf_save (img, file_path, "png", NULL, "compression", "7", NULL);
|
|
|
|
sokoke_key_file_save_to_file (key_file, config_file, NULL);
|
2009-05-15 21:49:01 +00:00
|
|
|
|
2011-03-22 21:59:56 +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-10 12:39:20 +00:00
|
|
|
|
2011-03-22 21:59:56 +00:00
|
|
|
|
|
|
|
g_object_unref (img);
|
|
|
|
g_free (file_path);
|
2011-04-05 17:52:59 +00:00
|
|
|
g_free (thumb_dir);
|
2011-03-22 21:59:56 +00:00
|
|
|
g_free (config_file);
|
|
|
|
g_free (dial_id);
|
2009-05-10 12:39:20 +00:00
|
|
|
}
|
2010-10-14 18:26:23 +00:00
|
|
|
g_free (uri);
|
2011-03-22 21:59:56 +00:00
|
|
|
g_free (title);
|
2010-10-14 18:26:23 +00:00
|
|
|
g_free (slot_id);
|
2009-05-10 12:39:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2009-12-23 15:46:14 +00:00
|
|
|
GtkWidget* toplevel;
|
|
|
|
GtkWidget* scrolled;
|
|
|
|
|
|
|
|
toplevel = gtk_widget_get_toplevel (inspector_view);
|
|
|
|
gtk_widget_hide (toplevel);
|
|
|
|
scrolled = gtk_widget_get_parent (browser->inspector_view);
|
|
|
|
gtk_widget_destroy (browser->inspector_view);
|
|
|
|
gtk_widget_reparent (inspector_view, scrolled);
|
|
|
|
gtk_widget_show_all (browser->inspector);
|
2008-11-01 18:15:58 +00:00
|
|
|
browser->inspector_view = inspector_view;
|
2009-12-23 15:46:14 +00:00
|
|
|
gtk_widget_destroy (toplevel);
|
2008-11-01 18:15:58 +00:00
|
|
|
}
|
|
|
|
|
2011-04-04 19:56:21 +00:00
|
|
|
static void
|
|
|
|
midori_view_detach_inspector_cb (GtkWidget* view,
|
|
|
|
GtkWidget* inspector_view,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkWidget* scrolled = gtk_widget_get_parent (GTK_WIDGET (inspector_view));
|
2011-04-19 21:21:31 +00:00
|
|
|
GtkWidget* paned = gtk_widget_get_parent (scrolled);
|
2011-04-04 19:56:21 +00:00
|
|
|
browser->inspector_view = gtk_viewport_new (NULL, NULL);
|
|
|
|
gtk_container_remove (GTK_CONTAINER (scrolled), GTK_WIDGET (inspector_view));
|
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled), browser->inspector_view);
|
2011-04-19 21:21:31 +00:00
|
|
|
gtk_widget_hide (paned);
|
2011-04-04 19:56:21 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2010-03-30 20:45:49 +00:00
|
|
|
copy_from = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view_from)));
|
2009-07-30 21:38:14 +00:00
|
|
|
list_from = webkit_web_view_get_back_forward_list (copy_from);
|
2010-03-30 20:45:49 +00:00
|
|
|
copy_to = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view_to)));
|
2009-07-30 21:38:14 +00:00
|
|
|
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-10-30 22:43:28 +00:00
|
|
|
MidoriBrowser* new_browser;
|
|
|
|
g_signal_emit (browser, signals[NEW_WINDOW], 0, NULL, &new_browser);
|
2010-10-24 18:33:38 +00:00
|
|
|
if (new_browser)
|
|
|
|
midori_browser_add_uri (new_browser, uri);
|
|
|
|
else /* No MidoriApp, so this is app or private mode */
|
|
|
|
sokoke_spawn_app (uri, TRUE);
|
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,
|
2011-04-19 21:16:34 +00:00
|
|
|
gboolean user_initiated,
|
2008-12-03 03:16:19 +00:00
|
|
|
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-10-30 22:43:28 +00:00
|
|
|
MidoriBrowser* new_browser;
|
|
|
|
g_signal_emit (browser, signals[NEW_WINDOW], 0, NULL, &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
|
|
|
}
|
2009-11-10 19:04:48 +00:00
|
|
|
else if (gtk_widget_get_parent (new_view) != browser->notebook)
|
2008-12-03 03:16:19 +00:00
|
|
|
{
|
|
|
|
gint n = midori_browser_add_tab (browser, new_view);
|
|
|
|
if (where != MIDORI_NEW_VIEW_BACKGROUND)
|
|
|
|
midori_browser_set_current_page (browser, n);
|
|
|
|
}
|
2011-04-19 21:16:34 +00:00
|
|
|
|
|
|
|
if (!user_initiated)
|
|
|
|
{
|
|
|
|
GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (browser));
|
|
|
|
GdkWindowState state = gdk_window_get_state (window);
|
|
|
|
if ((state | GDK_WINDOW_STATE_MAXIMIZED)
|
|
|
|
|| (state | GDK_WINDOW_STATE_FULLSCREEN))
|
|
|
|
{
|
|
|
|
if (where == MIDORI_NEW_VIEW_WINDOW)
|
|
|
|
g_signal_emit (browser, signals[SEND_NOTIFICATION], 0,
|
|
|
|
_("New Window"), _("A new window has been opened"));
|
|
|
|
else if (!browser->show_tabs)
|
|
|
|
g_signal_emit (browser, signals[SEND_NOTIFICATION], 0,
|
|
|
|
_("New Tab"), _("A new tab has been opened"));
|
|
|
|
}
|
|
|
|
}
|
2008-12-03 03:16:19 +00:00
|
|
|
}
|
|
|
|
|
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-12-09 19:56:47 +00:00
|
|
|
if (response == GTK_RESPONSE_OK)
|
2009-06-01 17:33:44 +00:00
|
|
|
{
|
|
|
|
gchar* uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
|
2010-04-30 19:36:33 +00:00
|
|
|
if (midori_browser_prepare_download (browser, download, uri))
|
|
|
|
webkit_download_start (download);
|
2009-06-01 17:33:44 +00:00
|
|
|
g_free (uri);
|
|
|
|
}
|
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-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)
|
|
|
|
{
|
2009-11-14 16:38:16 +00:00
|
|
|
dialog = sokoke_file_chooser_dialog_new (_("Save file"),
|
|
|
|
GTK_WINDOW (browser), GTK_FILE_CHOOSER_ACTION_SAVE);
|
2010-05-07 21:34:53 +00:00
|
|
|
gtk_file_chooser_set_do_overwrite_confirmation (
|
|
|
|
GTK_FILE_CHOOSER (dialog), TRUE);
|
2009-06-02 23:15:36 +00:00
|
|
|
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);
|
2010-04-24 22:57:21 +00:00
|
|
|
g_signal_connect (dialog, "destroy",
|
|
|
|
G_CALLBACK (gtk_widget_destroyed), &dialog);
|
2009-06-02 23:15:36 +00:00
|
|
|
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
|
|
|
{
|
2010-05-08 21:42:49 +00:00
|
|
|
const gchar* suggested;
|
|
|
|
gchar* basename;
|
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");
|
2010-05-08 21:42:49 +00:00
|
|
|
suggested = webkit_download_get_suggested_filename (download);
|
|
|
|
/* The suggested name may contain a folder name */
|
|
|
|
basename = g_path_get_basename (suggested);
|
|
|
|
filename = g_build_filename (folder, basename, NULL);
|
|
|
|
g_free (basename);
|
2010-05-07 21:34:53 +00:00
|
|
|
/* If the filename exists, choose a different name */
|
|
|
|
if (g_access (filename, F_OK) == 0)
|
|
|
|
{
|
2010-06-30 19:15:11 +00:00
|
|
|
/* Put the number in front of the extension */
|
|
|
|
gchar* extension = strrchr (filename, '.');
|
|
|
|
gsize length = extension ? (gsize)(extension - filename) : strlen (filename);
|
2010-05-07 21:34:53 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (g_ascii_isdigit (filename[length - 1]))
|
2010-06-30 19:15:11 +00:00
|
|
|
filename[length - 1] += 1; /* FIXME: This will increment '9' to ':' */
|
2010-05-07 21:34:53 +00:00
|
|
|
else
|
|
|
|
{
|
2010-06-30 19:15:11 +00:00
|
|
|
gchar* new_filename;
|
|
|
|
if (extension)
|
|
|
|
{
|
|
|
|
/* Change the '.' to a '\0' to put the 0 in between */
|
|
|
|
*extension++ = '\0';
|
|
|
|
new_filename= g_strconcat (filename, "0.", extension, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
new_filename = g_strconcat (filename, "0", NULL);
|
2010-05-07 21:34:53 +00:00
|
|
|
katze_assign (filename, new_filename);
|
2010-06-30 19:15:11 +00:00
|
|
|
if (extension)
|
|
|
|
{
|
|
|
|
extension = strrchr (filename, '.');
|
|
|
|
length = extension - filename;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
length = strlen (filename);
|
2010-05-07 21:34:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
while (g_access (filename, F_OK) == 0);
|
|
|
|
}
|
2009-06-01 17:33:44 +00:00
|
|
|
g_free (folder);
|
|
|
|
uri = g_filename_to_uri (filename, NULL, NULL);
|
|
|
|
g_free (filename);
|
2010-04-30 19:36:33 +00:00
|
|
|
midori_browser_prepare_download (browser, download, uri);
|
2009-06-01 17:33:44 +00:00
|
|
|
g_free (uri);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2010-06-20 18:13:39 +00:00
|
|
|
midori_findbar_search_text (MIDORI_FINDBAR (browser->find), view, found, typing);
|
2008-09-28 14:29:41 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
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));
|
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
|
|
|
}
|
|
|
|
|
2011-03-23 19:41:40 +00:00
|
|
|
static void
|
|
|
|
_midori_browser_update_notebook (MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
gint new_size = 0;
|
|
|
|
gint n = gtk_notebook_get_n_pages (GTK_NOTEBOOK(browser->notebook));
|
|
|
|
const gint max_size = 150;
|
|
|
|
const gint min_size = 32;
|
|
|
|
GtkAllocation notebook_size;
|
|
|
|
|
|
|
|
gtk_widget_get_allocation (browser->notebook, ¬ebook_size);
|
|
|
|
if (n > 0) new_size = notebook_size.width / n - 7;
|
|
|
|
if (new_size < min_size) new_size = min_size;
|
|
|
|
if (new_size > max_size) new_size = max_size;
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
|
|
|
GtkWidget* view;
|
|
|
|
GtkWidget* label;
|
|
|
|
view = gtk_notebook_get_nth_page (GTK_NOTEBOOK(browser->notebook), i);
|
|
|
|
label = gtk_notebook_get_tab_label (GTK_NOTEBOOK(browser->notebook), view);
|
2011-03-23 21:48:53 +00:00
|
|
|
/* Don't resize empty bin, which is used for thumbnail tabs */
|
2011-04-03 21:59:29 +00:00
|
|
|
if (GTK_IS_BIN (label) && gtk_bin_get_child (GTK_BIN (label))
|
|
|
|
&& !katze_object_get_boolean (view, "minimized"))
|
2011-03-23 21:48:53 +00:00
|
|
|
gtk_widget_set_size_request (label, new_size, -1);
|
2011-03-23 19:41:40 +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
|
|
|
{
|
2009-09-29 20:25:09 +00:00
|
|
|
GtkNotebook* notebook = GTK_NOTEBOOK (browser->notebook);
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* tab_label;
|
|
|
|
KatzeItem* item;
|
2008-06-15 02:02:56 +00:00
|
|
|
guint n;
|
|
|
|
|
2010-10-04 19:36:26 +00:00
|
|
|
gtk_widget_set_can_focus (view, TRUE);
|
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,
|
2011-04-03 21:59:29 +00:00
|
|
|
"signal::notify::minimized",
|
|
|
|
midori_view_notify_minimized_cb, browser,
|
2008-09-26 21:13:46 +00:00
|
|
|
"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,
|
2011-04-04 19:56:21 +00:00
|
|
|
"signal::detach-inspector",
|
|
|
|
midori_view_detach_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
|
|
|
"signal::download-requested",
|
|
|
|
midori_view_download_requested_cb, browser,
|
2008-09-28 14:29:41 +00:00
|
|
|
"signal::search-text",
|
|
|
|
midori_view_search_text_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") &&
|
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
|
|
|
{
|
2011-02-19 21:22:52 +00:00
|
|
|
n = gtk_notebook_get_current_page (notebook) + 1;
|
|
|
|
gtk_notebook_insert_page (notebook, view, tab_label, n);
|
|
|
|
katze_array_move_item (browser->proxy_array, item, n);
|
2008-08-15 18:38:27 +00:00
|
|
|
}
|
|
|
|
else
|
2011-02-19 21:22:52 +00:00
|
|
|
{
|
2009-09-29 20:25:09 +00:00
|
|
|
gtk_notebook_append_page (notebook, view, tab_label);
|
2011-02-19 21:22:52 +00:00
|
|
|
katze_array_move_item (browser->proxy_array, item,
|
|
|
|
gtk_notebook_get_n_pages (notebook));
|
|
|
|
}
|
2008-08-15 18:38:27 +00:00
|
|
|
|
2009-09-29 20:25:09 +00:00
|
|
|
gtk_notebook_set_tab_reorderable (notebook, view, TRUE);
|
|
|
|
gtk_notebook_set_tab_detachable (notebook, 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);
|
2011-03-23 19:41:40 +00:00
|
|
|
_midori_browser_update_notebook (browser);
|
2008-06-15 02:02:56 +00:00
|
|
|
}
|
|
|
|
|
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);
|
2011-03-23 19:41:40 +00:00
|
|
|
_midori_browser_update_notebook (browser);
|
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
|
|
|
}
|
|
|
|
|
2009-11-03 22:47:33 +00:00
|
|
|
static gboolean
|
|
|
|
midori_browser_key_press_event (GtkWidget* widget,
|
|
|
|
GdkEventKey* event)
|
|
|
|
{
|
|
|
|
GtkWindow* window = GTK_WINDOW (widget);
|
2011-04-26 21:05:53 +00:00
|
|
|
MidoriBrowser* browser = MIDORI_BROWSER (widget);
|
2009-11-03 22:47:33 +00:00
|
|
|
GtkWidgetClass* widget_class;
|
2010-03-29 22:39:31 +00:00
|
|
|
guint clean_state;
|
2011-07-28 19:59:29 +00:00
|
|
|
GtkWidget* focus;
|
2009-11-03 22:47:33 +00:00
|
|
|
|
2011-04-26 21:05:53 +00:00
|
|
|
/* Interpret Ctrl(+Shift)+Tab as tab switching for compatibility */
|
|
|
|
if (midori_browser_get_nth_tab (browser, 1) != NULL
|
|
|
|
&& event->keyval == GDK_Tab
|
|
|
|
&& (event->state & GDK_CONTROL_MASK))
|
|
|
|
{
|
|
|
|
gtk_action_activate (_action_by_name (browser, "TabNext"));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (event->keyval == GDK_ISO_Left_Tab
|
|
|
|
&& (event->state & GDK_CONTROL_MASK)
|
|
|
|
&& (event->state & GDK_SHIFT_MASK))
|
|
|
|
{
|
|
|
|
gtk_action_activate (_action_by_name (browser, "TabPrevious"));
|
|
|
|
return TRUE;
|
|
|
|
}
|
2011-07-09 20:48:26 +00:00
|
|
|
/* Interpret Ctrl+= as Zoom In for compatibility */
|
|
|
|
else if ((event->keyval == GDK_KP_Equal || event->keyval == GDK_equal)
|
|
|
|
&& (event->state & GDK_CONTROL_MASK))
|
|
|
|
{
|
|
|
|
midori_browser_activate_action (browser, "ZoomIn");
|
|
|
|
return TRUE;
|
|
|
|
}
|
2011-05-15 23:05:27 +00:00
|
|
|
/* Interpret F5 as reloading for compatibility */
|
|
|
|
else if (event->keyval == GDK_F5)
|
|
|
|
{
|
|
|
|
gtk_action_activate (_action_by_name (browser, "Reload"));
|
|
|
|
return TRUE;
|
|
|
|
}
|
2011-04-26 21:05:53 +00:00
|
|
|
|
2011-07-28 19:59:29 +00:00
|
|
|
focus = gtk_window_get_focus (GTK_WINDOW (widget));
|
|
|
|
if (focus == NULL)
|
2011-03-06 16:25:32 +00:00
|
|
|
gtk_widget_grab_focus (midori_browser_get_current_tab (MIDORI_BROWSER (widget)));
|
2011-07-28 19:59:29 +00:00
|
|
|
else if (G_OBJECT_TYPE (focus) == WEBKIT_TYPE_WEB_VIEW
|
|
|
|
&& event->keyval == GDK_space
|
|
|
|
&& !webkit_web_view_can_cut_clipboard (WEBKIT_WEB_VIEW (focus))
|
|
|
|
&& !webkit_web_view_can_paste_clipboard (WEBKIT_WEB_VIEW (focus)))
|
|
|
|
{
|
|
|
|
/* Space at the bottom of the page: Go to next page */
|
|
|
|
GtkScrolledWindow* scrolled = GTK_SCROLLED_WINDOW (gtk_widget_get_parent (focus));
|
|
|
|
MidoriView* view = MIDORI_VIEW (gtk_widget_get_parent (GTK_WIDGET (scrolled)));
|
|
|
|
GtkAdjustment* vadjust = gtk_scrolled_window_get_vadjustment (scrolled);
|
|
|
|
if (gtk_adjustment_get_value (vadjust)
|
|
|
|
== (gtk_adjustment_get_upper (vadjust) - gtk_adjustment_get_page_size (vadjust)))
|
|
|
|
{
|
|
|
|
/* Duplicate here because the URI pointer might change */
|
|
|
|
gchar* uri = g_strdup (midori_view_get_next_page (view));
|
|
|
|
if (uri != NULL)
|
|
|
|
{
|
|
|
|
midori_view_set_uri (view, uri);
|
|
|
|
g_free (uri);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-03-06 16:25:32 +00:00
|
|
|
|
2009-11-03 22:47:33 +00:00
|
|
|
if (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))
|
|
|
|
if (sokoke_window_activate_key (window, event))
|
|
|
|
return TRUE;
|
|
|
|
|
2010-03-29 22:39:31 +00:00
|
|
|
clean_state = event->state & gtk_accelerator_get_default_mod_mask();
|
|
|
|
if (!clean_state && gtk_window_propagate_key_event (window, event))
|
2009-11-03 22:47:33 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (!(event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)))
|
|
|
|
if (sokoke_window_activate_key (window, event))
|
|
|
|
return TRUE;
|
|
|
|
|
2009-11-29 13:31:23 +00:00
|
|
|
if (event->state && gtk_window_propagate_key_event (window, event))
|
2009-11-03 22:47:33 +00:00
|
|
|
return TRUE;
|
|
|
|
|
2011-07-19 20:14:07 +00:00
|
|
|
/* Interpret (Shift+)Backspace as going back (forward) for compatibility */
|
|
|
|
if ((event->keyval == GDK_BackSpace)
|
|
|
|
&& (event->state & GDK_SHIFT_MASK))
|
|
|
|
{
|
|
|
|
gtk_action_activate (_action_by_name (browser, "Forward"));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (event->keyval == GDK_BackSpace)
|
2011-05-14 23:43:26 +00:00
|
|
|
{
|
|
|
|
gtk_action_activate (_action_by_name (browser, "Back"));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-11-03 22:47:33 +00:00
|
|
|
widget_class = g_type_class_peek_static (g_type_parent (GTK_TYPE_WINDOW));
|
|
|
|
return widget_class->key_press_event (widget, event);
|
|
|
|
}
|
|
|
|
|
2010-05-22 21:48:03 +00:00
|
|
|
static gboolean
|
|
|
|
midori_browser_delete_event (GtkWidget* widget,
|
|
|
|
GdkEventAny* event)
|
|
|
|
{
|
|
|
|
MidoriBrowser* browser = MIDORI_BROWSER (widget);
|
2010-06-17 18:03:11 +00:00
|
|
|
return midori_transferbar_confirm_delete (MIDORI_TRANSFERBAR (browser->transferbar));
|
2010-05-22 21:48:03 +00:00
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
midori_browser_class_init (MidoriBrowserClass* class)
|
|
|
|
{
|
2009-11-03 22:47:33 +00:00
|
|
|
GtkWidgetClass* gtkwidget_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
|
2009-10-30 22:43:28 +00:00
|
|
|
* @window: a new browser window, or %NULL
|
2009-05-17 18:29:31 +00:00
|
|
|
*
|
|
|
|
* Emitted when a new browser window was created.
|
|
|
|
*
|
|
|
|
* Note: Before 0.1.7 the second argument was an URI string.
|
2009-10-30 22:43:28 +00:00
|
|
|
*
|
|
|
|
* Note: Since 0.2.1 the return value is a #MidoriBrowser
|
|
|
|
*
|
|
|
|
* Return value: a new #MidoriBrowser
|
2009-05-17 18:29:31 +00:00
|
|
|
*/
|
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-10-30 22:43:28 +00:00
|
|
|
midori_cclosure_marshal_OBJECT__OBJECT,
|
|
|
|
MIDORI_TYPE_BROWSER, 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
|
|
|
|
2011-03-07 21:56:20 +00:00
|
|
|
/**
|
|
|
|
* MidoriBrowser::move-tab:
|
|
|
|
* @browser: the object on which the signal is emitted
|
|
|
|
* @notebook: the notebook containing the tabs
|
|
|
|
* @cur_pos: the current position of the tab
|
|
|
|
* @new_pos: the new position of the tab
|
|
|
|
*
|
|
|
|
* Emitted when a tab is moved.
|
|
|
|
*
|
|
|
|
* Since: 0.3.3
|
|
|
|
*/
|
|
|
|
signals[MOVE_TAB] = g_signal_new (
|
|
|
|
"move-tab",
|
|
|
|
G_TYPE_FROM_CLASS (class),
|
|
|
|
(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
midori_cclosure_marshal_VOID__OBJECT_INT_INT,
|
|
|
|
G_TYPE_NONE, 3,
|
|
|
|
GTK_TYPE_NOTEBOOK, G_TYPE_INT, G_TYPE_INT);
|
|
|
|
|
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,
|
2011-04-19 21:16:34 +00:00
|
|
|
* e.g. when a download has been completed or a new tab was opened.
|
2009-05-09 13:55:10 +00:00
|
|
|
*
|
|
|
|
* 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);
|
2011-04-17 20:43:54 +00:00
|
|
|
/**
|
|
|
|
* MidoriBrowser::populate-toolbar-menu:
|
|
|
|
* @browser: the object on which the signal is emitted
|
|
|
|
* @menu: the #GtkMenu to populate
|
|
|
|
*
|
|
|
|
* Emitted when a toolbar menu is displayed on right-click.
|
|
|
|
*
|
|
|
|
* Since: 0.3.4
|
|
|
|
*/
|
|
|
|
signals[POPULATE_TOOLBAR_MENU] = g_signal_new (
|
|
|
|
"populate-toolbar-menu",
|
|
|
|
G_TYPE_FROM_CLASS (class),
|
|
|
|
(GSignalFlags)(G_SIGNAL_RUN_LAST),
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
g_cclosure_marshal_VOID__OBJECT,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
GTK_TYPE_MENU);
|
2009-07-24 21:55:57 +00:00
|
|
|
|
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);
|
|
|
|
|
2011-04-14 01:29:50 +00:00
|
|
|
/**
|
|
|
|
* MidoriBrowser::show-preferences:
|
|
|
|
* @browser: the object on which the signal is emitted
|
|
|
|
* @preferences: the #KatzePreferences to populate
|
|
|
|
*
|
|
|
|
* Emitted when a preference dialogue displayed, to allow
|
|
|
|
* adding of a new page, to be used sparingly.
|
|
|
|
*
|
|
|
|
* Since: 0.3.4
|
|
|
|
*/
|
|
|
|
signals[SHOW_PREFERENCES] = g_signal_new (
|
|
|
|
"show-preferences",
|
|
|
|
G_TYPE_FROM_CLASS (class),
|
|
|
|
(GSignalFlags)(G_SIGNAL_RUN_LAST),
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
g_cclosure_marshal_VOID__OBJECT,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
KATZE_TYPE_PREFERENCES);
|
|
|
|
|
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
|
|
|
|
2009-11-03 22:47:33 +00:00
|
|
|
gtkwidget_class = GTK_WIDGET_CLASS (class);
|
|
|
|
gtkwidget_class->key_press_event = midori_browser_key_press_event;
|
2010-05-22 21:48:03 +00:00
|
|
|
gtkwidget_class->delete_event = midori_browser_delete_event;
|
2009-11-03 22:47:33 +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
|
|
|
|
2009-10-27 22:55:17 +00:00
|
|
|
/**
|
|
|
|
* MidoriBrowser:statusbar:
|
|
|
|
*
|
|
|
|
* The widget representing the statusbar contents. This is
|
|
|
|
* not an actual #GtkStatusbar but rather a #GtkBox.
|
|
|
|
*/
|
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",
|
2009-10-27 22:55:17 +00:00
|
|
|
GTK_TYPE_BOX,
|
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
|
|
|
|
2011-03-14 19:07:18 +00:00
|
|
|
/**
|
|
|
|
* MidoriBrowser:speed-dial:
|
|
|
|
*
|
|
|
|
* The speed dial configuration file.
|
|
|
|
*
|
|
|
|
* Since: 0.3.4
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_SPEED_DIAL,
|
|
|
|
g_param_spec_pointer (
|
|
|
|
"speed-dial",
|
|
|
|
"Speeddial",
|
|
|
|
"Pointer to key-value object with speed dial items",
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
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-10-30 22:43:28 +00:00
|
|
|
MidoriBrowser* new_browser;
|
|
|
|
g_signal_emit (browser, signals[NEW_WINDOW], 0, NULL, &new_browser);
|
2009-11-21 05:45:01 +00:00
|
|
|
if (new_browser)
|
|
|
|
{
|
|
|
|
midori_browser_add_uri (new_browser, "");
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2009-12-12 20:56:11 +00:00
|
|
|
static void
|
|
|
|
_action_private_browsing_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
const gchar* uri = midori_browser_get_current_uri (browser);
|
2010-10-13 21:41:11 +00:00
|
|
|
sokoke_spawn_app (uri && *uri ? uri : "about:blank", TRUE);
|
2009-12-12 20:56:11 +00:00
|
|
|
}
|
|
|
|
|
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-11-14 16:38:16 +00:00
|
|
|
GtkWidget* view;
|
2008-07-13 19:49:57 +00:00
|
|
|
|
2010-04-02 16:38:56 +00:00
|
|
|
if (!gtk_widget_get_visible (GTK_WIDGET (browser)))
|
2009-02-28 13:05:01 +00:00
|
|
|
return;
|
|
|
|
|
2009-11-14 16:38:16 +00:00
|
|
|
dialog = sokoke_file_chooser_dialog_new (_("Open file"),
|
|
|
|
GTK_WINDOW (browser), GTK_FILE_CHOOSER_ACTION_OPEN);
|
2008-05-20 01:01:54 +00:00
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
/* base the start folder on the current view's uri if it is local */
|
2009-11-14 16:38:16 +00:00
|
|
|
view = midori_browser_get_current_tab (browser);
|
2008-09-26 21:13:46 +00:00
|
|
|
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);
|
|
|
|
|
2009-11-14 16:38:16 +00:00
|
|
|
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
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);
|
|
|
|
}
|
|
|
|
|
2009-10-12 20:57:35 +00:00
|
|
|
static void
|
|
|
|
_action_add_desktop_shortcut_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2010-12-12 00:26:08 +00:00
|
|
|
#if HAVE_HILDON
|
2009-10-12 20:57:35 +00:00
|
|
|
/* TODO: Implement */
|
2010-12-12 00:26:08 +00:00
|
|
|
#elif defined (GDK_WINDOWING_X11)
|
|
|
|
GtkWidget* tab = midori_browser_get_current_tab (browser);
|
|
|
|
KatzeItem* item = midori_view_get_proxy_item (MIDORI_VIEW (tab));
|
|
|
|
const gchar* app_name = katze_item_get_name (item);
|
|
|
|
gchar* app_exec = g_strconcat ("midori -a ", katze_item_get_uri (item), NULL);
|
|
|
|
const gchar* icon_uri = midori_view_get_icon_uri (MIDORI_VIEW (tab));
|
|
|
|
gchar* app_icon;
|
|
|
|
GKeyFile* keyfile = g_key_file_new ();
|
|
|
|
gchar* filename = g_strconcat (app_name, ".desktop", NULL);
|
|
|
|
gchar* app_dir;
|
|
|
|
int i = 0;
|
|
|
|
while (filename[i] != '\0')
|
|
|
|
{
|
|
|
|
if (filename[i] == '/')
|
|
|
|
filename[i] = '_';
|
|
|
|
i++;
|
|
|
|
}
|
2011-01-19 20:31:23 +00:00
|
|
|
app_dir = g_build_filename (g_get_user_data_dir (),
|
2010-12-12 00:26:08 +00:00
|
|
|
"applications", filename, NULL);
|
|
|
|
app_icon = katze_net_get_cached_path (NULL, icon_uri, "icons");
|
|
|
|
if (!g_file_test (app_icon, G_FILE_TEST_EXISTS))
|
|
|
|
katze_assign (app_icon, g_strdup (STOCK_WEB_BROWSER));
|
|
|
|
g_key_file_set_string (keyfile, "Desktop Entry", "Version", "1.0");
|
|
|
|
g_key_file_set_string (keyfile, "Desktop Entry", "Type", "Application");
|
|
|
|
g_key_file_set_string (keyfile, "Desktop Entry", "Name", app_name);
|
|
|
|
g_key_file_set_string (keyfile, "Desktop Entry", "Exec", app_exec);
|
|
|
|
g_key_file_set_string (keyfile, "Desktop Entry", "TryExec", "midori");
|
|
|
|
g_key_file_set_string (keyfile, "Desktop Entry", "Icon", app_icon);
|
|
|
|
g_key_file_set_string (keyfile, "Desktop Entry", "Categories", "Network;");
|
|
|
|
sokoke_key_file_save_to_file (keyfile, app_dir, NULL);
|
|
|
|
g_free (app_dir);
|
|
|
|
g_free (filename);
|
|
|
|
g_free (app_exec);
|
|
|
|
g_key_file_free (keyfile);
|
2009-10-12 20:57:35 +00:00
|
|
|
#elif defined(GDK_WINDOWING_QUARTZ)
|
|
|
|
/* TODO: Implement */
|
|
|
|
#elif defined (GDK_WINDOWING_WIN32)
|
|
|
|
/* TODO: Implement */
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-11-22 14:33:13 +00:00
|
|
|
midori_browser_subscribe_to_news_feed (MidoriBrowser* browser,
|
|
|
|
const gchar* uri)
|
2009-10-12 20:57:35 +00:00
|
|
|
{
|
|
|
|
if (browser->news_aggregator && *browser->news_aggregator)
|
2011-05-01 04:57:41 +00:00
|
|
|
{
|
|
|
|
/* Special-case Liferea because a helper script may be required */
|
|
|
|
if (g_str_equal (browser->news_aggregator, "liferea")
|
|
|
|
&& g_find_program_in_path ("liferea-add-feed"))
|
|
|
|
sokoke_spawn_program ("liferea-add-feed", uri);
|
|
|
|
else
|
|
|
|
sokoke_spawn_program (browser->news_aggregator, uri);
|
|
|
|
}
|
2009-10-12 20:57:35 +00:00
|
|
|
else
|
2010-05-25 16:26:47 +00:00
|
|
|
{
|
|
|
|
gchar* description = g_strdup_printf ("%s\n\n%s", uri,
|
|
|
|
_("To use the above URI open a news aggregator. "
|
|
|
|
"There is usually a menu or button \"New Subscription\", "
|
|
|
|
"\"New News Feed\" or similar.\n"
|
|
|
|
"Alternatively go to Preferences, Applications in Midori, "
|
|
|
|
"and select a News Aggregator. Next time you click the "
|
|
|
|
"news feed icon, it will be added automatically."));
|
2011-02-02 00:10:02 +00:00
|
|
|
sokoke_message_dialog (GTK_MESSAGE_INFO, _("New feed"), description, FALSE);
|
2010-05-25 16:26:47 +00:00
|
|
|
g_free (description);
|
|
|
|
}
|
2009-10-12 20:57:35 +00:00
|
|
|
}
|
|
|
|
|
2009-11-22 14:33:13 +00:00
|
|
|
static void
|
|
|
|
_action_add_news_feed_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkWidget* view;
|
|
|
|
const gchar* uri;
|
|
|
|
|
|
|
|
if (!(view = midori_browser_get_current_tab (browser)))
|
|
|
|
return;
|
|
|
|
if (!(uri = g_object_get_data (G_OBJECT (view), "news-feeds")))
|
|
|
|
return;
|
|
|
|
|
|
|
|
midori_browser_subscribe_to_news_feed (browser, uri);
|
|
|
|
}
|
|
|
|
|
2009-12-29 22:49:10 +00:00
|
|
|
static void
|
|
|
|
_action_compact_add_response_cb (GtkWidget* dialog,
|
|
|
|
gint response,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
}
|
|
|
|
|
2009-10-12 20:57:35 +00:00
|
|
|
static void
|
|
|
|
_action_compact_add_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkWidget* dialog;
|
|
|
|
GtkBox* box;
|
2009-11-29 13:08:52 +00:00
|
|
|
const gchar* actions[] = { "BookmarkAdd", "AddSpeedDial",
|
|
|
|
"AddDesktopShortcut", "AddNewsFeed" };
|
|
|
|
guint i;
|
2009-10-12 20:57:35 +00:00
|
|
|
|
2010-04-02 16:38:56 +00:00
|
|
|
if (!gtk_widget_get_visible (GTK_WIDGET (browser)))
|
2009-10-12 20:57:35 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
dialog = g_object_new (GTK_TYPE_DIALOG,
|
2009-10-22 21:27:03 +00:00
|
|
|
"transient-for", browser,
|
|
|
|
"title", _("Add a new bookmark"), NULL);
|
2010-02-19 18:05:29 +00:00
|
|
|
box = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog)));
|
2009-10-12 20:57:35 +00:00
|
|
|
|
2009-11-29 13:08:52 +00:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (actions); i++)
|
|
|
|
{
|
|
|
|
gchar* label;
|
|
|
|
GtkWidget* button;
|
|
|
|
|
|
|
|
action = _action_by_name (browser, actions[i]);
|
|
|
|
label = katze_object_get_string (action, "label");
|
|
|
|
button = gtk_button_new_with_mnemonic (label);
|
|
|
|
g_free (label);
|
|
|
|
gtk_widget_set_name (button, "GtkButton-thumb");
|
|
|
|
gtk_box_pack_start (box, button, TRUE, TRUE, 4);
|
2010-01-31 19:38:56 +00:00
|
|
|
#if GTK_CHECK_VERSION (2, 16, 0)
|
|
|
|
gtk_activatable_set_related_action (GTK_ACTIVATABLE (button), action);
|
|
|
|
#else
|
2009-11-29 13:08:52 +00:00
|
|
|
gtk_action_connect_proxy (action, button);
|
2010-01-31 19:38:56 +00:00
|
|
|
#endif
|
2009-11-29 13:08:52 +00:00
|
|
|
g_signal_connect_swapped (button, "clicked",
|
|
|
|
G_CALLBACK (gtk_widget_destroy), dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_show (dialog);
|
2009-12-29 22:49:10 +00:00
|
|
|
g_signal_connect (dialog, "response",
|
|
|
|
G_CALLBACK (_action_compact_add_response_cb), NULL);
|
2009-10-12 20:57:35 +00:00
|
|
|
}
|
|
|
|
|
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);
|
2011-07-19 19:57:27 +00:00
|
|
|
if (gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), 1) == NULL &&
|
|
|
|
midori_view_is_blank (MIDORI_VIEW (widget)))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
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;
|
|
|
|
|
2010-04-02 16:38:56 +00:00
|
|
|
if (!gtk_widget_get_visible (GTK_WIDGET (browser)))
|
2009-04-05 09:28:42 +00:00
|
|
|
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
|
|
|
gboolean can_undo = FALSE, can_redo = FALSE;
|
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
|
|
|
can_undo = webkit_web_view_can_undo (view);
|
|
|
|
can_redo = webkit_web_view_can_redo (view);
|
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
|
|
|
_action_set_sensitive (browser, "Undo", can_undo);
|
|
|
|
_action_set_sensitive (browser, "Redo", can_redo);
|
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
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
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));
|
2011-03-06 17:13:54 +00:00
|
|
|
/* Work around broken clipboard handling for the sake of the user */
|
|
|
|
if (WEBKIT_IS_WEB_VIEW (widget))
|
|
|
|
{
|
|
|
|
GtkWidget* scrolled = gtk_widget_get_parent (widget);
|
|
|
|
GtkWidget* view = gtk_widget_get_parent (scrolled);
|
|
|
|
const gchar* selected = midori_view_get_selected_text (MIDORI_VIEW (view));
|
|
|
|
sokoke_widget_copy_clipboard (widget, selected);
|
|
|
|
return;
|
|
|
|
}
|
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
|
|
|
{
|
2010-06-20 18:13:39 +00:00
|
|
|
midori_findbar_invoke (MIDORI_FINDBAR (browser->find));
|
2009-02-22 14:36:41 +00:00
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
_action_find_next_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2010-06-20 18:13:39 +00:00
|
|
|
midori_findbar_find (MIDORI_FINDBAR (browser->find), TRUE);
|
2009-02-22 14:36:41 +00:00
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
_action_find_previous_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2010-06-20 18:13:39 +00:00
|
|
|
midori_findbar_find (MIDORI_FINDBAR (browser->find), FALSE);
|
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-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))
|
|
|
|
{
|
2010-01-31 19:38:56 +00:00
|
|
|
GtkAction* action;
|
|
|
|
|
|
|
|
action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (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-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",
|
2010-09-14 20:12:55 +00:00
|
|
|
"Fullscreen", "Preferences", "Window", "Bookmarks",
|
2010-07-04 20:54:27 +00:00
|
|
|
"ReloadStop", "ZoomIn", "TabClose",
|
2009-07-10 15:37:44 +00:00
|
|
|
"ZoomOut", "Separator", "Back", "Forward", "Homepage",
|
2009-12-26 22:12:36 +00:00
|
|
|
"Panel", "Trash", "Search", "BookmarkAdd", "Previous", "Next", NULL };
|
2009-07-10 15:37:44 +00:00
|
|
|
|
|
|
|
return actions;
|
|
|
|
}
|
|
|
|
|
2010-04-27 21:36:14 +00:00
|
|
|
/**
|
|
|
|
* midori_browser_get_settings:
|
|
|
|
*
|
|
|
|
* Retrieves the settings instance of the browser.
|
|
|
|
*
|
|
|
|
* Return value: a #MidoriWebSettings instance
|
|
|
|
*
|
|
|
|
* Since: 0.2.5
|
|
|
|
**/
|
|
|
|
MidoriWebSettings*
|
|
|
|
midori_browser_get_settings (MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
|
|
|
|
|
|
|
|
return browser->settings;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
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);
|
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
|
|
|
|
2011-04-17 20:43:54 +00:00
|
|
|
g_signal_emit (browser, signals[POPULATE_TOOLBAR_MENU], 0, menu);
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2009-09-30 21:57:36 +00:00
|
|
|
static void
|
|
|
|
midori_browser_menu_item_select_cb (GtkWidget* menuitem,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2010-01-31 19:38:56 +00:00
|
|
|
GtkAction* action;
|
|
|
|
gchar* tooltip;
|
|
|
|
|
|
|
|
action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (menuitem));
|
|
|
|
tooltip = action ? katze_object_get_string (action, "tooltip") : NULL;
|
2009-09-30 21:57:36 +00:00
|
|
|
if (!tooltip)
|
|
|
|
{
|
|
|
|
/* This is undocumented object data, used by KatzeArrayAction. */
|
|
|
|
KatzeItem* item = g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
|
|
|
|
if (item)
|
2010-01-01 16:53:58 +00:00
|
|
|
{
|
2009-10-01 21:19:01 +00:00
|
|
|
tooltip = g_strdup (katze_item_get_uri (item));
|
2011-04-17 20:29:51 +00:00
|
|
|
sokoke_prefetch_uri (midori_browser_get_settings (browser),
|
|
|
|
tooltip, NULL, NULL);
|
2010-01-01 16:53:58 +00:00
|
|
|
}
|
2009-09-30 21:57:36 +00:00
|
|
|
}
|
|
|
|
_midori_browser_set_statusbar_text (browser, tooltip);
|
2009-10-01 21:19:01 +00:00
|
|
|
g_free (tooltip);
|
2009-09-30 21:57:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_menu_item_deselect_cb (GtkWidget* menuitem,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
_midori_browser_set_statusbar_text (browser, NULL);
|
|
|
|
}
|
|
|
|
|
2010-07-19 19:39:57 +00:00
|
|
|
static gboolean
|
|
|
|
midori_bookmarkbar_activate_item_alt (GtkAction* action,
|
|
|
|
KatzeItem* item,
|
|
|
|
guint button,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2010-09-16 19:18:14 +00:00
|
|
|
if (button == 1)
|
|
|
|
{
|
|
|
|
midori_browser_open_bookmark (browser, item);
|
|
|
|
}
|
|
|
|
else if (button == 2)
|
2010-07-19 19:39:57 +00:00
|
|
|
{
|
|
|
|
gint n = midori_browser_add_uri (browser, katze_item_get_uri (item));
|
|
|
|
midori_browser_set_current_page_smartly (browser, n);
|
|
|
|
}
|
|
|
|
|
2010-09-16 19:18:14 +00:00
|
|
|
return TRUE;
|
2010-07-19 19:39:57 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2009-09-30 21:57:36 +00:00
|
|
|
GList* children = gtk_container_get_children (GTK_CONTAINER (menu));
|
|
|
|
guint i = 0;
|
2008-10-10 20:31:37 +00:00
|
|
|
GtkWidget* menuitem;
|
2008-09-26 21:13:46 +00:00
|
|
|
|
2009-09-30 21:57:36 +00:00
|
|
|
while ((menuitem = g_list_nth_data (children, i++)))
|
|
|
|
{
|
|
|
|
g_signal_connect (menuitem, "select",
|
|
|
|
G_CALLBACK (midori_browser_menu_item_select_cb), browser);
|
|
|
|
g_signal_connect (menuitem, "deselect",
|
|
|
|
G_CALLBACK (midori_browser_menu_item_deselect_cb), browser);
|
|
|
|
}
|
|
|
|
g_list_free (children);
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2009-05-05 21:22:39 +00:00
|
|
|
static gboolean
|
|
|
|
_action_trash_activate_item_alt (GtkAction* action,
|
|
|
|
KatzeItem* item,
|
|
|
|
guint button,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2010-09-16 19:18:14 +00:00
|
|
|
if (button == 1)
|
2009-05-05 21:22:39 +00:00
|
|
|
{
|
2010-09-16 19:18:14 +00:00
|
|
|
guint n = midori_browser_add_item (browser, item);
|
|
|
|
midori_browser_set_current_page (browser, n);
|
|
|
|
katze_array_remove_item (browser->trash, item);
|
|
|
|
_midori_browser_update_actions (browser);
|
|
|
|
}
|
|
|
|
else if (button == 2)
|
|
|
|
{
|
|
|
|
gint n = midori_browser_add_item (browser, item);
|
2010-07-03 07:28:03 +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);
|
|
|
|
}
|
|
|
|
|
2010-09-16 19:18:14 +00:00
|
|
|
return TRUE;
|
2009-05-05 21:22:39 +00:00
|
|
|
}
|
|
|
|
|
2009-11-25 22:55:12 +00:00
|
|
|
/* static */ void
|
2009-11-18 22:10:47 +00:00
|
|
|
midori_browser_open_bookmark (MidoriBrowser* browser,
|
|
|
|
KatzeItem* item)
|
|
|
|
{
|
2009-11-25 22:55:12 +00:00
|
|
|
const gchar* uri = katze_item_get_uri (item);
|
2009-11-30 18:25:39 +00:00
|
|
|
gchar* uri_fixed;
|
|
|
|
|
2009-11-25 22:55:12 +00:00
|
|
|
if (!(uri && *uri))
|
|
|
|
return;
|
|
|
|
|
2009-11-30 18:25:39 +00:00
|
|
|
/* Imported bookmarks may lack a protocol */
|
2010-02-09 17:13:47 +00:00
|
|
|
uri_fixed = sokoke_magic_uri (uri);
|
|
|
|
if (!uri_fixed)
|
|
|
|
uri_fixed = g_strdup (uri);
|
2009-11-30 18:25:39 +00:00
|
|
|
|
2010-07-02 05:05:11 +00:00
|
|
|
if (katze_item_get_meta_boolean (item, "app"))
|
2010-10-13 21:41:11 +00:00
|
|
|
sokoke_spawn_app (uri_fixed, FALSE);
|
2009-11-18 22:10:47 +00:00
|
|
|
else
|
|
|
|
{
|
2009-11-30 18:25:39 +00:00
|
|
|
midori_browser_set_current_uri (browser, uri_fixed);
|
2009-11-18 22:10:47 +00:00
|
|
|
gtk_widget_grab_focus (midori_browser_get_current_tab (browser));
|
|
|
|
}
|
2009-11-30 18:25:39 +00:00
|
|
|
g_free (uri_fixed);
|
2009-11-18 22:10:47 +00:00
|
|
|
}
|
|
|
|
|
2009-07-24 21:55:57 +00:00
|
|
|
static void
|
|
|
|
_action_tools_populate_popup (GtkAction* action,
|
|
|
|
GtkMenu* menu,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2010-04-04 19:19:59 +00:00
|
|
|
static const GtkActionEntry actions[] =
|
|
|
|
{
|
|
|
|
{ "ManageSearchEngines" },
|
|
|
|
{ "ClearPrivateData" },
|
|
|
|
{ "InspectPage" },
|
|
|
|
{ "-" },
|
|
|
|
{ NULL },
|
|
|
|
{ "p" },
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
{ NULL },
|
|
|
|
{ "Preferences" },
|
|
|
|
#endif
|
2009-07-24 21:55:57 +00:00
|
|
|
};
|
|
|
|
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-12-13 14:44:02 +00:00
|
|
|
static void
|
|
|
|
midori_browser_bookmark_popup (GtkWidget* widget,
|
|
|
|
GdkEventButton* event,
|
|
|
|
KatzeItem* item,
|
|
|
|
MidoriBrowser* browser);
|
|
|
|
|
2010-09-14 20:12:55 +00:00
|
|
|
static gboolean
|
|
|
|
_action_bookmarks_populate_folder (GtkAction* action,
|
|
|
|
GtkMenuShell* menu,
|
|
|
|
KatzeArray* folder,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
const char* sqlcmd = "SELECT uri, title, app, folder "
|
|
|
|
"FROM bookmarks WHERE folder = '%q' ORDER BY uri ASC";
|
|
|
|
sqlite3* db = g_object_get_data (G_OBJECT (browser->bookmarks), "db");
|
|
|
|
const gchar* folder_name;
|
|
|
|
char* sqlcmd_folder;
|
|
|
|
KatzeArray* bookmarks;
|
|
|
|
GtkWidget* menuitem;
|
|
|
|
|
|
|
|
if (!db)
|
2010-09-16 19:39:42 +00:00
|
|
|
return FALSE;
|
2010-09-14 20:12:55 +00:00
|
|
|
|
|
|
|
/* Clear items from dummy array here */
|
|
|
|
gtk_container_foreach (GTK_CONTAINER (menu),
|
|
|
|
(GtkCallback)(gtk_widget_destroy), NULL);
|
|
|
|
|
|
|
|
folder_name = katze_item_get_name (KATZE_ITEM (folder));
|
|
|
|
sqlcmd_folder = sqlite3_mprintf (sqlcmd, folder_name ? folder_name : "");
|
|
|
|
bookmarks = katze_array_from_sqlite (db, sqlcmd_folder);
|
|
|
|
sqlite3_free (sqlcmd_folder);
|
|
|
|
if (!bookmarks || katze_array_is_empty (bookmarks))
|
|
|
|
{
|
|
|
|
menuitem = gtk_image_menu_item_new_with_label (_("Empty"));
|
|
|
|
gtk_widget_set_sensitive (menuitem, FALSE);
|
|
|
|
gtk_menu_shell_append (menu, menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
katze_array_action_generate_menu (KATZE_ARRAY_ACTION (action), bookmarks,
|
|
|
|
menu, GTK_WIDGET (browser));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-10-10 20:31:37 +00:00
|
|
|
static void
|
|
|
|
_action_window_populate_popup (GtkAction* action,
|
|
|
|
GtkMenu* menu,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-09-30 21:57:36 +00:00
|
|
|
GList* children = gtk_container_get_children (GTK_CONTAINER (menu));
|
|
|
|
guint i = 0;
|
|
|
|
GtkWidget* menuitem;
|
|
|
|
|
|
|
|
while ((menuitem = g_list_nth_data (children, i++)))
|
|
|
|
{
|
|
|
|
g_signal_connect (menuitem, "select",
|
|
|
|
G_CALLBACK (midori_browser_menu_item_select_cb), browser);
|
|
|
|
g_signal_connect (menuitem, "deselect",
|
|
|
|
G_CALLBACK (midori_browser_menu_item_deselect_cb), browser);
|
|
|
|
}
|
|
|
|
g_list_free (children);
|
|
|
|
|
|
|
|
menuitem = gtk_separator_menu_item_new ();
|
2008-10-10 20:31:37 +00:00
|
|
|
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
2009-09-30 21:02:10 +00:00
|
|
|
menuitem = gtk_action_create_menu_item (
|
|
|
|
_action_by_name (browser, "LastSession"));
|
|
|
|
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
2009-09-30 20:18:17 +00:00
|
|
|
menuitem = gtk_action_create_menu_item (
|
|
|
|
_action_by_name (browser, "TabCurrent"));
|
|
|
|
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
2011-04-26 20:57:13 +00:00
|
|
|
menuitem = gtk_action_create_menu_item (
|
|
|
|
_action_by_name (browser, "NextView"));
|
|
|
|
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 (
|
2009-11-10 19:07:10 +00:00
|
|
|
_action_by_name (browser, "TabNext"));
|
2008-10-10 20:31:37 +00:00
|
|
|
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 (
|
2009-11-10 19:07:10 +00:00
|
|
|
_action_by_name (browser, "TabPrevious"));
|
2008-10-10 20:31:37 +00:00
|
|
|
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-09-16 19:18:14 +00:00
|
|
|
_action_window_activate_item_alt (GtkAction* action,
|
|
|
|
KatzeItem* item,
|
|
|
|
gint button,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2010-09-16 19:18:14 +00:00
|
|
|
guint i;
|
|
|
|
guint n = katze_array_get_length (browser->proxy_array);
|
2008-09-07 01:39:25 +00:00
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
2010-09-16 19:18:14 +00:00
|
|
|
GtkWidget* view;
|
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,
|
2009-10-13 21:56:02 +00:00
|
|
|
GtkWidget* menu,
|
2009-06-22 19:47:42 +00:00
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
static const GtkActionEntry actions[] = {
|
|
|
|
{ "TabNew" },
|
|
|
|
{ "WindowNew" },
|
2011-04-07 19:17:18 +00:00
|
|
|
{ NULL },
|
2009-06-22 19:47:42 +00:00
|
|
|
{ "Open" },
|
2009-10-13 21:56:02 +00:00
|
|
|
{ "Find" },
|
2010-12-05 22:01:01 +00:00
|
|
|
#if !HAVE_HILDON
|
2009-07-17 17:37:49 +00:00
|
|
|
{ "Print" },
|
2010-01-21 17:31:17 +00:00
|
|
|
{ "InspectPage" },
|
|
|
|
#endif
|
2011-04-07 19:17:18 +00:00
|
|
|
{ NULL },
|
|
|
|
{ "PrivateBrowsing" },
|
|
|
|
#if !HAVE_HILDON
|
|
|
|
{ "ClearPrivateData" },
|
|
|
|
{ NULL },
|
2011-02-11 20:55:49 +00:00
|
|
|
{ "BookmarksImport"},
|
|
|
|
{ "BookmarksExport"},
|
2011-04-07 19:17:18 +00:00
|
|
|
{ NULL },
|
|
|
|
{ "Fullscreen" },
|
|
|
|
{ "Panel" },
|
|
|
|
{ "-" },
|
2009-10-12 20:57:35 +00:00
|
|
|
#endif
|
2011-04-07 19:17:18 +00:00
|
|
|
{ NULL },
|
|
|
|
#if !HAVE_HILDON
|
2011-02-21 18:32:30 +00:00
|
|
|
{ "HelpFAQ" },
|
2011-04-07 19:25:27 +00:00
|
|
|
{ "HelpBugs"},
|
2011-04-07 19:17:18 +00:00
|
|
|
#endif
|
2010-06-10 15:53:08 +00:00
|
|
|
{ "About" },
|
2009-06-22 19:47:42 +00:00
|
|
|
{ "Preferences" },
|
2009-10-26 17:07:10 +00:00
|
|
|
#if HAVE_HILDON
|
2011-04-07 19:17:18 +00:00
|
|
|
{ NULL },
|
2009-10-26 17:07:10 +00:00
|
|
|
{ "auto-load-images" },
|
|
|
|
{ "enable-scripts" },
|
|
|
|
{ "enable-plugins" },
|
|
|
|
#endif
|
2009-06-22 19:47:42 +00:00
|
|
|
};
|
2011-04-07 19:17:18 +00:00
|
|
|
|
2009-06-22 19:47:42 +00:00
|
|
|
guint i;
|
|
|
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (actions); i++)
|
|
|
|
{
|
2009-11-27 22:42:07 +00:00
|
|
|
#ifdef HAVE_HILDON_2_2
|
2009-10-13 21:56:02 +00:00
|
|
|
GtkAction* _action;
|
|
|
|
gchar* label;
|
|
|
|
GtkWidget* button;
|
|
|
|
|
|
|
|
if (!actions[i].name)
|
|
|
|
continue;
|
|
|
|
_action = _action_by_name (browser, actions[i].name);
|
2009-10-26 17:07:10 +00:00
|
|
|
if (_action)
|
|
|
|
{
|
|
|
|
label = katze_object_get_string (_action, "label");
|
|
|
|
button = hildon_gtk_button_new (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
|
|
|
|
gtk_button_set_label (GTK_BUTTON (button), label);
|
|
|
|
gtk_button_set_use_underline (GTK_BUTTON (button), TRUE);
|
|
|
|
g_free (label);
|
|
|
|
g_signal_connect_swapped (button, "clicked",
|
|
|
|
G_CALLBACK (gtk_action_activate), _action);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
button = katze_property_proxy (browser->settings, actions[i].name, NULL);
|
2009-10-13 21:56:02 +00:00
|
|
|
gtk_widget_show (button);
|
|
|
|
hildon_app_menu_append (HILDON_APP_MENU (menu), GTK_BUTTON (button));
|
|
|
|
#else
|
2009-06-22 19:47:42 +00:00
|
|
|
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
|
2009-10-31 22:07:15 +00:00
|
|
|
{
|
2009-06-22 19:47:42 +00:00
|
|
|
menuitem = gtk_separator_menu_item_new ();
|
2009-10-31 22:07:15 +00:00
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
}
|
2009-06-22 19:47:42 +00:00
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
2009-10-13 21:56:02 +00:00
|
|
|
#endif
|
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)
|
2011-03-08 22:25:37 +00:00
|
|
|
gtk_action_activate (_action_by_name (browser, "HelpFAQ"));
|
2008-10-03 22:46:54 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2010-04-02 16:38:56 +00:00
|
|
|
if (!gtk_widget_get_visible (GTK_WIDGET (browser)))
|
2009-02-28 13:05:01 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!dialog)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2009-11-13 17:27:49 +00:00
|
|
|
dialog = midori_preferences_new (GTK_WINDOW (browser), browser->settings);
|
2011-04-14 01:29:50 +00:00
|
|
|
g_signal_emit (browser, signals[SHOW_PREFERENCES], 0, dialog);
|
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-12-09 19:37:26 +00:00
|
|
|
if (active)
|
2009-06-22 19:47:42 +00:00
|
|
|
{
|
2009-12-09 19:37:26 +00:00
|
|
|
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))
|
2009-06-22 19:47:42 +00:00
|
|
|
{
|
2009-12-09 19:37:26 +00:00
|
|
|
GtkAction* action_;
|
2010-01-31 19:38:56 +00:00
|
|
|
|
|
|
|
action_ = gtk_activatable_get_related_action (GTK_ACTIVATABLE (children->data));
|
2009-12-09 19:37:26 +00:00
|
|
|
if (action_ == menu_action)
|
2009-06-22 19:47:42 +00:00
|
|
|
{
|
2009-12-09 19:37:26 +00:00
|
|
|
gtk_container_remove (navigationbar,
|
|
|
|
GTK_WIDGET (children->data));
|
|
|
|
_midori_browser_save_toolbar_items (browser);
|
|
|
|
break;
|
2009-06-22 19:47:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-12-09 19:37:26 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_set (browser->settings, "show-menubar", active, NULL);
|
2009-11-12 22:56:04 +00:00
|
|
|
/* Make sure the menubar is uptodate in case no settings are set */
|
|
|
|
sokoke_widget_set_visible (browser->menubar, active);
|
2009-09-26 20:08:16 +00:00
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (browser), "midori-toolbars-visible",
|
2010-04-02 16:38:56 +00:00
|
|
|
gtk_widget_get_visible (browser->menubar)
|
|
|
|
|| gtk_widget_get_visible (browser->navigationbar)
|
2009-09-26 20:08:16 +00:00
|
|
|
? (void*)0xdeadbeef : NULL);
|
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-11-13 17:24:16 +00:00
|
|
|
g_object_set (browser->settings, "show-navigationbar", active, NULL);
|
2008-06-19 18:39:00 +00:00
|
|
|
sokoke_widget_set_visible (browser->navigationbar, active);
|
2009-09-26 20:08:16 +00:00
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (browser), "midori-toolbars-visible",
|
2010-04-02 16:38:56 +00:00
|
|
|
gtk_widget_get_visible (browser->menubar)
|
|
|
|
|| gtk_widget_get_visible (browser->navigationbar)
|
2009-09-26 20:08:16 +00:00
|
|
|
? (void*)0xdeadbeef : NULL);
|
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-11-13 17:24:16 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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-11-13 17:24:16 +00:00
|
|
|
g_object_set (browser->settings, "show-statusbar", active, NULL);
|
2008-06-19 18:39:00 +00:00
|
|
|
sokoke_widget_set_visible (browser->statusbar, active);
|
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;
|
|
|
|
|
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))
|
|
|
|
{
|
2011-02-02 00:55:32 +00:00
|
|
|
GdkModifierType state = (GdkModifierType)0;
|
|
|
|
gint x, y;
|
|
|
|
gboolean from_cache = TRUE;
|
|
|
|
|
|
|
|
if (!strcmp (gtk_action_get_name (action), "ReloadUncached"))
|
|
|
|
from_cache = FALSE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gdk_window_get_pointer (NULL, &x, &y, &state);
|
|
|
|
if (state & GDK_SHIFT_MASK)
|
|
|
|
from_cache = FALSE;
|
|
|
|
}
|
|
|
|
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
|
2010-06-25 13:50:19 +00:00
|
|
|
_action_zoom_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
2010-06-25 13:50:19 +00:00
|
|
|
if (!view)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (g_str_equal (gtk_action_get_name (action), "ZoomIn"))
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_view_set_zoom_level (MIDORI_VIEW (view),
|
2011-07-09 19:43:02 +00:00
|
|
|
midori_view_get_zoom_level (MIDORI_VIEW (view)) + 0.10f);
|
2010-06-25 13:50:19 +00:00
|
|
|
else if (g_str_equal (gtk_action_get_name (action), "ZoomOut"))
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_view_set_zoom_level (MIDORI_VIEW (view),
|
2011-07-09 19:43:02 +00:00
|
|
|
midori_view_get_zoom_level (MIDORI_VIEW (view)) - 0.10f);
|
2010-06-25 13:50:19 +00:00
|
|
|
else
|
2008-09-26 21:13:46 +00:00
|
|
|
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);
|
2010-06-07 19:27:03 +00:00
|
|
|
if (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);
|
2010-03-30 20:45:49 +00:00
|
|
|
web_view = midori_view_get_web_view (MIDORI_VIEW (view));
|
2009-02-27 22:09:36 +00:00
|
|
|
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";
|
2009-10-31 21:51:35 +00:00
|
|
|
else if (!strcmp (name, "EncodingKorean"))
|
|
|
|
encoding = "EUC-KR";
|
2009-02-27 22:09:36 +00:00
|
|
|
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* slash;
|
|
|
|
gchar* period;
|
|
|
|
gchar* ext_end;
|
|
|
|
|
|
|
|
/* 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 */
|
2010-10-14 18:27:31 +00:00
|
|
|
slash = strrchr (uri, '/');
|
2008-10-23 23:15:43 +00:00
|
|
|
/* 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;
|
2010-10-14 18:27:31 +00:00
|
|
|
return g_strdup (period);
|
2008-10-23 23:15:43 +00:00
|
|
|
}
|
|
|
|
|
2011-05-28 15:40:20 +00:00
|
|
|
static gchar*
|
|
|
|
midori_browser_save_source (const gchar* uri,
|
|
|
|
const gchar* data,
|
2011-05-30 15:55:02 +00:00
|
|
|
const size_t len,
|
|
|
|
const gchar* outfile)
|
2008-10-20 19:32:25 +00:00
|
|
|
{
|
|
|
|
gchar* unique_filename;
|
|
|
|
gint fd;
|
|
|
|
FILE* fp;
|
2008-11-15 23:10:39 +00:00
|
|
|
size_t ret;
|
2008-10-20 19:32:25 +00:00
|
|
|
|
2011-05-28 15:40:20 +00:00
|
|
|
if (!data)
|
|
|
|
return NULL;
|
|
|
|
|
2011-05-30 15:55:02 +00:00
|
|
|
if (!outfile)
|
|
|
|
{
|
2011-06-08 22:37:25 +00:00
|
|
|
gchar* filename;
|
|
|
|
gchar* extension;
|
|
|
|
|
2011-05-30 15:55:02 +00:00
|
|
|
extension = midori_browser_get_uri_extension (uri);
|
|
|
|
filename = g_strdup_printf ("%uXXXXXX%s",
|
|
|
|
g_str_hash (uri), extension);
|
|
|
|
g_free (extension);
|
|
|
|
fd = g_file_open_tmp (filename, &unique_filename, NULL);
|
2011-06-08 22:37:25 +00:00
|
|
|
g_free (filename);
|
2011-05-30 15:55:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-06-08 22:37:25 +00:00
|
|
|
unique_filename = g_strdup (outfile);
|
|
|
|
fd = g_open (unique_filename, O_WRONLY|O_CREAT, 0644);
|
2011-05-30 15:55:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fd != -1)
|
2008-10-20 19:32:25 +00:00
|
|
|
{
|
2011-05-28 15:40:20 +00:00
|
|
|
if ((fp = fdopen (fd, "w")))
|
2008-10-20 19:32:25 +00:00
|
|
|
{
|
2011-05-28 15:40:20 +00:00
|
|
|
ret = fwrite (data, 1, len, fp);
|
|
|
|
fclose (fp);
|
|
|
|
if ((ret - len) != 0)
|
2008-10-20 19:32:25 +00:00
|
|
|
{
|
2011-05-28 15:40:20 +00:00
|
|
|
g_warning ("Error writing to file %s "
|
|
|
|
"in midori_browser_source_transfer_cb()", unique_filename);
|
2011-06-08 22:37:25 +00:00
|
|
|
katze_assign (unique_filename, NULL);
|
2008-10-20 19:32:25 +00:00
|
|
|
}
|
|
|
|
}
|
2011-05-28 15:40:20 +00:00
|
|
|
close (fd);
|
2008-10-20 19:32:25 +00:00
|
|
|
}
|
2011-05-28 15:40:20 +00:00
|
|
|
return unique_filename;
|
2008-10-20 19:32:25 +00:00
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2011-06-08 22:37:25 +00:00
|
|
|
WebKitWebDataSource *data_source;
|
|
|
|
WebKitWebFrame *frame;
|
|
|
|
const GString *data;
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view;
|
2011-05-28 15:40:20 +00:00
|
|
|
GtkWidget* web_view;
|
2009-03-17 20:35:05 +00:00
|
|
|
gchar* text_editor;
|
2011-05-28 15:40:20 +00:00
|
|
|
gchar* filename = NULL;
|
2009-03-17 20:35:05 +00:00
|
|
|
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-11-13 17:24:16 +00:00
|
|
|
g_object_get (browser->settings, "text-editor", &text_editor, NULL);
|
2009-03-17 20:35:05 +00:00
|
|
|
uri = midori_view_get_display_uri (MIDORI_VIEW (view));
|
2011-06-08 22:37:25 +00:00
|
|
|
web_view = midori_view_get_web_view (MIDORI_VIEW (view));
|
|
|
|
frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
|
|
|
|
data_source = webkit_web_frame_get_data_source (frame);
|
|
|
|
data = webkit_web_data_source_get_data (data_source);
|
|
|
|
if (data)
|
|
|
|
filename = midori_browser_save_source (uri, data->str, data->len, NULL);
|
|
|
|
|
|
|
|
if (!filename)
|
|
|
|
return;
|
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
|
|
|
GtkWidget* source;
|
2011-07-27 21:06:44 +00:00
|
|
|
GtkWidget* source_view;
|
2011-06-08 22:37:25 +00:00
|
|
|
gchar* source_uri;
|
|
|
|
|
|
|
|
source_uri = g_filename_to_uri (filename, NULL, NULL);
|
|
|
|
g_free (filename);
|
2009-03-17 20:35:05 +00:00
|
|
|
|
2010-05-25 16:50:16 +00:00
|
|
|
source = midori_view_new (NULL);
|
2009-09-27 21:37:08 +00:00
|
|
|
midori_view_set_settings (MIDORI_VIEW (source), browser->settings);
|
2011-07-27 21:06:44 +00:00
|
|
|
source_view = midori_view_get_web_view (MIDORI_VIEW (source));
|
|
|
|
webkit_web_view_set_view_source_mode (WEBKIT_WEB_VIEW (source_view), TRUE);
|
|
|
|
webkit_web_view_load_uri (WEBKIT_WEB_VIEW (source_view), source_uri);
|
2009-09-14 21:57:57 +00:00
|
|
|
gtk_widget_show (source);
|
|
|
|
midori_browser_add_tab (browser, source);
|
2008-10-20 19:32:25 +00:00
|
|
|
}
|
2011-05-28 15:40:20 +00:00
|
|
|
else
|
2009-09-26 21:56:29 +00:00
|
|
|
{
|
2010-10-10 11:27:06 +00:00
|
|
|
sokoke_spawn_program (text_editor, filename);
|
2009-09-26 21:56:29 +00:00
|
|
|
g_free (filename);
|
|
|
|
}
|
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
|
|
|
|
2011-04-30 10:07:12 +00:00
|
|
|
static void
|
|
|
|
_action_caret_browsing_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
g_object_set (browser->settings, "enable-caret-browsing",
|
|
|
|
!katze_object_get_boolean (browser->settings, "enable-caret-browsing"), NULL);
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
_action_fullscreen_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2010-01-29 21:30:23 +00:00
|
|
|
GdkWindowState state;
|
|
|
|
|
2010-10-18 20:42:10 +00:00
|
|
|
if (!gtk_widget_get_window (GTK_WIDGET (browser)))
|
2009-02-28 13:05:01 +00:00
|
|
|
return;
|
|
|
|
|
2010-10-18 20:42:10 +00:00
|
|
|
state = gdk_window_get_state (gtk_widget_get_window (GTK_WIDGET (browser)));
|
2008-03-10 21:26:09 +00:00
|
|
|
if (state & GDK_WINDOW_STATE_FULLSCREEN)
|
|
|
|
gtk_window_unfullscreen (GTK_WINDOW (browser));
|
|
|
|
else
|
|
|
|
gtk_window_fullscreen (GTK_WINDOW (browser));
|
|
|
|
}
|
|
|
|
|
2010-02-28 22:41:54 +00:00
|
|
|
static void
|
|
|
|
_action_scroll_somewhere_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkWidget* view;
|
|
|
|
WebKitWebView* web_view;
|
|
|
|
const gchar* name;
|
|
|
|
|
|
|
|
view = midori_browser_get_current_tab (browser);
|
|
|
|
if (!view)
|
|
|
|
return;
|
2010-03-30 20:45:49 +00:00
|
|
|
web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view)));
|
2010-02-28 22:41:54 +00:00
|
|
|
name = gtk_action_get_name (action);
|
|
|
|
|
|
|
|
if (g_str_equal (name, "ScrollLeft"))
|
|
|
|
webkit_web_view_move_cursor (web_view, GTK_MOVEMENT_VISUAL_POSITIONS, -1);
|
2010-06-25 14:11:40 +00:00
|
|
|
else if (g_str_equal (name, "ScrollDown"))
|
2010-02-28 22:41:54 +00:00
|
|
|
webkit_web_view_move_cursor (web_view, GTK_MOVEMENT_DISPLAY_LINES, 1);
|
|
|
|
else if (g_str_equal (name, "ScrollUp"))
|
|
|
|
webkit_web_view_move_cursor (web_view, GTK_MOVEMENT_DISPLAY_LINES, -1);
|
|
|
|
else if (g_str_equal (name, "ScrollRight"))
|
|
|
|
webkit_web_view_move_cursor (web_view, GTK_MOVEMENT_VISUAL_POSITIONS, 1);
|
|
|
|
}
|
|
|
|
|
2010-06-25 15:30:59 +00:00
|
|
|
static gboolean
|
2010-06-25 14:11:40 +00:00
|
|
|
_action_navigation_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2010-06-25 14:11:40 +00:00
|
|
|
MidoriView* view;
|
|
|
|
GtkWidget* tab;
|
|
|
|
gchar* uri;
|
|
|
|
const gchar* name;
|
2010-01-29 21:30:23 +00:00
|
|
|
|
2010-06-25 15:30:59 +00:00
|
|
|
g_assert (GTK_IS_ACTION (action));
|
|
|
|
|
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);
|
2010-06-25 15:30:59 +00:00
|
|
|
return FALSE;
|
2009-05-17 11:38:42 +00:00
|
|
|
}
|
|
|
|
|
2010-06-25 14:11:40 +00:00
|
|
|
tab = midori_browser_get_current_tab (browser);
|
|
|
|
if (!tab)
|
2010-06-25 15:30:59 +00:00
|
|
|
return FALSE;
|
2009-05-17 11:38:42 +00:00
|
|
|
|
2010-06-25 14:11:40 +00:00
|
|
|
view = MIDORI_VIEW (tab);
|
2010-01-29 21:30:23 +00:00
|
|
|
|
2010-06-25 14:11:40 +00:00
|
|
|
name = gtk_action_get_name (action);
|
2009-12-26 22:12:36 +00:00
|
|
|
|
2010-06-25 14:11:40 +00:00
|
|
|
if (g_str_equal (name, "Back"))
|
2010-06-25 15:30:59 +00:00
|
|
|
{
|
2010-06-25 14:11:40 +00:00
|
|
|
midori_view_go_back (view);
|
2010-06-25 15:30:59 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2010-06-25 14:11:40 +00:00
|
|
|
else if (g_str_equal (name, "Forward"))
|
2010-06-25 15:30:59 +00:00
|
|
|
{
|
2010-06-25 14:11:40 +00:00
|
|
|
midori_view_go_forward (view);
|
2010-06-25 15:30:59 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2010-06-25 14:11:40 +00:00
|
|
|
else if (g_str_equal (name, "Previous"))
|
2009-12-26 22:12:36 +00:00
|
|
|
{
|
2010-06-25 14:11:40 +00:00
|
|
|
/* Duplicate here because the URI pointer might change */
|
|
|
|
uri = g_strdup (midori_view_get_previous_page (view));
|
|
|
|
midori_view_set_uri (view, uri);
|
2009-12-26 22:12:36 +00:00
|
|
|
g_free (uri);
|
2010-06-25 15:30:59 +00:00
|
|
|
return TRUE;
|
2009-12-26 22:12:36 +00:00
|
|
|
}
|
2010-06-25 14:11:40 +00:00
|
|
|
else if (g_str_equal (name, "Next"))
|
2009-12-26 22:12:36 +00:00
|
|
|
{
|
2010-06-25 14:11:40 +00:00
|
|
|
/* Duplicate here because the URI pointer might change */
|
|
|
|
uri = g_strdup (midori_view_get_next_page (view));
|
|
|
|
midori_view_set_uri (view, uri);
|
2009-12-26 22:12:36 +00:00
|
|
|
g_free (uri);
|
2010-06-25 15:30:59 +00:00
|
|
|
return TRUE;
|
2009-12-26 22:12:36 +00:00
|
|
|
}
|
2010-06-25 15:18:22 +00:00
|
|
|
else if (g_str_equal (name, "Homepage"))
|
2009-05-17 11:38:42 +00:00
|
|
|
{
|
2010-06-25 15:18:22 +00:00
|
|
|
g_object_get (browser->settings, "homepage", &uri, NULL);
|
|
|
|
midori_view_set_uri (view, uri);
|
|
|
|
g_free (uri);
|
2010-06-25 15:30:59 +00:00
|
|
|
return TRUE;
|
2009-05-17 11:38:42 +00:00
|
|
|
}
|
2010-06-25 15:30:59 +00:00
|
|
|
return FALSE;
|
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)
|
|
|
|
{
|
2010-04-02 16:38:56 +00:00
|
|
|
if (!gtk_widget_get_visible (browser->navigationbar))
|
2008-08-14 23:57:48 +00:00
|
|
|
gtk_widget_show (browser->navigationbar);
|
|
|
|
}
|
|
|
|
|
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-12-08 22:55:25 +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);
|
2010-07-31 11:59:48 +00:00
|
|
|
midori_location_action_set_text (MIDORI_LOCATION_ACTION (action), uri);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2010-01-01 21:47:24 +00:00
|
|
|
|
|
|
|
|
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);
|
2010-02-09 17:13:47 +00:00
|
|
|
new_uri = sokoke_magic_uri (stripped_uri);
|
2009-04-18 22:47:02 +00:00
|
|
|
if (!new_uri)
|
2010-01-01 21:47:24 +00:00
|
|
|
{
|
2010-02-09 17:13:47 +00:00
|
|
|
gchar** parts;
|
|
|
|
gchar* keywords = NULL;
|
|
|
|
const gchar* search_uri = NULL;
|
2010-01-01 21:47:24 +00:00
|
|
|
|
2010-02-09 17:13:47 +00:00
|
|
|
/* Do we have a keyword and a string? */
|
|
|
|
parts = g_strsplit (stripped_uri, " ", 2);
|
2011-03-05 01:36:45 +00:00
|
|
|
if (parts[0] && browser->search_engines)
|
2010-01-01 21:47:24 +00:00
|
|
|
{
|
2010-02-09 17:13:47 +00:00
|
|
|
KatzeItem* item;
|
|
|
|
if ((item = katze_array_find_token (browser->search_engines, parts[0])))
|
|
|
|
{
|
|
|
|
keywords = g_strdup (parts[1] ? parts[1] : "");
|
|
|
|
search_uri = katze_item_get_uri (item);
|
|
|
|
}
|
2010-01-01 21:47:24 +00:00
|
|
|
}
|
2010-02-09 17:13:47 +00:00
|
|
|
g_strfreev (parts);
|
|
|
|
|
|
|
|
if (keywords)
|
|
|
|
g_free (stripped_uri);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
keywords = stripped_uri;
|
|
|
|
search_uri = browser->location_entry_search;
|
|
|
|
}
|
|
|
|
new_uri = sokoke_search_uri (search_uri, keywords);
|
|
|
|
|
2011-03-05 01:36:45 +00:00
|
|
|
if (browser->history != NULL)
|
2010-02-22 22:49:27 +00:00
|
|
|
{
|
2011-03-05 01:36:45 +00:00
|
|
|
time_t now = time (NULL);
|
|
|
|
gint64 day = sokoke_time_t_to_julian (&now);
|
|
|
|
sqlite3* db = g_object_get_data (G_OBJECT (browser->history), "db");
|
|
|
|
static sqlite3_stmt* statement = NULL;
|
|
|
|
|
|
|
|
if (!statement)
|
|
|
|
{
|
|
|
|
const gchar* sqlcmd;
|
|
|
|
sqlcmd = "INSERT INTO search (keywords, uri, day) VALUES (?,?,?)";
|
|
|
|
sqlite3_prepare_v2 (db, sqlcmd, strlen (sqlcmd) + 1, &statement, NULL);
|
|
|
|
}
|
|
|
|
sqlite3_bind_text (statement, 1, keywords, -1, 0);
|
|
|
|
sqlite3_bind_text (statement, 2, search_uri, -1, 0);
|
|
|
|
sqlite3_bind_int64 (statement, 3, day);
|
2010-02-22 22:49:27 +00:00
|
|
|
|
2011-03-05 01:36:45 +00:00
|
|
|
if (sqlite3_step (statement) != SQLITE_DONE)
|
|
|
|
g_printerr (_("Failed to insert new history item: %s\n"),
|
2010-02-22 22:49:27 +00:00
|
|
|
sqlite3_errmsg (db));
|
2011-03-05 01:36:45 +00:00
|
|
|
sqlite3_reset (statement);
|
|
|
|
if (sqlite3_step (statement) == SQLITE_DONE)
|
|
|
|
sqlite3_clear_bindings (statement);
|
|
|
|
}
|
2010-02-22 22:49:27 +00:00
|
|
|
|
2010-02-09 17:13:47 +00:00
|
|
|
g_free (keywords);
|
2010-01-01 21:47:24 +00:00
|
|
|
}
|
2010-02-09 17:13:47 +00:00
|
|
|
else
|
|
|
|
g_free (stripped_uri);
|
2010-01-01 21:47:24 +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-11-22 14:33:13 +00:00
|
|
|
static void
|
|
|
|
midori_browser_news_feed_clicked_cb (GtkWidget* menuitem,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
gchar* uri = g_object_get_data (G_OBJECT (menuitem), "uri");
|
|
|
|
midori_browser_subscribe_to_news_feed (browser, uri);
|
|
|
|
}
|
|
|
|
|
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));
|
2010-03-13 18:58:06 +00:00
|
|
|
const gchar* feed;
|
2010-10-22 21:52:08 +00:00
|
|
|
/* Clicking icon on blank is equal to Paste and Proceed */
|
|
|
|
if (midori_view_is_blank (MIDORI_VIEW (view)))
|
|
|
|
{
|
|
|
|
GtkClipboard* clipboard = gtk_clipboard_get_for_display (
|
2010-10-22 22:31:11 +00:00
|
|
|
gtk_widget_get_display (view), GDK_SELECTION_CLIPBOARD);
|
2010-10-22 21:52:08 +00:00
|
|
|
gchar* text = gtk_clipboard_wait_for_text (clipboard);
|
|
|
|
if (text != NULL)
|
|
|
|
{
|
|
|
|
_action_location_submit_uri (action, text, FALSE, browser);
|
|
|
|
g_free (text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (gtk_window_get_focus (GTK_WINDOW (browser)) == widget)
|
2011-02-19 22:38:34 +00:00
|
|
|
{
|
|
|
|
const gchar* text = gtk_entry_get_text (GTK_ENTRY (widget));
|
|
|
|
_action_location_submit_uri (action, text, FALSE, browser);
|
|
|
|
}
|
2010-03-13 18:58:06 +00:00
|
|
|
else if ((feed = g_object_get_data (G_OBJECT (view), "news-feeds")))
|
2009-11-22 14:33:13 +00:00
|
|
|
{
|
|
|
|
KatzeArray* news_feeds;
|
|
|
|
KatzeItem* item;
|
|
|
|
KatzeItem* itemm;
|
|
|
|
|
|
|
|
news_feeds = katze_object_get_object (G_OBJECT (view), "news-feeds");
|
|
|
|
item = katze_array_get_nth_item (news_feeds, 0);
|
|
|
|
if ((itemm = katze_array_get_nth_item (news_feeds, 1)))
|
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
GtkWidget* menu;
|
|
|
|
GtkWidget* menuitem;
|
|
|
|
|
|
|
|
menu = gtk_menu_new ();
|
|
|
|
menuitem = gtk_menu_item_new_with_label (katze_item_get_name (item));
|
|
|
|
g_object_set_data_full (G_OBJECT (menuitem), "uri",
|
|
|
|
g_strdup (katze_item_get_uri (item)), (GDestroyNotify)g_free);
|
|
|
|
g_signal_connect (menuitem, "activate",
|
|
|
|
G_CALLBACK (midori_browser_news_feed_clicked_cb), browser);
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
menuitem = gtk_menu_item_new_with_label (katze_item_get_name (itemm));
|
|
|
|
g_object_set_data_full (G_OBJECT (menuitem), "uri",
|
|
|
|
g_strdup (katze_item_get_uri (itemm)), (GDestroyNotify)g_free);
|
|
|
|
g_signal_connect (menuitem, "activate",
|
|
|
|
G_CALLBACK (midori_browser_news_feed_clicked_cb), browser);
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
i = 2;
|
|
|
|
while ((itemm = katze_array_get_nth_item (news_feeds, i++)))
|
|
|
|
{
|
|
|
|
menuitem = gtk_menu_item_new_with_label (
|
|
|
|
katze_item_get_name (itemm));
|
|
|
|
g_object_set_data_full (G_OBJECT (menuitem), "uri",
|
|
|
|
g_strdup (katze_item_get_uri (itemm)), (GDestroyNotify)g_free);
|
|
|
|
g_signal_connect (menuitem, "activate",
|
|
|
|
G_CALLBACK (midori_browser_news_feed_clicked_cb), browser);
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
}
|
|
|
|
sokoke_container_show_children (GTK_CONTAINER (menu));
|
|
|
|
katze_widget_popup (widget, GTK_MENU (menu), NULL,
|
|
|
|
KATZE_MENU_POSITION_RIGHT);
|
|
|
|
}
|
|
|
|
else
|
2010-03-13 18:58:06 +00:00
|
|
|
midori_browser_subscribe_to_news_feed (browser, feed);
|
2009-11-22 14:33:13 +00:00
|
|
|
g_object_unref (news_feeds);
|
|
|
|
}
|
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
|
|
|
KatzeItem* item;
|
|
|
|
const gchar* url;
|
|
|
|
gchar* search;
|
2008-10-01 02:00:16 +00:00
|
|
|
|
2011-05-15 19:40:39 +00:00
|
|
|
item = katze_array_get_nth_item (browser->search_engines, browser->last_web_search);
|
2008-10-05 21:25:02 +00:00
|
|
|
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))
|
|
|
|
{
|
2010-04-02 16:38:56 +00:00
|
|
|
if (!gtk_widget_get_visible (browser->navigationbar))
|
2009-04-29 22:43:47 +00:00
|
|
|
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);
|
2011-05-15 19:40:39 +00:00
|
|
|
browser->last_web_search = idx;
|
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)
|
|
|
|
{
|
2010-04-02 16:38:56 +00:00
|
|
|
if (gtk_widget_get_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)
|
|
|
|
{
|
2010-08-14 18:58:38 +00:00
|
|
|
KatzeItem* item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
|
|
|
|
midori_browser_open_bookmark (browser, item);
|
2008-10-30 01:19:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2008-10-30 01:19:52 +00:00
|
|
|
|
2010-09-11 21:39:51 +00:00
|
|
|
KATZE_ARRAY_FOREACH_ITEM (child, KATZE_ARRAY (item))
|
2009-02-27 20:52:51 +00:00
|
|
|
{
|
|
|
|
if ((uri = katze_item_get_uri (child)) && *uri)
|
|
|
|
{
|
|
|
|
n = midori_browser_add_item (browser, child);
|
2010-07-03 07:28:03 +00:00
|
|
|
midori_browser_set_current_page_smartly (browser, n);
|
2009-02-27 20:52:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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);
|
2010-07-03 07:28:03 +00:00
|
|
|
midori_browser_set_current_page_smartly (browser, n);
|
2009-02-27 20:52:51 +00:00
|
|
|
}
|
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
|
|
|
{
|
2009-10-30 22:43:28 +00:00
|
|
|
MidoriBrowser* new_browser;
|
|
|
|
g_signal_emit (browser, signals[NEW_WINDOW], 0, NULL, &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-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
|
|
|
|
2010-07-02 14:39:53 +00:00
|
|
|
if (KATZE_ITEM_IS_BOOKMARK (item))
|
2009-02-22 02:11:40 +00:00
|
|
|
midori_browser_edit_bookmark_dialog_new (browser, item, FALSE, FALSE);
|
2010-07-02 14:39:53 +00:00
|
|
|
else
|
|
|
|
midori_browser_edit_bookmark_dialog_new (browser, item, FALSE, TRUE);
|
2008-10-30 01:19:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_bookmark_delete_activate_cb (GtkWidget* menuitem,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
KatzeItem* item;
|
|
|
|
|
|
|
|
item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
|
2010-08-10 21:46:49 +00:00
|
|
|
katze_array_remove_item (browser->bookmarks, 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 ();
|
2010-07-01 05:24:17 +00:00
|
|
|
if (!katze_item_get_uri (item))
|
2009-02-27 20:52:51 +00:00
|
|
|
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
|
|
|
|
2009-11-15 17:00:33 +00:00
|
|
|
katze_widget_popup (widget, GTK_MENU (menu), event, KATZE_MENU_POSITION_CURSOR);
|
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)
|
|
|
|
{
|
2010-10-25 21:40:34 +00:00
|
|
|
if (event->button != 3)
|
|
|
|
return FALSE;
|
|
|
|
|
2009-12-13 14:44:02 +00:00
|
|
|
/* GtkMenuBar catches button events on children with submenus,
|
|
|
|
so we need to see if the actual widget is the menubar, and if
|
|
|
|
it is an item, we forward it to the actual widget. */
|
2010-10-25 21:40:34 +00:00
|
|
|
if ((GTK_IS_BOX (toolitem) || GTK_IS_MENU_BAR (toolitem)))
|
2009-05-07 20:41:39 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
2010-10-25 21:40:34 +00:00
|
|
|
else if (GTK_IS_MENU_ITEM (toolitem))
|
2009-12-13 14:44:02 +00:00
|
|
|
{
|
|
|
|
gboolean handled;
|
|
|
|
g_signal_emit_by_name (toolitem, "button-press-event", event, &handled);
|
|
|
|
return handled;
|
|
|
|
}
|
2009-05-07 20:41:39 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2010-01-31 19:38:56 +00:00
|
|
|
GtkAction* action;
|
|
|
|
|
|
|
|
action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (toolitem));
|
2009-05-09 11:57:52 +00:00
|
|
|
|
2010-06-25 15:30:59 +00:00
|
|
|
return _action_navigation_activate (action, browser);
|
2009-05-07 20:41:39 +00:00
|
|
|
}
|
|
|
|
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)
|
|
|
|
{
|
2010-06-25 04:11:36 +00:00
|
|
|
if (g_str_equal (gtk_action_get_name (action), "BookmarkFolderAdd"))
|
|
|
|
midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, TRUE);
|
|
|
|
else
|
|
|
|
midori_browser_edit_bookmark_dialog_new (browser, NULL, TRUE, FALSE);
|
2009-04-10 20:28:36 +00:00
|
|
|
}
|
|
|
|
|
2009-11-15 16:49:09 +00:00
|
|
|
static void
|
|
|
|
_action_bookmarks_import_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const gchar* path;
|
|
|
|
const gchar* name;
|
2009-11-21 19:48:09 +00:00
|
|
|
const gchar* icon;
|
2009-11-15 16:49:09 +00:00
|
|
|
} BookmarkClient;
|
|
|
|
static const BookmarkClient bookmark_clients[] = {
|
2009-11-21 19:48:09 +00:00
|
|
|
{ ".local/share/data/Arora/bookmarks.xbel", N_("Arora"), "arora" },
|
|
|
|
{ ".kazehakase/bookmarks.xml", N_("Kazehakase"), "kazehakase-icon" },
|
|
|
|
{ ".opera/bookmarks.adr", N_("Opera"), "opera" },
|
2009-12-05 19:14:41 +00:00
|
|
|
{ ".kde/share/apps/konqueror/bookmarks.xml", N_("Konqueror"), "konqueror" },
|
2009-12-05 22:43:12 +00:00
|
|
|
{ ".gnome2/epiphany/bookmarks.rdf", N_("Epiphany"), "epiphany" },
|
2009-11-15 16:49:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
GtkWidget* dialog;
|
2010-02-19 18:05:29 +00:00
|
|
|
GtkWidget* content_area;
|
2009-11-15 16:49:09 +00:00
|
|
|
GtkSizeGroup* sizegroup;
|
|
|
|
GtkWidget* hbox;
|
|
|
|
GtkWidget* label;
|
|
|
|
GtkWidget* combo;
|
|
|
|
GtkComboBox* combobox;
|
2009-11-21 19:48:09 +00:00
|
|
|
GtkListStore* model;
|
|
|
|
GtkCellRenderer* renderer;
|
2009-11-15 20:45:29 +00:00
|
|
|
GtkComboBox* combobox_folder;
|
2009-11-21 19:48:09 +00:00
|
|
|
gint icon_width = 16;
|
2009-11-15 16:49:09 +00:00
|
|
|
guint i;
|
|
|
|
KatzeItem* item;
|
2011-01-22 20:24:10 +00:00
|
|
|
KatzeArray* bookmarks;
|
2010-07-02 03:55:41 +00:00
|
|
|
sqlite3* db;
|
|
|
|
const gchar* sqlcmd;
|
|
|
|
KatzeArray* bookmarkdirs;
|
2009-11-15 16:49:09 +00:00
|
|
|
|
2010-04-02 16:38:56 +00:00
|
|
|
if (!browser->bookmarks || !gtk_widget_get_visible (GTK_WIDGET (browser)))
|
2009-11-21 05:39:18 +00:00
|
|
|
return;
|
|
|
|
|
2009-11-15 16:49:09 +00:00
|
|
|
dialog = gtk_dialog_new_with_buttons (
|
|
|
|
_("Import bookmarks..."), GTK_WINDOW (browser),
|
|
|
|
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
|
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
_("_Import bookmarks"), GTK_RESPONSE_ACCEPT,
|
|
|
|
NULL);
|
2010-02-19 18:05:29 +00:00
|
|
|
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
|
2009-11-15 16:49:09 +00:00
|
|
|
gtk_window_set_icon_name (GTK_WINDOW (dialog), STOCK_BOOKMARKS);
|
|
|
|
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
|
2010-02-19 18:05:29 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (content_area), 5);
|
2009-11-15 16:49:09 +00:00
|
|
|
sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
|
|
|
|
|
|
|
hbox = gtk_hbox_new (FALSE, 8);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
|
|
|
|
label = gtk_label_new_with_mnemonic (_("_Application:"));
|
|
|
|
gtk_size_group_add_widget (sizegroup, label);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
2009-12-01 21:43:16 +00:00
|
|
|
model = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING, G_TYPE_INT);
|
2009-11-21 19:48:09 +00:00
|
|
|
combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (model));
|
|
|
|
renderer = gtk_cell_renderer_pixbuf_new ();
|
|
|
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
|
|
|
|
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), renderer, "icon-name", 1);
|
2009-12-01 21:43:16 +00:00
|
|
|
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), renderer, "width", 3);
|
2009-11-21 19:48:09 +00:00
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
|
|
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
|
|
|
|
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), renderer, "text", 0);
|
2009-11-15 16:49:09 +00:00
|
|
|
combobox = GTK_COMBO_BOX (combo);
|
2010-01-29 21:30:23 +00:00
|
|
|
gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (GTK_WIDGET (browser)),
|
|
|
|
GTK_ICON_SIZE_MENU, &icon_width, NULL);
|
2009-11-15 16:49:09 +00:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (bookmark_clients); i++)
|
|
|
|
{
|
|
|
|
gchar* path = g_build_filename (g_get_home_dir (),
|
|
|
|
bookmark_clients[i].path, NULL);
|
2009-12-19 09:39:24 +00:00
|
|
|
if (g_access (path, F_OK) == 0)
|
2009-11-21 19:48:09 +00:00
|
|
|
gtk_list_store_insert_with_values (model, NULL, G_MAXINT,
|
2009-12-03 22:53:47 +00:00
|
|
|
0, _(bookmark_clients[i].name), 1, bookmark_clients[i].icon,
|
2009-12-01 21:43:16 +00:00
|
|
|
2, path, 3, icon_width, -1);
|
2009-11-15 16:49:09 +00:00
|
|
|
g_free (path);
|
|
|
|
}
|
2009-12-03 22:53:47 +00:00
|
|
|
gtk_list_store_insert_with_values (model, NULL, G_MAXINT,
|
2011-01-30 10:35:54 +00:00
|
|
|
0, _("Import from XBEL or HTML file"), 1, NULL, 2, NULL, 3, icon_width, -1);
|
2009-11-15 16:49:09 +00:00
|
|
|
gtk_combo_box_set_active (combobox, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
|
2010-02-19 18:05:29 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (content_area), hbox);
|
2009-11-15 16:49:09 +00:00
|
|
|
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 (_("_Folder:"));
|
|
|
|
gtk_size_group_add_widget (sizegroup, label);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
combo = gtk_combo_box_new_text ();
|
2009-11-15 20:45:29 +00:00
|
|
|
combobox_folder = GTK_COMBO_BOX (combo);
|
|
|
|
gtk_combo_box_append_text (combobox_folder, _("Toplevel folder"));
|
|
|
|
gtk_combo_box_set_active (combobox_folder, 0);
|
2010-07-02 03:55:41 +00:00
|
|
|
|
|
|
|
db = g_object_get_data (G_OBJECT (browser->bookmarks), "db");
|
|
|
|
sqlcmd = "SELECT title from bookmarks where uri=''";
|
|
|
|
bookmarkdirs = katze_array_from_sqlite (db, sqlcmd);
|
2010-09-11 21:39:51 +00:00
|
|
|
KATZE_ARRAY_FOREACH_ITEM (item, bookmarkdirs)
|
2009-11-15 16:49:09 +00:00
|
|
|
{
|
2010-07-02 03:55:41 +00:00
|
|
|
const gchar* name = katze_item_get_name (item);
|
|
|
|
gtk_combo_box_append_text (combobox_folder, name);
|
2009-11-15 16:49:09 +00:00
|
|
|
}
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
|
2010-02-19 18:05:29 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (content_area), hbox);
|
2009-11-15 16:49:09 +00:00
|
|
|
gtk_widget_show_all (hbox);
|
2010-07-02 03:55:41 +00:00
|
|
|
gtk_widget_set_sensitive (combo, TRUE);
|
2009-11-15 16:49:09 +00:00
|
|
|
|
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
|
|
|
|
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
|
|
|
|
{
|
2009-12-01 21:43:16 +00:00
|
|
|
GtkTreeIter iter;
|
2009-11-15 16:49:09 +00:00
|
|
|
gchar* path;
|
|
|
|
gchar* selected;
|
|
|
|
GError* error;
|
|
|
|
|
2009-12-01 21:43:16 +00:00
|
|
|
gtk_combo_box_get_active_iter (combobox, &iter);
|
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (model), &iter, 2, &path, -1);
|
2009-11-15 16:49:09 +00:00
|
|
|
|
2009-11-15 20:45:29 +00:00
|
|
|
selected = gtk_combo_box_get_active_text (combobox_folder);
|
2010-07-02 03:55:41 +00:00
|
|
|
if (g_str_equal (selected, _("Toplevel folder")))
|
|
|
|
selected = g_strdup ("");
|
2009-11-15 16:49:09 +00:00
|
|
|
|
2009-12-03 22:53:47 +00:00
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
if (!path)
|
|
|
|
{
|
2009-12-05 19:14:41 +00:00
|
|
|
GtkWidget* file_dialog;
|
|
|
|
|
2010-10-24 21:48:03 +00:00
|
|
|
file_dialog = sokoke_file_chooser_dialog_new (_("Import from a file"),
|
2009-12-03 22:53:47 +00:00
|
|
|
GTK_WINDOW (browser), GTK_FILE_CHOOSER_ACTION_OPEN);
|
|
|
|
if (gtk_dialog_run (GTK_DIALOG (file_dialog)) == GTK_RESPONSE_OK)
|
|
|
|
path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_dialog));
|
|
|
|
gtk_widget_destroy (file_dialog);
|
|
|
|
}
|
|
|
|
|
2009-11-15 16:49:09 +00:00
|
|
|
error = NULL;
|
2011-01-22 20:24:10 +00:00
|
|
|
bookmarks = katze_array_new (KATZE_TYPE_ARRAY);
|
|
|
|
if (path && !midori_array_from_file (bookmarks, path, NULL, &error))
|
2009-11-15 16:49:09 +00:00
|
|
|
{
|
2009-12-03 22:53:47 +00:00
|
|
|
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
2011-02-02 00:10:02 +00:00
|
|
|
_("Failed to import bookmarks"),
|
|
|
|
error ? error->message : "", FALSE);
|
2009-12-03 22:53:47 +00:00
|
|
|
if (error)
|
|
|
|
g_error_free (error);
|
2009-11-15 16:49:09 +00:00
|
|
|
}
|
2011-01-22 20:24:10 +00:00
|
|
|
midori_bookmarks_import_array_db (db, bookmarks, selected);
|
2011-01-19 20:58:26 +00:00
|
|
|
katze_array_update (browser->bookmarks);
|
2011-01-22 20:24:10 +00:00
|
|
|
g_object_unref (bookmarks);
|
2010-07-02 03:55:41 +00:00
|
|
|
g_free (selected);
|
2009-11-15 16:49:09 +00:00
|
|
|
g_free (path);
|
|
|
|
}
|
2009-12-03 22:53:47 +00:00
|
|
|
else
|
|
|
|
gtk_widget_destroy (dialog);
|
2009-11-15 16:49:09 +00:00
|
|
|
}
|
|
|
|
|
2010-03-01 21:10:42 +00:00
|
|
|
static void
|
|
|
|
_action_bookmarks_export_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkWidget* file_dialog;
|
2011-02-01 00:24:33 +00:00
|
|
|
GtkFileFilter* filter;
|
|
|
|
const gchar* format;
|
2010-03-01 21:10:42 +00:00
|
|
|
gchar* path = NULL;
|
|
|
|
GError* error;
|
2010-07-23 17:51:28 +00:00
|
|
|
sqlite3* db;
|
2011-01-22 20:17:37 +00:00
|
|
|
KatzeArray* bookmarks;
|
2010-03-01 21:10:42 +00:00
|
|
|
|
2010-04-02 16:38:56 +00:00
|
|
|
if (!browser->bookmarks || !gtk_widget_get_visible (GTK_WIDGET (browser)))
|
2010-03-06 18:16:52 +00:00
|
|
|
return;
|
|
|
|
|
2011-02-02 00:10:02 +00:00
|
|
|
wrong_format:
|
2010-03-01 21:10:42 +00:00
|
|
|
file_dialog = sokoke_file_chooser_dialog_new (_("Save file as"),
|
|
|
|
GTK_WINDOW (browser), GTK_FILE_CHOOSER_ACTION_SAVE);
|
|
|
|
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (file_dialog),
|
|
|
|
"bookmarks.xbel");
|
2011-02-01 00:24:33 +00:00
|
|
|
filter = gtk_file_filter_new ();
|
|
|
|
gtk_file_filter_set_name (filter, _("XBEL Bookmarks"));
|
|
|
|
gtk_file_filter_add_mime_type (filter, "application/xml");
|
|
|
|
gtk_file_filter_add_pattern (filter, "*.xbel");
|
|
|
|
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_dialog), filter);
|
|
|
|
filter = gtk_file_filter_new ();
|
|
|
|
gtk_file_filter_set_name (filter, _("Netscape Bookmarks"));
|
|
|
|
gtk_file_filter_add_mime_type (filter, "text/html");
|
|
|
|
gtk_file_filter_add_pattern (filter, "*.html");
|
|
|
|
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_dialog), filter);
|
2010-03-01 21:10:42 +00:00
|
|
|
if (gtk_dialog_run (GTK_DIALOG (file_dialog)) == GTK_RESPONSE_OK)
|
|
|
|
path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_dialog));
|
|
|
|
gtk_widget_destroy (file_dialog);
|
2011-02-02 00:10:02 +00:00
|
|
|
if (g_str_has_suffix (path, ".xbel"))
|
|
|
|
format = "xbel";
|
|
|
|
else if (g_str_has_suffix (path, ".html"))
|
|
|
|
format = "netscape";
|
|
|
|
else if (path != NULL)
|
|
|
|
{
|
|
|
|
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
|
|
|
_("Midori can only export to XBEL (*.xbel) and Netscape (*.html)"),
|
|
|
|
"", TRUE);
|
|
|
|
katze_assign (path, NULL);
|
|
|
|
goto wrong_format;
|
|
|
|
}
|
2010-03-01 21:10:42 +00:00
|
|
|
|
|
|
|
if (path == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
error = NULL;
|
2010-07-23 17:51:28 +00:00
|
|
|
db = g_object_get_data (G_OBJECT (browser->history), "db");
|
2011-01-22 20:17:37 +00:00
|
|
|
bookmarks = katze_array_new (KATZE_TYPE_ARRAY);
|
|
|
|
midori_bookmarks_export_array_db (db, bookmarks, "");
|
2011-02-01 00:24:33 +00:00
|
|
|
if (!midori_array_to_file (bookmarks, path, format, &error))
|
2010-03-01 21:10:42 +00:00
|
|
|
{
|
|
|
|
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
2011-02-02 00:10:02 +00:00
|
|
|
_("Failed to export bookmarks"), error ? error->message : "", FALSE);
|
2010-03-01 21:10:42 +00:00
|
|
|
if (error)
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
2011-01-22 20:17:37 +00:00
|
|
|
g_object_unref (bookmarks);
|
2010-03-01 21:10:42 +00:00
|
|
|
g_free (path);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2010-04-02 16:38:56 +00:00
|
|
|
if (!gtk_widget_get_visible (GTK_WIDGET (browser)))
|
2009-02-28 13:05:01 +00:00
|
|
|
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;
|
2010-10-17 20:48:32 +00:00
|
|
|
GList* data_items = sokoke_register_privacy_item (NULL, NULL, NULL);
|
|
|
|
GString* clear_data = g_string_new (NULL);
|
2009-05-22 21:53:54 +00:00
|
|
|
g_object_get (browser->settings, "clear-private-data", &saved_prefs, NULL);
|
2009-04-11 03:14:53 +00:00
|
|
|
|
2011-07-24 19:41:47 +00:00
|
|
|
button = g_object_get_data (G_OBJECT (dialog), "session");
|
|
|
|
if (gtk_toggle_button_get_active (button))
|
|
|
|
{
|
|
|
|
GList* tabs = gtk_container_get_children (GTK_CONTAINER (browser->notebook));
|
|
|
|
for (; tabs != NULL; tabs = g_list_next (tabs))
|
|
|
|
gtk_widget_destroy (tabs->data);
|
|
|
|
g_list_free (tabs);
|
|
|
|
clear_prefs |= MIDORI_CLEAR_SESSION;
|
|
|
|
}
|
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
|
|
|
{
|
2010-11-21 15:14:30 +00:00
|
|
|
katze_array_clear (browser->history);
|
2009-05-22 21:53:54 +00:00
|
|
|
clear_prefs |= MIDORI_CLEAR_HISTORY;
|
|
|
|
}
|
2009-05-22 00:16:58 +00:00
|
|
|
button = g_object_get_data (G_OBJECT (dialog), "trash");
|
2010-10-17 20:48:32 +00:00
|
|
|
if (gtk_toggle_button_get_active (button) && browser->trash)
|
2009-05-22 00:16:58 +00:00
|
|
|
{
|
2010-10-17 20:48:32 +00:00
|
|
|
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)
|
2010-01-30 21:50:00 +00:00
|
|
|
{
|
|
|
|
clear_prefs |= (saved_prefs & MIDORI_CLEAR_ON_QUIT);
|
2009-05-22 21:53:54 +00:00
|
|
|
g_object_set (browser->settings, "clear-private-data", clear_prefs, NULL);
|
2010-01-30 21:50:00 +00:00
|
|
|
}
|
2010-10-17 20:48:32 +00:00
|
|
|
for (; data_items != NULL; data_items = g_list_next (data_items))
|
|
|
|
{
|
|
|
|
SokokePrivacyItem* privacy = data_items->data;
|
|
|
|
button = g_object_get_data (G_OBJECT (dialog), privacy->name);
|
|
|
|
g_return_if_fail (button != NULL && GTK_IS_TOGGLE_BUTTON (button));
|
|
|
|
if (gtk_toggle_button_get_active (button))
|
|
|
|
{
|
|
|
|
privacy->clear ();
|
|
|
|
g_string_append (clear_data, privacy->name);
|
|
|
|
g_string_append_c (clear_data, ',');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_object_set (browser->settings, "clear-data", clear_data->str, NULL);
|
|
|
|
g_string_free (clear_data, TRUE);
|
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;
|
|
|
|
|
2010-04-02 16:38:56 +00:00
|
|
|
if (!gtk_widget_get_visible (GTK_WIDGET (browser)))
|
2009-04-11 03:14:53 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!dialog)
|
|
|
|
{
|
2010-02-19 18:05:29 +00:00
|
|
|
GtkWidget* content_area;
|
2009-04-11 03:14:53 +00:00
|
|
|
GdkScreen* screen;
|
|
|
|
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;
|
2010-10-17 20:48:32 +00:00
|
|
|
GList* data_items;
|
|
|
|
gchar* clear_data = katze_object_get_string (browser->settings, "clear-data");
|
2009-04-11 03:14:53 +00:00
|
|
|
|
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);
|
|
|
|
|
2010-04-08 21:54:25 +00:00
|
|
|
/* i18n: Dialog: Clear Private Data, in the Tools menu */
|
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);
|
2010-02-19 18:05:29 +00:00
|
|
|
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
|
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)
|
|
|
|
{
|
|
|
|
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);
|
2010-02-19 18:05:29 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (content_area), 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);
|
2011-07-24 19:41:47 +00:00
|
|
|
button = gtk_check_button_new_with_mnemonic (_("Last open _tabs"));
|
|
|
|
if ((clear_prefs & MIDORI_CLEAR_SESSION) == MIDORI_CLEAR_SESSION)
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
|
|
|
g_object_set_data (G_OBJECT (dialog), "session", button);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
|
2010-10-21 18:43:39 +00:00
|
|
|
/* i18n: Browsing history, visited web pages */
|
2010-10-30 19:44:19 +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);
|
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);
|
2010-10-17 20:48:32 +00:00
|
|
|
|
|
|
|
data_items = sokoke_register_privacy_item (NULL, NULL, NULL);
|
|
|
|
for (; data_items != NULL; data_items = g_list_next (data_items))
|
|
|
|
{
|
|
|
|
SokokePrivacyItem* privacy = data_items->data;
|
|
|
|
button = gtk_check_button_new_with_mnemonic (privacy->label);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
|
|
|
|
g_object_set_data (G_OBJECT (dialog), privacy->name, button);
|
|
|
|
if (clear_data && strstr (clear_data, privacy->name))
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
|
|
|
}
|
|
|
|
g_free (clear_data);
|
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);
|
2010-02-19 18:05:29 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (content_area), 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);
|
2010-02-19 18:05:29 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (content_area), alignment, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show_all (content_area);
|
2009-04-11 03:14:53 +00:00
|
|
|
|
|
|
|
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);
|
2010-10-17 21:13:54 +00:00
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
|
2009-04-11 03:14:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
|
|
|
}
|
|
|
|
|
2010-01-21 17:31:17 +00:00
|
|
|
static void
|
|
|
|
_action_inspect_page_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
2010-03-30 20:45:49 +00:00
|
|
|
WebKitWebView* web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view)));
|
2010-01-21 17:31:17 +00:00
|
|
|
WebKitWebInspector* inspector = webkit_web_view_get_inspector (web_view);
|
|
|
|
webkit_web_inspector_show (inspector);
|
|
|
|
}
|
|
|
|
|
2011-03-02 17:03:55 +00:00
|
|
|
static void
|
|
|
|
_action_tab_move_backward_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2011-03-07 21:56:20 +00:00
|
|
|
gint new_pos;
|
|
|
|
gint cur_pos = gtk_notebook_get_current_page (GTK_NOTEBOOK (browser->notebook));
|
|
|
|
GtkWidget* widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), cur_pos);
|
|
|
|
if (cur_pos > 0)
|
|
|
|
new_pos = cur_pos - 1;
|
|
|
|
else
|
|
|
|
new_pos = gtk_notebook_get_n_pages (GTK_NOTEBOOK (browser->notebook)) - 1;
|
|
|
|
gtk_notebook_reorder_child (GTK_NOTEBOOK (browser->notebook), widget, new_pos);
|
|
|
|
g_signal_emit (browser, signals[MOVE_TAB], 0, browser->notebook, cur_pos, new_pos);
|
2011-03-02 17:03:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_tab_move_forward_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2011-03-07 21:56:20 +00:00
|
|
|
gint new_pos;
|
|
|
|
gint cur_pos = gtk_notebook_get_current_page (GTK_NOTEBOOK (browser->notebook));
|
|
|
|
GtkWidget* widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), cur_pos);
|
|
|
|
if (cur_pos == (gtk_notebook_get_n_pages (GTK_NOTEBOOK (browser->notebook)) - 1))
|
|
|
|
new_pos = 0;
|
2011-03-05 01:08:19 +00:00
|
|
|
else
|
2011-03-07 21:56:20 +00:00
|
|
|
new_pos = cur_pos + 1;
|
|
|
|
gtk_notebook_reorder_child (GTK_NOTEBOOK (browser->notebook), widget, new_pos);
|
|
|
|
g_signal_emit (browser, signals[MOVE_TAB], 0, browser->notebook, cur_pos, new_pos);
|
2011-03-02 17:03:55 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2009-09-30 20:18:17 +00:00
|
|
|
static void
|
|
|
|
_action_tab_current_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
2010-05-06 20:27:29 +00:00
|
|
|
gtk_widget_grab_focus (view);
|
2009-09-30 20:18:17 +00:00
|
|
|
}
|
|
|
|
|
2011-04-26 20:57:13 +00:00
|
|
|
static void
|
|
|
|
_action_next_view_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
gtk_widget_grab_focus (midori_browser_get_current_tab (browser));
|
|
|
|
}
|
|
|
|
|
2010-07-08 21:08:18 +00:00
|
|
|
static void
|
|
|
|
_action_tab_minimize_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
|
|
|
g_object_set (view, "minimized",
|
|
|
|
!katze_object_get_boolean (view, "minimized"), NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_tab_duplicate_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
|
|
|
MidoriNewView where = MIDORI_NEW_VIEW_TAB;
|
2011-01-01 19:05:34 +00:00
|
|
|
GtkWidget* new_view = midori_view_new_with_title (
|
|
|
|
NULL, browser->settings, FALSE);
|
|
|
|
const gchar* uri = midori_view_get_display_uri (MIDORI_VIEW (view));
|
2011-04-19 21:16:34 +00:00
|
|
|
g_signal_emit_by_name (view, "new-view", new_view, where, TRUE);
|
2011-01-01 19:05:34 +00:00
|
|
|
midori_view_set_uri (MIDORI_VIEW (new_view), uri);
|
2010-07-08 21:08:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_close_other_tabs_cb (GtkWidget* view,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkWidget* remaining_view = data;
|
|
|
|
if (view != remaining_view)
|
|
|
|
gtk_widget_destroy (view);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_tab_close_other_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
|
|
|
midori_browser_foreach (browser, midori_browser_close_other_tabs_cb, view);
|
|
|
|
}
|
|
|
|
|
2010-04-04 19:32:57 +00:00
|
|
|
static const gchar* credits_authors[] =
|
|
|
|
{ "Christian Dywan <christian@twotoasts.de>", NULL };
|
|
|
|
static const gchar* credits_documenters[] =
|
|
|
|
{ "Christian Dywan <christian@twotoasts.de>", NULL };
|
|
|
|
static const gchar* credits_artists[] =
|
|
|
|
{ "Nancy Runge <nancy@twotoasts.de>", NULL };
|
2008-03-10 21:26:09 +00:00
|
|
|
|
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)
|
|
|
|
{
|
2011-02-02 00:45:38 +00:00
|
|
|
gchar* comments = g_strdup_printf ("%s\n%s",
|
|
|
|
_("A lightweight web browser."),
|
|
|
|
_("See about:version for version info."));
|
2010-04-09 20:56:21 +00:00
|
|
|
const gchar* license =
|
|
|
|
_("This library is free software; you can redistribute it and/or "
|
|
|
|
"modify it under the terms of the GNU Lesser General Public "
|
|
|
|
"License as published by the Free Software Foundation; either "
|
|
|
|
"version 2.1 of the License, or (at your option) any later version.");
|
2009-08-17 17:22:33 +00:00
|
|
|
|
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,
|
2011-02-12 16:09:35 +00:00
|
|
|
"copyright", "Copyright © 2007-2011 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);
|
2010-04-09 20:56:21 +00:00
|
|
|
g_free (comments);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
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;
|
2010-02-15 23:47:11 +00:00
|
|
|
#if defined (G_OS_WIN32) && defined (DOCDIR)
|
|
|
|
gchar* free_uri = NULL;
|
|
|
|
#endif
|
2008-09-07 20:41:03 +00:00
|
|
|
|
2008-10-03 20:23:00 +00:00
|
|
|
action_name = gtk_action_get_name (action);
|
2011-03-08 22:25:37 +00:00
|
|
|
if (!strncmp ("HelpFAQ", action_name, 7))
|
2008-10-03 20:23:00 +00:00
|
|
|
{
|
2010-02-15 23:47:11 +00:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
{
|
|
|
|
#ifdef DOCDIR
|
2011-03-08 22:25:37 +00:00
|
|
|
gchar* path = sokoke_find_data_filename ("doc/midori/faq.html");
|
2010-02-15 23:47:11 +00:00
|
|
|
uri = free_uri = g_filename_to_uri (path, NULL, NULL);
|
|
|
|
if (g_access (path, F_OK) != 0)
|
|
|
|
{
|
2011-03-08 22:25:37 +00:00
|
|
|
if (g_access (DOCDIR "/faq.html", F_OK) == 0)
|
|
|
|
uri = "file://" DOCDIR "/faq.html";
|
2010-02-15 23:47:11 +00:00
|
|
|
else
|
|
|
|
#endif
|
2011-03-08 22:25:37 +00:00
|
|
|
uri = "error:nodocs share/doc/midori/faq.html";
|
2010-02-15 23:47:11 +00:00
|
|
|
#ifdef DOCDIR
|
|
|
|
}
|
|
|
|
g_free (path);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#else
|
2008-10-03 20:23:00 +00:00
|
|
|
#ifdef DOCDIR
|
2011-03-08 22:25:37 +00:00
|
|
|
uri = "file://" DOCDIR "/faq.html";
|
|
|
|
if (g_access (DOCDIR "/faq.html", F_OK) != 0)
|
2008-10-03 20:23:00 +00:00
|
|
|
#endif
|
2011-03-08 22:25:37 +00:00
|
|
|
uri = "error:nodocs " DOCDIR "/faq.html";
|
2010-02-15 23:47:11 +00:00
|
|
|
#endif
|
2008-10-03 20:23:00 +00:00
|
|
|
}
|
|
|
|
else if (!strncmp ("HelpBugs", action_name, 8))
|
2011-01-30 17:47:17 +00:00
|
|
|
uri = PACKAGE_BUGREPORT;
|
2008-10-03 20:23:00 +00:00
|
|
|
else
|
|
|
|
uri = NULL;
|
|
|
|
|
|
|
|
if (uri)
|
|
|
|
{
|
|
|
|
n = midori_browser_add_uri (browser, uri);
|
|
|
|
midori_browser_set_current_page (browser, n);
|
|
|
|
|
2010-02-15 23:47:11 +00:00
|
|
|
#if defined (G_OS_WIN32) && defined (DOCDIR)
|
|
|
|
g_free (free_uri);
|
|
|
|
#endif
|
|
|
|
}
|
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-11-13 17:24:16 +00:00
|
|
|
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)
|
|
|
|
{
|
2010-01-09 22:12:14 +00:00
|
|
|
gint 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-11-13 17:24:16 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-04-26 20:57:13 +00:00
|
|
|
static gboolean
|
|
|
|
midori_panel_cycle_child_focus_cb (GtkWidget* hpaned,
|
|
|
|
gboolean reversed,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
/* Default cycle goes between all GtkPaned widgets.
|
|
|
|
If focus is in the panel, focus the location as if it's a paned.
|
|
|
|
If nothing is focussed, simply go to the location.
|
|
|
|
Be sure to suppress the default because the signal can recurse. */
|
|
|
|
GtkWidget* focus = gtk_window_get_focus (GTK_WINDOW (browser));
|
|
|
|
if (gtk_widget_get_ancestor (focus, MIDORI_TYPE_PANEL)
|
|
|
|
|| !gtk_widget_get_ancestor (focus, GTK_TYPE_PANED))
|
|
|
|
{
|
|
|
|
g_signal_stop_emission_by_name (hpaned, "cycle-child-focus");
|
|
|
|
gtk_action_activate (_action_by_name (browser, "Location"));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-06-22 22:25:09 +00:00
|
|
|
static void
|
|
|
|
midori_panel_notify_page_cb (MidoriPanel* panel,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2010-11-01 15:47:32 +00:00
|
|
|
gint page = midori_panel_get_current_page (panel);
|
2009-11-13 17:27:49 +00:00
|
|
|
if (page > -1)
|
2009-06-22 22:25:09 +00:00
|
|
|
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");
|
2009-11-13 17:24:16 +00:00
|
|
|
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);
|
2009-07-26 20:00:10 +00:00
|
|
|
}
|
|
|
|
|
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));
|
2010-10-18 20:42:10 +00:00
|
|
|
GtkAllocation allocation;
|
|
|
|
gint paned_size;
|
|
|
|
|
|
|
|
gtk_widget_get_allocation (hpaned, &allocation);
|
|
|
|
paned_size = allocation.width;
|
2009-02-22 18:23:45 +00:00
|
|
|
|
2009-11-13 17:27:49 +00:00
|
|
|
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)
|
|
|
|
{
|
2010-01-11 20:47:37 +00:00
|
|
|
gtk_paned_pack1 (GTK_PANED (hpaned), vpaned, TRUE, FALSE);
|
2009-02-22 18:23:45 +00:00
|
|
|
gtk_paned_pack2 (GTK_PANED (hpaned), browser->panel, FALSE, FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_paned_pack1 (GTK_PANED (hpaned), browser->panel, FALSE, FALSE);
|
2010-01-11 20:47:37 +00:00
|
|
|
gtk_paned_pack2 (GTK_PANED (hpaned), vpaned, TRUE, FALSE);
|
2009-02-22 18:23:45 +00:00
|
|
|
}
|
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,
|
2010-10-04 20:07:41 +00:00
|
|
|
gpointer page,
|
2008-03-10 21:26:09 +00:00
|
|
|
guint page_num,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2009-10-04 00:32:50 +00:00
|
|
|
GtkWidget* widget;
|
|
|
|
GtkAction* action;
|
|
|
|
const gchar* text;
|
|
|
|
|
|
|
|
if (!(widget = midori_browser_get_current_tab (browser)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
action = _action_by_name (browser, "Location");
|
|
|
|
text = midori_location_action_get_text (MIDORI_LOCATION_ACTION (action));
|
|
|
|
g_object_set_data_full (G_OBJECT (widget), "midori-browser-typed-text",
|
|
|
|
g_strdup (text), g_free);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_notebook_switch_page_after_cb (GtkWidget* notebook,
|
2010-10-04 20:07:41 +00:00
|
|
|
gpointer page,
|
2009-10-04 00:32:50 +00:00
|
|
|
guint page_num,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkWidget* widget;
|
|
|
|
MidoriView* 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
|
|
|
|
2009-10-04 00:32:50 +00:00
|
|
|
if (!(widget = midori_browser_get_current_tab (browser)))
|
2009-04-01 21:53:45 +00:00
|
|
|
return;
|
|
|
|
|
2009-10-04 00:32:50 +00:00
|
|
|
view = MIDORI_VIEW (widget);
|
|
|
|
uri = g_object_get_data (G_OBJECT (widget), "midori-browser-typed-text");
|
|
|
|
if (!uri)
|
|
|
|
uri = midori_view_get_display_uri (view);
|
2011-04-25 15:53:33 +00:00
|
|
|
midori_browser_set_title (browser, midori_view_get_display_title (view));
|
2008-08-14 23:57:48 +00:00
|
|
|
action = _action_by_name (browser, "Location");
|
2009-10-04 00:32:50 +00:00
|
|
|
midori_location_action_set_text (MIDORI_LOCATION_ACTION (action), uri);
|
2008-11-10 23:51:28 +00:00
|
|
|
midori_location_action_set_icon (MIDORI_LOCATION_ACTION (action),
|
2009-10-04 00:32:50 +00:00
|
|
|
midori_view_get_icon (view));
|
2008-07-17 19:02:14 +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));
|
2009-09-29 18:49:30 +00:00
|
|
|
g_object_notify (G_OBJECT (browser), "tab");
|
2008-07-23 18:17:13 +00:00
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
_midori_browser_set_statusbar_text (browser, NULL);
|
|
|
|
_midori_browser_update_interface (browser);
|
2009-10-04 00:32:50 +00:00
|
|
|
_midori_browser_update_progress (browser, 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);
|
2009-09-29 18:49:30 +00:00
|
|
|
g_object_notify (G_OBJECT (browser), "tab");
|
2009-03-24 22:54:37 +00:00
|
|
|
}
|
|
|
|
|
2011-03-07 02:38:17 +00:00
|
|
|
static gboolean
|
|
|
|
midori_browser_notebook_reorder_tab_cb (GtkNotebook* notebook,
|
|
|
|
GtkDirectionType arg1,
|
|
|
|
gboolean arg2,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
g_signal_stop_emission_by_name (notebook, "reorder-tab");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-03-02 17:03:13 +00:00
|
|
|
static void
|
|
|
|
midori_browser_switch_tab_cb (GtkWidget* menuitem,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2011-03-08 18:56:48 +00:00
|
|
|
gint page = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menuitem), "index"));
|
|
|
|
midori_browser_set_current_page (browser, page);
|
2011-03-02 17:03:13 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2011-01-30 18:11:38 +00:00
|
|
|
gint n = midori_browser_add_uri (browser, "");
|
2009-05-17 14:49:46 +00:00
|
|
|
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
|
|
|
}
|
2011-03-02 17:03:13 +00:00
|
|
|
else if (event->type == GDK_BUTTON_PRESS && event->button == 3)
|
|
|
|
{
|
|
|
|
GtkWidget* menu = gtk_menu_new ();
|
|
|
|
GList* tabs = gtk_container_get_children (GTK_CONTAINER (notebook));
|
|
|
|
GtkWidget* menuitem = sokoke_action_create_popup_menu_item (
|
|
|
|
gtk_action_group_get_action (browser->action_group, "TabNew"));
|
2011-03-08 18:56:48 +00:00
|
|
|
gint i = 0;
|
2011-03-02 17:03:13 +00:00
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
menuitem = sokoke_action_create_popup_menu_item (
|
|
|
|
gtk_action_group_get_action (browser->action_group, "UndoTabClose"));
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
menuitem = gtk_separator_menu_item_new ();
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
for (; tabs != NULL; tabs = g_list_next (tabs))
|
|
|
|
{
|
|
|
|
const gchar* title = midori_view_get_display_title (tabs->data);
|
|
|
|
menuitem = katze_image_menu_item_new_ellipsized (title);
|
|
|
|
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem),
|
|
|
|
gtk_image_new_from_pixbuf (midori_view_get_icon (tabs->data)));
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
g_object_set_data (G_OBJECT (menuitem), "index", GINT_TO_POINTER (i));
|
|
|
|
g_signal_connect (menuitem, "activate",
|
|
|
|
G_CALLBACK (midori_browser_switch_tab_cb), browser);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
g_list_free (tabs);
|
|
|
|
gtk_widget_show_all (menu);
|
|
|
|
katze_widget_popup (GTK_WIDGET (notebook), GTK_MENU (menu), NULL,
|
2011-03-13 14:02:57 +00:00
|
|
|
KATZE_MENU_POSITION_CURSOR);
|
2011-03-02 17:03:13 +00:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2010-04-04 19:27:24 +00:00
|
|
|
static const GtkActionEntry entries[] =
|
|
|
|
{
|
|
|
|
{ "File", NULL, N_("_File") },
|
|
|
|
{ "WindowNew", STOCK_WINDOW_NEW,
|
|
|
|
N_("New _Window"), "<Ctrl>n",
|
|
|
|
N_("Open a new window"), G_CALLBACK (_action_window_new_activate) },
|
|
|
|
{ "TabNew", STOCK_TAB_NEW,
|
|
|
|
NULL, "<Ctrl>t",
|
|
|
|
N_("Open a new tab"), G_CALLBACK (_action_tab_new_activate) },
|
|
|
|
{ "PrivateBrowsing", NULL,
|
2011-05-16 01:30:55 +00:00
|
|
|
N_("New P_rivate Browsing Window"), "<Ctrl><Shift>n",
|
2010-04-04 19:27:24 +00:00
|
|
|
N_("Don't save any private data while browsing"),
|
|
|
|
G_CALLBACK (_action_private_browsing_activate), },
|
|
|
|
{ "Open", GTK_STOCK_OPEN,
|
|
|
|
NULL, "<Ctrl>o",
|
|
|
|
N_("Open a file"), G_CALLBACK (_action_open_activate) },
|
|
|
|
{ "SaveAs", GTK_STOCK_SAVE_AS,
|
2011-05-16 01:30:55 +00:00
|
|
|
N_("_Save Page As..."), "<Ctrl>s",
|
2010-04-04 19:27:24 +00:00
|
|
|
N_("Save to a file"), G_CALLBACK (_action_save_as_activate) },
|
|
|
|
{ "AddSpeedDial", NULL,
|
|
|
|
N_("Add to Speed _dial"), "<Ctrl>h",
|
|
|
|
N_("Add shortcut to speed dial"), G_CALLBACK (_action_add_speed_dial_activate) },
|
|
|
|
{ "AddDesktopShortcut", NULL,
|
2011-02-12 17:12:55 +00:00
|
|
|
#if HAVE_HILDON
|
2010-12-12 00:26:08 +00:00
|
|
|
N_("Add Shortcut to the _desktop"), "<Ctrl>j",
|
2010-04-04 19:27:24 +00:00
|
|
|
N_("Add shortcut to the desktop"), G_CALLBACK (_action_add_desktop_shortcut_activate) },
|
2011-02-12 17:12:55 +00:00
|
|
|
#else
|
|
|
|
N_("Create _Launcher"), "<Ctrl>j",
|
|
|
|
N_("Create a launcher"), G_CALLBACK (_action_add_desktop_shortcut_activate) },
|
|
|
|
#endif
|
2010-04-04 19:27:24 +00:00
|
|
|
{ "AddNewsFeed", NULL,
|
|
|
|
N_("Subscribe to News _feed"), NULL,
|
|
|
|
N_("Subscribe to this news feed"), G_CALLBACK (_action_add_news_feed_activate) },
|
|
|
|
{ "CompactAdd", GTK_STOCK_ADD,
|
|
|
|
NULL, NULL,
|
|
|
|
NULL, G_CALLBACK (_action_compact_add_activate) },
|
|
|
|
{ "TabClose", GTK_STOCK_CLOSE,
|
|
|
|
N_("_Close Tab"), "<Ctrl>w",
|
|
|
|
N_("Close the current tab"), G_CALLBACK (_action_tab_close_activate) },
|
|
|
|
{ "WindowClose", NULL,
|
|
|
|
N_("C_lose Window"), "<Ctrl><Shift>w",
|
|
|
|
N_("Close this window"), G_CALLBACK (_action_window_close_activate) },
|
|
|
|
{ "Print", GTK_STOCK_PRINT,
|
|
|
|
NULL, "<Ctrl>p",
|
|
|
|
N_("Print the current page"), G_CALLBACK (_action_print_activate) },
|
|
|
|
{ "Quit", GTK_STOCK_QUIT,
|
2011-04-07 20:41:27 +00:00
|
|
|
N_("Close a_ll Windows"), "<Ctrl><Shift>q",
|
|
|
|
N_("Close all open windows"), G_CALLBACK (_action_quit_activate) },
|
2010-04-04 19:27:24 +00:00
|
|
|
|
|
|
|
{ "Edit", NULL, N_("_Edit"), NULL, NULL, G_CALLBACK (_action_edit_activate) },
|
|
|
|
{ "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) },
|
|
|
|
{ "Cut", GTK_STOCK_CUT,
|
|
|
|
NULL, "<Ctrl>x",
|
|
|
|
N_("Cut the selected text"), G_CALLBACK (_action_cut_activate) },
|
|
|
|
{ "Copy", GTK_STOCK_COPY,
|
|
|
|
NULL, "<Ctrl>c",
|
|
|
|
N_("Copy the selected text"), G_CALLBACK (_action_copy_activate) },
|
|
|
|
{ "Paste", GTK_STOCK_PASTE,
|
|
|
|
NULL, "<Ctrl>v",
|
|
|
|
N_("Paste text from the clipboard"), G_CALLBACK (_action_paste_activate) },
|
|
|
|
{ "Delete", GTK_STOCK_DELETE,
|
|
|
|
NULL, NULL,
|
|
|
|
N_("Delete the selected text"), G_CALLBACK (_action_delete_activate) },
|
|
|
|
{ "SelectAll", GTK_STOCK_SELECT_ALL,
|
|
|
|
NULL, "<Ctrl>a",
|
|
|
|
N_("Select all text"), G_CALLBACK (_action_select_all_activate) },
|
|
|
|
{ "Find", GTK_STOCK_FIND,
|
2011-05-16 01:30:55 +00:00
|
|
|
N_("_Find..."), "<Ctrl>f",
|
2010-04-04 19:27:24 +00:00
|
|
|
N_("Find a word or phrase in the page"), G_CALLBACK (_action_find_activate) },
|
|
|
|
{ "FindNext", GTK_STOCK_GO_FORWARD,
|
|
|
|
N_("Find _Next"), "<Ctrl>g",
|
|
|
|
N_("Find the next occurrence of a word or phrase"), G_CALLBACK (_action_find_next_activate) },
|
|
|
|
{ "FindPrevious", GTK_STOCK_GO_BACK,
|
|
|
|
N_("Find _Previous"), "<Ctrl><Shift>g",
|
|
|
|
N_("Find the previous occurrence of a word or phrase"),
|
|
|
|
G_CALLBACK (_action_find_previous_activate) },
|
|
|
|
{ "Preferences", GTK_STOCK_PREFERENCES,
|
|
|
|
NULL, "<Ctrl><Alt>p",
|
|
|
|
N_("Configure the application preferences"), G_CALLBACK (_action_preferences_activate) },
|
|
|
|
|
|
|
|
{ "View", NULL, N_("_View") },
|
|
|
|
{ "Toolbars", NULL, N_("_Toolbars") },
|
|
|
|
{ "Reload", GTK_STOCK_REFRESH,
|
|
|
|
NULL, "<Ctrl>r",
|
|
|
|
N_("Reload the current page"), G_CALLBACK (_action_reload_stop_activate) },
|
2011-02-02 00:55:32 +00:00
|
|
|
{ "ReloadUncached", GTK_STOCK_REFRESH,
|
2011-02-20 03:13:30 +00:00
|
|
|
N_("Reload page without caching"), "<Ctrl><Shift>r",
|
2011-02-02 00:55:32 +00:00
|
|
|
N_("Reload page without caching"), G_CALLBACK (_action_reload_stop_activate) },
|
2010-04-04 19:27:24 +00:00
|
|
|
{ "Stop", GTK_STOCK_STOP,
|
|
|
|
NULL, "Escape",
|
|
|
|
N_("Stop loading the current page"), G_CALLBACK (_action_reload_stop_activate) },
|
|
|
|
{ "ReloadStop", GTK_STOCK_STOP,
|
|
|
|
NULL, "<Ctrl>r",
|
|
|
|
N_("Reload the current page"), G_CALLBACK (_action_reload_stop_activate) },
|
|
|
|
{ "ZoomIn", GTK_STOCK_ZOOM_IN,
|
|
|
|
NULL, "<Ctrl>plus",
|
2010-06-25 13:50:19 +00:00
|
|
|
N_("Increase the zoom level"), G_CALLBACK (_action_zoom_activate) },
|
2010-04-04 19:27:24 +00:00
|
|
|
{ "ZoomOut", GTK_STOCK_ZOOM_OUT,
|
|
|
|
NULL, "<Ctrl>minus",
|
2010-06-25 13:50:19 +00:00
|
|
|
N_("Decrease the zoom level"), G_CALLBACK (_action_zoom_activate) },
|
2010-04-04 19:27:24 +00:00
|
|
|
{ "ZoomNormal", GTK_STOCK_ZOOM_100,
|
|
|
|
NULL, "<Ctrl>0",
|
2010-06-25 13:50:19 +00:00
|
|
|
N_("Reset the zoom level"), G_CALLBACK (_action_zoom_activate) },
|
2010-04-04 19:27:24 +00:00
|
|
|
{ "Encoding", NULL, N_("_Encoding") },
|
|
|
|
{ "SourceView", NULL,
|
|
|
|
N_("View So_urce"), "<Ctrl><Alt>U",
|
|
|
|
N_("View the source code of the page"), G_CALLBACK (_action_source_view_activate) },
|
2011-04-30 10:07:12 +00:00
|
|
|
{ "CaretBrowsing", NULL,
|
|
|
|
N_("Ca_ret Browsing"), "F7",
|
|
|
|
N_("Toggle text cursor navigation"), G_CALLBACK (_action_caret_browsing_activate) },
|
2010-04-04 19:27:24 +00:00
|
|
|
{ "Fullscreen", GTK_STOCK_FULLSCREEN,
|
|
|
|
NULL, "F11",
|
|
|
|
N_("Toggle fullscreen view"), G_CALLBACK (_action_fullscreen_activate) },
|
|
|
|
{ "ScrollLeft", NULL,
|
|
|
|
N_("Scroll _Left"), "h",
|
|
|
|
N_("Scroll to the left"), G_CALLBACK (_action_scroll_somewhere_activate) },
|
|
|
|
{ "ScrollDown", NULL,
|
|
|
|
N_("Scroll _Down"), "j",
|
|
|
|
N_("Scroll down"), G_CALLBACK (_action_scroll_somewhere_activate) },
|
|
|
|
{ "ScrollUp", NULL,
|
|
|
|
N_("Scroll _Up"), "k",
|
|
|
|
N_("Scroll up"), G_CALLBACK (_action_scroll_somewhere_activate) },
|
|
|
|
{ "ScrollRight", NULL,
|
|
|
|
N_("Scroll _Right"), "l",
|
|
|
|
N_("Scroll to the right"), G_CALLBACK (_action_scroll_somewhere_activate) },
|
|
|
|
|
|
|
|
{ "Go", NULL, N_("_Go") },
|
|
|
|
{ "Back", GTK_STOCK_GO_BACK,
|
|
|
|
NULL, "<Alt>Left",
|
2010-06-25 14:11:40 +00:00
|
|
|
N_("Go back to the previous page"), G_CALLBACK (_action_navigation_activate) },
|
2010-04-04 19:27:24 +00:00
|
|
|
{ "Forward", GTK_STOCK_GO_FORWARD,
|
|
|
|
NULL, "<Alt>Right",
|
2010-06-25 14:11:40 +00:00
|
|
|
N_("Go forward to the next page"), G_CALLBACK (_action_navigation_activate) },
|
2010-04-04 19:27:24 +00:00
|
|
|
{ "Previous", GTK_STOCK_MEDIA_PREVIOUS,
|
2010-09-02 22:21:03 +00:00
|
|
|
NULL, "<Alt><Shift>Left",
|
2010-04-04 19:27:24 +00:00
|
|
|
/* i18n: Visit the previous logical page, ie. in a forum or blog */
|
2010-06-25 14:11:40 +00:00
|
|
|
N_("Go to the previous sub-page"), G_CALLBACK (_action_navigation_activate) },
|
2010-04-04 19:27:24 +00:00
|
|
|
{ "Next", GTK_STOCK_MEDIA_NEXT,
|
2010-09-02 22:21:03 +00:00
|
|
|
NULL, "<Alt><Shift>Right",
|
2010-04-04 19:27:24 +00:00
|
|
|
/* i18n: Visit the following logical page, ie. in a forum or blog */
|
2010-06-25 14:11:40 +00:00
|
|
|
N_("Go to the next sub-page"), G_CALLBACK (_action_navigation_activate) },
|
2010-04-04 19:27:24 +00:00
|
|
|
{ "Homepage", STOCK_HOMEPAGE,
|
|
|
|
NULL, "<Alt>Home",
|
2010-06-25 15:18:22 +00:00
|
|
|
N_("Go to your homepage"), G_CALLBACK (_action_navigation_activate) },
|
2010-04-04 19:27:24 +00:00
|
|
|
{ "TrashEmpty", GTK_STOCK_CLEAR,
|
|
|
|
N_("Empty Trash"), "",
|
|
|
|
N_("Delete the contents of the trash"), G_CALLBACK (_action_trash_empty_activate) },
|
|
|
|
{ "UndoTabClose", GTK_STOCK_UNDELETE,
|
|
|
|
N_("Undo _Close Tab"), "<Ctrl><Shift>t",
|
|
|
|
N_("Open the last closed tab"), G_CALLBACK (_action_undo_tab_close_activate) },
|
|
|
|
|
|
|
|
{ "BookmarkAdd", STOCK_BOOKMARK_ADD,
|
|
|
|
NULL, "<Ctrl>d",
|
|
|
|
N_("Add a new bookmark"), G_CALLBACK (_action_bookmark_add_activate) },
|
|
|
|
{ "BookmarkFolderAdd", NULL,
|
|
|
|
N_("Add a new _folder"), "",
|
2010-06-25 04:11:36 +00:00
|
|
|
N_("Add a new bookmark folder"), G_CALLBACK (_action_bookmark_add_activate) },
|
2010-04-04 19:27:24 +00:00
|
|
|
{ "BookmarksImport", NULL,
|
|
|
|
N_("_Import bookmarks"), "",
|
|
|
|
NULL, G_CALLBACK (_action_bookmarks_import_activate) },
|
|
|
|
{ "BookmarksExport", NULL,
|
|
|
|
N_("_Export bookmarks"), "",
|
|
|
|
NULL, G_CALLBACK (_action_bookmarks_export_activate) },
|
|
|
|
{ "ManageSearchEngines", GTK_STOCK_PROPERTIES,
|
|
|
|
N_("_Manage Search Engines"), "<Ctrl><Alt>s",
|
|
|
|
N_("Add, edit and remove search engines..."),
|
|
|
|
G_CALLBACK (_action_manage_search_engines_activate) },
|
|
|
|
{ "ClearPrivateData", NULL,
|
|
|
|
N_("_Clear Private Data"), "<Ctrl><Shift>Delete",
|
|
|
|
N_("Clear private data..."),
|
|
|
|
G_CALLBACK (_action_clear_private_data_activate) },
|
|
|
|
{ "InspectPage", NULL,
|
|
|
|
N_("_Inspect Page"), "<Ctrl><Shift>i",
|
|
|
|
N_("Inspect page details and access developer tools..."),
|
|
|
|
G_CALLBACK (_action_inspect_page_activate) },
|
|
|
|
|
|
|
|
{ "TabPrevious", GTK_STOCK_GO_BACK,
|
|
|
|
N_("_Previous Tab"), "<Ctrl>Page_Up",
|
|
|
|
N_("Switch to the previous tab"), G_CALLBACK (_action_tab_previous_activate) },
|
|
|
|
{ "TabNext", GTK_STOCK_GO_FORWARD,
|
|
|
|
N_("_Next Tab"), "<Ctrl>Page_Down",
|
|
|
|
N_("Switch to the next tab"), G_CALLBACK (_action_tab_next_activate) },
|
2011-03-13 14:24:40 +00:00
|
|
|
{ "TabMoveBackward", NULL, N_("Move Tab _Backward"), "<Ctrl><Shift>Page_Up",
|
2011-03-02 17:03:55 +00:00
|
|
|
N_("Move tab behind the previous tab"), G_CALLBACK (_action_tab_move_backward_activate) },
|
|
|
|
{ "TabMoveForward", NULL, N_("_Move Tab Forward"), "<Ctrl><Shift>Page_Down",
|
|
|
|
N_("Move tab in front of the next tab"), G_CALLBACK (_action_tab_move_forward_activate) },
|
2010-04-04 19:27:24 +00:00
|
|
|
{ "TabCurrent", NULL,
|
|
|
|
N_("Focus _Current Tab"), "<Ctrl>Home",
|
|
|
|
N_("Focus the current tab"), G_CALLBACK (_action_tab_current_activate) },
|
2011-04-26 20:57:13 +00:00
|
|
|
{ "NextView", NULL,
|
|
|
|
N_("Focus _Next view"), "F6",
|
|
|
|
N_("Cycle focus between views"), G_CALLBACK (_action_next_view_activate) },
|
2010-07-08 21:08:18 +00:00
|
|
|
{ "TabMinimize", NULL,
|
2010-10-24 18:52:30 +00:00
|
|
|
N_("Only show the Icon of the _Current Tab"), "",
|
|
|
|
N_("Only show the icon of the current tab"), G_CALLBACK (_action_tab_minimize_activate) },
|
2010-07-08 21:08:18 +00:00
|
|
|
{ "TabDuplicate", NULL,
|
|
|
|
N_("_Duplicate Current Tab"), "",
|
|
|
|
N_("Duplicate the current tab"), G_CALLBACK (_action_tab_duplicate_activate) },
|
|
|
|
{ "TabCloseOther", NULL,
|
|
|
|
N_("Close Ot_her Tabs"), "",
|
|
|
|
N_("Close all tabs except the current tab"), G_CALLBACK (_action_tab_close_other_activate) },
|
2010-04-04 19:27:24 +00:00
|
|
|
{ "LastSession", NULL,
|
|
|
|
N_("Open last _session"), NULL,
|
|
|
|
N_("Open the tabs saved in the last session"), NULL },
|
|
|
|
|
|
|
|
{ "Help", NULL, N_("_Help") },
|
2011-03-08 22:25:37 +00:00
|
|
|
{ "HelpFAQ", GTK_STOCK_HELP,
|
|
|
|
N_("_Frequent Questions"), "F1",
|
2010-04-04 19:27:24 +00:00
|
|
|
N_("Show the Frequently Asked Questions"), G_CALLBACK (_action_help_link_activate) },
|
|
|
|
{ "HelpBugs", NULL,
|
2011-04-07 19:18:23 +00:00
|
|
|
N_("_Report a Problem..."), NULL,
|
2010-04-04 19:27:24 +00:00
|
|
|
N_("Open Midori's bug tracker"), G_CALLBACK (_action_help_link_activate) },
|
|
|
|
{ "About", GTK_STOCK_ABOUT,
|
|
|
|
NULL, "",
|
|
|
|
N_("Show information about the program"), G_CALLBACK (_action_about_activate) },
|
|
|
|
{ "Dummy", NULL, "Dummy" },
|
|
|
|
};
|
|
|
|
static const guint entries_n = G_N_ELEMENTS (entries);
|
|
|
|
|
|
|
|
static const GtkToggleActionEntry toggle_entries[] =
|
|
|
|
{
|
|
|
|
{ "Menubar", NULL,
|
|
|
|
N_("_Menubar"), "",
|
|
|
|
N_("Show menubar"), G_CALLBACK (_action_menubar_activate),
|
|
|
|
FALSE },
|
|
|
|
{ "Navigationbar", NULL,
|
|
|
|
N_("_Navigationbar"), "",
|
|
|
|
N_("Show navigationbar"), G_CALLBACK (_action_navigationbar_activate),
|
|
|
|
FALSE },
|
|
|
|
{ "Panel", GTK_STOCK_INDENT,
|
|
|
|
N_("Side_panel"), "F9",
|
|
|
|
N_("Show sidepanel"), G_CALLBACK (_action_panel_activate),
|
|
|
|
FALSE },
|
|
|
|
{ "Bookmarkbar", NULL,
|
|
|
|
N_("_Bookmarkbar"), "",
|
|
|
|
N_("Show bookmarkbar"), G_CALLBACK (_action_bookmarkbar_activate),
|
|
|
|
FALSE },
|
|
|
|
{ "Statusbar", NULL,
|
|
|
|
N_("_Statusbar"), "",
|
|
|
|
N_("Show statusbar"), G_CALLBACK (_action_statusbar_activate),
|
|
|
|
FALSE },
|
|
|
|
};
|
|
|
|
static const guint toggle_entries_n = G_N_ELEMENTS (toggle_entries);
|
|
|
|
|
|
|
|
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 the mnemonic */
|
|
|
|
N_("Japanese (SHIFT__JIS)"), "",
|
|
|
|
NULL, 1 },
|
|
|
|
{ "EncodingKorean", NULL,
|
|
|
|
N_("Korean (EUC-KR)"), "",
|
|
|
|
NULL, 1 },
|
|
|
|
{ "EncodingRussian", NULL,
|
|
|
|
N_("Russian (KOI8-R)"), "",
|
|
|
|
NULL, 1 },
|
|
|
|
{ "EncodingUnicode", NULL,
|
|
|
|
N_("Unicode (UTF-8)"), "",
|
|
|
|
NULL, 1 },
|
|
|
|
{ "EncodingWestern", NULL,
|
|
|
|
N_("Western (ISO-8859-1)"), "",
|
|
|
|
NULL, 1 },
|
|
|
|
{ "EncodingCustom", NULL,
|
|
|
|
N_("Custom..."), "",
|
|
|
|
NULL, 1 },
|
|
|
|
};
|
|
|
|
static const guint encoding_entries_n = G_N_ELEMENTS (encoding_entries);
|
2009-06-22 20:55:23 +00:00
|
|
|
|
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"))
|
2009-11-09 20:49:01 +00:00
|
|
|
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);
|
2010-10-18 20:42:10 +00:00
|
|
|
GdkWindowState state = gdk_window_get_state (gtk_widget_get_window (widget));
|
2009-02-22 13:42:27 +00:00
|
|
|
|
|
|
|
if (!(state &
|
|
|
|
(GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)))
|
2010-02-07 22:42:39 +00:00
|
|
|
{
|
2010-10-18 20:42:10 +00:00
|
|
|
GtkAllocation allocation;
|
|
|
|
gtk_widget_get_allocation (widget, &allocation);
|
|
|
|
if (allocation.width != browser->last_window_width)
|
2010-02-07 22:42:39 +00:00
|
|
|
{
|
2010-10-18 20:42:10 +00:00
|
|
|
browser->last_window_width = allocation.width;
|
2010-02-07 22:42:39 +00:00
|
|
|
g_object_set (browser->settings,
|
|
|
|
"last-window-width", browser->last_window_width, NULL);
|
|
|
|
}
|
2010-10-18 20:42:10 +00:00
|
|
|
if (allocation.height != browser->last_window_height)
|
2010-02-07 22:42:39 +00:00
|
|
|
{
|
2010-10-18 20:42:10 +00:00
|
|
|
browser->last_window_height = allocation.height;
|
2010-02-07 22:42:39 +00:00
|
|
|
g_object_set (browser->settings,
|
2010-10-18 20:42:10 +00:00
|
|
|
"last-window-height", allocation.height, NULL);
|
2010-02-07 22:42:39 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-22 13:42:27 +00:00
|
|
|
|
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);
|
|
|
|
|
2010-04-02 16:54:29 +00:00
|
|
|
if (gtk_widget_get_realized (widget) && !browser->alloc_timeout)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2009-06-22 22:25:09 +00:00
|
|
|
gpointer last_page;
|
|
|
|
|
|
|
|
if ((last_page = g_object_get_data (G_OBJECT (browser), "last-page")))
|
|
|
|
{
|
|
|
|
midori_panel_set_current_page (MIDORI_PANEL (browser->panel),
|
|
|
|
GPOINTER_TO_INT (last_page));
|
|
|
|
g_object_set_data (G_OBJECT (browser), "last-page", NULL);
|
|
|
|
}
|
|
|
|
|
2010-02-07 22:42:39 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-23 19:41:40 +00:00
|
|
|
static void
|
|
|
|
gtk_notebook_size_allocated_cb (GtkWidget* widget,
|
|
|
|
GdkRectangle* allocation,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
_midori_browser_update_notebook (browser);
|
|
|
|
}
|
|
|
|
|
2008-05-22 22:17:10 +00:00
|
|
|
static void
|
|
|
|
midori_browser_destroy_cb (MidoriBrowser* browser)
|
|
|
|
{
|
2010-10-04 21:05:21 +00:00
|
|
|
g_object_set_data (G_OBJECT (browser), "midori-browser-destroyed", (void*)1);
|
|
|
|
|
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 */
|
2011-03-07 02:38:17 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (browser->notebook,
|
|
|
|
midori_browser_notebook_reorder_tab_cb,
|
|
|
|
NULL);
|
2011-03-23 19:41:40 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (browser->notebook,
|
|
|
|
gtk_notebook_size_allocated_cb,
|
|
|
|
NULL);
|
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 =
|
2010-04-04 18:59:58 +00:00
|
|
|
"<ui>"
|
|
|
|
"<menubar>"
|
|
|
|
"<menu action='File'>"
|
|
|
|
"<menuitem action='WindowNew'/>"
|
|
|
|
"<menuitem action='TabNew'/>"
|
|
|
|
"<menuitem action='PrivateBrowsing'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='Open'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='SaveAs'/>"
|
|
|
|
"<menuitem action='AddSpeedDial'/>"
|
|
|
|
"<menuitem action='AddDesktopShortcut'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='TabClose'/>"
|
|
|
|
"<menuitem action='WindowClose'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='Print'/>"
|
2010-07-04 09:14:30 +00:00
|
|
|
"<menuitem action='BookmarksImport'/>"
|
|
|
|
"<menuitem action='BookmarksExport'/>"
|
2010-04-04 18:59:58 +00:00
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='Quit'/>"
|
|
|
|
"</menu>"
|
|
|
|
"<menu action='Edit'>"
|
|
|
|
"<menuitem action='Undo'/>"
|
|
|
|
"<menuitem action='Redo'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='Cut'/>"
|
|
|
|
"<menuitem action='Copy'/>"
|
|
|
|
"<menuitem action='Paste'/>"
|
|
|
|
"<menuitem action='Delete'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='SelectAll'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='Find'/>"
|
|
|
|
"<menuitem action='FindNext'/>"
|
|
|
|
#ifndef G_OS_WIN32
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='Preferences'/>"
|
|
|
|
#endif
|
|
|
|
"</menu>"
|
|
|
|
"<menu action='View'>"
|
|
|
|
"<menu action='Toolbars'>"
|
|
|
|
"<menuitem action='Menubar'/>"
|
|
|
|
"<menuitem action='Navigationbar'/>"
|
|
|
|
"<menuitem action='Bookmarkbar'/>"
|
|
|
|
"<menuitem action='Statusbar'/>"
|
|
|
|
"</menu>"
|
|
|
|
"<menuitem action='Panel'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='Stop'/>"
|
|
|
|
"<menuitem action='Reload'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='ZoomIn'/>"
|
|
|
|
"<menuitem action='ZoomOut'/>"
|
|
|
|
"<menuitem action='ZoomNormal'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menu action='Encoding'>"
|
|
|
|
"<menuitem action='EncodingAutomatic'/>"
|
|
|
|
"<menuitem action='EncodingChinese'/>"
|
|
|
|
"<menuitem action='EncodingJapanese'/>"
|
|
|
|
"<menuitem action='EncodingKorean'/>"
|
|
|
|
"<menuitem action='EncodingRussian'/>"
|
|
|
|
"<menuitem action='EncodingUnicode'/>"
|
|
|
|
"<menuitem action='EncodingWestern'/>"
|
|
|
|
"<menuitem action='EncodingCustom'/>"
|
|
|
|
"</menu>"
|
|
|
|
"<menuitem action='SourceView'/>"
|
|
|
|
"<menuitem action='Fullscreen'/>"
|
|
|
|
"</menu>"
|
|
|
|
"<menu action='Go'>"
|
|
|
|
"<menuitem action='Back'/>"
|
|
|
|
"<menuitem action='Forward'/>"
|
|
|
|
"<menuitem action='Previous'/>"
|
|
|
|
"<menuitem action='Next'/>"
|
|
|
|
"<menuitem action='Homepage'/>"
|
|
|
|
"<menuitem action='Location'/>"
|
|
|
|
"<menuitem action='Search'/>"
|
|
|
|
"<menuitem action='Trash'/>"
|
|
|
|
"</menu>"
|
2010-09-14 20:12:55 +00:00
|
|
|
"<menuitem action='Bookmarks'/>"
|
2010-04-04 18:59:58 +00:00
|
|
|
"<menuitem action='Tools'/>"
|
|
|
|
"<menuitem action='Window'/>"
|
|
|
|
"<menu action='Help'>"
|
|
|
|
"<menuitem action='HelpFAQ'/>"
|
|
|
|
"<menuitem action='HelpBugs'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='About'/>"
|
|
|
|
"</menu>"
|
|
|
|
/* For accelerators to work all actions need to be used
|
|
|
|
*somewhere* in the UI definition */
|
|
|
|
"<menu action='Dummy'>"
|
2011-03-02 17:03:55 +00:00
|
|
|
"<menuitem action='TabMoveBackward'/>"
|
|
|
|
"<menuitem action='TabMoveForward'/>"
|
2010-04-04 18:59:58 +00:00
|
|
|
"<menuitem action='ScrollLeft'/>"
|
|
|
|
"<menuitem action='ScrollDown'/>"
|
|
|
|
"<menuitem action='ScrollUp'/>"
|
|
|
|
"<menuitem action='ScrollRight'/>"
|
|
|
|
"<menuitem action='FindPrevious'/>"
|
|
|
|
"<menuitem action='BookmarkAdd'/>"
|
|
|
|
"<menuitem action='BookmarkFolderAdd'/>"
|
|
|
|
"<menuitem action='ManageSearchEngines'/>"
|
|
|
|
"<menuitem action='ClearPrivateData'/>"
|
|
|
|
"<menuitem action='TabPrevious'/>"
|
|
|
|
"<menuitem action='TabNext'/>"
|
|
|
|
"<menuitem action='TabCurrent'/>"
|
2011-04-26 20:57:13 +00:00
|
|
|
"<menuitem action='NextView'/>"
|
2010-07-08 21:08:18 +00:00
|
|
|
"<menuitem action='TabMinimize'/>"
|
|
|
|
"<menuitem action='TabDuplicate'/>"
|
|
|
|
"<menuitem action='TabCloseOther'/>"
|
2010-04-04 18:59:58 +00:00
|
|
|
"<menuitem action='LastSession'/>"
|
|
|
|
"<menuitem action='UndoTabClose'/>"
|
|
|
|
"<menuitem action='TrashEmpty'/>"
|
|
|
|
"<menuitem action='Preferences'/>"
|
2010-10-05 19:12:08 +00:00
|
|
|
"<menuitem action='InspectPage'/>"
|
2011-02-02 00:55:32 +00:00
|
|
|
"<menuitem action='ReloadUncached'/>"
|
2011-04-30 10:07:12 +00:00
|
|
|
"<menuitem action='CaretBrowsing'/>"
|
2010-04-04 18:59:58 +00:00
|
|
|
"</menu>"
|
|
|
|
"</menubar>"
|
|
|
|
"<toolbar name='toolbar_navigation'>"
|
|
|
|
"</toolbar>"
|
|
|
|
"</ui>";
|
2008-03-10 21:26:09 +00:00
|
|
|
|
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;
|
2009-11-29 14:09:00 +00:00
|
|
|
#ifdef HAVE_HILDON_2_2
|
|
|
|
/* hildon_gtk_window_enable_zoom_keys */
|
|
|
|
guint32 set = 1;
|
2010-10-18 20:42:10 +00:00
|
|
|
gdk_property_change (gtk_widget_get_window (GTK_WIDGET (browser)),
|
2009-11-29 14:09:00 +00:00
|
|
|
gdk_atom_intern ("_HILDON_ZOOM_KEY_ATOM", FALSE),
|
|
|
|
gdk_x11_xatom_to_atom (XA_INTEGER),
|
|
|
|
32, GDK_PROP_MODE_REPLACE,
|
|
|
|
(const guchar *) &set, 1);
|
|
|
|
#endif
|
2008-07-27 05:39:39 +00:00
|
|
|
|
|
|
|
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-11-09 18:26:48 +00:00
|
|
|
static void
|
|
|
|
midori_browser_new_history_item (MidoriBrowser* browser,
|
2010-07-21 19:28:45 +00:00
|
|
|
KatzeItem* item)
|
2008-11-09 18:26:48 +00:00
|
|
|
{
|
|
|
|
time_t now;
|
2009-01-23 21:38:39 +00:00
|
|
|
gint64 day;
|
2010-02-03 21:12:19 +00:00
|
|
|
sqlite3* db;
|
2010-02-04 18:13:16 +00:00
|
|
|
static sqlite3_stmt* stmt = NULL;
|
2008-11-09 18:26:48 +00:00
|
|
|
|
2010-07-22 13:28:18 +00:00
|
|
|
g_return_if_fail (katze_item_get_uri (item) != NULL);
|
|
|
|
|
2008-11-09 18:26:48 +00:00
|
|
|
now = time (NULL);
|
2010-07-21 19:28:45 +00:00
|
|
|
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
|
|
|
|
2010-02-03 21:12:19 +00:00
|
|
|
db = g_object_get_data (G_OBJECT (browser->history), "db");
|
2010-12-24 15:44:49 +00:00
|
|
|
g_return_if_fail (db != NULL);
|
2010-02-04 18:13:16 +00:00
|
|
|
if (!stmt)
|
2008-11-09 18:26:48 +00:00
|
|
|
{
|
2010-02-04 18:13:16 +00:00
|
|
|
const gchar* sqlcmd;
|
|
|
|
|
|
|
|
sqlcmd = "INSERT INTO history (uri, title, date, day) VALUES (?,?,?,?)";
|
|
|
|
sqlite3_prepare_v2 (db, sqlcmd, -1, &stmt, NULL);
|
2008-11-09 18:26:48 +00:00
|
|
|
}
|
2010-07-21 19:28:45 +00:00
|
|
|
sqlite3_bind_text (stmt, 1, katze_item_get_uri (item), -1, 0);
|
|
|
|
sqlite3_bind_text (stmt, 2, katze_item_get_name (item), -1, 0);
|
|
|
|
sqlite3_bind_int64 (stmt, 3, katze_item_get_added (item));
|
2010-02-04 18:13:16 +00:00
|
|
|
sqlite3_bind_int64 (stmt, 4, day);
|
|
|
|
|
|
|
|
if (sqlite3_step (stmt) != SQLITE_DONE)
|
|
|
|
g_printerr (_("Failed to insert new history item: %s\n"),
|
|
|
|
sqlite3_errmsg (db));
|
|
|
|
sqlite3_reset (stmt);
|
|
|
|
sqlite3_clear_bindings (stmt);
|
2010-07-30 23:42:14 +00:00
|
|
|
|
|
|
|
/* FIXME: Workaround for the lack of a database interface */
|
|
|
|
katze_array_add_item (browser->history, item);
|
|
|
|
katze_array_remove_item (browser->history, item);
|
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");
|
2010-01-28 22:56:54 +00:00
|
|
|
midori_location_action_clear (MIDORI_LOCATION_ACTION (location_action));
|
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
|
|
|
{
|
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)
|
2008-11-09 18:26:48 +00:00
|
|
|
return;
|
|
|
|
|
2008-12-21 19:44:31 +00:00
|
|
|
g_signal_connect (browser->history, "clear",
|
|
|
|
G_CALLBACK (midori_browser_history_clear_cb), browser);
|
|
|
|
|
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;
|
|
|
|
|
2011-02-26 15:23:56 +00:00
|
|
|
/* Switch to n-th tab. 9 and 0 go to the last tab. */
|
2009-06-12 00:02:55 +00:00
|
|
|
n = keyval - GDK_0;
|
|
|
|
browser = g_object_get_data (G_OBJECT (accel_group), "midori-browser");
|
|
|
|
if ((view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook),
|
2011-02-26 15:23:56 +00:00
|
|
|
n < 9 ? n - 1 : -1)))
|
2009-06-12 00:02:55 +00:00
|
|
|
midori_browser_set_current_tab (browser, view);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-30 21:57:36 +00:00
|
|
|
static void
|
|
|
|
midori_browser_ui_manager_connect_proxy_cb (GtkUIManager* ui_manager,
|
|
|
|
GtkAction* action,
|
|
|
|
GtkWidget* proxy,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
if (GTK_IS_MENU_ITEM (proxy))
|
|
|
|
{
|
|
|
|
g_signal_connect (proxy, "select",
|
|
|
|
G_CALLBACK (midori_browser_menu_item_select_cb), browser);
|
|
|
|
g_signal_connect (proxy, "deselect",
|
|
|
|
G_CALLBACK (midori_browser_menu_item_deselect_cb), browser);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_ui_manager_disconnect_proxy_cb (GtkUIManager* ui_manager,
|
|
|
|
GtkAction* action,
|
|
|
|
GtkWidget* proxy,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
if (GTK_IS_MENU_ITEM (proxy))
|
|
|
|
{
|
|
|
|
g_signal_handlers_disconnect_by_func (proxy,
|
|
|
|
midori_browser_menu_item_select_cb, browser);
|
|
|
|
g_signal_handlers_disconnect_by_func (proxy,
|
|
|
|
midori_browser_menu_item_deselect_cb, browser);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-27 22:42:07 +00:00
|
|
|
#ifdef HAVE_HILDON_2_2
|
|
|
|
static void
|
|
|
|
midori_browser_set_portrait_mode (MidoriBrowser* browser,
|
|
|
|
gboolean portrait)
|
|
|
|
{
|
|
|
|
if (portrait)
|
|
|
|
hildon_gtk_window_set_portrait_flags (GTK_WINDOW (browser),
|
|
|
|
HILDON_PORTRAIT_MODE_REQUEST);
|
|
|
|
else
|
|
|
|
hildon_gtk_window_set_portrait_flags (GTK_WINDOW (browser),
|
|
|
|
~HILDON_PORTRAIT_MODE_REQUEST);
|
2009-11-28 18:50:56 +00:00
|
|
|
_action_set_visible (browser, "Tools", !portrait);
|
2009-11-27 22:42:07 +00:00
|
|
|
_action_set_visible (browser, "CompactAdd", !portrait);
|
|
|
|
_action_set_visible (browser, "Back", !portrait);
|
|
|
|
_action_set_visible (browser, "SourceView", !portrait);
|
|
|
|
_action_set_visible (browser, "Fullscreen", !portrait);
|
|
|
|
}
|
|
|
|
|
|
|
|
static DBusHandlerResult
|
|
|
|
midori_browser_mce_filter_cb (DBusConnection* connection,
|
|
|
|
DBusMessage* message,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
if (dbus_message_is_signal (message, MCE_SIGNAL_IF, MCE_DEVICE_ORIENTATION_SIG))
|
|
|
|
{
|
|
|
|
DBusError error;
|
|
|
|
char *rotation, *stand, *face;
|
|
|
|
int x, y, z;
|
|
|
|
|
|
|
|
dbus_error_init (&error);
|
|
|
|
if (dbus_message_get_args (message,
|
|
|
|
&error,
|
|
|
|
DBUS_TYPE_STRING, &rotation,
|
|
|
|
DBUS_TYPE_STRING, &stand,
|
|
|
|
DBUS_TYPE_STRING, &face,
|
|
|
|
DBUS_TYPE_INT32, &x,
|
|
|
|
DBUS_TYPE_INT32, &y,
|
|
|
|
DBUS_TYPE_INT32, &z, DBUS_TYPE_INVALID))
|
|
|
|
{
|
|
|
|
gboolean portrait = !strcmp (rotation, MCE_ORIENTATION_PORTRAIT);
|
|
|
|
midori_browser_set_portrait_mode (MIDORI_BROWSER (data), portrait);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("%s: %s\n", error.name, error.message);
|
|
|
|
dbus_error_free (&error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
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;
|
2011-04-26 21:05:53 +00:00
|
|
|
GClosure* accel_closure;
|
2008-11-01 18:15:58 +00:00
|
|
|
GError* error;
|
|
|
|
GtkAction* action;
|
2009-10-13 21:56:02 +00:00
|
|
|
#if !HAVE_HILDON
|
2008-11-01 18:15:58 +00:00
|
|
|
GtkWidget* menuitem;
|
2009-10-13 21:56:02 +00:00
|
|
|
#endif
|
2009-05-07 20:41:39 +00:00
|
|
|
GtkWidget* homepage;
|
|
|
|
GtkWidget* back;
|
|
|
|
GtkWidget* forward;
|
2008-11-01 18:15:58 +00:00
|
|
|
GtkSettings* gtk_settings;
|
|
|
|
GtkWidget* hpaned;
|
|
|
|
GtkWidget* vpaned;
|
2008-07-23 12:42:27 +00:00
|
|
|
GtkRcStyle* rcstyle;
|
2008-11-01 18:15:58 +00:00
|
|
|
GtkWidget* scrolled;
|
2008-07-23 12:42:27 +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;
|
2011-03-14 19:07:18 +00:00
|
|
|
browser->speeddial = NULL;
|
2008-09-03 00:28:54 +00:00
|
|
|
|
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");
|
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 ();
|
2009-09-30 21:57:36 +00:00
|
|
|
g_signal_connect (ui_manager, "connect-proxy",
|
|
|
|
G_CALLBACK (midori_browser_ui_manager_connect_proxy_cb), browser);
|
|
|
|
g_signal_connect (ui_manager, "disconnect-proxy",
|
|
|
|
G_CALLBACK (midori_browser_ui_manager_disconnect_proxy_cb), browser);
|
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);
|
2009-10-31 22:47:44 +00:00
|
|
|
gtk_ui_manager_insert_action_group (ui_manager, browser->action_group, 0);
|
2009-06-12 00:02:55 +00:00
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (accel_group), "midori-browser", browser);
|
2011-04-26 21:05:53 +00:00
|
|
|
accel_closure = g_cclosure_new (G_CALLBACK (
|
|
|
|
midori_browser_accel_switch_tab_activate_cb), browser, NULL);
|
2009-06-12 00:02:55 +00:00
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
{
|
|
|
|
gchar* accel_path = g_strdup_printf ("<Manual>/Browser/SwitchTab%d", i);
|
|
|
|
gtk_accel_map_add_entry (accel_path, GDK_0 + i, GDK_MOD1_MASK);
|
2011-04-26 21:05:53 +00:00
|
|
|
gtk_accel_group_connect_by_path (accel_group, accel_path, accel_closure);
|
2009-06-12 00:02:55 +00:00
|
|
|
g_free (accel_path);
|
|
|
|
}
|
2011-04-26 21:05:53 +00:00
|
|
|
g_closure_unref (accel_closure);
|
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
|
|
|
{
|
|
|
|
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,
|
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,
|
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);
|
|
|
|
|
2010-09-14 20:12:55 +00:00
|
|
|
action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
|
|
|
|
"name", "Bookmarks",
|
|
|
|
"label", _("_Bookmarks"),
|
|
|
|
"stock-id", STOCK_BOOKMARKS,
|
|
|
|
"tooltip", _("Show the saved bookmarks"),
|
|
|
|
"array", browser->proxy_array, /* Use a non-empty array here */
|
|
|
|
NULL);
|
|
|
|
g_object_connect (action,
|
|
|
|
"signal::populate-folder",
|
|
|
|
_action_bookmarks_populate_folder, browser,
|
|
|
|
"signal::activate-item-alt",
|
|
|
|
midori_bookmarkbar_activate_item_alt, browser,
|
|
|
|
NULL);
|
|
|
|
gtk_action_group_add_action_with_accel (browser->action_group, action, "");
|
|
|
|
g_object_unref (action);
|
|
|
|
|
2009-07-24 21:55:57 +00:00
|
|
|
action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
|
|
|
|
"name", "Tools",
|
|
|
|
"label", _("_Tools"),
|
2009-12-02 23:06:53 +00:00
|
|
|
"stock-id", GTK_STOCK_PREFERENCES,
|
2009-07-24 21:55:57 +00:00
|
|
|
"array", katze_array_new (KATZE_TYPE_ITEM),
|
|
|
|
NULL);
|
|
|
|
g_object_connect (action,
|
|
|
|
"signal::populate-popup",
|
|
|
|
_action_tools_populate_popup, browser,
|
2010-07-19 19:39:57 +00:00
|
|
|
"signal::activate-item-alt",
|
|
|
|
midori_bookmarkbar_activate_item_alt, browser,
|
2009-07-24 21:55:57 +00:00
|
|
|
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,
|
2010-09-16 19:18:14 +00:00
|
|
|
"signal::activate-item-alt",
|
|
|
|
_action_window_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-06-22 19:47:42 +00:00
|
|
|
action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
|
|
|
|
"name", "CompactMenu",
|
|
|
|
"label", _("_Menu"),
|
2010-11-21 15:52:10 +00:00
|
|
|
"stock-id", GTK_STOCK_PROPERTIES,
|
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 */
|
2009-11-29 14:00:15 +00:00
|
|
|
browser->menubar = gtk_ui_manager_get_widget (ui_manager, "/menubar");
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), browser->menubar, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_hide (browser->menubar);
|
2009-01-27 01:57:40 +00:00
|
|
|
#if HAVE_HILDON
|
2009-10-13 21:56:02 +00:00
|
|
|
#if HILDON_CHECK_VERSION (2, 2, 0)
|
|
|
|
browser->menubar = hildon_app_menu_new ();
|
|
|
|
_action_compact_menu_populate_popup (NULL, browser->menubar, browser);
|
|
|
|
hildon_window_set_app_menu (HILDON_WINDOW (browser), HILDON_APP_MENU (browser->menubar));
|
|
|
|
#else
|
2009-10-12 11:02:39 +00:00
|
|
|
browser->menubar = gtk_menu_new ();
|
2009-10-13 21:56:02 +00:00
|
|
|
_action_compact_menu_populate_popup (NULL, browser->menubar, browser);
|
2009-01-27 01:57:40 +00:00
|
|
|
hildon_window_set_menu (HILDON_WINDOW (browser), GTK_MENU (browser->menubar));
|
2009-10-13 21:56:02 +00:00
|
|
|
#endif
|
2009-01-27 01:57:40 +00:00
|
|
|
hildon_program_add_window (hildon_program_get_instance (),
|
|
|
|
HILDON_WINDOW (browser));
|
|
|
|
#else
|
|
|
|
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-10-13 21:56:02 +00:00
|
|
|
|
2008-11-01 18:15:58 +00:00
|
|
|
menuitem = gtk_menu_item_new ();
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_widget_show (menuitem);
|
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-10-13 21:56:02 +00:00
|
|
|
#endif
|
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");
|
2009-12-26 22:12:36 +00:00
|
|
|
g_signal_connect (forward, "button-press-event",
|
|
|
|
G_CALLBACK (midori_browser_menu_item_middle_click_event_cb), browser);
|
|
|
|
forward = gtk_ui_manager_get_widget (ui_manager, "/menubar/Go/Previous");
|
|
|
|
g_signal_connect (forward, "button-press-event",
|
|
|
|
G_CALLBACK (midori_browser_menu_item_middle_click_event_cb), browser);
|
|
|
|
forward = gtk_ui_manager_get_widget (ui_manager, "/menubar/Go/Next");
|
2009-05-07 20:41:39 +00:00
|
|
|
g_signal_connect (forward, "button-press-event",
|
|
|
|
G_CALLBACK (midori_browser_menu_item_middle_click_event_cb), browser);
|
|
|
|
|
2009-01-27 01:57:40 +00:00
|
|
|
#if HAVE_HILDON
|
2009-10-31 21:43:58 +00:00
|
|
|
_action_set_visible (browser, "Menubar", FALSE);
|
2009-01-27 01:57:40 +00:00
|
|
|
#endif
|
2009-02-27 22:09:36 +00:00
|
|
|
_action_set_sensitive (browser, "EncodingCustom", FALSE);
|
2009-10-31 21:43:58 +00:00
|
|
|
_action_set_visible (browser, "LastSession", FALSE);
|
2010-12-12 00:26:08 +00:00
|
|
|
#if !HAVE_HILDON && !defined (GDK_WINDOWING_X11)
|
2009-10-31 21:43:58 +00:00
|
|
|
_action_set_visible (browser, "AddDesktopShortcut", FALSE);
|
2010-12-12 00:26:08 +00:00
|
|
|
#endif
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2010-10-24 17:23:16 +00:00
|
|
|
_action_set_visible (browser, "Bookmarks", browser->bookmarks != NULL);
|
|
|
|
_action_set_visible (browser, "BookmarkAdd", browser->bookmarks != NULL);
|
|
|
|
_action_set_visible (browser, "BookmarksImport", browser->bookmarks != NULL);
|
|
|
|
_action_set_visible (browser, "BookmarksExport", browser->bookmarks != NULL);
|
|
|
|
_action_set_visible (browser, "Bookmarkbar", browser->bookmarks != NULL);
|
2010-10-31 20:27:47 +00:00
|
|
|
_action_set_visible (browser, "Trash", browser->trash != NULL);
|
|
|
|
_action_set_visible (browser, "UndoTabClose", browser->trash != NULL);
|
2010-10-24 17:23:16 +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
|
|
|
|
2009-11-27 22:42:07 +00:00
|
|
|
#ifdef HAVE_HILDON_2_2
|
|
|
|
DBusConnection* system_bus = dbus_bus_get (DBUS_BUS_SYSTEM, NULL);
|
|
|
|
if (system_bus)
|
|
|
|
{
|
|
|
|
dbus_bus_add_match (system_bus, MCE_SIGNAL_MATCH, NULL);
|
|
|
|
dbus_connection_add_filter (system_bus,
|
|
|
|
midori_browser_mce_filter_cb, browser, NULL);
|
|
|
|
hildon_gtk_window_set_portrait_flags (GTK_WINDOW (browser),
|
|
|
|
HILDON_PORTRAIT_MODE_SUPPORT);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
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-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);
|
2011-04-26 20:57:13 +00:00
|
|
|
g_signal_connect (hpaned, "cycle-child-focus",
|
|
|
|
G_CALLBACK (midori_panel_cycle_child_focus_cb),
|
|
|
|
browser);
|
2008-03-10 21:26:09 +00:00
|
|
|
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-10-31 22:47:44 +00:00
|
|
|
"action-group", browser->action_group,
|
2009-02-22 18:23:45 +00:00
|
|
|
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::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 ();
|
2010-01-11 20:47:37 +00:00
|
|
|
gtk_paned_pack2 (GTK_PANED (hpaned), vpaned, TRUE, FALSE);
|
2008-11-01 18:15:58 +00:00
|
|
|
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);
|
2009-12-23 15:46:14 +00:00
|
|
|
gtk_paned_pack1 (GTK_PANED (vpaned), browser->notebook, FALSE, FALSE);
|
2009-10-04 00:32:50 +00:00
|
|
|
g_signal_connect (browser->notebook, "switch-page",
|
|
|
|
G_CALLBACK (gtk_notebook_switch_page_cb),
|
|
|
|
browser);
|
2008-06-19 18:39:00 +00:00
|
|
|
g_signal_connect_after (browser->notebook, "switch-page",
|
2009-10-04 00:32:50 +00:00
|
|
|
G_CALLBACK (gtk_notebook_switch_page_after_cb),
|
2008-03-10 21:26:09 +00:00
|
|
|
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);
|
2011-03-23 19:41:40 +00:00
|
|
|
g_signal_connect (browser->notebook, "size-allocate",
|
|
|
|
G_CALLBACK (gtk_notebook_size_allocated_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);
|
2011-03-07 02:38:17 +00:00
|
|
|
g_signal_connect (browser->notebook, "reorder-tab",
|
|
|
|
G_CALLBACK (midori_browser_notebook_reorder_tab_cb), NULL);
|
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);
|
2009-12-23 15:46:14 +00:00
|
|
|
gtk_paned_pack2 (GTK_PANED (vpaned), browser->inspector, FALSE, FALSE);
|
2008-11-01 18:15:58 +00:00
|
|
|
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
|
2009-12-23 15:46:14 +00:00
|
|
|
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
2010-10-04 19:36:26 +00:00
|
|
|
gtk_widget_set_can_focus (scrolled, TRUE);
|
2008-11-01 18:15:58 +00:00
|
|
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
|
|
|
|
GTK_SHADOW_ETCHED_IN);
|
2009-12-23 15:46:14 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (browser->inspector), scrolled, TRUE, TRUE, 0);
|
|
|
|
browser->inspector_view = gtk_viewport_new (NULL, NULL);
|
2008-11-01 18:15:58 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled), browser->inspector_view);
|
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Incremental findbar */
|
2010-06-20 18:13:39 +00:00
|
|
|
browser->find = g_object_new (MIDORI_TYPE_FINDBAR, NULL);
|
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 ();
|
2010-10-18 20:44:56 +00:00
|
|
|
#if GTK_CHECK_VERSION (2, 20, 0)
|
|
|
|
browser->statusbar_contents =
|
|
|
|
gtk_statusbar_get_message_area (GTK_STATUSBAR (browser->statusbar));
|
|
|
|
#else
|
2009-10-27 22:55:17 +00:00
|
|
|
/* Rearrange the statusbar packing. This is necessariy to keep
|
|
|
|
themes happy while there is no support from GtkStatusbar. */
|
2010-10-18 20:44:56 +00:00
|
|
|
forward = GTK_STATUSBAR (browser->statusbar)->label;
|
|
|
|
if (GTK_IS_BOX (gtk_widget_get_parent (forward)))
|
|
|
|
browser->statusbar_contents = gtk_widget_get_parent (forward);
|
2009-11-17 17:51:38 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
browser->statusbar_contents = gtk_hbox_new (FALSE, 4);
|
|
|
|
gtk_widget_show (browser->statusbar_contents);
|
|
|
|
g_object_ref (GTK_STATUSBAR (browser->statusbar)->label);
|
|
|
|
gtk_container_remove (
|
2010-10-18 20:44:56 +00:00
|
|
|
GTK_CONTAINER (GTK_STATUSBAR (browser->statusbar)->frame), forward);
|
2009-11-17 17:51:38 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (browser->statusbar_contents),
|
2010-10-18 20:44:56 +00:00
|
|
|
forward, TRUE, TRUE, 0);
|
|
|
|
g_object_unref (forward);
|
2009-11-17 17:51:38 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_STATUSBAR (browser->statusbar)->frame),
|
|
|
|
browser->statusbar_contents);
|
|
|
|
}
|
2010-10-18 20:44:56 +00:00
|
|
|
#endif
|
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
|
|
|
|
2010-06-17 18:03:11 +00:00
|
|
|
browser->transferbar = g_object_new (MIDORI_TYPE_TRANSFERBAR, NULL);
|
|
|
|
gtk_box_pack_start (GTK_BOX (browser->statusbar_contents), browser->transferbar, FALSE, FALSE, 3);
|
|
|
|
gtk_toolbar_set_show_arrow (GTK_TOOLBAR (browser->transferbar), FALSE);
|
2009-03-19 17:28:50 +00:00
|
|
|
gtk_widget_show (browser->transferbar);
|
2010-06-17 18:03:11 +00:00
|
|
|
|
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);
|
2010-07-29 13:03:18 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (browser->settings,
|
|
|
|
midori_browser_settings_notify,
|
|
|
|
browser);
|
|
|
|
midori_browser_set_bookmarks (browser, 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);
|
|
|
|
|
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->trash, NULL);
|
|
|
|
katze_object_assign (browser->search_engines, NULL);
|
|
|
|
katze_object_assign (browser->history, NULL);
|
2011-03-14 19:07:18 +00:00
|
|
|
browser->speeddial = NULL;
|
2008-03-10 21:26:09 +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)
|
|
|
|
{
|
|
|
|
GtkToolbarStyle gtk_toolbar_style;
|
2009-11-17 17:49:14 +00:00
|
|
|
GtkIconSize icon_size;
|
2008-04-22 20:19:24 +00:00
|
|
|
GtkSettings* gtk_settings = gtk_widget_get_settings (GTK_WIDGET (browser));
|
2009-11-17 17:49:14 +00:00
|
|
|
g_object_get (gtk_settings, "gtk-toolbar-icon-size", &icon_size, NULL);
|
2008-04-22 20:19:24 +00:00
|
|
|
if (toolbar_style == MIDORI_TOOLBAR_DEFAULT && gtk_settings)
|
|
|
|
g_object_get (gtk_settings, "gtk-toolbar-style", >k_toolbar_style, NULL);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (toolbar_style)
|
|
|
|
{
|
2009-11-17 17:49:14 +00:00
|
|
|
case MIDORI_TOOLBAR_SMALL_ICONS:
|
|
|
|
icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR;
|
2008-04-22 20:19:24 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
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);
|
2009-11-17 17:49:14 +00:00
|
|
|
gtk_toolbar_set_icon_size (GTK_TOOLBAR (browser->navigationbar), icon_size);
|
2010-07-29 13:18:27 +00:00
|
|
|
midori_panel_set_toolbar_style (MIDORI_PANEL (browser->panel),
|
|
|
|
gtk_toolbar_style);
|
2008-04-22 20:19:24 +00:00
|
|
|
}
|
|
|
|
|
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);
|
2010-04-02 16:54:29 +00:00
|
|
|
GtkAction* action = gtk_activatable_get_related_action (
|
|
|
|
GTK_ACTIVATABLE (parent));
|
2009-05-03 19:35:05 +00:00
|
|
|
|
2010-06-25 15:30:59 +00:00
|
|
|
return _action_navigation_activate (action, browser);
|
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;
|
|
|
|
|
|
|
|
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;
|
2009-01-20 22:27:19 +00:00
|
|
|
MidoriWindowState last_window_state;
|
2011-05-16 00:51:03 +00:00
|
|
|
gboolean compact_sidepanel;
|
2009-11-28 22:53:49 +00:00
|
|
|
gboolean right_align_sidepanel, open_panels_in_windows;
|
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;
|
2011-02-13 18:07:48 +00:00
|
|
|
gboolean show_panel;
|
2008-04-16 23:38:22 +00:00
|
|
|
MidoriToolbarStyle toolbar_style;
|
2008-10-12 16:14:57 +00:00
|
|
|
gchar* toolbar_items;
|
2008-07-13 19:49:57 +00:00
|
|
|
gboolean close_buttons_on_tabs;
|
2008-10-12 16:14:57 +00:00
|
|
|
KatzeItem* item;
|
2008-07-13 19:49:57 +00:00
|
|
|
|
2011-04-25 23:29:26 +00:00
|
|
|
g_free (browser->location_entry_search);
|
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,
|
2010-02-07 22:42:39 +00:00
|
|
|
"last-window-width", &browser->last_window_width,
|
|
|
|
"last-window-height", &browser->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-02-22 02:51:10 +00:00
|
|
|
"right-align-sidepanel", &right_align_sidepanel,
|
2009-11-28 22:53:49 +00:00
|
|
|
"open-panels-in-windows", &open_panels_in_windows,
|
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-02-28 13:05:01 +00:00
|
|
|
"show-statusbar", &browser->show_statusbar,
|
2008-04-16 23:38:22 +00:00
|
|
|
"toolbar-style", &toolbar_style,
|
2008-10-12 16:14:57 +00:00
|
|
|
"toolbar-items", &toolbar_items,
|
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-11-14 17:29:29 +00:00
|
|
|
"maximum-history-age", &browser->maximum_history_age,
|
2009-04-14 17:44:48 +00:00
|
|
|
"news-aggregator", &browser->news_aggregator,
|
2008-04-16 23:38:22 +00:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (remember_last_window_size)
|
|
|
|
{
|
2010-02-07 22:42:39 +00:00
|
|
|
if (browser->last_window_width && browser->last_window_height)
|
2008-04-16 23:38:22 +00:00
|
|
|
gtk_window_set_default_size (GTK_WINDOW (browser),
|
2010-02-07 22:42:39 +00:00
|
|
|
browser->last_window_width, browser->last_window_height);
|
2008-04-16 23:38:22 +00:00
|
|
|
else
|
2010-06-26 21:39:49 +00:00
|
|
|
{
|
|
|
|
GdkScreen* screen;
|
|
|
|
GdkRectangle monitor;
|
|
|
|
gint default_width, default_height;
|
|
|
|
|
|
|
|
screen = gtk_window_get_screen (GTK_WINDOW (browser));
|
|
|
|
gdk_screen_get_monitor_geometry (screen, 0, &monitor);
|
|
|
|
default_width = monitor.width / 1.7;
|
|
|
|
default_height = monitor.height / 1.7;
|
2008-04-16 23:38:22 +00:00
|
|
|
gtk_window_set_default_size (GTK_WINDOW (browser),
|
|
|
|
default_width, default_height);
|
2010-06-26 21:39:49 +00:00
|
|
|
}
|
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
|
|
|
{
|
2008-08-25 23:19:38 +00:00
|
|
|
item = katze_array_get_nth_item (browser->search_engines,
|
2011-05-15 19:40:39 +00:00
|
|
|
browser->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
|
|
|
|
2010-09-11 21:39:51 +00:00
|
|
|
KATZE_ARRAY_FOREACH_ITEM (item, browser->search_engines)
|
2009-04-18 20:41:37 +00:00
|
|
|
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,
|
2009-11-28 22:53:49 +00:00
|
|
|
"right-aligned", right_align_sidepanel,
|
|
|
|
"open-panels-in-windows", open_panels_in_windows, 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 */
|
2010-04-02 16:38:56 +00:00
|
|
|
if (gtk_widget_get_visible (GTK_WIDGET (browser)))
|
2009-06-22 22:25:09 +00:00
|
|
|
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);
|
2010-10-31 20:27:22 +00:00
|
|
|
_action_set_active (browser, "Bookmarkbar", show_bookmarkbar
|
|
|
|
&& browser->bookmarks != NULL);
|
2008-04-16 23:38:22 +00:00
|
|
|
_action_set_active (browser, "Panel", show_panel);
|
2009-02-28 13:05:01 +00:00
|
|
|
_action_set_active (browser, "Statusbar", browser->show_statusbar);
|
2009-07-17 02:28:53 +00:00
|
|
|
|
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);
|
|
|
|
}
|
2009-11-28 22:53:49 +00:00
|
|
|
else if (name == g_intern_string ("open-panels-in-windows"))
|
|
|
|
g_object_set (browser->panel, "open-panels-in-windows",
|
|
|
|
g_value_get_boolean (&value), NULL);
|
2008-10-03 23:45:17 +00:00
|
|
|
else if (name == g_intern_string ("always-show-tabbar"))
|
|
|
|
_toggle_tabbar_smartly (browser);
|
2009-11-12 22:56:04 +00:00
|
|
|
else if (name == g_intern_string ("show-menubar"))
|
|
|
|
sokoke_widget_set_visible (browser->menubar, g_value_get_boolean (&value));
|
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-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-11-14 17:29:29 +00:00
|
|
|
else if (name == g_intern_string ("maximum-history-age"))
|
2011-05-16 01:20:59 +00:00
|
|
|
browser->maximum_history_age = g_value_get_int (&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);
|
|
|
|
}
|
|
|
|
|
2010-06-25 02:05:26 +00:00
|
|
|
static gboolean
|
|
|
|
midori_bookmarkbar_item_button_press_event_cb (GtkWidget* toolitem,
|
|
|
|
GdkEventButton* event,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
KatzeItem* item;
|
|
|
|
gint n;
|
|
|
|
|
|
|
|
item = (KatzeItem*)g_object_get_data (G_OBJECT (toolitem), "KatzeItem");
|
|
|
|
if (event->button == 2)
|
|
|
|
{
|
2010-07-19 19:39:57 +00:00
|
|
|
if (KATZE_ITEM_IS_BOOKMARK (item))
|
2010-06-25 02:05:26 +00:00
|
|
|
{
|
|
|
|
n = midori_browser_add_uri (browser, katze_item_get_uri (item));
|
2010-07-03 07:28:03 +00:00
|
|
|
midori_browser_set_current_page_smartly (browser, n);
|
2010-06-25 02:05:26 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (event->button == 3)
|
|
|
|
{
|
|
|
|
midori_browser_bookmark_popup (toolitem, NULL, item, browser);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_bookmarkbar_insert_item (GtkWidget* toolbar,
|
|
|
|
KatzeItem* item)
|
|
|
|
{
|
|
|
|
MidoriBrowser* browser = midori_browser_get_for_widget (toolbar);
|
2010-07-19 19:39:57 +00:00
|
|
|
GtkAction* action = _action_by_name (browser, "Tools");
|
|
|
|
GtkToolItem* toolitem = katze_array_action_create_tool_item_for (
|
|
|
|
KATZE_ARRAY_ACTION (action), item);
|
2010-06-25 02:05:26 +00:00
|
|
|
g_object_set_data (G_OBJECT (toolitem), "KatzeItem", item);
|
|
|
|
|
|
|
|
if (KATZE_IS_ITEM (item))
|
|
|
|
{
|
|
|
|
GtkWidget* child = gtk_bin_get_child (GTK_BIN (toolitem));
|
|
|
|
g_object_set_data (G_OBJECT (child), "KatzeItem", item);
|
2010-06-25 15:55:04 +00:00
|
|
|
g_signal_connect (child, "button-press-event",
|
|
|
|
G_CALLBACK (midori_bookmarkbar_item_button_press_event_cb),
|
|
|
|
browser);
|
2010-06-25 02:05:26 +00:00
|
|
|
}
|
|
|
|
else /* Separator */
|
|
|
|
gtk_tool_item_set_use_drag_window (toolitem, TRUE);
|
|
|
|
|
|
|
|
gtk_widget_show (GTK_WIDGET (toolitem));
|
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
|
|
|
|
}
|
|
|
|
|
2010-08-10 21:46:49 +00:00
|
|
|
static void
|
|
|
|
midori_bookmarkbar_remove_item_cb (KatzeArray* bookmarks,
|
|
|
|
KatzeItem* item,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
if (gtk_widget_get_visible (browser->bookmarkbar))
|
|
|
|
midori_bookmarkbar_populate (browser);
|
|
|
|
}
|
|
|
|
|
2010-06-25 02:05:26 +00:00
|
|
|
static void
|
|
|
|
midori_bookmarkbar_populate (MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
sqlite3* db;
|
|
|
|
const gchar* sqlcmd;
|
2010-07-01 19:21:01 +00:00
|
|
|
KatzeArray* array;
|
|
|
|
KatzeItem* item;
|
2010-07-19 18:55:59 +00:00
|
|
|
|
|
|
|
midori_bookmarkbar_clear (browser->bookmarkbar);
|
2010-06-25 02:05:26 +00:00
|
|
|
|
2010-08-22 01:39:11 +00:00
|
|
|
/* Use a dummy to ensure height of the toolbar */
|
2010-06-29 06:15:52 +00:00
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->bookmarkbar),
|
2010-08-22 01:39:11 +00:00
|
|
|
gtk_separator_tool_item_new (), -1);
|
2010-06-25 02:05:26 +00:00
|
|
|
|
|
|
|
db = g_object_get_data (G_OBJECT (browser->bookmarks), "db");
|
|
|
|
if (!db)
|
|
|
|
return;
|
|
|
|
|
2010-07-23 17:57:59 +00:00
|
|
|
sqlcmd = "SELECT uri, title, desc, app, folder, toolbar FROM bookmarks WHERE "
|
2010-07-02 16:59:09 +00:00
|
|
|
" toolbar = 1 ORDER BY uri ASC";
|
2010-07-01 19:21:01 +00:00
|
|
|
|
|
|
|
array = katze_array_from_sqlite (db, sqlcmd);
|
|
|
|
if (!array)
|
2010-06-25 02:05:26 +00:00
|
|
|
{
|
|
|
|
_action_set_sensitive (browser, "BookmarkAdd", FALSE);
|
|
|
|
_action_set_sensitive (browser, "BookmarkFolderAdd", FALSE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-09-11 21:39:51 +00:00
|
|
|
KATZE_ARRAY_FOREACH_ITEM (item, array)
|
2010-06-25 02:05:26 +00:00
|
|
|
{
|
2010-07-01 19:42:54 +00:00
|
|
|
if (KATZE_ITEM_IS_BOOKMARK (item))
|
|
|
|
midori_bookmarkbar_insert_item (browser->bookmarkbar, item);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
KatzeArray* subfolder;
|
|
|
|
gchar* subsqlcmd;
|
|
|
|
|
2010-07-23 17:57:59 +00:00
|
|
|
subsqlcmd = g_strdup_printf ("SELECT uri, title, desc, app FROM bookmarks WHERE "
|
2010-07-02 16:59:09 +00:00
|
|
|
" folder = '%s' and uri != ''", katze_item_get_name (item));
|
2010-07-01 21:03:24 +00:00
|
|
|
subfolder = katze_array_from_sqlite (db, subsqlcmd);
|
2010-07-01 19:42:54 +00:00
|
|
|
katze_item_set_name (KATZE_ITEM (subfolder), katze_item_get_name (item));
|
|
|
|
midori_bookmarkbar_insert_item (browser->bookmarkbar, KATZE_ITEM (subfolder));
|
|
|
|
g_free (subsqlcmd);
|
|
|
|
}
|
2010-06-25 02:05:26 +00:00
|
|
|
}
|
|
|
|
_action_set_sensitive (browser, "BookmarkAdd", TRUE);
|
|
|
|
_action_set_sensitive (browser, "BookmarkFolderAdd", TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_bookmarkbar_clear (GtkWidget* toolbar)
|
|
|
|
{
|
|
|
|
GList* children = gtk_container_get_children (GTK_CONTAINER (toolbar));
|
|
|
|
while (children != NULL)
|
|
|
|
{
|
|
|
|
gtk_widget_destroy (children->data);
|
|
|
|
children = g_list_next (children);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_show_bookmarkbar_notify_value_cb (MidoriWebSettings* settings,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2011-04-25 23:29:26 +00:00
|
|
|
if (!katze_object_get_boolean (browser->settings, "show-bookmarkbar"))
|
2010-06-25 02:05:26 +00:00
|
|
|
midori_bookmarkbar_clear (browser->bookmarkbar);
|
|
|
|
else
|
|
|
|
midori_bookmarkbar_populate (browser);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2010-06-25 02:05:26 +00:00
|
|
|
MidoriWebSettings* settings;
|
|
|
|
|
2010-08-10 21:46:49 +00:00
|
|
|
if (browser->bookmarks != NULL)
|
|
|
|
g_signal_handlers_disconnect_by_func (browser->bookmarks,
|
|
|
|
midori_bookmarkbar_remove_item_cb, browser);
|
2010-07-29 13:03:18 +00:00
|
|
|
settings = midori_browser_get_settings (browser);
|
|
|
|
g_signal_handlers_disconnect_by_func (settings,
|
|
|
|
midori_browser_show_bookmarkbar_notify_value_cb, browser);
|
|
|
|
katze_object_assign (browser->bookmarks, bookmarks);
|
|
|
|
|
2010-10-24 17:23:16 +00:00
|
|
|
_action_set_visible (browser, "Bookmarks", bookmarks != NULL);
|
|
|
|
if (bookmarks != NULL)
|
|
|
|
{
|
|
|
|
/* FIXME: Proxies aren't shown propely. Why? */
|
|
|
|
GSList* proxies = gtk_action_get_proxies (
|
|
|
|
_action_by_name (browser, "Bookmarks"));
|
|
|
|
for (; proxies; proxies = g_slist_next (proxies))
|
|
|
|
gtk_widget_show (proxies->data);
|
|
|
|
}
|
|
|
|
_action_set_visible (browser, "BookmarkAdd", bookmarks != NULL);
|
|
|
|
_action_set_visible (browser, "BookmarksImport", bookmarks != NULL);
|
|
|
|
_action_set_visible (browser, "BookmarksExport", bookmarks != NULL);
|
|
|
|
_action_set_visible (browser, "Bookmarkbar", bookmarks != NULL);
|
|
|
|
|
2010-06-25 02:05:26 +00:00
|
|
|
if (!bookmarks)
|
|
|
|
return;
|
|
|
|
|
2010-11-01 15:54:11 +00:00
|
|
|
if (katze_object_get_boolean (browser->settings, "show-bookmarkbar"))
|
|
|
|
_action_set_active (browser, "Bookmarkbar", TRUE);
|
2010-07-29 13:03:18 +00:00
|
|
|
g_object_ref (bookmarks);
|
2010-06-25 02:05:26 +00:00
|
|
|
g_signal_connect (settings, "notify::show-bookmarkbar",
|
|
|
|
G_CALLBACK (midori_browser_show_bookmarkbar_notify_value_cb), browser);
|
|
|
|
g_object_notify (G_OBJECT (settings), "show-bookmarkbar");
|
2010-08-10 21:46:49 +00:00
|
|
|
g_signal_connect_after (bookmarks, "remove-item",
|
|
|
|
G_CALLBACK (midori_bookmarkbar_remove_item_cb), browser);
|
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-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:
|
2009-11-13 17:24:16 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (browser->settings,
|
|
|
|
midori_browser_settings_notify,
|
|
|
|
browser);
|
2008-10-27 03:23:41 +00:00
|
|
|
katze_object_assign (browser->settings, g_value_dup_object (value));
|
2009-11-13 17:24:16 +00:00
|
|
|
if (!browser->settings)
|
|
|
|
browser->settings = midori_web_settings_new ();
|
|
|
|
|
|
|
|
_midori_browser_update_settings (browser);
|
|
|
|
g_signal_connect (browser->settings, "notify",
|
|
|
|
G_CALLBACK (midori_browser_settings_notify), browser);
|
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));
|
2009-12-05 20:33:19 +00:00
|
|
|
g_object_set (_action_by_name (browser, "Trash"),
|
|
|
|
"array", browser->trash, "reversed", TRUE,
|
|
|
|
NULL);
|
2010-10-31 20:27:47 +00:00
|
|
|
_action_set_visible (browser, "Trash", browser->trash != NULL);
|
|
|
|
_action_set_visible (browser, "UndoTabClose", 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:
|
2009-11-13 17:24:16 +00:00
|
|
|
{
|
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));
|
2011-05-16 00:51:03 +00:00
|
|
|
midori_location_action_set_search_engines (MIDORI_LOCATION_ACTION (
|
|
|
|
_action_by_name (browser, "Location")), browser->search_engines);
|
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 */
|
2009-04-18 20:41:37 +00:00
|
|
|
|
2009-11-21 05:36:35 +00:00
|
|
|
if (browser->search_engines)
|
|
|
|
{
|
2011-05-15 19:40:39 +00:00
|
|
|
g_object_get (browser->settings, "last-web-search", &browser->last_web_search, NULL);
|
|
|
|
item = katze_array_get_nth_item (browser->search_engines, browser->last_web_search);
|
2009-11-21 05:36:35 +00:00
|
|
|
midori_search_action_set_current_item (MIDORI_SEARCH_ACTION (
|
2009-11-13 17:24:16 +00:00
|
|
|
_action_by_name (browser, "Search")), item);
|
2009-11-21 05:36:35 +00:00
|
|
|
|
2010-09-11 21:39:51 +00:00
|
|
|
KATZE_ARRAY_FOREACH_ITEM (item, browser->search_engines)
|
2009-11-21 05:36:35 +00:00
|
|
|
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
|
|
|
break;
|
2009-11-13 17:24:16 +00:00
|
|
|
}
|
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;
|
2011-03-14 19:07:18 +00:00
|
|
|
case PROP_SPEED_DIAL:
|
|
|
|
browser->speeddial = g_value_get_pointer (value);
|
|
|
|
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:
|
2009-10-27 22:55:17 +00:00
|
|
|
g_value_set_object (value, browser->statusbar_contents);
|
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;
|
2011-03-14 19:07:18 +00:00
|
|
|
case PROP_SPEED_DIAL:
|
|
|
|
g_value_set_pointer (value, browser->speeddial);
|
|
|
|
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);
|
|
|
|
|
2011-07-26 23:19:48 +00:00
|
|
|
if (!g_object_get_data (G_OBJECT (webkit_get_default_session ()),
|
|
|
|
"midori-session-initialized"))
|
|
|
|
g_critical ("midori_load_soup_session was not called!");
|
|
|
|
|
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
|
|
|
{
|
2010-06-06 21:46:10 +00:00
|
|
|
const gchar* uri;
|
2008-09-26 21:13:46 +00:00
|
|
|
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
|
|
|
|
2010-06-06 21:46:10 +00:00
|
|
|
uri = katze_item_get_uri (item);
|
2010-11-18 20:22:12 +00:00
|
|
|
if (!uri)
|
|
|
|
uri = "about:blank";
|
2008-09-26 21:13:46 +00:00
|
|
|
title = katze_item_get_name (item);
|
2011-01-01 19:05:34 +00:00
|
|
|
view = midori_view_new_with_title (title, browser->settings,
|
|
|
|
g_object_get_data (G_OBJECT (item), "midori-view-append") ? TRUE : FALSE);
|
2011-02-23 21:36:03 +00:00
|
|
|
|
|
|
|
proxy_item = midori_view_get_proxy_item (MIDORI_VIEW (view));
|
|
|
|
|
|
|
|
if (katze_item_get_meta_boolean (item, "dont-write-history"))
|
|
|
|
katze_item_set_meta_integer (proxy_item, "dont-write-history", 1);
|
|
|
|
|
2011-01-01 19:05:34 +00:00
|
|
|
page = midori_browser_add_tab (browser, view);
|
|
|
|
|
2010-06-06 21:46:10 +00:00
|
|
|
/* Blank pages should not be delayed */
|
|
|
|
if (katze_item_get_meta_integer (item, "delay") > 0
|
2011-02-23 06:23:06 +00:00
|
|
|
&& strcmp (uri, "about:blank") != 0
|
|
|
|
&& strncmp (uri, "pause:", 6) != 0)
|
2010-05-31 21:39:02 +00:00
|
|
|
{
|
2010-09-17 18:03:11 +00:00
|
|
|
gchar* new_uri = g_strdup_printf ("pause:%s", uri);
|
2011-01-01 19:05:34 +00:00
|
|
|
midori_view_set_uri (MIDORI_VIEW (view), new_uri);
|
2010-05-31 21:39:02 +00:00
|
|
|
g_free (new_uri);
|
|
|
|
}
|
|
|
|
else
|
2011-01-01 19:05:34 +00:00
|
|
|
midori_view_set_uri (MIDORI_VIEW (view), uri);
|
2010-03-03 22:52:07 +00:00
|
|
|
|
2009-07-18 14:41:13 +00:00
|
|
|
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;
|
2011-01-01 19:05:34 +00:00
|
|
|
gint n;
|
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);
|
|
|
|
|
2011-01-01 19:05:34 +00:00
|
|
|
view = midori_view_new_with_title (NULL, browser->settings, FALSE);
|
|
|
|
n = midori_browser_add_tab (browser, view);
|
|
|
|
midori_view_set_uri (MIDORI_VIEW (view), uri);
|
|
|
|
return n;
|
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
|
|
|
}
|
|
|
|
|
2010-10-13 21:22:54 +00:00
|
|
|
void
|
|
|
|
midori_browser_set_action_visible (MidoriBrowser* browser,
|
|
|
|
const gchar* name,
|
|
|
|
gboolean visible)
|
|
|
|
{
|
|
|
|
g_return_if_fail (MIDORI_IS_BROWSER (browser));
|
|
|
|
g_return_if_fail (name != NULL);
|
|
|
|
|
|
|
|
_action_set_visible (browser, name, visible);
|
2011-03-13 21:15:14 +00:00
|
|
|
_action_set_sensitive (browser, name, visible);
|
2010-10-13 21:22:54 +00:00
|
|
|
}
|
|
|
|
|
2011-04-30 10:17:55 +00:00
|
|
|
/**
|
|
|
|
* midori_browser_block_action:
|
|
|
|
* @browser: a #MidoriBrowser
|
|
|
|
* @name: the action to be blocked
|
|
|
|
*
|
|
|
|
* Blocks built-in behavior of the specified action without
|
|
|
|
* disabling it, which gives you a chance to connect your
|
|
|
|
* own signal handling.
|
|
|
|
* Call midori_browser_unblock_action() to undo the effect.
|
|
|
|
*
|
|
|
|
* Since: 0.3.4
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
midori_browser_block_action (MidoriBrowser* browser,
|
|
|
|
GtkAction* action)
|
|
|
|
{
|
|
|
|
const gchar* name;
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
g_return_if_fail (MIDORI_IS_BROWSER (browser));
|
|
|
|
g_return_if_fail (GTK_IS_ACTION (action));
|
|
|
|
|
|
|
|
name = gtk_action_get_name (action);
|
|
|
|
for (i = 0; i < entries_n; i++)
|
|
|
|
if (g_str_equal (entries[i].name, name))
|
|
|
|
{
|
|
|
|
g_signal_handlers_block_by_func (action, entries[i].callback, browser);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
g_critical ("%s: Action \"%s\" can't be blocked.", G_STRFUNC, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* midori_browser_unblock_action:
|
|
|
|
* @browser: a #MidoriBrowser
|
|
|
|
* @name: the action to be unblocked
|
|
|
|
*
|
|
|
|
* Restores built-in behavior of the specified action after
|
|
|
|
* previously blocking it with midori_browser_block_action().
|
|
|
|
*
|
|
|
|
* Since: 0.3.4
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
midori_browser_unblock_action (MidoriBrowser* browser,
|
|
|
|
GtkAction* action)
|
|
|
|
{
|
|
|
|
const gchar* name;
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
g_return_if_fail (MIDORI_IS_BROWSER (browser));
|
|
|
|
g_return_if_fail (GTK_IS_ACTION (action));
|
|
|
|
|
|
|
|
name = gtk_action_get_name (action);
|
|
|
|
for (i = 0; i < entries_n; i++)
|
|
|
|
if (g_str_equal (entries[i].name, name))
|
|
|
|
{
|
|
|
|
g_signal_handlers_unblock_by_func (action, entries[i].callback, browser);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
g_critical ("%s: Action \"%s\" can't be unblocked.", G_STRFUNC, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2010-12-25 01:07:45 +00:00
|
|
|
gint n_pages;
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view;
|
|
|
|
|
2010-12-25 01:07:45 +00:00
|
|
|
g_return_if_fail (MIDORI_IS_BROWSER (browser));
|
|
|
|
|
|
|
|
n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (browser->notebook));
|
|
|
|
g_return_if_fail (n < n_pages);
|
|
|
|
|
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);
|
2010-05-06 20:27:29 +00:00
|
|
|
if (midori_view_is_blank (MIDORI_VIEW (view)))
|
2008-08-14 23:57:48 +00:00
|
|
|
gtk_action_activate (_action_by_name (browser, "Location"));
|
2009-10-12 11:05:43 +00:00
|
|
|
else
|
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
|
|
|
/**
|
2010-05-18 21:55:30 +00:00
|
|
|
* midori_browser_set_tab:
|
2008-05-02 20:30:26 +00:00
|
|
|
* @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.
|
2010-05-18 21:55:30 +00:00
|
|
|
*
|
|
|
|
* Since: 0.2.6
|
2008-05-02 20:30:26 +00:00
|
|
|
**/
|
|
|
|
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);
|
2010-05-06 20:27:29 +00:00
|
|
|
if (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);
|
2011-03-02 17:04:36 +00:00
|
|
|
|
|
|
|
g_object_freeze_notify (G_OBJECT (browser));
|
|
|
|
g_object_notify (G_OBJECT (browser), "uri");
|
|
|
|
g_object_notify (G_OBJECT (browser), "tab");
|
|
|
|
g_object_thaw_notify (G_OBJECT (browser));
|
2008-05-02 20:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-05-18 21:55:30 +00:00
|
|
|
* midori_browser_get_tab:
|
2008-05-02 20:30:26 +00:00
|
|
|
* @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
|
2010-05-18 21:55:30 +00:00
|
|
|
*
|
|
|
|
* Since: 0.2.6
|
2008-05-02 20:30:26 +00:00
|
|
|
**/
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-04-25 16:58:28 +00:00
|
|
|
/**
|
|
|
|
* midori_browser_get_tabs:
|
|
|
|
* @browser: a #MidoriBrowser
|
|
|
|
*
|
|
|
|
* Retrieves the tabs as a list.
|
|
|
|
*
|
|
|
|
* Return value: a newly allocated #GList of #MidoriView
|
|
|
|
*
|
|
|
|
* Since: 0.2.5
|
|
|
|
**/
|
|
|
|
GList*
|
|
|
|
midori_browser_get_tabs (MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
|
|
|
|
|
|
|
|
return gtk_container_get_children (GTK_CONTAINER (browser->notebook));
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
/**
|
2010-04-25 16:20:19 +00:00
|
|
|
* midori_browser_get_proxy_items:
|
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
|
2010-04-25 16:20:19 +00:00
|
|
|
*
|
|
|
|
* Since: 0.2.5
|
|
|
|
**/
|
|
|
|
KatzeArray*
|
|
|
|
midori_browser_get_proxy_items (MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
|
|
|
|
|
|
|
|
return browser->proxy_array;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* midori_browser_get_proxy_array:
|
|
|
|
* @browser: a #MidoriBrowser
|
|
|
|
*
|
|
|
|
* Retrieves a proxy array representing the respective proxy items.
|
|
|
|
*
|
|
|
|
* Return value: the proxy #KatzeArray
|
|
|
|
*
|
|
|
|
* Deprecated: 0.2.5: Use midori_browser_get_proxy_item instead.
|
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);
|
|
|
|
}
|