2008-03-10 21:26:09 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2007-2008 Christian Dywan <christian@twotoasts.de>
|
2008-10-07 00:19:33 +00:00
|
|
|
Copyright (C) 2008 Dale Whittaker <dayul@users.sf.net>
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
See the file COPYING for the full license text.
|
|
|
|
*/
|
|
|
|
|
2008-08-14 23:57:48 +00:00
|
|
|
#if HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
#include "midori-browser.h"
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
#include "midori-view.h"
|
|
|
|
#include "midori-source.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-04-28 20:38:57 +00:00
|
|
|
#include "midori-addons.h"
|
2008-03-27 00:21:29 +00:00
|
|
|
#include "midori-console.h"
|
2008-08-14 23:57:48 +00:00
|
|
|
#include "midori-locationaction.h"
|
2008-10-05 21:25:02 +00:00
|
|
|
#include "midori-searchaction.h"
|
2008-09-03 00:39:25 +00:00
|
|
|
#include "midori-stock.h"
|
|
|
|
|
|
|
|
#include "gtkiconentry.h"
|
2008-07-16 12:24:30 +00:00
|
|
|
#include "compat.h"
|
2008-09-03 00:39:25 +00:00
|
|
|
#include "sokoke.h"
|
2008-08-02 02:25:05 +00:00
|
|
|
#include "gjs.h"
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-08-23 21:44:55 +00:00
|
|
|
#if HAVE_GIO
|
2008-07-13 20:09:52 +00:00
|
|
|
#include <gio/gio.h>
|
|
|
|
#endif
|
2008-04-16 23:38:22 +00:00
|
|
|
#include <glib/gi18n.h>
|
2008-03-10 21:26:09 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
struct _MidoriBrowser
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-06-19 18:39:00 +00:00
|
|
|
GtkWindow parent_instance;
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
GtkActionGroup* action_group;
|
|
|
|
GtkWidget* menubar;
|
|
|
|
GtkWidget* menu_tools;
|
|
|
|
GtkWidget* popup_bookmark;
|
2008-10-07 00:19:33 +00:00
|
|
|
GtkWidget* popup_history;
|
2008-03-10 21:26:09 +00:00
|
|
|
GtkWidget* throbber;
|
|
|
|
GtkWidget* navigationbar;
|
|
|
|
GtkWidget* button_tab_new;
|
2008-05-20 01:21:11 +00:00
|
|
|
GtkWidget* button_homepage;
|
2008-03-10 21:26:09 +00:00
|
|
|
GtkWidget* search;
|
|
|
|
GtkWidget* button_trash;
|
|
|
|
GtkWidget* button_fullscreen;
|
|
|
|
GtkWidget* bookmarkbar;
|
|
|
|
|
|
|
|
GtkWidget* panel;
|
|
|
|
GtkWidget* panel_bookmarks;
|
2008-10-07 00:19:33 +00:00
|
|
|
GtkWidget* panel_history;
|
2008-03-27 00:21:29 +00:00
|
|
|
GtkWidget* panel_console;
|
2008-03-10 21:26:09 +00:00
|
|
|
GtkWidget* panel_pageholder;
|
|
|
|
GtkWidget* notebook;
|
|
|
|
|
|
|
|
GtkWidget* find;
|
|
|
|
GtkWidget* find_text;
|
|
|
|
GtkToolItem* find_case;
|
|
|
|
GtkToolItem* find_highlight;
|
|
|
|
|
|
|
|
GtkWidget* statusbar;
|
|
|
|
GtkWidget* progressbar;
|
|
|
|
gchar* statusbar_text;
|
|
|
|
|
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;
|
2008-03-10 21:26:09 +00:00
|
|
|
};
|
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
G_DEFINE_TYPE (MidoriBrowser, midori_browser, GTK_TYPE_WINDOW)
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
|
2008-05-02 20:30:26 +00:00
|
|
|
PROP_MENUBAR,
|
|
|
|
PROP_NAVIGATIONBAR,
|
2008-07-23 18:17:13 +00:00
|
|
|
PROP_URI,
|
2008-05-02 20:30:26 +00:00
|
|
|
PROP_TAB,
|
|
|
|
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,
|
|
|
|
PROP_HISTORY
|
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
|
|
|
WINDOW_OBJECT_CLEARED,
|
|
|
|
NEW_WINDOW,
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-05-31 22:21:08 +00:00
|
|
|
ADD_TAB,
|
2008-07-23 18:17:13 +00:00
|
|
|
REMOVE_TAB,
|
2008-05-31 22:21:08 +00:00
|
|
|
ACTIVATE_ACTION,
|
|
|
|
QUIT,
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint signals[LAST_SIGNAL];
|
|
|
|
|
2008-07-25 10:45:50 +00:00
|
|
|
static void
|
|
|
|
midori_browser_dispose (GObject* object);
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
midori_browser_finalize (GObject* object);
|
|
|
|
|
|
|
|
static void
|
2008-03-27 00:21:29 +00:00
|
|
|
midori_browser_set_property (GObject* object,
|
|
|
|
guint prop_id,
|
2008-03-10 21:26:09 +00:00
|
|
|
const GValue* value,
|
2008-03-27 00:21:29 +00:00
|
|
|
GParamSpec* pspec);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
static void
|
2008-03-27 00:21:29 +00:00
|
|
|
midori_browser_get_property (GObject* object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue* value,
|
2008-03-10 21:26:09 +00:00
|
|
|
GParamSpec* pspec);
|
|
|
|
|
2008-10-07 00:19:33 +00:00
|
|
|
static void
|
|
|
|
midori_browser_new_history_item (MidoriBrowser* browser,
|
|
|
|
KatzeItem* item);
|
2008-07-17 19:02:14 +00:00
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static GtkAction*
|
|
|
|
_action_by_name (MidoriBrowser* browser,
|
|
|
|
const gchar* name)
|
|
|
|
{
|
2008-06-19 18:39:00 +00:00
|
|
|
return gtk_action_group_get_action (browser->action_group, name);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_set_sensitive (MidoriBrowser* browser,
|
|
|
|
const gchar* name,
|
|
|
|
gboolean sensitive)
|
|
|
|
{
|
|
|
|
gtk_action_set_sensitive (_action_by_name (browser, name), sensitive);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_set_active (MidoriBrowser* browser,
|
|
|
|
const gchar* name,
|
|
|
|
gboolean active)
|
|
|
|
{
|
|
|
|
GtkAction* action = _action_by_name (browser, name);
|
|
|
|
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), active);
|
|
|
|
}
|
|
|
|
|
2008-07-13 19:49:57 +00:00
|
|
|
static void
|
|
|
|
_midori_browser_open_uri (MidoriBrowser* browser,
|
|
|
|
const gchar* uri)
|
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view;
|
2008-07-13 19:49:57 +00:00
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
view = midori_browser_get_current_tab (browser);
|
|
|
|
if (view)
|
|
|
|
midori_view_set_uri (MIDORI_VIEW (view), uri);
|
2008-07-13 19:49:57 +00:00
|
|
|
}
|
|
|
|
|
2008-10-03 23:45:17 +00:00
|
|
|
static void
|
|
|
|
_toggle_tabbar_smartly (MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
guint n;
|
|
|
|
gboolean always_show_tabbar;
|
|
|
|
|
|
|
|
n = gtk_notebook_get_n_pages (GTK_NOTEBOOK (browser->notebook));
|
|
|
|
if (n < 2)
|
|
|
|
{
|
|
|
|
g_object_get (browser->settings, "always-show-tabbar",
|
|
|
|
&always_show_tabbar, NULL);
|
|
|
|
if (always_show_tabbar)
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (browser->notebook), n > 1);
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
_midori_browser_update_actions (MidoriBrowser* browser)
|
|
|
|
{
|
2008-07-13 19:49:57 +00:00
|
|
|
guint n;
|
2008-08-25 23:19:38 +00:00
|
|
|
gboolean trash_empty;
|
2008-07-13 19:49:57 +00:00
|
|
|
|
2008-10-03 23:45:17 +00:00
|
|
|
_toggle_tabbar_smartly (browser);
|
2008-07-13 19:49:57 +00:00
|
|
|
n = gtk_notebook_get_n_pages (GTK_NOTEBOOK (browser->notebook));
|
2008-03-10 21:26:09 +00:00
|
|
|
_action_set_sensitive (browser, "TabClose", n > 1);
|
|
|
|
_action_set_sensitive (browser, "TabPrevious", n > 1);
|
|
|
|
_action_set_sensitive (browser, "TabNext", n > 1);
|
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
if (browser->trash)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-08-25 23:19:38 +00:00
|
|
|
trash_empty = katze_array_is_empty (browser->trash);
|
2008-03-10 21:26:09 +00:00
|
|
|
_action_set_sensitive (browser, "UndoTabClose", !trash_empty);
|
|
|
|
_action_set_sensitive (browser, "Trash", !trash_empty);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_midori_browser_update_interface (MidoriBrowser* browser)
|
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view;
|
2008-07-06 14:12:27 +00:00
|
|
|
gboolean loading;
|
2008-09-26 21:13:46 +00:00
|
|
|
gboolean can_reload;
|
2008-08-14 23:57:48 +00:00
|
|
|
GtkAction* action;
|
2008-07-13 19:49:57 +00:00
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
view = midori_browser_get_current_tab (browser);
|
|
|
|
loading = midori_view_get_load_status (MIDORI_VIEW (view))
|
2008-07-23 15:54:24 +00:00
|
|
|
!= MIDORI_LOAD_FINISHED;
|
2008-09-26 21:13:46 +00:00
|
|
|
can_reload = midori_view_can_reload (MIDORI_VIEW (view));
|
|
|
|
|
|
|
|
_action_set_sensitive (browser, "Reload", can_reload && !loading);
|
|
|
|
_action_set_sensitive (browser, "Stop", can_reload && loading);
|
|
|
|
_action_set_sensitive (browser, "Back",
|
|
|
|
midori_view_can_go_back (MIDORI_VIEW (view)));
|
|
|
|
_action_set_sensitive (browser, "Forward",
|
|
|
|
midori_view_can_go_forward (MIDORI_VIEW (view)));
|
|
|
|
|
|
|
|
_action_set_sensitive (browser, "Print",
|
|
|
|
midori_view_can_print (MIDORI_VIEW (view)));
|
|
|
|
_action_set_sensitive (browser, "ZoomIn",
|
|
|
|
midori_view_can_zoom_in (MIDORI_VIEW (view)));
|
|
|
|
_action_set_sensitive (browser, "ZoomOut",
|
|
|
|
midori_view_can_zoom_out (MIDORI_VIEW (view)));
|
|
|
|
_action_set_sensitive (browser, "ZoomNormal",
|
|
|
|
midori_view_get_zoom_level (MIDORI_VIEW (view)) != 1.0);
|
|
|
|
_action_set_sensitive (browser, "SourceView",
|
|
|
|
midori_view_can_view_source (MIDORI_VIEW (view)));
|
|
|
|
_action_set_sensitive (browser, "Find",
|
|
|
|
midori_view_can_find (MIDORI_VIEW (view)));
|
|
|
|
_action_set_sensitive (browser, "FindNext",
|
|
|
|
midori_view_can_find (MIDORI_VIEW (view)));
|
|
|
|
_action_set_sensitive (browser, "FindPrevious",
|
|
|
|
midori_view_can_find (MIDORI_VIEW (view)));
|
|
|
|
/* _action_set_sensitive (browser, "FindQuick",
|
|
|
|
midori_view_can_find (MIDORI_VIEW (view))); */
|
2008-09-28 14:29:41 +00:00
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (browser->find_highlight),
|
|
|
|
midori_view_can_find (MIDORI_VIEW (view)));
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-08-14 23:57:48 +00:00
|
|
|
action = gtk_action_group_get_action (browser->action_group, "ReloadStop");
|
2008-03-10 21:26:09 +00:00
|
|
|
if (!loading)
|
|
|
|
{
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_widget_set_sensitive (browser->throbber, FALSE);
|
2008-03-10 21:26:09 +00:00
|
|
|
g_object_set (action,
|
|
|
|
"stock-id", GTK_STOCK_REFRESH,
|
2008-08-31 00:45:13 +00:00
|
|
|
"tooltip", _("Reload the current page"),
|
2008-09-26 21:13:46 +00:00
|
|
|
"sensitive", can_reload, NULL);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_widget_hide (browser->progressbar);
|
2008-09-11 00:14:53 +00:00
|
|
|
if (!GTK_WIDGET_VISIBLE (browser->statusbar))
|
|
|
|
if (!sokoke_object_get_boolean (browser->settings,
|
|
|
|
"show-navigationbar"))
|
|
|
|
gtk_widget_hide (browser->navigationbar);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_widget_set_sensitive (browser->throbber, TRUE);
|
2008-03-10 21:26:09 +00:00
|
|
|
g_object_set (action,
|
|
|
|
"stock-id", GTK_STOCK_STOP,
|
2008-03-22 02:38:23 +00:00
|
|
|
"tooltip", _("Stop loading the current page"), NULL);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_widget_show (browser->progressbar);
|
2008-08-31 00:45:13 +00:00
|
|
|
if (!GTK_WIDGET_VISIBLE (browser->statusbar))
|
2008-09-11 00:14:53 +00:00
|
|
|
{
|
|
|
|
if (!GTK_WIDGET_VISIBLE (browser->navigationbar))
|
|
|
|
gtk_widget_show (browser->navigationbar);
|
2008-08-31 00:45:13 +00:00
|
|
|
g_object_set (_action_by_name (browser, "Location"), "progress",
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_view_get_progress (MIDORI_VIEW (view)), NULL);
|
2008-09-11 00:14:53 +00:00
|
|
|
}
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
2008-06-19 18:39:00 +00:00
|
|
|
katze_throbber_set_animated (KATZE_THROBBER (browser->throbber), loading);
|
2008-08-02 02:25:05 +00:00
|
|
|
|
|
|
|
/* FIXME: This won't work due to a bug in GtkIconEntry */
|
2008-09-26 21:13:46 +00:00
|
|
|
/* if (view && midori_view_get_news_feeds (MIDORI_VIEW (view)))
|
2008-08-02 02:25:05 +00:00
|
|
|
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (
|
|
|
|
gtk_bin_get_child (GTK_BIN (browser->location))),
|
2008-08-17 14:14:15 +00:00
|
|
|
GTK_ICON_ENTRY_SECONDARY, STOCK_NEWS_FEED);
|
2008-08-02 02:25:05 +00:00
|
|
|
else
|
|
|
|
gtk_icon_entry_set_icon_from_pixbuf (GTK_ICON_ENTRY (
|
2008-07-21 13:55:08 +00:00
|
|
|
gtk_bin_get_child (GTK_BIN (browser->location))),
|
2008-08-02 02:25:05 +00:00
|
|
|
GTK_ICON_ENTRY_SECONDARY, NULL);*/
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_midori_browser_set_statusbar_text (MidoriBrowser* browser,
|
|
|
|
const gchar* text)
|
|
|
|
{
|
2008-06-19 18:39:00 +00:00
|
|
|
katze_assign (browser->statusbar_text, g_strdup (text));
|
|
|
|
gtk_statusbar_pop (GTK_STATUSBAR (browser->statusbar), 1);
|
|
|
|
gtk_statusbar_push (GTK_STATUSBAR (browser->statusbar), 1,
|
|
|
|
browser->statusbar_text ? browser->statusbar_text : "");
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2008-04-24 22:20:43 +00:00
|
|
|
static void
|
|
|
|
_midori_browser_set_current_page_smartly (MidoriBrowser* browser,
|
|
|
|
gint n)
|
|
|
|
{
|
2008-07-16 16:08:47 +00:00
|
|
|
if (!sokoke_object_get_boolean (browser->settings,
|
|
|
|
"open-tabs-in-the-background"))
|
2008-04-24 22:20:43 +00:00
|
|
|
midori_browser_set_current_page (browser, n);
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
_midori_browser_update_progress (MidoriBrowser* browser,
|
2008-09-26 21:13:46 +00:00
|
|
|
MidoriView* view)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-08-31 00:45:13 +00:00
|
|
|
MidoriLocationAction* action;
|
2008-07-23 15:54:24 +00:00
|
|
|
gdouble progress;
|
|
|
|
gchar* message;
|
|
|
|
|
2008-08-31 00:45:13 +00:00
|
|
|
action = MIDORI_LOCATION_ACTION (_action_by_name (browser, "Location"));
|
2008-09-26 21:13:46 +00:00
|
|
|
progress = midori_view_get_progress (view);
|
2008-08-31 00:45:13 +00:00
|
|
|
/* When we are finished, we don't want to *see* progress anymore */
|
2008-09-26 21:13:46 +00:00
|
|
|
if (midori_view_get_load_status (view) == MIDORI_LOAD_FINISHED)
|
2008-08-31 00:45:13 +00:00
|
|
|
progress = 0.0;
|
2008-07-23 15:54:24 +00:00
|
|
|
if (progress > 0.0)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (browser->progressbar),
|
2008-07-23 15:54:24 +00:00
|
|
|
progress);
|
|
|
|
message = g_strdup_printf (_("%d%% loaded"), (gint)(progress * 100));
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (browser->progressbar),
|
2008-03-10 21:26:09 +00:00
|
|
|
message);
|
|
|
|
g_free (message);
|
2008-08-31 00:45:13 +00:00
|
|
|
if (!GTK_WIDGET_VISIBLE (browser->statusbar))
|
|
|
|
midori_location_action_set_progress (action, progress);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-07-23 15:54:24 +00:00
|
|
|
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (browser->progressbar));
|
|
|
|
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (browser->progressbar),
|
|
|
|
NULL);
|
2008-08-31 00:45:13 +00:00
|
|
|
midori_location_action_set_progress (action, 0.0);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-28 20:38:57 +00:00
|
|
|
static void
|
2008-09-26 21:13:46 +00:00
|
|
|
_midori_browser_activate_action (MidoriBrowser* browser,
|
|
|
|
const gchar* name)
|
|
|
|
{
|
|
|
|
GtkAction* action = _action_by_name (browser, name);
|
|
|
|
if (action)
|
|
|
|
gtk_action_activate (action);
|
|
|
|
else
|
|
|
|
g_warning (_("Unexpected action '%s'."), name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_view_notify_icon_cb (MidoriView* view,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
2008-04-28 20:38:57 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
const gchar* uri;
|
|
|
|
GtkAction* action;
|
|
|
|
|
|
|
|
uri = midori_view_get_display_uri (MIDORI_VIEW (view));
|
|
|
|
action = _action_by_name (browser, "Location");
|
|
|
|
midori_location_action_set_icon_for_uri (
|
|
|
|
MIDORI_LOCATION_ACTION (action), midori_view_get_icon (view), uri);
|
2008-04-28 20:38:57 +00:00
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_view_notify_load_status_cb (GtkWidget* view,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-07-23 15:54:24 +00:00
|
|
|
const gchar* uri;
|
2008-08-14 23:57:48 +00:00
|
|
|
GtkAction* action;
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
uri = midori_view_get_display_uri (MIDORI_VIEW (view));
|
2008-08-14 23:57:48 +00:00
|
|
|
action = _action_by_name (browser, "Location");
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
if (midori_view_get_load_status (MIDORI_VIEW (view))
|
2008-08-14 23:57:48 +00:00
|
|
|
== MIDORI_LOAD_COMMITTED)
|
|
|
|
midori_location_action_add_uri (
|
|
|
|
MIDORI_LOCATION_ACTION (action), uri);
|
2008-09-26 21:13:46 +00:00
|
|
|
else if (midori_view_get_load_status (MIDORI_VIEW (view))
|
|
|
|
== MIDORI_LOAD_FINISHED)
|
|
|
|
{
|
|
|
|
/* g_signal_emit (browser, signals[WINDOW_OBJECT_CLEARED], 0,
|
|
|
|
web_frame, js_context, js_window); */
|
|
|
|
}
|
2008-07-23 15:54:24 +00:00
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
if (view == midori_browser_get_current_tab (browser))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
if (midori_view_get_load_status (MIDORI_VIEW (view))
|
2008-07-23 15:54:24 +00:00
|
|
|
== MIDORI_LOAD_COMMITTED)
|
|
|
|
{
|
2008-08-14 23:57:48 +00:00
|
|
|
midori_location_action_set_uri (
|
|
|
|
MIDORI_LOCATION_ACTION (action), uri);
|
|
|
|
midori_location_action_set_secondary_icon (
|
|
|
|
MIDORI_LOCATION_ACTION (action), NULL);
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
static void
|
|
|
|
midori_web_view_news_feed_ready_cb (MidoriWebView* web_view,
|
|
|
|
const gchar* href,
|
|
|
|
const gchar* type,
|
|
|
|
const gchar* title,
|
2008-07-23 15:54:24 +00:00
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
if (web_view == (MidoriWebView*)midori_browser_get_current_web_view (browser))
|
|
|
|
midori_location_action_set_secondary_icon (MIDORI_LOCATION_ACTION (
|
|
|
|
_action_by_name (browser, "Location")), STOCK_NEWS_FEED);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
2008-09-26 21:13:46 +00:00
|
|
|
*/
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
static void
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_view_notify_title_cb (GtkWidget* view,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-08-14 23:57:48 +00:00
|
|
|
const gchar* uri;
|
|
|
|
const gchar* title;
|
|
|
|
GtkAction* action;
|
|
|
|
gchar* window_title;
|
2008-10-07 00:19:33 +00:00
|
|
|
KatzeItem* item;
|
2008-08-14 23:57:48 +00:00
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
uri = midori_view_get_display_uri (MIDORI_VIEW (view));
|
|
|
|
title = midori_view_get_display_title (MIDORI_VIEW (view));
|
2008-08-14 23:57:48 +00:00
|
|
|
action = _action_by_name (browser, "Location");
|
|
|
|
midori_location_action_set_title_for_uri (
|
|
|
|
MIDORI_LOCATION_ACTION (action), title, uri);
|
2008-10-07 00:19:33 +00:00
|
|
|
if (midori_view_get_load_status (MIDORI_VIEW (view)) == MIDORI_LOAD_COMMITTED)
|
|
|
|
{
|
|
|
|
if (!browser->history)
|
|
|
|
return;
|
|
|
|
|
|
|
|
item = katze_item_new ();
|
|
|
|
katze_item_set_uri (item, uri);
|
|
|
|
katze_item_set_name (item, title);
|
|
|
|
katze_item_set_visits (item, -1);
|
|
|
|
midori_browser_new_history_item (browser, item);
|
|
|
|
}
|
2008-08-14 23:57:48 +00:00
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
if (view == midori_browser_get_current_tab (browser))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-08-14 23:57:48 +00:00
|
|
|
window_title = g_strconcat (title, " - ",
|
2008-03-10 21:26:09 +00:00
|
|
|
g_get_application_name (), NULL);
|
|
|
|
gtk_window_set_title (GTK_WINDOW (browser), window_title);
|
|
|
|
g_free (window_title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-21 23:51:08 +00:00
|
|
|
static void
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_view_notify_zoom_level_cb (GtkWidget* view,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
2008-07-21 23:51:08 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
if (view == midori_browser_get_current_tab (browser))
|
2008-07-21 23:51:08 +00:00
|
|
|
_action_set_sensitive (browser, "ZoomNormal",
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_view_get_zoom_level (MIDORI_VIEW (view)) != 1.0);
|
2008-07-19 02:06:10 +00:00
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_view_notify_statusbar_text_cb (MidoriView* view,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
2008-07-16 16:08:47 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
gchar* text;
|
2008-07-16 16:08:47 +00:00
|
|
|
|
2008-09-26 21:13:46 +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
|
|
|
}
|
|
|
|
|
2008-06-15 11:29:30 +00:00
|
|
|
static void
|
|
|
|
midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
|
2008-10-01 02:00:16 +00:00
|
|
|
KatzeItem* bookmark)
|
2008-06-15 11:29:30 +00:00
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
gboolean new_bookmark;
|
|
|
|
GtkWidget* dialog;
|
|
|
|
GtkSizeGroup* sizegroup;
|
|
|
|
GtkWidget* view;
|
|
|
|
GtkWidget* hbox;
|
|
|
|
GtkWidget* label;
|
|
|
|
const gchar* value;
|
|
|
|
GtkWidget* entry_title;
|
|
|
|
GtkWidget* entry_desc;
|
|
|
|
GtkWidget* entry_uri;
|
|
|
|
GtkWidget* combo_folder;
|
|
|
|
GtkTreeView* treeview;
|
|
|
|
GtkTreeModel* treemodel;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
new_bookmark = bookmark == NULL;
|
|
|
|
dialog = gtk_dialog_new_with_buttons (
|
2008-06-15 11:29:30 +00:00
|
|
|
new_bookmark ? _("New bookmark") : _("Edit bookmark"),
|
|
|
|
GTK_WINDOW (browser),
|
|
|
|
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
|
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
new_bookmark ? GTK_STOCK_ADD : GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
|
|
|
|
NULL);
|
|
|
|
gtk_window_set_icon_name (GTK_WINDOW (dialog),
|
|
|
|
new_bookmark ? GTK_STOCK_ADD : GTK_STOCK_REMOVE);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 5);
|
2008-10-01 02:00:16 +00:00
|
|
|
sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
2008-06-15 11:29:30 +00:00
|
|
|
|
|
|
|
if (new_bookmark)
|
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
view = midori_browser_get_current_tab (browser);
|
|
|
|
bookmark = g_object_new (KATZE_TYPE_ITEM,
|
|
|
|
"uri", midori_view_get_display_uri (MIDORI_VIEW (view)),
|
|
|
|
"name", midori_view_get_display_title (MIDORI_VIEW (view)), NULL);
|
2008-06-15 11:29:30 +00:00
|
|
|
}
|
|
|
|
|
2008-10-01 02:00:16 +00:00
|
|
|
hbox = gtk_hbox_new (FALSE, 8);
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
|
2008-10-01 02:00:16 +00:00
|
|
|
label = gtk_label_new_with_mnemonic (_("_Title:"));
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_size_group_add_widget (sizegroup, label);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
2008-10-01 02:00:16 +00:00
|
|
|
entry_title = gtk_entry_new ();
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_entry_set_activates_default (GTK_ENTRY (entry_title), TRUE);
|
2008-10-01 02:00:16 +00:00
|
|
|
value = katze_item_get_name (bookmark);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry_title), value ? value : "");
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), entry_title, TRUE, TRUE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox);
|
|
|
|
gtk_widget_show_all (hbox);
|
|
|
|
|
|
|
|
hbox = gtk_hbox_new (FALSE, 8);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
|
|
|
|
label = gtk_label_new_with_mnemonic (_("_Description:"));
|
|
|
|
gtk_size_group_add_widget (sizegroup, label);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
2008-10-01 02:00:16 +00:00
|
|
|
entry_desc = gtk_entry_new ();
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_entry_set_activates_default (GTK_ENTRY (entry_desc), TRUE);
|
|
|
|
if (!new_bookmark)
|
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
value = katze_item_get_text (bookmark);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry_desc), value ? value : "");
|
2008-06-15 11:29:30 +00:00
|
|
|
}
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), entry_desc, TRUE, TRUE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox);
|
|
|
|
gtk_widget_show_all (hbox);
|
|
|
|
|
2008-10-01 02:00:16 +00:00
|
|
|
entry_uri = NULL;
|
|
|
|
if (!KATZE_IS_ARRAY (bookmark))
|
2008-06-15 11:29:30 +00:00
|
|
|
{
|
|
|
|
hbox = gtk_hbox_new (FALSE, 8);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
|
|
|
|
label = gtk_label_new_with_mnemonic (_("_URL:"));
|
|
|
|
gtk_size_group_add_widget (sizegroup, label);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
entry_uri = gtk_entry_new ();
|
|
|
|
gtk_entry_set_activates_default (GTK_ENTRY (entry_uri), TRUE);
|
2008-10-01 02:00:16 +00:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry_uri), katze_item_get_uri (bookmark));
|
2008-08-31 00:45:13 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), entry_uri, TRUE, TRUE, 0);
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox);
|
|
|
|
gtk_widget_show_all (hbox);
|
|
|
|
}
|
|
|
|
|
2008-10-01 02:00:16 +00:00
|
|
|
combo_folder = NULL;
|
2008-06-15 11:29:30 +00:00
|
|
|
if (new_bookmark)
|
|
|
|
{
|
|
|
|
hbox = gtk_hbox_new (FALSE, 8);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
|
|
|
|
label = gtk_label_new_with_mnemonic (_("_Folder:"));
|
|
|
|
gtk_size_group_add_widget (sizegroup, label);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
combo_folder = gtk_combo_box_new_text ();
|
|
|
|
gtk_combo_box_append_text (GTK_COMBO_BOX (combo_folder), _("Root"));
|
|
|
|
gtk_widget_set_sensitive (combo_folder, FALSE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), combo_folder, TRUE, TRUE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox);
|
|
|
|
gtk_widget_show_all (hbox);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
|
|
|
|
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
|
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
katze_item_set_name (bookmark,
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_entry_get_text (GTK_ENTRY (entry_title)));
|
2008-10-01 02:00:16 +00:00
|
|
|
katze_item_set_text (bookmark,
|
2008-08-31 00:45:13 +00:00
|
|
|
gtk_entry_get_text (GTK_ENTRY (entry_desc)));
|
2008-10-01 02:00:16 +00:00
|
|
|
if (!KATZE_IS_ARRAY (bookmark))
|
|
|
|
katze_item_set_uri (bookmark,
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_entry_get_text (GTK_ENTRY (entry_uri)));
|
|
|
|
|
|
|
|
/* FIXME: We want to choose a folder */
|
|
|
|
if (new_bookmark)
|
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
katze_array_add_item (browser->bookmarks, bookmark);
|
|
|
|
treeview = GTK_TREE_VIEW (browser->panel_bookmarks);
|
|
|
|
treemodel = gtk_tree_view_get_model (treeview);
|
2008-06-15 11:29:30 +00:00
|
|
|
gtk_tree_store_insert_with_values (GTK_TREE_STORE (treemodel),
|
|
|
|
&iter, NULL, G_MAXINT, 0, bookmark, -1);
|
2008-10-01 02:00:16 +00:00
|
|
|
g_object_ref (bookmark);
|
2008-06-15 11:29:30 +00:00
|
|
|
}
|
|
|
|
|
2008-10-01 02:00:16 +00:00
|
|
|
/* FIXME: Update navigationbar */
|
2008-06-15 11:29:30 +00:00
|
|
|
/* FIXME: Update panel in other windows */
|
|
|
|
}
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_view_add_bookmark_cb (GtkWidget* menuitem,
|
|
|
|
const gchar* uri,
|
|
|
|
GtkWidget* view)
|
2008-06-15 11:29:30 +00:00
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
KatzeItem* item;
|
2008-06-15 11:29:30 +00:00
|
|
|
MidoriBrowser* browser;
|
|
|
|
|
2008-10-01 02:00:16 +00:00
|
|
|
item = katze_item_new ();
|
|
|
|
katze_item_set_uri (item, uri);
|
2008-06-15 11:29:30 +00:00
|
|
|
browser = (MidoriBrowser*)gtk_widget_get_toplevel (menuitem);
|
2008-10-01 02:00:16 +00:00
|
|
|
midori_browser_edit_bookmark_dialog_new (browser, item);
|
2008-06-15 11:29:30 +00:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_view_console_message_cb (GtkWidget* view,
|
|
|
|
const gchar* message,
|
|
|
|
gint line,
|
|
|
|
const gchar* source_id,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
midori_console_add (MIDORI_CONSOLE (browser->panel_console),
|
|
|
|
message, line, source_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2008-10-02 22:49:16 +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
|
|
|
{
|
|
|
|
g_signal_emit (browser, signals[NEW_WINDOW], 0, uri);
|
|
|
|
}
|
|
|
|
|
2008-09-28 14:29:41 +00:00
|
|
|
static void
|
|
|
|
midori_view_search_text_cb (GtkWidget* view,
|
|
|
|
gboolean found,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
const gchar* text;
|
|
|
|
gboolean case_sensitive;
|
|
|
|
gboolean highlight;
|
|
|
|
|
|
|
|
if (GTK_WIDGET_VISIBLE (browser->find))
|
|
|
|
{
|
|
|
|
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (browser->find_text),
|
|
|
|
GTK_ICON_ENTRY_PRIMARY, (found) ? GTK_STOCK_FIND : GTK_STOCK_STOP);
|
|
|
|
text = gtk_entry_get_text (GTK_ENTRY (browser->find_text));
|
|
|
|
case_sensitive = gtk_toggle_tool_button_get_active (
|
|
|
|
GTK_TOGGLE_TOOL_BUTTON (browser->find_case));
|
|
|
|
midori_view_mark_text_matches (MIDORI_VIEW (view), text, case_sensitive);
|
|
|
|
highlight = gtk_toggle_tool_button_get_active (
|
|
|
|
GTK_TOGGLE_TOOL_BUTTON (browser->find_highlight));
|
|
|
|
midori_view_set_highlight_text_matches (MIDORI_VIEW (view), highlight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-13 19:49:57 +00:00
|
|
|
static gboolean
|
|
|
|
midori_browser_tab_destroy_cb (GtkWidget* widget,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
KatzeItem* item;
|
2008-07-13 19:49:57 +00:00
|
|
|
const gchar* uri;
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
if (browser->proxy_array && MIDORI_IS_VIEW (widget))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
item = midori_view_get_proxy_item (MIDORI_VIEW (widget));
|
|
|
|
uri = katze_item_get_uri (item);
|
2008-10-10 20:50:56 +00:00
|
|
|
if (browser->trash && !midori_view_is_blank (MIDORI_VIEW (widget)))
|
2008-09-26 21:13:46 +00:00
|
|
|
katze_array_add_item (browser->trash, item);
|
|
|
|
katze_array_remove_item (browser->proxy_array, item);
|
|
|
|
g_object_unref (item);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_midori_browser_update_actions (browser);
|
2008-07-25 10:45:50 +00:00
|
|
|
|
|
|
|
/* This callback must only be called once, but we need to ensure
|
|
|
|
that "remove-tab" is emitted in any case */
|
|
|
|
g_signal_handlers_disconnect_by_func (widget,
|
|
|
|
midori_browser_tab_destroy_cb, browser);
|
|
|
|
|
|
|
|
g_signal_emit (browser, signals[REMOVE_TAB], 0, widget);
|
2008-10-03 23:45:17 +00:00
|
|
|
|
|
|
|
/* We don't ever want to be in a situation with no tabs,
|
2008-10-10 20:31:37 +00:00
|
|
|
so just create an empty one if the last one is closed.
|
|
|
|
The only exception is when we are closing the window,
|
|
|
|
which is indicated by the proxy array having been unset. */
|
|
|
|
if (browser->proxy_array && !midori_browser_get_current_tab (browser))
|
2008-10-03 23:45:17 +00:00
|
|
|
midori_browser_add_uri (browser, "");
|
2008-07-13 19:49:57 +00:00
|
|
|
return FALSE;
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2008-07-23 18:17:13 +00:00
|
|
|
static void
|
2008-06-15 02:02:56 +00:00
|
|
|
_midori_browser_add_tab (MidoriBrowser* browser,
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view)
|
2008-06-15 02:02:56 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* tab_label;
|
|
|
|
KatzeItem* item;
|
2008-06-15 02:02:56 +00:00
|
|
|
guint n;
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (view),
|
2008-06-15 02:02:56 +00:00
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
2008-09-26 21:13:46 +00:00
|
|
|
GTK_WIDGET_SET_FLAGS (view, GTK_CAN_FOCUS);
|
|
|
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (view),
|
2008-07-23 12:42:27 +00:00
|
|
|
GTK_SHADOW_ETCHED_IN);
|
2008-06-15 02:02:56 +00:00
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
tab_label = midori_view_get_proxy_tab_label (MIDORI_VIEW (view));
|
|
|
|
|
2008-10-10 20:31:37 +00:00
|
|
|
item = midori_view_get_proxy_item (MIDORI_VIEW (view));
|
|
|
|
g_object_ref (item);
|
|
|
|
katze_array_add_item (browser->proxy_array, item);
|
2008-09-26 21:13:46 +00:00
|
|
|
|
|
|
|
g_object_connect (view,
|
|
|
|
"signal::notify::icon",
|
|
|
|
midori_view_notify_icon_cb, browser,
|
|
|
|
"signal::notify::load-status",
|
|
|
|
midori_view_notify_load_status_cb, browser,
|
|
|
|
"signal::notify::progress",
|
|
|
|
midori_view_notify_progress_cb, browser,
|
|
|
|
/* "signal::news-feed-ready",
|
|
|
|
midori_view_news_feed_ready_cb, browser, */
|
|
|
|
"signal::notify::title",
|
|
|
|
midori_view_notify_title_cb, browser,
|
|
|
|
"signal::notify::zoom-level",
|
|
|
|
midori_view_notify_zoom_level_cb, browser,
|
|
|
|
"signal::notify::statusbar-text",
|
|
|
|
midori_view_notify_statusbar_text_cb, browser,
|
|
|
|
"signal::activate-action",
|
|
|
|
midori_view_activate_action_cb, browser,
|
|
|
|
"signal::console-message",
|
|
|
|
midori_view_console_message_cb, browser,
|
|
|
|
"signal::new-tab",
|
|
|
|
midori_view_new_tab_cb, browser,
|
|
|
|
"signal::new-window",
|
|
|
|
midori_view_new_window_cb, browser,
|
2008-09-28 14:29:41 +00:00
|
|
|
"signal::search-text",
|
|
|
|
midori_view_search_text_cb, browser,
|
2008-09-26 21:13:46 +00:00
|
|
|
"signal::add-bookmark",
|
|
|
|
midori_view_add_bookmark_cb, browser,
|
|
|
|
NULL);
|
2008-07-13 19:49:57 +00:00
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
g_signal_connect (view, "leave-notify-event",
|
2008-07-13 19:49:57 +00:00
|
|
|
G_CALLBACK (midori_browser_tab_leave_notify_event_cb), browser);
|
|
|
|
|
2008-08-15 18:38:27 +00:00
|
|
|
if (sokoke_object_get_boolean (browser->settings, "open-tabs-next-to-current"))
|
|
|
|
{
|
|
|
|
n = gtk_notebook_get_current_page (GTK_NOTEBOOK (browser->notebook));
|
2008-09-26 21:13:46 +00:00
|
|
|
gtk_notebook_insert_page (GTK_NOTEBOOK (browser->notebook), view,
|
|
|
|
tab_label, n + 1);
|
2008-08-15 18:38:27 +00:00
|
|
|
}
|
|
|
|
else
|
2008-09-26 21:13:46 +00:00
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (browser->notebook), view,
|
|
|
|
tab_label);
|
2008-08-15 18:38:27 +00:00
|
|
|
|
2008-06-15 02:02:56 +00:00
|
|
|
#if GTK_CHECK_VERSION(2, 10, 0)
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (browser->notebook),
|
2008-09-26 21:13:46 +00:00
|
|
|
view, TRUE);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (browser->notebook),
|
2008-09-26 21:13:46 +00:00
|
|
|
view, TRUE);
|
2008-06-15 02:02:56 +00:00
|
|
|
#endif
|
2008-07-13 19:49:57 +00:00
|
|
|
|
|
|
|
/* We want the tab to be removed if the widget is destroyed */
|
2008-09-26 21:13:46 +00:00
|
|
|
g_signal_connect (view, "destroy",
|
2008-07-13 19:49:57 +00:00
|
|
|
G_CALLBACK (midori_browser_tab_destroy_cb), browser);
|
|
|
|
|
2008-06-15 02:02:56 +00:00
|
|
|
_midori_browser_update_actions (browser);
|
|
|
|
}
|
|
|
|
|
2008-07-23 18:17:13 +00:00
|
|
|
static void
|
|
|
|
_midori_browser_remove_tab (MidoriBrowser* browser,
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view)
|
2008-06-15 02:02:56 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
gtk_widget_destroy (view);
|
2008-06-15 02:02:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_midori_browser_quit (MidoriBrowser* browser)
|
2008-06-07 23:25:57 +00:00
|
|
|
{
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Nothing to do */
|
2008-06-07 23:25:57 +00:00
|
|
|
}
|
|
|
|
|
2008-04-28 20:38:57 +00:00
|
|
|
static void
|
|
|
|
midori_cclosure_marshal_VOID__OBJECT_POINTER_POINTER (GClosure* closure,
|
|
|
|
GValue* return_value,
|
|
|
|
guint n_param_values,
|
|
|
|
const GValue* param_values,
|
|
|
|
gpointer invocation_hint,
|
|
|
|
gpointer marshal_data)
|
|
|
|
{
|
|
|
|
typedef gboolean(*GMarshalFunc_VOID__OBJECT_POINTER_POINTER) (gpointer data1,
|
|
|
|
gpointer arg_1,
|
|
|
|
gpointer arg_2,
|
|
|
|
gpointer arg_3,
|
|
|
|
gpointer data2);
|
|
|
|
register GMarshalFunc_VOID__OBJECT_POINTER_POINTER callback;
|
|
|
|
register GCClosure* cc = (GCClosure*) closure;
|
|
|
|
register gpointer data1, data2;
|
|
|
|
|
|
|
|
g_return_if_fail (n_param_values == 4);
|
|
|
|
|
|
|
|
if (G_CCLOSURE_SWAP_DATA (closure))
|
|
|
|
{
|
|
|
|
data1 = closure->data;
|
|
|
|
data2 = g_value_peek_pointer (param_values + 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
data1 = g_value_peek_pointer (param_values + 0);
|
|
|
|
data2 = closure->data;
|
|
|
|
}
|
|
|
|
callback = (GMarshalFunc_VOID__OBJECT_POINTER_POINTER) (marshal_data
|
|
|
|
? marshal_data : cc->callback);
|
|
|
|
|
|
|
|
callback (data1,
|
|
|
|
g_value_get_object (param_values + 1),
|
|
|
|
g_value_get_pointer (param_values + 2),
|
|
|
|
g_value_get_pointer (param_values + 3),
|
|
|
|
data2);
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
midori_browser_class_init (MidoriBrowserClass* class)
|
|
|
|
{
|
2008-04-28 20:38:57 +00:00
|
|
|
signals[WINDOW_OBJECT_CLEARED] = g_signal_new (
|
|
|
|
"window-object-cleared",
|
|
|
|
G_TYPE_FROM_CLASS (class),
|
2008-05-22 22:17:10 +00:00
|
|
|
(GSignalFlags)(G_SIGNAL_RUN_LAST),
|
2008-04-28 20:38:57 +00:00
|
|
|
G_STRUCT_OFFSET (MidoriBrowserClass, window_object_cleared),
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
midori_cclosure_marshal_VOID__OBJECT_POINTER_POINTER,
|
|
|
|
G_TYPE_NONE, 3,
|
|
|
|
WEBKIT_TYPE_WEB_FRAME,
|
|
|
|
G_TYPE_POINTER,
|
|
|
|
G_TYPE_POINTER);
|
|
|
|
|
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,
|
|
|
|
g_cclosure_marshal_VOID__STRING,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
G_TYPE_STRING);
|
|
|
|
|
|
|
|
signals[ADD_TAB] = g_signal_new (
|
|
|
|
"add-tab",
|
2008-03-24 13:15:23 +00:00
|
|
|
G_TYPE_FROM_CLASS (class),
|
2008-03-10 21:26:09 +00:00
|
|
|
(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
|
2008-05-31 22:21:08 +00:00
|
|
|
G_STRUCT_OFFSET (MidoriBrowserClass, add_tab),
|
2008-03-10 21:26:09 +00:00
|
|
|
0,
|
2008-05-31 22:21:08 +00:00
|
|
|
NULL,
|
2008-07-23 18:17:13 +00:00
|
|
|
g_cclosure_marshal_VOID__OBJECT,
|
|
|
|
G_TYPE_NONE, 1,
|
2008-05-31 22:21:08 +00:00
|
|
|
GTK_TYPE_WIDGET);
|
|
|
|
|
2008-07-23 18:17:13 +00:00
|
|
|
signals[REMOVE_TAB] = g_signal_new (
|
|
|
|
"remove-tab",
|
2008-05-31 22:21:08 +00:00
|
|
|
G_TYPE_FROM_CLASS (class),
|
|
|
|
(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
|
2008-07-23 18:17:13 +00:00
|
|
|
G_STRUCT_OFFSET (MidoriBrowserClass, remove_tab),
|
2008-03-10 21:26:09 +00:00
|
|
|
0,
|
|
|
|
NULL,
|
2008-07-23 18:17:13 +00:00
|
|
|
g_cclosure_marshal_VOID__OBJECT,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
GTK_TYPE_WIDGET);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-05-31 22:21:08 +00:00
|
|
|
signals[ACTIVATE_ACTION] = g_signal_new (
|
|
|
|
"activate-action",
|
2008-03-24 13:15:23 +00:00
|
|
|
G_TYPE_FROM_CLASS (class),
|
2008-05-31 22:21:08 +00:00
|
|
|
(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
|
|
|
|
G_STRUCT_OFFSET (MidoriBrowserClass, activate_action),
|
2008-03-10 21:26:09 +00:00
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
g_cclosure_marshal_VOID__STRING,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
G_TYPE_STRING);
|
|
|
|
|
2008-05-31 22:21:08 +00:00
|
|
|
signals[QUIT] = g_signal_new (
|
|
|
|
"quit",
|
|
|
|
G_TYPE_FROM_CLASS (class),
|
|
|
|
(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
|
|
|
|
G_STRUCT_OFFSET (MidoriBrowserClass, quit),
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
2008-06-15 02:02:56 +00:00
|
|
|
class->add_tab = _midori_browser_add_tab;
|
2008-07-23 18:17:13 +00:00
|
|
|
class->remove_tab = _midori_browser_remove_tab;
|
2008-06-15 02:02:56 +00:00
|
|
|
class->activate_action = _midori_browser_activate_action;
|
|
|
|
class->quit = _midori_browser_quit;
|
2008-05-31 22:21:08 +00:00
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
GObjectClass* 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;
|
|
|
|
|
|
|
|
GParamFlags flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT;
|
|
|
|
|
2008-05-02 20:30:26 +00:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_MENUBAR,
|
|
|
|
g_param_spec_object (
|
|
|
|
"menubar",
|
|
|
|
_("Menubar"),
|
|
|
|
_("The menubar"),
|
|
|
|
GTK_TYPE_MENU_BAR,
|
|
|
|
G_PARAM_READABLE));
|
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_NAVIGATIONBAR,
|
|
|
|
g_param_spec_object (
|
|
|
|
"navigationbar",
|
|
|
|
_("Navigationbar"),
|
|
|
|
_("The navigationbar"),
|
|
|
|
GTK_TYPE_TOOLBAR,
|
|
|
|
G_PARAM_READABLE));
|
|
|
|
|
2008-07-23 18:17:13 +00:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_URI,
|
|
|
|
g_param_spec_string (
|
|
|
|
"uri",
|
|
|
|
_("URI"),
|
|
|
|
_("The current URI"),
|
|
|
|
"about:blank",
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
2008-05-02 20:30:26 +00:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_TAB,
|
|
|
|
g_param_spec_object (
|
|
|
|
"tab",
|
|
|
|
_("Tab"),
|
|
|
|
_("The current tab"),
|
|
|
|
GTK_TYPE_WIDGET,
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_STATUSBAR,
|
|
|
|
g_param_spec_object (
|
|
|
|
"statusbar",
|
|
|
|
_("Statusbar"),
|
|
|
|
_("The statusbar"),
|
|
|
|
GTK_TYPE_STATUSBAR,
|
|
|
|
G_PARAM_READABLE));
|
|
|
|
|
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",
|
|
|
|
_("Statusbar Text"),
|
|
|
|
_("The text that is displayed in the statusbar"),
|
|
|
|
"",
|
|
|
|
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-05-02 20:30:26 +00:00
|
|
|
_("Settings"),
|
2008-03-22 02:38:23 +00:00
|
|
|
_("The associated settings"),
|
2008-03-10 21:26:09 +00:00
|
|
|
MIDORI_TYPE_WEB_SETTINGS,
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
|
|
/**
|
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",
|
|
|
|
_("Bookmarks"),
|
|
|
|
_("The bookmarks folder, containing all bookmarks"),
|
2008-10-01 02:00:16 +00:00
|
|
|
KATZE_TYPE_ARRAY,
|
2008-09-03 00:28:54 +00:00
|
|
|
G_PARAM_READWRITE));
|
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-05-02 20:30:26 +00:00
|
|
|
_("Trash"),
|
2008-03-22 02:38:23 +00:00
|
|
|
_("The trash, collecting recently closed tabs and windows"),
|
2008-08-25 23:19:38 +00:00
|
|
|
KATZE_TYPE_ARRAY,
|
2008-03-10 21:26:09 +00:00
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
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",
|
|
|
|
_("Search Engines"),
|
|
|
|
_("The list of search engines to be used for web search"),
|
2008-08-25 23:19:38 +00:00
|
|
|
KATZE_TYPE_ARRAY,
|
2008-06-15 02:02:56 +00:00
|
|
|
G_PARAM_READWRITE));
|
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",
|
|
|
|
_("History"),
|
|
|
|
_("The list of history items"),
|
|
|
|
KATZE_TYPE_ARRAY,
|
|
|
|
G_PARAM_READWRITE));
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_window_new_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-03-30 14:55:46 +00:00
|
|
|
g_signal_emit (browser, signals[NEW_WINDOW], 0, "");
|
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-08-14 23:57:48 +00:00
|
|
|
gtk_action_activate (_action_by_name (browser, "Location"));
|
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;
|
|
|
|
|
|
|
|
dialog = gtk_file_chooser_dialog_new (
|
2008-03-22 02:38:23 +00:00
|
|
|
("Open file"), GTK_WINDOW (browser),
|
2008-03-10 21:26:09 +00:00
|
|
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
|
|
|
|
NULL);
|
|
|
|
gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_OPEN);
|
2008-05-20 01:01:54 +00:00
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (browser));
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
/* base the start folder on the current view's uri if it is local */
|
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
|
|
|
if ((uri = (gchar*)midori_view_get_display_uri (MIDORI_VIEW (view))))
|
2008-05-20 01:01:54 +00:00
|
|
|
{
|
|
|
|
gchar* filename = g_filename_from_uri (uri, NULL, NULL);
|
|
|
|
if (filename)
|
|
|
|
{
|
|
|
|
gchar* dirname = g_path_get_dirname (filename);
|
|
|
|
if (dirname && g_file_test (dirname, G_FILE_TEST_IS_DIR))
|
|
|
|
{
|
|
|
|
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), dirname);
|
|
|
|
folder_set = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (dirname);
|
|
|
|
g_free (filename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!folder_set && last_dir && *last_dir)
|
|
|
|
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), last_dir);
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
|
|
|
|
{
|
2008-05-20 01:01:54 +00:00
|
|
|
uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
|
|
|
|
gchar* folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
|
2008-07-13 19:49:57 +00:00
|
|
|
_midori_browser_open_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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_tab_close_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-05-02 20:30:26 +00:00
|
|
|
GtkWidget* widget = midori_browser_get_current_tab (browser);
|
2008-07-13 19:49:57 +00:00
|
|
|
gtk_widget_destroy (widget);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_window_close_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
gtk_widget_destroy (GTK_WIDGET (browser));
|
|
|
|
}
|
|
|
|
|
2008-06-01 09:43:55 +00:00
|
|
|
static void
|
|
|
|
_action_print_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
|
|
|
if (view)
|
|
|
|
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));
|
|
|
|
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-09-26 21:13:46 +00:00
|
|
|
if (MIDORI_IS_VIEW (widget))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
MidoriView* view = MIDORI_VIEW (widget);
|
|
|
|
can_cut = midori_view_can_cut_clipboard (view);
|
|
|
|
can_copy = midori_view_can_copy_clipboard (view);
|
|
|
|
can_paste = midori_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
|
|
|
}
|
|
|
|
|
|
|
|
_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
|
|
|
}
|
|
|
|
|
|
|
|
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));
|
|
|
|
if (G_LIKELY (widget))
|
|
|
|
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));
|
|
|
|
if (G_LIKELY (widget))
|
|
|
|
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));
|
|
|
|
if (G_LIKELY (widget))
|
|
|
|
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);
|
|
|
|
else
|
2008-07-13 19:49:57 +00:00
|
|
|
g_signal_emit_by_name (widget, "select-all", TRUE);
|
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
|
|
|
{
|
2008-09-28 14:29:41 +00:00
|
|
|
GtkWidget* view;
|
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
if (GTK_WIDGET_VISIBLE (browser->find))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-09-28 14:29:41 +00:00
|
|
|
view = midori_browser_get_current_tab (browser);
|
|
|
|
midori_view_unmark_text_matches (MIDORI_VIEW (view));
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_toggle_tool_button_set_active (
|
2008-06-19 18:39:00 +00:00
|
|
|
GTK_TOGGLE_TOOL_BUTTON (browser->find_highlight), FALSE);
|
|
|
|
gtk_widget_hide (browser->find);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-07-17 19:02:14 +00:00
|
|
|
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (browser->find_text),
|
|
|
|
GTK_ICON_ENTRY_PRIMARY, GTK_STOCK_FIND);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (browser->find_text), "");
|
|
|
|
gtk_widget_show (browser->find);
|
|
|
|
gtk_widget_grab_focus (GTK_WIDGET (browser->find_text));
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_midori_browser_find (MidoriBrowser* browser,
|
|
|
|
gboolean forward)
|
|
|
|
{
|
2008-09-28 14:29:41 +00:00
|
|
|
const gchar* text;
|
|
|
|
gboolean case_sensitive;
|
|
|
|
GtkWidget* view;
|
|
|
|
|
|
|
|
text = gtk_entry_get_text (GTK_ENTRY (browser->find_text));
|
|
|
|
case_sensitive = gtk_toggle_tool_button_get_active (
|
2008-08-31 00:45:13 +00:00
|
|
|
GTK_TOGGLE_TOOL_BUTTON (browser->find_case));
|
2008-09-28 14:29:41 +00:00
|
|
|
view = midori_browser_get_current_tab (browser);
|
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
if (GTK_WIDGET_VISIBLE (browser->find))
|
2008-09-28 14:29:41 +00:00
|
|
|
midori_view_unmark_text_matches (MIDORI_VIEW (view));
|
|
|
|
midori_view_search_text (MIDORI_VIEW (view), text, case_sensitive, forward);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_find_next_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
_midori_browser_find (browser, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_find_previous_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
_midori_browser_find (browser, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_find_highlight_toggled (GtkToggleToolButton* toolitem,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-09-28 14:29:41 +00:00
|
|
|
GtkWidget* view;
|
|
|
|
gboolean highlight;
|
|
|
|
|
|
|
|
view = midori_browser_get_current_tab (browser);
|
|
|
|
highlight = gtk_toggle_tool_button_get_active (toolitem);
|
|
|
|
midori_view_set_highlight_text_matches (MIDORI_VIEW (view), highlight);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_find_button_close_clicked_cb (GtkWidget* widget,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_widget_hide (browser->find);
|
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;
|
|
|
|
GtkToolbarStyle gtk_toolbar_style;
|
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
g_object_get (browser->settings, "toolbar-style", &toolbar_style, NULL);
|
2008-04-16 23:38:22 +00:00
|
|
|
if (toolbar_style == MIDORI_TOOLBAR_DEFAULT)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-06-19 18:39:00 +00:00
|
|
|
g_object_get (browser->settings,
|
2008-04-16 23:38:22 +00:00
|
|
|
"gtk-toolbar-style", >k_toolbar_style, NULL);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_toolbar_set_style (GTK_TOOLBAR (browser->navigationbar),
|
2008-04-16 23:38:22 +00:00
|
|
|
gtk_toolbar_style);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-10-10 20:31:37 +00:00
|
|
|
_action_trash_populate_popup (GtkAction* action,
|
|
|
|
GtkMenu* menu,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-10-10 20:31:37 +00:00
|
|
|
GtkWidget* menuitem;
|
2008-09-26 21:13:46 +00:00
|
|
|
|
2008-10-10 20:31:37 +00:00
|
|
|
menuitem = gtk_separator_menu_item_new ();
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
menuitem = sokoke_action_create_popup_menu_item (
|
|
|
|
_action_by_name (browser, "TrashEmpty"));
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_trash_activate_item (GtkAction* action,
|
|
|
|
KatzeItem* item,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
gint 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-08-02 03:29:38 +00:00
|
|
|
_midori_browser_update_actions (browser);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-10-10 20:31:37 +00:00
|
|
|
_action_history_populate_popup (GtkAction* action,
|
|
|
|
GtkMenu* menu,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
/* Nothing to do */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_history_activate_item (GtkAction* action,
|
|
|
|
KatzeItem* item,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
_midori_browser_open_uri (browser, katze_item_get_uri (item));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_bookmarks_populate_popup (GtkAction* action,
|
|
|
|
GtkMenu* menu,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkWidget* menuitem = gtk_separator_menu_item_new ();
|
|
|
|
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
menuitem = sokoke_action_create_popup_menu_item (
|
|
|
|
_action_by_name (browser, "BookmarkAdd"));
|
|
|
|
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_bookmarks_activate_item (GtkAction* action,
|
|
|
|
KatzeItem* item,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
gint n = midori_browser_add_item (browser, item);
|
|
|
|
midori_browser_set_current_page (browser, n);
|
|
|
|
_midori_browser_update_actions (browser);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_window_populate_popup (GtkAction* action,
|
|
|
|
GtkMenu* menu,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkWidget* menuitem = gtk_separator_menu_item_new ();
|
|
|
|
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
menuitem = sokoke_action_create_popup_menu_item (
|
|
|
|
_action_by_name (browser, "TabPrevious"));
|
|
|
|
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
menuitem = sokoke_action_create_popup_menu_item (
|
|
|
|
_action_by_name (browser, "TabNext"));
|
|
|
|
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_window_activate_item (GtkAction* action,
|
|
|
|
KatzeItem* item,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-09-07 01:39:25 +00:00
|
|
|
guint i, n;
|
2008-10-10 20:31:37 +00:00
|
|
|
GtkWidget* view;
|
2008-09-07 01:39:25 +00:00
|
|
|
|
2008-10-10 20:31:37 +00:00
|
|
|
n = katze_array_get_length (browser->proxy_array);
|
2008-03-10 21:26:09 +00:00
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
2008-10-10 20:31:37 +00:00
|
|
|
view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), i);
|
|
|
|
if (midori_view_get_proxy_item (MIDORI_VIEW (view)) == item)
|
|
|
|
gtk_notebook_set_current_page (GTK_NOTEBOOK (browser->notebook), i);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-03 22:46:54 +00:00
|
|
|
static void
|
|
|
|
midori_preferences_response_help_cb (GtkWidget* preferences,
|
|
|
|
gint response,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
if (response == GTK_RESPONSE_HELP)
|
|
|
|
gtk_action_activate (_action_by_name (browser, "HelpContents"));
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
_action_preferences_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Show the preferences dialog. Create it if necessary. */
|
2008-03-10 21:26:09 +00:00
|
|
|
static GtkWidget* dialog = NULL;
|
|
|
|
if (GTK_IS_DIALOG (dialog))
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
|
|
|
else
|
|
|
|
{
|
2008-04-20 01:30:24 +00:00
|
|
|
dialog = midori_preferences_new (GTK_WINDOW (browser),
|
2008-06-19 18:39:00 +00:00
|
|
|
browser->settings);
|
2008-10-03 22:46:54 +00:00
|
|
|
g_signal_connect (dialog, "response",
|
|
|
|
G_CALLBACK (midori_preferences_response_help_cb), browser);
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_widget_show (dialog);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2008-06-19 18:39:00 +00:00
|
|
|
g_object_set (browser->settings, "show-navigationbar", active, NULL);
|
|
|
|
sokoke_widget_set_visible (browser->navigationbar, active);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_bookmarkbar_activate (GtkToggleAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-04-16 23:38:22 +00:00
|
|
|
gboolean active = gtk_toggle_action_get_active (action);
|
2008-06-19 18:39:00 +00:00
|
|
|
g_object_set (browser->settings, "show-bookmarkbar", active, NULL);
|
|
|
|
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);
|
2008-06-19 18:39:00 +00:00
|
|
|
g_object_set (browser->settings, "show-statusbar", active, NULL);
|
|
|
|
sokoke_widget_set_visible (browser->statusbar, active);
|
2008-08-31 00:45:13 +00:00
|
|
|
if (active)
|
|
|
|
g_object_set (_action_by_name (browser, "Location"),
|
|
|
|
"progress", 0.0, NULL);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_reload_stop_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
gchar* stock_id;
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view;
|
|
|
|
GdkModifierType state = (GdkModifierType)0;
|
|
|
|
gint x, y;
|
|
|
|
gboolean from_cache;
|
|
|
|
|
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
|
|
|
view = midori_browser_get_current_tab (browser);
|
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Refresh or stop, depending on the stock id */
|
2008-03-10 21:26:09 +00:00
|
|
|
if (!strcmp (stock_id, GTK_STOCK_REFRESH))
|
|
|
|
{
|
|
|
|
gdk_window_get_pointer (NULL, &x, &y, &state);
|
2008-09-26 21:13:46 +00:00
|
|
|
from_cache = state & GDK_SHIFT_MASK;
|
|
|
|
midori_view_reload (MIDORI_VIEW (view), !from_cache);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
else
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_view_stop_loading (MIDORI_VIEW (view));
|
2008-03-10 21:26:09 +00:00
|
|
|
g_free (stock_id);
|
|
|
|
}
|
|
|
|
|
2008-06-01 09:26:10 +00:00
|
|
|
static void
|
2008-03-10 21:26:09 +00:00
|
|
|
_action_zoom_in_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
|
|
|
if (view)
|
|
|
|
midori_view_set_zoom_level (MIDORI_VIEW (view),
|
|
|
|
midori_view_get_zoom_level (MIDORI_VIEW (view)) + 0.25f);
|
2008-06-01 09:26:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-03-10 21:26:09 +00:00
|
|
|
_action_zoom_out_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
|
|
|
if (view)
|
|
|
|
midori_view_set_zoom_level (MIDORI_VIEW (view),
|
|
|
|
midori_view_get_zoom_level (MIDORI_VIEW (view)) - 0.25f);
|
2008-06-01 09:26:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-03-10 21:26:09 +00:00
|
|
|
_action_zoom_normal_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
|
|
|
if (view)
|
|
|
|
midori_view_set_zoom_level (MIDORI_VIEW (view), 1.0f);
|
2008-06-01 09:26:10 +00:00
|
|
|
}
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-07-13 19:49:57 +00:00
|
|
|
static void
|
2008-03-10 21:26:09 +00:00
|
|
|
_action_source_view_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view;
|
|
|
|
GtkWidget* source_view;
|
|
|
|
gchar* uri;
|
2008-07-13 19:49:57 +00:00
|
|
|
gint n;
|
|
|
|
|
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;
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
uri = g_strdup_printf ("view-source:%s",
|
|
|
|
midori_view_get_display_uri (MIDORI_VIEW (view)));
|
|
|
|
source_view = midori_view_new_with_uri (uri);
|
|
|
|
g_free (uri);
|
|
|
|
gtk_widget_show (source_view);
|
|
|
|
n = midori_browser_add_tab (browser, source_view);
|
2008-07-13 19:49:57 +00:00
|
|
|
midori_browser_set_current_page (browser, n);
|
|
|
|
}
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
_action_fullscreen_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GdkWindowState state = gdk_window_get_state (GTK_WIDGET (browser)->window);
|
|
|
|
if (state & GDK_WINDOW_STATE_FULLSCREEN)
|
|
|
|
gtk_window_unfullscreen (GTK_WINDOW (browser));
|
|
|
|
else
|
|
|
|
gtk_window_fullscreen (GTK_WINDOW (browser));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_back_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
|
|
|
if (view)
|
|
|
|
midori_view_go_back (MIDORI_VIEW (view));
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_forward_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
|
|
|
if (view)
|
|
|
|
midori_view_go_forward (MIDORI_VIEW (view));
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-05-20 01:21:11 +00:00
|
|
|
_action_homepage_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-04-16 23:38:22 +00:00
|
|
|
gchar* homepage;
|
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
g_object_get (browser->settings, "homepage", &homepage, NULL);
|
2008-07-13 19:49:57 +00:00
|
|
|
_midori_browser_open_uri (browser, homepage);
|
2008-04-16 23:38:22 +00:00
|
|
|
g_free (homepage);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2008-07-17 19:02:14 +00:00
|
|
|
static void
|
2008-08-14 23:57:48 +00:00
|
|
|
_action_location_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
if (!GTK_WIDGET_VISIBLE (browser->navigationbar))
|
|
|
|
gtk_widget_show (browser->navigationbar);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_location_active_changed (GtkAction* action,
|
|
|
|
gint index,
|
|
|
|
MidoriBrowser* browser)
|
2008-07-17 19:02:14 +00:00
|
|
|
{
|
|
|
|
const gchar* uri;
|
|
|
|
|
|
|
|
if (index > -1)
|
|
|
|
{
|
2008-08-14 23:57:48 +00:00
|
|
|
uri = midori_location_action_get_uri (MIDORI_LOCATION_ACTION (action));
|
2008-07-17 19:02:14 +00:00
|
|
|
_midori_browser_open_uri (browser, uri);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2008-09-11 00:14:53 +00:00
|
|
|
if (GTK_WIDGET_VISIBLE (browser->statusbar) &&
|
|
|
|
!sokoke_object_get_boolean (browser->settings, "show-navigationbar"))
|
2008-08-14 23:57:48 +00:00
|
|
|
gtk_widget_hide (browser->navigationbar);
|
|
|
|
}
|
2008-04-20 19:44:56 +00:00
|
|
|
|
2008-08-14 23:57:48 +00:00
|
|
|
static void
|
|
|
|
_action_location_reset_uri (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
const gchar* uri;
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
uri = midori_browser_get_current_uri (browser);
|
2008-08-14 23:57:48 +00:00
|
|
|
midori_location_action_set_uri (MIDORI_LOCATION_ACTION (action), uri);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-08-14 23:57:48 +00:00
|
|
|
_action_location_submit_uri (GtkAction* action,
|
|
|
|
const gchar* uri,
|
2008-08-31 01:21:29 +00:00
|
|
|
gboolean new_tab,
|
2008-08-14 23:57:48 +00:00
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-08-14 23:57:48 +00:00
|
|
|
gchar* location_entry_search;
|
|
|
|
gchar* new_uri;
|
2008-08-31 01:21:29 +00:00
|
|
|
gint n;
|
2008-08-14 23:57:48 +00:00
|
|
|
|
|
|
|
g_object_get (browser->settings, "location-entry-search",
|
|
|
|
&location_entry_search, NULL);
|
|
|
|
new_uri = sokoke_magic_uri (uri, browser->search_engines);
|
|
|
|
if (!new_uri && strstr (location_entry_search, "%s"))
|
|
|
|
new_uri = g_strdup_printf (location_entry_search, uri);
|
|
|
|
else if (!new_uri)
|
|
|
|
new_uri = g_strdup (location_entry_search);
|
|
|
|
g_free (location_entry_search);
|
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
|
|
|
|
_midori_browser_open_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
|
|
|
}
|
|
|
|
|
2008-08-14 23:57:48 +00:00
|
|
|
static void
|
|
|
|
midori_browser_menu_feed_item_activate_cb (GtkWidget* widget,
|
|
|
|
MidoriBrowser* browser)
|
2008-04-22 21:36:37 +00:00
|
|
|
{
|
2008-08-14 23:57:48 +00:00
|
|
|
const gchar* uri;
|
|
|
|
|
|
|
|
uri = g_object_get_data (G_OBJECT (widget), "uri");
|
|
|
|
_midori_browser_open_uri (browser, uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_location_secondary_icon_released (GtkAction* action,
|
|
|
|
GtkWidget* widget,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
MidoriView* view;
|
2008-08-25 23:19:38 +00:00
|
|
|
KatzeArray* news_feeds;
|
2008-08-14 23:57:48 +00:00
|
|
|
GtkWidget* menu;
|
|
|
|
guint n, i;
|
|
|
|
GjsValue* feed;
|
|
|
|
const gchar* uri;
|
|
|
|
const gchar* title;
|
|
|
|
GtkWidget* menuitem;
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
view = (MidoriView*)midori_browser_get_current_tab (browser);
|
|
|
|
if (view)
|
2008-08-14 23:57:48 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
news_feeds = NULL /* midori_view_get_news_feeds (view) */;
|
2008-08-25 23:19:38 +00:00
|
|
|
n = news_feeds ? katze_array_get_length (news_feeds) : 0;
|
2008-08-14 23:57:48 +00:00
|
|
|
if (n)
|
|
|
|
{
|
|
|
|
menu = gtk_menu_new ();
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
2008-08-25 23:19:38 +00:00
|
|
|
if (!(feed = katze_array_get_nth_item (news_feeds, i)))
|
2008-08-14 23:57:48 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
uri = gjs_value_get_attribute_string (feed, "href");
|
|
|
|
if (gjs_value_has_attribute (feed, "title"))
|
|
|
|
title = gjs_value_get_attribute_string (feed, "title");
|
|
|
|
else
|
|
|
|
title = uri;
|
|
|
|
if (!*title)
|
|
|
|
title = uri;
|
2008-09-07 01:39:25 +00:00
|
|
|
menuitem = sokoke_image_menu_item_new_ellipsized (title);
|
2008-08-14 23:57:48 +00:00
|
|
|
/* FIXME: Get the real icon */
|
|
|
|
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (
|
2008-08-17 14:14:15 +00:00
|
|
|
menuitem), gtk_image_new_from_stock (STOCK_NEWS_FEED,
|
2008-08-14 23:57:48 +00:00
|
|
|
GTK_ICON_SIZE_MENU));
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
g_object_set_data (G_OBJECT (menuitem), "uri", (gchar*)uri);
|
|
|
|
g_signal_connect (menuitem, "activate",
|
|
|
|
G_CALLBACK (midori_browser_menu_feed_item_activate_cb),
|
|
|
|
browser);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
}
|
|
|
|
sokoke_widget_popup (widget, GTK_MENU (menu), NULL,
|
|
|
|
SOKOKE_MENU_POSITION_CURSOR);
|
|
|
|
}
|
|
|
|
}
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_search_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-06-19 18:39:00 +00:00
|
|
|
if (!GTK_WIDGET_VISIBLE (browser->navigationbar))
|
|
|
|
gtk_widget_show (browser->navigationbar);
|
2008-04-22 21:36:37 +00:00
|
|
|
}
|
|
|
|
|
2008-10-05 21:25:02 +00:00
|
|
|
static void
|
|
|
|
_action_search_submit (GtkAction* action,
|
|
|
|
const gchar* keywords,
|
|
|
|
gboolean new_tab,
|
|
|
|
MidoriBrowser* browser)
|
2008-04-22 21:36:37 +00:00
|
|
|
{
|
2008-10-05 21:25:02 +00:00
|
|
|
guint last_web_search;
|
|
|
|
KatzeItem* item;
|
|
|
|
const gchar* url;
|
|
|
|
gchar* location_entry_search;
|
|
|
|
gchar* search;
|
2008-10-01 02:00:16 +00:00
|
|
|
|
2008-10-05 21:25:02 +00:00
|
|
|
g_object_get (browser->settings, "last-web-search", &last_web_search, NULL);
|
|
|
|
item = katze_array_get_nth_item (browser->search_engines, last_web_search);
|
|
|
|
if (item)
|
|
|
|
{
|
|
|
|
location_entry_search = NULL;
|
|
|
|
url = katze_item_get_uri (item);
|
|
|
|
}
|
|
|
|
else /* The location entry search is our fallback */
|
|
|
|
{
|
|
|
|
g_object_get (browser->settings, "location-entry-search",
|
|
|
|
&location_entry_search, NULL);
|
|
|
|
url = location_entry_search;
|
|
|
|
}
|
|
|
|
if (strstr (url, "%s"))
|
|
|
|
search = g_strdup_printf (url, keywords);
|
|
|
|
else
|
|
|
|
search = g_strconcat (url, " ", keywords, NULL);
|
|
|
|
|
|
|
|
if (new_tab)
|
|
|
|
midori_browser_add_uri (browser, search);
|
|
|
|
else
|
|
|
|
_midori_browser_open_uri (browser, search);
|
|
|
|
|
|
|
|
g_free (search);
|
|
|
|
g_free (location_entry_search);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_search_notify_current_item (GtkAction* action,
|
|
|
|
GParamSpec* pspec,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
MidoriSearchAction* search_action;
|
|
|
|
KatzeItem* item;
|
|
|
|
guint index;
|
|
|
|
|
|
|
|
search_action = MIDORI_SEARCH_ACTION (action);
|
|
|
|
item = midori_search_action_get_current_item (search_action);
|
|
|
|
if (item)
|
|
|
|
index = katze_array_get_item_index (browser->search_engines, item);
|
|
|
|
else
|
|
|
|
index = 0;
|
|
|
|
|
|
|
|
g_object_set (browser->settings, "last-web-search", index, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_search_focus_out (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
if (GTK_WIDGET_VISIBLE (browser->statusbar) &&
|
|
|
|
!sokoke_object_get_boolean (browser->settings, "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
|
|
|
|
midori_panel_bookmarks_row_activated_cb (GtkTreeView* treeview,
|
|
|
|
GtkTreePath* path,
|
|
|
|
GtkTreeViewColumn* column,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
GtkTreeModel* model;
|
2008-03-10 21:26:09 +00:00
|
|
|
GtkTreeIter iter;
|
2008-10-01 02:00:16 +00:00
|
|
|
KatzeItem* item;
|
|
|
|
const gchar* uri;
|
|
|
|
|
|
|
|
model = gtk_tree_view_get_model (treeview);
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
if (gtk_tree_model_get_iter (model, &iter, path))
|
|
|
|
{
|
|
|
|
gtk_tree_model_get (model, &iter, 0, &item, -1);
|
2008-10-01 02:00:16 +00:00
|
|
|
uri = katze_item_get_uri (item);
|
|
|
|
if (uri && *uri)
|
2008-07-13 19:49:57 +00:00
|
|
|
_midori_browser_open_uri (browser, uri);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-08-29 01:20:31 +00:00
|
|
|
midori_panel_bookmarks_cursor_or_row_changed_cb (GtkTreeView* tree_view,
|
2008-03-10 21:26:09 +00:00
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-08-29 01:20:31 +00:00
|
|
|
GtkTreeModel* model;
|
|
|
|
GtkTreeIter iter;
|
2008-10-01 02:00:16 +00:00
|
|
|
KatzeItem* item;
|
2008-08-29 01:20:31 +00:00
|
|
|
gboolean is_separator;
|
|
|
|
|
|
|
|
if (sokoke_tree_view_get_selected_iter (tree_view, &model, &iter))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-08-29 01:20:31 +00:00
|
|
|
gtk_tree_model_get (model, &iter, 0, &item, -1);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-10-01 02:00:16 +00:00
|
|
|
is_separator = !KATZE_IS_ARRAY (item) && !katze_item_get_uri (item);
|
2008-08-29 01:20:31 +00:00
|
|
|
_action_set_sensitive (browser, "BookmarkEdit", !is_separator);
|
|
|
|
_action_set_sensitive (browser, "BookmarkDelete", TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_action_set_sensitive (browser, "BookmarkEdit", FALSE);
|
|
|
|
_action_set_sensitive (browser, "BookmarkDelete", FALSE);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_midori_panel_bookmarks_popup (GtkWidget* widget,
|
|
|
|
GdkEventButton* event,
|
2008-10-01 02:00:16 +00:00
|
|
|
KatzeItem* item,
|
2008-03-10 21:26:09 +00:00
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
const gchar* uri;
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-10-01 02:00:16 +00:00
|
|
|
uri = katze_item_get_uri (item);
|
|
|
|
|
|
|
|
_action_set_sensitive (browser, "BookmarkOpen", uri != NULL);
|
|
|
|
_action_set_sensitive (browser, "BookmarkOpenTab", uri != NULL);
|
|
|
|
_action_set_sensitive (browser, "BookmarkOpenWindow", uri != NULL);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
sokoke_widget_popup (widget, GTK_MENU (browser->popup_bookmark),
|
|
|
|
event, SOKOKE_MENU_POSITION_CURSOR);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
midori_panel_bookmarks_button_release_event_cb (GtkWidget* widget,
|
|
|
|
GdkEventButton* event,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-08-29 01:20:31 +00:00
|
|
|
GtkTreeModel* model;
|
|
|
|
GtkTreeIter iter;
|
2008-10-01 02:00:16 +00:00
|
|
|
KatzeItem* item;
|
|
|
|
const gchar* uri;
|
|
|
|
gint n;
|
2008-08-29 01:20:31 +00:00
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
if (event->button != 2 && event->button != 3)
|
|
|
|
return FALSE;
|
|
|
|
|
2008-08-29 01:20:31 +00:00
|
|
|
if (sokoke_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-08-29 01:20:31 +00:00
|
|
|
gtk_tree_model_get (model, &iter, 0, &item, -1);
|
2008-10-01 02:00:16 +00:00
|
|
|
uri = katze_item_get_uri (item);
|
|
|
|
if (event->button == 2)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
if (uri && *uri)
|
|
|
|
{
|
|
|
|
n = midori_browser_add_uri (browser, uri);
|
|
|
|
midori_browser_set_current_page (browser, n);
|
|
|
|
}
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
2008-08-29 01:20:31 +00:00
|
|
|
else
|
|
|
|
_midori_panel_bookmarks_popup (widget, event, item, browser);
|
|
|
|
return TRUE;
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_panel_bookmarks_popup_menu_cb (GtkWidget* widget,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-08-29 01:20:31 +00:00
|
|
|
GtkTreeModel* model;
|
|
|
|
GtkTreeIter iter;
|
2008-10-01 02:00:16 +00:00
|
|
|
KatzeItem* item;
|
2008-08-29 01:20:31 +00:00
|
|
|
|
|
|
|
if (sokoke_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-08-29 01:20:31 +00:00
|
|
|
gtk_tree_model_get (model, &iter, 0, &item, -1);
|
|
|
|
_midori_panel_bookmarks_popup (widget, NULL, item, browser);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-07 00:19:33 +00:00
|
|
|
static void
|
|
|
|
midori_panel_history_row_activated_cb (GtkTreeView* treeview,
|
|
|
|
GtkTreePath* path,
|
|
|
|
GtkTreeViewColumn* column,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
KatzeItem* item;
|
|
|
|
GtkTreeModel* model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
const gchar* uri;
|
|
|
|
|
|
|
|
model = gtk_tree_view_get_model (treeview);
|
|
|
|
if (gtk_tree_model_get_iter (model, &iter, path))
|
|
|
|
{
|
|
|
|
gtk_tree_model_get (model, &iter, 0, &item, -1);
|
|
|
|
if (KATZE_IS_ITEM (item))
|
|
|
|
{
|
|
|
|
uri = katze_item_get_uri (item);
|
|
|
|
_midori_browser_open_uri (browser, uri);
|
|
|
|
}
|
|
|
|
g_object_unref (item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_midori_panel_history_popup (GtkWidget* widget,
|
|
|
|
GdkEventButton* event,
|
|
|
|
KatzeItem* item,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
gboolean is_history_item = (KATZE_IS_ITEM (item) && !KATZE_IS_ARRAY (item));
|
|
|
|
|
|
|
|
_action_set_sensitive (browser, "HistoryOpen", is_history_item);
|
|
|
|
_action_set_sensitive (browser, "HistoryOpenTab", is_history_item);
|
|
|
|
|
|
|
|
sokoke_widget_popup (widget, GTK_MENU (browser->popup_history),
|
|
|
|
event, SOKOKE_MENU_POSITION_CURSOR);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
midori_panel_history_button_release_event_cb (GtkWidget* widget,
|
|
|
|
GdkEventButton* event,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkTreeModel* model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
KatzeItem* item;
|
|
|
|
const gchar* uri;
|
|
|
|
gint n;
|
|
|
|
|
|
|
|
if (event->button != 2 && event->button != 3)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (sokoke_tree_view_get_selected_iter (GTK_TREE_VIEW (widget),
|
|
|
|
&model, &iter))
|
|
|
|
{
|
|
|
|
gtk_tree_model_get (model, &iter, 0, &item, -1);
|
|
|
|
uri = katze_item_get_uri (item);
|
|
|
|
if (event->button == 2)
|
|
|
|
{
|
|
|
|
if (uri && *uri)
|
|
|
|
{
|
|
|
|
n = midori_browser_add_uri (browser, uri);
|
|
|
|
midori_browser_set_current_page (browser, n);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_midori_panel_history_popup (widget, event, item, browser);
|
|
|
|
|
|
|
|
g_object_unref (item);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_panel_history_popup_menu_cb (GtkWidget* widget,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkTreeModel* model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
KatzeItem* item;
|
|
|
|
|
|
|
|
if (sokoke_tree_view_get_selected_iter (GTK_TREE_VIEW (widget),
|
|
|
|
&model, &iter))
|
|
|
|
{
|
|
|
|
gtk_tree_model_get (model, &iter, 0, &item, -1);
|
|
|
|
_midori_panel_history_popup (widget, NULL, item, browser);
|
|
|
|
g_object_unref (item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
2008-10-01 02:00:16 +00:00
|
|
|
_tree_store_insert_folder (GtkTreeStore* treestore,
|
|
|
|
GtkTreeIter* parent,
|
|
|
|
KatzeArray* array)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
guint n, i;
|
|
|
|
KatzeItem* item;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
n = katze_array_get_length (array);
|
2008-03-10 21:26:09 +00:00
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
item = katze_array_get_nth_item (array, i);
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_tree_store_insert_with_values (treestore, &iter, parent, n,
|
|
|
|
0, item, -1);
|
2008-10-01 02:00:16 +00:00
|
|
|
g_object_ref (item);
|
|
|
|
if (KATZE_IS_ARRAY (item))
|
|
|
|
_tree_store_insert_folder (treestore, &iter, KATZE_ARRAY (item));
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_bookmarks_item_render_icon_cb (GtkTreeViewColumn* column,
|
|
|
|
GtkCellRenderer* renderer,
|
|
|
|
GtkTreeModel* model,
|
|
|
|
GtkTreeIter* iter,
|
|
|
|
GtkWidget* treeview)
|
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
KatzeItem* item;
|
|
|
|
GdkPixbuf* pixbuf;
|
2008-07-14 19:14:57 +00:00
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_tree_model_get (model, iter, 0, &item, -1);
|
|
|
|
|
|
|
|
if (G_UNLIKELY (!item))
|
|
|
|
return;
|
2008-10-01 02:00:16 +00:00
|
|
|
if (G_UNLIKELY (!katze_item_get_parent (item)))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
|
|
|
gtk_tree_store_remove (GTK_TREE_STORE (model), iter);
|
2008-10-01 02:00:16 +00:00
|
|
|
g_object_unref (item);
|
2008-03-10 21:26:09 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* TODO: Would it be better to not do this on every redraw? */
|
2008-10-01 02:00:16 +00:00
|
|
|
pixbuf = NULL;
|
|
|
|
if (KATZE_IS_ARRAY (item))
|
2008-03-10 21:26:09 +00:00
|
|
|
pixbuf = gtk_widget_render_icon (treeview, GTK_STOCK_DIRECTORY,
|
|
|
|
GTK_ICON_SIZE_MENU, NULL);
|
2008-10-01 02:00:16 +00:00
|
|
|
else if (katze_item_get_uri (item))
|
|
|
|
pixbuf = gtk_widget_render_icon (treeview, STOCK_BOOKMARK,
|
|
|
|
GTK_ICON_SIZE_MENU, NULL);
|
2008-03-10 21:26:09 +00:00
|
|
|
g_object_set (renderer, "pixbuf", pixbuf, NULL);
|
|
|
|
if (pixbuf)
|
|
|
|
g_object_unref (pixbuf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_bookmarks_item_render_text_cb (GtkTreeViewColumn* column,
|
|
|
|
GtkCellRenderer* renderer,
|
|
|
|
GtkTreeModel* model,
|
|
|
|
GtkTreeIter* iter,
|
|
|
|
GtkWidget* treeview)
|
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
KatzeItem* item;
|
2008-07-14 19:14:57 +00:00
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_tree_model_get (model, iter, 0, &item, -1);
|
|
|
|
|
|
|
|
if (G_UNLIKELY (!item))
|
|
|
|
return;
|
2008-10-01 02:00:16 +00:00
|
|
|
if (G_UNLIKELY (!katze_item_get_parent (item)))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
|
|
|
gtk_tree_store_remove (GTK_TREE_STORE (model), iter);
|
2008-10-01 02:00:16 +00:00
|
|
|
g_object_unref (item);
|
2008-03-10 21:26:09 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-10-01 02:00:16 +00:00
|
|
|
if (KATZE_IS_ARRAY (item) || katze_item_get_uri (item))
|
2008-03-10 21:26:09 +00:00
|
|
|
g_object_set (renderer, "markup", NULL,
|
2008-10-01 02:00:16 +00:00
|
|
|
"text", katze_item_get_name (item), NULL);
|
|
|
|
else
|
|
|
|
g_object_set (renderer, "markup", _("<i>Separator</i>"), NULL);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_midori_browser_create_bookmark_menu (MidoriBrowser* browser,
|
2008-10-01 02:00:16 +00:00
|
|
|
KatzeArray* array,
|
2008-03-10 21:26:09 +00:00
|
|
|
GtkWidget* menu);
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_bookmark_menu_folder_activate_cb (GtkWidget* menuitem,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
GtkWidget* menu;
|
|
|
|
KatzeArray* array;
|
|
|
|
|
|
|
|
menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menuitem));
|
2008-06-14 00:23:33 +00:00
|
|
|
gtk_container_foreach (GTK_CONTAINER (menu), (GtkCallback) gtk_widget_destroy, NULL);
|
2008-10-01 02:00:16 +00:00
|
|
|
array = (KatzeArray*)g_object_get_data (G_OBJECT (menuitem), "KatzeArray");
|
|
|
|
_midori_browser_create_bookmark_menu (browser, array, menu);
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Remove all menuitems when the menu is hidden.
|
|
|
|
FIXME: We really *want* the line below, but it won't work like that
|
|
|
|
g_signal_connect_after (menu, "hide", G_CALLBACK (gtk_container_foreach), gtk_widget_destroy); */
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_bookmarkbar_folder_activate_cb (GtkToolItem* toolitem,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
GtkWidget* menu;
|
|
|
|
KatzeArray* array;
|
|
|
|
|
|
|
|
menu = gtk_menu_new ();
|
|
|
|
array = (KatzeArray*)g_object_get_data (G_OBJECT (toolitem), "KatzeArray");
|
|
|
|
_midori_browser_create_bookmark_menu (browser, array, menu);
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Remove all menuitems when the menu is hidden.
|
|
|
|
FIXME: We really *should* run the line below, but it won't work like that
|
|
|
|
g_signal_connect (menu, "hide", G_CALLBACK (gtk_container_foreach),
|
|
|
|
gtk_widget_destroy); */
|
2008-03-29 21:38:59 +00:00
|
|
|
sokoke_widget_popup (GTK_WIDGET (toolitem), GTK_MENU (menu),
|
|
|
|
NULL, SOKOKE_MENU_POSITION_LEFT);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_menu_bookmarks_item_activate_cb (GtkWidget* widget,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
KatzeItem* item;
|
|
|
|
|
|
|
|
item = (KatzeItem*)g_object_get_data (G_OBJECT (widget), "KatzeItem");
|
|
|
|
_midori_browser_open_uri (browser, katze_item_get_uri (item));
|
2008-07-13 19:49:57 +00:00
|
|
|
gtk_widget_grab_focus (midori_browser_get_current_tab (browser));
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_midori_browser_create_bookmark_menu (MidoriBrowser* browser,
|
2008-10-01 02:00:16 +00:00
|
|
|
KatzeArray* array,
|
2008-03-10 21:26:09 +00:00
|
|
|
GtkWidget* menu)
|
|
|
|
{
|
2008-09-07 01:39:25 +00:00
|
|
|
guint i, n;
|
2008-10-01 02:00:16 +00:00
|
|
|
KatzeItem* item;
|
2008-09-07 01:39:25 +00:00
|
|
|
const gchar* title;
|
|
|
|
GtkWidget* menuitem;
|
|
|
|
GtkWidget* submenu;
|
|
|
|
GtkWidget* icon;
|
|
|
|
|
2008-10-01 02:00:16 +00:00
|
|
|
n = katze_array_get_length (array);
|
2008-03-10 21:26:09 +00:00
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
item = katze_array_get_nth_item (array, i);
|
|
|
|
title = katze_item_get_name (item);
|
2008-09-07 01:39:25 +00:00
|
|
|
|
2008-10-01 02:00:16 +00:00
|
|
|
if (KATZE_IS_ARRAY (item))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
/* FIXME: what about the "folded" status */
|
2008-09-07 01:39:25 +00:00
|
|
|
menuitem = sokoke_image_menu_item_new_ellipsized (title);
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem),
|
|
|
|
gtk_image_new_from_stock (GTK_STOCK_DIRECTORY,
|
|
|
|
GTK_ICON_SIZE_MENU));
|
2008-09-07 01:39:25 +00:00
|
|
|
submenu = gtk_menu_new ();
|
|
|
|
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu);
|
2008-03-10 21:26:09 +00:00
|
|
|
g_signal_connect (menuitem, "activate",
|
|
|
|
G_CALLBACK (midori_browser_bookmark_menu_folder_activate_cb),
|
|
|
|
browser);
|
2008-10-01 02:00:16 +00:00
|
|
|
g_object_set_data (G_OBJECT (menuitem), "KatzeArray", item);
|
|
|
|
}
|
|
|
|
else if (katze_item_get_uri (item))
|
|
|
|
{
|
2008-09-07 01:39:25 +00:00
|
|
|
menuitem = sokoke_image_menu_item_new_ellipsized (title);
|
|
|
|
icon = gtk_image_new_from_stock (STOCK_BOOKMARK, GTK_ICON_SIZE_MENU);
|
|
|
|
gtk_widget_show (icon);
|
|
|
|
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), icon);
|
2008-03-10 21:26:09 +00:00
|
|
|
g_signal_connect (menuitem, "activate",
|
|
|
|
G_CALLBACK (midori_browser_menu_bookmarks_item_activate_cb),
|
|
|
|
browser);
|
2008-10-01 02:00:16 +00:00
|
|
|
g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item);
|
|
|
|
}
|
|
|
|
else
|
2008-03-10 21:26:09 +00:00
|
|
|
menuitem = gtk_separator_menu_item_new ();
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
midori_browser_edit_bookmark_dialog_new (browser, NULL);
|
|
|
|
}
|
|
|
|
|
2008-10-07 00:19:33 +00:00
|
|
|
static void
|
|
|
|
midori_browser_history_render_icon_cb (GtkTreeViewColumn* column,
|
|
|
|
GtkCellRenderer* renderer,
|
|
|
|
GtkTreeModel* model,
|
|
|
|
GtkTreeIter* iter,
|
|
|
|
GtkWidget* treeview)
|
|
|
|
{
|
|
|
|
KatzeItem* item;
|
|
|
|
GdkPixbuf* pixbuf = NULL;
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, iter, 0, &item, -1);
|
|
|
|
|
|
|
|
if (G_UNLIKELY (!item))
|
|
|
|
return;
|
|
|
|
if (G_UNLIKELY (!katze_item_get_parent (item)))
|
|
|
|
{
|
|
|
|
gtk_tree_store_remove (GTK_TREE_STORE (model), iter);
|
|
|
|
g_object_unref (item);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (KATZE_IS_ARRAY (item))
|
|
|
|
pixbuf = gtk_widget_render_icon (treeview, GTK_STOCK_DIRECTORY,
|
|
|
|
GTK_ICON_SIZE_MENU, NULL);
|
|
|
|
else
|
|
|
|
pixbuf = gtk_widget_render_icon (treeview, GTK_STOCK_FILE,
|
|
|
|
GTK_ICON_SIZE_MENU, NULL);
|
|
|
|
|
|
|
|
g_object_set (renderer, "pixbuf", pixbuf, NULL);
|
|
|
|
|
|
|
|
if (pixbuf)
|
|
|
|
g_object_unref (pixbuf);
|
|
|
|
|
|
|
|
g_object_unref (item);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_history_render_text_cb (GtkTreeViewColumn* column,
|
|
|
|
GtkCellRenderer* renderer,
|
|
|
|
GtkTreeModel* model,
|
|
|
|
GtkTreeIter* iter,
|
|
|
|
GtkWidget* treeview)
|
|
|
|
{
|
|
|
|
KatzeItem* item;
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, iter, 0, &item, -1);
|
|
|
|
|
|
|
|
if (G_UNLIKELY (!item))
|
|
|
|
return;
|
|
|
|
if (G_UNLIKELY (!katze_item_get_parent (item)))
|
|
|
|
{
|
|
|
|
gtk_tree_store_remove (GTK_TREE_STORE (model), iter);
|
|
|
|
g_object_unref (item);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (KATZE_IS_ARRAY (item))
|
|
|
|
g_object_set (renderer, "text", katze_item_get_added (item), NULL);
|
|
|
|
else
|
|
|
|
g_object_set (renderer, "text", katze_item_get_name (item), NULL);
|
|
|
|
|
|
|
|
g_object_unref (item);
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
_action_manage_search_engines_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-06-21 21:57:20 +00:00
|
|
|
GtkWidget* dialog;
|
2008-06-15 02:02:56 +00:00
|
|
|
|
2008-10-05 21:25:02 +00:00
|
|
|
dialog = midori_search_action_get_dialog (
|
|
|
|
MIDORI_SEARCH_ACTION (_action_by_name (browser, "Search")));
|
2008-06-21 21:57:20 +00:00
|
|
|
if (GTK_WIDGET_VISIBLE (dialog))
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
|
|
|
else
|
|
|
|
gtk_widget_show (dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_tab_previous_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-06-19 18:39:00 +00:00
|
|
|
gint n = gtk_notebook_get_current_page (GTK_NOTEBOOK (browser->notebook));
|
|
|
|
gtk_notebook_set_current_page (GTK_NOTEBOOK (browser->notebook), n - 1);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_tab_next_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Advance one tab or jump to the first one if we are at the last one */
|
2008-06-19 18:39:00 +00:00
|
|
|
gint n = gtk_notebook_get_current_page (GTK_NOTEBOOK (browser->notebook));
|
|
|
|
if (n == gtk_notebook_get_n_pages (GTK_NOTEBOOK (browser->notebook)) - 1)
|
2008-03-10 21:26:09 +00:00
|
|
|
n = -1;
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_notebook_set_current_page (GTK_NOTEBOOK (browser->notebook), n + 1);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const gchar* credits_authors[] = {
|
|
|
|
"Christian Dywan <christian@twotoasts.de>", NULL };
|
2008-10-03 20:23:00 +00:00
|
|
|
static const gchar* credits_documenters[] = {
|
|
|
|
"Christian Dywan <christian@twotoasts.de>" };
|
2008-03-10 21:26:09 +00:00
|
|
|
static const gchar* credits_artists[] = {
|
|
|
|
"Nancy Runge <nancy@twotoasts.de>", NULL };
|
|
|
|
|
|
|
|
static const gchar* license =
|
|
|
|
"This library is free software; you can redistribute it and/or\n"
|
|
|
|
"modify it under the terms of the GNU Lesser General Public\n"
|
|
|
|
"License as published by the Free Software Foundation; either\n"
|
|
|
|
"version 2.1 of the License, or (at your option) any later version.\n";
|
|
|
|
|
2008-10-03 20:23:00 +00:00
|
|
|
static void
|
|
|
|
_action_about_activate_link (GtkAboutDialog* about,
|
|
|
|
const gchar* link,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
MidoriBrowser* browser;
|
|
|
|
gint n;
|
|
|
|
|
|
|
|
browser = MIDORI_BROWSER (user_data);
|
|
|
|
n = midori_browser_add_uri (browser, link);
|
|
|
|
midori_browser_set_current_page (browser, n);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_about_activate_email (GtkAboutDialog* about,
|
|
|
|
const gchar* link,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
gchar* command = g_strconcat ("xdg-open ", link, NULL);
|
|
|
|
g_spawn_command_line_async (command, NULL);
|
|
|
|
g_free (command);
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
_action_about_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-10-03 20:23:00 +00:00
|
|
|
gtk_about_dialog_set_email_hook (_action_about_activate_email, NULL, NULL);
|
|
|
|
gtk_about_dialog_set_url_hook (_action_about_activate_link, browser, NULL);
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_show_about_dialog (GTK_WINDOW (browser),
|
|
|
|
"logo-icon-name", gtk_window_get_icon_name (GTK_WINDOW (browser)),
|
|
|
|
"name", PACKAGE_NAME,
|
|
|
|
"version", PACKAGE_VERSION,
|
2008-03-22 02:38:23 +00:00
|
|
|
"comments", _("A lightweight web browser."),
|
2008-03-10 21:26:09 +00:00
|
|
|
"copyright", "Copyright © 2007-2008 Christian Dywan",
|
2008-08-02 02:25:05 +00:00
|
|
|
"website", "http://www.twotoasts.de",
|
2008-03-10 21:26:09 +00:00
|
|
|
"authors", credits_authors,
|
|
|
|
"documenters", credits_documenters,
|
|
|
|
"artists", credits_artists,
|
|
|
|
"license", license,
|
|
|
|
"wrap-license", TRUE,
|
2008-03-22 02:38:23 +00:00
|
|
|
"translator-credits", _("translator-credits"),
|
2008-03-10 21:26:09 +00:00
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2008-09-07 20:41:03 +00:00
|
|
|
static void
|
2008-10-03 20:23:00 +00:00
|
|
|
_action_help_link_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
2008-09-07 20:41:03 +00:00
|
|
|
{
|
2008-10-03 20:23:00 +00:00
|
|
|
const gchar* action_name;
|
|
|
|
const gchar* uri;
|
2008-09-07 20:41:03 +00:00
|
|
|
gint n;
|
|
|
|
|
2008-10-03 20:23:00 +00:00
|
|
|
action_name = gtk_action_get_name (action);
|
|
|
|
if (!strncmp ("HelpContents", action_name, 12))
|
|
|
|
{
|
|
|
|
#ifdef DOCDIR
|
|
|
|
uri = DOCDIR "/midori/user/midori.html";
|
|
|
|
if (!g_file_test (uri, G_FILE_TEST_EXISTS))
|
|
|
|
uri = "error:nodocs " DOCDIR "/midori/user/midori.html";
|
|
|
|
#else
|
|
|
|
uri = "error:nodocs " DATADIR "/doc/midori/user/midori.html";
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else if (!strncmp ("HelpFAQ", action_name, 7))
|
|
|
|
uri = "http://wiki.xfce.org/_export/xhtml/midori_faq";
|
|
|
|
else if (!strncmp ("HelpBugs", action_name, 8))
|
|
|
|
uri = "http://www.twotoasts.de/bugs/";
|
|
|
|
else
|
|
|
|
uri = NULL;
|
|
|
|
|
|
|
|
if (uri)
|
|
|
|
{
|
|
|
|
n = midori_browser_add_uri (browser, uri);
|
|
|
|
midori_browser_set_current_page (browser, n);
|
|
|
|
}
|
|
|
|
|
2008-09-07 20:41:03 +00:00
|
|
|
}
|
|
|
|
|
2008-10-03 20:23:00 +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);
|
2008-06-19 18:39:00 +00:00
|
|
|
g_object_set (browser->settings, "show-panel", active, NULL);
|
|
|
|
sokoke_widget_set_visible (browser->panel, active);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_open_in_panel_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view;
|
|
|
|
const gchar* uri;
|
|
|
|
gint n;
|
|
|
|
|
|
|
|
view = midori_browser_get_current_tab (browser);
|
|
|
|
uri = midori_view_get_display_uri (MIDORI_VIEW (view));
|
2008-06-14 00:23:33 +00:00
|
|
|
/* FIXME: Don't assign the uri here, update it properly while navigating */
|
2008-06-19 18:39:00 +00:00
|
|
|
g_object_set (browser->settings, "last-pageholder-uri", uri, NULL);
|
2008-09-26 21:13:46 +00:00
|
|
|
n = midori_panel_page_num (MIDORI_PANEL (browser->panel),
|
|
|
|
browser->panel_pageholder);
|
2008-06-19 18:39:00 +00:00
|
|
|
midori_panel_set_current_page (MIDORI_PANEL (browser->panel), n);
|
|
|
|
gtk_widget_show (browser->panel);
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_view_set_uri (MIDORI_VIEW (browser->panel_pageholder), uri);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_panel_notify_position_cb (GObject* object,
|
|
|
|
GParamSpec* arg1,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-04-16 23:38:22 +00:00
|
|
|
gboolean position = gtk_paned_get_position (GTK_PANED (object));
|
2008-06-19 18:39:00 +00:00
|
|
|
g_object_set (browser->settings, "last-panel-position", position, NULL);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
midori_panel_close_cb (MidoriPanel* panel,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-04-06 23:15:09 +00:00
|
|
|
_action_set_active (browser, "Panel", FALSE);
|
2008-03-10 21:26:09 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-07-13 19:49:57 +00:00
|
|
|
gtk_notebook_switch_page_cb (GtkWidget* notebook,
|
2008-03-10 21:26:09 +00:00
|
|
|
GtkNotebookPage* page,
|
|
|
|
guint page_num,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view;
|
2008-07-13 19:49:57 +00:00
|
|
|
const gchar* uri;
|
2008-08-14 23:57:48 +00:00
|
|
|
GtkAction* action;
|
2008-07-13 19:49:57 +00:00
|
|
|
const gchar* title;
|
|
|
|
gchar* window_title;
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
view = midori_browser_get_current_tab (browser);
|
|
|
|
uri = midori_view_get_display_uri (MIDORI_VIEW (view));
|
2008-08-14 23:57:48 +00:00
|
|
|
action = _action_by_name (browser, "Location");
|
|
|
|
midori_location_action_set_uri (MIDORI_LOCATION_ACTION (action), uri);
|
2008-07-17 19:02:14 +00:00
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
title = midori_view_get_display_title (MIDORI_VIEW (view));
|
2008-07-13 19:49:57 +00:00
|
|
|
window_title = g_strconcat (title, " - ",
|
|
|
|
g_get_application_name (), NULL);
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_window_set_title (GTK_WINDOW (browser), window_title);
|
|
|
|
g_free (window_title);
|
2008-07-23 18:17:13 +00:00
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (browser), "uri");
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
_midori_browser_set_statusbar_text (browser, NULL);
|
|
|
|
_midori_browser_update_interface (browser);
|
2008-09-26 21:13:46 +00:00
|
|
|
_midori_browser_update_progress (browser, MIDORI_VIEW (view));
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_bookmark_open_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-08-29 01:20:31 +00:00
|
|
|
GtkTreeView* tree_view;
|
|
|
|
GtkTreeModel* model;
|
|
|
|
GtkTreeIter iter;
|
2008-10-01 02:00:16 +00:00
|
|
|
KatzeItem* item;
|
|
|
|
const gchar* uri;
|
2008-08-29 01:20:31 +00:00
|
|
|
|
|
|
|
tree_view = GTK_TREE_VIEW (browser->panel_bookmarks);
|
|
|
|
if (sokoke_tree_view_get_selected_iter (tree_view, &model, &iter))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-08-29 01:20:31 +00:00
|
|
|
gtk_tree_model_get (model, &iter, 0, &item, -1);
|
2008-10-01 02:00:16 +00:00
|
|
|
uri = katze_item_get_uri (item);
|
|
|
|
if (uri && *uri)
|
|
|
|
_midori_browser_open_uri (browser, uri);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_bookmark_open_tab_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-08-29 01:20:31 +00:00
|
|
|
GtkTreeView* tree_view;
|
|
|
|
GtkTreeModel* model;
|
|
|
|
GtkTreeIter iter;
|
2008-10-01 02:00:16 +00:00
|
|
|
KatzeItem* item;
|
|
|
|
const gchar* uri;
|
2008-08-29 01:20:31 +00:00
|
|
|
gint n;
|
|
|
|
|
|
|
|
tree_view = GTK_TREE_VIEW (browser->panel_bookmarks);
|
|
|
|
if (sokoke_tree_view_get_selected_iter (tree_view, &model, &iter))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-08-29 01:20:31 +00:00
|
|
|
gtk_tree_model_get (model, &iter, 0, &item, -1);
|
2008-10-01 02:00:16 +00:00
|
|
|
uri = katze_item_get_uri (item);
|
|
|
|
if (uri && *uri)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
n = midori_browser_add_item (browser, item);
|
2008-08-29 01:20:31 +00:00
|
|
|
_midori_browser_set_current_page_smartly (browser, n);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_bookmark_open_window_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-08-29 01:20:31 +00:00
|
|
|
GtkTreeView* tree_view;
|
|
|
|
GtkTreeModel* model;
|
|
|
|
GtkTreeIter iter;
|
2008-10-01 02:00:16 +00:00
|
|
|
KatzeItem* item;
|
|
|
|
const gchar* uri;
|
2008-08-29 01:20:31 +00:00
|
|
|
gint n;
|
|
|
|
|
|
|
|
tree_view = GTK_TREE_VIEW (browser->panel_bookmarks);
|
|
|
|
if (sokoke_tree_view_get_selected_iter (tree_view, &model, &iter))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-08-29 01:20:31 +00:00
|
|
|
gtk_tree_model_get (model, &iter, 0, &item, -1);
|
2008-10-01 02:00:16 +00:00
|
|
|
uri = katze_item_get_uri (item);
|
|
|
|
if (uri && *uri)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
n = midori_browser_add_item (browser, item);
|
2008-08-29 01:20:31 +00:00
|
|
|
_midori_browser_set_current_page_smartly (browser, n);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_bookmark_edit_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
2008-08-29 01:20:31 +00:00
|
|
|
GtkTreeView* tree_view;
|
|
|
|
GtkTreeModel* model;
|
|
|
|
GtkTreeIter iter;
|
2008-10-01 02:00:16 +00:00
|
|
|
KatzeItem* item;
|
2008-08-29 01:20:31 +00:00
|
|
|
|
|
|
|
tree_view = GTK_TREE_VIEW (browser->panel_bookmarks);
|
|
|
|
if (sokoke_tree_view_get_selected_iter (tree_view, &model, &iter))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-08-29 01:20:31 +00:00
|
|
|
gtk_tree_model_get (model, &iter, 0, &item, -1);
|
2008-10-01 02:00:16 +00:00
|
|
|
/* if (katze_item_get_uri (item)) */
|
2008-08-29 01:20:31 +00:00
|
|
|
midori_browser_edit_bookmark_dialog_new (browser, item);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-07 00:19:33 +00:00
|
|
|
static void
|
|
|
|
_action_history_open_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkTreeView* tree_view;
|
|
|
|
GtkTreeModel* model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
KatzeItem* item;
|
|
|
|
const gchar* uri;
|
|
|
|
|
|
|
|
tree_view = GTK_TREE_VIEW (browser->panel_history);
|
|
|
|
if (sokoke_tree_view_get_selected_iter (tree_view, &model, &iter))
|
|
|
|
{
|
|
|
|
gtk_tree_model_get (model, &iter, 0, &item, -1);
|
|
|
|
uri = katze_item_get_uri (item);
|
|
|
|
if (uri && *uri)
|
|
|
|
_midori_browser_open_uri (browser, uri);
|
|
|
|
g_object_unref (item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_history_open_tab_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkTreeView* tree_view;
|
|
|
|
GtkTreeModel* model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
KatzeItem* item;
|
|
|
|
const gchar* uri;
|
|
|
|
gint n;
|
|
|
|
|
|
|
|
tree_view = GTK_TREE_VIEW (browser->panel_history);
|
|
|
|
if (sokoke_tree_view_get_selected_iter (tree_view, &model, &iter))
|
|
|
|
{
|
|
|
|
gtk_tree_model_get (model, &iter, 0, &item, -1);
|
|
|
|
uri = katze_item_get_uri (item);
|
|
|
|
if (uri && *uri)
|
|
|
|
{
|
|
|
|
n = midori_browser_add_item (browser, item);
|
|
|
|
_midori_browser_set_current_page_smartly (browser, n);
|
|
|
|
}
|
|
|
|
g_object_unref (item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_history_delete_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkTreeView* treeview;
|
|
|
|
GtkTreeModel* treemodel;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter childiter;
|
|
|
|
KatzeItem* item;
|
|
|
|
KatzeItem* child;
|
|
|
|
KatzeArray* parent;
|
|
|
|
gint i, n;
|
|
|
|
|
|
|
|
treeview = GTK_TREE_VIEW (browser->panel_history);
|
|
|
|
if (sokoke_tree_view_get_selected_iter (treeview, &treemodel, &iter))
|
|
|
|
{
|
|
|
|
gtk_tree_model_get (treemodel, &iter, 0, &item, -1);
|
|
|
|
|
|
|
|
if (KATZE_IS_ARRAY (item))
|
|
|
|
{
|
|
|
|
n = katze_array_get_length (KATZE_ARRAY (item));
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
|
|
|
child = katze_array_get_nth_item (KATZE_ARRAY (item), 0);
|
|
|
|
katze_array_remove_item (KATZE_ARRAY (item), child);
|
|
|
|
}
|
|
|
|
parent = katze_item_get_parent (item);
|
|
|
|
katze_array_remove_item (parent, item);
|
|
|
|
while (gtk_tree_model_iter_nth_child (treemodel, &childiter, &iter, 0))
|
|
|
|
gtk_tree_store_remove (GTK_TREE_STORE (treemodel), &childiter);
|
|
|
|
gtk_tree_store_remove (GTK_TREE_STORE (treemodel), &iter);
|
|
|
|
g_object_unref (item);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
parent = katze_item_get_parent (item);
|
|
|
|
katze_array_remove_item (parent, item);
|
|
|
|
gtk_tree_store_remove (GTK_TREE_STORE (treemodel), &iter);
|
|
|
|
g_object_unref (item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_action_history_clear_activate (GtkAction* action,
|
|
|
|
MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkTreeView* tree_view;
|
|
|
|
GtkTreeStore* store;
|
|
|
|
KatzeItem* item;
|
|
|
|
gint i, n;
|
|
|
|
|
|
|
|
if (!browser->history)
|
|
|
|
return;
|
|
|
|
|
|
|
|
tree_view = GTK_TREE_VIEW (browser->panel_history);
|
|
|
|
store = GTK_TREE_STORE (gtk_tree_view_get_model (tree_view));
|
|
|
|
gtk_tree_store_clear (store);
|
|
|
|
|
|
|
|
n = katze_array_get_length (browser->history);
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
|
|
|
item = katze_array_get_nth_item (browser->history, i);
|
|
|
|
katze_array_clear (KATZE_ARRAY (item));
|
|
|
|
}
|
|
|
|
katze_array_clear (browser->history);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
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)
|
|
|
|
{
|
2008-08-25 23:19:38 +00:00
|
|
|
katze_array_clear (browser->trash);
|
2008-03-10 21:26:09 +00:00
|
|
|
_midori_browser_update_actions (browser);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-06-24 19:54:01 +00:00
|
|
|
_action_bookmark_delete_activate (GtkAction* action,
|
2008-03-27 00:21:29 +00:00
|
|
|
MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-08-29 01:20:31 +00:00
|
|
|
GtkTreeView* tree_view;
|
|
|
|
GtkTreeModel* model;
|
|
|
|
GtkTreeIter iter;
|
2008-10-01 02:00:16 +00:00
|
|
|
KatzeItem* item;
|
|
|
|
KatzeArray* parent;
|
2008-08-29 01:20:31 +00:00
|
|
|
|
|
|
|
tree_view = GTK_TREE_VIEW (browser->panel_bookmarks);
|
|
|
|
if (sokoke_tree_view_get_selected_iter (tree_view, &model, &iter))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-08-29 01:20:31 +00:00
|
|
|
gtk_tree_model_get (model, &iter, 0, &item, -1);
|
2008-10-01 02:00:16 +00:00
|
|
|
parent = katze_item_get_parent (item);
|
|
|
|
katze_array_remove_item (parent, item);
|
|
|
|
/* FIXME: This is a preliminary hack, until we fix it properly again */
|
2008-08-29 01:20:31 +00:00
|
|
|
gtk_tree_store_remove (GTK_TREE_STORE (model), &iter);
|
2008-10-01 02:00:16 +00:00
|
|
|
g_object_unref (item);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const GtkActionEntry entries[] = {
|
2008-03-22 02:38:23 +00:00
|
|
|
{ "File", NULL, N_("_File") },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "WindowNew", STOCK_WINDOW_NEW,
|
|
|
|
NULL, "<Ctrl>n",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Open a new window"), G_CALLBACK (_action_window_new_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "TabNew", STOCK_TAB_NEW,
|
|
|
|
NULL, "<Ctrl>t",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Open a new tab"), G_CALLBACK (_action_tab_new_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Open", GTK_STOCK_OPEN,
|
|
|
|
NULL, "<Ctrl>o",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Open a file"), G_CALLBACK (_action_open_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "SaveAs", GTK_STOCK_SAVE_AS,
|
|
|
|
NULL, "<Ctrl>s",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Save to a file"), NULL/*G_CALLBACK (_action_saveas_activate)*/ },
|
|
|
|
{ "TabClose", NULL,
|
|
|
|
N_("_Close Tab"), "<Ctrl>w",
|
|
|
|
N_("Close the current tab"), G_CALLBACK (_action_tab_close_activate) },
|
|
|
|
{ "WindowClose", NULL,
|
|
|
|
N_("C_lose Window"), "<Ctrl><Shift>w",
|
|
|
|
N_("Close this window"), G_CALLBACK (_action_window_close_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Print", GTK_STOCK_PRINT,
|
|
|
|
NULL, "<Ctrl>p",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Print the current page"), G_CALLBACK (_action_print_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Quit", GTK_STOCK_QUIT,
|
|
|
|
NULL, "<Ctrl>q",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Quit the application"), G_CALLBACK (_action_quit_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-03-22 02:38:23 +00:00
|
|
|
{ "Edit", NULL, N_("_Edit"), NULL, NULL, G_CALLBACK (_action_edit_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Cut", GTK_STOCK_CUT,
|
|
|
|
NULL, "<Ctrl>x",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Cut the selected text"), G_CALLBACK (_action_cut_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Copy", GTK_STOCK_COPY,
|
|
|
|
NULL, "<Ctrl>c",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Copy the selected text"), G_CALLBACK (_action_copy_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Copy_", GTK_STOCK_COPY,
|
|
|
|
NULL, "<Ctrl>c",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Copy the selected text"), G_CALLBACK (_action_copy_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Paste", GTK_STOCK_PASTE,
|
|
|
|
NULL, "<Ctrl>v",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Paste text from the clipboard"), G_CALLBACK (_action_paste_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Delete", GTK_STOCK_DELETE,
|
|
|
|
NULL, NULL,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Delete the selected text"), G_CALLBACK (_action_delete_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "SelectAll", GTK_STOCK_SELECT_ALL,
|
|
|
|
NULL, "<Ctrl>a",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Select all text"), G_CALLBACK (_action_select_all_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Find", GTK_STOCK_FIND,
|
|
|
|
NULL, "<Ctrl>f",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Find a word or phrase in the page"), G_CALLBACK (_action_find_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "FindNext", GTK_STOCK_GO_FORWARD,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Find _Next"), "<Ctrl>g",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Find the next occurrence of a word or phrase"), G_CALLBACK (_action_find_next_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "FindPrevious", GTK_STOCK_GO_BACK,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Find _Previous"), "<Ctrl><Shift>g",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Find the previous occurrence of a word or phrase"), G_CALLBACK (_action_find_previous_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "FindQuick", GTK_STOCK_FIND,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("_Quick Find"), "period",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Quickly jump to a word or phrase"), NULL/*G_CALLBACK (_action_find_quick_activate)*/ },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Preferences", GTK_STOCK_PREFERENCES,
|
|
|
|
NULL, "<Ctrl><Alt>p",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Configure the application preferences"), G_CALLBACK (_action_preferences_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-03-22 02:38:23 +00:00
|
|
|
{ "View", NULL, N_("_View") },
|
|
|
|
{ "Toolbars", NULL, N_("_Toolbars") },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Reload", GTK_STOCK_REFRESH,
|
|
|
|
NULL, "<Ctrl>r",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Reload the current page"), G_CALLBACK (_action_reload_stop_activate) },
|
2008-04-03 21:33:32 +00:00
|
|
|
{ "Stop", GTK_STOCK_STOP,
|
|
|
|
NULL, "Escape",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Stop loading the current page"), G_CALLBACK (_action_reload_stop_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "ReloadStop", GTK_STOCK_STOP,
|
|
|
|
NULL, "<Ctrl>r",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Reload the current page"), G_CALLBACK (_action_reload_stop_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "ZoomIn", GTK_STOCK_ZOOM_IN,
|
|
|
|
NULL, "<Ctrl>plus",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Increase the zoom level"), G_CALLBACK (_action_zoom_in_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "ZoomOut", GTK_STOCK_ZOOM_OUT,
|
|
|
|
NULL, "<Ctrl>minus",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Decrease the zoom level"), G_CALLBACK (_action_zoom_out_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "ZoomNormal", GTK_STOCK_ZOOM_100,
|
|
|
|
NULL, "<Ctrl>0",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Reset the zoom level"), G_CALLBACK (_action_zoom_normal_activate) },
|
2008-03-19 13:46:08 +00:00
|
|
|
{ "SourceView", NULL,
|
2008-07-13 19:49:57 +00:00
|
|
|
N_("View _Source"), "",
|
|
|
|
N_("View the source code of the page"), G_CALLBACK (_action_source_view_activate) },
|
2008-03-19 13:46:08 +00:00
|
|
|
{ "SelectionSourceView", NULL,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("View Selection Source"), "",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("View the source code of the selection"), NULL/*G_CALLBACK (_action_selection_source_view_activate)*/ },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Fullscreen", GTK_STOCK_FULLSCREEN,
|
|
|
|
NULL, "F11",
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Toggle fullscreen view"), G_CALLBACK (_action_fullscreen_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-03-22 02:38:23 +00:00
|
|
|
{ "Go", NULL, N_("_Go") },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Back", GTK_STOCK_GO_BACK,
|
|
|
|
NULL, "<Alt>Left",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Go back to the previous page"), G_CALLBACK (_action_back_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "Forward", GTK_STOCK_GO_FORWARD,
|
|
|
|
NULL, "<Alt>Right",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Go forward to the next page"), G_CALLBACK (_action_forward_activate) },
|
2008-05-20 01:21:11 +00:00
|
|
|
{ "Homepage", STOCK_HOMEPAGE,
|
2008-03-10 21:26:09 +00:00
|
|
|
NULL, "<Alt>Home",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Go to your homepage"), G_CALLBACK (_action_homepage_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "OpenInPageholder", GTK_STOCK_JUMP_TO,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Open in Page_holder..."), "",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Open the current page in the pageholder"), G_CALLBACK (_action_open_in_panel_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "TrashEmpty", GTK_STOCK_CLEAR,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Empty Trash"), "",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Delete the contents of the trash"), G_CALLBACK (_action_trash_empty_activate) },
|
2008-03-10 21:48:12 +00:00
|
|
|
{ "UndoTabClose", GTK_STOCK_UNDELETE,
|
2008-08-15 18:48:30 +00:00
|
|
|
N_("Undo Close Tab"), "<Ctrl><Shift>t",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Open the last closed tab"), G_CALLBACK (_action_undo_tab_close_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-06-01 14:40:44 +00:00
|
|
|
{ "BookmarkAdd", STOCK_BOOKMARK_ADD,
|
2008-03-10 21:26:09 +00:00
|
|
|
NULL, "<Ctrl>d",
|
2008-06-01 14:40:44 +00:00
|
|
|
N_("Add a new bookmark"), G_CALLBACK (_action_bookmark_add_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "BookmarkOpen", GTK_STOCK_OPEN,
|
|
|
|
NULL, "",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Open the selected bookmark"), G_CALLBACK (_action_bookmark_open_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "BookmarkOpenTab", STOCK_TAB_NEW,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Open in New _Tab"), "",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Open the selected bookmark in a new tab"), G_CALLBACK (_action_bookmark_open_tab_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "BookmarkOpenWindow", STOCK_WINDOW_NEW,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Open in New _Window"), "",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Open the selected bookmark in a new window"), G_CALLBACK (_action_bookmark_open_window_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "BookmarkEdit", GTK_STOCK_EDIT,
|
|
|
|
NULL, "",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Edit the selected bookmark"), G_CALLBACK (_action_bookmark_edit_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "BookmarkDelete", GTK_STOCK_DELETE,
|
|
|
|
NULL, "",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Delete the selected bookmark"), G_CALLBACK (_action_bookmark_delete_activate) },
|
2008-10-07 00:19:33 +00:00
|
|
|
{ "HistoryDelete", GTK_STOCK_DELETE,
|
|
|
|
NULL, "",
|
|
|
|
N_("Delete the selected history item"), G_CALLBACK (_action_history_delete_activate) },
|
|
|
|
{ "HistoryClear", GTK_STOCK_CLEAR,
|
|
|
|
NULL, "",
|
|
|
|
N_("Clear the enitre history"), G_CALLBACK (_action_history_clear_activate) },
|
|
|
|
{ "HistoryOpen", GTK_STOCK_OPEN,
|
|
|
|
NULL, "",
|
|
|
|
N_("Open the selected history item"), G_CALLBACK (_action_history_open_activate) },
|
|
|
|
{ "HistoryOpenTab", STOCK_TAB_NEW,
|
|
|
|
N_("Open in New _Tab"), "",
|
|
|
|
N_("Open the selected history item in a new tab"), G_CALLBACK (_action_history_open_tab_activate) },
|
2008-03-22 02:38:23 +00:00
|
|
|
{ "Tools", NULL, N_("_Tools") },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "ManageSearchEngines", GTK_STOCK_PROPERTIES,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("_Manage Search Engines"), "<Ctrl><Alt>s",
|
|
|
|
N_("Add, edit and remove search engines..."),
|
2008-03-10 21:26:09 +00:00
|
|
|
G_CALLBACK (_action_manage_search_engines_activate) },
|
|
|
|
|
|
|
|
{ "TabPrevious", GTK_STOCK_GO_BACK,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("_Previous Tab"), "<Ctrl>Page_Up",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Switch to the previous tab"), G_CALLBACK (_action_tab_previous_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "TabNext", GTK_STOCK_GO_FORWARD,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("_Next Tab"), "<Ctrl>Page_Down",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Switch to the next tab"), G_CALLBACK (_action_tab_next_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-03-22 02:38:23 +00:00
|
|
|
{ "Help", NULL, N_("_Help") },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "HelpContents", GTK_STOCK_HELP,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("_Contents"), "F1",
|
2008-10-03 20:23:00 +00:00
|
|
|
N_("Show the documentation"), G_CALLBACK (_action_help_link_activate) },
|
|
|
|
{ "HelpFAQ", NULL,
|
|
|
|
N_("_Frequent questions"), NULL,
|
|
|
|
N_("Show the Frequently Asked Questions"), G_CALLBACK (_action_help_link_activate) },
|
|
|
|
{ "HelpBugs", NULL,
|
|
|
|
N_("_Report a bug"), NULL,
|
|
|
|
N_("Open Midori's bug tracker"), G_CALLBACK (_action_help_link_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
{ "About", GTK_STOCK_ABOUT,
|
|
|
|
NULL, "",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Show information about the program"), G_CALLBACK (_action_about_activate) },
|
2008-03-10 21:26:09 +00:00
|
|
|
};
|
2008-03-24 13:15:23 +00:00
|
|
|
static const guint entries_n = G_N_ELEMENTS (entries);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
static const GtkToggleActionEntry toggle_entries[] = {
|
|
|
|
{ "PrivateBrowsing", NULL,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("P_rivate Browsing"), "",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Don't save any private data while browsing"), NULL/*G_CALLBACK (_action_private_browsing_activate)*/,
|
2008-03-10 21:26:09 +00:00
|
|
|
FALSE },
|
|
|
|
|
|
|
|
{ "Navigationbar", NULL,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("_Navigationbar"), "",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Show navigationbar"), G_CALLBACK (_action_navigationbar_activate),
|
2008-03-10 21:26:09 +00:00
|
|
|
FALSE },
|
|
|
|
{ "Panel", NULL,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("Side_panel"), "F9",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Show sidepanel"), G_CALLBACK (_action_panel_activate),
|
2008-03-10 21:26:09 +00:00
|
|
|
FALSE },
|
|
|
|
{ "Bookmarkbar", NULL,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("_Bookmarkbar"), "",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Show bookmarkbar"), G_CALLBACK (_action_bookmarkbar_activate),
|
2008-03-10 21:26:09 +00:00
|
|
|
FALSE },
|
2008-03-22 02:38:23 +00:00
|
|
|
{ "Transferbar", NULL,
|
|
|
|
N_("_Transferbar"), "",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Show transferbar"), NULL/*G_CALLBACK (_action_transferbar_activate)*/,
|
2008-03-10 21:26:09 +00:00
|
|
|
FALSE },
|
|
|
|
{ "Statusbar", NULL,
|
2008-03-22 02:38:23 +00:00
|
|
|
N_("_Statusbar"), "",
|
2008-06-01 12:08:48 +00:00
|
|
|
N_("Show statusbar"), G_CALLBACK (_action_statusbar_activate),
|
2008-03-10 21:26:09 +00:00
|
|
|
FALSE },
|
|
|
|
};
|
2008-03-24 13:15:23 +00:00
|
|
|
static const guint toggle_entries_n = G_N_ELEMENTS (toggle_entries);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_window_state_event_cb (MidoriBrowser* browser,
|
|
|
|
GdkEventWindowState* event)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
g_object_set (browser->button_fullscreen,
|
2008-03-10 21:26:09 +00:00
|
|
|
"stock-id", GTK_STOCK_LEAVE_FULLSCREEN, NULL);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_widget_show (browser->button_fullscreen);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_widget_show (browser->menubar);
|
|
|
|
gtk_widget_hide (browser->button_fullscreen);
|
|
|
|
g_object_set (browser->button_fullscreen,
|
2008-03-10 21:26:09 +00:00
|
|
|
"stock-id", GTK_STOCK_FULLSCREEN, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_size_allocate_cb (MidoriBrowser* browser,
|
|
|
|
GtkAllocation* allocation)
|
|
|
|
{
|
|
|
|
GtkWidget* widget = GTK_WIDGET (browser);
|
|
|
|
|
|
|
|
if (GTK_WIDGET_REALIZED (widget))
|
|
|
|
{
|
|
|
|
GdkWindowState state = gdk_window_get_state (widget->window);
|
|
|
|
if (!(state & (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)))
|
|
|
|
{
|
2008-06-19 18:39:00 +00:00
|
|
|
g_object_set (browser->settings,
|
2008-04-16 23:38:22 +00:00
|
|
|
"last-window-width", allocation->width,
|
|
|
|
"last-window-height", allocation->height, NULL);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-22 22:17:10 +00:00
|
|
|
static void
|
|
|
|
midori_browser_destroy_cb (MidoriBrowser* browser)
|
|
|
|
{
|
2008-07-25 10:45:50 +00:00
|
|
|
/* Destroy tabs first, so child widgets don't need special care */
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_container_foreach (GTK_CONTAINER (browser->notebook),
|
2008-05-31 12:20:36 +00:00
|
|
|
(GtkCallback) gtk_widget_destroy, NULL);
|
2008-05-22 22:17:10 +00:00
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static const gchar* ui_markup =
|
|
|
|
"<ui>"
|
|
|
|
"<menubar>"
|
|
|
|
"<menu action='File'>"
|
|
|
|
"<menuitem action='WindowNew'/>"
|
|
|
|
"<menuitem action='TabNew'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='Open'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='SaveAs'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='TabClose'/>"
|
|
|
|
"<menuitem action='WindowClose'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='Print'/>"
|
|
|
|
"<menuitem action='PrivateBrowsing'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='Quit'/>"
|
|
|
|
"</menu>"
|
|
|
|
"<menu action='Edit'>"
|
|
|
|
"<menuitem action='Cut'/>"
|
|
|
|
"<menuitem action='Copy'/>"
|
|
|
|
"<menuitem action='Paste'/>"
|
|
|
|
"<menuitem action='Delete'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='SelectAll'/>"
|
|
|
|
"<separator/>"
|
2008-10-03 23:00:34 +00:00
|
|
|
"<menuitem action='Find'/>"
|
|
|
|
"<menuitem action='FindNext'/>"
|
|
|
|
"<menuitem action='FindPrevious'/>"
|
|
|
|
"<separator/>"
|
2008-03-10 21:26:09 +00:00
|
|
|
"<menuitem action='Preferences'/>"
|
|
|
|
"</menu>"
|
|
|
|
"<menu action='View'>"
|
|
|
|
"<menu action='Toolbars'>"
|
|
|
|
"<menuitem action='Navigationbar'/>"
|
|
|
|
"<menuitem action='Bookmarkbar'/>"
|
2008-03-22 02:38:23 +00:00
|
|
|
"<menuitem action='Transferbar'/>"
|
2008-03-10 21:26:09 +00:00
|
|
|
"<menuitem action='Statusbar'/>"
|
|
|
|
"</menu>"
|
|
|
|
"<menuitem action='Panel'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='Reload'/>"
|
|
|
|
"<menuitem action='Stop'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='ZoomIn'/>"
|
|
|
|
"<menuitem action='ZoomOut'/>"
|
|
|
|
"<menuitem action='ZoomNormal'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='SourceView'/>"
|
|
|
|
"<menuitem action='Fullscreen'/>"
|
|
|
|
"</menu>"
|
|
|
|
"<menu action='Go'>"
|
|
|
|
"<menuitem action='Back'/>"
|
|
|
|
"<menuitem action='Forward'/>"
|
2008-05-20 01:21:11 +00:00
|
|
|
"<menuitem action='Homepage'/>"
|
2008-03-10 21:26:09 +00:00
|
|
|
"<menuitem action='Location'/>"
|
|
|
|
"<menuitem action='Search'/>"
|
|
|
|
"<menuitem action='OpenInPageholder'/>"
|
2008-10-10 20:31:37 +00:00
|
|
|
"<menuitem action='Trash'/>"
|
|
|
|
/* "<menuitem action='RecentlyVisited'/>" */
|
2008-03-10 21:26:09 +00:00
|
|
|
"</menu>"
|
2008-10-10 20:31:37 +00:00
|
|
|
"<menuitem action='Bookmarks'/>"
|
2008-03-10 21:26:09 +00:00
|
|
|
"<menu action='Tools'>"
|
|
|
|
"<menuitem action='ManageSearchEngines'/>"
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Panel items shall be appended here */
|
2008-03-10 21:26:09 +00:00
|
|
|
"</menu>"
|
2008-10-10 20:31:37 +00:00
|
|
|
"<menuitem action='Window'/>"
|
2008-03-10 21:26:09 +00:00
|
|
|
"<menu action='Help'>"
|
|
|
|
"<menuitem action='HelpContents'/>"
|
2008-10-03 20:23:00 +00:00
|
|
|
"<menuitem action='HelpFAQ'/>"
|
|
|
|
"<menuitem action='HelpBugs'/>"
|
|
|
|
"<separator/>"
|
2008-03-10 21:26:09 +00:00
|
|
|
"<menuitem action='About'/>"
|
|
|
|
"</menu>"
|
|
|
|
"</menubar>"
|
|
|
|
"<toolbar name='toolbar_navigation'>"
|
|
|
|
"<toolitem action='TabNew'/>"
|
|
|
|
"<toolitem action='Back'/>"
|
|
|
|
"<toolitem action='Forward'/>"
|
|
|
|
"<toolitem action='ReloadStop'/>"
|
2008-05-20 01:21:11 +00:00
|
|
|
"<toolitem action='Homepage'/>"
|
2008-08-14 23:57:48 +00:00
|
|
|
"<toolitem action='Location'/>"
|
2008-10-05 21:25:02 +00:00
|
|
|
"<toolitem action='Search'/>"
|
2008-10-10 20:31:37 +00:00
|
|
|
"<toolitem action='Trash'/>"
|
2008-03-10 21:26:09 +00:00
|
|
|
"</toolbar>"
|
|
|
|
"<toolbar name='toolbar_bookmarks'>"
|
2008-06-01 14:40:44 +00:00
|
|
|
"<toolitem action='BookmarkAdd'/>"
|
2008-03-10 21:26:09 +00:00
|
|
|
"<toolitem action='BookmarkEdit'/>"
|
|
|
|
"<toolitem action='BookmarkDelete'/>"
|
|
|
|
"</toolbar>"
|
|
|
|
"<popup name='popup_bookmark'>"
|
|
|
|
"<menuitem action='BookmarkOpen'/>"
|
|
|
|
"<menuitem action='BookmarkOpenTab'/>"
|
|
|
|
"<menuitem action='BookmarkOpenWindow'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='BookmarkEdit'/>"
|
|
|
|
"<menuitem action='BookmarkDelete'/>"
|
|
|
|
"</popup>"
|
2008-10-07 00:19:33 +00:00
|
|
|
"<toolbar name='toolbar_history'>"
|
|
|
|
"<toolitem action='HistoryDelete'/>"
|
|
|
|
"<toolitem action='HistoryClear' position='bottom' />"
|
|
|
|
"</toolbar>"
|
|
|
|
"<popup name='popup_history'>"
|
|
|
|
"<menuitem action='HistoryOpen'/>"
|
|
|
|
"<menuitem action='HistoryOpenTab'/>"
|
|
|
|
"<separator/>"
|
|
|
|
"<menuitem action='HistoryDelete'/>"
|
|
|
|
"</popup>"
|
2008-03-10 21:26:09 +00:00
|
|
|
"</ui>";
|
|
|
|
|
2008-05-31 12:20:36 +00:00
|
|
|
static void
|
2008-07-27 05:39:39 +00:00
|
|
|
midori_browser_realize_cb (GtkStyle* style,
|
|
|
|
MidoriBrowser* browser)
|
2008-05-31 12:20:36 +00:00
|
|
|
{
|
2008-07-27 05:39:39 +00:00
|
|
|
GdkScreen* screen;
|
|
|
|
GtkIconTheme* icon_theme;
|
|
|
|
|
|
|
|
screen = gtk_widget_get_screen (GTK_WIDGET (browser));
|
2008-05-31 12:20:36 +00:00
|
|
|
if (screen)
|
|
|
|
{
|
2008-07-27 05:39:39 +00:00
|
|
|
icon_theme = gtk_icon_theme_get_for_screen (screen);
|
2008-05-31 12:20:36 +00:00
|
|
|
if (gtk_icon_theme_has_icon (icon_theme, "midori"))
|
|
|
|
gtk_window_set_icon_name (GTK_WINDOW (browser), "midori");
|
|
|
|
else
|
|
|
|
gtk_window_set_icon_name (GTK_WINDOW (browser), "web-browser");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-17 19:02:14 +00:00
|
|
|
static void
|
|
|
|
midori_browser_entry_clear_icon_released_cb (GtkIconEntry* entry,
|
|
|
|
gint icon_pos,
|
|
|
|
gint button,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
if (icon_pos == GTK_ICON_ENTRY_SECONDARY)
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry), "");
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
midori_browser_init (MidoriBrowser* browser)
|
|
|
|
{
|
2008-08-14 23:57:48 +00:00
|
|
|
GtkToolItem* toolitem;
|
2008-07-23 12:42:27 +00:00
|
|
|
GtkRcStyle* rcstyle;
|
|
|
|
|
2008-09-03 00:28:54 +00:00
|
|
|
browser->settings = midori_web_settings_new ();
|
2008-10-10 20:31:37 +00:00
|
|
|
browser->proxy_array = katze_array_new (KATZE_TYPE_ARRAY);
|
2008-09-03 00:28:54 +00:00
|
|
|
browser->bookmarks = NULL;
|
|
|
|
browser->trash = NULL;
|
|
|
|
browser->search_engines = NULL;
|
2008-10-07 00:19:33 +00:00
|
|
|
browser->history = 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);
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_window_set_icon_name (GTK_WINDOW (browser), "web-browser");
|
|
|
|
gtk_window_set_title (GTK_WINDOW (browser), g_get_application_name ());
|
|
|
|
GtkWidget* vbox = gtk_vbox_new (FALSE, 0);
|
|
|
|
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);
|
|
|
|
GtkUIManager* ui_manager = gtk_ui_manager_new ();
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_ui_manager_insert_action_group (ui_manager, browser->action_group, 0);
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_window_add_accel_group (GTK_WINDOW (browser),
|
|
|
|
gtk_ui_manager_get_accel_group (ui_manager));
|
|
|
|
|
|
|
|
GError* error = NULL;
|
2008-08-02 02:25:05 +00:00
|
|
|
if (!gtk_ui_manager_add_ui_from_string (ui_manager, ui_markup, -1, &error))
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-06-14 00:23:33 +00:00
|
|
|
/* TODO: Should this be a message dialog? When does this happen? */
|
2008-03-10 21:26:09 +00:00
|
|
|
g_message ("User interface couldn't be created: %s", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkAction* action;
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Make all actions except toplevel menus which lack a callback insensitive
|
|
|
|
This will vanish once all actions are implemented */
|
2008-03-10 21:26:09 +00:00
|
|
|
guint i;
|
|
|
|
for (i = 0; i < entries_n; i++)
|
|
|
|
{
|
2008-08-02 02:25:05 +00:00
|
|
|
action = gtk_action_group_get_action (browser->action_group,
|
|
|
|
entries[i].name);
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_action_set_sensitive (action,
|
|
|
|
entries[i].callback || !entries[i].tooltip);
|
|
|
|
}
|
|
|
|
for (i = 0; i < toggle_entries_n; i++)
|
|
|
|
{
|
2008-06-19 18:39:00 +00:00
|
|
|
action = gtk_action_group_get_action (browser->action_group,
|
2008-03-10 21:26:09 +00:00
|
|
|
toggle_entries[i].name);
|
|
|
|
gtk_action_set_sensitive (action, toggle_entries[i].callback != NULL);
|
|
|
|
}
|
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* _action_set_active(browser, "Transferbar", config->toolbarTransfers); */
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-08-14 23:57:48 +00:00
|
|
|
action = g_object_new (MIDORI_TYPE_LOCATION_ACTION,
|
|
|
|
"name", "Location",
|
|
|
|
"label", _("_Location..."),
|
|
|
|
"stock-id", GTK_STOCK_JUMP_TO,
|
|
|
|
"tooltip", _("Open a particular location"),
|
|
|
|
/* FIXME: Due to a bug in GtkIconEntry we need to set an initial icon */
|
2008-08-17 14:14:15 +00:00
|
|
|
"secondary-icon", STOCK_NEWS_FEED,
|
2008-08-14 23:57:48 +00:00
|
|
|
NULL);
|
|
|
|
g_object_connect (action,
|
|
|
|
"signal::activate",
|
|
|
|
_action_location_activate, browser,
|
|
|
|
"signal::active-changed",
|
|
|
|
_action_location_active_changed, browser,
|
|
|
|
"signal::focus-out",
|
|
|
|
_action_location_focus_out, browser,
|
|
|
|
"signal::reset-uri",
|
|
|
|
_action_location_reset_uri, browser,
|
|
|
|
"signal::submit-uri",
|
|
|
|
_action_location_submit_uri, browser,
|
|
|
|
"signal::secondary-icon-released",
|
|
|
|
_action_location_secondary_icon_released, browser,
|
|
|
|
NULL);
|
|
|
|
gtk_action_group_add_action_with_accel (browser->action_group,
|
|
|
|
action, "<Ctrl>L");
|
|
|
|
g_object_unref (action);
|
|
|
|
|
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,
|
|
|
|
NULL);
|
|
|
|
gtk_action_group_add_action_with_accel (browser->action_group,
|
|
|
|
action, "<Ctrl>K");
|
|
|
|
g_object_unref (action);
|
|
|
|
|
2008-10-10 20:31:37 +00:00
|
|
|
action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
|
|
|
|
"name", "Trash",
|
|
|
|
"stock-id", STOCK_USER_TRASH,
|
|
|
|
"tooltip", _("Reopen a previously closed tab or window"),
|
|
|
|
NULL);
|
|
|
|
g_object_connect (action,
|
|
|
|
"signal::populate-popup",
|
|
|
|
_action_trash_populate_popup, browser,
|
|
|
|
"signal::activate-item",
|
|
|
|
_action_trash_activate_item, browser,
|
|
|
|
NULL);
|
|
|
|
gtk_action_group_add_action_with_accel (browser->action_group,
|
|
|
|
action, "");
|
|
|
|
g_object_unref (action);
|
|
|
|
|
|
|
|
action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
|
|
|
|
"name", "RecentlyVisited",
|
|
|
|
"label", _("_Recently visited pages"),
|
|
|
|
"stock-id", STOCK_HISTORY,
|
|
|
|
"tooltip", _("Revisit pages that you opened before"),
|
|
|
|
NULL);
|
|
|
|
g_object_connect (action,
|
|
|
|
"signal::populate-popup",
|
|
|
|
_action_history_populate_popup, browser,
|
|
|
|
"signal::activate-item",
|
|
|
|
_action_history_activate_item, browser,
|
|
|
|
NULL);
|
|
|
|
gtk_action_group_add_action_with_accel (browser->action_group,
|
|
|
|
action, "");
|
|
|
|
g_object_unref (action);
|
|
|
|
|
|
|
|
action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
|
|
|
|
"name", "Bookmarks",
|
|
|
|
"label", _("_Bookmarks"),
|
|
|
|
"stock-id", STOCK_BOOKMARKS,
|
|
|
|
"tooltip", _("Reopen a previously closed tab or window"),
|
|
|
|
NULL);
|
|
|
|
g_object_connect (action,
|
|
|
|
"signal::populate-popup",
|
|
|
|
_action_bookmarks_populate_popup, browser,
|
|
|
|
"signal::activate-item",
|
|
|
|
_action_bookmarks_activate_item, browser,
|
|
|
|
NULL);
|
|
|
|
gtk_action_group_add_action_with_accel (browser->action_group,
|
|
|
|
action, "");
|
|
|
|
g_object_unref (action);
|
|
|
|
|
|
|
|
action = g_object_new (KATZE_TYPE_ARRAY_ACTION,
|
|
|
|
"name", "Window",
|
|
|
|
"label", _("Window"),
|
|
|
|
"stock-id", GTK_STOCK_INDEX,
|
|
|
|
"tooltip", _("Show a list of all open tabs"),
|
|
|
|
"array", browser->proxy_array,
|
|
|
|
NULL);
|
|
|
|
g_object_connect (action,
|
|
|
|
"signal::populate-popup",
|
|
|
|
_action_window_populate_popup, browser,
|
|
|
|
"signal::activate-item",
|
|
|
|
_action_window_activate_item, browser,
|
|
|
|
NULL);
|
|
|
|
gtk_action_group_add_action_with_accel (browser->action_group,
|
|
|
|
action, "");
|
|
|
|
g_object_unref (action);
|
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Create the menubar */
|
2008-06-19 18:39:00 +00:00
|
|
|
browser->menubar = gtk_ui_manager_get_widget (ui_manager, "/menubar");
|
2008-06-01 09:26:10 +00:00
|
|
|
GtkWidget* 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);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), browser->menubar, FALSE, FALSE, 0);
|
2008-10-10 20:31:37 +00:00
|
|
|
browser->popup_bookmark = g_object_ref (gtk_ui_manager_get_widget (
|
|
|
|
ui_manager, "/popup_bookmark"));
|
|
|
|
browser->popup_history = g_object_ref (gtk_ui_manager_get_widget (
|
|
|
|
ui_manager, "/popup_history"));
|
2008-06-19 18:39:00 +00:00
|
|
|
browser->menu_tools = gtk_menu_item_get_submenu (GTK_MENU_ITEM (
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_ui_manager_get_widget (ui_manager, "/menubar/Tools")));
|
2008-08-25 23:19:38 +00:00
|
|
|
menuitem = gtk_separator_menu_item_new ();
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_widget_show (menuitem);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (browser->menu_tools), menuitem);
|
|
|
|
gtk_widget_show (browser->menubar);
|
2008-03-10 21:26:09 +00:00
|
|
|
_action_set_sensitive (browser, "PrivateBrowsing", FALSE);
|
|
|
|
|
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-06-14 00:23:33 +00:00
|
|
|
/* FIXME: settings should be connected with screen changes */
|
2008-04-16 23:38:22 +00:00
|
|
|
GtkSettings* gtk_settings = gtk_widget_get_settings (GTK_WIDGET (browser));
|
|
|
|
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);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), browser->navigationbar, FALSE, FALSE, 0);
|
|
|
|
browser->button_tab_new = gtk_ui_manager_get_widget (
|
2008-03-10 21:26:09 +00:00
|
|
|
ui_manager, "/toolbar_navigation/TabNew");
|
|
|
|
g_object_set (_action_by_name (browser, "Back"), "is-important", TRUE, NULL);
|
2008-06-19 18:39:00 +00:00
|
|
|
browser->button_homepage = gtk_ui_manager_get_widget (
|
2008-05-20 01:21:11 +00:00
|
|
|
ui_manager, "/toolbar_navigation/Homepage");
|
2008-10-05 21:25:02 +00:00
|
|
|
browser->search = gtk_ui_manager_get_widget (
|
|
|
|
ui_manager, "/toolbar_navigation/Search");
|
2008-10-10 20:31:37 +00:00
|
|
|
browser->button_trash = gtk_ui_manager_get_widget (
|
|
|
|
ui_manager, "/toolbar_navigation/Trash");
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
sokoke_container_show_children (GTK_CONTAINER (browser->navigationbar));
|
2008-08-10 16:28:08 +00:00
|
|
|
gtk_widget_hide (browser->navigationbar);
|
2008-06-19 18:39:00 +00:00
|
|
|
action = gtk_action_group_get_action (browser->action_group, "Fullscreen");
|
|
|
|
browser->button_fullscreen = gtk_action_create_tool_item (action);
|
|
|
|
gtk_widget_hide (browser->button_fullscreen);
|
|
|
|
g_signal_connect (browser->button_fullscreen, "clicked",
|
2008-03-10 21:26:09 +00:00
|
|
|
G_CALLBACK (_action_fullscreen_activate), browser);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->navigationbar),
|
|
|
|
GTK_TOOL_ITEM (browser->button_fullscreen), -1);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Bookmarkbar */
|
2008-06-19 18:39:00 +00:00
|
|
|
browser->bookmarkbar = gtk_toolbar_new ();
|
|
|
|
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);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), browser->bookmarkbar, FALSE, FALSE, 0);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Superuser warning */
|
2008-03-10 21:26:09 +00:00
|
|
|
GtkWidget* hbox;
|
|
|
|
if ((hbox = sokoke_superuser_warning_new ()))
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Create the panel */
|
2008-03-10 21:26:09 +00:00
|
|
|
GtkWidget* hpaned = gtk_hpaned_new ();
|
|
|
|
g_signal_connect (hpaned, "notify::position",
|
|
|
|
G_CALLBACK (midori_panel_notify_position_cb),
|
|
|
|
browser);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hpaned, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (hpaned);
|
2008-06-19 18:39:00 +00:00
|
|
|
browser->panel = g_object_new (MIDORI_TYPE_PANEL,
|
2008-03-10 21:26:09 +00:00
|
|
|
"shadow-type", GTK_SHADOW_IN,
|
2008-06-19 18:39:00 +00:00
|
|
|
"menu", browser->menu_tools,
|
2008-03-10 21:26:09 +00:00
|
|
|
NULL);
|
2008-06-19 18:39:00 +00:00
|
|
|
g_signal_connect (browser->panel, "close",
|
2008-03-10 21:26:09 +00:00
|
|
|
G_CALLBACK (midori_panel_close_cb), browser);
|
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-06-14 00:23:33 +00:00
|
|
|
/* Bookmarks */
|
2008-03-10 21:26:09 +00:00
|
|
|
GtkWidget* box = gtk_vbox_new (FALSE, 0);
|
|
|
|
GtkTreeViewColumn* column;
|
|
|
|
GtkCellRenderer* renderer_text;
|
|
|
|
GtkCellRenderer* renderer_pixbuf;
|
2008-10-01 02:00:16 +00:00
|
|
|
GtkTreeStore* treestore = gtk_tree_store_new (1, KATZE_TYPE_ITEM);
|
2008-03-10 21:26:09 +00:00
|
|
|
GtkWidget* treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (treestore));
|
|
|
|
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
|
|
|
|
column = gtk_tree_view_column_new ();
|
|
|
|
renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
|
|
|
|
gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
|
|
|
|
gtk_tree_view_column_set_cell_data_func (column, renderer_pixbuf,
|
|
|
|
(GtkTreeCellDataFunc)midori_browser_bookmarks_item_render_icon_cb,
|
|
|
|
treeview, NULL);
|
|
|
|
renderer_text = gtk_cell_renderer_text_new ();
|
|
|
|
gtk_tree_view_column_pack_start (column, renderer_text, FALSE);
|
|
|
|
gtk_tree_view_column_set_cell_data_func (column, renderer_text,
|
|
|
|
(GtkTreeCellDataFunc)midori_browser_bookmarks_item_render_text_cb,
|
|
|
|
treeview, NULL);
|
|
|
|
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
|
|
|
|
g_object_unref (treestore);
|
|
|
|
g_object_connect (treeview,
|
|
|
|
"signal::row-activated",
|
|
|
|
midori_panel_bookmarks_row_activated_cb, browser,
|
|
|
|
"signal::cursor-changed",
|
|
|
|
midori_panel_bookmarks_cursor_or_row_changed_cb, browser,
|
|
|
|
"signal::columns-changed",
|
|
|
|
midori_panel_bookmarks_cursor_or_row_changed_cb, browser,
|
|
|
|
"signal::button-release-event",
|
|
|
|
midori_panel_bookmarks_button_release_event_cb, browser,
|
|
|
|
"signal::popup-menu",
|
|
|
|
midori_panel_bookmarks_popup_menu_cb, browser,
|
|
|
|
NULL);
|
|
|
|
midori_panel_bookmarks_cursor_or_row_changed_cb (GTK_TREE_VIEW (treeview),
|
|
|
|
browser);
|
2008-03-27 00:21:29 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (box), treeview, TRUE, TRUE, 0);
|
2008-06-19 18:39:00 +00:00
|
|
|
browser->panel_bookmarks = treeview;
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_widget_show_all (box);
|
2008-04-26 00:43:32 +00:00
|
|
|
GtkWidget* toolbar = gtk_ui_manager_get_widget (ui_manager,
|
|
|
|
"/toolbar_bookmarks");
|
2008-09-03 00:28:54 +00:00
|
|
|
_action_set_sensitive (browser, "BookmarkAdd", FALSE);
|
2008-04-26 00:43:32 +00:00
|
|
|
gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_MENU);
|
|
|
|
gtk_widget_show_all (toolbar);
|
2008-06-19 18:39:00 +00:00
|
|
|
midori_panel_append_page (MIDORI_PANEL (browser->panel),
|
2008-04-26 00:43:32 +00:00
|
|
|
box, toolbar,
|
2008-08-17 14:14:15 +00:00
|
|
|
STOCK_BOOKMARKS, _("Bookmarks"));
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Transfers */
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* panel = midori_view_new ();
|
2008-04-28 20:38:57 +00:00
|
|
|
gtk_widget_show (panel);
|
2008-06-19 18:39:00 +00:00
|
|
|
midori_panel_append_page (MIDORI_PANEL (browser->panel),
|
2008-04-28 20:38:57 +00:00
|
|
|
panel, NULL,
|
2008-08-17 14:14:15 +00:00
|
|
|
STOCK_TRANSFERS, _("Transfers"));
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Console */
|
2008-06-19 18:39:00 +00:00
|
|
|
browser->panel_console = midori_console_new ();
|
|
|
|
gtk_widget_show (browser->panel_console);
|
|
|
|
toolbar = midori_console_get_toolbar (MIDORI_CONSOLE (browser->panel_console));
|
2008-04-26 00:43:32 +00:00
|
|
|
gtk_widget_show (toolbar);
|
2008-06-19 18:39:00 +00:00
|
|
|
midori_panel_append_page (MIDORI_PANEL (browser->panel),
|
|
|
|
browser->panel_console, toolbar,
|
2008-08-17 14:14:15 +00:00
|
|
|
STOCK_CONSOLE, _("Console"));
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* History */
|
2008-10-07 00:19:33 +00:00
|
|
|
box = gtk_vbox_new (FALSE, 0);
|
|
|
|
treestore = gtk_tree_store_new (1, KATZE_TYPE_ITEM);
|
|
|
|
treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (treestore));
|
|
|
|
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
|
|
|
|
column = gtk_tree_view_column_new ();
|
|
|
|
renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
|
|
|
|
gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
|
|
|
|
gtk_tree_view_column_set_cell_data_func (column, renderer_pixbuf,
|
|
|
|
(GtkTreeCellDataFunc)midori_browser_history_render_icon_cb,
|
|
|
|
treeview, NULL);
|
|
|
|
renderer_text = gtk_cell_renderer_text_new ();
|
|
|
|
gtk_tree_view_column_pack_start (column, renderer_text, FALSE);
|
|
|
|
gtk_tree_view_column_set_cell_data_func (column, renderer_text,
|
|
|
|
(GtkTreeCellDataFunc)midori_browser_history_render_text_cb,
|
|
|
|
treeview, NULL);
|
|
|
|
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
|
|
|
|
g_object_unref (treestore);
|
|
|
|
g_object_connect (treeview,
|
|
|
|
"signal::row-activated",
|
|
|
|
midori_panel_history_row_activated_cb, browser,
|
|
|
|
"signal::button-release-event",
|
|
|
|
midori_panel_history_button_release_event_cb, browser,
|
|
|
|
"signal::popup-menu",
|
|
|
|
midori_panel_history_popup_menu_cb, browser,
|
|
|
|
NULL);
|
|
|
|
gtk_box_pack_start (GTK_BOX (box), treeview, TRUE, TRUE, 0);
|
|
|
|
browser->panel_history = treeview;
|
|
|
|
gtk_widget_show_all (box);
|
|
|
|
toolbar = gtk_ui_manager_get_widget (ui_manager, "/toolbar_history");
|
|
|
|
gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_MENU);
|
|
|
|
gtk_widget_show (toolbar);
|
2008-06-19 18:39:00 +00:00
|
|
|
midori_panel_append_page (MIDORI_PANEL (browser->panel),
|
2008-10-07 00:19:33 +00:00
|
|
|
box, toolbar,
|
2008-08-17 14:14:15 +00:00
|
|
|
STOCK_HISTORY, _("History"));
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Pageholder */
|
2008-09-26 21:13:46 +00:00
|
|
|
browser->panel_pageholder = midori_view_new ();
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_widget_show (browser->panel_pageholder);
|
|
|
|
midori_panel_append_page (MIDORI_PANEL (browser->panel),
|
|
|
|
browser->panel_pageholder, NULL,
|
2008-08-17 14:14:15 +00:00
|
|
|
STOCK_PAGE_HOLDER, _("Pageholder"));
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Userscripts */
|
2008-04-28 20:38:57 +00:00
|
|
|
panel = midori_addons_new (GTK_WIDGET (browser), MIDORI_ADDON_USER_SCRIPTS);
|
|
|
|
gtk_widget_show (panel);
|
|
|
|
toolbar = midori_addons_get_toolbar (MIDORI_ADDONS (panel));
|
|
|
|
gtk_widget_show (toolbar);
|
2008-06-19 18:39:00 +00:00
|
|
|
midori_panel_append_page (MIDORI_PANEL (browser->panel),
|
2008-04-28 20:38:57 +00:00
|
|
|
panel, toolbar,
|
2008-08-17 14:14:15 +00:00
|
|
|
STOCK_SCRIPTS, _("Userscripts"));
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Userstyles */
|
2008-08-17 23:24:26 +00:00
|
|
|
panel = midori_addons_new (GTK_WIDGET (browser), MIDORI_ADDON_USER_STYLES);
|
2008-04-28 20:38:57 +00:00
|
|
|
gtk_widget_show (panel);
|
|
|
|
toolbar = midori_addons_get_toolbar (MIDORI_ADDONS (panel));
|
|
|
|
gtk_widget_show (toolbar);
|
2008-06-19 18:39:00 +00:00
|
|
|
midori_panel_append_page (MIDORI_PANEL (browser->panel),
|
2008-04-28 20:38:57 +00:00
|
|
|
panel, toolbar,
|
2008-08-17 23:24:26 +00:00
|
|
|
STOCK_STYLES, _("Userstyles"));
|
2008-04-28 20:38:57 +00:00
|
|
|
|
2008-08-01 13:49:47 +00:00
|
|
|
/* Extensions */
|
|
|
|
panel = midori_addons_new (GTK_WIDGET (browser), MIDORI_ADDON_EXTENSIONS);
|
|
|
|
gtk_widget_show (panel);
|
|
|
|
toolbar = midori_addons_get_toolbar (MIDORI_ADDONS (panel));
|
|
|
|
gtk_widget_show (toolbar);
|
|
|
|
midori_panel_append_page (MIDORI_PANEL (browser->panel),
|
|
|
|
panel, toolbar,
|
2008-08-17 14:14:15 +00:00
|
|
|
STOCK_EXTENSIONS, _("Extensions"));
|
2008-08-01 13:49:47 +00:00
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
/* Notebook, containing all views */
|
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 ();
|
|
|
|
rcstyle->xthickness = rcstyle->ythickness = 0;
|
|
|
|
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);
|
|
|
|
gtk_paned_pack2 (GTK_PANED (hpaned), browser->notebook, FALSE, FALSE);
|
|
|
|
g_signal_connect_after (browser->notebook, "switch-page",
|
2008-03-10 21:26:09 +00:00
|
|
|
G_CALLBACK (gtk_notebook_switch_page_cb),
|
|
|
|
browser);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_widget_show (browser->notebook);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Incremental findbar */
|
2008-06-19 18:39:00 +00:00
|
|
|
browser->find = gtk_toolbar_new ();
|
|
|
|
gtk_toolbar_set_icon_size (GTK_TOOLBAR (browser->find), GTK_ICON_SIZE_MENU);
|
|
|
|
gtk_toolbar_set_style (GTK_TOOLBAR (browser->find), GTK_TOOLBAR_BOTH_HORIZ);
|
2008-03-10 21:26:09 +00:00
|
|
|
toolitem = gtk_tool_item_new ();
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (toolitem), 6);
|
|
|
|
gtk_container_add (GTK_CONTAINER (toolitem),
|
2008-03-22 02:38:23 +00:00
|
|
|
gtk_label_new_with_mnemonic (_("_Inline find:")));
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->find), toolitem, -1);
|
2008-07-17 19:02:14 +00:00
|
|
|
browser->find_text = gtk_icon_entry_new ();
|
2008-08-25 23:59:02 +00:00
|
|
|
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (browser->find_text),
|
2008-07-17 19:02:14 +00:00
|
|
|
GTK_ICON_ENTRY_PRIMARY,
|
|
|
|
GTK_STOCK_FIND);
|
|
|
|
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (browser->find_text),
|
|
|
|
GTK_ICON_ENTRY_SECONDARY,
|
|
|
|
GTK_STOCK_CLEAR);
|
2008-07-22 12:53:25 +00:00
|
|
|
gtk_icon_entry_set_icon_highlight (GTK_ICON_ENTRY (browser->find_text),
|
|
|
|
GTK_ICON_ENTRY_SECONDARY, TRUE);
|
2008-07-17 19:02:14 +00:00
|
|
|
g_signal_connect (browser->find_text, "icon_released",
|
|
|
|
G_CALLBACK (midori_browser_entry_clear_icon_released_cb), NULL);
|
2008-06-19 18:39:00 +00:00
|
|
|
g_signal_connect (browser->find_text, "activate",
|
2008-03-10 21:26:09 +00:00
|
|
|
G_CALLBACK (_action_find_next_activate), browser);
|
|
|
|
toolitem = gtk_tool_item_new ();
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (toolitem), browser->find_text);
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_tool_item_set_expand (GTK_TOOL_ITEM (toolitem), TRUE);
|
2008-08-25 23:59:02 +00:00
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->find), toolitem, -1);
|
2008-07-13 19:49:57 +00:00
|
|
|
toolitem = (GtkToolItem*)gtk_action_create_tool_item
|
|
|
|
(_action_by_name (browser, "FindPrevious"));
|
|
|
|
gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem), NULL);
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_tool_item_set_is_important (toolitem, TRUE);
|
|
|
|
g_signal_connect (toolitem, "clicked",
|
|
|
|
G_CALLBACK (_action_find_previous_activate), browser);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->find), toolitem, -1);
|
2008-07-13 19:49:57 +00:00
|
|
|
toolitem = (GtkToolItem*)gtk_action_create_tool_item
|
|
|
|
(_action_by_name (browser, "FindNext"));
|
|
|
|
gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem), NULL);
|
2008-03-10 21:26:09 +00:00
|
|
|
gtk_tool_item_set_is_important (toolitem, TRUE);
|
|
|
|
g_signal_connect (toolitem, "clicked",
|
|
|
|
G_CALLBACK (_action_find_next_activate), browser);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->find), toolitem, -1);
|
|
|
|
browser->find_case = gtk_toggle_tool_button_new_from_stock (
|
2008-03-10 21:26:09 +00:00
|
|
|
GTK_STOCK_SPELL_CHECK);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_tool_button_set_label (GTK_TOOL_BUTTON (browser->find_case), _("Match Case"));
|
|
|
|
gtk_tool_item_set_is_important (GTK_TOOL_ITEM (browser->find_case), TRUE);
|
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->find), browser->find_case, -1);
|
|
|
|
browser->find_highlight = gtk_toggle_tool_button_new_from_stock (
|
2008-03-10 21:26:09 +00:00
|
|
|
GTK_STOCK_SELECT_ALL);
|
2008-06-19 18:39:00 +00:00
|
|
|
g_signal_connect (browser->find_highlight, "toggled",
|
2008-03-10 21:26:09 +00:00
|
|
|
G_CALLBACK (_find_highlight_toggled), browser);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_tool_button_set_label (GTK_TOOL_BUTTON (browser->find_highlight),
|
2008-09-07 01:39:25 +00:00
|
|
|
_("Highlight Matches"));
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_tool_item_set_is_important (GTK_TOOL_ITEM (browser->find_highlight), TRUE);
|
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->find), browser->find_highlight, -1);
|
2008-03-10 21:26:09 +00:00
|
|
|
toolitem = gtk_separator_tool_item_new ();
|
|
|
|
gtk_separator_tool_item_set_draw (
|
|
|
|
GTK_SEPARATOR_TOOL_ITEM (toolitem), FALSE);
|
|
|
|
gtk_tool_item_set_expand (GTK_TOOL_ITEM (toolitem), TRUE);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->find), toolitem, -1);
|
2008-03-10 21:26:09 +00:00
|
|
|
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_CLOSE);
|
2008-03-22 02:38:23 +00:00
|
|
|
gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem), _("Close Findbar"));
|
2008-03-10 21:26:09 +00:00
|
|
|
g_signal_connect (toolitem, "clicked",
|
|
|
|
G_CALLBACK (midori_browser_find_button_close_clicked_cb), browser);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->find), toolitem, -1);
|
|
|
|
sokoke_container_show_children (GTK_CONTAINER (browser->find));
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), browser->find, FALSE, FALSE, 0);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-06-14 00:23:33 +00:00
|
|
|
/* Statusbar */
|
2008-06-19 18:39:00 +00:00
|
|
|
browser->statusbar = gtk_statusbar_new ();
|
2008-07-23 16:23:21 +00:00
|
|
|
/* Adjust the statusbar's padding to avoid child overlapping */
|
|
|
|
rcstyle = gtk_rc_style_new ();
|
|
|
|
rcstyle->xthickness = rcstyle->ythickness = -4;
|
|
|
|
gtk_widget_modify_style (browser->statusbar, rcstyle);
|
|
|
|
g_object_unref (rcstyle);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), browser->statusbar, FALSE, FALSE, 0);
|
|
|
|
browser->progressbar = gtk_progress_bar_new ();
|
2008-07-23 16:23:21 +00:00
|
|
|
/* Set the progressbar's height to 1 to fit it in the statusbar */
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_widget_set_size_request (browser->progressbar, -1, 1);
|
|
|
|
gtk_box_pack_start (GTK_BOX (browser->statusbar), browser->progressbar,
|
2008-03-10 21:26:09 +00:00
|
|
|
FALSE, FALSE, 3);
|
|
|
|
|
|
|
|
g_object_unref (ui_manager);
|
2008-06-09 01:13:08 +00:00
|
|
|
|
2008-08-27 22:55:35 +00:00
|
|
|
#if !HAVE_GIO
|
|
|
|
_action_set_sensitive (browser, "SourceView", FALSE);
|
|
|
|
#endif
|
2008-08-17 17:11:43 +00:00
|
|
|
|
2008-06-09 01:13:08 +00:00
|
|
|
#ifndef WEBKIT_CHECK_VERSION
|
|
|
|
_action_set_sensitive (browser, "ZoomIn", FALSE);
|
|
|
|
_action_set_sensitive (browser, "ZoomOut", FALSE);
|
|
|
|
#endif
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2008-07-25 10:45:50 +00:00
|
|
|
static void
|
|
|
|
midori_browser_dispose (GObject* object)
|
|
|
|
{
|
|
|
|
MidoriBrowser* browser = MIDORI_BROWSER (object);
|
|
|
|
|
|
|
|
/* We are done, the session mustn't change anymore */
|
2008-10-10 20:31:37 +00:00
|
|
|
katze_object_assign (browser->proxy_array, NULL);
|
2008-07-25 10:45:50 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (midori_browser_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
midori_browser_finalize (GObject* object)
|
|
|
|
{
|
|
|
|
MidoriBrowser* browser = MIDORI_BROWSER (object);
|
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
g_free (browser->statusbar_text);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
if (browser->settings)
|
|
|
|
g_object_unref (browser->settings);
|
2008-09-03 00:28:54 +00:00
|
|
|
if (browser->bookmarks)
|
|
|
|
g_object_unref (browser->bookmarks);
|
2008-06-19 18:39:00 +00:00
|
|
|
if (browser->trash)
|
|
|
|
g_object_unref (browser->trash);
|
|
|
|
if (browser->search_engines)
|
|
|
|
g_object_unref (browser->search_engines);
|
2008-10-07 00:19:33 +00:00
|
|
|
if (browser->history)
|
|
|
|
g_object_unref (browser->history);
|
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;
|
|
|
|
GtkSettings* gtk_settings = gtk_widget_get_settings (GTK_WIDGET (browser));
|
|
|
|
if (toolbar_style == MIDORI_TOOLBAR_DEFAULT && gtk_settings)
|
|
|
|
g_object_get (gtk_settings, "gtk-toolbar-style", >k_toolbar_style, NULL);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (toolbar_style)
|
|
|
|
{
|
|
|
|
case MIDORI_TOOLBAR_ICONS:
|
|
|
|
gtk_toolbar_style = GTK_TOOLBAR_ICONS;
|
|
|
|
break;
|
|
|
|
case MIDORI_TOOLBAR_TEXT:
|
|
|
|
gtk_toolbar_style = GTK_TOOLBAR_TEXT;
|
|
|
|
break;
|
|
|
|
case MIDORI_TOOLBAR_BOTH:
|
|
|
|
gtk_toolbar_style = GTK_TOOLBAR_BOTH;
|
|
|
|
break;
|
|
|
|
case MIDORI_TOOLBAR_BOTH_HORIZ:
|
|
|
|
case MIDORI_TOOLBAR_DEFAULT:
|
|
|
|
gtk_toolbar_style = GTK_TOOLBAR_BOTH_HORIZ;
|
|
|
|
}
|
|
|
|
}
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_midori_browser_update_settings (MidoriBrowser* browser)
|
2008-04-16 23:38:22 +00:00
|
|
|
{
|
2008-08-23 16:32:53 +00:00
|
|
|
KatzeItem* item;
|
2008-04-16 23:38:22 +00:00
|
|
|
|
|
|
|
gboolean remember_last_window_size;
|
|
|
|
gint last_window_width, last_window_height;
|
|
|
|
gint last_panel_position, last_panel_page;
|
|
|
|
gboolean show_navigationbar, show_bookmarkbar, show_panel, show_statusbar;
|
2008-08-05 00:40:51 +00:00
|
|
|
gboolean show_new_tab, show_homepage, show_web_search, show_trash;
|
2008-04-16 23:38:22 +00:00
|
|
|
MidoriToolbarStyle toolbar_style;
|
|
|
|
gint last_web_search;
|
|
|
|
gchar* last_pageholder_uri;
|
2008-07-13 19:49:57 +00:00
|
|
|
gboolean close_buttons_on_tabs;
|
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
g_object_get (browser->settings,
|
2008-04-16 23:38:22 +00:00
|
|
|
"remember-last-window-size", &remember_last_window_size,
|
|
|
|
"last-window-width", &last_window_width,
|
|
|
|
"last-window-height", &last_window_height,
|
|
|
|
"last-panel-position", &last_panel_position,
|
|
|
|
"last-panel-page", &last_panel_page,
|
|
|
|
"show-navigationbar", &show_navigationbar,
|
|
|
|
"show-bookmarkbar", &show_bookmarkbar,
|
|
|
|
"show-panel", &show_panel,
|
|
|
|
"show-statusbar", &show_statusbar,
|
|
|
|
"show-new-tab", &show_new_tab,
|
2008-05-20 01:21:11 +00:00
|
|
|
"show-homepage", &show_homepage,
|
2008-04-16 23:38:22 +00:00
|
|
|
"show-web-search", &show_web_search,
|
|
|
|
"show-trash", &show_trash,
|
|
|
|
"toolbar-style", &toolbar_style,
|
|
|
|
"last-web-search", &last_web_search,
|
|
|
|
"last-pageholder-uri", &last_pageholder_uri,
|
2008-07-13 19:49:57 +00:00
|
|
|
"close-buttons-on-tabs", &close_buttons_on_tabs,
|
2008-04-16 23:38:22 +00:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
GdkScreen* screen = gtk_window_get_screen (GTK_WINDOW (browser));
|
|
|
|
const gint default_width = (gint)gdk_screen_get_width (screen) / 1.7;
|
|
|
|
const gint default_height = (gint)gdk_screen_get_height (screen) / 1.7;
|
|
|
|
|
|
|
|
if (remember_last_window_size)
|
|
|
|
{
|
|
|
|
if (last_window_width && last_window_height)
|
|
|
|
gtk_window_set_default_size (GTK_WINDOW (browser),
|
|
|
|
last_window_width, last_window_height);
|
|
|
|
else
|
|
|
|
gtk_window_set_default_size (GTK_WINDOW (browser),
|
|
|
|
default_width, default_height);
|
|
|
|
}
|
|
|
|
|
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-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,
|
|
|
|
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);
|
2008-06-15 02:02:56 +00:00
|
|
|
}
|
2008-04-16 23:38:22 +00:00
|
|
|
|
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);
|
2008-06-19 18:39:00 +00:00
|
|
|
midori_panel_set_current_page (MIDORI_PANEL (browser->panel), last_panel_page);
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_view_set_uri (MIDORI_VIEW (browser->panel_pageholder),
|
|
|
|
last_pageholder_uri);
|
2008-04-16 23:38:22 +00:00
|
|
|
|
|
|
|
_action_set_active (browser, "Navigationbar", show_navigationbar);
|
|
|
|
_action_set_active (browser, "Bookmarkbar", show_bookmarkbar);
|
|
|
|
_action_set_active (browser, "Panel", show_panel);
|
|
|
|
_action_set_active (browser, "Statusbar", show_statusbar);
|
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
sokoke_widget_set_visible (browser->button_tab_new, show_new_tab);
|
|
|
|
sokoke_widget_set_visible (browser->button_homepage, show_homepage);
|
|
|
|
sokoke_widget_set_visible (browser->search, show_web_search);
|
|
|
|
sokoke_widget_set_visible (browser->button_trash, show_trash);
|
2008-04-16 23:38:22 +00:00
|
|
|
|
|
|
|
g_free (last_pageholder_uri);
|
|
|
|
}
|
|
|
|
|
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-06-19 18:39:00 +00:00
|
|
|
g_object_get_property (G_OBJECT (browser->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-03 23:45:17 +00:00
|
|
|
else if (name == g_intern_string ("always-show-tabbar"))
|
|
|
|
_toggle_tabbar_smartly (browser);
|
2008-04-22 20:19:24 +00:00
|
|
|
else if (name == g_intern_string ("show-new-tab"))
|
2008-06-19 18:39:00 +00:00
|
|
|
sokoke_widget_set_visible (browser->button_tab_new,
|
2008-04-22 20:19:24 +00:00
|
|
|
g_value_get_boolean (&value));
|
2008-05-20 01:21:11 +00:00
|
|
|
else if (name == g_intern_string ("show-homepage"))
|
2008-06-19 18:39:00 +00:00
|
|
|
sokoke_widget_set_visible (browser->button_homepage,
|
2008-05-20 01:21:11 +00:00
|
|
|
g_value_get_boolean (&value));
|
2008-04-22 20:19:24 +00:00
|
|
|
else if (name == g_intern_string ("show-web-search"))
|
2008-06-19 18:39:00 +00:00
|
|
|
sokoke_widget_set_visible (browser->search,
|
2008-04-22 20:19:24 +00:00
|
|
|
g_value_get_boolean (&value));
|
|
|
|
else if (name == g_intern_string ("show-trash"))
|
2008-06-19 18:39:00 +00:00
|
|
|
sokoke_widget_set_visible (browser->button_trash,
|
2008-04-22 20:19:24 +00:00
|
|
|
g_value_get_boolean (&value));
|
|
|
|
else if (!g_object_class_find_property (G_OBJECT_GET_CLASS (web_settings),
|
|
|
|
name))
|
2008-04-25 19:31:57 +00:00
|
|
|
g_warning (_("Unexpected setting '%s'"), name);
|
2008-04-22 20:19:24 +00:00
|
|
|
g_value_unset (&value);
|
|
|
|
}
|
|
|
|
|
2008-09-03 00:28:54 +00:00
|
|
|
static void
|
|
|
|
midori_browser_load_bookmarks (MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
guint i, n;
|
2008-10-01 02:00:16 +00:00
|
|
|
KatzeItem* item;
|
2008-09-03 00:28:54 +00:00
|
|
|
const gchar* title;
|
|
|
|
const gchar* desc;
|
|
|
|
GtkToolItem* toolitem;
|
|
|
|
GtkTreeModel* treestore;
|
|
|
|
|
|
|
|
// FIXME: Clear bookmarks menu
|
|
|
|
// FIXME: Clear bookmarkbar
|
|
|
|
// FIXME: Clear bookmark panel
|
|
|
|
|
|
|
|
_action_set_sensitive (browser, "BookmarkAdd", FALSE);
|
|
|
|
|
|
|
|
if (!browser->bookmarks)
|
|
|
|
return;
|
|
|
|
|
2008-10-01 02:00:16 +00:00
|
|
|
n = katze_array_get_length (browser->bookmarks);
|
2008-09-03 00:28:54 +00:00
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
2008-10-01 02:00:16 +00:00
|
|
|
item = katze_array_get_nth_item (browser->bookmarks, i);
|
|
|
|
title = katze_item_get_name (item);
|
|
|
|
desc = katze_item_get_text (item);
|
|
|
|
|
|
|
|
if (KATZE_IS_ARRAY (item))
|
2008-09-03 00:28:54 +00:00
|
|
|
{
|
|
|
|
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_DIRECTORY);
|
|
|
|
gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem), title);
|
|
|
|
gtk_tool_item_set_is_important (toolitem, TRUE);
|
|
|
|
g_signal_connect (toolitem, "clicked",
|
|
|
|
G_CALLBACK (midori_browser_bookmarkbar_folder_activate_cb),
|
|
|
|
browser);
|
|
|
|
if (desc && *desc)
|
|
|
|
gtk_tool_item_set_tooltip_text (toolitem, desc);
|
2008-10-01 02:00:16 +00:00
|
|
|
g_object_set_data (G_OBJECT (toolitem), "KatzeArray", item);
|
|
|
|
}
|
|
|
|
else if (katze_item_get_uri (item))
|
|
|
|
{
|
2008-09-03 00:28:54 +00:00
|
|
|
toolitem = gtk_tool_button_new_from_stock (STOCK_BOOKMARK);
|
|
|
|
gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem), title);
|
|
|
|
gtk_tool_item_set_is_important (toolitem, TRUE);
|
|
|
|
g_signal_connect (toolitem, "clicked",
|
|
|
|
G_CALLBACK (midori_browser_menu_bookmarks_item_activate_cb),
|
|
|
|
browser);
|
|
|
|
if (desc && *desc)
|
|
|
|
gtk_tool_item_set_tooltip_text (toolitem, desc);
|
2008-10-01 02:00:16 +00:00
|
|
|
g_object_set_data (G_OBJECT (toolitem), "KatzeItem", item);
|
2008-09-03 00:28:54 +00:00
|
|
|
}
|
2008-10-01 02:00:16 +00:00
|
|
|
else
|
|
|
|
toolitem = gtk_separator_tool_item_new ();
|
2008-09-03 00:28:54 +00:00
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (browser->bookmarkbar), toolitem, -1);
|
|
|
|
}
|
|
|
|
sokoke_container_show_children (GTK_CONTAINER (browser->bookmarkbar));
|
|
|
|
|
|
|
|
treestore = gtk_tree_view_get_model (GTK_TREE_VIEW (browser->panel_bookmarks));
|
|
|
|
_tree_store_insert_folder (GTK_TREE_STORE (treestore),
|
|
|
|
NULL, browser->bookmarks);
|
|
|
|
midori_panel_bookmarks_cursor_or_row_changed_cb (
|
|
|
|
GTK_TREE_VIEW (browser->panel_bookmarks), browser);
|
|
|
|
|
|
|
|
_action_set_sensitive (browser, "BookmarkAdd", TRUE);
|
|
|
|
}
|
|
|
|
|
2008-10-07 00:19:33 +00:00
|
|
|
static void
|
|
|
|
_tree_store_insert_history_item (GtkTreeStore* treestore,
|
|
|
|
GtkTreeIter* parent,
|
|
|
|
KatzeItem* item)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
KatzeItem* child;
|
|
|
|
guint i, n;
|
|
|
|
GtkTreeIter* piter;
|
|
|
|
|
|
|
|
g_return_if_fail (KATZE_IS_ITEM (item));
|
|
|
|
|
|
|
|
if (KATZE_IS_ARRAY (item))
|
|
|
|
{
|
|
|
|
piter = parent;
|
|
|
|
if (katze_item_get_added (item))
|
|
|
|
{
|
|
|
|
gtk_tree_store_insert_with_values (treestore, &iter, parent, 0, 0, item, -1);
|
|
|
|
g_object_unref (item);
|
|
|
|
piter = &iter;
|
|
|
|
}
|
|
|
|
n = katze_array_get_length (KATZE_ARRAY (item));
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
|
|
|
child = katze_array_get_nth_item (KATZE_ARRAY (item), i);
|
|
|
|
_tree_store_insert_history_item (treestore, piter, child);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_tree_store_insert_with_values (treestore, &iter, parent, 0, 0, item, -1);
|
|
|
|
g_object_unref (item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_new_history_item (MidoriBrowser* browser,
|
|
|
|
KatzeItem* item)
|
|
|
|
{
|
|
|
|
GtkTreeView* treeview;
|
|
|
|
GtkTreeModel* treemodel;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
KatzeArray* parent;
|
|
|
|
gint i;
|
|
|
|
gboolean found;
|
|
|
|
time_t now;
|
|
|
|
gchar newdate [70];
|
|
|
|
gchar *today;
|
|
|
|
gsize len;
|
|
|
|
|
|
|
|
treeview = GTK_TREE_VIEW (browser->panel_history);
|
|
|
|
treemodel = gtk_tree_view_get_model (treeview);
|
|
|
|
|
|
|
|
now = time (NULL);
|
|
|
|
strftime (newdate, sizeof (newdate), "%Y-%m-%d %H:%M:%S", localtime (&now));
|
|
|
|
katze_item_set_added (item, newdate);
|
|
|
|
|
|
|
|
len = (g_strrstr (newdate, " ") - newdate);
|
|
|
|
today = g_strndup (newdate, len);
|
|
|
|
|
|
|
|
found = FALSE;
|
|
|
|
i = 0;
|
|
|
|
while (gtk_tree_model_iter_nth_child (treemodel, &iter, NULL, i++))
|
|
|
|
{
|
|
|
|
gtk_tree_model_get (treemodel, &iter, 0, &parent, -1);
|
|
|
|
if (g_ascii_strcasecmp (today,
|
|
|
|
katze_item_get_added (KATZE_ITEM (parent))) == 0)
|
|
|
|
{
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
g_object_unref (parent);
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
{
|
|
|
|
parent = katze_array_new (KATZE_TYPE_ARRAY);
|
|
|
|
katze_item_set_added (KATZE_ITEM (parent), today);
|
|
|
|
katze_array_add_item (browser->history, parent);
|
|
|
|
katze_array_add_item (parent, item);
|
|
|
|
_tree_store_insert_history_item (GTK_TREE_STORE (treemodel), NULL,
|
|
|
|
KATZE_ITEM (parent));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_tree_store_insert_history_item (GTK_TREE_STORE (treemodel),
|
|
|
|
&iter, item);
|
|
|
|
katze_array_add_item (parent, item);
|
|
|
|
g_object_unref (parent);
|
|
|
|
}
|
|
|
|
g_free (today);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
midori_browser_load_history (MidoriBrowser* browser)
|
|
|
|
{
|
|
|
|
GtkTreeView* treeview;
|
|
|
|
GtkTreeModel* treemodel;
|
|
|
|
|
|
|
|
if (!browser->history)
|
|
|
|
return;
|
|
|
|
|
|
|
|
treeview = GTK_TREE_VIEW (browser->panel_history);
|
|
|
|
treemodel = gtk_tree_view_get_model (treeview);
|
|
|
|
|
|
|
|
_tree_store_insert_history_item (GTK_TREE_STORE (treemodel),
|
|
|
|
NULL, KATZE_ITEM (browser->history));
|
|
|
|
}
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
static void
|
|
|
|
midori_browser_set_property (GObject* object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue* value,
|
|
|
|
GParamSpec* pspec)
|
|
|
|
{
|
|
|
|
MidoriBrowser* browser = MIDORI_BROWSER (object);
|
2008-06-15 23:13:27 +00:00
|
|
|
guint last_web_search;
|
2008-08-23 16:32:53 +00:00
|
|
|
KatzeItem* item;
|
2008-03-10 21:26:09 +00:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2008-07-23 18:17:13 +00:00
|
|
|
case PROP_URI:
|
|
|
|
_midori_browser_open_uri (browser, g_value_get_string (value));
|
|
|
|
break;
|
2008-05-02 20:30:26 +00:00
|
|
|
case PROP_TAB:
|
|
|
|
midori_browser_set_current_tab (browser, g_value_get_object (value));
|
|
|
|
break;
|
2008-03-10 21:26:09 +00:00
|
|
|
case PROP_STATUSBAR_TEXT:
|
|
|
|
_midori_browser_set_statusbar_text (browser, g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
case PROP_SETTINGS:
|
2008-06-19 18:39:00 +00:00
|
|
|
if (browser->settings)
|
|
|
|
g_signal_handlers_disconnect_by_func (browser->settings,
|
2008-04-22 20:19:24 +00:00
|
|
|
midori_browser_settings_notify,
|
|
|
|
browser);
|
2008-06-19 18:39:00 +00:00
|
|
|
katze_object_assign (browser->settings, g_value_get_object (value));
|
|
|
|
g_object_ref (browser->settings);
|
2008-04-16 23:38:22 +00:00
|
|
|
_midori_browser_update_settings (browser);
|
2008-06-19 18:39:00 +00:00
|
|
|
g_signal_connect (browser->settings, "notify",
|
2008-04-22 20:19:24 +00:00
|
|
|
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:
|
|
|
|
; /* FIXME: Disconnect handlers */
|
|
|
|
katze_object_assign (browser->bookmarks, g_value_get_object (value));
|
|
|
|
g_object_ref (browser->bookmarks);
|
2008-10-10 20:31:37 +00:00
|
|
|
g_object_set (_action_by_name (browser, "Bookmarks"), "array",
|
|
|
|
browser->bookmarks, NULL);
|
2008-09-03 00:28:54 +00:00
|
|
|
midori_browser_load_bookmarks (browser);
|
|
|
|
/* FIXME: Connect to updates */
|
|
|
|
break;
|
2008-03-10 21:26:09 +00:00
|
|
|
case PROP_TRASH:
|
2008-06-14 00:23:33 +00:00
|
|
|
; /* FIXME: Disconnect handlers */
|
2008-06-19 18:39:00 +00:00
|
|
|
katze_object_assign (browser->trash, g_value_get_object (value));
|
|
|
|
g_object_ref (browser->trash);
|
2008-10-10 20:31:37 +00:00
|
|
|
g_object_set (_action_by_name (browser, "Trash"), "array",
|
|
|
|
browser->trash, NULL);
|
2008-06-14 00:23:33 +00:00
|
|
|
/* FIXME: Connect to updates */
|
2008-03-10 21:26:09 +00:00
|
|
|
_midori_browser_update_actions (browser);
|
|
|
|
break;
|
2008-06-15 02:02:56 +00:00
|
|
|
case PROP_SEARCH_ENGINES:
|
|
|
|
; /* FIXME: Disconnect handlers */
|
2008-06-19 18:39:00 +00:00
|
|
|
katze_object_assign (browser->search_engines, g_value_get_object (value));
|
|
|
|
g_object_ref (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 */
|
2008-06-19 18:39:00 +00:00
|
|
|
if (browser->settings)
|
2008-06-15 23:13:27 +00:00
|
|
|
{
|
2008-06-19 18:39:00 +00:00
|
|
|
g_object_get (browser->settings, "last-web-search",
|
2008-06-15 23:13:27 +00:00
|
|
|
&last_web_search, NULL);
|
2008-08-25 23:19:38 +00:00
|
|
|
item = katze_array_get_nth_item (browser->search_engines,
|
|
|
|
last_web_search);
|
2008-10-05 21:25:02 +00:00
|
|
|
midori_search_action_set_current_item (MIDORI_SEARCH_ACTION (
|
|
|
|
_action_by_name (browser, "Search")), item);
|
2008-06-15 23:13:27 +00:00
|
|
|
}
|
2008-06-15 02:02:56 +00:00
|
|
|
break;
|
2008-10-07 00:19:33 +00:00
|
|
|
case PROP_HISTORY:
|
|
|
|
; /* FIXME: Disconnect handlers */
|
|
|
|
katze_object_assign (browser->history, g_value_get_object (value));
|
2008-10-10 20:31:37 +00:00
|
|
|
g_object_ref (browser->history);
|
2008-10-07 00:19:33 +00:00
|
|
|
midori_browser_load_history (browser);
|
2008-10-10 20:31:37 +00:00
|
|
|
g_object_set (_action_by_name (browser, "RecentlyVisited"), "array",
|
|
|
|
browser->history, NULL);
|
2008-10-07 00:19:33 +00:00
|
|
|
/* FIXME: Connect to updates */
|
|
|
|
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-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;
|
|
|
|
case PROP_STATUSBAR:
|
2008-06-19 18:39:00 +00:00
|
|
|
g_value_set_object (value, browser->statusbar);
|
2008-05-02 20:30:26 +00:00
|
|
|
break;
|
2008-03-10 21:26:09 +00:00
|
|
|
case PROP_STATUSBAR_TEXT:
|
2008-06-19 18:39:00 +00:00
|
|
|
g_value_set_string (value, browser->statusbar_text);
|
2008-03-10 21:26:09 +00:00
|
|
|
break;
|
|
|
|
case PROP_SETTINGS:
|
2008-06-19 18:39:00 +00:00
|
|
|
g_value_set_object (value, browser->settings);
|
2008-03-10 21:26:09 +00:00
|
|
|
break;
|
2008-09-03 00:28:54 +00:00
|
|
|
case PROP_BOOKMARKS:
|
|
|
|
g_value_set_object (value, browser->bookmarks);
|
|
|
|
break;
|
2008-03-10 21:26:09 +00:00
|
|
|
case PROP_TRASH:
|
2008-06-19 18:39:00 +00:00
|
|
|
g_value_set_object (value, browser->trash);
|
2008-03-10 21:26:09 +00:00
|
|
|
break;
|
2008-06-15 02:02:56 +00:00
|
|
|
case PROP_SEARCH_ENGINES:
|
2008-06-19 18:39:00 +00:00
|
|
|
g_value_set_object (value, browser->search_engines);
|
2008-06-15 02:02:56 +00:00
|
|
|
break;
|
2008-10-07 00:19:33 +00:00
|
|
|
case PROP_HISTORY:
|
|
|
|
g_value_set_object (value, browser->history);
|
|
|
|
break;
|
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-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-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.
|
|
|
|
*
|
|
|
|
* Note: Currently this will always be a #MidoriWebView.
|
|
|
|
*
|
|
|
|
* Return value: the index of the new tab, or -1 in case of an error
|
|
|
|
**/
|
|
|
|
gint
|
|
|
|
midori_browser_add_item (MidoriBrowser* browser,
|
|
|
|
KatzeItem* item)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
const gchar* uri;
|
|
|
|
const gchar* title;
|
|
|
|
GtkWidget* view;
|
|
|
|
|
|
|
|
g_return_val_if_fail (KATZE_IS_ITEM (item), -1);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
uri = katze_item_get_uri (item);
|
|
|
|
title = katze_item_get_name (item);
|
|
|
|
view = g_object_new (MIDORI_TYPE_VIEW,
|
|
|
|
"title", title,
|
|
|
|
"settings", browser->settings,
|
|
|
|
NULL);
|
|
|
|
midori_view_set_uri (MIDORI_VIEW (view), uri);
|
|
|
|
gtk_widget_show (view);
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
return midori_browser_add_tab (browser, view);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-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
|
|
|
* Note: Currently this will always be a #MidoriView.
|
|
|
|
*
|
|
|
|
* Return value: the index of the new view, or -1
|
2008-03-10 21:26:09 +00:00
|
|
|
**/
|
|
|
|
gint
|
2008-05-31 22:21:08 +00:00
|
|
|
midori_browser_add_uri (MidoriBrowser* browser,
|
|
|
|
const gchar* uri)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view;
|
2008-03-10 21:26:09 +00:00
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
view = g_object_new (MIDORI_TYPE_VIEW,
|
|
|
|
"settings", browser->settings,
|
|
|
|
NULL);
|
|
|
|
midori_view_set_uri (MIDORI_VIEW (view), uri);
|
|
|
|
gtk_widget_show (view);
|
2008-07-23 18:17:13 +00:00
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
return midori_browser_add_tab (browser, view);
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
2008-04-25 19:31:57 +00:00
|
|
|
/**
|
|
|
|
* midori_browser_activate_action:
|
|
|
|
* @browser: a #MidoriBrowser
|
|
|
|
* @name: name of the action
|
|
|
|
*
|
|
|
|
* Activates the specified action.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
midori_browser_activate_action (MidoriBrowser* browser,
|
|
|
|
const gchar* name)
|
|
|
|
{
|
2008-06-15 02:02:56 +00:00
|
|
|
g_signal_emit (browser, signals[ACTIVATE_ACTION], 0, name);
|
2008-04-25 19:31:57 +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);
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
view = midori_browser_get_current_tab (browser);
|
|
|
|
return midori_view_get_display_uri (MIDORI_VIEW (view));
|
2008-07-23 18:17:13 +00:00
|
|
|
}
|
|
|
|
|
2008-04-24 22:20:43 +00:00
|
|
|
/**
|
|
|
|
* midori_browser_set_current_page:
|
|
|
|
* @browser: a #MidoriBrowser
|
|
|
|
* @n: the index of a page
|
|
|
|
*
|
|
|
|
* Switches to the page with the index @n.
|
|
|
|
*
|
|
|
|
* The widget will also grab the focus automatically.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
midori_browser_set_current_page (MidoriBrowser* browser,
|
|
|
|
gint n)
|
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view;
|
|
|
|
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_notebook_set_current_page (GTK_NOTEBOOK (browser->notebook), n);
|
2008-09-26 21:13:46 +00:00
|
|
|
view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), n);
|
|
|
|
if (view && midori_view_is_blank (MIDORI_VIEW (view)))
|
2008-08-14 23:57:48 +00:00
|
|
|
gtk_action_activate (_action_by_name (browser, "Location"));
|
2008-04-25 19:31:57 +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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* midori_browser_set_current_tab:
|
|
|
|
* @browser: a #MidoriBrowser
|
2008-09-26 21:13:46 +00:00
|
|
|
* @view: a #GtkWidget
|
2008-05-02 20:30:26 +00:00
|
|
|
*
|
2008-09-26 21:13:46 +00:00
|
|
|
* Switches to the page containing @view.
|
2008-05-02 20:30:26 +00:00
|
|
|
*
|
|
|
|
* The widget will also grab the focus automatically.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
midori_browser_set_current_tab (MidoriBrowser* browser,
|
2008-09-26 21:13:46 +00:00
|
|
|
GtkWidget* view)
|
2008-05-02 20:30:26 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
gint n;
|
|
|
|
|
|
|
|
g_return_if_fail (MIDORI_IS_BROWSER (browser));
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (view));
|
|
|
|
|
|
|
|
n = gtk_notebook_page_num (GTK_NOTEBOOK (browser->notebook), view);
|
2008-06-19 18:39:00 +00:00
|
|
|
gtk_notebook_set_current_page (GTK_NOTEBOOK (browser->notebook), n);
|
2008-09-26 21:13:46 +00:00
|
|
|
if (view && midori_view_is_blank (MIDORI_VIEW (view)))
|
2008-08-14 23:57:48 +00:00
|
|
|
gtk_action_activate (_action_by_name (browser, "Location"));
|
2008-05-02 20:30:26 +00:00
|
|
|
else
|
2008-09-26 21:13:46 +00:00
|
|
|
gtk_widget_grab_focus (view);
|
2008-05-02 20:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* midori_browser_get_current_tab:
|
|
|
|
* @browser: a #MidoriBrowser
|
|
|
|
*
|
|
|
|
* Retrieves the currently selected tab.
|
|
|
|
*
|
|
|
|
* If there is no tab present at all, %NULL is returned.
|
|
|
|
*
|
2008-09-26 21:13:46 +00:00
|
|
|
* See also midori_browser_get_current_page().
|
|
|
|
*
|
2008-05-02 20:30:26 +00:00
|
|
|
* Return value: the selected tab, or %NULL
|
|
|
|
**/
|
|
|
|
GtkWidget*
|
|
|
|
midori_browser_get_current_tab (MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
gint n;
|
|
|
|
|
2008-03-10 21:26:09 +00:00
|
|
|
g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
n = gtk_notebook_get_current_page (GTK_NOTEBOOK (browser->notebook));
|
2008-05-02 20:30:26 +00:00
|
|
|
if (n >= 0)
|
|
|
|
{
|
2008-09-26 21:13:46 +00:00
|
|
|
return gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), n);
|
2008-05-02 20:30:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return NULL;
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-09-26 21:13:46 +00:00
|
|
|
* midori_browser_get_proxy_array:
|
2008-03-10 21:26:09 +00:00
|
|
|
* @browser: a #MidoriBrowser
|
|
|
|
*
|
2008-09-26 21:13:46 +00:00
|
|
|
* Retrieves a proxy array representing the respective proxy items
|
|
|
|
* of the present views that can be used for session management.
|
2008-03-10 21:26:09 +00:00
|
|
|
*
|
2008-10-10 20:31:37 +00:00
|
|
|
* The array is updated automatically.
|
2008-03-10 21:26:09 +00:00
|
|
|
*
|
2008-07-25 10:45:50 +00:00
|
|
|
* Note: Calling this function doesn't add a reference and the browser
|
|
|
|
* may release its reference at some point.
|
|
|
|
*
|
2008-09-03 22:35:15 +00:00
|
|
|
* Return value: the proxy #KatzeArray
|
2008-03-10 21:26:09 +00:00
|
|
|
**/
|
2008-09-03 22:35:15 +00:00
|
|
|
KatzeArray*
|
2008-09-26 21:13:46 +00:00
|
|
|
midori_browser_get_proxy_array (MidoriBrowser* browser)
|
2008-03-10 21:26:09 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
|
|
|
|
|
2008-09-26 21:13:46 +00:00
|
|
|
return browser->proxy_array;
|
2008-03-10 21:26:09 +00:00
|
|
|
}
|
2008-05-31 22:21:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
}
|