[epiphany/uncrustify: 2/3] Uncrustify
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/uncrustify: 2/3] Uncrustify
- Date: Tue, 22 Mar 2016 04:50:38 +0000 (UTC)
commit 76b1c82ce5b663e24577d00afe1a224287c796ea
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Mon Mar 21 23:13:34 2016 -0500
Uncrustify
For a better future. Apologies when your 'git blame' resolves to this.
I'm actually really impressed how well uncrustify works. This required
only a little one-time manual work to avoid extra space in 'else {'.
This breaks function prototype alignment, but we should get rid of most
of those anyway.
We decided to start aligning function parameters, like other GNOME
applications. It looks nicer this way, and I couldn't teach uncrustify
the previous Epiphany style.
embed/ephy-about-handler.c | 91 +-
embed/ephy-download.c | 207 +-
embed/ephy-downloads-manager.c | 5 +-
embed/ephy-embed-container.c | 10 +-
embed/ephy-embed-event.c | 17 +-
embed/ephy-embed-prefs.c | 185 +-
embed/ephy-embed-shell.c | 172 +-
embed/ephy-embed-utils.c | 28 +-
embed/ephy-embed.c | 135 +-
embed/ephy-encoding.c | 122 +-
embed/ephy-encodings.c | 193 +-
embed/ephy-file-monitor.c | 40 +-
embed/ephy-find-toolbar.c | 799 ++--
embed/ephy-web-extension-proxy.c | 106 +-
embed/ephy-web-view.c | 520 +-
embed/web-extension/ephy-embed-form-auth.c | 7 +-
embed/web-extension/ephy-uri-tester.c | 649 ++--
embed/web-extension/ephy-web-dom-utils.c | 38 +-
embed/web-extension/ephy-web-extension-main.c | 2 +-
embed/web-extension/ephy-web-extension.c | 142 +-
embed/web-extension/ephy-web-overview-model.c | 22 +-
embed/web-extension/ephy-web-overview.c | 63 +-
lib/egg/eggtreemultidnd.c | 270 +-
lib/ephy-debug.c | 268 +-
lib/ephy-dnd.c | 109 +-
lib/ephy-file-helpers.c | 1226 +++---
lib/ephy-form-auth-data.c | 61 +-
lib/ephy-gui.c | 535 +-
lib/ephy-initial-state.c | 75 +-
lib/ephy-langs.c | 451 +-
lib/ephy-node-db.c | 512 +-
lib/ephy-node-filter.c | 604 ++--
lib/ephy-node.c | 1814 ++++----
lib/ephy-nss-glue.c | 89 +-
lib/ephy-profile-migrator.c | 106 +-
lib/ephy-profile-utils.c | 6 +-
lib/ephy-security-levels.c | 28 +-
lib/ephy-signal-accumulator.c | 81 +-
lib/ephy-smaps.c | 30 +-
lib/ephy-snapshot-service.c | 149 +-
lib/ephy-sqlite-connection.c | 8 +-
lib/ephy-sqlite-statement.c | 9 +-
lib/ephy-string.c | 36 +-
lib/ephy-time-helpers.c | 370 +-
lib/ephy-uri-helpers.c | 46 +-
lib/ephy-web-app-utils.c | 30 +-
lib/ephy-zoom.c | 2 +-
lib/history/ephy-history-service-hosts-table.c | 80 +-
lib/history/ephy-history-service-urls-table.c | 124 +-
lib/history/ephy-history-service-visits-table.c | 34 +-
lib/history/ephy-history-service.c | 206 +-
lib/history/ephy-history-types.c | 8 +-
lib/widgets/ephy-certificate-dialog.c | 106 +-
lib/widgets/ephy-download-widget.c | 135 +-
lib/widgets/ephy-downloads-popover.c | 3 +-
lib/widgets/ephy-downloads-progress-icon.c | 3 +-
lib/widgets/ephy-file-chooser.c | 343 +-
lib/widgets/ephy-location-entry.c | 2062 ++++----
lib/widgets/ephy-middle-clickable-button.c | 11 +-
lib/widgets/ephy-node-view.c | 2657 +++++-----
lib/widgets/ephy-security-popover.c | 130 +-
lib/widgets/ephy-tree-model-node.c | 653 ++--
lib/widgets/ephy-tree-model-sort.c | 164 +-
lib/widgets/ephy-zoom-action.c | 245 +-
lib/widgets/nautilus-floating-bar.c | 658 ++--
src/bookmarks/ephy-bookmark-action-group.c | 201 +-
src/bookmarks/ephy-bookmark-action.c | 620 ++--
src/bookmarks/ephy-bookmark-properties.c | 696 ++--
src/bookmarks/ephy-bookmarks-editor.c | 2737 +++++-----
src/bookmarks/ephy-bookmarks-export.c | 859 ++--
src/bookmarks/ephy-bookmarks-import.c | 1596 +++----
src/bookmarks/ephy-bookmarks-menu.c | 384 +-
src/bookmarks/ephy-bookmarks-ui.c | 486 +-
src/bookmarks/ephy-bookmarks.c | 2409 +++++-----
src/bookmarks/ephy-nodes-cover.c | 271 +-
src/bookmarks/ephy-open-tabs-action.c | 163 +-
src/bookmarks/ephy-topic-action-group.c | 139 +-
src/bookmarks/ephy-topic-action.c | 450 +-
src/bookmarks/ephy-topics-entry.c | 935 ++--
src/bookmarks/ephy-topics-palette.c | 498 +-
src/clear-data-dialog.c | 171 +-
src/cookies-dialog.c | 539 +-
src/ephy-action-helper.c | 40 +-
src/ephy-combined-stop-reload-action.c | 27 +-
src/ephy-completion-model.c | 100 +-
src/ephy-encoding-dialog.c | 589 +--
src/ephy-encoding-row.c | 118 +-
src/ephy-history-window.c | 1002 ++--
src/ephy-home-action.c | 78 +-
src/ephy-link-action.c | 140 +-
src/ephy-link.c | 120 +-
src/ephy-location-controller.c | 1205 +++---
src/ephy-lockdown.c | 31 +-
src/ephy-main.c | 72 +-
src/ephy-navigation-history-action.c | 124 +-
src/ephy-notebook.c | 1242 +++---
src/ephy-search-provider-main.c | 2 +-
src/ephy-search-provider.c | 179 +-
src/ephy-session.c | 2160 ++++----
src/ephy-shell.c | 134 +-
src/ephy-title-box.c | 36 +-
src/ephy-toolbar.c | 92 +-
src/ephy-window-action.c | 72 +-
src/ephy-window.c | 5449 ++++++++++----------
src/passwords-dialog.c | 667 ++--
src/popup-commands.c | 522 +-
src/prefs-dialog.c | 1916 ++++----
src/window-commands.c | 2298 ++++-----
tests/.deps/ephy-bookmarks-test.Po | 1 +
tests/.deps/ephy-completion-model-test.Po | 1 +
tests/.deps/ephy-download-test.Po | 1 +
tests/.deps/ephy-embed-shell-test.Po | 1 +
tests/.deps/ephy-embed-utils-test.Po | 1 +
tests/.deps/ephy-encodings-test.Po | 1 +
tests/.deps/ephy-history-test.Po | 1 +
tests/.deps/ephy-location-entry-test.Po | 1 +
tests/.deps/ephy-migration-test.Po | 1 +
tests/.deps/ephy-sqlite-test.Po | 1 +
tests/.deps/ephy-string-test.Po | 1 +
tests/.deps/ephy-uri-helpers-test.Po | 1 +
tests/.deps/ephy-web-view-test.Po | 1 +
tests/.deps/epiphany-resources.Po | 1 +
...est_ephy_file_helpers-ephy-file-helpers-test.Po | 1 +
tests/Makefile | 1233 +++++
tests/data/Makefile | 509 ++
tests/ephy-bookmarks-test.c | 7 +-
tests/ephy-completion-model-test.c | 48 +-
tests/ephy-download-test.c | 18 +-
tests/ephy-embed-shell-test.c | 48 +-
tests/ephy-embed-utils-test.c | 4 +-
tests/ephy-file-helpers-test.c | 2 +-
tests/ephy-history-test.c | 64 +-
tests/ephy-migration-test.c | 12 +-
tests/ephy-session-test.c | 308 +-
tests/ephy-shell-test.c | 48 +-
tests/ephy-snapshot-service-test.c | 27 +-
tests/ephy-sqlite-test.c | 14 +-
tests/ephy-test-utils.c | 11 +-
tests/ephy-uri-helpers-test.c | 3 +-
tests/ephy-web-view-test.c | 114 +-
140 files changed, 26124 insertions(+), 26020 deletions(-)
---
diff --git a/embed/ephy-about-handler.c b/embed/ephy-about-handler.c
index b64fcb0..791926e 100644
--- a/embed/ephy-about-handler.c
+++ b/embed/ephy-about-handler.c
@@ -34,8 +34,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
-struct _EphyAboutHandler
-{
+struct _EphyAboutHandler {
GObject parent_instance;
EphySMaps *smaps;
@@ -79,8 +78,8 @@ ephy_about_handler_get_smaps (EphyAboutHandler *handler)
static void
ephy_about_handler_finish_request (WebKitURISchemeRequest *request,
- gchar *data,
- gssize data_length)
+ gchar *data,
+ gssize data_length)
{
GInputStream *stream;
@@ -96,7 +95,7 @@ typedef struct {
} EphyAboutRequest;
static EphyAboutRequest *
-ephy_about_request_new (EphyAboutHandler *handler,
+ephy_about_request_new (EphyAboutHandler *handler,
WebKitURISchemeRequest *request)
{
EphyAboutRequest *about_request;
@@ -119,7 +118,7 @@ ephy_about_request_free (EphyAboutRequest *about_request)
static void
get_plugins_cb (WebKitWebContext *web_context,
- GAsyncResult *result,
+ GAsyncResult *result,
EphyAboutRequest *about_request)
{
GString *data_str;
@@ -132,7 +131,7 @@ get_plugins_cb (WebKitWebContext *web_context,
data_str = g_string_new ("<html>");
g_string_append_printf (data_str, "<head><title>%s</title>"
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"
- "<link href=\""EPHY_PAGE_TEMPLATE_ABOUT_CSS"\" rel=\"stylesheet\"
type=\"text/css\">"
+ "<link href=\""EPHY_PAGE_TEMPLATE_ABOUT_CSS "\" rel=\"stylesheet\"
type=\"text/css\">"
"</head><body>",
_("Installed plugins"));
g_string_append_printf (data_str, "<h1>%s</h1>", _("Plugins"));
@@ -157,7 +156,7 @@ get_plugins_cb (WebKitWebContext *web_context,
mime_types = webkit_plugin_get_mime_info_list (plugin);
for (m = mime_types; m; m = m->next) {
- WebKitMimeInfo *mime_info = (WebKitMimeInfo *) m->data;
+ WebKitMimeInfo *mime_info = (WebKitMimeInfo *)m->data;
const gchar * const *extensions;
guint i;
@@ -185,7 +184,7 @@ get_plugins_cb (WebKitWebContext *web_context,
}
static gboolean
-ephy_about_handler_handle_plugins (EphyAboutHandler *handler,
+ephy_about_handler_handle_plugins (EphyAboutHandler *handler,
WebKitURISchemeRequest *request)
{
EphyEmbedShell *shell = ephy_embed_shell_get_default ();
@@ -199,8 +198,8 @@ ephy_about_handler_handle_plugins (EphyAboutHandler *handler,
}
static void
-handle_memory_finished_cb (EphyAboutHandler *handler,
- GAsyncResult *result,
+handle_memory_finished_cb (EphyAboutHandler *handler,
+ GAsyncResult *result,
WebKitURISchemeRequest *request)
{
GString *data_str;
@@ -213,7 +212,7 @@ handle_memory_finished_cb (EphyAboutHandler *handler,
if (memory) {
g_string_append_printf (data_str, "<head><title>%s</title>"
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"
- "<link href=\""EPHY_PAGE_TEMPLATE_ABOUT_CSS"\" rel=\"stylesheet\"
type=\"text/css\">"
+ "<link href=\""EPHY_PAGE_TEMPLATE_ABOUT_CSS "\" rel=\"stylesheet\"
type=\"text/css\">"
"</head><body>",
_("Memory usage"));
@@ -230,9 +229,9 @@ handle_memory_finished_cb (EphyAboutHandler *handler,
}
static void
-handle_memory_sync (GTask *task,
- gpointer source_object,
- gpointer task_data,
+handle_memory_sync (GTask *task,
+ gpointer source_object,
+ gpointer task_data,
GCancellable *cancellable)
{
EphyAboutHandler *handler = EPHY_ABOUT_HANDLER (source_object);
@@ -243,7 +242,7 @@ handle_memory_sync (GTask *task,
}
static gboolean
-ephy_about_handler_handle_memory (EphyAboutHandler *handler,
+ephy_about_handler_handle_memory (EphyAboutHandler *handler,
WebKitURISchemeRequest *request)
{
GTask *task;
@@ -258,7 +257,7 @@ ephy_about_handler_handle_memory (EphyAboutHandler *handler,
}
static gboolean
-ephy_about_handler_handle_about (EphyAboutHandler *handler,
+ephy_about_handler_handle_about (EphyAboutHandler *handler,
WebKitURISchemeRequest *request)
{
char *data;
@@ -274,7 +273,7 @@ ephy_about_handler_handle_about (EphyAboutHandler *handler,
data = g_strdup_printf ("<html><head><title>%s</title>"
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"
- "<link href=\""EPHY_PAGE_TEMPLATE_ABOUT_CSS"\" rel=\"stylesheet\"
type=\"text/css\">"
+ "<link href=\""EPHY_PAGE_TEMPLATE_ABOUT_CSS "\" rel=\"stylesheet\"
type=\"text/css\">"
"</head><body>"
"<div class=\"dialog\">"
"<img src=\"file://%s\"/>"
@@ -301,14 +300,14 @@ ephy_about_handler_handle_about (EphyAboutHandler *handler,
}
static gboolean
-ephy_about_handler_handle_epiphany (EphyAboutHandler *handler,
+ephy_about_handler_handle_epiphany (EphyAboutHandler *handler,
WebKitURISchemeRequest *request)
{
char *data;
data = g_strdup_printf ("<html class=\"epiphany-html\"><head><title>%s</title>"
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"
- "<link href=\""EPHY_PAGE_TEMPLATE_ABOUT_CSS"\" rel=\"stylesheet\"
type=\"text/css\">"
+ "<link href=\""EPHY_PAGE_TEMPLATE_ABOUT_CSS "\" rel=\"stylesheet\"
type=\"text/css\">"
"</head><body class=\"epiphany-body\">"
"<div id=\"ephytext\">"
"“Il semble que la perfection soit atteinte non quand il n'y a plus rien à"
@@ -326,8 +325,8 @@ ephy_about_handler_handle_epiphany (EphyAboutHandler *handler,
}
static void
-handle_applications_finished_cb (EphyAboutHandler *handler,
- GAsyncResult *result,
+handle_applications_finished_cb (EphyAboutHandler *handler,
+ GAsyncResult *result,
WebKitURISchemeRequest *request)
{
GString *data_str;
@@ -337,7 +336,7 @@ handle_applications_finished_cb (EphyAboutHandler *handler,
data_str = g_string_new (NULL);
g_string_append_printf (data_str, "<html><head><title>%s</title>"
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"
- "<link href=\""EPHY_PAGE_TEMPLATE_ABOUT_CSS"\" rel=\"stylesheet\"
type=\"text/css\">"
+ "<link href=\""EPHY_PAGE_TEMPLATE_ABOUT_CSS "\" rel=\"stylesheet\"
type=\"text/css\">"
"<script>"
" function deleteWebApp(appID) {"
" window.webkit.messageHandlers.aboutApps.postMessage(appID);"
@@ -355,7 +354,7 @@ handle_applications_finished_cb (EphyAboutHandler *handler,
applications = g_task_propagate_pointer (G_TASK (result), NULL);
for (p = applications; p; p = p->next) {
- EphyWebApplication *app = (EphyWebApplication*)p->data;
+ EphyWebApplication *app = (EphyWebApplication *)p->data;
g_string_append_printf (data_str,
"<tbody><tr id =\"%s\">"
@@ -378,9 +377,9 @@ handle_applications_finished_cb (EphyAboutHandler *handler,
}
static void
-handle_applications_sync (GTask *task,
- gpointer source_object,
- gpointer task_data,
+handle_applications_sync (GTask *task,
+ gpointer source_object,
+ gpointer task_data,
GCancellable *cancellable)
{
g_task_return_pointer (task,
@@ -389,7 +388,7 @@ handle_applications_sync (GTask *task,
}
static gboolean
-ephy_about_handler_handle_applications (EphyAboutHandler *handler,
+ephy_about_handler_handle_applications (EphyAboutHandler *handler,
WebKitURISchemeRequest *request)
{
GTask *task;
@@ -409,8 +408,8 @@ typedef struct {
} GetSnapshotPathAsyncData;
static void
-got_snapshot_path_for_url_cb (EphySnapshotService *service,
- GAsyncResult *result,
+got_snapshot_path_for_url_cb (EphySnapshotService *service,
+ GAsyncResult *result,
GetSnapshotPathAsyncData *data)
{
char *snapshot;
@@ -430,9 +429,9 @@ got_snapshot_path_for_url_cb (EphySnapshotService *service,
}
static void
-history_service_query_urls_cb (EphyHistoryService *history,
- gboolean success,
- GList *urls,
+history_service_query_urls_cb (EphyHistoryService *history,
+ gboolean success,
+ GList *urls,
WebKitURISchemeRequest *request)
{
EphySnapshotService *snapshot_service = ephy_snapshot_service_get_default ();
@@ -451,7 +450,7 @@ history_service_query_urls_cb (EphyHistoryService *history,
"<head>\n"
" <title>%s</title>\n"
" <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n"
- " <link href=\""EPHY_PAGE_TEMPLATE_ABOUT_CSS"\" rel=\"stylesheet\"
type=\"text/css\">\n"
+ " <link href=\""EPHY_PAGE_TEMPLATE_ABOUT_CSS "\" rel=\"stylesheet\"
type=\"text/css\">\n"
" <script>\n"
" document.onkeypress = function listenKeypress(event) {\n"
" // Remove from overview when Del is pressed\n"
@@ -499,9 +498,9 @@ history_service_query_urls_cb (EphyHistoryService *history,
}
g_string_append (data_str,
- "<div id=\"overview\">\n"
- " <div id=\"overview-grid\">\n"
- " <ul id=\"overview-item-list\">\n");
+ "<div id=\"overview\">\n"
+ " <div id=\"overview-grid\">\n"
+ " <ul id=\"overview-item-list\">\n");
for (l = urls; l; l = g_list_next (l)) {
EphyHistoryURL *url = (EphyHistoryURL *)l->data;
@@ -541,14 +540,14 @@ history_service_query_urls_cb (EphyHistoryService *history,
" </div>\n"
"</body></html>\n");
-out:
+ out:
data_length = data_str->len;
ephy_about_handler_finish_request (request, g_string_free (data_str, FALSE), data_length);
g_object_unref (request);
}
static gboolean
-ephy_about_handler_handle_html_overview (EphyAboutHandler *handler,
+ephy_about_handler_handle_html_overview (EphyAboutHandler *handler,
WebKitURISchemeRequest *request)
{
EphyHistoryService *history;
@@ -569,7 +568,7 @@ ephy_about_handler_handle_html_overview (EphyAboutHandler *handler,
}
static gboolean
-ephy_about_handler_handle_incognito (EphyAboutHandler *handler,
+ephy_about_handler_handle_incognito (EphyAboutHandler *handler,
WebKitURISchemeRequest *request)
{
char *data;
@@ -582,7 +581,7 @@ ephy_about_handler_handle_incognito (EphyAboutHandler *handler,
"<head>\n"
"<title>%s</title>\n"
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"
- "<link href=\""EPHY_PAGE_TEMPLATE_ABOUT_CSS"\" rel=\"stylesheet\"
type=\"text/css\">\n"
+ "<link href=\""EPHY_PAGE_TEMPLATE_ABOUT_CSS "\" rel=\"stylesheet\"
type=\"text/css\">\n"
"</head>\n"
"<body class=\"incognito-body\">\n"
" <div id=\"mainblock\">\n"
@@ -604,7 +603,7 @@ ephy_about_handler_handle_incognito (EphyAboutHandler *handler,
"download will be kept."),
_("Incognito mode hides your activity only from people using this "
"computer."),
- _("It will not hide your activity from your employer if you are at "
+ _("It will not hide your activity from your employer if you are at "
"work. Your internet service provider, your government, other "
"governments, the websites that you visit, and advertisers on "
"these websites may still be tracking you."));
@@ -615,7 +614,7 @@ ephy_about_handler_handle_incognito (EphyAboutHandler *handler,
}
static void
-ephy_about_handler_handle_blank (EphyAboutHandler *handler,
+ephy_about_handler_handle_blank (EphyAboutHandler *handler,
WebKitURISchemeRequest *request)
{
ephy_about_handler_finish_request (request, g_strdup ("<html></html>"), -1);
@@ -628,11 +627,11 @@ ephy_about_handler_new (void)
}
void
-ephy_about_handler_handle_request (EphyAboutHandler *handler,
+ephy_about_handler_handle_request (EphyAboutHandler *handler,
WebKitURISchemeRequest *request)
{
const char *path;
- gboolean handled = FALSE;
+ gboolean handled = FALSE;
path = webkit_uri_scheme_request_get_path (request);
@@ -641,7 +640,7 @@ ephy_about_handler_handle_request (EphyAboutHandler *handler,
else if (!g_strcmp0 (path, "memory"))
handled = ephy_about_handler_handle_memory (handler, request);
else if (!g_strcmp0 (path, "epiphany"))
- handled = ephy_about_handler_handle_epiphany (handler, request);
+ handled = ephy_about_handler_handle_epiphany (handler, request);
else if (!g_strcmp0 (path, "applications"))
handled = ephy_about_handler_handle_applications (handler, request);
else if (!g_strcmp0 (path, "overview"))
diff --git a/embed/ephy-download.c b/embed/ephy-download.c
index cf88bfe..69d4e89 100644
--- a/embed/ephy-download.c
+++ b/embed/ephy-download.c
@@ -35,8 +35,7 @@
#include <glib/gi18n.h>
#include <string.h>
-struct _EphyDownload
-{
+struct _EphyDownload {
GObject parent_instance;
WebKitDownload *download;
@@ -52,8 +51,7 @@ struct _EphyDownload
G_DEFINE_TYPE (EphyDownload, ephy_download, G_TYPE_OBJECT)
-enum
-{
+enum {
PROP_0,
PROP_DOWNLOAD,
PROP_DESTINATION,
@@ -65,8 +63,7 @@ enum
static GParamSpec *obj_properties[LAST_PROP];
-enum
-{
+enum {
FILENAME_SUGGESTED,
ERROR,
COMPLETED,
@@ -176,11 +173,11 @@ decide_action_from_mime (EphyDownload *ephy_download)
}
/* From the old embed/mozilla/MozDownload.cpp */
-static const char*
+static const char *
file_is_compressed (const char *filename)
{
int i;
- static const char * const compression[] = {".gz", ".bz2", ".Z", ".lz", ".xz", NULL};
+ static const char * const compression[] = { ".gz", ".bz2", ".Z", ".lz", ".xz", NULL };
for (i = 0; compression[i] != NULL; i++) {
if (g_str_has_suffix (filename, compression[i]))
@@ -190,7 +187,7 @@ file_is_compressed (const char *filename)
return NULL;
}
-static const char*
+static const char *
parse_extension (const char *filename)
{
const char *compression;
@@ -201,7 +198,7 @@ parse_extension (const char *filename)
/* if the file is compressed we might have a double extension */
if (compression != NULL) {
int i;
- static const char * const extensions[] = {"tar", "ps", "xcf", "dvi", "txt", "text", NULL};
+ static const char * const extensions[] = { "tar", "ps", "xcf", "dvi", "txt", "text", NULL };
for (i = 0; extensions[i] != NULL; i++) {
char *suffix;
@@ -302,7 +299,7 @@ set_destination_uri_for_suggested_filename (EphyDownload *download, const char *
**/
void
ephy_download_set_destination_uri (EphyDownload *download,
- const char *destination)
+ const char *destination)
{
g_return_if_fail (EPHY_IS_DOWNLOAD (download));
g_return_if_fail (destination != NULL);
@@ -321,7 +318,7 @@ ephy_download_set_destination_uri (EphyDownload *download,
* files" is set.
**/
void
-ephy_download_set_action (EphyDownload *download,
+ephy_download_set_action (EphyDownload *download,
EphyDownloadActionType action)
{
g_return_if_fail (EPHY_IS_DOWNLOAD (download));
@@ -456,48 +453,48 @@ ephy_download_failed (EphyDownload *download,
*
**/
gboolean
-ephy_download_do_download_action (EphyDownload *download,
+ephy_download_do_download_action (EphyDownload *download,
EphyDownloadActionType action)
{
- GFile *destination;
- const char *destination_uri;
- gboolean ret = FALSE;
-
- destination_uri = webkit_download_get_destination (download->download);
- destination = g_file_new_for_uri (destination_uri);
-
- switch ((action ? action : download->action)) {
- case EPHY_DOWNLOAD_ACTION_AUTO:
- LOG ("ephy_download_do_download_action: auto");
- ret = ephy_download_do_download_action (download, decide_action_from_mime (download));
- break;
- case EPHY_DOWNLOAD_ACTION_BROWSE_TO:
- LOG ("ephy_download_do_download_action: browse_to");
+ GFile *destination;
+ const char *destination_uri;
+ gboolean ret = FALSE;
+
+ destination_uri = webkit_download_get_destination (download->download);
+ destination = g_file_new_for_uri (destination_uri);
+
+ switch ((action ? action : download->action)) {
+ case EPHY_DOWNLOAD_ACTION_AUTO:
+ LOG ("ephy_download_do_download_action: auto");
+ ret = ephy_download_do_download_action (download, decide_action_from_mime (download));
+ break;
+ case EPHY_DOWNLOAD_ACTION_BROWSE_TO:
+ LOG ("ephy_download_do_download_action: browse_to");
+ ret = ephy_file_browse_to (destination, download->start_time);
+ break;
+ case EPHY_DOWNLOAD_ACTION_OPEN:
+ LOG ("ephy_download_do_download_action: open");
+ ret = ephy_embed_shell_launch_handler (ephy_embed_shell_get_default (),
+ destination, NULL, download->start_time);
+ if (!ret)
ret = ephy_file_browse_to (destination, download->start_time);
- break;
- case EPHY_DOWNLOAD_ACTION_OPEN:
- LOG ("ephy_download_do_download_action: open");
- ret = ephy_embed_shell_launch_handler (ephy_embed_shell_get_default (),
- destination, NULL, download->start_time);
- if (!ret)
- ret = ephy_file_browse_to (destination, download->start_time);
- break;
- case EPHY_DOWNLOAD_ACTION_NONE:
- LOG ("ephy_download_do_download_action: none");
- ret = TRUE;
- break;
- case EPHY_DOWNLOAD_ACTION_DO_NOTHING:
- LOG ("ephy_download_do_download_action: nothing");
- ret = TRUE;
- break;
- default:
- LOG ("ephy_download_do_download_action: unhandled action");
- ret = FALSE;
- break;
- }
- g_object_unref (destination);
+ break;
+ case EPHY_DOWNLOAD_ACTION_NONE:
+ LOG ("ephy_download_do_download_action: none");
+ ret = TRUE;
+ break;
+ case EPHY_DOWNLOAD_ACTION_DO_NOTHING:
+ LOG ("ephy_download_do_download_action: nothing");
+ ret = TRUE;
+ break;
+ default:
+ LOG ("ephy_download_do_download_action: unhandled action");
+ ret = FALSE;
+ break;
+ }
+ g_object_unref (destination);
- return ret;
+ return ret;
}
static void
@@ -513,7 +510,7 @@ ephy_download_dispose (GObject *object)
download->download = NULL;
}
- g_clear_error(&download->error);
+ g_clear_error (&download->error);
g_clear_pointer (&download->content_type, g_free);
G_OBJECT_CLASS (ephy_download_parent_class)->dispose (object);
@@ -535,11 +532,11 @@ ephy_download_class_init (EphyDownloadClass *klass)
*/
obj_properties[PROP_DOWNLOAD] =
g_param_spec_object ("download",
- "Internal WebKitDownload",
- "The WebKitDownload used internally by EphyDownload",
- WEBKIT_TYPE_DOWNLOAD,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS);
+ "Internal WebKitDownload",
+ "The WebKitDownload used internally by EphyDownload",
+ WEBKIT_TYPE_DOWNLOAD,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS);
/**
* EphyDownload::destination:
@@ -548,11 +545,11 @@ ephy_download_class_init (EphyDownloadClass *klass)
*/
obj_properties[PROP_DESTINATION] =
g_param_spec_string ("destination",
- "Destination",
- "Destination file URI",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS);
+ "Destination",
+ "Destination file URI",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS);
/**
* EphyDownload::action:
@@ -563,12 +560,12 @@ ephy_download_class_init (EphyDownloadClass *klass)
*/
obj_properties[PROP_ACTION] =
g_param_spec_enum ("action",
- "Download action",
- "Action to take when download finishes",
- EPHY_TYPE_DOWNLOAD_ACTION_TYPE,
- EPHY_DOWNLOAD_ACTION_NONE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS);
+ "Download action",
+ "Action to take when download finishes",
+ EPHY_TYPE_DOWNLOAD_ACTION_TYPE,
+ EPHY_DOWNLOAD_ACTION_NONE,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS);
/**
* EphyDownload::start-time:
@@ -578,19 +575,19 @@ ephy_download_class_init (EphyDownloadClass *klass)
*/
obj_properties[PROP_START_TIME] =
g_param_spec_uint ("start-time",
- "Event start time",
- "Time for focus-stealing prevention.",
- 0, G_MAXUINT32, 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS);
+ "Event start time",
+ "Time for focus-stealing prevention.",
+ 0, G_MAXUINT32, 0,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS);
obj_properties[PROP_CONTENT_TYPE] =
g_param_spec_string ("content-type",
- "Content Type",
- "The download content type",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS);
+ "Content Type",
+ "The download content type",
+ NULL,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
@@ -601,13 +598,13 @@ ephy_download_class_init (EphyDownloadClass *klass)
* suggested filename from WebKit.
**/
signals[FILENAME_SUGGESTED] = g_signal_new ("filename-suggested",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
/**
* EphyDownload::completed:
@@ -615,24 +612,24 @@ ephy_download_class_init (EphyDownloadClass *klass)
* The ::completed signal is emitted when @download has finished downloading.
**/
signals[COMPLETED] = g_signal_new ("completed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL, NULL,
- G_TYPE_NONE,
- 0);
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 0);
/**
* EphyDownload::error:
*
* The ::error signal wraps the @download ::error signal.
**/
signals[ERROR] = g_signal_new ("error",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL, NULL,
- G_TYPE_NONE,
- 1, G_TYPE_POINTER);
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1, G_TYPE_POINTER);
}
static void
@@ -649,8 +646,8 @@ ephy_download_init (EphyDownload *download)
static void
download_response_changed_cb (WebKitDownload *wk_download,
- GParamSpec *spec,
- EphyDownload *download)
+ GParamSpec *spec,
+ EphyDownload *download)
{
WebKitURIResponse *response;
const char *mime_type;
@@ -667,8 +664,8 @@ download_response_changed_cb (WebKitDownload *wk_download,
static gboolean
download_decide_destination_cb (WebKitDownload *wk_download,
- const gchar *suggested_filename,
- EphyDownload *download)
+ const gchar *suggested_filename,
+ EphyDownload *download)
{
if (webkit_download_get_destination (wk_download))
return TRUE;
@@ -683,8 +680,8 @@ download_decide_destination_cb (WebKitDownload *wk_download,
static void
download_created_destination_cb (WebKitDownload *wk_download,
- const char *destination,
- EphyDownload *download)
+ const char *destination,
+ EphyDownload *download)
{
char *filename;
char *content_type;
@@ -727,7 +724,7 @@ download_created_destination_cb (WebKitDownload *wk_download,
static void
download_finished_cb (WebKitDownload *wk_download,
- EphyDownload *download)
+ EphyDownload *download)
{
download->finished = TRUE;
g_signal_emit (download, signals[COMPLETED], 0);
@@ -741,8 +738,8 @@ download_finished_cb (WebKitDownload *wk_download,
static void
download_failed_cb (WebKitDownload *wk_download,
- GError *error,
- EphyDownload *download)
+ GError *error,
+ EphyDownload *download)
{
g_signal_handlers_disconnect_by_func (wk_download, download_finished_cb, download);
diff --git a/embed/ephy-downloads-manager.c b/embed/ephy-downloads-manager.c
index 0ad8d46..a2c13c4 100644
--- a/embed/ephy-downloads-manager.c
+++ b/embed/ephy-downloads-manager.c
@@ -33,8 +33,7 @@ enum {
LAST_SIGNAL
};
-struct _EphyDownloadsManager
-{
+struct _EphyDownloadsManager {
GObject parent_instance;
GList *downloads;
@@ -57,7 +56,7 @@ ephy_downloads_manager_acquire_session_inhibitor (EphyDownloadsManager *manager)
manager->inhibitor_cookie = gtk_application_inhibit (GTK_APPLICATION (ephy_embed_shell_get_default ()),
NULL,
GTK_APPLICATION_INHIBIT_LOGOUT |
GTK_APPLICATION_INHIBIT_SUSPEND,
- "Downloading");
+ "Downloading");
if (manager->inhibitor_cookie == 0)
g_warning ("Failed to acquire session inhibitor for active download. Is gnome-session running?");
diff --git a/embed/ephy-embed-container.c b/embed/ephy-embed-container.c
index cb21649..9ba5f71 100644
--- a/embed/ephy-embed-container.c
+++ b/embed/ephy-embed-container.c
@@ -51,9 +51,9 @@ ephy_embed_container_default_init (EphyEmbedContainerInterface *iface)
**/
gint
ephy_embed_container_add_child (EphyEmbedContainer *container,
- EphyEmbed *child,
- gint position,
- gboolean set_active)
+ EphyEmbed *child,
+ gint position,
+ gboolean set_active)
{
EphyEmbedContainerInterface *iface;
@@ -73,7 +73,7 @@ ephy_embed_container_add_child (EphyEmbedContainer *container,
**/
void
ephy_embed_container_set_active_child (EphyEmbedContainer *container,
- EphyEmbed *child)
+ EphyEmbed *child)
{
EphyEmbedContainerInterface *iface;
@@ -94,7 +94,7 @@ ephy_embed_container_set_active_child (EphyEmbedContainer *container,
**/
void
ephy_embed_container_remove_child (EphyEmbedContainer *container,
- EphyEmbed *child)
+ EphyEmbed *child)
{
EphyEmbedContainerInterface *iface;
diff --git a/embed/ephy-embed-event.c b/embed/ephy-embed-event.c
index bc491db..aa013c9 100644
--- a/embed/ephy-embed-event.c
+++ b/embed/ephy-embed-event.c
@@ -116,10 +116,10 @@ ephy_embed_event_get_coords (EphyEmbedEvent *event,
* @name: the name of the property
* @value: (out): a variable to hold its value
*/
-void
-ephy_embed_event_get_property (EphyEmbedEvent *event,
- const char *name,
- GValue *value)
+void
+ephy_embed_event_get_property (EphyEmbedEvent *event,
+ const char *name,
+ GValue *value)
{
g_return_if_fail (EPHY_IS_EMBED_EVENT (event));
g_return_if_fail (name);
@@ -132,27 +132,26 @@ ephy_embed_event_get_property (EphyEmbedEvent *event,
}
gboolean
-ephy_embed_event_has_property (EphyEmbedEvent *event,
- const char *name)
+ephy_embed_event_has_property (EphyEmbedEvent *event,
+ const char *name)
{
g_return_val_if_fail (EPHY_IS_EMBED_EVENT (event), FALSE);
g_return_val_if_fail (name, FALSE);
return g_object_class_find_property (G_OBJECT_GET_CLASS (event->hit_test_result),
name) != NULL;
-
}
/**
* ephy_embed_event_get_hit_test_result:
* @event: an #EphyEmbedEvent
- *
+ *
* Returns: (transfer none): returns the #WebKitHitTestResult associated with @event
**/
WebKitHitTestResult *
ephy_embed_event_get_hit_test_result (EphyEmbedEvent *event)
{
g_return_val_if_fail (EPHY_IS_EMBED_EVENT (event), NULL);
-
+
return event->hit_test_result;
}
diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c
index 8dc1e84..044761f 100644
--- a/embed/ephy-embed-prefs.c
+++ b/embed/ephy-embed-prefs.c
@@ -30,12 +30,11 @@
#include <math.h>
#include <webkit2/webkit2.h>
-typedef struct
-{
+typedef struct {
const char *schema;
const char *key;
const char *webkit_pref;
- void (*callback) (GSettings *settings, const char *key, gpointer data);
+ void (*callback)(GSettings *settings, const char *key, gpointer data);
} PrefData;
#define ENABLE_SCRIPTS_SETTING "enable-javascript"
@@ -44,8 +43,8 @@ static WebKitSettings *webkit_settings = NULL;
static void
user_style_sheet_output_stream_splice_cb (GOutputStream *output_stream,
- GAsyncResult *result,
- gpointer user_data)
+ GAsyncResult *result,
+ gpointer user_data)
{
gssize bytes;
@@ -63,9 +62,9 @@ user_style_sheet_output_stream_splice_cb (GOutputStream *output_stream,
}
static void
-user_style_seet_read_cb (GFile *file,
+user_style_seet_read_cb (GFile *file,
GAsyncResult *result,
- gpointer user_data)
+ gpointer user_data)
{
GFileInputStream *input_stream;
GOutputStream *output_stream;
@@ -87,9 +86,9 @@ user_style_seet_read_cb (GFile *file,
}
static void
-webkit_pref_callback_user_stylesheet (GSettings *settings,
+webkit_pref_callback_user_stylesheet (GSettings *settings,
const char *key,
- gpointer data)
+ gpointer data)
{
gboolean value;
@@ -119,7 +118,7 @@ webkit_pref_get_vendor_user_agent (void)
branding_keyfile = g_key_file_new ();
- if (g_key_file_load_from_file (branding_keyfile, SHARE_DIR"/branding.conf",
+ if (g_key_file_load_from_file (branding_keyfile, SHARE_DIR "/branding.conf",
G_KEY_FILE_NONE, NULL)) {
char *vendor;
char *vendor_sub;
@@ -178,9 +177,9 @@ webkit_pref_get_internal_user_agent (void)
}
static void
-webkit_pref_callback_user_agent (GSettings *settings,
+webkit_pref_callback_user_agent (GSettings *settings,
const char *key,
- gpointer data)
+ gpointer data)
{
char *value;
const char *internal_user_agent;
@@ -234,9 +233,9 @@ normalize_font_size (gdouble font_size)
}
static void
-webkit_pref_callback_font_size (GSettings *settings,
+webkit_pref_callback_font_size (GSettings *settings,
const char *key,
- gpointer data)
+ gpointer data)
{
char *webkit_pref = data;
char *value = NULL;
@@ -248,8 +247,7 @@ webkit_pref_callback_font_size (GSettings *settings,
/* If we are changing a GNOME font value and we are not using GNOME fonts in
* Epiphany, return. */
if (g_strcmp0 (schema, EPHY_PREFS_WEB_SCHEMA) != 0 &&
- g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_USE_GNOME_FONTS) != TRUE)
- {
+ g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_USE_GNOME_FONTS) != TRUE) {
g_free (schema);
return;
}
@@ -258,7 +256,7 @@ webkit_pref_callback_font_size (GSettings *settings,
value = g_settings_get_string (settings, key);
if (value) {
- PangoFontDescription* desc;
+ PangoFontDescription *desc;
desc = pango_font_description_from_string (value);
size = pango_font_description_get_size (desc);
@@ -272,9 +270,9 @@ webkit_pref_callback_font_size (GSettings *settings,
}
static void
-webkit_pref_callback_font_family (GSettings *settings,
+webkit_pref_callback_font_family (GSettings *settings,
const char *key,
- gpointer data)
+ gpointer data)
{
char *webkit_pref = data;
char *value = NULL;
@@ -285,8 +283,7 @@ webkit_pref_callback_font_family (GSettings *settings,
/* If we are changing a GNOME font value and we are not using GNOME fonts in
* Epiphany, return. */
if (g_strcmp0 (schema, EPHY_PREFS_WEB_SCHEMA) != 0 &&
- g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_USE_GNOME_FONTS) != TRUE)
- {
+ g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_USE_GNOME_FONTS) != TRUE) {
g_free (schema);
return;
}
@@ -295,7 +292,7 @@ webkit_pref_callback_font_family (GSettings *settings,
value = g_settings_get_string (settings, key);
if (value) {
- PangoFontDescription* desc;
+ PangoFontDescription *desc;
const char *family = NULL;
desc = pango_font_description_from_string (value);
@@ -336,9 +333,9 @@ normalize_languages (char **languages)
/* Based on Christian Persch's code from gecko backend of epiphany
(old transform_accept_languages_list() function) */
static void
-webkit_pref_callback_accept_languages (GSettings *settings,
+webkit_pref_callback_accept_languages (GSettings *settings,
const char *key,
- gpointer data)
+ gpointer data)
{
GArray *array;
char **languages;
@@ -351,12 +348,12 @@ webkit_pref_callback_accept_languages (GSettings *settings,
array = g_array_new (TRUE, FALSE, sizeof (char *));
for (i = 0; languages[i]; i++) {
- if (!g_strcmp0 (languages[i], "system")) {
- ephy_langs_append_languages (array);
- } else if (languages[i][0] != '\0') {
- char *str = g_ascii_strdown (languages[i], -1);
- g_array_append_val (array, str);
- }
+ if (!g_strcmp0 (languages[i], "system")) {
+ ephy_langs_append_languages (array);
+ } else if (languages[i][0] != '\0') {
+ char *str = g_ascii_strdown (languages[i], -1);
+ g_array_append_val (array, str);
+ }
}
ephy_langs_sanitise (array);
@@ -376,7 +373,7 @@ webkit_pref_callback_accept_languages (GSettings *settings,
void
ephy_embed_prefs_set_cookie_accept_policy (WebKitCookieManager *cookie_manager,
- const char *settings_policy)
+ const char *settings_policy)
{
WebKitCookieAcceptPolicy policy;
@@ -395,9 +392,9 @@ ephy_embed_prefs_set_cookie_accept_policy (WebKitCookieManager *cookie_manager,
}
static void
-webkit_pref_callback_cookie_accept_policy (GSettings *settings,
+webkit_pref_callback_cookie_accept_policy (GSettings *settings,
const char *key,
- gpointer data)
+ gpointer data)
{
WebKitCookieManager *cookie_manager;
char *value;
@@ -443,17 +440,17 @@ ephy_embed_prefs_update_font_settings (GSettings *ephy_settings, const char *key
}
static void
-webkit_pref_callback_gnome_fonts (GSettings *ephy_settings,
+webkit_pref_callback_gnome_fonts (GSettings *ephy_settings,
const char *key,
- gpointer data)
+ gpointer data)
{
ephy_embed_prefs_update_font_settings (ephy_settings, key);
}
static void
-webkit_pref_callback_enable_spell_checking (GSettings *settings,
+webkit_pref_callback_enable_spell_checking (GSettings *settings,
const char *key,
- gpointer data)
+ gpointer data)
{
WebKitWebContext *web_context;
gboolean value = FALSE;
@@ -468,7 +465,7 @@ webkit_pref_callback_enable_spell_checking (GSettings *settings,
char **languages = g_settings_get_strv (settings, EPHY_PREFS_WEB_LANGUAGE);
char **normalized = normalize_languages (languages);
- webkit_web_context_set_spell_checking_languages (web_context, (const char* const *)normalized);
+ webkit_web_context_set_spell_checking_languages (web_context, (const char * const *)normalized);
g_strfreev (languages);
g_strfreev (normalized);
@@ -477,68 +474,68 @@ webkit_pref_callback_enable_spell_checking (GSettings *settings,
static void
gtk_settings_xft_dpi_changed_cb (GtkSettings *gtk_settings,
- GParamSpec *pspec,
- gpointer data)
+ GParamSpec *pspec,
+ gpointer data)
{
GSettings *gsettings = ephy_settings_get (EPHY_PREFS_WEB_SCHEMA);
ephy_embed_prefs_update_font_settings (gsettings, EPHY_PREFS_WEB_USE_GNOME_FONTS);
}
static const PrefData webkit_pref_entries[] =
- {
- /* Epiphany font settings */
- { EPHY_PREFS_WEB_SCHEMA,
- EPHY_PREFS_WEB_SERIF_FONT,
- "default-font-size",
- webkit_pref_callback_font_size },
- { EPHY_PREFS_WEB_SCHEMA,
- EPHY_PREFS_WEB_MONOSPACE_FONT,
- "default-monospace-font-size",
- webkit_pref_callback_font_size },
- { EPHY_PREFS_WEB_SCHEMA,
- EPHY_PREFS_WEB_SERIF_FONT,
- "default-font-family",
- webkit_pref_callback_font_family },
- { EPHY_PREFS_WEB_SCHEMA,
- EPHY_PREFS_WEB_SANS_SERIF_FONT,
- "sans-serif-font-family",
- webkit_pref_callback_font_family },
- { EPHY_PREFS_WEB_SCHEMA,
- EPHY_PREFS_WEB_MONOSPACE_FONT,
- "monospace-font-family",
- webkit_pref_callback_font_family },
- { EPHY_PREFS_WEB_SCHEMA,
- EPHY_PREFS_WEB_SERIF_FONT,
- "serif-font-family",
- webkit_pref_callback_font_family },
-
- { EPHY_PREFS_WEB_SCHEMA,
- EPHY_PREFS_WEB_USE_GNOME_FONTS,
- NULL,
- webkit_pref_callback_gnome_fonts },
-
- { EPHY_PREFS_WEB_SCHEMA,
- EPHY_PREFS_WEB_ENABLE_SPELL_CHECKING,
- NULL,
- webkit_pref_callback_enable_spell_checking },
-
- { EPHY_PREFS_WEB_SCHEMA,
- EPHY_PREFS_WEB_ENABLE_USER_CSS,
- "user-stylesheet-uri",
- webkit_pref_callback_user_stylesheet },
- { EPHY_PREFS_WEB_SCHEMA,
- EPHY_PREFS_WEB_LANGUAGE,
- "accept-language",
- webkit_pref_callback_accept_languages },
- { EPHY_PREFS_SCHEMA,
- EPHY_PREFS_USER_AGENT,
- "user-agent",
- webkit_pref_callback_user_agent },
- { EPHY_PREFS_WEB_SCHEMA,
- EPHY_PREFS_WEB_COOKIES_POLICY,
- "accept-policy",
- webkit_pref_callback_cookie_accept_policy },
- };
+{
+ /* Epiphany font settings */
+ { EPHY_PREFS_WEB_SCHEMA,
+ EPHY_PREFS_WEB_SERIF_FONT,
+ "default-font-size",
+ webkit_pref_callback_font_size },
+ { EPHY_PREFS_WEB_SCHEMA,
+ EPHY_PREFS_WEB_MONOSPACE_FONT,
+ "default-monospace-font-size",
+ webkit_pref_callback_font_size },
+ { EPHY_PREFS_WEB_SCHEMA,
+ EPHY_PREFS_WEB_SERIF_FONT,
+ "default-font-family",
+ webkit_pref_callback_font_family },
+ { EPHY_PREFS_WEB_SCHEMA,
+ EPHY_PREFS_WEB_SANS_SERIF_FONT,
+ "sans-serif-font-family",
+ webkit_pref_callback_font_family },
+ { EPHY_PREFS_WEB_SCHEMA,
+ EPHY_PREFS_WEB_MONOSPACE_FONT,
+ "monospace-font-family",
+ webkit_pref_callback_font_family },
+ { EPHY_PREFS_WEB_SCHEMA,
+ EPHY_PREFS_WEB_SERIF_FONT,
+ "serif-font-family",
+ webkit_pref_callback_font_family },
+
+ { EPHY_PREFS_WEB_SCHEMA,
+ EPHY_PREFS_WEB_USE_GNOME_FONTS,
+ NULL,
+ webkit_pref_callback_gnome_fonts },
+
+ { EPHY_PREFS_WEB_SCHEMA,
+ EPHY_PREFS_WEB_ENABLE_SPELL_CHECKING,
+ NULL,
+ webkit_pref_callback_enable_spell_checking },
+
+ { EPHY_PREFS_WEB_SCHEMA,
+ EPHY_PREFS_WEB_ENABLE_USER_CSS,
+ "user-stylesheet-uri",
+ webkit_pref_callback_user_stylesheet },
+ { EPHY_PREFS_WEB_SCHEMA,
+ EPHY_PREFS_WEB_LANGUAGE,
+ "accept-language",
+ webkit_pref_callback_accept_languages },
+ { EPHY_PREFS_SCHEMA,
+ EPHY_PREFS_USER_AGENT,
+ "user-agent",
+ webkit_pref_callback_user_agent },
+ { EPHY_PREFS_WEB_SCHEMA,
+ EPHY_PREFS_WEB_COOKIES_POLICY,
+ "accept-policy",
+ webkit_pref_callback_cookie_accept_policy },
+};
static gpointer
ephy_embed_prefs_init (gpointer user_data)
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index 5d9f7f0..a9901f7 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -61,8 +61,7 @@ typedef struct {
GList *web_extensions;
} EphyEmbedShellPrivate;
-enum
-{
+enum {
RESTORED_WINDOW,
WEB_VIEW_CREATED,
PAGE_CREATED,
@@ -74,8 +73,7 @@ enum
static guint signals[LAST_SIGNAL];
-enum
-{
+enum {
PROP_0,
PROP_MODE,
N_PROPERTIES
@@ -112,8 +110,8 @@ ephy_embed_shell_dispose (GObject *object)
static void
web_extension_form_auth_data_message_received_cb (WebKitUserContentManager *manager,
- WebKitJavascriptResult *message,
- EphyEmbedShell *shell)
+ WebKitJavascriptResult *message,
+ EphyEmbedShell *shell)
{
guint request_id;
guint64 page_id;
@@ -134,9 +132,9 @@ web_extension_form_auth_data_message_received_cb (WebKitUserContentManager *mana
static void
history_service_query_urls_cb (EphyHistoryService *service,
- gboolean success,
- GList *urls,
- EphyEmbedShell *shell)
+ gboolean success,
+ GList *urls,
+ EphyEmbedShell *shell)
{
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
GList *l;
@@ -164,16 +162,16 @@ ephy_embed_shell_update_overview_urls (EphyEmbedShell *shell)
query->ignore_local = TRUE;
ephy_history_service_query_urls (priv->global_history_service, query, NULL,
- (EphyHistoryJobCallback) history_service_query_urls_cb,
+ (EphyHistoryJobCallback)history_service_query_urls_cb,
shell);
ephy_history_query_free (query);
}
static void
history_service_urls_visited_cb (EphyHistoryService *history,
- EphyEmbedShell *shell)
+ EphyEmbedShell *shell)
{
- ephy_embed_shell_update_overview_urls (shell);
+ ephy_embed_shell_update_overview_urls (shell);
}
static gboolean
@@ -193,9 +191,9 @@ ephy_embed_shell_update_overview_timeout_cb (EphyEmbedShell *shell)
static void
history_set_url_hidden_cb (EphyHistoryService *service,
- gboolean success,
- gpointer result_data,
- EphyEmbedShell *shell)
+ gboolean success,
+ gpointer result_data,
+ EphyEmbedShell *shell)
{
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
@@ -212,8 +210,8 @@ history_set_url_hidden_cb (EphyHistoryService *service,
static void
web_extension_overview_message_received_cb (WebKitUserContentManager *manager,
- WebKitJavascriptResult *message,
- EphyEmbedShell *shell)
+ WebKitJavascriptResult *message,
+ EphyEmbedShell *shell)
{
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
char *url_to_remove;
@@ -223,7 +221,7 @@ web_extension_overview_message_received_cb (WebKitUserContentManager *manager,
priv->hiding_overview_item++;
ephy_history_service_set_url_hidden (priv->global_history_service,
url_to_remove, TRUE, NULL,
- (EphyHistoryJobCallback) history_set_url_hidden_cb,
+ (EphyHistoryJobCallback)history_set_url_hidden_cb,
shell);
g_free (url_to_remove);
@@ -232,13 +230,13 @@ web_extension_overview_message_received_cb (WebKitUserContentManager *manager,
/* Wait for the CSS animations to finish before refreshing */
priv->update_overview_timeout_id =
- g_timeout_add (OVERVIEW_RELOAD_DELAY, (GSourceFunc) ephy_embed_shell_update_overview_timeout_cb, shell);
+ g_timeout_add (OVERVIEW_RELOAD_DELAY, (GSourceFunc)ephy_embed_shell_update_overview_timeout_cb, shell);
}
static void
web_extension_tls_error_page_message_received_cb (WebKitUserContentManager *manager,
- WebKitJavascriptResult *message,
- EphyEmbedShell *shell)
+ WebKitJavascriptResult *message,
+ EphyEmbedShell *shell)
{
guint64 page_id;
@@ -248,8 +246,8 @@ web_extension_tls_error_page_message_received_cb (WebKitUserContentManager *mana
static void
web_extension_about_apps_message_received_cb (WebKitUserContentManager *manager,
- WebKitJavascriptResult *message,
- EphyEmbedShell *shell)
+ WebKitJavascriptResult *message,
+ EphyEmbedShell *shell)
{
char *app_id;
@@ -260,9 +258,9 @@ web_extension_about_apps_message_received_cb (WebKitUserContentManager *manager,
static void
history_service_url_title_changed_cb (EphyHistoryService *service,
- const char *url,
- const char *title,
- EphyEmbedShell *shell)
+ const char *url,
+ const char *title,
+ EphyEmbedShell *shell)
{
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
GList *l;
@@ -276,8 +274,8 @@ history_service_url_title_changed_cb (EphyHistoryService *service,
static void
history_service_url_deleted_cb (EphyHistoryService *service,
- const char *url,
- EphyEmbedShell *shell)
+ const char *url,
+ EphyEmbedShell *shell)
{
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
GList *l;
@@ -291,8 +289,8 @@ history_service_url_deleted_cb (EphyHistoryService *service,
static void
history_service_host_deleted_cb (EphyHistoryService *service,
- const char *deleted_url,
- EphyEmbedShell *shell)
+ const char *deleted_url,
+ EphyEmbedShell *shell)
{
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
GList *l;
@@ -311,7 +309,7 @@ history_service_host_deleted_cb (EphyHistoryService *service,
static void
history_service_cleared_cb (EphyHistoryService *service,
- EphyEmbedShell *shell)
+ EphyEmbedShell *shell)
{
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
GList *l;
@@ -331,8 +329,8 @@ typedef struct {
static DelayedThumbnailUpdateData *
delayed_thumbnail_update_data_new (EphyWebExtensionProxy *extension,
- const char *url,
- const char *path)
+ const char *url,
+ const char *path)
{
DelayedThumbnailUpdateData *data = g_new (DelayedThumbnailUpdateData, 1);
data->extension = extension;
@@ -371,9 +369,9 @@ delayed_thumbnail_update_cb (DelayedThumbnailUpdateData *data)
void
ephy_embed_shell_set_thumbnail_path (EphyEmbedShell *shell,
- const char *url,
- time_t mtime,
- const char *path)
+ const char *url,
+ time_t mtime,
+ const char *path)
{
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
GList *l;
@@ -461,7 +459,7 @@ ephy_embed_shell_restored_window (EphyEmbedShell *shell)
static void
about_request_cb (WebKitURISchemeRequest *request,
- EphyEmbedShell *shell)
+ EphyEmbedShell *shell)
{
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
@@ -495,7 +493,7 @@ ephy_resource_request_cb (WebKitURISchemeRequest *request)
static void
web_extension_destroyed (EphyEmbedShell *shell,
- GObject *web_extension)
+ GObject *web_extension)
{
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
@@ -503,7 +501,7 @@ web_extension_destroyed (EphyEmbedShell *shell,
}
static void
-ephy_embed_shell_watch_web_extension (EphyEmbedShell *shell,
+ephy_embed_shell_watch_web_extension (EphyEmbedShell *shell,
EphyWebExtensionProxy *web_extension)
{
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
@@ -514,14 +512,14 @@ ephy_embed_shell_watch_web_extension (EphyEmbedShell *shell,
static void
ephy_embed_shell_unwatch_web_extension (EphyWebExtensionProxy *web_extension,
- EphyEmbedShell *shell)
+ EphyEmbedShell *shell)
{
g_object_weak_unref (G_OBJECT (web_extension), (GWeakNotify)web_extension_destroyed, shell);
}
static void
-initialize_web_extensions (WebKitWebContext* web_context,
- EphyEmbedShell *shell)
+initialize_web_extensions (WebKitWebContext *web_context,
+ EphyEmbedShell *shell)
{
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
GVariant *user_data;
@@ -542,17 +540,17 @@ initialize_web_extensions (WebKitWebContext* web_context,
static void
web_extension_page_created (EphyWebExtensionProxy *extension,
- guint64 page_id,
- EphyEmbedShell *shell)
+ guint64 page_id,
+ EphyEmbedShell *shell)
{
g_object_set_data (G_OBJECT (extension), "initialized", GINT_TO_POINTER (TRUE));
g_signal_emit (shell, signals[PAGE_CREATED], 0, page_id, extension);
}
static gboolean
-new_connection_cb (GDBusServer *server,
+new_connection_cb (GDBusServer *server,
GDBusConnection *connection,
- EphyEmbedShell *shell)
+ EphyEmbedShell *shell)
{
EphyWebExtensionProxy *extension = ephy_web_extension_proxy_new (connection);
ephy_embed_shell_watch_web_extension (shell, extension);
@@ -565,9 +563,9 @@ new_connection_cb (GDBusServer *server,
static gboolean
authorize_authenticated_peer_cb (GDBusAuthObserver *observer,
- GIOStream *stream,
- GCredentials *credentials,
- EphyEmbedShell *shell)
+ GIOStream *stream,
+ GCredentials *credentials,
+ EphyEmbedShell *shell)
{
return ephy_dbus_peer_is_authorized (credentials);
}
@@ -611,7 +609,7 @@ ephy_embed_shell_setup_web_extensions_server (EphyEmbedShell *shell)
G_CALLBACK (new_connection_cb), shell);
g_dbus_server_start (priv->dbus_server);
-out:
+ out:
g_free (address);
g_free (guid);
g_object_unref (observer);
@@ -630,14 +628,14 @@ ephy_embed_shell_setup_process_model (EphyEmbedShell *shell)
process_model = g_settings_get_enum (EPHY_SETTINGS_MAIN, EPHY_PREFS_PROCESS_MODEL);
switch (process_model) {
- case EPHY_PREFS_PROCESS_MODEL_SHARED_SECONDARY_PROCESS:
- max_processes = 1;
- break;
- case EPHY_PREFS_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW:
- max_processes = g_settings_get_uint (EPHY_SETTINGS_MAIN, EPHY_PREFS_MAX_PROCESSES);
- break;
- default:
- g_assert_not_reached ();
+ case EPHY_PREFS_PROCESS_MODEL_SHARED_SECONDARY_PROCESS:
+ max_processes = 1;
+ break;
+ case EPHY_PREFS_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW:
+ max_processes = g_settings_get_uint (EPHY_SETTINGS_MAIN, EPHY_PREFS_MAX_PROCESSES);
+ break;
+ default:
+ g_assert_not_reached ();
}
webkit_web_context_set_process_model (priv->web_context,
WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
@@ -670,7 +668,7 @@ ephy_embed_shell_create_web_context (EphyEmbedShell *shell)
}
static void
-ephy_embed_shell_startup (GApplication* application)
+ephy_embed_shell_startup (GApplication *application)
{
EphyEmbedShell *shell = EPHY_EMBED_SHELL (application);
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
@@ -762,7 +760,7 @@ ephy_embed_shell_startup (GApplication* application)
}
static void
-ephy_embed_shell_shutdown (GApplication* application)
+ephy_embed_shell_shutdown (GApplication *application)
{
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (EPHY_EMBED_SHELL (application));
@@ -783,36 +781,36 @@ ephy_embed_shell_shutdown (GApplication* application)
}
static void
-ephy_embed_shell_set_property (GObject *object,
- guint prop_id,
+ephy_embed_shell_set_property (GObject *object,
+ guint prop_id,
const GValue *value,
- GParamSpec *pspec)
+ GParamSpec *pspec)
{
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (EPHY_EMBED_SHELL (object));
switch (prop_id) {
- case PROP_MODE:
- priv->mode = g_value_get_enum (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ case PROP_MODE:
+ priv->mode = g_value_get_enum (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
-ephy_embed_shell_get_property (GObject *object,
- guint prop_id,
- GValue *value,
+ephy_embed_shell_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
GParamSpec *pspec)
{
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (EPHY_EMBED_SHELL (object));
switch (prop_id) {
- case PROP_MODE:
- g_value_set_enum (value, priv->mode);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ case PROP_MODE:
+ g_value_set_enum (value, priv->mode);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
@@ -864,7 +862,7 @@ ephy_embed_shell_class_init (EphyEmbedShellClass *klass)
EPHY_TYPE_EMBED_SHELL_MODE,
EPHY_EMBED_SHELL_MODE_BROWSER,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
-
+
g_object_class_install_properties (object_class,
N_PROPERTIES,
object_properties);
@@ -974,7 +972,7 @@ ephy_embed_shell_get_default (void)
void
ephy_embed_shell_set_page_setup (EphyEmbedShell *shell,
- GtkPageSetup *page_setup)
+ GtkPageSetup *page_setup)
{
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
char *path;
@@ -1036,7 +1034,7 @@ ephy_embed_shell_get_page_setup (EphyEmbedShell *shell)
*
**/
void
-ephy_embed_shell_set_print_settings (EphyEmbedShell *shell,
+ephy_embed_shell_set_print_settings (EphyEmbedShell *shell,
GtkPrintSettings *settings)
{
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
@@ -1094,7 +1092,7 @@ ephy_embed_shell_get_print_settings (EphyEmbedShell *shell)
/**
* ephy_embed_shell_get_mode:
* @shell: an #EphyEmbedShell
- *
+ *
* Returns: the global mode of the @shell
**/
EphyEmbedShellMode
@@ -1103,7 +1101,7 @@ ephy_embed_shell_get_mode (EphyEmbedShell *shell)
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
g_return_val_if_fail (EPHY_IS_EMBED_SHELL (shell), EPHY_EMBED_SHELL_MODE_BROWSER);
-
+
return priv->mode;
}
@@ -1113,18 +1111,18 @@ ephy_embed_shell_get_mode (EphyEmbedShell *shell)
* @file: a #GFile to open
* @mime_type: the mime type of @file or %NULL
* @user_time: user time to prevent focus stealing
- *
+ *
* Tries to open @file with the right application, making sure we will
* not call ourselves in the process. This is needed to avoid
* potential infinite loops when opening unknown file types.
- *
+ *
* Returns: %TRUE on success
**/
gboolean
ephy_embed_shell_launch_handler (EphyEmbedShell *shell,
- GFile *file,
- const char *mime_type,
- guint32 user_time)
+ GFile *file,
+ const char *mime_type,
+ guint32 user_time)
{
GAppInfo *app;
GList *list = NULL;
@@ -1154,7 +1152,7 @@ ephy_embed_shell_launch_handler (EphyEmbedShell *shell,
/**
* ephy_embed_shell_clear_cache:
* @shell: an #EphyEmbedShell
- *
+ *
* Clears the HTTP cache (temporarily saved web pages).
**/
void
diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c
index 4a22ab8..cb87080 100644
--- a/embed/ephy-embed-utils.c
+++ b/embed/ephy-embed-utils.c
@@ -38,7 +38,6 @@ static GRegex *domain_regex;
char *
ephy_embed_utils_link_message_parse (const char *message)
{
-
char *status_message;
char **splitted_message;
int i = 1;
@@ -46,7 +45,7 @@ ephy_embed_utils_link_message_parse (const char *message)
GString *tmp;
status_message = ephy_string_blank_chr (g_strdup (message));
-
+
if (!status_message || !g_str_has_prefix (status_message, "mailto:"))
return status_message;
@@ -55,14 +54,14 @@ ephy_embed_utils_link_message_parse (const char *message)
*/
p = strchr (status_message, '?');
if (p != NULL) *p = '\0';
-
+
/* Then we also want to check if there is more than an email address
* in the mailto: list.
*/
splitted_message = g_strsplit_set (status_message, ";", -1);
tmp = g_string_new (g_strdup_printf (_("Send an email message to “%s”"),
(splitted_message[0] + 7)));
-
+
while (splitted_message [i] != NULL) {
g_string_append_printf (tmp, ", “%s”", splitted_message[i]);
i++;
@@ -137,7 +136,7 @@ gboolean
ephy_embed_utils_address_is_existing_absolute_filename (const char *address)
{
return g_path_is_absolute (address) &&
- g_file_test (address, G_FILE_TEST_EXISTS);
+ g_file_test (address, G_FILE_TEST_EXISTS);
}
static gboolean
@@ -179,16 +178,16 @@ ephy_embed_utils_address_is_valid (const char *address)
scheme = g_uri_parse_scheme (address);
retval = scheme ||
- ephy_embed_utils_address_is_existing_absolute_filename (address) ||
- g_regex_match (get_non_search_regex (), address, 0, NULL) ||
- is_public_domain (address);
+ ephy_embed_utils_address_is_existing_absolute_filename (address) ||
+ g_regex_match (get_non_search_regex (), address, 0, NULL) ||
+ is_public_domain (address);
g_free (scheme);
return retval;
}
-char*
+char *
ephy_embed_utils_normalize_address (const char *address)
{
char *effective_address = NULL;
@@ -250,7 +249,6 @@ ephy_embed_utils_autosearch_address (const char *search_key)
g_free (url_search);
return effective_address;
-
}
char *
@@ -267,17 +265,17 @@ ephy_embed_utils_url_is_empty (const char *location)
{
gboolean is_empty = FALSE;
- if (location == NULL ||
- location[0] == '\0' ||
+ if (location == NULL ||
+ location[0] == '\0' ||
strcmp (location, "about:blank") == 0)
is_empty = TRUE;
-
+
return is_empty;
}
/* This is the list of addresses that should never be shown in the
* window's location entry. */
-static const char * do_not_show_address[] = {
+static const char *do_not_show_address[] = {
"about:blank",
"ephy-about:incognito",
"ephy-about:overview",
@@ -305,7 +303,7 @@ ephy_embed_utils_get_title_from_address (const char *address)
if (g_str_has_prefix (address, "file://"))
return g_strdup (address + 7);
- if (!strcmp (address, EPHY_ABOUT_SCHEME":overview") ||
+ if (!strcmp (address, EPHY_ABOUT_SCHEME ":overview") ||
!strcmp (address, "about:overview"))
return g_strdup (_("Most Visited"));
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index e64df1f..1069abc 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -38,9 +38,9 @@
#include <glib/gi18n.h>
#include <webkit2/webkit2.h>
-static void ephy_embed_constructed (GObject *object);
-static void ephy_embed_restored_window_cb (EphyEmbedShell *shell,
- EphyEmbed *embed);
+static void ephy_embed_constructed (GObject *object);
+static void ephy_embed_restored_window_cb (EphyEmbedShell *shell,
+ EphyEmbed *embed);
#define EPHY_EMBED_STATUSBAR_TAB_MESSAGE_CONTEXT_DESCRIPTION "tab_message"
#define MAX_TITLE_LENGTH 512 /* characters */
@@ -88,8 +88,7 @@ struct _EphyEmbed {
G_DEFINE_TYPE (EphyEmbed, ephy_embed, GTK_TYPE_BOX)
-enum
-{
+enum {
PROP_0,
PROP_WEB_VIEW,
PROP_TITLE,
@@ -238,7 +237,7 @@ remove_from_destroy_list_cb (GtkWidget *widget, EphyEmbed *embed)
}
static void
-ephy_embed_set_title (EphyEmbed *embed,
+ephy_embed_set_title (EphyEmbed *embed,
const char *title)
{
char *new_title;
@@ -268,31 +267,31 @@ ephy_embed_set_title (EphyEmbed *embed,
static void
web_view_title_changed_cb (WebKitWebView *web_view,
- GParamSpec *spec,
- EphyEmbed *embed)
+ GParamSpec *spec,
+ EphyEmbed *embed)
{
ephy_embed_set_title (embed, webkit_web_view_get_title (web_view));
}
static void
-load_changed_cb (WebKitWebView *web_view,
+load_changed_cb (WebKitWebView *web_view,
WebKitLoadEvent load_event,
- EphyEmbed *embed)
+ EphyEmbed *embed)
{
switch (load_event) {
- case WEBKIT_LOAD_COMMITTED:
- ephy_embed_destroy_top_widgets (embed);
- break;
- case WEBKIT_LOAD_FINISHED: {
- const char *title = webkit_web_view_get_title (web_view);
- if (ephy_web_view_get_is_blank (EPHY_WEB_VIEW (web_view)) || !title || !*title)
- ephy_embed_set_title (embed, NULL);
- break;
- }
- case WEBKIT_LOAD_STARTED:
- case WEBKIT_LOAD_REDIRECTED:
- default:
- break;
+ case WEBKIT_LOAD_COMMITTED:
+ ephy_embed_destroy_top_widgets (embed);
+ break;
+ case WEBKIT_LOAD_FINISHED: {
+ const char *title = webkit_web_view_get_title (web_view);
+ if (ephy_web_view_get_is_blank (EPHY_WEB_VIEW (web_view)) || !title || !*title)
+ ephy_embed_set_title (embed, NULL);
+ break;
+ }
+ case WEBKIT_LOAD_STARTED:
+ case WEBKIT_LOAD_REDIRECTED:
+ default:
+ break;
}
}
@@ -330,8 +329,8 @@ ephy_embed_entering_fullscreen (EphyEmbed *embed)
g_source_remove (embed->fullscreen_message_id);
embed->fullscreen_message_id = g_timeout_add_seconds (5,
- (GSourceFunc)fullscreen_message_label_hide,
- embed);
+ (GSourceFunc)fullscreen_message_label_hide,
+ embed);
g_source_set_name_by_id (embed->fullscreen_message_id, "[epiphany] fullscreen_message_label_hide");
}
}
@@ -392,7 +391,7 @@ ephy_embed_finalize (GObject *object)
EphyEmbedShell *shell = ephy_embed_shell_get_default ();
GSList *list;
- g_signal_handlers_disconnect_by_func(shell, ephy_embed_restored_window_cb, embed);
+ g_signal_handlers_disconnect_by_func (shell, ephy_embed_restored_window_cb, embed);
list = embed->destroy_on_transition_list;
for (; list; list = list->next) {
@@ -424,52 +423,50 @@ ephy_embed_finalize (GObject *object)
}
static void
-ephy_embed_set_property (GObject *object,
- guint prop_id,
+ephy_embed_set_property (GObject *object,
+ guint prop_id,
const GValue *value,
- GParamSpec *pspec)
+ GParamSpec *pspec)
{
EphyEmbed *embed = EPHY_EMBED (object);
- switch (prop_id)
- {
- case PROP_WEB_VIEW:
- embed->web_view = g_value_get_object (value);
- break;
- case PROP_TITLE:
- ephy_embed_set_title (embed, g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ switch (prop_id) {
+ case PROP_WEB_VIEW:
+ embed->web_view = g_value_get_object (value);
+ break;
+ case PROP_TITLE:
+ ephy_embed_set_title (embed, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static void
-ephy_embed_get_property (GObject *object,
- guint prop_id,
- GValue *value,
+ephy_embed_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
GParamSpec *pspec)
{
EphyEmbed *embed = EPHY_EMBED (object);
- switch (prop_id)
- {
- case PROP_WEB_VIEW:
- g_value_set_object (value, ephy_embed_get_web_view (embed));
- break;
- case PROP_TITLE:
- g_value_set_string (value, ephy_embed_get_title (embed));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ switch (prop_id) {
+ case PROP_WEB_VIEW:
+ g_value_set_object (value, ephy_embed_get_web_view (embed));
+ break;
+ case PROP_TITLE:
+ g_value_set_string (value, ephy_embed_get_title (embed));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static void
ephy_embed_find_toolbar_close_cb (EphyFindToolbar *toolbar,
- EphyEmbed *embed)
+ EphyEmbed *embed)
{
ephy_find_toolbar_close (embed->find_toolbar);
@@ -508,7 +505,7 @@ ephy_embed_class_init (EphyEmbedClass *klass)
static gboolean
ephy_embed_attach_inspector_cb (WebKitWebInspector *inspector,
- EphyEmbed *embed)
+ EphyEmbed *embed)
{
GtkWidget *inspector_view = GTK_WIDGET (webkit_web_inspector_get_web_view (inspector));
int inspected_view_height;
@@ -526,7 +523,7 @@ ephy_embed_attach_inspector_cb (WebKitWebInspector *inspector,
static void
ephy_embed_set_fullscreen_message (EphyEmbed *embed,
- gboolean is_html5_fullscreen)
+ gboolean is_html5_fullscreen)
{
char *message;
@@ -539,7 +536,7 @@ ephy_embed_set_fullscreen_message (EphyEmbed *embed,
static gboolean
entering_fullscreen_cb (WebKitWebView *web_view,
- EphyEmbed *embed)
+ EphyEmbed *embed)
{
ephy_embed_set_fullscreen_message (embed, TRUE);
return FALSE;
@@ -547,7 +544,7 @@ entering_fullscreen_cb (WebKitWebView *web_view,
static gboolean
leaving_fullscreen_cb (WebKitWebView *web_view,
- EphyEmbed *embed)
+ EphyEmbed *embed)
{
ephy_embed_set_fullscreen_message (embed, FALSE);
return FALSE;
@@ -580,7 +577,7 @@ status_message_notify_cb (EphyWebView *view, GParamSpec *pspec, EphyEmbed *embed
ephy_embed_statusbar_push (embed, embed->tab_message_id, message);
} else {
/* A short timeout before hiding the statusbar ensures that while moving
- over a series of links, the overlay widget doesn't flicker on and off. */
+ over a series of links, the overlay widget doesn't flicker on and off. */
if (embed->pop_statusbar_later_source_id == 0) {
embed->pop_statusbar_later_source_id = g_timeout_add (250, pop_statusbar_later_cb, embed);
g_source_set_name_by_id (embed->pop_statusbar_later_source_id, "[epiphany] pop_statusbar_later_cb");
@@ -690,13 +687,13 @@ ephy_embed_restored_window_cb (EphyEmbedShell *shell, EphyEmbed *embed)
static void
ephy_embed_mapped_cb (GtkWidget *widget, gpointer data)
{
- ephy_embed_maybe_load_delayed_request ((EphyEmbed*)widget);
+ ephy_embed_maybe_load_delayed_request ((EphyEmbed *)widget);
}
static void
ephy_embed_constructed (GObject *object)
{
- EphyEmbed *embed = (EphyEmbed*)object;
+ EphyEmbed *embed = (EphyEmbed *)object;
EphyEmbedShell *shell = ephy_embed_shell_get_default ();
GtkWidget *paned;
WebKitWebInspector *inspector;
@@ -711,7 +708,7 @@ ephy_embed_constructed (GObject *object)
/* Skeleton */
overlay = gtk_overlay_new ();
- gtk_widget_add_events (overlay,
+ gtk_widget_add_events (overlay,
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK);
gtk_container_add (GTK_CONTAINER (overlay), GTK_WIDGET (embed->web_view));
@@ -800,12 +797,12 @@ ephy_embed_init (EphyEmbed *embed)
/**
* ephy_embed_get_web_view:
* @embed: and #EphyEmbed
- *
+ *
* Returns the #EphyWebView wrapped by @embed.
- *
+ *
* Returns: (transfer none): an #EphyWebView
**/
-EphyWebView*
+EphyWebView *
ephy_embed_get_web_view (EphyEmbed *embed)
{
g_return_val_if_fail (EPHY_IS_EMBED (embed), NULL);
@@ -816,12 +813,12 @@ ephy_embed_get_web_view (EphyEmbed *embed)
/**
* ephy_embed_get_find_toolbar:
* @embed: and #EphyEmbed
- *
+ *
* Returns the #EphyFindToolbar wrapped by @embed.
- *
+ *
* Returns: (transfer none): an #EphyFindToolbar
**/
-EphyFindToolbar*
+EphyFindToolbar *
ephy_embed_get_find_toolbar (EphyEmbed *embed)
{
g_return_val_if_fail (EPHY_IS_EMBED (embed), NULL);
diff --git a/embed/ephy-encoding.c b/embed/ephy-encoding.c
index a0665a5..dec62df 100644
--- a/embed/ephy-encoding.c
+++ b/embed/ephy-encoding.c
@@ -21,8 +21,7 @@
#include <string.h>
-struct _EphyEncoding
-{
+struct _EphyEncoding {
GObject parent_instance;
char *title;
@@ -62,9 +61,9 @@ ephy_encoding_finalize (GObject *object)
}
static void
-ephy_encoding_get_property (GObject *object,
- guint prop_id,
- GValue *value,
+ephy_encoding_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
GParamSpec *pspec)
{
EphyEncoding *encoding = EPHY_ENCODING (object);
@@ -105,8 +104,7 @@ elide_underscores (const char *original)
for (p = original; *p; p++) {
if (!last_underscore && *p == '_') {
last_underscore = TRUE;
- }
- else {
+ } else {
last_underscore = FALSE;
*q++ = *p;
}
@@ -118,53 +116,53 @@ elide_underscores (const char *original)
}
static void
-ephy_encoding_set_property (GObject *object,
- guint prop_id,
+ephy_encoding_set_property (GObject *object,
+ guint prop_id,
const GValue *value,
- GParamSpec *pspec)
+ GParamSpec *pspec)
{
EphyEncoding *encoding = EPHY_ENCODING (object);
switch (prop_id) {
- case PROP_TITLE: {
- char *elided, *collate_key, *normalised;
-
- g_free (encoding->title);
- encoding->title = g_strdup (g_value_get_string (value));
-
- elided = elide_underscores (encoding->title);
- normalised = g_utf8_normalize (elided, -1, G_NORMALIZE_DEFAULT);
- collate_key = g_utf8_collate_key (normalised, -1);
-
- g_object_set (object,
- "title-elided", elided,
- "collation-key", collate_key,
- NULL);
-
- g_free (collate_key);
- g_free (normalised);
- g_free (elided);
-
- break;
- }
- case PROP_TITLE_ELIDED:
- g_free (encoding->title_elided);
- encoding->title_elided = g_strdup (g_value_get_string (value));
- break;
- case PROP_COLLATION_KEY:
- g_free (encoding->collation_key);
- encoding->collation_key = g_strdup (g_value_get_string (value));
- break;
- case PROP_ENCODING:
- g_free (encoding->encoding);
- encoding->encoding = g_strdup (g_value_get_string (value));
- break;
- case PROP_LANGUAGE_GROUPS:
- encoding->language_groups = g_value_get_int (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case PROP_TITLE: {
+ char *elided, *collate_key, *normalised;
+
+ g_free (encoding->title);
+ encoding->title = g_strdup (g_value_get_string (value));
+
+ elided = elide_underscores (encoding->title);
+ normalised = g_utf8_normalize (elided, -1, G_NORMALIZE_DEFAULT);
+ collate_key = g_utf8_collate_key (normalised, -1);
+
+ g_object_set (object,
+ "title-elided", elided,
+ "collation-key", collate_key,
+ NULL);
+
+ g_free (collate_key);
+ g_free (normalised);
+ g_free (elided);
+
+ break;
+ }
+ case PROP_TITLE_ELIDED:
+ g_free (encoding->title_elided);
+ encoding->title_elided = g_strdup (g_value_get_string (value));
+ break;
+ case PROP_COLLATION_KEY:
+ g_free (encoding->collation_key);
+ encoding->collation_key = g_strdup (g_value_get_string (value));
+ break;
+ case PROP_ENCODING:
+ g_free (encoding->encoding);
+ encoding->encoding = g_strdup (g_value_get_string (value));
+ break;
+ case PROP_LANGUAGE_GROUPS:
+ encoding->language_groups = g_value_get_int (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
@@ -193,25 +191,25 @@ ephy_encoding_class_init (EphyEncodingClass *klass)
obj_properties[PROP_COLLATION_KEY] =
g_param_spec_string ("collation-key",
- "Collation Key",
- "The encoding's collation key",
- "",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ "Collation Key",
+ "The encoding's collation key",
+ "",
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
obj_properties[PROP_ENCODING] =
g_param_spec_string ("encoding",
- "Encoding",
- "The encoding's encoding",
- "",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ "Encoding",
+ "The encoding's encoding",
+ "",
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
obj_properties[PROP_LANGUAGE_GROUPS] =
g_param_spec_int ("language-groups",
- "Language Groups",
- "The encoding's language groups",
- LG_NONE, LG_ALL,
- LG_NONE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ "Language Groups",
+ "The encoding's language groups",
+ LG_NONE, LG_ALL,
+ LG_NONE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, LAST_PROP, obj_properties);
}
diff --git a/embed/ephy-encodings.c b/embed/ephy-encodings.c
index faac080..ccceb2a 100644
--- a/embed/ephy-encodings.c
+++ b/embed/ephy-encodings.c
@@ -27,16 +27,14 @@
#include <glib/gi18n.h>
-struct _EphyEncodings
-{
+struct _EphyEncodings {
GObject parent_instance;
GHashTable *hash;
GSList *recent;
};
-enum
-{
+enum {
ENCODING_ADDED,
LAST_SIGNAL
};
@@ -48,98 +46,97 @@ static guint signals[LAST_SIGNAL];
* NOTE: if you add/remove/change encodings, please also update the
* schema in epiphany.schemas.in
*/
-static const
-struct
-{
+static const
+struct {
const char *title;
const char *code;
EphyLanguageGroup groups;
}
encoding_entries [] =
-{
- { N_("Arabic (_IBM-864)"), "IBM864", LG_ARABIC },
- { N_("Arabic (ISO-_8859-6)"), "ISO-8859-6", LG_ARABIC },
- { N_("Arabic (_MacArabic)"), "x-mac-arabic", LG_ARABIC },
- { N_("Arabic (_Windows-1256)"), "windows-1256", LG_ARABIC },
- { N_("Baltic (_ISO-8859-13)"), "ISO-8859-13", LG_BALTIC },
- { N_("Baltic (I_SO-8859-4)"), "ISO-8859-4", LG_BALTIC },
- { N_("Baltic (_Windows-1257)"), "windows-1257", LG_BALTIC },
- { N_("_Armenian (ARMSCII-8)"), "armscii-8", LG_CAUCASIAN },
- { N_("_Georgian (GEOSTD8)"), "geostd8", LG_CAUCASIAN },
- { N_("Central European (_IBM-852)"), "IBM852", LG_C_EUROPEAN },
- { N_("Central European (I_SO-8859-2)"), "ISO-8859-2", LG_C_EUROPEAN },
- { N_("Central European (_MacCE)"), "x-mac-ce", LG_C_EUROPEAN },
- { N_("Central European (_Windows-1250)"), "windows-1250", LG_C_EUROPEAN },
- { N_("Chinese Simplified (_GB18030)"), "gb18030", LG_CHINESE_SIMP },
- { N_("Chinese Simplified (G_B2312)"), "GB2312", LG_CHINESE_SIMP },
- { N_("Chinese Simplified (GB_K)"), "x-gbk", LG_CHINESE_SIMP },
- { N_("Chinese Simplified (_HZ)"), "HZ-GB-2312", LG_CHINESE_SIMP },
- { N_("Chinese Simplified (_ISO-2022-CN)"), "ISO-2022-CN", LG_CHINESE_SIMP },
- { N_("Chinese Traditional (Big_5)"), "Big5", LG_CHINESE_TRAD },
- { N_("Chinese Traditional (Big5-HK_SCS)"), "Big5-HKSCS", LG_CHINESE_TRAD },
- { N_("Chinese Traditional (_EUC-TW)"), "x-euc-tw", LG_CHINESE_TRAD },
- { N_("Cyrillic (_IBM-855)"), "IBM855", LG_CYRILLIC },
- { N_("Cyrillic (I_SO-8859-5)"), "ISO-8859-5", LG_CYRILLIC },
- { N_("Cyrillic (IS_O-IR-111)"), "ISO-IR-111", LG_CYRILLIC },
- { N_("Cyrillic (_KOI8-R)"), "KOI8-R", LG_CYRILLIC },
- { N_("Cyrillic (_MacCyrillic)"), "x-mac-cyrillic", LG_CYRILLIC },
- { N_("Cyrillic (_Windows-1251)"), "windows-1251", LG_CYRILLIC },
- { N_("Cyrillic/_Russian (IBM-866)"), "IBM866", LG_CYRILLIC },
- { N_("Greek (_ISO-8859-7)"), "ISO-8859-7", LG_GREEK },
- { N_("Greek (_MacGreek)"), "x-mac-greek", LG_GREEK },
- { N_("Greek (_Windows-1253)"), "windows-1253", LG_GREEK },
- { N_("Gujarati (_MacGujarati)"), "x-mac-gujarati", LG_INDIAN },
- { N_("Gurmukhi (Mac_Gurmukhi)"), "x-mac-gurmukhi", LG_INDIAN },
- { N_("Hindi (Mac_Devanagari)"), "x-mac-devanagari", LG_INDIAN },
- { N_("Hebrew (_IBM-862)"), "IBM862", LG_HEBREW },
- { N_("Hebrew (IS_O-8859-8-I)"), "ISO-8859-8-I", LG_HEBREW },
- { N_("Hebrew (_MacHebrew)"), "x-mac-hebrew", LG_HEBREW },
- { N_("Hebrew (_Windows-1255)"), "windows-1255", LG_HEBREW },
- { N_("_Visual Hebrew (ISO-8859-8)"), "ISO-8859-8", LG_HEBREW },
- { N_("Japanese (_EUC-JP)"), "EUC-JP", LG_JAPANESE },
- { N_("Japanese (_ISO-2022-JP)"), "ISO-2022-JP", LG_JAPANESE },
- { N_("Japanese (_Shift-JIS)"), "Shift_JIS", LG_JAPANESE },
- { N_("Korean (_EUC-KR)"), "EUC-KR", LG_KOREAN },
- { N_("Korean (_ISO-2022-KR)"), "ISO-2022-KR", LG_KOREAN },
- { N_("Korean (_JOHAB)"), "x-johab", LG_KOREAN },
- { N_("Korean (_UHC)"), "x-windows-949", LG_KOREAN },
- { N_("_Celtic (ISO-8859-14)"), "ISO-8859-14", LG_NORDIC },
- { N_("_Icelandic (MacIcelandic)"), "x-mac-icelandic", LG_NORDIC },
- { N_("_Nordic (ISO-8859-10)"), "ISO-8859-10", LG_NORDIC },
- { N_("_Persian (MacFarsi)"), "x-mac-farsi", LG_PERSIAN },
- { N_("Croatian (Mac_Croatian)"), "x-mac-croatian", LG_SE_EUROPEAN },
- { N_("_Romanian (MacRomanian)"), "x-mac-romanian", LG_SE_EUROPEAN },
- { N_("R_omanian (ISO-8859-16)"), "ISO-8859-16", LG_SE_EUROPEAN },
- { N_("South _European (ISO-8859-3)"), "ISO-8859-3", LG_SE_EUROPEAN },
- { N_("Thai (TIS-_620)"), "TIS-620", LG_THAI },
- { N_("Thai (IS_O-8859-11)"), "iso-8859-11", LG_THAI },
- { N_("_Thai (Windows-874)"), "windows-874", LG_THAI },
- { N_("Turkish (_IBM-857)"), "IBM857", LG_TURKISH },
- { N_("Turkish (I_SO-8859-9)"), "ISO-8859-9", LG_TURKISH },
- { N_("Turkish (_MacTurkish)"), "x-mac-turkish", LG_TURKISH },
- { N_("Turkish (_Windows-1254)"), "windows-1254", LG_TURKISH },
- { N_("Unicode (UTF-_8)"), "UTF-8", LG_UNICODE },
- { N_("Cyrillic/Ukrainian (_KOI8-U)"), "KOI8-U", LG_UKRAINIAN },
- { N_("Cyrillic/Ukrainian (Mac_Ukrainian)"), "x-mac-ukrainian", LG_UKRAINIAN },
- { N_("Vietnamese (_TCVN)"), "x-viet-tcvn5712", LG_VIETNAMESE },
- { N_("Vietnamese (_VISCII)"), "VISCII", LG_VIETNAMESE },
- { N_("Vietnamese (V_PS)"), "x-viet-vps", LG_VIETNAMESE },
- { N_("Vietnamese (_Windows-1258)"), "windows-1258", LG_VIETNAMESE },
- { N_("Western (_IBM-850)"), "IBM850", LG_WESTERN },
- { N_("Western (_ISO-8859-1)"), "ISO-8859-1", LG_WESTERN },
- { N_("Western (IS_O-8859-15)"), "ISO-8859-15", LG_WESTERN },
- { N_("Western (_MacRoman)"), "x-mac-roman", LG_WESTERN },
- { N_("Western (_Windows-1252)"), "windows-1252", LG_WESTERN },
+{
+ { N_("Arabic (_IBM-864)"), "IBM864", LG_ARABIC },
+ { N_("Arabic (ISO-_8859-6)"), "ISO-8859-6", LG_ARABIC },
+ { N_("Arabic (_MacArabic)"), "x-mac-arabic", LG_ARABIC },
+ { N_("Arabic (_Windows-1256)"), "windows-1256", LG_ARABIC },
+ { N_("Baltic (_ISO-8859-13)"), "ISO-8859-13", LG_BALTIC },
+ { N_("Baltic (I_SO-8859-4)"), "ISO-8859-4", LG_BALTIC },
+ { N_("Baltic (_Windows-1257)"), "windows-1257", LG_BALTIC },
+ { N_("_Armenian (ARMSCII-8)"), "armscii-8", LG_CAUCASIAN },
+ { N_("_Georgian (GEOSTD8)"), "geostd8", LG_CAUCASIAN },
+ { N_("Central European (_IBM-852)"), "IBM852", LG_C_EUROPEAN },
+ { N_("Central European (I_SO-8859-2)"), "ISO-8859-2", LG_C_EUROPEAN },
+ { N_("Central European (_MacCE)"), "x-mac-ce", LG_C_EUROPEAN },
+ { N_("Central European (_Windows-1250)"), "windows-1250", LG_C_EUROPEAN },
+ { N_("Chinese Simplified (_GB18030)"), "gb18030", LG_CHINESE_SIMP },
+ { N_("Chinese Simplified (G_B2312)"), "GB2312", LG_CHINESE_SIMP },
+ { N_("Chinese Simplified (GB_K)"), "x-gbk", LG_CHINESE_SIMP },
+ { N_("Chinese Simplified (_HZ)"), "HZ-GB-2312", LG_CHINESE_SIMP },
+ { N_("Chinese Simplified (_ISO-2022-CN)"), "ISO-2022-CN", LG_CHINESE_SIMP },
+ { N_("Chinese Traditional (Big_5)"), "Big5", LG_CHINESE_TRAD },
+ { N_("Chinese Traditional (Big5-HK_SCS)"), "Big5-HKSCS", LG_CHINESE_TRAD },
+ { N_("Chinese Traditional (_EUC-TW)"), "x-euc-tw", LG_CHINESE_TRAD },
+ { N_("Cyrillic (_IBM-855)"), "IBM855", LG_CYRILLIC },
+ { N_("Cyrillic (I_SO-8859-5)"), "ISO-8859-5", LG_CYRILLIC },
+ { N_("Cyrillic (IS_O-IR-111)"), "ISO-IR-111", LG_CYRILLIC },
+ { N_("Cyrillic (_KOI8-R)"), "KOI8-R", LG_CYRILLIC },
+ { N_("Cyrillic (_MacCyrillic)"), "x-mac-cyrillic", LG_CYRILLIC },
+ { N_("Cyrillic (_Windows-1251)"), "windows-1251", LG_CYRILLIC },
+ { N_("Cyrillic/_Russian (IBM-866)"), "IBM866", LG_CYRILLIC },
+ { N_("Greek (_ISO-8859-7)"), "ISO-8859-7", LG_GREEK },
+ { N_("Greek (_MacGreek)"), "x-mac-greek", LG_GREEK },
+ { N_("Greek (_Windows-1253)"), "windows-1253", LG_GREEK },
+ { N_("Gujarati (_MacGujarati)"), "x-mac-gujarati", LG_INDIAN },
+ { N_("Gurmukhi (Mac_Gurmukhi)"), "x-mac-gurmukhi", LG_INDIAN },
+ { N_("Hindi (Mac_Devanagari)"), "x-mac-devanagari", LG_INDIAN },
+ { N_("Hebrew (_IBM-862)"), "IBM862", LG_HEBREW },
+ { N_("Hebrew (IS_O-8859-8-I)"), "ISO-8859-8-I", LG_HEBREW },
+ { N_("Hebrew (_MacHebrew)"), "x-mac-hebrew", LG_HEBREW },
+ { N_("Hebrew (_Windows-1255)"), "windows-1255", LG_HEBREW },
+ { N_("_Visual Hebrew (ISO-8859-8)"), "ISO-8859-8", LG_HEBREW },
+ { N_("Japanese (_EUC-JP)"), "EUC-JP", LG_JAPANESE },
+ { N_("Japanese (_ISO-2022-JP)"), "ISO-2022-JP", LG_JAPANESE },
+ { N_("Japanese (_Shift-JIS)"), "Shift_JIS", LG_JAPANESE },
+ { N_("Korean (_EUC-KR)"), "EUC-KR", LG_KOREAN },
+ { N_("Korean (_ISO-2022-KR)"), "ISO-2022-KR", LG_KOREAN },
+ { N_("Korean (_JOHAB)"), "x-johab", LG_KOREAN },
+ { N_("Korean (_UHC)"), "x-windows-949", LG_KOREAN },
+ { N_("_Celtic (ISO-8859-14)"), "ISO-8859-14", LG_NORDIC },
+ { N_("_Icelandic (MacIcelandic)"), "x-mac-icelandic", LG_NORDIC },
+ { N_("_Nordic (ISO-8859-10)"), "ISO-8859-10", LG_NORDIC },
+ { N_("_Persian (MacFarsi)"), "x-mac-farsi", LG_PERSIAN },
+ { N_("Croatian (Mac_Croatian)"), "x-mac-croatian", LG_SE_EUROPEAN },
+ { N_("_Romanian (MacRomanian)"), "x-mac-romanian", LG_SE_EUROPEAN },
+ { N_("R_omanian (ISO-8859-16)"), "ISO-8859-16", LG_SE_EUROPEAN },
+ { N_("South _European (ISO-8859-3)"), "ISO-8859-3", LG_SE_EUROPEAN },
+ { N_("Thai (TIS-_620)"), "TIS-620", LG_THAI },
+ { N_("Thai (IS_O-8859-11)"), "iso-8859-11", LG_THAI },
+ { N_("_Thai (Windows-874)"), "windows-874", LG_THAI },
+ { N_("Turkish (_IBM-857)"), "IBM857", LG_TURKISH },
+ { N_("Turkish (I_SO-8859-9)"), "ISO-8859-9", LG_TURKISH },
+ { N_("Turkish (_MacTurkish)"), "x-mac-turkish", LG_TURKISH },
+ { N_("Turkish (_Windows-1254)"), "windows-1254", LG_TURKISH },
+ { N_("Unicode (UTF-_8)"), "UTF-8", LG_UNICODE },
+ { N_("Cyrillic/Ukrainian (_KOI8-U)"), "KOI8-U", LG_UKRAINIAN },
+ { N_("Cyrillic/Ukrainian (Mac_Ukrainian)"), "x-mac-ukrainian", LG_UKRAINIAN },
+ { N_("Vietnamese (_TCVN)"), "x-viet-tcvn5712", LG_VIETNAMESE },
+ { N_("Vietnamese (_VISCII)"), "VISCII", LG_VIETNAMESE },
+ { N_("Vietnamese (V_PS)"), "x-viet-vps", LG_VIETNAMESE },
+ { N_("Vietnamese (_Windows-1258)"), "windows-1258", LG_VIETNAMESE },
+ { N_("Western (_IBM-850)"), "IBM850", LG_WESTERN },
+ { N_("Western (_ISO-8859-1)"), "ISO-8859-1", LG_WESTERN },
+ { N_("Western (IS_O-8859-15)"), "ISO-8859-15", LG_WESTERN },
+ { N_("Western (_MacRoman)"), "x-mac-roman", LG_WESTERN },
+ { N_("Western (_Windows-1252)"), "windows-1252", LG_WESTERN },
/* The following encodings are so rarely used that we don't want to
* pollute the "related" part of the encodings menu with them, so we
* set the language group to 0 here.
*/
- { N_("English (_US-ASCII)"), "us-ascii", 0 },
- { N_("Unicode (UTF-_16 BE)"), "UTF-16BE", 0 },
- { N_("Unicode (UTF-1_6 LE)"), "UTF-16LE", 0 },
- { N_("Unicode (UTF-_32 BE)"), "UTF-32BE", 0 },
- { N_("Unicode (UTF-3_2 LE)"), "UTF-32LE", 0 },
+ { N_("English (_US-ASCII)"), "us-ascii", 0 },
+ { N_("Unicode (UTF-_16 BE)"), "UTF-16BE", 0 },
+ { N_("Unicode (UTF-1_6 LE)"), "UTF-16LE", 0 },
+ { N_("Unicode (UTF-_32 BE)"), "UTF-32BE", 0 },
+ { N_("Unicode (UTF-3_2 LE)"), "UTF-32LE", 0 },
};
#define RECENT_MAX 4
@@ -183,9 +180,9 @@ ephy_encodings_class_init (EphyEncodingsClass *klass)
}
static EphyEncoding *
-add_encoding (EphyEncodings *encodings,
- const char *title,
- const char *code,
+add_encoding (EphyEncodings *encodings,
+ const char *title,
+ const char *code,
EphyLanguageGroup groups)
{
EphyEncoding *encoding;
@@ -202,8 +199,8 @@ add_encoding (EphyEncodings *encodings,
EphyEncoding *
ephy_encodings_get_encoding (EphyEncodings *encodings,
- const char *code,
- gboolean add_if_not_found)
+ const char *code,
+ gboolean add_if_not_found)
{
EphyEncoding *encoding;
@@ -236,16 +233,16 @@ get_encodings_foreach (gpointer key,
gpointer value,
gpointer user_data)
{
- GetEncodingsData *data = (GetEncodingsData*)user_data;
+ GetEncodingsData *data = (GetEncodingsData *)user_data;
EphyLanguageGroup group;
-
+
group = ephy_encoding_get_language_groups (EPHY_ENCODING (value));
if ((group & data->group_mask) != 0)
data->list = g_list_prepend (data->list, value);
}
GList *
-ephy_encodings_get_encodings (EphyEncodings *encodings,
+ephy_encodings_get_encodings (EphyEncodings *encodings,
EphyLanguageGroup group_mask)
{
GList *list = NULL;
@@ -264,7 +261,7 @@ get_all_encodings (gpointer key,
gpointer value,
gpointer user_data)
{
- GList **l = (GList**)user_data;
+ GList **l = (GList **)user_data;
*l = g_list_prepend (*l, value);
}
@@ -283,14 +280,14 @@ ephy_encodings_get_all (EphyEncodings *encodings)
void
ephy_encodings_add_recent (EphyEncodings *encodings,
- const char *code)
+ const char *code)
{
GSList *element, *l;
GVariantBuilder builder;
g_return_if_fail (EPHY_IS_ENCODINGS (encodings));
g_return_if_fail (code != NULL);
-
+
if (ephy_encodings_get_encoding (encodings, code, FALSE) == NULL)
return;
@@ -368,7 +365,7 @@ ephy_encodings_init (EphyEncodings *encodings)
/* Get the list of recently used encodings. */
list = g_settings_get_strv (EPHY_SETTINGS_STATE,
- EPHY_PREFS_STATE_RECENT_ENCODINGS);
+ EPHY_PREFS_STATE_RECENT_ENCODINGS);
/* Make sure the list has no duplicates (GtkUIManager goes
* crazy otherwise), and only valid entries.
diff --git a/embed/ephy-file-monitor.c b/embed/ephy-file-monitor.c
index 7e2e069..7bd377d 100644
--- a/embed/ephy-file-monitor.c
+++ b/embed/ephy-file-monitor.c
@@ -27,8 +27,7 @@
#define RELOAD_DELAY 250 /* ms */
#define RELOAD_DELAY_MAX_TICKS 40 /* RELOAD_DELAY * RELOAD_DELAY_MAX_TICKS = 10 s */
-struct _EphyFileMonitor
-{
+struct _EphyFileMonitor {
GObject parent;
GFileMonitor *monitor;
@@ -100,11 +99,11 @@ ephy_file_monitor_reload_cb (EphyFileMonitor *monitor)
}
static void
-ephy_file_monitor_changed_cb (GFileMonitor *monitor,
- GFile *file,
- GFile *other_file,
+ephy_file_monitor_changed_cb (GFileMonitor *monitor,
+ GFile *file,
+ GFile *other_file,
GFileMonitorEvent event_type,
- EphyFileMonitor *file_monitor)
+ EphyFileMonitor *file_monitor)
{
gboolean should_reload;
@@ -162,7 +161,7 @@ ephy_file_monitor_changed_cb (GFileMonitor *monitor,
void
ephy_file_monitor_update_location (EphyFileMonitor *file_monitor,
- const char *address)
+ const char *address)
{
gboolean local;
char *anchor;
@@ -207,8 +206,7 @@ ephy_file_monitor_update_location (EphyFileMonitor *file_monitor,
file_monitor);
file_monitor->monitor_directory = TRUE;
LOG ("Installed monitor for directory '%s'", url);
- }
- else if (file_type == G_FILE_TYPE_REGULAR) {
+ } else if (file_type == G_FILE_TYPE_REGULAR) {
file_monitor->monitor = g_file_monitor_file (file, 0, NULL, NULL);
g_signal_connect (file_monitor->monitor, "changed",
G_CALLBACK (ephy_file_monitor_changed_cb),
@@ -230,9 +228,9 @@ ephy_file_monitor_dispose (GObject *object)
}
static void
-ephy_file_monitor_get_property (GObject *object,
- guint prop_id,
- GValue *value,
+ephy_file_monitor_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
GParamSpec *pspec)
{
EphyFileMonitor *monitor = EPHY_FILE_MONITOR (object);
@@ -242,16 +240,16 @@ ephy_file_monitor_get_property (GObject *object,
g_value_set_object (value, monitor->view);
break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
-ephy_file_monitor_set_property (GObject *object,
- guint prop_id,
+ephy_file_monitor_set_property (GObject *object,
+ guint prop_id,
const GValue *value,
- GParamSpec *pspec)
+ GParamSpec *pspec)
{
EphyFileMonitor *monitor = EPHY_FILE_MONITOR (object);
@@ -260,7 +258,7 @@ ephy_file_monitor_set_property (GObject *object,
monitor->view = g_value_get_object (value);
break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
@@ -276,10 +274,10 @@ ephy_file_monitor_class_init (EphyFileMonitorClass *klass)
obj_properties[PROP_VIEW] =
g_param_spec_object ("view",
- "View",
- "The file monitor's associated view",
- EPHY_TYPE_WEB_VIEW,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+ "View",
+ "The file monitor's associated view",
+ EPHY_TYPE_WEB_VIEW,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, LAST_PROP, obj_properties);
}
diff --git a/embed/ephy-find-toolbar.c b/embed/ephy-find-toolbar.c
index 54d2c75..0efe2e8 100644
--- a/embed/ephy-find-toolbar.c
+++ b/embed/ephy-find-toolbar.c
@@ -31,55 +31,50 @@
#include <string.h>
#include <webkit2/webkit2.h>
-struct _EphyFindToolbar
-{
- GtkSearchBar parent_instance;
-
- WebKitWebView *web_view;
- WebKitFindController *controller;
- GtkWidget *entry;
- GtkWidget *next;
- GtkWidget *prev;
- guint find_again_source_id;
- guint find_source_id;
- char *find_string;
- guint preedit_changed : 1;
- guint prevent_activate : 1;
- guint activated : 1;
- guint links_only : 1;
- guint typing_ahead : 1;
+struct _EphyFindToolbar {
+ GtkSearchBar parent_instance;
+
+ WebKitWebView *web_view;
+ WebKitFindController *controller;
+ GtkWidget *entry;
+ GtkWidget *next;
+ GtkWidget *prev;
+ guint find_again_source_id;
+ guint find_source_id;
+ char *find_string;
+ guint preedit_changed : 1;
+ guint prevent_activate : 1;
+ guint activated : 1;
+ guint links_only : 1;
+ guint typing_ahead : 1;
};
G_DEFINE_TYPE (EphyFindToolbar, ephy_find_toolbar, GTK_TYPE_SEARCH_BAR)
-enum
-{
- PROP_0,
- PROP_WEB_VIEW,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_WEB_VIEW,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
-enum
-{
- CLOSE,
- LAST_SIGNAL
+enum {
+ CLOSE,
+ LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
-typedef enum
-{
- EPHY_FIND_RESULT_FOUND = 0,
- EPHY_FIND_RESULT_NOTFOUND = 1,
- EPHY_FIND_RESULT_FOUNDWRAPPED = 2
+typedef enum {
+ EPHY_FIND_RESULT_FOUND = 0,
+ EPHY_FIND_RESULT_NOTFOUND = 1,
+ EPHY_FIND_RESULT_FOUNDWRAPPED = 2
} EphyFindResult;
-typedef enum
-{
- EPHY_FIND_DIRECTION_NEXT,
- EPHY_FIND_DIRECTION_PREV
+typedef enum {
+ EPHY_FIND_DIRECTION_NEXT,
+ EPHY_FIND_DIRECTION_PREV
} EphyFindDirection;
/* private functions */
@@ -88,253 +83,239 @@ static void ephy_find_toolbar_set_web_view (EphyFindToolbar *toolbar, WebKitWebV
static void
set_status (EphyFindToolbar *toolbar,
- EphyFindResult result)
-{
- const char *icon_name = "edit-find-symbolic";
- const char *tooltip = NULL;
-
- switch (result)
- {
- case EPHY_FIND_RESULT_FOUND:
- break;
- case EPHY_FIND_RESULT_NOTFOUND:
- icon_name = "face-uncertain-symbolic";
- tooltip = _("Text not found");
- gtk_widget_error_bell (GTK_WIDGET (toolbar));
-
- break;
- case EPHY_FIND_RESULT_FOUNDWRAPPED:
- icon_name = "view-wrapped-symbolic";
- tooltip = _("Search wrapped back to the top");
- break;
-
- default:
- g_assert_not_reached ();
- }
-
- gtk_widget_set_sensitive (toolbar->prev, result != EPHY_FIND_RESULT_NOTFOUND);
- gtk_widget_set_sensitive (toolbar->next, result != EPHY_FIND_RESULT_NOTFOUND);
-
- g_object_set (toolbar->entry,
- "primary-icon-name", icon_name,
- "primary-icon-activatable", FALSE,
- "primary-icon-sensitive", FALSE,
- "primary-icon-tooltip-text", tooltip,
- NULL);
+ EphyFindResult result)
+{
+ const char *icon_name = "edit-find-symbolic";
+ const char *tooltip = NULL;
+
+ switch (result) {
+ case EPHY_FIND_RESULT_FOUND:
+ break;
+ case EPHY_FIND_RESULT_NOTFOUND:
+ icon_name = "face-uncertain-symbolic";
+ tooltip = _("Text not found");
+ gtk_widget_error_bell (GTK_WIDGET (toolbar));
+
+ break;
+ case EPHY_FIND_RESULT_FOUNDWRAPPED:
+ icon_name = "view-wrapped-symbolic";
+ tooltip = _("Search wrapped back to the top");
+ break;
+
+ default:
+ g_assert_not_reached ();
+ }
+
+ gtk_widget_set_sensitive (toolbar->prev, result != EPHY_FIND_RESULT_NOTFOUND);
+ gtk_widget_set_sensitive (toolbar->next, result != EPHY_FIND_RESULT_NOTFOUND);
+
+ g_object_set (toolbar->entry,
+ "primary-icon-name", icon_name,
+ "primary-icon-activatable", FALSE,
+ "primary-icon-sensitive", FALSE,
+ "primary-icon-tooltip-text", tooltip,
+ NULL);
}
static void
clear_status (EphyFindToolbar *toolbar)
{
- g_object_set (toolbar->entry,
- "primary-icon-name", "edit-find-symbolic",
- NULL);
+ g_object_set (toolbar->entry,
+ "primary-icon-name", "edit-find-symbolic",
+ NULL);
- gtk_widget_set_sensitive (toolbar->prev, FALSE);
- gtk_widget_set_sensitive (toolbar->next, FALSE);
+ gtk_widget_set_sensitive (toolbar->prev, FALSE);
+ gtk_widget_set_sensitive (toolbar->next, FALSE);
- if (toolbar->web_view == NULL) return;
+ if (toolbar->web_view == NULL) return;
- webkit_find_controller_search_finish (toolbar->controller);
+ webkit_find_controller_search_finish (toolbar->controller);
}
/* Code adapted from gtktreeview.c:gtk_tree_view_key_press() and
* gtk_tree_view_real_start_interactive_seach()
*/
static gboolean
-tab_search_key_press_cb (WebKitWebView *web_view,
- GdkEventKey *event,
- EphyFindToolbar *toolbar)
+tab_search_key_press_cb (WebKitWebView *web_view,
+ GdkEventKey *event,
+ EphyFindToolbar *toolbar)
{
- GtkWidget *widget = (GtkWidget *) toolbar;
-
- g_return_val_if_fail (event != NULL, FALSE);
-
- /* check for / and ' which open the find toolbar in text resp. link mode */
- if (gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (widget)) == FALSE)
- {
- if (event->keyval == GDK_KEY_slash)
- {
- ephy_find_toolbar_open (toolbar, FALSE, TRUE);
- return TRUE;
- }
- else if (event->keyval == GDK_KEY_apostrophe)
- {
- ephy_find_toolbar_open (toolbar, TRUE, TRUE);
- return TRUE;
- }
- }
-
- return FALSE;
+ GtkWidget *widget = (GtkWidget *)toolbar;
+
+ g_return_val_if_fail (event != NULL, FALSE);
+
+ /* check for / and ' which open the find toolbar in text resp. link mode */
+ if (gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (widget)) == FALSE) {
+ if (event->keyval == GDK_KEY_slash) {
+ ephy_find_toolbar_open (toolbar, FALSE, TRUE);
+ return TRUE;
+ } else if (event->keyval == GDK_KEY_apostrophe) {
+ ephy_find_toolbar_open (toolbar, TRUE, TRUE);
+ return TRUE;
+ }
+ }
+
+ return FALSE;
}
static void
-real_find (EphyFindToolbar *toolbar,
+real_find (EphyFindToolbar *toolbar,
EphyFindDirection direction)
{
- WebKitFindOptions options = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE;
+ WebKitFindOptions options = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE;
- if (!g_strcmp0 (toolbar->find_string, ""))
- return;
+ if (!g_strcmp0 (toolbar->find_string, ""))
+ return;
- if (direction == EPHY_FIND_DIRECTION_PREV)
- options |= WEBKIT_FIND_OPTIONS_BACKWARDS;
+ if (direction == EPHY_FIND_DIRECTION_PREV)
+ options |= WEBKIT_FIND_OPTIONS_BACKWARDS;
- webkit_find_controller_search (toolbar->controller, toolbar->find_string, options, G_MAXUINT);
+ webkit_find_controller_search (toolbar->controller, toolbar->find_string, options, G_MAXUINT);
}
static gboolean
do_search (EphyFindToolbar *toolbar)
{
- toolbar->find_source_id = 0;
+ toolbar->find_source_id = 0;
- real_find (toolbar, EPHY_FIND_DIRECTION_NEXT);
+ real_find (toolbar, EPHY_FIND_DIRECTION_NEXT);
- return FALSE;
+ return FALSE;
}
static void
found_text_cb (WebKitFindController *controller,
- guint n_matches,
- EphyFindToolbar *toolbar)
+ guint n_matches,
+ EphyFindToolbar *toolbar)
{
- WebKitFindOptions options;
- EphyFindResult result;
+ WebKitFindOptions options;
+ EphyFindResult result;
- options = webkit_find_controller_get_options (controller);
- /* FIXME: it's not possible to remove the wrap flag, so the status is now always wrapped. */
- result = options & WEBKIT_FIND_OPTIONS_WRAP_AROUND ? EPHY_FIND_RESULT_FOUNDWRAPPED :
EPHY_FIND_RESULT_FOUND;
- set_status (toolbar, result);
+ options = webkit_find_controller_get_options (controller);
+ /* FIXME: it's not possible to remove the wrap flag, so the status is now always wrapped. */
+ result = options & WEBKIT_FIND_OPTIONS_WRAP_AROUND ? EPHY_FIND_RESULT_FOUNDWRAPPED :
EPHY_FIND_RESULT_FOUND;
+ set_status (toolbar, result);
}
static void
failed_to_find_text_cb (WebKitFindController *controller,
- EphyFindToolbar *toolbar)
+ EphyFindToolbar *toolbar)
{
- WebKitFindOptions options;
+ WebKitFindOptions options;
- options = webkit_find_controller_get_options (controller);
- if (options & WEBKIT_FIND_OPTIONS_WRAP_AROUND) {
- set_status (toolbar, EPHY_FIND_RESULT_NOTFOUND);
- return;
- }
+ options = webkit_find_controller_get_options (controller);
+ if (options & WEBKIT_FIND_OPTIONS_WRAP_AROUND) {
+ set_status (toolbar, EPHY_FIND_RESULT_NOTFOUND);
+ return;
+ }
- options |= WEBKIT_FIND_OPTIONS_WRAP_AROUND;
- webkit_find_controller_search (controller, toolbar->find_string, options, G_MAXUINT);
+ options |= WEBKIT_FIND_OPTIONS_WRAP_AROUND;
+ webkit_find_controller_search (controller, toolbar->find_string, options, G_MAXUINT);
}
static void
update_find_string (EphyFindToolbar *toolbar)
{
- g_free (toolbar->find_string);
- toolbar->find_string = g_strdup (gtk_entry_get_text (GTK_ENTRY (toolbar->entry)));
+ g_free (toolbar->find_string);
+ toolbar->find_string = g_strdup (gtk_entry_get_text (GTK_ENTRY (toolbar->entry)));
- if (toolbar->find_source_id != 0) {
- g_source_remove (toolbar->find_source_id);
- toolbar->find_source_id = 0;
- }
+ if (toolbar->find_source_id != 0) {
+ g_source_remove (toolbar->find_source_id);
+ toolbar->find_source_id = 0;
+ }
- if (strlen (toolbar->find_string) == 0) {
- clear_status (toolbar);
- return;
- }
+ if (strlen (toolbar->find_string) == 0) {
+ clear_status (toolbar);
+ return;
+ }
- toolbar->find_source_id = g_timeout_add (300, (GSourceFunc)do_search, toolbar);
- g_source_set_name_by_id (toolbar->find_source_id, "[epiphany] do_search");
+ toolbar->find_source_id = g_timeout_add (300, (GSourceFunc)do_search, toolbar);
+ g_source_set_name_by_id (toolbar->find_source_id, "[epiphany] do_search");
}
static gboolean
ephy_find_toolbar_activate_link (EphyFindToolbar *toolbar,
- GdkModifierType mask)
+ GdkModifierType mask)
{
- return FALSE;
+ return FALSE;
}
static gboolean
-entry_key_press_event_cb (GtkEntry *entry,
- GdkEventKey *event,
- EphyFindToolbar *toolbar)
-{
- guint mask = gtk_accelerator_get_default_mod_mask ();
- gboolean handled = FALSE;
-
- if ((event->state & mask) == 0)
- {
- handled = TRUE;
- switch (event->keyval)
- {
- case GDK_KEY_Escape:
- /* Hide the toolbar when ESC is pressed */
- ephy_find_toolbar_request_close (toolbar);
- break;
- default:
- handled = FALSE;
- break;
- }
- }
- else if ((event->state & mask) == GDK_CONTROL_MASK &&
- (event->keyval == GDK_KEY_Return ||
- event->keyval == GDK_KEY_KP_Enter ||
- event->keyval == GDK_KEY_ISO_Enter))
- {
- handled = ephy_find_toolbar_activate_link (toolbar, event->state);
- }
- else if ((event->state & mask) == GDK_SHIFT_MASK &&
- (event->keyval == GDK_KEY_Return ||
- event->keyval == GDK_KEY_KP_Enter ||
- event->keyval == GDK_KEY_ISO_Enter))
- {
- handled = TRUE;
- ephy_find_toolbar_find_previous (toolbar);
- }
-
- return handled;
+entry_key_press_event_cb (GtkEntry *entry,
+ GdkEventKey *event,
+ EphyFindToolbar *toolbar)
+{
+ guint mask = gtk_accelerator_get_default_mod_mask ();
+ gboolean handled = FALSE;
+
+ if ((event->state & mask) == 0) {
+ handled = TRUE;
+ switch (event->keyval) {
+ case GDK_KEY_Escape:
+ /* Hide the toolbar when ESC is pressed */
+ ephy_find_toolbar_request_close (toolbar);
+ break;
+ default:
+ handled = FALSE;
+ break;
+ }
+ } else if ((event->state & mask) == GDK_CONTROL_MASK &&
+ (event->keyval == GDK_KEY_Return ||
+ event->keyval == GDK_KEY_KP_Enter ||
+ event->keyval == GDK_KEY_ISO_Enter)) {
+ handled = ephy_find_toolbar_activate_link (toolbar, event->state);
+ } else if ((event->state & mask) == GDK_SHIFT_MASK &&
+ (event->keyval == GDK_KEY_Return ||
+ event->keyval == GDK_KEY_KP_Enter ||
+ event->keyval == GDK_KEY_ISO_Enter)) {
+ handled = TRUE;
+ ephy_find_toolbar_find_previous (toolbar);
+ }
+
+ return handled;
}
static void
-entry_activate_cb (GtkWidget *entry,
- EphyFindToolbar *toolbar)
-{
- if (toolbar->typing_ahead)
- {
- ephy_find_toolbar_activate_link (toolbar, 0);
- }
- else
- {
- ephy_find_toolbar_find_next (toolbar);
- }
+entry_activate_cb (GtkWidget *entry,
+ EphyFindToolbar *toolbar)
+{
+ if (toolbar->typing_ahead) {
+ ephy_find_toolbar_activate_link (toolbar, 0);
+ } else {
+ ephy_find_toolbar_find_next (toolbar);
+ }
}
static void
ephy_find_toolbar_grab_focus (GtkWidget *widget)
{
- EphyFindToolbar *toolbar = EPHY_FIND_TOOLBAR (widget);
+ EphyFindToolbar *toolbar = EPHY_FIND_TOOLBAR (widget);
- gtk_widget_grab_focus (toolbar->entry);
+ gtk_widget_grab_focus (toolbar->entry);
}
static gboolean
ephy_find_toolbar_draw (GtkWidget *widget,
- cairo_t *cr)
+ cairo_t *cr)
{
- GtkStyleContext *context;
+ GtkStyleContext *context;
- context = gtk_widget_get_style_context (widget);
+ context = gtk_widget_get_style_context (widget);
- gtk_style_context_save (context);
- gtk_style_context_set_state (context, gtk_widget_get_state_flags (widget));
+ gtk_style_context_save (context);
+ gtk_style_context_set_state (context, gtk_widget_get_state_flags (widget));
- gtk_render_background (context, cr, 0, 0,
- gtk_widget_get_allocated_width (widget),
- gtk_widget_get_allocated_height (widget));
+ gtk_render_background (context, cr, 0, 0,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
- gtk_render_frame (context, cr, 0, 0,
- gtk_widget_get_allocated_width (widget),
- gtk_widget_get_allocated_height (widget));
+ gtk_render_frame (context, cr, 0, 0,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
- gtk_style_context_restore (context);
+ gtk_style_context_restore (context);
- return GTK_WIDGET_CLASS (ephy_find_toolbar_parent_class)->draw (widget, cr);
+ return GTK_WIDGET_CLASS (ephy_find_toolbar_parent_class)->draw (widget, cr);
}
static void
@@ -345,159 +326,155 @@ search_entry_clear_cb (GtkEntry *entry,
}
static void
-search_entry_changed_cb (GtkEntry *entry,
+search_entry_changed_cb (GtkEntry *entry,
EphyFindToolbar *toolbar)
{
- const char *str;
- const char *primary_icon_name = "edit-find-symbolic";
- const char *secondary_icon_name = NULL;
- gboolean primary_active = FALSE;
- gboolean secondary_active = FALSE;
-
- str = gtk_entry_get_text (entry);
-
- if (str == NULL || *str == '\0') {
- primary_icon_name = "edit-find-symbolic";
- } else {
- secondary_icon_name = "edit-clear-symbolic";
- secondary_active = TRUE;
- }
-
- g_object_set (entry,
- "primary-icon-name", primary_icon_name,
- "primary-icon-activatable", primary_active,
- "primary-icon-sensitive", primary_active,
- "secondary-icon-name", secondary_icon_name,
- "secondary-icon-activatable", secondary_active,
- "secondary-icon-sensitive", secondary_active,
- NULL);
-
- update_find_string (toolbar);
+ const char *str;
+ const char *primary_icon_name = "edit-find-symbolic";
+ const char *secondary_icon_name = NULL;
+ gboolean primary_active = FALSE;
+ gboolean secondary_active = FALSE;
+
+ str = gtk_entry_get_text (entry);
+
+ if (str == NULL || *str == '\0') {
+ primary_icon_name = "edit-find-symbolic";
+ } else {
+ secondary_icon_name = "edit-clear-symbolic";
+ secondary_active = TRUE;
+ }
+
+ g_object_set (entry,
+ "primary-icon-name", primary_icon_name,
+ "primary-icon-activatable", primary_active,
+ "primary-icon-sensitive", primary_active,
+ "secondary-icon-name", secondary_icon_name,
+ "secondary-icon-activatable", secondary_active,
+ "secondary-icon-sensitive", secondary_active,
+ NULL);
+
+ update_find_string (toolbar);
}
static void
ephy_find_toolbar_load_changed_cb (WebKitWebView *web_view,
- WebKitLoadEvent load_event,
- EphyFindToolbar *toolbar)
+ WebKitLoadEvent load_event,
+ EphyFindToolbar *toolbar)
{
- if (load_event == WEBKIT_LOAD_STARTED &&
- gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (toolbar)))
- {
- ephy_find_toolbar_close (toolbar);
- }
+ if (load_event == WEBKIT_LOAD_STARTED &&
+ gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (toolbar))) {
+ ephy_find_toolbar_close (toolbar);
+ }
}
static void
ephy_find_toolbar_init (EphyFindToolbar *toolbar)
{
- GtkWidget *box;
- GtkSizeGroup *size_group;
-
- size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
-
- box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_style_context_add_class (gtk_widget_get_style_context (box),
- GTK_STYLE_CLASS_RAISED);
- gtk_style_context_add_class (gtk_widget_get_style_context (box),
- GTK_STYLE_CLASS_LINKED);
- gtk_container_add (GTK_CONTAINER (toolbar), box);
-
- toolbar->entry = gtk_entry_new ();
- gtk_entry_set_width_chars (GTK_ENTRY (toolbar->entry), 32);
- gtk_entry_set_max_length (GTK_ENTRY (toolbar->entry), 512);
- gtk_entry_set_placeholder_text (GTK_ENTRY (toolbar->entry), _("Type to search…"));
- gtk_container_add (GTK_CONTAINER (box), toolbar->entry);
-
- /* Prev */
- toolbar->prev = gtk_button_new_from_icon_name ("go-up-symbolic", GTK_ICON_SIZE_MENU);
- gtk_widget_set_tooltip_text (toolbar->prev,
- _("Find previous occurrence of the search string"));
- gtk_container_add (GTK_CONTAINER (box), toolbar->prev);
- gtk_widget_show_all (toolbar->prev);
- gtk_widget_set_sensitive (toolbar->prev, FALSE);
-
- /* Next */
- toolbar->next = gtk_button_new_from_icon_name ("go-down-symbolic", GTK_ICON_SIZE_MENU);
- gtk_widget_set_tooltip_text (toolbar->next,
- _("Find next occurrence of the search string"));
- gtk_container_add (GTK_CONTAINER (box), toolbar->next);
- gtk_widget_set_sensitive (toolbar->next, FALSE);
-
- gtk_size_group_add_widget (size_group, toolbar->entry);
- gtk_size_group_add_widget (size_group, toolbar->next);
- gtk_size_group_add_widget (size_group, toolbar->prev);
- g_object_unref (size_group);
-
- /* connect signals */
- g_signal_connect (toolbar->entry, "icon-release",
- G_CALLBACK (search_entry_clear_cb), toolbar);
- g_signal_connect (toolbar->entry, "key-press-event",
- G_CALLBACK (entry_key_press_event_cb), toolbar);
- g_signal_connect_after (toolbar->entry, "changed",
- G_CALLBACK (search_entry_changed_cb), toolbar);
- g_signal_connect (toolbar->entry, "activate",
- G_CALLBACK (entry_activate_cb), toolbar);
- g_signal_connect_swapped (toolbar->next, "clicked",
- G_CALLBACK (ephy_find_toolbar_find_next), toolbar);
- g_signal_connect_swapped (toolbar->prev, "clicked",
- G_CALLBACK (ephy_find_toolbar_find_previous), toolbar);
- gtk_search_bar_connect_entry (GTK_SEARCH_BAR (toolbar),
- GTK_ENTRY (toolbar->entry));
-
- search_entry_changed_cb (GTK_ENTRY (toolbar->entry), toolbar);
-
- gtk_widget_show_all (GTK_WIDGET (toolbar));
+ GtkWidget *box;
+ GtkSizeGroup *size_group;
+
+ size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
+
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_style_context_add_class (gtk_widget_get_style_context (box),
+ GTK_STYLE_CLASS_RAISED);
+ gtk_style_context_add_class (gtk_widget_get_style_context (box),
+ GTK_STYLE_CLASS_LINKED);
+ gtk_container_add (GTK_CONTAINER (toolbar), box);
+
+ toolbar->entry = gtk_entry_new ();
+ gtk_entry_set_width_chars (GTK_ENTRY (toolbar->entry), 32);
+ gtk_entry_set_max_length (GTK_ENTRY (toolbar->entry), 512);
+ gtk_entry_set_placeholder_text (GTK_ENTRY (toolbar->entry), _("Type to search…"));
+ gtk_container_add (GTK_CONTAINER (box), toolbar->entry);
+
+ /* Prev */
+ toolbar->prev = gtk_button_new_from_icon_name ("go-up-symbolic", GTK_ICON_SIZE_MENU);
+ gtk_widget_set_tooltip_text (toolbar->prev,
+ _("Find previous occurrence of the search string"));
+ gtk_container_add (GTK_CONTAINER (box), toolbar->prev);
+ gtk_widget_show_all (toolbar->prev);
+ gtk_widget_set_sensitive (toolbar->prev, FALSE);
+
+ /* Next */
+ toolbar->next = gtk_button_new_from_icon_name ("go-down-symbolic", GTK_ICON_SIZE_MENU);
+ gtk_widget_set_tooltip_text (toolbar->next,
+ _("Find next occurrence of the search string"));
+ gtk_container_add (GTK_CONTAINER (box), toolbar->next);
+ gtk_widget_set_sensitive (toolbar->next, FALSE);
+
+ gtk_size_group_add_widget (size_group, toolbar->entry);
+ gtk_size_group_add_widget (size_group, toolbar->next);
+ gtk_size_group_add_widget (size_group, toolbar->prev);
+ g_object_unref (size_group);
+
+ /* connect signals */
+ g_signal_connect (toolbar->entry, "icon-release",
+ G_CALLBACK (search_entry_clear_cb), toolbar);
+ g_signal_connect (toolbar->entry, "key-press-event",
+ G_CALLBACK (entry_key_press_event_cb), toolbar);
+ g_signal_connect_after (toolbar->entry, "changed",
+ G_CALLBACK (search_entry_changed_cb), toolbar);
+ g_signal_connect (toolbar->entry, "activate",
+ G_CALLBACK (entry_activate_cb), toolbar);
+ g_signal_connect_swapped (toolbar->next, "clicked",
+ G_CALLBACK (ephy_find_toolbar_find_next), toolbar);
+ g_signal_connect_swapped (toolbar->prev, "clicked",
+ G_CALLBACK (ephy_find_toolbar_find_previous), toolbar);
+ gtk_search_bar_connect_entry (GTK_SEARCH_BAR (toolbar),
+ GTK_ENTRY (toolbar->entry));
+
+ search_entry_changed_cb (GTK_ENTRY (toolbar->entry), toolbar);
+
+ gtk_widget_show_all (GTK_WIDGET (toolbar));
}
static void
ephy_find_toolbar_dispose (GObject *object)
{
- EphyFindToolbar *toolbar = EPHY_FIND_TOOLBAR (object);
+ EphyFindToolbar *toolbar = EPHY_FIND_TOOLBAR (object);
- if (toolbar->find_again_source_id != 0)
- {
- g_source_remove (toolbar->find_again_source_id);
- toolbar->find_again_source_id = 0;
- }
+ if (toolbar->find_again_source_id != 0) {
+ g_source_remove (toolbar->find_again_source_id);
+ toolbar->find_again_source_id = 0;
+ }
- if (toolbar->find_source_id != 0)
- {
- g_source_remove (toolbar->find_source_id);
- toolbar->find_source_id = 0;
- }
+ if (toolbar->find_source_id != 0) {
+ g_source_remove (toolbar->find_source_id);
+ toolbar->find_source_id = 0;
+ }
- G_OBJECT_CLASS (ephy_find_toolbar_parent_class)->dispose (object);
+ G_OBJECT_CLASS (ephy_find_toolbar_parent_class)->dispose (object);
}
#ifndef G_DISABLE_ASSERT
G_GNUC_NORETURN
#endif
static void
-ephy_find_toolbar_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ephy_find_toolbar_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- /* no readable properties */
- g_assert_not_reached ();
+ /* no readable properties */
+ g_assert_not_reached ();
}
static void
-ephy_find_toolbar_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EphyFindToolbar *toolbar = EPHY_FIND_TOOLBAR (object);
-
- switch (prop_id)
- {
- case PROP_WEB_VIEW:
- ephy_find_toolbar_set_web_view (toolbar, (WebKitWebView *) g_value_get_object
(value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
+ephy_find_toolbar_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EphyFindToolbar *toolbar = EPHY_FIND_TOOLBAR (object);
+
+ switch (prop_id) {
+ case PROP_WEB_VIEW:
+ ephy_find_toolbar_set_web_view (toolbar, (WebKitWebView *)g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
@@ -513,32 +490,32 @@ ephy_find_toolbar_finalize (GObject *o)
static void
ephy_find_toolbar_class_init (EphyFindToolbarClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
- object_class->dispose = ephy_find_toolbar_dispose;
- object_class->finalize = ephy_find_toolbar_finalize;
- object_class->get_property = ephy_find_toolbar_get_property;
- object_class->set_property = ephy_find_toolbar_set_property;
-
- widget_class->draw = ephy_find_toolbar_draw;
- widget_class->grab_focus = ephy_find_toolbar_grab_focus;
-
- signals[CLOSE] =
- g_signal_new ("close",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE, 0);
-
- obj_properties[PROP_WEB_VIEW] =
- g_param_spec_object ("web-view",
- "WebView",
- "Parent web view",
- WEBKIT_TYPE_WEB_VIEW,
- G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->dispose = ephy_find_toolbar_dispose;
+ object_class->finalize = ephy_find_toolbar_finalize;
+ object_class->get_property = ephy_find_toolbar_get_property;
+ object_class->set_property = ephy_find_toolbar_set_property;
+
+ widget_class->draw = ephy_find_toolbar_draw;
+ widget_class->grab_focus = ephy_find_toolbar_grab_focus;
+
+ signals[CLOSE] =
+ g_signal_new ("close",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
+
+ obj_properties[PROP_WEB_VIEW] =
+ g_param_spec_object ("web-view",
+ "WebView",
+ "Parent web view",
+ WEBKIT_TYPE_WEB_VIEW,
+ G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
}
/* public functions */
@@ -546,111 +523,105 @@ ephy_find_toolbar_class_init (EphyFindToolbarClass *klass)
EphyFindToolbar *
ephy_find_toolbar_new (WebKitWebView *web_view)
{
- return g_object_new (EPHY_TYPE_FIND_TOOLBAR,
- "web-view", web_view,
- NULL);
+ return g_object_new (EPHY_TYPE_FIND_TOOLBAR,
+ "web-view", web_view,
+ NULL);
}
const char *
ephy_find_toolbar_get_text (EphyFindToolbar *toolbar)
{
- return gtk_entry_get_text (GTK_ENTRY (toolbar->entry));
+ return gtk_entry_get_text (GTK_ENTRY (toolbar->entry));
}
static void
ephy_find_toolbar_set_web_view (EphyFindToolbar *toolbar,
- WebKitWebView *web_view)
-{
- if (toolbar->web_view == web_view) return;
-
- if (toolbar->web_view != NULL)
- {
- g_signal_handlers_disconnect_matched (toolbar->controller,
- G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, toolbar);
- }
-
- toolbar->web_view = web_view;
- if (web_view != NULL)
- {
- toolbar->controller = webkit_web_view_get_find_controller (web_view);
- g_signal_connect_object (toolbar->controller, "found-text",
- G_CALLBACK (found_text_cb),
- toolbar, 0);
- g_signal_connect_object (toolbar->controller, "failed-to-find-text",
- G_CALLBACK (failed_to_find_text_cb),
- toolbar, 0);
- g_signal_connect (web_view, "load-changed",
- G_CALLBACK (ephy_find_toolbar_load_changed_cb),
- toolbar);
-
- clear_status (toolbar);
-
- g_signal_connect_object (EPHY_WEB_VIEW (web_view), "search-key-press",
- G_CALLBACK (tab_search_key_press_cb),
- toolbar, 0);
- }
+ WebKitWebView *web_view)
+{
+ if (toolbar->web_view == web_view) return;
+
+ if (toolbar->web_view != NULL) {
+ g_signal_handlers_disconnect_matched (toolbar->controller,
+ G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, toolbar);
+ }
+
+ toolbar->web_view = web_view;
+ if (web_view != NULL) {
+ toolbar->controller = webkit_web_view_get_find_controller (web_view);
+ g_signal_connect_object (toolbar->controller, "found-text",
+ G_CALLBACK (found_text_cb),
+ toolbar, 0);
+ g_signal_connect_object (toolbar->controller, "failed-to-find-text",
+ G_CALLBACK (failed_to_find_text_cb),
+ toolbar, 0);
+ g_signal_connect (web_view, "load-changed",
+ G_CALLBACK (ephy_find_toolbar_load_changed_cb),
+ toolbar);
+
+ clear_status (toolbar);
+
+ g_signal_connect_object (EPHY_WEB_VIEW (web_view), "search-key-press",
+ G_CALLBACK (tab_search_key_press_cb),
+ toolbar, 0);
+ }
}
void
ephy_find_toolbar_find_next (EphyFindToolbar *toolbar)
{
- webkit_find_controller_search_next (toolbar->controller);
+ webkit_find_controller_search_next (toolbar->controller);
}
void
ephy_find_toolbar_find_previous (EphyFindToolbar *toolbar)
{
- webkit_find_controller_search_previous (toolbar->controller);
+ webkit_find_controller_search_previous (toolbar->controller);
}
void
ephy_find_toolbar_open (EphyFindToolbar *toolbar,
- gboolean links_only,
- gboolean typing_ahead)
+ gboolean links_only,
+ gboolean typing_ahead)
{
- g_return_if_fail (toolbar->web_view != NULL);
+ g_return_if_fail (toolbar->web_view != NULL);
- toolbar->typing_ahead = typing_ahead;
- toolbar->links_only = links_only;
+ toolbar->typing_ahead = typing_ahead;
+ toolbar->links_only = links_only;
- clear_status (toolbar);
+ clear_status (toolbar);
- gtk_editable_select_region (GTK_EDITABLE (toolbar->entry), 0, -1);
+ gtk_editable_select_region (GTK_EDITABLE (toolbar->entry), 0, -1);
- gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (toolbar), TRUE);
- gtk_search_bar_set_show_close_button (GTK_SEARCH_BAR (toolbar), TRUE);
- gtk_widget_grab_focus (toolbar->entry);
+ gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (toolbar), TRUE);
+ gtk_search_bar_set_show_close_button (GTK_SEARCH_BAR (toolbar), TRUE);
+ gtk_widget_grab_focus (toolbar->entry);
}
void
ephy_find_toolbar_close (EphyFindToolbar *toolbar)
{
- gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (toolbar), FALSE);
+ gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (toolbar), FALSE);
- if (toolbar->web_view == NULL) return;
+ if (toolbar->web_view == NULL) return;
- webkit_find_controller_search_finish (toolbar->controller);
+ webkit_find_controller_search_finish (toolbar->controller);
}
void
ephy_find_toolbar_request_close (EphyFindToolbar *toolbar)
{
- if (gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (toolbar)))
- {
- g_signal_emit (toolbar, signals[CLOSE], 0);
- }
+ if (gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (toolbar))) {
+ g_signal_emit (toolbar, signals[CLOSE], 0);
+ }
}
void
ephy_find_toolbar_toggle_state (EphyFindToolbar *toolbar)
{
- if (gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (toolbar)))
- {
- ephy_find_toolbar_close (toolbar);
- }
- else
- {
- ephy_find_toolbar_open (toolbar, FALSE, FALSE);
- }
+ if (gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (toolbar))) {
+ ephy_find_toolbar_close (toolbar);
+ } else {
+ ephy_find_toolbar_open (toolbar, FALSE, FALSE);
+ }
}
diff --git a/embed/ephy-web-extension-proxy.c b/embed/ephy-web-extension-proxy.c
index 6cf067a..fdbe8d5 100644
--- a/embed/ephy-web-extension-proxy.c
+++ b/embed/ephy-web-extension-proxy.c
@@ -22,8 +22,7 @@
#include "ephy-web-extension-names.h"
#include "ephy-history-service.h"
-struct _EphyWebExtensionProxy
-{
+struct _EphyWebExtensionProxy {
GObject parent_instance;
GCancellable *cancellable;
@@ -33,8 +32,7 @@ struct _EphyWebExtensionProxy
guint page_created_signal_id;
};
-enum
-{
+enum {
PAGE_CREATED,
LAST_SIGNAL
@@ -91,12 +89,12 @@ ephy_web_extension_proxy_class_init (EphyWebExtensionProxyClass *klass)
}
static void
-web_extension_page_created (GDBusConnection *connection,
- const char *sender_name,
- const char *object_path,
- const char *interface_name,
- const char *signal_name,
- GVariant *parameters,
+web_extension_page_created (GDBusConnection *connection,
+ const char *sender_name,
+ const char *object_path,
+ const char *interface_name,
+ const char *signal_name,
+ GVariant *parameters,
EphyWebExtensionProxy *web_extension)
{
guint64 page_id;
@@ -105,8 +103,8 @@ web_extension_page_created (GDBusConnection *connection,
}
static void
-web_extension_proxy_created_cb (GDBusProxy *proxy,
- GAsyncResult *result,
+web_extension_proxy_created_cb (GDBusProxy *proxy,
+ GAsyncResult *result,
EphyWebExtensionProxy *web_extension)
{
GError *error = NULL;
@@ -140,9 +138,9 @@ web_extension_proxy_created_cb (GDBusProxy *proxy,
}
static void
-connection_closed_cb (GDBusConnection *connection,
- gboolean remote_peer_vanished,
- GError *error,
+connection_closed_cb (GDBusConnection *connection,
+ gboolean remote_peer_vanished,
+ GError *error,
EphyWebExtensionProxy *web_extension)
{
if (error) {
@@ -183,8 +181,8 @@ ephy_web_extension_proxy_new (GDBusConnection *connection)
void
ephy_web_extension_proxy_form_auth_data_save_confirmation_response (EphyWebExtensionProxy *web_extension,
- guint request_id,
- gboolean response)
+ guint request_id,
+ gboolean response)
{
g_return_if_fail (EPHY_IS_WEB_EXTENSION_PROXY (web_extension));
@@ -201,9 +199,9 @@ ephy_web_extension_proxy_form_auth_data_save_confirmation_response (EphyWebExten
}
static void
-has_modified_forms_cb (GDBusProxy *proxy,
+has_modified_forms_cb (GDBusProxy *proxy,
GAsyncResult *result,
- GTask *task)
+ GTask *task)
{
GVariant *return_value;
gboolean retval = FALSE;
@@ -220,10 +218,10 @@ has_modified_forms_cb (GDBusProxy *proxy,
void
ephy_web_extension_proxy_web_page_has_modified_forms (EphyWebExtensionProxy *web_extension,
- guint64 page_id,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+ guint64 page_id,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GTask *task;
@@ -249,8 +247,8 @@ ephy_web_extension_proxy_web_page_has_modified_forms (EphyWebExtensionProxy *web
gboolean
ephy_web_extension_proxy_web_page_has_modified_forms_finish (EphyWebExtensionProxy *web_extension,
- GAsyncResult *result,
- GError **error)
+ GAsyncResult *result,
+ GError **error)
{
g_return_val_if_fail (g_task_is_valid (result, web_extension), FALSE);
@@ -258,9 +256,9 @@ ephy_web_extension_proxy_web_page_has_modified_forms_finish (EphyWebExtensionPro
}
static void
-get_best_web_app_icon_cb (GDBusProxy *proxy,
+get_best_web_app_icon_cb (GDBusProxy *proxy,
GAsyncResult *result,
- GTask *task)
+ GTask *task)
{
GVariant *retval;
GError *error = NULL;
@@ -276,11 +274,11 @@ get_best_web_app_icon_cb (GDBusProxy *proxy,
void
ephy_web_extension_proxy_get_best_web_app_icon (EphyWebExtensionProxy *web_extension,
- guint64 page_id,
- const char *base_uri,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+ guint64 page_id,
+ const char *base_uri,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GTask *task;
@@ -291,7 +289,7 @@ ephy_web_extension_proxy_get_best_web_app_icon (EphyWebExtensionProxy *web_exten
if (web_extension->proxy) {
g_dbus_proxy_call (web_extension->proxy,
"GetBestWebAppIcon",
- g_variant_new("(ts)", page_id, base_uri),
+ g_variant_new ("(ts)", page_id, base_uri),
G_DBUS_CALL_FLAGS_NONE,
-1,
web_extension->cancellable,
@@ -306,11 +304,11 @@ ephy_web_extension_proxy_get_best_web_app_icon (EphyWebExtensionProxy *web_exten
gboolean
ephy_web_extension_proxy_get_best_web_app_icon_finish (EphyWebExtensionProxy *web_extension,
- GAsyncResult *result,
- gboolean *icon_result,
- char **icon_uri,
- char **icon_color,
- GError **error)
+ GAsyncResult *result,
+ gboolean *icon_result,
+ char **icon_uri,
+ char **icon_color,
+ GError **error)
{
GVariant *variant;
GTask *task = G_TASK (result);
@@ -328,9 +326,9 @@ ephy_web_extension_proxy_get_best_web_app_icon_finish (EphyWebExtensionProxy *we
}
static void
-get_web_app_title_cb (GDBusProxy *proxy,
+get_web_app_title_cb (GDBusProxy *proxy,
GAsyncResult *result,
- GTask *task)
+ GTask *task)
{
GVariant *retval;
GError *error = NULL;
@@ -350,10 +348,10 @@ get_web_app_title_cb (GDBusProxy *proxy,
void
ephy_web_extension_proxy_get_web_app_title (EphyWebExtensionProxy *web_extension,
- guint64 page_id,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+ guint64 page_id,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GTask *task;
@@ -364,7 +362,7 @@ ephy_web_extension_proxy_get_web_app_title (EphyWebExtensionProxy *web_extension
if (web_extension->proxy) {
g_dbus_proxy_call (web_extension->proxy,
"GetWebAppTitle",
- g_variant_new("(t)", page_id),
+ g_variant_new ("(t)", page_id),
G_DBUS_CALL_FLAGS_NONE,
-1,
web_extension->cancellable,
@@ -379,8 +377,8 @@ ephy_web_extension_proxy_get_web_app_title (EphyWebExtensionProxy *web_extension
char *
ephy_web_extension_proxy_get_web_app_title_finish (EphyWebExtensionProxy *web_extension,
- GAsyncResult *result,
- GError **error)
+ GAsyncResult *result,
+ GError **error)
{
g_return_val_if_fail (g_task_is_valid (result, web_extension), FALSE);
@@ -389,7 +387,7 @@ ephy_web_extension_proxy_get_web_app_title_finish (EphyWebExtensionProxy *web_ex
void
ephy_web_extension_proxy_history_set_urls (EphyWebExtensionProxy *web_extension,
- GList *urls)
+ GList *urls)
{
GList *l;
GVariantBuilder builder;
@@ -415,8 +413,8 @@ ephy_web_extension_proxy_history_set_urls (EphyWebExtensionProxy *web_extension,
void
ephy_web_extension_proxy_history_set_url_thumbnail (EphyWebExtensionProxy *web_extension,
- const char *url,
- const char *path)
+ const char *url,
+ const char *path)
{
if (!web_extension->proxy)
return;
@@ -432,8 +430,8 @@ ephy_web_extension_proxy_history_set_url_thumbnail (EphyWebExtensionProxy *web_e
void
ephy_web_extension_proxy_history_set_url_title (EphyWebExtensionProxy *web_extension,
- const char *url,
- const char *title)
+ const char *url,
+ const char *title)
{
if (!web_extension->proxy)
return;
@@ -449,7 +447,7 @@ ephy_web_extension_proxy_history_set_url_title (EphyWebExtensionProxy *web_exten
void
ephy_web_extension_proxy_history_delete_url (EphyWebExtensionProxy *web_extension,
- const char *url)
+ const char *url)
{
if (!web_extension->proxy)
return;
@@ -465,7 +463,7 @@ ephy_web_extension_proxy_history_delete_url (EphyWebExtensionProxy *web_extensio
void
ephy_web_extension_proxy_history_delete_host (EphyWebExtensionProxy *web_extension,
- const char *host)
+ const char *host)
{
if (!web_extension->proxy)
return;
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index a731475..4f3e386 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -161,7 +161,7 @@ popups_manager_free_info (PopupInfo *popup)
}
static void
-popups_manager_show (PopupInfo *popup,
+popups_manager_show (PopupInfo *popup,
EphyWebView *view)
{
/* Only show popup with non NULL url */
@@ -203,19 +203,19 @@ popups_manager_new_window_info (EphyEmbedContainer *container)
gtk_widget_get_allocation (GTK_WIDGET (embed), &allocation);
features = g_strdup_printf
- ("width=%d,height=%d,toolbar=%d",
- allocation.width,
- allocation.height,
- 1);
+ ("width=%d,height=%d,toolbar=%d",
+ allocation.width,
+ allocation.height,
+ 1);
return features;
}
static void
popups_manager_add (EphyWebView *view,
- const char *url,
- const char *name,
- const char *features)
+ const char *url,
+ const char *name,
+ const char *features)
{
PopupInfo *popup;
@@ -249,7 +249,7 @@ popups_manager_add (EphyWebView *view,
static void
popups_manager_hide (EphyEmbedContainer *container,
- EphyWebView *parent_view)
+ EphyWebView *parent_view)
{
EphyEmbed *embed;
const char *location;
@@ -283,7 +283,7 @@ popups_manager_hide_all (EphyWebView *view)
static void
ephy_web_view_set_popups_allowed (EphyWebView *view,
- gboolean allowed)
+ gboolean allowed)
{
if (allowed) {
popups_manager_show_all (view);
@@ -307,7 +307,7 @@ ephy_web_view_get_popups_allowed (EphyWebView *view)
}
static gboolean
-popups_manager_remove_window (EphyWebView *view,
+popups_manager_remove_window (EphyWebView *view,
EphyEmbedContainer *container)
{
view->shown_popups = g_slist_remove (view->shown_popups, container);
@@ -316,7 +316,7 @@ popups_manager_remove_window (EphyWebView *view,
}
static void
-popups_manager_add_window (EphyWebView *view,
+popups_manager_add_window (EphyWebView *view,
EphyEmbedContainer *container)
{
LOG ("popups_manager_add_window: view %p, container %p", view, container);
@@ -330,10 +330,10 @@ popups_manager_add_window (EphyWebView *view,
static void
disconnect_popup (EphyEmbedContainer *container,
- EphyWebView *view)
+ EphyWebView *view)
{
g_signal_handlers_disconnect_by_func
- (container, G_CALLBACK (popups_manager_remove_window), view);
+ (container, G_CALLBACK (popups_manager_remove_window), view);
}
/**
@@ -360,9 +360,9 @@ ephy_web_view_popups_manager_reset (EphyWebView *view)
}
static void
-ephy_web_view_get_property (GObject *object,
- guint prop_id,
- GValue *value,
+ephy_web_view_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
GParamSpec *pspec)
{
EphyWebView *view = EPHY_WEB_VIEW (object);
@@ -379,7 +379,7 @@ ephy_web_view_get_property (GObject *object,
break;
case PROP_HIDDEN_POPUP_COUNT:
g_value_set_int (value, popup_blocker_n_hidden
- (EPHY_WEB_VIEW (object)));
+ (EPHY_WEB_VIEW (object)));
break;
case PROP_ICON:
g_value_set_object (value, view->icon);
@@ -392,7 +392,7 @@ ephy_web_view_get_property (GObject *object,
break;
case PROP_POPUPS_ALLOWED:
g_value_set_boolean (value, ephy_web_view_get_popups_allowed
- (EPHY_WEB_VIEW (object)));
+ (EPHY_WEB_VIEW (object)));
break;
case PROP_SECURITY:
g_value_set_enum (value, view->security_level);
@@ -409,10 +409,10 @@ ephy_web_view_get_property (GObject *object,
}
static void
-ephy_web_view_set_property (GObject *object,
- guint prop_id,
+ephy_web_view_set_property (GObject *object,
+ guint prop_id,
const GValue *value,
- GParamSpec *pspec)
+ GParamSpec *pspec)
{
switch (prop_id) {
case PROP_POPUPS_ALLOWED:
@@ -481,8 +481,8 @@ ephy_web_view_button_press_event (GtkWidget *widget, GdkEventButton *event)
static GtkWidget *
ephy_web_view_create_form_auth_save_confirmation_info_bar (EphyWebView *web_view,
- const char *hostname,
- const char *username)
+ const char *hostname,
+ const char *username)
{
GtkWidget *info_bar;
GtkWidget *action_area;
@@ -501,7 +501,7 @@ ephy_web_view_create_form_auth_save_confirmation_info_bar (EphyWebView *web_view
GTK_ORIENTATION_HORIZONTAL);
label = gtk_label_new (NULL);
- /* Translators: The %s the hostname where this is happening.
+ /* Translators: The %s the hostname where this is happening.
* Example: mail.google.com.
*/
message = g_markup_printf_escaped (_("Do you want to save your password for “%s”?"),
@@ -573,7 +573,7 @@ ephy_web_view_clear_history (EphyWebView *view)
static void
ephy_web_view_history_cleared_cb (EphyHistoryService *history_service,
- EphyWebView *view)
+ EphyWebView *view)
{
ephy_web_view_clear_history (view);
}
@@ -584,8 +584,8 @@ typedef struct {
} GetSnapshotPathAsyncData;
static void
-got_snapshot_path_cb (EphySnapshotService *service,
- GAsyncResult *result,
+got_snapshot_path_cb (EphySnapshotService *service,
+ GAsyncResult *result,
GetSnapshotPathAsyncData *data)
{
char *snapshot;
@@ -607,7 +607,7 @@ got_snapshot_path_cb (EphySnapshotService *service,
static gboolean
web_view_check_snapshot (WebKitWebView *web_view)
{
- EphyWebView* view = EPHY_WEB_VIEW (web_view);
+ EphyWebView *view = EPHY_WEB_VIEW (web_view);
EphySnapshotService *service = ephy_snapshot_service_get_default ();
const char *url = webkit_web_view_get_uri (web_view);
GetSnapshotPathAsyncData *data;
@@ -647,8 +647,8 @@ _ephy_web_view_update_icon (EphyWebView *view)
static void
icon_changed_cb (EphyWebView *view,
- GParamSpec *pspec,
- gpointer user_data)
+ GParamSpec *pspec,
+ gpointer user_data)
{
_ephy_web_view_update_icon (view);
}
@@ -659,8 +659,8 @@ typedef struct {
} FormAuthRequestData;
static void
-form_auth_data_save_confirmation_response (GtkInfoBar *info_bar,
- gint response_id,
+form_auth_data_save_confirmation_response (GtkInfoBar *info_bar,
+ gint response_id,
FormAuthRequestData *data)
{
gtk_widget_destroy (GTK_WIDGET (info_bar));
@@ -676,11 +676,11 @@ form_auth_data_save_confirmation_response (GtkInfoBar *info_bar,
static void
form_auth_data_save_requested (EphyEmbedShell *shell,
- guint request_id,
- guint64 page_id,
- const char *hostname,
- const char *username,
- EphyWebView *web_view)
+ guint request_id,
+ guint64 page_id,
+ const char *hostname,
+ const char *username,
+ EphyWebView *web_view)
{
GtkWidget *info_bar;
FormAuthRequestData *data;
@@ -701,8 +701,8 @@ form_auth_data_save_requested (EphyEmbedShell *shell,
static void
allow_tls_certificate_cb (EphyEmbedShell *shell,
- guint64 page_id,
- EphyWebView *view)
+ guint64 page_id,
+ EphyWebView *view)
{
SoupURI *uri;
@@ -721,10 +721,10 @@ allow_tls_certificate_cb (EphyEmbedShell *shell,
}
static void
-page_created_cb (EphyEmbedShell *shell,
- guint64 page_id,
+page_created_cb (EphyEmbedShell *shell,
+ guint64 page_id,
EphyWebExtensionProxy *web_extension,
- EphyWebView *view)
+ EphyWebView *view)
{
if (webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)) != page_id)
return;
@@ -746,17 +746,15 @@ ephy_web_view_dispose (GObject *object)
{
EphyWebView *view = EPHY_WEB_VIEW (object);
- if (view->web_extension)
- {
- g_object_remove_weak_pointer (G_OBJECT (view->web_extension), (gpointer *)&view->web_extension);
- view->web_extension = NULL;
- }
+ if (view->web_extension) {
+ g_object_remove_weak_pointer (G_OBJECT (view->web_extension), (gpointer *)&view->web_extension);
+ view->web_extension = NULL;
+ }
- if (view->password_info_bar)
- {
- g_object_remove_weak_pointer (G_OBJECT (view->password_info_bar), (gpointer
*)&view->password_info_bar);
- view->password_info_bar = NULL;
- }
+ if (view->password_info_bar) {
+ g_object_remove_weak_pointer (G_OBJECT (view->password_info_bar), (gpointer *)&view->password_info_bar);
+ view->password_info_bar = NULL;
+ }
g_signal_handlers_disconnect_by_func (view->history_service,
ephy_web_view_history_cleared_cb,
@@ -800,7 +798,7 @@ ephy_web_view_finalize (GObject *object)
static void
_ephy_web_view_set_is_blank (EphyWebView *view,
- gboolean is_blank)
+ gboolean is_blank)
{
if (view->is_blank != is_blank) {
view->is_blank = is_blank;
@@ -810,13 +808,13 @@ _ephy_web_view_set_is_blank (EphyWebView *view,
static void
title_changed_cb (WebKitWebView *web_view,
- GParamSpec *spec,
- gpointer data)
+ GParamSpec *spec,
+ gpointer data)
{
const char *uri;
const char *title;
char *title_from_address = NULL;
- EphyWebView *webview = EPHY_WEB_VIEW (web_view);
+ EphyWebView *webview = EPHY_WEB_VIEW (web_view);
EphyHistoryService *history = webview->history_service;
uri = webkit_web_view_get_uri (web_view);
@@ -837,7 +835,7 @@ title_changed_cb (WebKitWebView *web_view,
*/
static void
ephy_web_view_set_address (EphyWebView *view,
- const char *address)
+ const char *address)
{
GObject *object = G_OBJECT (view);
gboolean is_blank;
@@ -866,8 +864,8 @@ ephy_web_view_set_address (EphyWebView *view,
static void
uri_changed_cb (WebKitWebView *web_view,
- GParamSpec *spec,
- gpointer data)
+ GParamSpec *spec,
+ gpointer data)
{
char *uri;
const char *current_address;
@@ -892,10 +890,10 @@ uri_changed_cb (WebKitWebView *web_view,
}
static void
-mouse_target_changed_cb (EphyWebView *web_view,
+mouse_target_changed_cb (EphyWebView *web_view,
WebKitHitTestResult *hit_test_result,
- guint modifiers,
- gpointer data)
+ guint modifiers,
+ gpointer data)
{
const char *message = NULL;
@@ -1096,13 +1094,13 @@ ephy_web_view_class_init (EphyWebViewClass *klass)
* The ::new-window signal is emitted after a new window has been opened by
* the view. For example, when a JavaScript popup window is opened.
**/
- g_signal_new ("new-window",
- EPHY_TYPE_WEB_VIEW,
- G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- GTK_TYPE_WIDGET);
+ g_signal_new ("new-window",
+ EPHY_TYPE_WEB_VIEW,
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ GTK_TYPE_WIDGET);
/**
* EphyWebView::search-key-press:
@@ -1112,13 +1110,13 @@ ephy_web_view_class_init (EphyWebViewClass *klass)
* The ::search-key-press signal is emitted for keypresses which
* should be used for find implementations.
**/
- g_signal_new ("search-key-press",
- EPHY_TYPE_WEB_VIEW,
- G_SIGNAL_RUN_LAST,
- 0, g_signal_accumulator_true_handled, NULL, NULL,
- G_TYPE_BOOLEAN,
- 1,
- GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+ g_signal_new ("search-key-press",
+ EPHY_TYPE_WEB_VIEW,
+ G_SIGNAL_RUN_LAST,
+ 0, g_signal_accumulator_true_handled, NULL, NULL,
+ G_TYPE_BOOLEAN,
+ 1,
+ GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
/**
* EphyWebView::download-only-load:
@@ -1127,18 +1125,18 @@ ephy_web_view_class_init (EphyWebViewClass *klass)
* The ::download-only-load signal is emitted when the @view has its main load
* replaced by a download, and that is the only reason why the @view has been created.
**/
- g_signal_new ("download-only-load",
- EPHY_TYPE_WEB_VIEW,
- G_SIGNAL_RUN_FIRST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 0);
+ g_signal_new ("download-only-load",
+ EPHY_TYPE_WEB_VIEW,
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 0);
}
static void
new_window_cb (EphyWebView *view,
EphyWebView *new_view,
- gpointer user_data)
+ gpointer user_data)
{
EphyEmbedContainer *container;
@@ -1151,10 +1149,10 @@ new_window_cb (EphyWebView *view,
}
static gboolean
-decide_policy_cb (WebKitWebView *web_view,
- WebKitPolicyDecision *decision,
+decide_policy_cb (WebKitWebView *web_view,
+ WebKitPolicyDecision *decision,
WebKitPolicyDecisionType decision_type,
- gpointer user_data)
+ gpointer user_data)
{
WebKitResponsePolicyDecision *response_decision;
WebKitURIResponse *response;
@@ -1206,19 +1204,19 @@ decide_policy_cb (WebKitWebView *web_view,
}
static void
-decide_on_permission_request (GtkWidget *info_bar,
- int response,
+decide_on_permission_request (GtkWidget *info_bar,
+ int response,
WebKitPermissionRequest *request)
{
gtk_widget_destroy (info_bar);
switch (response) {
- case GTK_RESPONSE_YES:
- webkit_permission_request_allow (request);
- break;
- default:
- webkit_permission_request_deny (request);
- break;
+ case GTK_RESPONSE_YES:
+ webkit_permission_request_allow (request);
+ break;
+ default:
+ webkit_permission_request_deny (request);
+ break;
}
gtk_widget_destroy (info_bar);
@@ -1321,7 +1319,7 @@ get_host_for_url_cb (gpointer service,
static void
restore_zoom_level (EphyWebView *view,
- const char *address)
+ const char *address)
{
if (ephy_embed_utils_address_has_web_scheme (address))
ephy_history_service_get_host_for_url (view->history_service,
@@ -1338,7 +1336,7 @@ restore_zoom_level (EphyWebView *view,
**/
static void
ephy_web_view_set_loading_message (EphyWebView *view,
- const char *address)
+ const char *address)
{
g_clear_pointer (&view->loading_message, g_free);
if (address) {
@@ -1350,7 +1348,7 @@ ephy_web_view_set_loading_message (EphyWebView *view,
if (title != NULL && title[0] != '\0') {
/* translators: %s here is the address of the web page */
- view->loading_message = g_strdup_printf (_ ("Loading “%s”…"), title);
+ view->loading_message = g_strdup_printf (_("Loading “%s”…"), title);
} else {
view->loading_message = g_strdup (_("Loading…"));
}
@@ -1364,7 +1362,7 @@ ephy_web_view_set_loading_message (EphyWebView *view,
static void
ephy_web_view_location_changed (EphyWebView *view,
- const char *location)
+ const char *location)
{
GObject *object = G_OBJECT (view);
@@ -1375,7 +1373,7 @@ ephy_web_view_location_changed (EphyWebView *view,
if (location == NULL || location[0] == '\0') {
ephy_web_view_set_address (view, NULL);
- } else if (g_str_has_prefix (location, EPHY_ABOUT_SCHEME":applications")) {
+ } else if (g_str_has_prefix (location, EPHY_ABOUT_SCHEME ":applications")) {
SoupURI *uri = soup_uri_new (location);
char *new_address;
@@ -1401,7 +1399,7 @@ ephy_web_view_location_changed (EphyWebView *view,
static void
update_security_status_for_committed_load (EphyWebView *view,
- const char *uri)
+ const char *uri)
{
EphySecurityLevel security_level = EPHY_SECURITY_LEVEL_NO_SECURITY;
EphyEmbed *embed = NULL;
@@ -1428,7 +1426,7 @@ update_security_status_for_committed_load (EphyWebView *view,
} else if (webkit_web_view_get_tls_info (WEBKIT_WEB_VIEW (view), &view->certificate, &view->tls_errors)) {
g_object_ref (view->certificate);
security_level = view->tls_errors == 0 ?
- EPHY_SECURITY_LEVEL_STRONG_SECURITY : EPHY_SECURITY_LEVEL_UNACCEPTABLE_CERTIFICATE;
+ EPHY_SECURITY_LEVEL_STRONG_SECURITY : EPHY_SECURITY_LEVEL_UNACCEPTABLE_CERTIFICATE;
} else if (!embed || ephy_embed_has_load_pending (embed)) {
security_level = EPHY_SECURITY_LEVEL_TO_BE_DETERMINED;
}
@@ -1439,9 +1437,9 @@ update_security_status_for_committed_load (EphyWebView *view,
}
static void
-load_changed_cb (WebKitWebView *web_view,
+load_changed_cb (WebKitWebView *web_view,
WebKitLoadEvent load_event,
- gpointer user_data)
+ gpointer user_data)
{
EphyWebView *view = EPHY_WEB_VIEW (web_view);
GObject *object = G_OBJECT (web_view);
@@ -1449,96 +1447,96 @@ load_changed_cb (WebKitWebView *web_view,
g_object_freeze_notify (object);
switch (load_event) {
- case WEBKIT_LOAD_STARTED: {
- const char *loading_uri = NULL;
+ case WEBKIT_LOAD_STARTED: {
+ const char *loading_uri = NULL;
- view->load_failed = FALSE;
+ view->load_failed = FALSE;
- if (view->snapshot_timeout_id) {
- g_source_remove (view->snapshot_timeout_id);
- view->snapshot_timeout_id = 0;
- }
+ if (view->snapshot_timeout_id) {
+ g_source_remove (view->snapshot_timeout_id);
+ view->snapshot_timeout_id = 0;
+ }
- loading_uri = webkit_web_view_get_uri (web_view);
+ loading_uri = webkit_web_view_get_uri (web_view);
- if (ephy_embed_utils_is_no_show_address (loading_uri))
- ephy_web_view_freeze_history (view);
+ if (ephy_embed_utils_is_no_show_address (loading_uri))
+ ephy_web_view_freeze_history (view);
- if (view->address == NULL || view->address[0] == '\0')
- ephy_web_view_set_address (view, loading_uri);
+ if (view->address == NULL || view->address[0] == '\0')
+ ephy_web_view_set_address (view, loading_uri);
- ephy_web_view_set_loading_message (view, loading_uri);
+ ephy_web_view_set_loading_message (view, loading_uri);
- /* Zoom level. */
- restore_zoom_level (view, loading_uri);
+ /* Zoom level. */
+ restore_zoom_level (view, loading_uri);
- break;
- }
- case WEBKIT_LOAD_REDIRECTED:
- /* TODO: Update the loading uri */
- break;
- case WEBKIT_LOAD_COMMITTED: {
- const char *uri;
- view->ever_committed = TRUE;
+ break;
+ }
+ case WEBKIT_LOAD_REDIRECTED:
+ /* TODO: Update the loading uri */
+ break;
+ case WEBKIT_LOAD_COMMITTED: {
+ const char *uri;
+ view->ever_committed = TRUE;
- /* Title and location. */
- uri = webkit_web_view_get_uri (web_view);
- ephy_web_view_location_changed (view, uri);
- update_security_status_for_committed_load (view, uri);
+ /* Title and location. */
+ uri = webkit_web_view_get_uri (web_view);
+ ephy_web_view_location_changed (view, uri);
+ update_security_status_for_committed_load (view, uri);
- /* History. */
- if (!ephy_web_view_is_history_frozen (view)) {
- char *history_uri = NULL;
+ /* History. */
+ if (!ephy_web_view_is_history_frozen (view)) {
+ char *history_uri = NULL;
- /* TODO: move the normalization down to the history service? */
- if (g_str_has_prefix (uri, EPHY_ABOUT_SCHEME))
+ /* TODO: move the normalization down to the history service? */
+ if (g_str_has_prefix (uri, EPHY_ABOUT_SCHEME))
history_uri = g_strdup_printf ("about:%s", uri + EPHY_ABOUT_SCHEME_LEN + 1);
- else
- history_uri = g_strdup (uri);
+ else
+ history_uri = g_strdup (uri);
- ephy_history_service_visit_url (view->history_service,
- history_uri,
- view->visit_type);
+ ephy_history_service_visit_url (view->history_service,
+ history_uri,
+ view->visit_type);
- g_free (history_uri);
- }
+ g_free (history_uri);
+ }
- if (view->loading_error_page)
+ if (view->loading_error_page)
view->loading_error_page = FALSE;
- else
+ else
view->error_page = EPHY_WEB_VIEW_ERROR_PAGE_NONE;
- break;
- }
- case WEBKIT_LOAD_FINISHED:
- ephy_web_view_set_loading_message (view, NULL);
-
- /* Ensure we load the icon for this web view, if available. */
- _ephy_web_view_update_icon (view);
-
- /* Reset visit type. */
- view->visit_type = EPHY_PAGE_VISIT_NONE;
-
- if (!ephy_web_view_is_history_frozen (view) &&
- ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) != EPHY_EMBED_SHELL_MODE_INCOGNITO) {
- if (!ephy_snapshot_service_lookup_snapshot_path (ephy_snapshot_service_get_default (),
webkit_web_view_get_uri (web_view))) {
- /* FIXME: The 1s delay is a workaround to allow time to render the page and get a favicon.
- * https://bugzilla.gnome.org/show_bug.cgi?id=761065
- */
- if (view->snapshot_timeout_id == 0) {
- view->snapshot_timeout_id = g_timeout_add_seconds_full (G_PRIORITY_LOW, 1,
- (GSourceFunc)web_view_check_snapshot,
- web_view, NULL);
+ break;
+ }
+ case WEBKIT_LOAD_FINISHED:
+ ephy_web_view_set_loading_message (view, NULL);
+
+ /* Ensure we load the icon for this web view, if available. */
+ _ephy_web_view_update_icon (view);
+
+ /* Reset visit type. */
+ view->visit_type = EPHY_PAGE_VISIT_NONE;
+
+ if (!ephy_web_view_is_history_frozen (view) &&
+ ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) != EPHY_EMBED_SHELL_MODE_INCOGNITO) {
+ if (!ephy_snapshot_service_lookup_snapshot_path (ephy_snapshot_service_get_default (),
webkit_web_view_get_uri (web_view))) {
+ /* FIXME: The 1s delay is a workaround to allow time to render the page and get a favicon.
+ * https://bugzilla.gnome.org/show_bug.cgi?id=761065
+ */
+ if (view->snapshot_timeout_id == 0) {
+ view->snapshot_timeout_id = g_timeout_add_seconds_full (G_PRIORITY_LOW, 1,
+ (GSourceFunc)web_view_check_snapshot,
+ web_view, NULL);
+ }
}
}
- }
- ephy_web_view_thaw_history (view);
+ ephy_web_view_thaw_history (view);
- break;
+ break;
- default:
- break;
+ default:
+ break;
}
g_object_thaw_notify (object);
@@ -1556,8 +1554,8 @@ load_changed_cb (WebKitWebView *web_view,
**/
void
ephy_web_view_set_placeholder (EphyWebView *view,
- const char *uri,
- const char *title)
+ const char *uri,
+ const char *title)
{
char *html;
@@ -1718,10 +1716,10 @@ ephy_web_view_get_error_page (EphyWebView *view)
*
**/
void
-ephy_web_view_load_error_page (EphyWebView *view,
- const char *uri,
+ephy_web_view_load_error_page (EphyWebView *view,
+ const char *uri,
EphyWebViewErrorPage page,
- GError *error)
+ GError *error)
{
GString *html = g_string_new ("");
const char *reason;
@@ -1813,7 +1811,7 @@ ephy_web_view_load_error_page (EphyWebView *view,
custom_class = "tls-error";
/* Access key for the "Accept Risk" button on the TLS error page. */
accesskey = C_("accept-risk-access-key", "R");
- load_anyway_js = g_strdup_printf
("window.webkit.messageHandlers.tlsErrorPage.postMessage(%"G_GUINT64_FORMAT");",
+ load_anyway_js = g_strdup_printf
("window.webkit.messageHandlers.tlsErrorPage.postMessage(%"G_GUINT64_FORMAT ");",
webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)));
break;
case EPHY_WEB_VIEW_ERROR_PAGE_NONE:
@@ -1860,11 +1858,11 @@ ephy_web_view_load_error_page (EphyWebView *view,
}
static gboolean
-load_failed_cb (WebKitWebView *web_view,
+load_failed_cb (WebKitWebView *web_view,
WebKitLoadEvent load_event,
- const char *uri,
- GError *error,
- gpointer user_data)
+ const char *uri,
+ GError *error,
+ gpointer user_data)
{
EphyWebView *view = EPHY_WEB_VIEW (web_view);
@@ -1882,53 +1880,53 @@ load_failed_cb (WebKitWebView *web_view,
(error->domain == WEBKIT_PLUGIN_ERROR), FALSE);
switch (error->code) {
- case WEBKIT_NETWORK_ERROR_FAILED:
- case WEBKIT_NETWORK_ERROR_TRANSPORT:
- case WEBKIT_NETWORK_ERROR_UNKNOWN_PROTOCOL:
- case WEBKIT_NETWORK_ERROR_FILE_DOES_NOT_EXIST:
- case WEBKIT_POLICY_ERROR_FAILED:
- case WEBKIT_POLICY_ERROR_CANNOT_SHOW_MIME_TYPE:
- case WEBKIT_POLICY_ERROR_CANNOT_SHOW_URI:
- case WEBKIT_POLICY_ERROR_CANNOT_USE_RESTRICTED_PORT:
- case WEBKIT_PLUGIN_ERROR_FAILED:
- case WEBKIT_PLUGIN_ERROR_CANNOT_FIND_PLUGIN:
- case WEBKIT_PLUGIN_ERROR_CANNOT_LOAD_PLUGIN:
- case WEBKIT_PLUGIN_ERROR_JAVA_UNAVAILABLE:
- case WEBKIT_PLUGIN_ERROR_CONNECTION_CANCELLED:
- ephy_web_view_load_error_page (view, uri, EPHY_WEB_VIEW_ERROR_PAGE_NETWORK_ERROR, error);
- return TRUE;
- case WEBKIT_NETWORK_ERROR_CANCELLED:
+ case WEBKIT_NETWORK_ERROR_FAILED:
+ case WEBKIT_NETWORK_ERROR_TRANSPORT:
+ case WEBKIT_NETWORK_ERROR_UNKNOWN_PROTOCOL:
+ case WEBKIT_NETWORK_ERROR_FILE_DOES_NOT_EXIST:
+ case WEBKIT_POLICY_ERROR_FAILED:
+ case WEBKIT_POLICY_ERROR_CANNOT_SHOW_MIME_TYPE:
+ case WEBKIT_POLICY_ERROR_CANNOT_SHOW_URI:
+ case WEBKIT_POLICY_ERROR_CANNOT_USE_RESTRICTED_PORT:
+ case WEBKIT_PLUGIN_ERROR_FAILED:
+ case WEBKIT_PLUGIN_ERROR_CANNOT_FIND_PLUGIN:
+ case WEBKIT_PLUGIN_ERROR_CANNOT_LOAD_PLUGIN:
+ case WEBKIT_PLUGIN_ERROR_JAVA_UNAVAILABLE:
+ case WEBKIT_PLUGIN_ERROR_CONNECTION_CANCELLED:
+ ephy_web_view_load_error_page (view, uri, EPHY_WEB_VIEW_ERROR_PAGE_NETWORK_ERROR, error);
+ return TRUE;
+ case WEBKIT_NETWORK_ERROR_CANCELLED:
{
if (!view->typed_address) {
- const char* prev_uri;
+ const char *prev_uri;
prev_uri = webkit_web_view_get_uri (web_view);
ephy_web_view_set_address (view, prev_uri);
}
}
break;
- case WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE:
- /* If we are going to download something, and this is the first
- * page to load in this tab, we may want to close it down. */
- if (!view->ever_committed)
- g_signal_emit_by_name (view, "download-only-load", NULL);
- break;
- /* In case the resource is going to be showed with a plugin just let
- * WebKit do it */
- case WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD:
- default:
- break;
+ case WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE:
+ /* If we are going to download something, and this is the first
+ * page to load in this tab, we may want to close it down. */
+ if (!view->ever_committed)
+ g_signal_emit_by_name (view, "download-only-load", NULL);
+ break;
+ /* In case the resource is going to be showed with a plugin just let
+ * WebKit do it */
+ case WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD:
+ default:
+ break;
}
return FALSE;
}
static gboolean
-load_failed_with_tls_error_cb (WebKitWebView *web_view,
- const char *uri,
- GTlsCertificate *certificate,
+load_failed_with_tls_error_cb (WebKitWebView *web_view,
+ const char *uri,
+ GTlsCertificate *certificate,
GTlsCertificateFlags errors,
- gpointer user_data)
+ gpointer user_data)
{
EphyWebView *view = EPHY_WEB_VIEW (web_view);
@@ -1945,9 +1943,9 @@ load_failed_with_tls_error_cb (WebKitWebView *web_view,
}
static void
-mixed_content_detected_cb (WebKitWebView *web_view,
+mixed_content_detected_cb (WebKitWebView *web_view,
WebKitInsecureContentEvent event,
- gpointer user_data)
+ gpointer user_data)
{
EphyWebView *view = EPHY_WEB_VIEW (web_view);
@@ -1957,7 +1955,7 @@ mixed_content_detected_cb (WebKitWebView *web_view,
static void
close_web_view_cb (WebKitWebView *web_view,
- gpointer user_data)
+ gpointer user_data)
{
GtkWidget *widget = gtk_widget_get_toplevel (GTK_WIDGET (web_view));
@@ -1974,8 +1972,8 @@ close_web_view_cb (WebKitWebView *web_view,
static void
zoom_changed_cb (WebKitWebView *web_view,
- GParamSpec *pspec,
- gpointer user_data)
+ GParamSpec *pspec,
+ gpointer user_data)
{
const char *address;
double zoom;
@@ -1994,7 +1992,7 @@ zoom_changed_cb (WebKitWebView *web_view,
}
static gboolean
-script_dialog_cb (WebKitWebView *web_view,
+script_dialog_cb (WebKitWebView *web_view,
WebKitScriptDialog *dialog)
{
if (webkit_script_dialog_get_dialog_type (dialog) != WEBKIT_SCRIPT_DIALOG_BEFORE_UNLOAD_CONFIRM)
@@ -2122,7 +2120,7 @@ ephy_web_view_new_with_related_view (WebKitWebView *related_view)
* Loads the given #WebKitNetworkRequest in the given #EphyWebView.
**/
void
-ephy_web_view_load_request (EphyWebView *view,
+ephy_web_view_load_request (EphyWebView *view,
WebKitURIRequest *request)
{
const char *url;
@@ -2149,9 +2147,9 @@ typedef struct {
static void
effective_url_head_cb (SoupSession *session,
SoupMessage *message,
- gpointer user_data)
+ gpointer user_data)
{
- HEADAttemptData *data = (HEADAttemptData*)user_data;
+ HEADAttemptData *data = (HEADAttemptData *)user_data;
EphyWebView *view = data->view;
@@ -2191,7 +2189,7 @@ effective_url_head_cb (SoupSession *session,
**/
void
ephy_web_view_load_url (EphyWebView *view,
- const char *url)
+ const char *url)
{
char *effective_url;
@@ -2231,7 +2229,7 @@ ephy_web_view_is_overview (EphyWebView *view)
if (!view->address)
return FALSE;
- return (!strcmp (view->address, EPHY_ABOUT_SCHEME":overview") ||
+ return (!strcmp (view->address, EPHY_ABOUT_SCHEME ":overview") ||
!strcmp (view->address, "about:overview"));
}
@@ -2399,7 +2397,7 @@ ephy_web_view_get_link_message (EphyWebView *view)
**/
void
ephy_web_view_set_link_message (EphyWebView *view,
- const char *address)
+ const char *address)
{
char *decoded_address;
@@ -2427,7 +2425,7 @@ ephy_web_view_set_link_message (EphyWebView *view,
* Sets @view's security-level property to @level.
**/
void
-ephy_web_view_set_security_level (EphyWebView *view,
+ephy_web_view_set_security_level (EphyWebView *view,
EphySecurityLevel level)
{
g_return_if_fail (EPHY_IS_WEB_VIEW (view));
@@ -2479,7 +2477,7 @@ ephy_web_view_get_typed_address (EphyWebView *view)
**/
void
ephy_web_view_set_typed_address (EphyWebView *view,
- const char *address)
+ const char *address)
{
g_return_if_fail (EPHY_IS_WEB_VIEW (view));
@@ -2491,8 +2489,8 @@ ephy_web_view_set_typed_address (EphyWebView *view,
static void
has_modified_forms_cb (EphyWebExtensionProxy *web_extension,
- GAsyncResult *result,
- GTask *task)
+ GAsyncResult *result,
+ GTask *task)
{
gboolean retval;
@@ -2516,10 +2514,10 @@ has_modified_forms_cb (EphyWebExtensionProxy *web_extension,
* Return value: %TRUE if @view has user-modified forms
**/
void
-ephy_web_view_has_modified_forms (EphyWebView *view,
- GCancellable *cancellable,
+ephy_web_view_has_modified_forms (EphyWebView *view,
+ GCancellable *cancellable,
GAsyncReadyCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
GTask *task;
@@ -2541,9 +2539,9 @@ ephy_web_view_has_modified_forms (EphyWebView *view,
}
gboolean
-ephy_web_view_has_modified_forms_finish (EphyWebView *view,
+ephy_web_view_has_modified_forms_finish (EphyWebView *view,
GAsyncResult *result,
- GError **error)
+ GError **error)
{
g_return_val_if_fail (g_task_is_valid (result, view), FALSE);
@@ -2567,8 +2565,8 @@ get_best_web_app_icon_async_data_free (GetBestWebAppIconAsyncData *data)
static void
get_best_web_app_icon_cb (EphyWebExtensionProxy *web_extension,
- GAsyncResult *result,
- GTask *task)
+ GAsyncResult *result,
+ GTask *task)
{
gboolean retval = FALSE;
char *uri = NULL;
@@ -2589,10 +2587,10 @@ get_best_web_app_icon_cb (EphyWebExtensionProxy *web_extension,
}
void
-ephy_web_view_get_best_web_app_icon (EphyWebView *view,
- GCancellable *cancellable,
+ephy_web_view_get_best_web_app_icon (EphyWebView *view,
+ GCancellable *cancellable,
GAsyncReadyCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
GTask *task;
@@ -2615,12 +2613,12 @@ ephy_web_view_get_best_web_app_icon (EphyWebView *view,
}
gboolean
-ephy_web_view_get_best_web_app_icon_finish (EphyWebView *view,
+ephy_web_view_get_best_web_app_icon_finish (EphyWebView *view,
GAsyncResult *result,
- gboolean *icon_result,
- char **icon_uri,
- GdkRGBA *icon_color,
- GError **error)
+ gboolean *icon_result,
+ char **icon_uri,
+ GdkRGBA *icon_color,
+ GError **error)
{
GetBestWebAppIconAsyncData *data;
GTask *task = G_TASK (result);
@@ -2646,8 +2644,8 @@ ephy_web_view_get_best_web_app_icon_finish (EphyWebView *view,
static void
get_web_app_title_cb (EphyWebExtensionProxy *web_extension,
- GAsyncResult *result,
- GTask *task)
+ GAsyncResult *result,
+ GTask *task)
{
char *retval;
GError *error = NULL;
@@ -2661,10 +2659,10 @@ get_web_app_title_cb (EphyWebExtensionProxy *web_extension,
}
void
-ephy_web_view_get_web_app_title (EphyWebView *view,
- GCancellable *cancellable,
+ephy_web_view_get_web_app_title (EphyWebView *view,
+ GCancellable *cancellable,
GAsyncReadyCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
GTask *task;
@@ -2686,9 +2684,9 @@ ephy_web_view_get_web_app_title (EphyWebView *view,
}
char *
-ephy_web_view_get_web_app_title_finish (EphyWebView *view,
+ephy_web_view_get_web_app_title_finish (EphyWebView *view,
GAsyncResult *result,
- GError **error)
+ GError **error)
{
g_return_val_if_fail (g_task_is_valid (result, view), NULL);
@@ -2707,9 +2705,9 @@ ephy_web_view_get_web_app_title_finish (EphyWebView *view,
* have been found with that certificate.
**/
void
-ephy_web_view_get_security_level (EphyWebView *view,
- EphySecurityLevel *level,
- GTlsCertificate **certificate,
+ephy_web_view_get_security_level (EphyWebView *view,
+ EphySecurityLevel *level,
+ GTlsCertificate **certificate,
GTlsCertificateFlags *errors)
{
g_return_if_fail (EPHY_IS_WEB_VIEW (view));
@@ -2747,7 +2745,7 @@ ephy_web_view_print_failed (EphyWebView *view, GError *error)
static void
print_operation_finished_cb (WebKitPrintOperation *operation,
- EphyWebView *view)
+ EphyWebView *view)
{
ephy_embed_shell_set_page_setup (ephy_embed_shell_get_default (),
webkit_print_operation_get_page_setup (operation));
@@ -2755,8 +2753,8 @@ print_operation_finished_cb (WebKitPrintOperation *operation,
static void
print_operation_failed_cb (WebKitPrintOperation *operation,
- GError *error,
- EphyWebView *view)
+ GError *error,
+ EphyWebView *view)
{
g_signal_handlers_disconnect_by_func (operation, print_operation_finished_cb, view);
ephy_web_view_print_failed (view, error);
@@ -2801,8 +2799,8 @@ ephy_web_view_print (EphyWebView *view)
static void
web_resource_get_data_cb (WebKitWebResource *resource,
- GAsyncResult *result,
- GOutputStream *output_stream)
+ GAsyncResult *result,
+ GOutputStream *output_stream)
{
guchar *data;
gsize data_length;
@@ -2828,8 +2826,8 @@ web_resource_get_data_cb (WebKitWebResource *resource,
}
static void
-ephy_web_view_save_main_resource_cb (GFile *file,
- GAsyncResult *result,
+ephy_web_view_save_main_resource_cb (GFile *file,
+ GAsyncResult *result,
WebKitWebView *view)
{
GFileOutputStream *output_stream;
diff --git a/embed/web-extension/ephy-embed-form-auth.c b/embed/web-extension/ephy-embed-form-auth.c
index 1ce6504..0542779 100644
--- a/embed/web-extension/ephy-embed-form-auth.c
+++ b/embed/web-extension/ephy-embed-form-auth.c
@@ -19,8 +19,7 @@
#include <config.h>
#include "ephy-embed-form-auth.h"
-struct _EphyEmbedFormAuth
-{
+struct _EphyEmbedFormAuth {
GObject parent_instance;
guint64 page_id;
@@ -62,7 +61,7 @@ EphyEmbedFormAuth *
ephy_embed_form_auth_new (WebKitWebPage *web_page,
WebKitDOMNode *username_node,
WebKitDOMNode *password_node,
- const char* username)
+ const char *username)
{
EphyEmbedFormAuth *form_auth;
@@ -103,7 +102,7 @@ ephy_embed_form_auth_get_page_id (EphyEmbedFormAuth *form_auth)
return form_auth->page_id;
}
-const char*
+const char *
ephy_embed_form_auth_get_username (EphyEmbedFormAuth *form_auth)
{
return form_auth->username;
diff --git a/embed/web-extension/ephy-uri-tester.c b/embed/web-extension/ephy-uri-tester.c
index 76cdc3b..c2c97ab 100644
--- a/embed/web-extension/ephy-uri-tester.c
+++ b/embed/web-extension/ephy-uri-tester.c
@@ -35,8 +35,7 @@
#define SIGNATURE_SIZE 8
#define UPDATE_FREQUENCY 24 * 60 * 60 /* In seconds */
-struct _EphyUriTester
-{
+struct _EphyUriTester {
GObject parent_instance;
GSList *filters;
@@ -61,8 +60,7 @@ struct _EphyUriTester
GRegex *regex_frame_add;
};
-enum
-{
+enum {
PROP_0,
PROP_FILTERS,
PROP_BASE_DATA_DIR,
@@ -93,9 +91,9 @@ ephy_uri_tester_ensure_data_dir (const char *base_data_dir)
return folder;
}
-static char*
+static char *
ephy_uri_tester_get_fileuri_for_url (EphyUriTester *tester,
- const char *url)
+ const char *url)
{
char *filename = NULL;
char *path = NULL;
@@ -121,8 +119,8 @@ typedef struct {
} RetrieveFilterAsyncData;
static void
-ephy_uri_tester_retrieve_filter_finished (GFile *src,
- GAsyncResult *result,
+ephy_uri_tester_retrieve_filter_finished (GFile *src,
+ GAsyncResult *result,
RetrieveFilterAsyncData *data)
{
GError *error = NULL;
@@ -140,8 +138,8 @@ ephy_uri_tester_retrieve_filter_finished (GFile *src,
static void
ephy_uri_tester_retrieve_filter (EphyUriTester *tester,
- const char *url,
- const char *fileuri)
+ const char *url,
+ const char *fileuri)
{
GFile *src;
GFile *dest;
@@ -184,21 +182,19 @@ ephy_uri_tester_filter_is_valid (const char *fileuri)
NULL,
NULL);
result = FALSE;
- if (file_info)
- {
- GTimeVal current_time;
- GTimeVal mod_time;
-
- g_get_current_time (¤t_time);
- g_file_info_get_modification_time (file_info, &mod_time);
-
- if (current_time.tv_sec > mod_time.tv_sec)
- {
- gint64 expire_time = mod_time.tv_sec + UPDATE_FREQUENCY;
- result = current_time.tv_sec < expire_time;
- }
- g_object_unref (file_info);
+ if (file_info) {
+ GTimeVal current_time;
+ GTimeVal mod_time;
+
+ g_get_current_time (¤t_time);
+ g_file_info_get_modification_time (file_info, &mod_time);
+
+ if (current_time.tv_sec > mod_time.tv_sec) {
+ gint64 expire_time = mod_time.tv_sec + UPDATE_FREQUENCY;
+ result = current_time.tv_sec < expire_time;
}
+ g_object_unref (file_info);
+ }
g_object_unref (file);
@@ -213,18 +209,17 @@ ephy_uri_tester_load_patterns (EphyUriTester *tester)
char *fileuri = NULL;
/* Load patterns from the list of filters. */
- for (filter = tester->filters; filter; filter = g_slist_next(filter))
- {
- url = (char*)filter->data;
- fileuri = ephy_uri_tester_get_fileuri_for_url (tester, url);
+ for (filter = tester->filters; filter; filter = g_slist_next (filter)) {
+ url = (char *)filter->data;
+ fileuri = ephy_uri_tester_get_fileuri_for_url (tester, url);
- if (!ephy_uri_tester_filter_is_valid (fileuri))
- ephy_uri_tester_retrieve_filter (tester, url, fileuri);
- else
- ephy_uri_tester_parse_file_at_uri (tester, fileuri);
+ if (!ephy_uri_tester_filter_is_valid (fileuri))
+ ephy_uri_tester_retrieve_filter (tester, url, fileuri);
+ else
+ ephy_uri_tester_parse_file_at_uri (tester, fileuri);
- g_free (fileuri);
- }
+ g_free (fileuri);
+ }
}
static void
@@ -235,53 +230,47 @@ ephy_uri_tester_load_filters (EphyUriTester *tester)
filepath = g_build_filename (tester->data_dir, FILTERS_LIST_FILENAME, NULL);
- if (g_file_test (filepath, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))
- {
- GFile *file = NULL;
- char *contents = NULL;
- gsize length = 0;
- GError *error = NULL;
-
- file = g_file_new_for_path (filepath);
- if (g_file_load_contents (file, NULL, &contents, &length, NULL, &error))
- {
- char **urls_array = NULL;
- char *url = NULL;
- int i = 0;
-
- urls_array = g_strsplit (contents, ";", -1);
- for (i = 0; urls_array [i]; i++)
- {
- url = g_strstrip (g_strdup (urls_array[i]));
- if (!g_str_equal (url, ""))
- list = g_slist_prepend (list, url);
- }
- g_strfreev (urls_array);
-
- g_free (contents);
- }
-
- if (error)
- {
- LOG ("Error loading filters from %s: %s", filepath, error->message);
- g_error_free (error);
- }
+ if (g_file_test (filepath, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
+ GFile *file = NULL;
+ char *contents = NULL;
+ gsize length = 0;
+ GError *error = NULL;
+
+ file = g_file_new_for_path (filepath);
+ if (g_file_load_contents (file, NULL, &contents, &length, NULL, &error)) {
+ char **urls_array = NULL;
+ char *url = NULL;
+ int i = 0;
+
+ urls_array = g_strsplit (contents, ";", -1);
+ for (i = 0; urls_array [i]; i++) {
+ url = g_strstrip (g_strdup (urls_array[i]));
+ if (!g_str_equal (url, ""))
+ list = g_slist_prepend (list, url);
+ }
+ g_strfreev (urls_array);
- g_object_unref (file);
+ g_free (contents);
}
- else
- {
- /* No file exists yet, so use the default filter and save it. */
- list = g_slist_prepend (list, g_strdup (DEFAULT_FILTER_URL));
+
+ if (error) {
+ LOG ("Error loading filters from %s: %s", filepath, error->message);
+ g_error_free (error);
}
+ g_object_unref (file);
+ } else {
+ /* No file exists yet, so use the default filter and save it. */
+ list = g_slist_prepend (list, g_strdup (DEFAULT_FILTER_URL));
+ }
+
g_free (filepath);
- ephy_uri_tester_set_filters (tester, g_slist_reverse(list));
+ ephy_uri_tester_set_filters (tester, g_slist_reverse (list));
}
#if 0
-TODO: Use this to create a filters dialog, or something.
+ TODO: Use this to create a filters dialog, or something.
static void
ephy_uri_tester_save_filters (EphyUriTester *tester)
@@ -291,30 +280,28 @@ ephy_uri_tester_save_filters (EphyUriTester *tester)
filepath = g_build_filename (tester->data_dir, FILTERS_LIST_FILENAME, NULL);
- if ((file = g_fopen (filepath, "w")))
- {
- GSList *item = NULL;
- char *filter = NULL;
+ if ((file = g_fopen (filepath, "w"))) {
+ GSList *item = NULL;
+ char *filter = NULL;
- for (item = tester->filters; item; item = g_slist_next (item))
- {
- filter = g_strdup_printf ("%s;", (char*)item->data);
- fputs (filter, file);
- g_free (filter);
- }
- fclose (file);
+ for (item = tester->filters; item; item = g_slist_next (item)) {
+ filter = g_strdup_printf ("%s;", (char *)item->data);
+ fputs (filter, file);
+ g_free (filter);
}
+ fclose (file);
+ }
g_free (filepath);
}
#endif
static inline int
-ephy_uri_tester_check_rule (EphyUriTester *tester,
- GRegex *regex,
- const char *patt,
- const char *req_uri,
- const char *page_uri,
- gboolean whitelist)
+ephy_uri_tester_check_rule (EphyUriTester *tester,
+ GRegex *regex,
+ const char *patt,
+ const char *req_uri,
+ const char *page_uri,
+ gboolean whitelist)
{
char *opts;
GHashTable *optslist = tester->optslist;
@@ -325,11 +312,10 @@ ephy_uri_tester_check_rule (EphyUriTester *tester,
return FALSE;
opts = g_hash_table_lookup (optslist, patt);
- if (opts && g_regex_match (tester->regex_third_party, opts, 0, NULL))
- {
- if (page_uri && g_regex_match_full (regex, page_uri, -1, 0, 0, NULL, NULL))
- return FALSE;
- }
+ if (opts && g_regex_match (tester->regex_third_party, opts, 0, NULL)) {
+ if (page_uri && g_regex_match_full (regex, page_uri, -1, 0, 0, NULL, NULL))
+ return FALSE;
+ }
/* TODO: Domain and document opt check */
if (whitelist)
LOG ("whitelisted by pattern regexp=%s -- %s", g_regex_get_pattern (regex), req_uri);
@@ -339,10 +325,10 @@ ephy_uri_tester_check_rule (EphyUriTester *tester,
}
static inline gboolean
-ephy_uri_tester_is_matched_by_pattern (EphyUriTester *tester,
- const char *req_uri,
- const char *page_uri,
- gboolean whitelist)
+ephy_uri_tester_is_matched_by_pattern (EphyUriTester *tester,
+ const char *req_uri,
+ const char *page_uri,
+ gboolean whitelist)
{
GHashTableIter iter;
gpointer patt, regex;
@@ -351,20 +337,19 @@ ephy_uri_tester_is_matched_by_pattern (EphyUriTester *tester,
pattern = tester->whitelisted_pattern;
g_hash_table_iter_init (&iter, pattern);
- while (g_hash_table_iter_next (&iter, &patt, ®ex))
- {
- if (ephy_uri_tester_check_rule (tester, regex, patt, req_uri, page_uri, whitelist))
- return TRUE;
- }
+ while (g_hash_table_iter_next (&iter, &patt, ®ex)) {
+ if (ephy_uri_tester_check_rule (tester, regex, patt, req_uri, page_uri, whitelist))
+ return TRUE;
+ }
return FALSE;
}
static inline gboolean
-ephy_uri_tester_is_matched_by_key (EphyUriTester *tester,
- const char *opts,
- const char *req_uri,
- const char *page_uri,
- gboolean whitelist)
+ephy_uri_tester_is_matched_by_key (EphyUriTester *tester,
+ const char *opts,
+ const char *req_uri,
+ const char *page_uri,
+ gboolean whitelist)
{
char *uri;
int len;
@@ -379,35 +364,34 @@ ephy_uri_tester_is_matched_by_key (EphyUriTester *tester,
memset (&sig[0], 0, sizeof (sig));
/* Signatures are made on pattern, so we need to convert url to a pattern as well */
- guri = ephy_uri_tester_fixup_regexp ("", (char*)req_uri);
+ guri = ephy_uri_tester_fixup_regexp ("", (char *)req_uri);
uri = guri->str;
len = guri->len;
- for (pos = len - SIGNATURE_SIZE; pos >= 0; pos--)
- {
- GRegex *regex;
- strncpy (sig, uri + pos, SIGNATURE_SIZE);
- regex = g_hash_table_lookup (keys, sig);
-
- /* Dont check if regex is already blacklisted */
- if (!regex || g_list_find (regex_bl, regex))
- continue;
- ret = ephy_uri_tester_check_rule (tester, regex, sig, req_uri, page_uri, whitelist);
- if (ret)
- break;
- regex_bl = g_list_prepend (regex_bl, regex);
- }
+ for (pos = len - SIGNATURE_SIZE; pos >= 0; pos--) {
+ GRegex *regex;
+ strncpy (sig, uri + pos, SIGNATURE_SIZE);
+ regex = g_hash_table_lookup (keys, sig);
+
+ /* Dont check if regex is already blacklisted */
+ if (!regex || g_list_find (regex_bl, regex))
+ continue;
+ ret = ephy_uri_tester_check_rule (tester, regex, sig, req_uri, page_uri, whitelist);
+ if (ret)
+ break;
+ regex_bl = g_list_prepend (regex_bl, regex);
+ }
g_string_free (guri, TRUE);
g_list_free (regex_bl);
return ret;
}
static gboolean
-ephy_uri_tester_is_matched (EphyUriTester *tester,
- const char *opts,
- const char *req_uri,
- const char *page_uri,
- gboolean whitelist)
+ephy_uri_tester_is_matched (EphyUriTester *tester,
+ const char *opts,
+ const char *req_uri,
+ const char *page_uri,
+ gboolean whitelist)
{
char *value;
GHashTable *urlcache = tester->urlcache;
@@ -419,18 +403,16 @@ ephy_uri_tester_is_matched (EphyUriTester *tester,
return GPOINTER_TO_INT (value);
/* Look for a match either by key or by pattern. */
- if (ephy_uri_tester_is_matched_by_key (tester, opts, req_uri, page_uri, whitelist))
- {
- g_hash_table_insert (urlcache, g_strdup (req_uri), g_strdup ("1"));
- return TRUE;
- }
+ if (ephy_uri_tester_is_matched_by_key (tester, opts, req_uri, page_uri, whitelist)) {
+ g_hash_table_insert (urlcache, g_strdup (req_uri), g_strdup ("1"));
+ return TRUE;
+ }
/* Matching by pattern is pretty expensive, so do it if needed only. */
- if (ephy_uri_tester_is_matched_by_pattern (tester, req_uri, page_uri, whitelist))
- {
- g_hash_table_insert (urlcache, g_strdup (req_uri), GINT_TO_POINTER (TRUE));
- return TRUE;
- }
+ if (ephy_uri_tester_is_matched_by_pattern (tester, req_uri, page_uri, whitelist)) {
+ g_hash_table_insert (urlcache, g_strdup (req_uri), GINT_TO_POINTER (TRUE));
+ return TRUE;
+ }
g_hash_table_insert (urlcache, g_strdup (req_uri), GINT_TO_POINTER (FALSE));
return FALSE;
@@ -448,54 +430,50 @@ ephy_uri_tester_fixup_regexp (const char *prefix, char *src)
str = g_string_new (prefix);
/* lets strip first .* */
- if (src[0] == '*')
- {
- (void)*src++;
- }
+ if (src[0] == '*') {
+ (void)*src++;
+ }
- do
- {
- switch (*src)
- {
- case '*':
- g_string_append (str, ".*");
- break;
- /*case '.':
- g_string_append (str, "\\.");
- break;*/
- case '?':
- case '[':
- case ']':
- g_string_append_printf (str, "\\%c", *src);
- break;
- case '|':
- /* FIXME: We actually need to match :[0-9]+ or '/'. Sign means
- "here could be port number or nothing". So bla.com^ will match
- bla.com/ or bla.com:8080/ but not bla.com.au/ */
- case '^':
- case '+':
- break;
- default:
- g_string_append_printf (str,"%c", *src);
- break;
- }
- src++;
+ do {
+ switch (*src) {
+ case '*':
+ g_string_append (str, ".*");
+ break;
+ /*case '.':
+ g_string_append (str, "\\.");
+ break;*/
+ case '?':
+ case '[':
+ case ']':
+ g_string_append_printf (str, "\\%c", *src);
+ break;
+ case '|':
+ /* FIXME: We actually need to match :[0-9]+ or '/'. Sign means
+ "here could be port number or nothing". So bla.com^ will match
+ bla.com/ or bla.com:8080/ but not bla.com.au/ */
+ case '^':
+ case '+':
+ break;
+ default:
+ g_string_append_printf (str, "%c", *src);
+ break;
}
- while (*src);
+ src++;
+ } while (*src);
len = str->len;
/* We dont need .* in the end of url. Thats stupid */
- if (str->str && str->str[len-1] == '*' && str->str[len-2] == '.')
- g_string_erase (str, len-2, 2);
+ if (str->str && str->str[len - 1] == '*' && str->str[len - 2] == '.')
+ g_string_erase (str, len - 2, 2);
return str;
}
static void
ephy_uri_tester_compile_regexp (EphyUriTester *tester,
- GString *gpatt,
- const char *opts,
- gboolean whitelist)
+ GString *gpatt,
+ const char *opts,
+ gboolean whitelist)
{
GHashTable *pattern;
GHashTable *keys;
@@ -514,126 +492,110 @@ ephy_uri_tester_compile_regexp (EphyUriTester *tester,
/* TODO: Play with optimization flags */
regex = g_regex_new (patt, G_REGEX_OPTIMIZE | G_REGEX_JAVASCRIPT_COMPAT,
G_REGEX_MATCH_NOTEMPTY, &error);
- if (error)
- {
- g_warning ("%s: %s", G_STRFUNC, error->message);
- g_error_free (error);
- return;
- }
+ if (error) {
+ g_warning ("%s: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ return;
+ }
pattern = tester->pattern;
keys = tester->keys;
optslist = tester->optslist;
- if (whitelist)
- {
- pattern = tester->whitelisted_pattern;
- keys = tester->whitelisted_keys;
- optslist = tester->whitelisted_optslist;
- }
+ if (whitelist) {
+ pattern = tester->whitelisted_pattern;
+ keys = tester->whitelisted_keys;
+ optslist = tester->whitelisted_optslist;
+ }
- if (!g_regex_match (tester->regex_pattern, patt, 0, NULL))
- {
- int signature_count = 0;
- int pos = 0;
- char *sig;
-
- for (pos = len - SIGNATURE_SIZE; pos >= 0; pos--) {
- sig = g_strndup (patt + pos, SIGNATURE_SIZE);
- if (!strchr (sig, '*') &&
- !g_hash_table_lookup (keys, sig))
- {
- LOG ("sig: %s %s", sig, patt);
- g_hash_table_insert (keys, g_strdup (sig), g_regex_ref (regex));
- g_hash_table_insert (optslist, g_strdup (sig), g_strdup (opts));
- signature_count++;
- }
- else
- {
- if (sig[0] == '*' &&
- !g_hash_table_lookup (pattern, patt))
- {
- LOG ("patt2: %s %s", sig, patt);
- g_hash_table_insert (pattern, g_strdup (patt), g_regex_ref (regex));
- g_hash_table_insert (optslist, g_strdup (patt), g_strdup (opts));
- }
- }
- g_free (sig);
+ if (!g_regex_match (tester->regex_pattern, patt, 0, NULL)) {
+ int signature_count = 0;
+ int pos = 0;
+ char *sig;
+
+ for (pos = len - SIGNATURE_SIZE; pos >= 0; pos--) {
+ sig = g_strndup (patt + pos, SIGNATURE_SIZE);
+ if (!strchr (sig, '*') &&
+ !g_hash_table_lookup (keys, sig)) {
+ LOG ("sig: %s %s", sig, patt);
+ g_hash_table_insert (keys, g_strdup (sig), g_regex_ref (regex));
+ g_hash_table_insert (optslist, g_strdup (sig), g_strdup (opts));
+ signature_count++;
+ } else {
+ if (sig[0] == '*' &&
+ !g_hash_table_lookup (pattern, patt)) {
+ LOG ("patt2: %s %s", sig, patt);
+ g_hash_table_insert (pattern, g_strdup (patt), g_regex_ref (regex));
+ g_hash_table_insert (optslist, g_strdup (patt), g_strdup (opts));
+ }
}
- g_regex_unref (regex);
-
- if (signature_count > 1 && g_hash_table_lookup (pattern, patt))
- g_hash_table_remove (pattern, patt);
- }
- else
- {
- LOG ("patt: %s%s", patt, "");
- /* Pattern is a regexp chars */
- g_hash_table_insert (pattern, g_strdup (patt), regex);
- g_hash_table_insert (optslist, g_strdup (patt), g_strdup (opts));
+ g_free (sig);
}
+ g_regex_unref (regex);
+
+ if (signature_count > 1 && g_hash_table_lookup (pattern, patt))
+ g_hash_table_remove (pattern, patt);
+ } else {
+ LOG ("patt: %s%s", patt, "");
+ /* Pattern is a regexp chars */
+ g_hash_table_insert (pattern, g_strdup (patt), regex);
+ g_hash_table_insert (optslist, g_strdup (patt), g_strdup (opts));
+ }
}
static void
ephy_uri_tester_add_url_pattern (EphyUriTester *tester,
- const char *prefix,
- const char *type,
- char *line,
- gboolean whitelist)
+ const char *prefix,
+ const char *type,
+ char *line,
+ gboolean whitelist)
{
- char **data;
- char *patt;
- GString *format_patt;
- const char *opts;
-
- data = g_strsplit (line, "$", -1);
- if (!data || !data[0])
- {
- g_strfreev (data);
- return;
- }
-
- if (data[1] && data[2])
- {
- patt = g_strconcat (data[0], data[1], NULL);
- opts = g_strconcat (type, ",", data[2], NULL);
- }
- else if (data[1])
- {
- patt = data[0];
- opts = g_strconcat (type, ",", data[1], NULL);
- }
- else
- {
- patt = data[0];
- opts = type;
- }
-
- if (g_regex_match (tester->regex_subdocument, opts, 0, NULL))
- {
- if (data[1] && data[2])
- g_free (patt);
- if (data[1])
- g_free ((char *)opts);
- g_strfreev (data);
- return;
- }
-
- format_patt = ephy_uri_tester_fixup_regexp (prefix, patt);
+ char **data;
+ char *patt;
+ GString *format_patt;
+ const char *opts;
- if (whitelist)
- LOG ("whitelist: %s opts %s", format_patt->str, opts);
- else
- LOG ("blacklist: %s opts %s", format_patt->str, opts);
+ data = g_strsplit (line, "$", -1);
+ if (!data || !data[0]) {
+ g_strfreev (data);
+ return;
+ }
- ephy_uri_tester_compile_regexp (tester, format_patt, opts, whitelist);
+ if (data[1] && data[2]) {
+ patt = g_strconcat (data[0], data[1], NULL);
+ opts = g_strconcat (type, ",", data[2], NULL);
+ } else if (data[1]) {
+ patt = data[0];
+ opts = g_strconcat (type, ",", data[1], NULL);
+ } else {
+ patt = data[0];
+ opts = type;
+ }
+ if (g_regex_match (tester->regex_subdocument, opts, 0, NULL)) {
if (data[1] && data[2])
- g_free (patt);
+ g_free (patt);
if (data[1])
- g_free ((char *)opts);
+ g_free ((char *)opts);
g_strfreev (data);
+ return;
+ }
+
+ format_patt = ephy_uri_tester_fixup_regexp (prefix, patt);
- g_string_free (format_patt, TRUE);
+ if (whitelist)
+ LOG ("whitelist: %s opts %s", format_patt->str, opts);
+ else
+ LOG ("blacklist: %s opts %s", format_patt->str, opts);
+
+ ephy_uri_tester_compile_regexp (tester, format_patt, opts, whitelist);
+
+ if (data[1] && data[2])
+ g_free (patt);
+ if (data[1])
+ g_free ((char *)opts);
+ g_strfreev (data);
+
+ g_string_free (format_patt, TRUE);
}
static inline void
@@ -645,49 +607,43 @@ ephy_uri_tester_frame_add (EphyUriTester *tester, char *line)
(void)*line++;
if (strchr (line, '\'')
|| (strchr (line, ':')
- && !g_regex_match (tester->regex_frame_add, line, 0, NULL)))
- {
- return;
- }
+ && !g_regex_match (tester->regex_frame_add, line, 0, NULL))) {
+ return;
+ }
g_string_append (tester->blockcss, separator);
g_string_append (tester->blockcss, line);
}
static inline void
-ephy_uri_tester_frame_add_private (EphyUriTester *tester,
- const char *line,
- const char *sep)
+ephy_uri_tester_frame_add_private (EphyUriTester *tester,
+ const char *line,
+ const char *sep)
{
char **data;
data = g_strsplit (line, sep, 2);
if (!(data[1] && *data[1])
- || strchr (data[1], '\'')
+ || strchr (data[1], '\'')
|| (strchr (data[1], ':')
- && !g_regex_match (tester->regex_frame_add, data[1], 0, NULL)))
- {
- g_strfreev (data);
- return;
- }
+ && !g_regex_match (tester->regex_frame_add, data[1], 0, NULL))) {
+ g_strfreev (data);
+ return;
+ }
- if (strchr (data[0], ','))
- {
- char **domains;
- int i;
+ if (strchr (data[0], ',')) {
+ char **domains;
+ int i;
- domains = g_strsplit (data[0], ",", -1);
- for (i = 0; domains[i]; i++)
- {
- g_string_append_printf (tester->blockcssprivate, ";sites['%s']+=',%s'",
- g_strstrip (domains[i]), data[1]);
- }
- g_strfreev (domains);
- }
- else
- {
+ domains = g_strsplit (data[0], ",", -1);
+ for (i = 0; domains[i]; i++) {
g_string_append_printf (tester->blockcssprivate, ";sites['%s']+=',%s'",
- data[0], data[1]);
+ g_strstrip (domains[i]), data[1]);
}
+ g_strfreev (domains);
+ } else {
+ g_string_append_printf (tester->blockcssprivate, ";sites['%s']+=',%s'",
+ data[0], data[1]);
+ }
g_strfreev (data);
}
@@ -708,11 +664,10 @@ ephy_uri_tester_parse_line (EphyUriTester *tester,
return;
/* Whitelisted exception rules */
- if (g_str_has_prefix (line, "@@"))
- {
- ephy_uri_tester_parse_line (tester, line+2, TRUE);
- return;
- }
+ if (g_str_has_prefix (line, "@@")) {
+ ephy_uri_tester_parse_line (tester, line + 2, TRUE);
+ return;
+ }
/* FIXME: No support for domain= */
if (strstr (line, "domain="))
@@ -723,45 +678,40 @@ ephy_uri_tester_parse_line (EphyUriTester *tester,
return;
/* Got CSS block hider */
- if (line[0] == '#' && line[1] == '#' )
- {
- ephy_uri_tester_frame_add (tester, line);
- return;
- }
+ if (line[0] == '#' && line[1] == '#') {
+ ephy_uri_tester_frame_add (tester, line);
+ return;
+ }
/* Got CSS block hider. Workaround */
if (line[0] == '#')
return;
/* Got per domain CSS hider rule */
- if (strstr (line, "##"))
- {
- ephy_uri_tester_frame_add_private (tester, line, "##");
- return;
- }
+ if (strstr (line, "##")) {
+ ephy_uri_tester_frame_add_private (tester, line, "##");
+ return;
+ }
/* Got per domain CSS hider rule. Workaround */
- if (strchr (line, '#'))
- {
- ephy_uri_tester_frame_add_private (tester, line, "#");
- return;
- }
+ if (strchr (line, '#')) {
+ ephy_uri_tester_frame_add_private (tester, line, "#");
+ return;
+ }
/* Got URL blocker rule */
- if (line[0] == '|' && line[1] == '|' )
- {
- (void)*line++;
- (void)*line++;
- /* set a regex prefix to ensure that '||' patterns are anchored at the
- * start and that any characters (if any) preceding the domain specified
- * by the rule is separated from it by a dot '.' */
- ephy_uri_tester_add_url_pattern (tester, "^[\\w\\-]+:\\/+(?!\\/)(?:[^\\/]+\\.)?", "fulluri", line,
whitelist);
- return;
- }
- if (line[0] == '|')
- {
- (void)*line++;
- ephy_uri_tester_add_url_pattern (tester, "^", "fulluri", line, whitelist);
- return;
- }
+ if (line[0] == '|' && line[1] == '|') {
+ (void)*line++;
+ (void)*line++;
+ /* set a regex prefix to ensure that '||' patterns are anchored at the
+ * start and that any characters (if any) preceding the domain specified
+ * by the rule is separated from it by a dot '.' */
+ ephy_uri_tester_add_url_pattern (tester, "^[\\w\\-]+:\\/+(?!\\/)(?:[^\\/]+\\.)?", "fulluri", line,
whitelist);
+ return;
+ }
+ if (line[0] == '|') {
+ (void)*line++;
+ ephy_uri_tester_add_url_pattern (tester, "^", "fulluri", line, whitelist);
+ return;
+ }
ephy_uri_tester_add_url_pattern (tester, "", "uri", line, whitelist);
}
@@ -890,17 +840,16 @@ ephy_uri_tester_constructed (GObject *object)
}
static void
-ephy_uri_tester_set_property (GObject *object,
- guint prop_id,
+ephy_uri_tester_set_property (GObject *object,
+ guint prop_id,
const GValue *value,
- GParamSpec *pspec)
+ GParamSpec *pspec)
{
EphyUriTester *tester = EPHY_URI_TESTER (object);
- switch (prop_id)
- {
+ switch (prop_id) {
case PROP_FILTERS:
- ephy_uri_tester_set_filters (tester, (GSList*) g_value_get_pointer (value));
+ ephy_uri_tester_set_filters (tester, (GSList *)g_value_get_pointer (value));
break;
case PROP_BASE_DATA_DIR:
tester->data_dir = ephy_uri_tester_ensure_data_dir (g_value_get_string (value));
@@ -908,7 +857,7 @@ ephy_uri_tester_set_property (GObject *object,
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
- }
+ }
}
static void
@@ -955,7 +904,7 @@ ephy_uri_tester_class_init (EphyUriTesterClass *klass)
g_param_spec_pointer ("filters",
"filters",
"filters",
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS );
+ G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
obj_properties[PROP_BASE_DATA_DIR] =
g_param_spec_string ("base-data-dir",
@@ -977,8 +926,8 @@ ephy_uri_tester_new (const char *base_data_dir)
gboolean
ephy_uri_tester_test_uri (EphyUriTester *tester,
- const char *req_uri,
- const char *page_uri)
+ const char *req_uri,
+ const char *page_uri)
{
/* check whitelisting rules before the normal ones */
if (ephy_uri_tester_is_matched (tester, NULL, req_uri, page_uri, TRUE))
diff --git a/embed/web-extension/ephy-web-dom-utils.c b/embed/web-extension/ephy-web-dom-utils.c
index 6ffb86b..cf32786 100644
--- a/embed/web-extension/ephy-web-dom-utils.c
+++ b/embed/web-extension/ephy-web-dom-utils.c
@@ -159,8 +159,8 @@ resolve_uri (const char *base_uri,
static gboolean
get_icon_from_mstile (WebKitDOMDocument *document,
- char **uri_out,
- char **color_out)
+ char **uri_out,
+ char **color_out)
{
gboolean ret;
WebKitDOMNodeList *metas;
@@ -203,8 +203,8 @@ get_icon_from_mstile (WebKitDOMDocument *document,
static gboolean
get_icon_from_ogp (WebKitDOMDocument *document,
- char **uri_out,
- char **color_out)
+ char **uri_out,
+ char **color_out)
{
gboolean ret;
WebKitDOMNodeList *metas;
@@ -242,8 +242,8 @@ get_icon_from_ogp (WebKitDOMDocument *document,
static gboolean
get_icon_from_touch_icon (WebKitDOMDocument *document,
- char **uri_out,
- char **color_out)
+ char **uri_out,
+ char **color_out)
{
gboolean ret;
WebKitDOMNodeList *links;
@@ -279,8 +279,8 @@ get_icon_from_touch_icon (WebKitDOMDocument *document,
static gboolean
get_icon_from_favicon (WebKitDOMDocument *document,
- char **uri_out,
- char **color_out)
+ char **uri_out,
+ char **color_out)
{
gboolean ret;
WebKitDOMNodeList *links;
@@ -344,11 +344,11 @@ ephy_web_dom_utils_get_best_icon (WebKitDOMDocument *document,
*
http://stackoverflow.com/questions/21991044/how-to-get-high-resolution-website-logo-favicon-for-a-given-url
*/
ret = get_icon_from_mstile (document, &image, &color);
- if (! ret)
+ if (!ret)
ret = get_icon_from_ogp (document, &image, &color);
- if (! ret)
+ if (!ret)
ret = get_icon_from_touch_icon (document, &image, &color);
- if (! ret)
+ if (!ret)
ret = get_icon_from_favicon (document, &image, &color);
if (uri_out != NULL)
@@ -364,8 +364,8 @@ ephy_web_dom_utils_get_best_icon (WebKitDOMDocument *document,
gboolean
ephy_web_dom_utils_find_form_auth_elements (WebKitDOMHTMLFormElement *form,
- WebKitDOMNode **username,
- WebKitDOMNode **password)
+ WebKitDOMNode **username,
+ WebKitDOMNode **password)
{
WebKitDOMHTMLCollection *elements;
WebKitDOMNode *username_node = NULL;
@@ -421,7 +421,7 @@ ephy_web_dom_utils_find_form_auth_elements (WebKitDOMHTMLFormElement *form,
g_free (element_name);
}
- g_object_unref(elements);
+ g_object_unref (elements);
if (found_auth_no_username_elements && password_node) {
g_clear_object (&username_node);
@@ -457,8 +457,8 @@ ephy_web_dom_utils_find_form_auth_elements (WebKitDOMHTMLFormElement *form,
**/
void
ephy_web_dom_utils_get_absolute_position_for_element (WebKitDOMElement *element,
- double *x,
- double *y)
+ double *x,
+ double *y)
{
WebKitDOMElement *parent;
double offset_top, offset_left;
@@ -492,8 +492,8 @@ ephy_web_dom_utils_get_absolute_position_for_element (WebKitDOMElement *element,
**/
void
ephy_web_dom_utils_get_absolute_bottom_for_element (WebKitDOMElement *element,
- double *x,
- double *y)
+ double *x,
+ double *y)
{
double offset_height;
@@ -513,7 +513,7 @@ ephy_web_dom_utils_get_absolute_bottom_for_element (WebKitDOMElement *element,
* Returns: a newly allocated string with the selection or %NULL.
**/
char *
-ephy_web_dom_utils_get_selection_as_string (WebKitDOMDOMSelection *selection)
+ephy_web_dom_utils_get_selection_as_string (WebKitDOMDOMSelection *selection)
{
char *string;
WebKitDOMRange *range = webkit_dom_dom_selection_get_range_at (selection, 0, NULL);
diff --git a/embed/web-extension/ephy-web-extension-main.c b/embed/web-extension/ephy-web-extension-main.c
index 9c416a0..0dd2409 100644
--- a/embed/web-extension/ephy-web-extension-main.c
+++ b/embed/web-extension/ephy-web-extension-main.c
@@ -30,7 +30,7 @@ static EphyWebExtension *extension = NULL;
G_MODULE_EXPORT void
webkit_web_extension_initialize_with_user_data (WebKitWebExtension *webkit_extension,
- GVariant *user_data)
+ GVariant *user_data)
{
const char *server_address;
const char *dot_dir;
diff --git a/embed/web-extension/ephy-web-extension.c b/embed/web-extension/ephy-web-extension.c
index d72245a..a0ec04d 100644
--- a/embed/web-extension/ephy-web-extension.c
+++ b/embed/web-extension/ephy-web-extension.c
@@ -42,8 +42,7 @@
#include <webkitdom/WebKitDOMDOMWindowUnstable.h>
#include <JavaScriptCore/JavaScript.h>
-struct _EphyWebExtension
-{
+struct _EphyWebExtension {
GObject parent_instance;
WebKitWebExtension *extension;
@@ -108,10 +107,10 @@ static const char introspection_xml[] =
G_DEFINE_TYPE (EphyWebExtension, ephy_web_extension, G_TYPE_OBJECT)
static gboolean
-web_page_send_request (WebKitWebPage *web_page,
- WebKitURIRequest *request,
+web_page_send_request (WebKitWebPage *web_page,
+ WebKitURIRequest *request,
WebKitURIResponse *redirected_response,
- EphyWebExtension *extension)
+ EphyWebExtension *extension)
{
const char *request_uri;
const char *page_uri;
@@ -140,7 +139,7 @@ web_page_send_request (WebKitWebPage *web_page,
}
if (!g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_ENABLE_ADBLOCK))
- return FALSE;
+ return FALSE;
page_uri = webkit_web_page_get_uri (web_page);
@@ -150,7 +149,7 @@ web_page_send_request (WebKitWebPage *web_page,
/* Always load data requests, as uri_tester won't do any good here. */
if (g_str_has_prefix (request_uri, SOUP_URI_SCHEME_DATA))
- return FALSE;
+ return FALSE;
ret = ephy_uri_tester_test_uri (extension->uri_tester, request_uri, page_uri);
if (ret)
@@ -275,7 +274,7 @@ request_decision_on_storing (EphyEmbedFormAuth *form_auth)
static void
should_store_cb (const char *username,
const char *password,
- gpointer user_data)
+ gpointer user_data)
{
EphyEmbedFormAuth *form_auth = EPHY_EMBED_FORM_AUTH (user_data);
@@ -310,8 +309,8 @@ should_store_cb (const char *username,
static gboolean
form_submitted_cb (WebKitDOMHTMLFormElement *dom_form,
- WebKitDOMEvent *dom_event,
- WebKitWebPage *web_page)
+ WebKitDOMEvent *dom_event,
+ WebKitWebPage *web_page)
{
EphyEmbedFormAuth *form_auth;
SoupURI *uri;
@@ -360,7 +359,7 @@ form_submitted_cb (WebKitDOMHTMLFormElement *dom_form,
static void
fill_form_cb (const char *username,
const char *password,
- gpointer user_data)
+ gpointer user_data)
{
EphyEmbedFormAuth *form_auth = EPHY_EMBED_FORM_AUTH (user_data);
WebKitDOMNode *username_node;
@@ -380,7 +379,7 @@ fill_form_cb (const char *username,
}
static gint
-ephy_form_auth_data_compare (EphyFormAuthData *form_data,
+ephy_form_auth_data_compare (EphyFormAuthData *form_data,
EphyEmbedFormAuth *form_auth)
{
WebKitDOMNode *username_node;
@@ -395,7 +394,7 @@ ephy_form_auth_data_compare (EphyFormAuthData *form_data,
"name", &password_field_name, NULL);
retval = g_strcmp0 (username_field_name, form_data->form_username) == 0 &&
- g_strcmp0 (password_field_name, form_data->form_password) == 0;
+ g_strcmp0 (password_field_name, form_data->form_password) == 0;
g_free (username_field_name);
g_free (password_field_name);
@@ -444,7 +443,7 @@ pre_fill_form (EphyEmbedFormAuth *form_auth)
username,
fill_form_cb,
g_object_ref (form_auth),
- (GDestroyNotify) g_object_unref);
+ (GDestroyNotify)g_object_unref);
g_free (username);
g_free (uri_str);
@@ -467,8 +466,8 @@ remove_user_choices (WebKitDOMDocument *document)
}
static gboolean
-username_changed_cb (WebKitDOMNode *username_node,
- WebKitDOMEvent *dom_event,
+username_changed_cb (WebKitDOMNode *username_node,
+ WebKitDOMEvent *dom_event,
EphyEmbedFormAuth *form_auth)
{
pre_fill_form (form_auth);
@@ -481,7 +480,7 @@ user_chosen_cb (WebKitDOMNode *li,
WebKitDOMNode *username_node)
{
WebKitDOMElement *anchor;
- const char* username;
+ const char *username;
anchor = webkit_dom_element_get_first_element_child (WEBKIT_DOM_ELEMENT (li));
@@ -494,7 +493,7 @@ user_chosen_cb (WebKitDOMNode *li,
}
GtkStyleContext *global_entry_context = NULL;
-static GtkStyleContext*
+static GtkStyleContext *
get_entry_style_context (void)
{
GtkWidgetPath *path;
@@ -513,7 +512,7 @@ get_entry_style_context (void)
return global_entry_context;
}
-static char*
+static char *
get_selected_bgcolor (void)
{
GdkRGBA color;
@@ -525,7 +524,7 @@ get_selected_bgcolor (void)
return gdk_rgba_to_string (&color);
}
-static char*
+static char *
get_selected_fgcolor (void)
{
GdkRGBA color;
@@ -537,7 +536,7 @@ get_selected_fgcolor (void)
return gdk_rgba_to_string (&color);
}
-static char*
+static char *
get_bgcolor (void)
{
GdkRGBA color;
@@ -549,7 +548,7 @@ get_bgcolor (void)
return gdk_rgba_to_string (&color);
}
-static char*
+static char *
get_fgcolor (void)
{
GdkRGBA color;
@@ -561,7 +560,7 @@ get_fgcolor (void)
return gdk_rgba_to_string (&color);
}
-static char*
+static char *
get_user_choice_style (gboolean selected)
{
char *style_attribute;
@@ -581,7 +580,7 @@ get_user_choice_style (gboolean selected)
return style_attribute;
}
-static char*
+static char *
get_user_choice_anchor_style (gboolean selected)
{
char *style_attribute;
@@ -613,7 +612,7 @@ show_user_choices (WebKitDOMDocument *document,
double x, y;
double input_width;
char *style_attribute;
- char* username;
+ char *username;
g_object_get (username_node,
"value", &username,
@@ -654,8 +653,8 @@ show_user_choices (WebKitDOMDocument *document,
"padding: 0;",
NULL);
- auth_data_list = (GSList*)g_object_get_data (G_OBJECT (username_node),
- "ephy-auth-data-list");
+ auth_data_list = (GSList *)g_object_get_data (G_OBJECT (username_node),
+ "ephy-auth-data-list");
username_node_ever_edited =
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (username_node),
@@ -668,13 +667,13 @@ show_user_choices (WebKitDOMDocument *document,
char *child_style;
gboolean is_selected;
- data = (EphyFormAuthData*)iter->data;
+ data = (EphyFormAuthData *)iter->data;
/* Filter out the available names that do not match, but show all options in
* case we have been triggered by something other than the user editing the
* input.
*/
- if (username_node_ever_edited && !g_str_has_prefix(data->username, username))
+ if (username_node_ever_edited && !g_str_has_prefix (data->username, username))
continue;
is_selected = !g_strcmp0 (username, data->username);
@@ -713,7 +712,7 @@ show_user_choices (WebKitDOMDocument *document,
NULL);
}
- g_free (username);
+ g_free (username);
body = WEBKIT_DOM_NODE (webkit_dom_document_get_body (document));
webkit_dom_node_append_child (WEBKIT_DOM_NODE (body),
WEBKIT_DOM_NODE (main_div),
@@ -755,8 +754,8 @@ clear_password_field (WebKitDOMNode *username_node)
EphyEmbedFormAuth *form_auth;
WebKitDOMNode *password_node;
- form_auth = (EphyEmbedFormAuth*)g_object_get_data (G_OBJECT (username_node),
- "ephy-form-auth");
+ form_auth = (EphyEmbedFormAuth *)g_object_get_data (G_OBJECT (username_node),
+ "ephy-form-auth");
password_node = ephy_embed_form_auth_get_password_node (form_auth);
webkit_dom_html_input_element_set_value (WEBKIT_DOM_HTML_INPUT_ELEMENT (password_node), "");
@@ -767,8 +766,8 @@ pre_fill_password (WebKitDOMNode *username_node)
{
EphyEmbedFormAuth *form_auth;
- form_auth = (EphyEmbedFormAuth*)g_object_get_data (G_OBJECT (username_node),
- "ephy-form-auth");
+ form_auth = (EphyEmbedFormAuth *)g_object_get_data (G_OBJECT (username_node),
+ "ephy-form-auth");
pre_fill_form (form_auth);
}
@@ -781,7 +780,7 @@ username_node_keydown_cb (WebKitDOMNode *username_node,
WebKitDOMDocument *document;
WebKitDOMElement *main_div;
WebKitDOMElement *container;
- WebKitDOMElement *selected= NULL;
+ WebKitDOMElement *selected = NULL;
WebKitDOMElement *to_select = NULL;
WebKitDOMElement *anchor;
WebKitDOMKeyboardEvent *keyboard_event;
@@ -883,7 +882,7 @@ username_node_input_cb (WebKitDOMNode *username_node,
WebKitDOMDocument *document;
WebKitDOMElement *main_div;
- g_object_set_data (G_OBJECT (username_node), "ephy-user-ever-edited", GINT_TO_POINTER(TRUE));
+ g_object_set_data (G_OBJECT (username_node), "ephy-user-ever-edited", GINT_TO_POINTER (TRUE));
document = webkit_web_page_get_dom_document (web_page);
remove_user_choices (document);
show_user_choices (document, username_node);
@@ -905,7 +904,7 @@ form_destroyed_cb (gpointer form_auth, GObject *form)
}
static void
-web_page_document_loaded (WebKitWebPage *web_page,
+web_page_document_loaded (WebKitWebPage *web_page,
EphyWebExtension *extension)
{
WebKitDOMHTMLCollection *forms = NULL;
@@ -923,7 +922,7 @@ web_page_document_loaded (WebKitWebPage *web_page,
if (forms_n == 0) {
LOG ("No forms found.");
- g_object_unref(forms);
+ g_object_unref (forms);
return;
}
@@ -992,12 +991,12 @@ web_page_document_loaded (WebKitWebPage *web_page,
LOG ("No pre-fillable/hookable form found");
}
- g_object_unref(forms);
+ g_object_unref (forms);
}
static void
-web_page_uri_changed (WebKitWebPage *web_page,
- GParamSpec *param_spec,
+web_page_uri_changed (WebKitWebPage *web_page,
+ GParamSpec *param_spec,
EphyWebExtension *extension)
{
EphyWebOverview *overview = NULL;
@@ -1009,10 +1008,10 @@ web_page_uri_changed (WebKitWebPage *web_page,
}
static gboolean
-web_page_context_menu (WebKitWebPage *web_page,
- WebKitContextMenu *context_menu,
+web_page_context_menu (WebKitWebPage *web_page,
+ WebKitContextMenu *context_menu,
WebKitWebHitTestResult *hit_test_result,
- gpointer user_data)
+ gpointer user_data)
{
char *string;
GVariantBuilder builder;
@@ -1028,8 +1027,7 @@ web_page_context_menu (WebKitWebPage *web_page,
string = ephy_web_dom_utils_get_selection_as_string (selection);
g_object_unref (selection);
- if (!string || *string == '\0')
- {
+ if (!string || *string == '\0') {
g_free (string);
return FALSE;
}
@@ -1046,7 +1044,7 @@ web_page_context_menu (WebKitWebPage *web_page,
static void
ephy_web_extension_emit_page_created (EphyWebExtension *extension,
- guint64 page_id)
+ guint64 page_id)
{
GError *error = NULL;
@@ -1084,7 +1082,7 @@ ephy_web_extension_emit_page_created_signals_pending (EphyWebExtension *extensio
static void
ephy_web_extension_queue_page_created_signal_emission (EphyWebExtension *extension,
- guint64 page_id)
+ guint64 page_id)
{
if (!extension->page_created_signals_pending)
extension->page_created_signals_pending = g_array_new (FALSE, FALSE, sizeof (guint64));
@@ -1093,7 +1091,7 @@ ephy_web_extension_queue_page_created_signal_emission (EphyWebExtension *extensi
static void
ephy_web_extension_page_created_cb (EphyWebExtension *extension,
- WebKitWebPage *web_page)
+ WebKitWebPage *web_page)
{
guint64 page_id;
@@ -1119,8 +1117,8 @@ ephy_web_extension_page_created_cb (EphyWebExtension *extension,
static WebKitWebPage *
get_webkit_web_page_or_return_dbus_error (GDBusMethodInvocation *invocation,
- WebKitWebExtension *web_extension,
- guint64 page_id)
+ WebKitWebExtension *web_extension,
+ guint64 page_id)
{
WebKitWebPage *web_page = webkit_web_extension_get_page (web_extension, page_id);
if (!web_page) {
@@ -1131,14 +1129,14 @@ get_webkit_web_page_or_return_dbus_error (GDBusMethodInvocation *invocation,
}
static void
-handle_method_call (GDBusConnection *connection,
- const char *sender,
- const char *object_path,
- const char *interface_name,
- const char *method_name,
- GVariant *parameters,
+handle_method_call (GDBusConnection *connection,
+ const char *sender,
+ const char *object_path,
+ const char *interface_name,
+ const char *method_name,
+ GVariant *parameters,
GDBusMethodInvocation *invocation,
- gpointer user_data)
+ gpointer user_data)
{
EphyWebExtension *extension = EPHY_WEB_EXTENSION (user_data);
@@ -1195,7 +1193,7 @@ handle_method_call (GDBusConnection *connection,
return;
}
- document= webkit_web_page_get_dom_document (web_page);
+ document = webkit_web_page_get_dom_document (web_page);
result = ephy_web_dom_utils_get_best_icon (document, base_uri, &uri, &color);
g_dbus_method_invocation_return_value (invocation,
@@ -1298,9 +1296,9 @@ ephy_web_extension_dispose (GObject *object)
}
if (extension->page_created_signals_pending) {
- g_array_free (extension->page_created_signals_pending, TRUE);
- extension->page_created_signals_pending = NULL;
- }
+ g_array_free (extension->page_created_signals_pending, TRUE);
+ extension->page_created_signals_pending = NULL;
+ }
g_clear_object (&extension->cancellable);
g_clear_object (&extension->dbus_connection);
@@ -1325,7 +1323,7 @@ ephy_web_extension_init (EphyWebExtension *extension)
}
static gpointer
-ephy_web_extension_create_instance(gpointer data)
+ephy_web_extension_create_instance (gpointer data)
{
return g_object_new (EPHY_TYPE_WEB_EXTENSION, NULL);
}
@@ -1338,8 +1336,8 @@ ephy_web_extension_get (void)
}
static void
-dbus_connection_created_cb (GObject *source_object,
- GAsyncResult *result,
+dbus_connection_created_cb (GObject *source_object,
+ GAsyncResult *result,
EphyWebExtension *extension)
{
static GDBusNodeInfo *introspection_data = NULL;
@@ -1378,19 +1376,19 @@ dbus_connection_created_cb (GObject *source_object,
static gboolean
authorize_authenticated_peer_cb (GDBusAuthObserver *observer,
- GIOStream *stream,
- GCredentials *credentials,
- EphyWebExtension *extension)
+ GIOStream *stream,
+ GCredentials *credentials,
+ EphyWebExtension *extension)
{
return ephy_dbus_peer_is_authorized (credentials);
}
void
-ephy_web_extension_initialize (EphyWebExtension *extension,
+ephy_web_extension_initialize (EphyWebExtension *extension,
WebKitWebExtension *wk_extension,
- const char *server_address,
- const char *dot_dir,
- gboolean is_private_profile)
+ const char *server_address,
+ const char *dot_dir,
+ gboolean is_private_profile)
{
GDBusAuthObserver *observer;
diff --git a/embed/web-extension/ephy-web-overview-model.c b/embed/web-extension/ephy-web-overview-model.c
index 7a8687f..bc6f975 100644
--- a/embed/web-extension/ephy-web-overview-model.c
+++ b/embed/web-extension/ephy-web-overview-model.c
@@ -21,8 +21,7 @@
#include <libsoup/soup.h>
-struct _EphyWebOverviewModel
-{
+struct _EphyWebOverviewModel {
GObject parent_instance;
GList *items;
@@ -31,8 +30,7 @@ struct _EphyWebOverviewModel
G_DEFINE_TYPE (EphyWebOverviewModel, ephy_web_overview_model, G_TYPE_OBJECT)
-enum
-{
+enum {
URLS_CHANGED,
THUMBNAIL_CHANGED,
TITLE_CHANGED,
@@ -110,7 +108,7 @@ ephy_web_overview_model_new (void)
void
ephy_web_overview_model_set_urls (EphyWebOverviewModel *model,
- GList *urls)
+ GList *urls)
{
g_return_if_fail (EPHY_IS_WEB_OVERVIEW_MODEL (model));
@@ -129,8 +127,8 @@ ephy_web_overview_model_get_urls (EphyWebOverviewModel *model)
void
ephy_web_overview_model_set_url_thumbnail (EphyWebOverviewModel *model,
- const char *url,
- const char *path)
+ const char *url,
+ const char *path)
{
const char *thumbnail_path;
@@ -146,7 +144,7 @@ ephy_web_overview_model_set_url_thumbnail (EphyWebOverviewModel *model,
const char *
ephy_web_overview_model_get_url_thumbnail (EphyWebOverviewModel *model,
- const char *url)
+ const char *url)
{
g_return_val_if_fail (EPHY_IS_WEB_OVERVIEW_MODEL (model), NULL);
@@ -155,8 +153,8 @@ ephy_web_overview_model_get_url_thumbnail (EphyWebOverviewModel *model,
void
ephy_web_overview_model_set_url_title (EphyWebOverviewModel *model,
- const char *url,
- const char *title)
+ const char *url,
+ const char *title)
{
GList *l;
gboolean changed = FALSE;
@@ -183,7 +181,7 @@ ephy_web_overview_model_set_url_title (EphyWebOverviewModel *model,
void
ephy_web_overview_model_delete_url (EphyWebOverviewModel *model,
- const char *url)
+ const char *url)
{
GList *l;
gboolean changed = FALSE;
@@ -211,7 +209,7 @@ ephy_web_overview_model_delete_url (EphyWebOverviewModel *model,
void
ephy_web_overview_model_delete_host (EphyWebOverviewModel *model,
- const char *host)
+ const char *host)
{
GList *l;
gboolean changed = FALSE;
diff --git a/embed/web-extension/ephy-web-overview.c b/embed/web-extension/ephy-web-overview.c
index 14ad5f6..e252bfe 100644
--- a/embed/web-extension/ephy-web-overview.c
+++ b/embed/web-extension/ephy-web-overview.c
@@ -25,8 +25,7 @@
#include <webkitdom/WebKitDOMElementUnstable.h>
#include <webkitdom/WebKitDOMDOMTokenList.h>
-struct _EphyWebOverview
-{
+struct _EphyWebOverview {
GObject parent_instance;
WebKitWebPage *web_page;
@@ -38,8 +37,7 @@ struct _EphyWebOverview
G_DEFINE_TYPE (EphyWebOverview, ephy_web_overview, G_TYPE_OBJECT)
-enum
-{
+enum {
PROP_0,
PROP_WEB_PAGE,
PROP_MODEL,
@@ -70,7 +68,7 @@ overview_item_new (WebKitDOMElement *anchor)
nodes = webkit_dom_node_get_child_nodes (WEBKIT_DOM_NODE (anchor));
n_nodes = webkit_dom_node_list_get_length (nodes);
for (i = 0; i < n_nodes; i++) {
- WebKitDOMNode* node = webkit_dom_node_list_item (nodes, i);
+ WebKitDOMNode *node = webkit_dom_node_list_item (nodes, i);
WebKitDOMElement *element;
char *tag;
@@ -111,7 +109,7 @@ overview_item_free (OverviewItem *item)
static void
update_thumbnail_element_style (WebKitDOMElement *thumbnail,
- const char *path)
+ const char *path)
{
char *style;
@@ -122,12 +120,12 @@ update_thumbnail_element_style (WebKitDOMElement *thumbnail,
static void
ephy_web_overview_model_urls_changed (EphyWebOverviewModel *model,
- EphyWebOverview *overview)
+ EphyWebOverview *overview)
{
GList *urls;
GList *l;
GList *items;
- OverviewItem* item;
+ OverviewItem *item;
urls = ephy_web_overview_model_get_urls (model);
@@ -250,9 +248,9 @@ apply_delayed_thumbnail_change (gpointer key,
static void
ephy_web_overview_model_thumbnail_changed (EphyWebOverviewModel *model,
- const char *url,
- const char *path,
- EphyWebOverview *overview)
+ const char *url,
+ const char *path,
+ EphyWebOverview *overview)
{
GList *l;
for (l = overview->items; l; l = g_list_next (l)) {
@@ -283,9 +281,9 @@ ephy_web_overview_model_thumbnail_changed (EphyWebOverviewModel *model,
static void
ephy_web_overview_model_title_changed (EphyWebOverviewModel *model,
- const char *url,
- const char *title,
- EphyWebOverview *overview)
+ const char *url,
+ const char *title,
+ EphyWebOverview *overview)
{
GList *l;
@@ -301,8 +299,8 @@ ephy_web_overview_model_title_changed (EphyWebOverviewModel *model,
}
static void
-ephy_web_overview_update_thumbnail_in_model_from_element (EphyWebOverview *overview,
- const char *url,
+ephy_web_overview_update_thumbnail_in_model_from_element (EphyWebOverview *overview,
+ const char *url,
WebKitDOMElement *thumbnail)
{
WebKitDOMCSSStyleDeclaration *style;
@@ -342,7 +340,7 @@ ephy_web_overview_update_thumbnail_in_model_from_element (EphyWebOverview *overv
}
static void
-ephy_web_overview_document_loaded (WebKitWebPage *web_page,
+ephy_web_overview_document_loaded (WebKitWebPage *web_page,
EphyWebOverview *overview)
{
WebKitDOMDocument *document;
@@ -353,7 +351,7 @@ ephy_web_overview_document_loaded (WebKitWebPage *web_page,
nodes = webkit_dom_document_get_elements_by_tag_name (document, "a");
n_nodes = webkit_dom_node_list_get_length (nodes);
for (i = 0; i < n_nodes; i++) {
- WebKitDOMElement* element = WEBKIT_DOM_ELEMENT (webkit_dom_node_list_item (nodes, i));
+ WebKitDOMElement *element = WEBKIT_DOM_ELEMENT (webkit_dom_node_list_item (nodes, i));
char *class;
class = webkit_dom_element_get_class_name (element);
@@ -381,24 +379,23 @@ ephy_web_overview_document_loaded (WebKitWebPage *web_page,
}
static void
-ephy_web_overview_set_property (GObject *object,
- guint prop_id,
+ephy_web_overview_set_property (GObject *object,
+ guint prop_id,
const GValue *value,
- GParamSpec *pspec)
+ GParamSpec *pspec)
{
EphyWebOverview *overview = EPHY_WEB_OVERVIEW (object);
- switch (prop_id)
- {
- case PROP_WEB_PAGE:
- overview->web_page = g_value_get_object (value);
- break;
- case PROP_MODEL:
- overview->model = g_value_get_object (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ switch (prop_id) {
+ case PROP_WEB_PAGE:
+ overview->web_page = g_value_get_object (value);
+ break;
+ case PROP_MODEL:
+ overview->model = g_value_get_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
@@ -471,7 +468,7 @@ ephy_web_overview_init (EphyWebOverview *overview)
}
EphyWebOverview *
-ephy_web_overview_new (WebKitWebPage *web_page,
+ephy_web_overview_new (WebKitWebPage *web_page,
EphyWebOverviewModel *model)
{
g_return_val_if_fail (WEBKIT_IS_WEB_PAGE (web_page), NULL);
diff --git a/lib/egg/eggtreemultidnd.c b/lib/egg/eggtreemultidnd.c
index f140c25..cb58485 100644
--- a/lib/egg/eggtreemultidnd.c
+++ b/lib/egg/eggtreemultidnd.c
@@ -24,8 +24,7 @@
#define EGG_TREE_MULTI_DND_STRING "EggTreeMultiDndString"
-typedef struct
-{
+typedef struct {
guint pressed_button;
gint x;
gint y;
@@ -37,8 +36,7 @@ typedef struct
/* CUT-N-PASTE from gtktreeview.c */
typedef struct _TreeViewDragInfo TreeViewDragInfo;
-struct _TreeViewDragInfo
-{
+struct _TreeViewDragInfo {
GdkModifierType start_button_mask;
GtkTargetList *source_target_list;
GdkDragAction source_actions;
@@ -55,24 +53,23 @@ egg_tree_multi_drag_source_get_type (void)
{
static GType our_type = 0;
- if (!our_type)
+ if (!our_type) {
+ static const GTypeInfo our_info =
{
- static const GTypeInfo our_info =
- {
- sizeof (EggTreeMultiDragSourceIface), /* class_size */
- NULL, /* base_init */
- NULL, /* base_finalize */
- NULL,
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0,
- 0, /* n_preallocs */
- NULL
- };
-
- our_type = g_type_register_static (G_TYPE_INTERFACE, "EggTreeMultiDragSource", &our_info, 0);
- }
-
+ sizeof (EggTreeMultiDragSourceIface), /* class_size */
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ NULL,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ 0,
+ 0, /* n_preallocs */
+ NULL
+ };
+
+ our_type = g_type_register_static (G_TYPE_INTERFACE, "EggTreeMultiDragSource", &our_info, 0);
+ }
+
return our_type;
}
@@ -81,7 +78,7 @@ egg_tree_multi_drag_source_get_type (void)
* egg_tree_multi_drag_source_row_draggable:
* @drag_source: a #EggTreeMultiDragSource
* @path: row on which user is initiating a drag
- *
+ *
* Asks the #EggTreeMultiDragSource whether a particular row can be used as
* the source of a DND operation. If the source doesn't implement
* this interface, the row is assumed draggable.
@@ -90,7 +87,7 @@ egg_tree_multi_drag_source_get_type (void)
**/
gboolean
egg_tree_multi_drag_source_row_draggable (EggTreeMultiDragSource *drag_source,
- GList *path_list)
+ GList *path_list)
{
EggTreeMultiDragSourceIface *iface = EGG_TREE_MULTI_DRAG_SOURCE_GET_IFACE (drag_source);
@@ -99,7 +96,7 @@ egg_tree_multi_drag_source_row_draggable (EggTreeMultiDragSource *drag_source,
g_return_val_if_fail (path_list != NULL, FALSE);
if (iface->row_draggable)
- return (* iface->row_draggable) (drag_source, path_list);
+ return (*iface->row_draggable)(drag_source, path_list);
else
return TRUE;
}
@@ -109,18 +106,18 @@ egg_tree_multi_drag_source_row_draggable (EggTreeMultiDragSource *drag_source,
* egg_tree_multi_drag_source_drag_data_delete:
* @drag_source: a #EggTreeMultiDragSource
* @path: row that was being dragged
- *
+ *
* Asks the #EggTreeMultiDragSource to delete the row at @path, because
* it was moved somewhere else via drag-and-drop. Returns %FALSE
* if the deletion fails because @path no longer exists, or for
* some model-specific reason. Should robustly handle a @path no
* longer found in the model!
- *
+ *
* Return value: %TRUE if the row was successfully deleted
**/
gboolean
egg_tree_multi_drag_source_drag_data_delete (EggTreeMultiDragSource *drag_source,
- GList *path_list)
+ GList *path_list)
{
EggTreeMultiDragSourceIface *iface = EGG_TREE_MULTI_DRAG_SOURCE_GET_IFACE (drag_source);
@@ -128,7 +125,7 @@ egg_tree_multi_drag_source_drag_data_delete (EggTreeMultiDragSource *drag_source
g_return_val_if_fail (iface->drag_data_delete != NULL, FALSE);
g_return_val_if_fail (path_list != NULL, FALSE);
- return (* iface->drag_data_delete) (drag_source, path_list);
+ return (*iface->drag_data_delete)(drag_source, path_list);
}
/**
@@ -136,18 +133,18 @@ egg_tree_multi_drag_source_drag_data_delete (EggTreeMultiDragSource *drag_source
* @drag_source: a #EggTreeMultiDragSource
* @path: row that was dragged
* @selection_data: a #EggSelectionData to fill with data from the dragged row
- *
+ *
* Asks the #EggTreeMultiDragSource to fill in @selection_data with a
* representation of the row at @path. @selection_data->target gives
* the required type of the data. Should robustly handle a @path no
* longer found in the model!
- *
- * Return value: %TRUE if data of the required type was provided
+ *
+ * Return value: %TRUE if data of the required type was provided
**/
gboolean
-egg_tree_multi_drag_source_drag_data_get (EggTreeMultiDragSource *drag_source,
- GList *path_list,
- GtkSelectionData *selection_data)
+egg_tree_multi_drag_source_drag_data_get (EggTreeMultiDragSource *drag_source,
+ GList *path_list,
+ GtkSelectionData *selection_data)
{
EggTreeMultiDragSourceIface *iface = EGG_TREE_MULTI_DRAG_SOURCE_GET_IFACE (drag_source);
@@ -156,7 +153,7 @@ egg_tree_multi_drag_source_drag_data_get (EggTreeMultiDragSource *drag_source
g_return_val_if_fail (path_list != NULL, FALSE);
g_return_val_if_fail (selection_data != NULL, FALSE);
- return (* iface->drag_data_get) (drag_source, path_list, selection_data);
+ return (*iface->drag_data_get)(drag_source, path_list, selection_data);
}
static void
@@ -166,10 +163,10 @@ stop_drag_check (GtkWidget *widget)
GSList *l;
priv_data = g_object_get_data (G_OBJECT (widget), EGG_TREE_MULTI_DND_STRING);
-
+
for (l = priv_data->event_list; l != NULL; l = l->next)
gdk_event_free (l->data);
-
+
g_slist_free (priv_data->event_list);
priv_data->event_list = NULL;
g_signal_handler_disconnect (widget, priv_data->motion_notify_handler);
@@ -178,17 +175,17 @@ stop_drag_check (GtkWidget *widget)
static gboolean
egg_tree_multi_drag_button_release_event (GtkWidget *widget,
- GdkEventButton *event,
- gpointer data)
+ GdkEventButton *event,
+ gpointer data)
{
EggTreeMultiDndData *priv_data;
GSList *l;
priv_data = g_object_get_data (G_OBJECT (widget), EGG_TREE_MULTI_DND_STRING);
- for (l = priv_data->event_list; l != NULL; l = l->next)
+ for (l = priv_data->event_list; l != NULL; l = l->next)
gtk_propagate_event (widget, l->data);
-
+
stop_drag_check (widget);
return FALSE;
@@ -196,13 +193,13 @@ egg_tree_multi_drag_button_release_event (GtkWidget *widget,
static void
selection_foreach (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data)
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data)
{
GList **list_ptr;
- list_ptr = (GList **) data;
+ list_ptr = (GList **)data;
*list_ptr = g_list_prepend (*list_ptr, gtk_tree_row_reference_new (model, path));
}
@@ -210,29 +207,29 @@ selection_foreach (GtkTreeModel *model,
static void
path_list_free (GList *path_list)
{
- g_list_foreach (path_list, (GFunc) gtk_tree_row_reference_free, NULL);
+ g_list_foreach (path_list, (GFunc)gtk_tree_row_reference_free, NULL);
g_list_free (path_list);
}
static void
set_context_data (GdkDragContext *context,
- GList *path_list)
+ GList *path_list)
{
g_object_set_data_full (G_OBJECT (context),
"egg-tree-view-multi-source-row",
path_list,
- (GDestroyNotify) path_list_free);
+ (GDestroyNotify)path_list_free);
}
static GList *
get_context_data (GdkDragContext *context)
{
return g_object_get_data (G_OBJECT (context),
- "egg-tree-view-multi-source-row");
+ "egg-tree-view-multi-source-row");
}
/* CUT-N-PASTE from gtktreeview.c */
-static TreeViewDragInfo*
+static TreeViewDragInfo *
get_info (GtkTreeView *tree_view)
{
return g_object_get_data (G_OBJECT (tree_view), "gtk-tree-view-drag-info");
@@ -241,10 +238,10 @@ get_info (GtkTreeView *tree_view)
static void
egg_tree_multi_drag_drag_data_get (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint info,
- guint time)
+ GdkDragContext *context,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint time)
{
GtkTreeView *tree_view;
GtkTreeModel *model;
@@ -273,71 +270,65 @@ egg_tree_multi_drag_drag_data_get (GtkWidget *widget,
* we also support.
*/
- if (EGG_IS_TREE_MULTI_DRAG_SOURCE (model))
- {
- egg_tree_multi_drag_source_drag_data_get (EGG_TREE_MULTI_DRAG_SOURCE (model),
- path_list,
- selection_data);
- }
+ if (EGG_IS_TREE_MULTI_DRAG_SOURCE (model)) {
+ egg_tree_multi_drag_source_drag_data_get (EGG_TREE_MULTI_DRAG_SOURCE (model),
+ path_list,
+ selection_data);
+ }
}
static gboolean
egg_tree_multi_drag_motion_event (GtkWidget *widget,
- GdkEventMotion *event,
- gpointer data)
+ GdkEventMotion *event,
+ gpointer data)
{
EggTreeMultiDndData *priv_data;
priv_data = g_object_get_data (G_OBJECT (widget), EGG_TREE_MULTI_DND_STRING);
if (gtk_drag_check_threshold (widget,
- priv_data->x,
- priv_data->y,
- event->x,
- event->y))
- {
- GList *path_list = NULL;
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GdkDragContext *context;
- TreeViewDragInfo *di;
-
- di = get_info (GTK_TREE_VIEW (widget));
-
- if (di == NULL)
- return FALSE;
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
- stop_drag_check (widget);
- gtk_tree_selection_selected_foreach (selection, selection_foreach, &path_list);
- path_list = g_list_reverse (path_list);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
- if (egg_tree_multi_drag_source_row_draggable (EGG_TREE_MULTI_DRAG_SOURCE (model), path_list))
- {
- context = gtk_drag_begin_with_coordinates (widget,
- gtk_drag_source_get_target_list (widget),
- di->source_actions,
- priv_data->pressed_button,
- (GdkEvent*)event,
- event->x,
- event->y);
- set_context_data (context, path_list);
- gtk_drag_set_icon_default (context);
-
- }
- else
- {
- path_list_free (path_list);
- }
+ priv_data->x,
+ priv_data->y,
+ event->x,
+ event->y)) {
+ GList *path_list = NULL;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GdkDragContext *context;
+ TreeViewDragInfo *di;
+
+ di = get_info (GTK_TREE_VIEW (widget));
+
+ if (di == NULL)
+ return FALSE;
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
+ stop_drag_check (widget);
+ gtk_tree_selection_selected_foreach (selection, selection_foreach, &path_list);
+ path_list = g_list_reverse (path_list);
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
+ if (egg_tree_multi_drag_source_row_draggable (EGG_TREE_MULTI_DRAG_SOURCE (model), path_list)) {
+ context = gtk_drag_begin_with_coordinates (widget,
+ gtk_drag_source_get_target_list (widget),
+ di->source_actions,
+ priv_data->pressed_button,
+ (GdkEvent *)event,
+ event->x,
+ event->y);
+ set_context_data (context, path_list);
+ gtk_drag_set_icon_default (context);
+ } else {
+ path_list_free (path_list);
}
+ }
return TRUE;
}
static gboolean
egg_tree_multi_drag_button_press_event (GtkWidget *widget,
- GdkEventButton *event,
- gpointer data)
+ GdkEventButton *event,
+ gpointer data)
{
GtkTreeView *tree_view;
GtkTreePath *path = NULL;
@@ -348,58 +339,53 @@ egg_tree_multi_drag_button_press_event (GtkWidget *widget,
tree_view = GTK_TREE_VIEW (widget);
priv_data = g_object_get_data (G_OBJECT (tree_view), EGG_TREE_MULTI_DND_STRING);
- if (priv_data == NULL)
- {
- priv_data = g_new0 (EggTreeMultiDndData, 1);
- g_object_set_data (G_OBJECT (tree_view), EGG_TREE_MULTI_DND_STRING, priv_data);
- }
+ if (priv_data == NULL) {
+ priv_data = g_new0 (EggTreeMultiDndData, 1);
+ g_object_set_data (G_OBJECT (tree_view), EGG_TREE_MULTI_DND_STRING, priv_data);
+ }
- if (g_slist_find (priv_data->event_list, event))
+ if (g_slist_find (priv_data->event_list, event))
return FALSE;
- if (priv_data->event_list)
- {
- /* save the event to be propagated in order */
- priv_data->event_list = g_slist_append (priv_data->event_list, gdk_event_copy ((GdkEvent*)event));
- return TRUE;
- }
-
+ if (priv_data->event_list) {
+ /* save the event to be propagated in order */
+ priv_data->event_list = g_slist_append (priv_data->event_list, gdk_event_copy ((GdkEvent *)event));
+ return TRUE;
+ }
+
if (event->type == GDK_2BUTTON_PRESS)
return FALSE;
gtk_tree_view_get_path_at_pos (tree_view,
- event->x, event->y,
- &path, &column,
- &cell_x, &cell_y);
+ event->x, event->y,
+ &path, &column,
+ &cell_x, &cell_y);
selection = gtk_tree_view_get_selection (tree_view);
- if (path && gtk_tree_selection_path_is_selected (selection, path))
- {
- priv_data->pressed_button = event->button;
- priv_data->x = event->x;
- priv_data->y = event->y;
- priv_data->event_list = g_slist_append (priv_data->event_list, gdk_event_copy ((GdkEvent*)event));
- priv_data->motion_notify_handler =
- g_signal_connect (G_OBJECT (tree_view), "motion_notify_event", G_CALLBACK
(egg_tree_multi_drag_motion_event), NULL);
- priv_data->button_release_handler =
- g_signal_connect (G_OBJECT (tree_view), "button_release_event", G_CALLBACK
(egg_tree_multi_drag_button_release_event), NULL);
-
- if (priv_data->drag_data_get_handler == 0)
- {
- priv_data->drag_data_get_handler =
- g_signal_connect (G_OBJECT (tree_view), "drag_data_get", G_CALLBACK
(egg_tree_multi_drag_drag_data_get), NULL);
- }
-
- gtk_tree_path_free (path);
-
- return TRUE;
+ if (path && gtk_tree_selection_path_is_selected (selection, path)) {
+ priv_data->pressed_button = event->button;
+ priv_data->x = event->x;
+ priv_data->y = event->y;
+ priv_data->event_list = g_slist_append (priv_data->event_list, gdk_event_copy ((GdkEvent *)event));
+ priv_data->motion_notify_handler =
+ g_signal_connect (G_OBJECT (tree_view), "motion_notify_event", G_CALLBACK
(egg_tree_multi_drag_motion_event), NULL);
+ priv_data->button_release_handler =
+ g_signal_connect (G_OBJECT (tree_view), "button_release_event", G_CALLBACK
(egg_tree_multi_drag_button_release_event), NULL);
+
+ if (priv_data->drag_data_get_handler == 0) {
+ priv_data->drag_data_get_handler =
+ g_signal_connect (G_OBJECT (tree_view), "drag_data_get", G_CALLBACK
(egg_tree_multi_drag_drag_data_get), NULL);
}
- if (path)
- {
- gtk_tree_path_free (path);
- }
+ gtk_tree_path_free (path);
+
+ return TRUE;
+ }
+
+ if (path) {
+ gtk_tree_path_free (path);
+ }
return FALSE;
}
diff --git a/lib/ephy-debug.c b/lib/ephy-debug.c
index 6a6997d..43ffc90 100644
--- a/lib/ephy-debug.c
+++ b/lib/ephy-debug.c
@@ -48,24 +48,22 @@ static gboolean ephy_profile_all_modules;
static char **
build_modules (const char *name,
- gboolean* is_all)
+ gboolean *is_all)
{
- const char *env;
+ const char *env;
- *is_all = FALSE;
+ *is_all = FALSE;
- env = g_getenv (name);
- if (env == NULL) return NULL;
+ env = g_getenv (name);
+ if (env == NULL) return NULL;
- if (strcmp (env, "all") == 0)
- {
- *is_all = TRUE;
- return NULL;
- }
+ if (strcmp (env, "all") == 0) {
+ *is_all = TRUE;
+ return NULL;
+ }
- return g_strsplit (g_getenv (name), ":", -1);
+ return g_strsplit (g_getenv (name), ":", -1);
}
-
#endif
#ifndef DISABLE_LOGGING
@@ -74,92 +72,77 @@ static char **ephy_log_modules;
static gboolean ephy_log_all_modules;
static void
-log_module (const gchar *log_domain,
- GLogLevelFlags log_level,
- const char *message,
- gpointer user_data)
+log_module (const gchar *log_domain,
+ GLogLevelFlags log_level,
+ const char *message,
+ gpointer user_data)
{
- gboolean should_log = ephy_log_all_modules;
-
- if (!ephy_log_all_modules && !ephy_log_modules) return;
-
- if (ephy_log_modules != NULL)
- {
- guint i;
-
- for (i = 0; ephy_log_modules[i] != NULL; i++)
- {
- if (strstr (message, ephy_log_modules [i]) != NULL)
- {
- should_log = TRUE;
- break;
- }
- }
- }
-
- if (should_log)
- {
- g_print ("%s\n", message);
- }
-}
+ gboolean should_log = ephy_log_all_modules;
+
+ if (!ephy_log_all_modules && !ephy_log_modules) return;
+
+ if (ephy_log_modules != NULL) {
+ guint i;
+
+ for (i = 0; ephy_log_modules[i] != NULL; i++) {
+ if (strstr (message, ephy_log_modules [i]) != NULL) {
+ should_log = TRUE;
+ break;
+ }
+ }
+ }
+ if (should_log) {
+ g_print ("%s\n", message);
+ }
+}
#endif /* !DISABLE_LOGGING */
#define MAX_DEPTH 200
-static void
-trap_handler (const char *log_domain,
- GLogLevelFlags log_level,
- const char *message,
- gpointer user_data)
+static void
+trap_handler (const char *log_domain,
+ GLogLevelFlags log_level,
+ const char *message,
+ gpointer user_data)
{
- g_log_default_handler (log_domain, log_level, message, user_data);
-
- if (ephy_debug_break != NULL &&
- (log_level & (G_LOG_LEVEL_WARNING |
- G_LOG_LEVEL_ERROR |
- G_LOG_LEVEL_CRITICAL |
- G_LOG_FLAG_FATAL)))
- {
- if (strcmp (ephy_debug_break, "suspend") == 0)
- {
- /* the suspend case is first because we wanna send the signal before
- * other threads have had a chance to get too far from the state that
- * caused this assertion (in case they happen to have been involved).
- */
- g_print ("Suspending program; attach with the debugger.\n");
-
- raise (SIGSTOP);
- }
- else if (strcmp (ephy_debug_break, "stack") == 0)
- {
+ g_log_default_handler (log_domain, log_level, message, user_data);
+
+ if (ephy_debug_break != NULL &&
+ (log_level & (G_LOG_LEVEL_WARNING |
+ G_LOG_LEVEL_ERROR |
+ G_LOG_LEVEL_CRITICAL |
+ G_LOG_FLAG_FATAL))) {
+ if (strcmp (ephy_debug_break, "suspend") == 0) {
+ /* the suspend case is first because we wanna send the signal before
+ * other threads have had a chance to get too far from the state that
+ * caused this assertion (in case they happen to have been involved).
+ */
+ g_print ("Suspending program; attach with the debugger.\n");
+
+ raise (SIGSTOP);
+ } else if (strcmp (ephy_debug_break, "stack") == 0) {
#ifdef HAVE_EXECINFO_H
- void *array[MAX_DEPTH];
- size_t size;
-
- size = backtrace (array, MAX_DEPTH);
- backtrace_symbols_fd (array, size, 2);
+ void *array[MAX_DEPTH];
+ size_t size;
+
+ size = backtrace (array, MAX_DEPTH);
+ backtrace_symbols_fd (array, size, 2);
#else
- g_on_error_stack_trace (g_get_prgname ());
+ g_on_error_stack_trace (g_get_prgname ());
#endif /* HAVE_EXECINFO_H */
- }
- else if (strcmp (ephy_debug_break, "trap") == 0)
- {
- /* FIXME: disable the handler for a moment so we
- * don't crash if we don't actually run under gdb
- */
- G_BREAKPOINT ();
- }
- else if (strcmp (ephy_debug_break, "warn") == 0)
- {
- /* default behaviour only */
- }
- else if (ephy_debug_break[0] != '\0')
- {
- g_print ("Unrecognised value of EPHY_DEBUG_BREAK env var: %s!\n",
- ephy_debug_break);
- }
- }
+ } else if (strcmp (ephy_debug_break, "trap") == 0) {
+ /* FIXME: disable the handler for a moment so we
+ * don't crash if we don't actually run under gdb
+ */
+ G_BREAKPOINT ();
+ } else if (strcmp (ephy_debug_break, "warn") == 0) {
+ /* default behaviour only */
+ } else if (ephy_debug_break[0] != '\0') {
+ g_print ("Unrecognised value of EPHY_DEBUG_BREAK env var: %s!\n",
+ ephy_debug_break);
+ }
+ }
}
/**
@@ -173,17 +156,16 @@ void
ephy_debug_init (void)
{
#ifndef DISABLE_LOGGING
- ephy_log_modules = build_modules ("EPHY_LOG_MODULES", &ephy_log_all_modules);
-
- g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, log_module, NULL);
+ ephy_log_modules = build_modules ("EPHY_LOG_MODULES", &ephy_log_all_modules);
+ g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, log_module, NULL);
#endif
- ephy_debug_break = g_getenv ("EPHY_DEBUG_BREAK");
- g_log_set_default_handler (trap_handler, NULL);
+ ephy_debug_break = g_getenv ("EPHY_DEBUG_BREAK");
+ g_log_set_default_handler (trap_handler, NULL);
#ifndef DISABLE_PROFILING
- ephy_profile_modules = build_modules ("EPHY_PROFILE_MODULES", &ephy_profile_all_modules);
+ ephy_profile_modules = build_modules ("EPHY_PROFILE_MODULES", &ephy_profile_all_modules);
#endif
}
@@ -192,65 +174,63 @@ ephy_debug_init (void)
static EphyProfiler *
ephy_profiler_new (const char *name, const char *module)
{
- EphyProfiler *profiler;
+ EphyProfiler *profiler;
- profiler = g_new0 (EphyProfiler, 1);
- profiler->timer = g_timer_new ();
- profiler->name = g_strdup (name);
- profiler->module = g_strdup (module);
+ profiler = g_new0 (EphyProfiler, 1);
+ profiler->timer = g_timer_new ();
+ profiler->name = g_strdup (name);
+ profiler->module = g_strdup (module);
- g_timer_start (profiler->timer);
+ g_timer_start (profiler->timer);
- return profiler;
+ return profiler;
}
static gboolean
ephy_should_profile (const char *module)
{
- char *slash;
- gboolean result = FALSE;
- guint i;
+ char *slash;
+ gboolean result = FALSE;
+ guint i;
- slash = strrchr (module, '/');
+ slash = strrchr (module, '/');
- /* Happens on builddir != srcdir builds */
- if (slash != NULL) module = slash + 1;
+ /* Happens on builddir != srcdir builds */
+ if (slash != NULL) module = slash + 1;
- for (i = 0; ephy_profile_modules[i] != NULL; i++)
- {
- if (strcmp (ephy_profile_modules[i], module) == 0)
- {
- result = TRUE;
- break;
- }
- }
+ for (i = 0; ephy_profile_modules[i] != NULL; i++) {
+ if (strcmp (ephy_profile_modules[i], module) == 0) {
+ result = TRUE;
+ break;
+ }
+ }
- return result;
+ return result;
}
static void
ephy_profiler_dump (EphyProfiler *profiler)
{
- double seconds;
+ double seconds;
- g_return_if_fail (profiler != NULL);
+ g_return_if_fail (profiler != NULL);
- seconds = g_timer_elapsed (profiler->timer, NULL);
+ seconds = g_timer_elapsed (profiler->timer, NULL);
- g_print ("[ %s ] %s %f s elapsed\n",
- profiler->module, profiler->name,
- seconds);
+ g_print ("[ %s ] %s %f s elapsed\n",
+ profiler->module, profiler->name,
+ seconds);
}
static void
ephy_profiler_free (EphyProfiler *profiler)
{
- g_return_if_fail (profiler != NULL);
+ g_return_if_fail (profiler != NULL);
- g_timer_destroy (profiler->timer);
- g_free (profiler->name);
- g_free (profiler->module);
- g_free (profiler);
+ g_timer_destroy (profiler->timer);
+ g_free (profiler->name);
+ g_free (profiler->module);
+ g_free (profiler);
}
/**
@@ -263,21 +243,20 @@ ephy_profiler_free (EphyProfiler *profiler)
void
ephy_profiler_start (const char *name, const char *module)
{
- EphyProfiler *profiler;
+ EphyProfiler *profiler;
- if (ephy_profilers_hash == NULL)
- {
- ephy_profilers_hash =
- g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, NULL);
- }
+ if (ephy_profilers_hash == NULL) {
+ ephy_profilers_hash =
+ g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, NULL);
+ }
- if (!ephy_profile_all_modules &&
- (ephy_profile_modules == NULL || !ephy_should_profile (module))) return;
+ if (!ephy_profile_all_modules &&
+ (ephy_profile_modules == NULL || !ephy_should_profile (module))) return;
- profiler = ephy_profiler_new (name, module);
+ profiler = ephy_profiler_new (name, module);
- g_hash_table_insert (ephy_profilers_hash, g_strdup (name), profiler);
+ g_hash_table_insert (ephy_profilers_hash, g_strdup (name), profiler);
}
/**
@@ -289,14 +268,13 @@ ephy_profiler_start (const char *name, const char *module)
void
ephy_profiler_stop (const char *name)
{
- EphyProfiler *profiler;
+ EphyProfiler *profiler;
- profiler = g_hash_table_lookup (ephy_profilers_hash, name);
- if (profiler == NULL) return;
- g_hash_table_remove (ephy_profilers_hash, name);
+ profiler = g_hash_table_lookup (ephy_profilers_hash, name);
+ if (profiler == NULL) return;
+ g_hash_table_remove (ephy_profilers_hash, name);
- ephy_profiler_dump (profiler);
- ephy_profiler_free (profiler);
+ ephy_profiler_dump (profiler);
+ ephy_profiler_free (profiler);
}
-
#endif
diff --git a/lib/ephy-dnd.c b/lib/ephy-dnd.c
index bb7b61a..fe4289f 100644
--- a/lib/ephy-dnd.c
+++ b/lib/ephy-dnd.c
@@ -32,82 +32,73 @@
static void
add_one_netscape_url (const char *url, const char *title, gpointer data)
{
- GString *result;
-
- result = (GString *) data;
- if (result->len == 0)
- {
- g_string_append (result, url);
- if (title)
- {
- g_string_append (result, "\n");
- g_string_append (result, title);
- }
- }
+ GString *result;
+
+ result = (GString *)data;
+ if (result->len == 0) {
+ g_string_append (result, url);
+ if (title) {
+ g_string_append (result, "\n");
+ g_string_append (result, title);
+ }
+ }
}
static void
add_one_uri (const char *uri, const char *title, gpointer data)
{
- GString *result;
+ GString *result;
- result = (GString *) data;
+ result = (GString *)data;
- g_string_append (result, uri);
- g_string_append (result, "\r\n");
+ g_string_append (result, uri);
+ g_string_append (result, "\r\n");
}
static void
add_one_topic (const char *uri, const char *title, gpointer data)
{
- GString *result;
+ GString *result;
- result = (GString *) data;
+ result = (GString *)data;
- g_string_append (result, uri);
- g_string_append (result, "\r\n");
+ g_string_append (result, uri);
+ g_string_append (result, "\r\n");
}
gboolean
-ephy_dnd_drag_data_get (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint32 time,
- gpointer container_context,
+ephy_dnd_drag_data_get (GtkWidget *widget,
+ GdkDragContext *context,
+ GtkSelectionData *selection_data,
+ guint32 time,
+ gpointer container_context,
EphyDragEachSelectedItemIterator each_selected_item_iterator)
{
- GString *result = NULL;
- GdkAtom target;
-
- target = gtk_selection_data_get_target (selection_data);
-
- if (target == gdk_atom_intern (EPHY_DND_URI_LIST_TYPE, FALSE) ||
- target == gdk_atom_intern (EPHY_DND_TEXT_TYPE, FALSE))
- {
- result = g_string_new (NULL);
- (* each_selected_item_iterator) (add_one_uri, container_context, result);
- }
- else if (target == gdk_atom_intern (EPHY_DND_URL_TYPE, FALSE))
- {
- result = g_string_new (NULL);
- (* each_selected_item_iterator) (add_one_netscape_url, container_context, result);
- }
- else if (target == gdk_atom_intern (EPHY_DND_TOPIC_TYPE, FALSE))
- {
- result = g_string_new (NULL);
- (* each_selected_item_iterator) (add_one_topic, container_context, result);
- g_string_erase (result, result->len - 2, -1);
- }
- else
- {
- g_assert_not_reached ();
- }
-
- gtk_selection_data_set (selection_data,
- target,
- 8, (const guchar *) result->str, result->len);
-
- g_string_free (result, TRUE);
-
- return TRUE;
+ GString *result = NULL;
+ GdkAtom target;
+
+ target = gtk_selection_data_get_target (selection_data);
+
+ if (target == gdk_atom_intern (EPHY_DND_URI_LIST_TYPE, FALSE) ||
+ target == gdk_atom_intern (EPHY_DND_TEXT_TYPE, FALSE)) {
+ result = g_string_new (NULL);
+ (*each_selected_item_iterator)(add_one_uri, container_context, result);
+ } else if (target == gdk_atom_intern (EPHY_DND_URL_TYPE, FALSE)) {
+ result = g_string_new (NULL);
+ (*each_selected_item_iterator)(add_one_netscape_url, container_context, result);
+ } else if (target == gdk_atom_intern (EPHY_DND_TOPIC_TYPE, FALSE)) {
+ result = g_string_new (NULL);
+ (*each_selected_item_iterator)(add_one_topic, container_context, result);
+ g_string_erase (result, result->len - 2, -1);
+ } else {
+ g_assert_not_reached ();
+ }
+
+ gtk_selection_data_set (selection_data,
+ target,
+ 8, (const guchar *)result->str, result->len);
+
+ g_string_free (result, TRUE);
+
+ return TRUE;
}
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c
index 69de134..0545733 100644
--- a/lib/ephy-file-helpers.c
+++ b/lib/ephy-file-helpers.c
@@ -50,8 +50,8 @@
* atomically.
*/
-#define DELAY_MAX_TICKS 64
-#define INITIAL_TICKS 2
+#define DELAY_MAX_TICKS 64
+#define INITIAL_TICKS 2
static GHashTable *files = NULL;
static GHashTable *mime_table = NULL;
@@ -74,38 +74,36 @@ GQuark ephy_file_helpers_error_quark;
const char *
ephy_file_tmp_dir (void)
{
- if (tmp_dir == NULL)
- {
- char *partial_name;
- char *full_name;
-
- partial_name = g_strconcat ("epiphany-", g_get_user_name (),
- "-XXXXXX", NULL);
- full_name = g_build_filename (g_get_tmp_dir (), partial_name,
- NULL);
- tmp_dir = mkdtemp (full_name);
- g_free (partial_name);
-
- if (tmp_dir == NULL)
- {
- g_free (full_name);
- }
- }
-
- return tmp_dir;
+ if (tmp_dir == NULL) {
+ char *partial_name;
+ char *full_name;
+
+ partial_name = g_strconcat ("epiphany-", g_get_user_name (),
+ "-XXXXXX", NULL);
+ full_name = g_build_filename (g_get_tmp_dir (), partial_name,
+ NULL);
+ tmp_dir = mkdtemp (full_name);
+ g_free (partial_name);
+
+ if (tmp_dir == NULL) {
+ g_free (full_name);
+ }
+ }
+
+ return tmp_dir;
}
static char *
ephy_file_download_dir (void)
{
- const char *xdg_download_dir;
+ const char *xdg_download_dir;
- xdg_download_dir = g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD);
- if (xdg_download_dir != NULL)
- return g_strdup (xdg_download_dir);
+ xdg_download_dir = g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD);
+ if (xdg_download_dir != NULL)
+ return g_strdup (xdg_download_dir);
- /* If we don't have XDG user dirs info, return an educated guess. */
- return g_build_filename (g_get_home_dir (), _("Downloads"), NULL);
+ /* If we don't have XDG user dirs info, return an educated guess. */
+ return g_build_filename (g_get_home_dir (), _("Downloads"), NULL);
}
/**
@@ -127,18 +125,18 @@ ephy_file_download_dir (void)
char *
ephy_file_get_downloads_dir (void)
{
- char *download_dir;
+ char *download_dir;
- download_dir = g_settings_get_string (EPHY_SETTINGS_STATE,
- EPHY_PREFS_STATE_DOWNLOAD_DIR);
+ download_dir = g_settings_get_string (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_DOWNLOAD_DIR);
- if (g_str_equal (download_dir, "Desktop"))
- download_dir = ephy_file_desktop_dir ();
- if (g_str_equal (download_dir, "Downloads") ||
- g_path_is_absolute (download_dir) != TRUE)
- download_dir = ephy_file_download_dir ();
+ if (g_str_equal (download_dir, "Desktop"))
+ download_dir = ephy_file_desktop_dir ();
+ if (g_str_equal (download_dir, "Downloads") ||
+ g_path_is_absolute (download_dir) != TRUE)
+ download_dir = ephy_file_download_dir ();
- return download_dir;
+ return download_dir;
}
/**
@@ -151,14 +149,14 @@ ephy_file_get_downloads_dir (void)
char *
ephy_file_desktop_dir (void)
{
- const char *xdg_desktop_dir;
+ const char *xdg_desktop_dir;
- xdg_desktop_dir = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
- if (xdg_desktop_dir != NULL)
- return g_strdup (xdg_desktop_dir);
+ xdg_desktop_dir = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
+ if (xdg_desktop_dir != NULL)
+ return g_strdup (xdg_desktop_dir);
- /* If we don't have XDG user dirs info, return an educated guess. */
- return g_build_filename (g_get_home_dir (), _("Desktop"), NULL);
+ /* If we don't have XDG user dirs info, return an educated guess. */
+ return g_build_filename (g_get_home_dir (), _("Desktop"), NULL);
}
/**
@@ -177,35 +175,31 @@ ephy_file_desktop_dir (void)
**/
char *
ephy_file_tmp_filename (const char *base,
- const char *extension)
+ const char *extension)
{
- int fd;
- char *name = g_strdup (base);
-
- fd = g_mkstemp (name);
-
- if (fd != -1)
- {
- unlink (name);
- close (fd);
- }
- else
- {
- g_free (name);
-
- return NULL;
- }
-
- if (extension)
- {
- char *tmp;
- tmp = g_strconcat (name, ".",
- extension, NULL);
- g_free (name);
- name = tmp;
- }
-
- return name;
+ int fd;
+ char *name = g_strdup (base);
+
+ fd = g_mkstemp (name);
+
+ if (fd != -1) {
+ unlink (name);
+ close (fd);
+ } else {
+ g_free (name);
+
+ return NULL;
+ }
+
+ if (extension) {
+ char *tmp;
+ tmp = g_strconcat (name, ".",
+ extension, NULL);
+ g_free (name);
+ name = tmp;
+ }
+
+ return name;
}
/**
@@ -219,41 +213,39 @@ ephy_file_tmp_filename (const char *base,
const char *
ephy_file (const char *filename)
{
- char *ret;
- guint i;
+ char *ret;
+ guint i;
- static const char * const paths[] =
- {
+ static const char * const paths[] =
+ {
#ifndef NDEBUG
- TOP_SRC_DATADIR "/",
- TOP_SRC_DATADIR "/icons/",
- TOP_SRC_DATADIR "/pages/",
+ TOP_SRC_DATADIR "/",
+ TOP_SRC_DATADIR "/icons/",
+ TOP_SRC_DATADIR "/pages/",
#endif
- SHARE_DIR "/",
- SHARE_DIR "/icons/",
- SHARE_DIR "/pages/"
- };
-
- g_assert (files != NULL);
-
- ret = g_hash_table_lookup (files, filename);
- if (ret != NULL)
- return ret;
-
- for (i = 0; i < G_N_ELEMENTS (paths); i++)
- {
- ret = g_strconcat (paths[i], filename, NULL);
- if (g_file_test (ret, G_FILE_TEST_EXISTS) == TRUE)
- {
- g_hash_table_insert (files, g_strdup (filename), ret);
- return (const char *) ret;
- }
- g_free (ret);
- }
-
- g_warning ("Failed to find %s\n", filename);
-
- return NULL;
+ SHARE_DIR "/",
+ SHARE_DIR "/icons/",
+ SHARE_DIR "/pages/"
+ };
+
+ g_assert (files != NULL);
+
+ ret = g_hash_table_lookup (files, filename);
+ if (ret != NULL)
+ return ret;
+
+ for (i = 0; i < G_N_ELEMENTS (paths); i++) {
+ ret = g_strconcat (paths[i], filename, NULL);
+ if (g_file_test (ret, G_FILE_TEST_EXISTS) == TRUE) {
+ g_hash_table_insert (files, g_strdup (filename), ret);
+ return (const char *)ret;
+ }
+ g_free (ret);
+ }
+
+ g_warning ("Failed to find %s\n", filename);
+
+ return NULL;
}
/**
@@ -267,7 +259,7 @@ ephy_file (const char *filename)
const char *
ephy_dot_dir (void)
{
- return dot_dir;
+ return dot_dir;
}
/**
@@ -281,7 +273,7 @@ ephy_dot_dir (void)
gboolean
ephy_dot_dir_is_default (void)
{
- return is_default_dot_dir;
+ return is_default_dot_dir;
}
/**
@@ -294,7 +286,7 @@ ephy_dot_dir_is_default (void)
char *
ephy_default_dot_dir (void)
{
- return g_build_filename (g_get_user_config_dir (), "epiphany", NULL);
+ return g_build_filename (g_get_user_config_dir (), "epiphany", NULL);
}
/**
@@ -309,111 +301,99 @@ ephy_default_dot_dir (void)
* Returns: %FALSE if the profile dir couldn't be created or accessed
**/
gboolean
-ephy_file_helpers_init (const char *profile_dir,
- EphyFileHelpersFlags flags,
- GError **error)
+ephy_file_helpers_init (const char *profile_dir,
+ EphyFileHelpersFlags flags,
+ GError **error)
{
- gboolean ret = TRUE;
- gboolean private_profile;
- gboolean steal_data_from_profile;
-
- ephy_file_helpers_error_quark = g_quark_from_static_string ("ephy-file-helpers-error");
-
- files = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) g_free);
-
- keep_directory = flags & EPHY_FILE_HELPERS_KEEP_DIR;
- private_profile = flags & EPHY_FILE_HELPERS_PRIVATE_PROFILE;
- steal_data_from_profile = flags & EPHY_FILE_HELPERS_STEAL_DATA;
-
- if (profile_dir != NULL && !steal_data_from_profile)
- {
- if (g_path_is_absolute (profile_dir))
- {
- dot_dir = g_strdup (profile_dir);
- }
- else
- {
- GFile *file = g_file_new_for_path (profile_dir);
- dot_dir = g_file_get_path (file);
- g_object_unref (file);
- }
- }
- else if (private_profile)
- {
- if (ephy_file_tmp_dir () == NULL)
- {
- g_set_error (error,
- EPHY_FILE_HELPERS_ERROR_QUARK,
- 0,
- _("Could not create a temporary directory in “%s”."),
- g_get_tmp_dir ());
- return FALSE;
- }
-
- dot_dir = g_build_filename (ephy_file_tmp_dir (),
- "epiphany",
- NULL);
- }
-
- if (dot_dir == NULL)
- {
- dot_dir = ephy_default_dot_dir ();
- is_default_dot_dir = TRUE;
- }
-
- if (flags & EPHY_FILE_HELPERS_ENSURE_EXISTS)
- ret = ephy_ensure_dir_exists (ephy_dot_dir (), error);
-
- if (steal_data_from_profile && profile_dir)
- {
- guint i;
- const char *files_to_copy[] = { EPHY_HISTORY_FILE, EPHY_BOOKMARKS_FILE };
-
- for (i = 0; i < G_N_ELEMENTS (files_to_copy); i++)
- {
- char *filename;
- GError *err = NULL;
- GFile *source, *destination;
-
- filename = g_build_filename (profile_dir,
- files_to_copy[i],
- NULL);
- source = g_file_new_for_path (filename);
- g_free (filename);
-
- filename = g_build_filename (dot_dir,
- files_to_copy[i],
- NULL);
- destination = g_file_new_for_path (filename);
- g_free (filename);
-
- g_file_copy (source, destination,
- G_FILE_COPY_OVERWRITE,
- NULL, NULL, NULL, &err);
- if (err)
- {
- printf("Error stealing file %s from profile: %s\n", files_to_copy[i],
err->message);
- g_error_free (err);
- }
-
- g_object_unref (source);
- g_object_unref (destination);
- }
- }
-
- return ret;
+ gboolean ret = TRUE;
+ gboolean private_profile;
+ gboolean steal_data_from_profile;
+
+ ephy_file_helpers_error_quark = g_quark_from_static_string ("ephy-file-helpers-error");
+
+ files = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ (GDestroyNotify)g_free,
+ (GDestroyNotify)g_free);
+
+ keep_directory = flags & EPHY_FILE_HELPERS_KEEP_DIR;
+ private_profile = flags & EPHY_FILE_HELPERS_PRIVATE_PROFILE;
+ steal_data_from_profile = flags & EPHY_FILE_HELPERS_STEAL_DATA;
+
+ if (profile_dir != NULL && !steal_data_from_profile) {
+ if (g_path_is_absolute (profile_dir)) {
+ dot_dir = g_strdup (profile_dir);
+ } else {
+ GFile *file = g_file_new_for_path (profile_dir);
+ dot_dir = g_file_get_path (file);
+ g_object_unref (file);
+ }
+ } else if (private_profile) {
+ if (ephy_file_tmp_dir () == NULL) {
+ g_set_error (error,
+ EPHY_FILE_HELPERS_ERROR_QUARK,
+ 0,
+ _("Could not create a temporary directory in “%s”."),
+ g_get_tmp_dir ());
+ return FALSE;
+ }
+
+ dot_dir = g_build_filename (ephy_file_tmp_dir (),
+ "epiphany",
+ NULL);
+ }
+
+ if (dot_dir == NULL) {
+ dot_dir = ephy_default_dot_dir ();
+ is_default_dot_dir = TRUE;
+ }
+
+ if (flags & EPHY_FILE_HELPERS_ENSURE_EXISTS)
+ ret = ephy_ensure_dir_exists (ephy_dot_dir (), error);
+
+ if (steal_data_from_profile && profile_dir) {
+ guint i;
+ const char *files_to_copy[] = { EPHY_HISTORY_FILE, EPHY_BOOKMARKS_FILE };
+
+ for (i = 0; i < G_N_ELEMENTS (files_to_copy); i++) {
+ char *filename;
+ GError *err = NULL;
+ GFile *source, *destination;
+
+ filename = g_build_filename (profile_dir,
+ files_to_copy[i],
+ NULL);
+ source = g_file_new_for_path (filename);
+ g_free (filename);
+
+ filename = g_build_filename (dot_dir,
+ files_to_copy[i],
+ NULL);
+ destination = g_file_new_for_path (filename);
+ g_free (filename);
+
+ g_file_copy (source, destination,
+ G_FILE_COPY_OVERWRITE,
+ NULL, NULL, NULL, &err);
+ if (err) {
+ printf ("Error stealing file %s from profile: %s\n", files_to_copy[i], err->message);
+ g_error_free (err);
+ }
+
+ g_object_unref (source);
+ g_object_unref (destination);
+ }
+ }
+
+ return ret;
}
static void
delete_files (GList *l)
{
- for (; l != NULL; l = l->next)
- {
- unlink (l->data);
- }
+ for (; l != NULL; l = l->next) {
+ unlink (l->data);
+ }
}
/**
@@ -424,37 +404,34 @@ delete_files (GList *l)
void
ephy_file_helpers_shutdown (void)
{
- g_hash_table_destroy (files);
-
- del_on_exit = g_list_reverse (del_on_exit);
- delete_files (del_on_exit);
- g_list_foreach (del_on_exit, (GFunc)g_free, NULL);
- g_list_free (del_on_exit);
- del_on_exit = NULL;
-
- if (mime_table != NULL)
- {
- LOG ("Destroying mime type hashtable");
- g_hash_table_destroy (mime_table);
- mime_table = NULL;
- }
-
- g_free (dot_dir);
- dot_dir = NULL;
-
- if (tmp_dir != NULL)
- {
- if (!keep_directory)
- {
- /* recursively delete the contents and the
- * directory */
- LOG ("shutdown: delete tmp_dir %s", tmp_dir);
- ephy_file_delete_dir_recursively (tmp_dir, NULL);
- }
-
- g_free (tmp_dir);
- tmp_dir = NULL;
- }
+ g_hash_table_destroy (files);
+
+ del_on_exit = g_list_reverse (del_on_exit);
+ delete_files (del_on_exit);
+ g_list_foreach (del_on_exit, (GFunc)g_free, NULL);
+ g_list_free (del_on_exit);
+ del_on_exit = NULL;
+
+ if (mime_table != NULL) {
+ LOG ("Destroying mime type hashtable");
+ g_hash_table_destroy (mime_table);
+ mime_table = NULL;
+ }
+
+ g_free (dot_dir);
+ dot_dir = NULL;
+
+ if (tmp_dir != NULL) {
+ if (!keep_directory) {
+ /* recursively delete the contents and the
+ * directory */
+ LOG ("shutdown: delete tmp_dir %s", tmp_dir);
+ ephy_file_delete_dir_recursively (tmp_dir, NULL);
+ }
+
+ g_free (tmp_dir);
+ tmp_dir = NULL;
+ }
}
/**
@@ -470,79 +447,69 @@ ephy_file_helpers_shutdown (void)
**/
gboolean
ephy_ensure_dir_exists (const char *dir,
- GError **error)
+ GError **error)
{
- if (g_file_test (dir, G_FILE_TEST_EXISTS) &&
- !g_file_test (dir, G_FILE_TEST_IS_DIR))
- {
- g_set_error (error,
- EPHY_FILE_HELPERS_ERROR_QUARK,
- 0,
- _("The file “%s” exists. Please move it out of the way."),
- dir);
-
- return FALSE;
- }
-
- if (!g_file_test (dir, G_FILE_TEST_EXISTS))
- {
- if (g_mkdir_with_parents (dir, 488) == 0)
- {
- if (dir == ephy_dot_dir ())
- {
- /* We need to set the .migrated file to the
- * current profile migration version,
- * otherwise the next time the browser runs
- * things might go awry. */
- ephy_profile_utils_set_migration_version (EPHY_PROFILE_MIGRATION_VERSION);
- }
- }
- else
- {
- g_set_error (error,
- EPHY_FILE_HELPERS_ERROR_QUARK,
- 0,
- _("Failed to create directory “%s”."),
- dir);
-
- return FALSE;
- }
- }
-
- return TRUE;
+ if (g_file_test (dir, G_FILE_TEST_EXISTS) &&
+ !g_file_test (dir, G_FILE_TEST_IS_DIR)) {
+ g_set_error (error,
+ EPHY_FILE_HELPERS_ERROR_QUARK,
+ 0,
+ _("The file “%s” exists. Please move it out of the way."),
+ dir);
+
+ return FALSE;
+ }
+
+ if (!g_file_test (dir, G_FILE_TEST_EXISTS)) {
+ if (g_mkdir_with_parents (dir, 488) == 0) {
+ if (dir == ephy_dot_dir ()) {
+ /* We need to set the .migrated file to the
+ * current profile migration version,
+ * otherwise the next time the browser runs
+ * things might go awry. */
+ ephy_profile_utils_set_migration_version (EPHY_PROFILE_MIGRATION_VERSION);
+ }
+ } else {
+ g_set_error (error,
+ EPHY_FILE_HELPERS_ERROR_QUARK,
+ 0,
+ _("Failed to create directory “%s”."),
+ dir);
+
+ return FALSE;
+ }
+ }
+
+ return TRUE;
}
static void
ephy_find_file_recursive (const char *path,
- const char *fname,
- GSList **list,
- gint depth,
- gint maxdepth)
+ const char *fname,
+ GSList **list,
+ gint depth,
+ gint maxdepth)
{
- GDir *dir;
- const gchar *file;
-
- dir = g_dir_open (path, 0, NULL);
- if (dir != NULL)
- {
- while ((file = g_dir_read_name (dir)))
- {
- if (depth < maxdepth)
- {
- char *new_path = g_build_filename (path, file, NULL);
- ephy_find_file_recursive (new_path, fname, list,
- depth + 1, maxdepth);
- g_free (new_path);
- }
- if (strcmp (file, fname) == 0)
- {
- char *new_path = g_build_filename (path, file, NULL);
- *list = g_slist_prepend (*list, new_path);
- }
- }
-
- g_dir_close (dir);
- }
+ GDir *dir;
+ const gchar *file;
+
+ dir = g_dir_open (path, 0, NULL);
+ if (dir != NULL) {
+ while ((file = g_dir_read_name (dir))) {
+ if (depth < maxdepth) {
+ char *new_path = g_build_filename (path, file, NULL);
+ ephy_find_file_recursive (new_path, fname, list,
+ depth + 1, maxdepth);
+ g_free (new_path);
+ }
+ if (strcmp (file, fname) == 0) {
+ char *new_path = g_build_filename (path, file, NULL);
+ *list = g_slist_prepend (*list, new_path);
+ }
+ }
+
+ g_dir_close (dir);
+ }
}
/**
@@ -557,12 +524,12 @@ ephy_find_file_recursive (const char *path,
**/
GSList *
ephy_file_find (const char *path,
- const char *fname,
- gint maxdepth)
+ const char *fname,
+ gint maxdepth)
{
- GSList *ret = NULL;
- ephy_find_file_recursive (path, fname, &ret, 0, maxdepth);
- return ret;
+ GSList *ret = NULL;
+ ephy_find_file_recursive (path, fname, &ret, 0, maxdepth);
+ return ret;
}
/**
@@ -575,66 +542,58 @@ ephy_file_find (const char *path,
void
ephy_file_delete_on_exit (GFile *file)
{
- /* does nothing now */
+ /* does nothing now */
}
static void
load_mime_from_xml (void)
{
- xmlTextReaderPtr reader;
- const char *xml_file;
- int ret;
- EphyMimePermission permission = EPHY_MIME_PERMISSION_UNKNOWN;
-
- g_return_if_fail (mime_table == NULL);
-
- mime_table = g_hash_table_new_full (g_str_hash, g_str_equal,
- xmlFree, NULL);
-
- xml_file = ephy_file ("mime-types-permissions.xml");
- if (xml_file == NULL)
- {
- g_warning ("MIME types permissions file not found!\n");
- return;
- }
-
- reader = xmlNewTextReaderFilename (xml_file);
- if (reader == NULL)
- {
- g_warning ("Could not load MIME types permissions file!\n");
- return;
- }
-
- ret = xmlTextReaderRead (reader);
- while (ret == 1)
- {
- const xmlChar *tag;
- xmlReaderTypes type;
-
- tag = xmlTextReaderConstName (reader);
- type = xmlTextReaderNodeType (reader);
-
- if (xmlStrEqual (tag, (const xmlChar *)"safe") && type == XML_READER_TYPE_ELEMENT)
- {
- permission = EPHY_MIME_PERMISSION_SAFE;
- }
- else if (xmlStrEqual (tag, (const xmlChar *)"unsafe") && type == XML_READER_TYPE_ELEMENT)
- {
- permission = EPHY_MIME_PERMISSION_UNSAFE;
- }
- else if (xmlStrEqual (tag, (const xmlChar *)"mime-type"))
- {
- xmlChar *t;
-
- t = xmlTextReaderGetAttribute (reader, (const xmlChar *)"type");
- g_hash_table_insert (mime_table, t,
- GINT_TO_POINTER (permission));
- }
-
- ret = xmlTextReaderRead (reader);
- }
-
- xmlFreeTextReader (reader);
+ xmlTextReaderPtr reader;
+ const char *xml_file;
+ int ret;
+ EphyMimePermission permission = EPHY_MIME_PERMISSION_UNKNOWN;
+
+ g_return_if_fail (mime_table == NULL);
+
+ mime_table = g_hash_table_new_full (g_str_hash, g_str_equal,
+ xmlFree, NULL);
+
+ xml_file = ephy_file ("mime-types-permissions.xml");
+ if (xml_file == NULL) {
+ g_warning ("MIME types permissions file not found!\n");
+ return;
+ }
+
+ reader = xmlNewTextReaderFilename (xml_file);
+ if (reader == NULL) {
+ g_warning ("Could not load MIME types permissions file!\n");
+ return;
+ }
+
+ ret = xmlTextReaderRead (reader);
+ while (ret == 1) {
+ const xmlChar *tag;
+ xmlReaderTypes type;
+
+ tag = xmlTextReaderConstName (reader);
+ type = xmlTextReaderNodeType (reader);
+
+ if (xmlStrEqual (tag, (const xmlChar *)"safe") && type == XML_READER_TYPE_ELEMENT) {
+ permission = EPHY_MIME_PERMISSION_SAFE;
+ } else if (xmlStrEqual (tag, (const xmlChar *)"unsafe") && type == XML_READER_TYPE_ELEMENT) {
+ permission = EPHY_MIME_PERMISSION_UNSAFE;
+ } else if (xmlStrEqual (tag, (const xmlChar *)"mime-type")) {
+ xmlChar *t;
+
+ t = xmlTextReaderGetAttribute (reader, (const xmlChar *)"type");
+ g_hash_table_insert (mime_table, t,
+ GINT_TO_POINTER (permission));
+ }
+
+ ret = xmlTextReaderRead (reader);
+ }
+
+ xmlFreeTextReader (reader);
}
/**
@@ -649,27 +608,23 @@ load_mime_from_xml (void)
EphyMimePermission
ephy_file_check_mime (const char *mime_type)
{
- EphyMimePermission permission;
- gpointer tmp;
-
- g_return_val_if_fail (mime_type != NULL, EPHY_MIME_PERMISSION_UNKNOWN);
-
- if (mime_table == NULL)
- {
- load_mime_from_xml ();
- }
-
- tmp = g_hash_table_lookup (mime_table, mime_type);
- if (tmp == NULL)
- {
- permission = EPHY_MIME_PERMISSION_UNKNOWN;
- }
- else
- {
- permission = GPOINTER_TO_INT (tmp);
- }
-
- return permission;
+ EphyMimePermission permission;
+ gpointer tmp;
+
+ g_return_val_if_fail (mime_type != NULL, EPHY_MIME_PERMISSION_UNKNOWN);
+
+ if (mime_table == NULL) {
+ load_mime_from_xml ();
+ }
+
+ tmp = g_hash_table_lookup (mime_table, mime_type);
+ if (tmp == NULL) {
+ permission = EPHY_MIME_PERMISSION_UNKNOWN;
+ } else {
+ permission = GPOINTER_TO_INT (tmp);
+ }
+
+ return permission;
}
/**
@@ -686,36 +641,33 @@ ephy_file_check_mime (const char *mime_type)
* Returns: %TRUE if g_app_info_launch() succeeded
**/
gboolean
-ephy_file_launch_application (GAppInfo *app,
- GList *list,
- guint32 user_time,
- GtkWidget *widget)
+ephy_file_launch_application (GAppInfo *app,
+ GList *list,
+ guint32 user_time,
+ GtkWidget *widget)
{
- GdkAppLaunchContext *context;
- GdkDisplay *display;
- GdkScreen *screen;
- gboolean res;
-
- if (widget)
- {
- display = gtk_widget_get_display (widget);
- screen = gtk_widget_get_screen (widget);
- }
- else
- {
- display = gdk_display_get_default ();
- screen = gdk_screen_get_default ();
- }
-
- context = gdk_display_get_app_launch_context (display);
- gdk_app_launch_context_set_screen (context, screen);
- gdk_app_launch_context_set_timestamp (context, user_time);
-
- res = g_app_info_launch (app, list,
- G_APP_LAUNCH_CONTEXT (context), NULL);
- g_object_unref (context);
-
- return res;
+ GdkAppLaunchContext *context;
+ GdkDisplay *display;
+ GdkScreen *screen;
+ gboolean res;
+
+ if (widget) {
+ display = gtk_widget_get_display (widget);
+ screen = gtk_widget_get_screen (widget);
+ } else {
+ display = gdk_display_get_default ();
+ screen = gdk_screen_get_default ();
+ }
+
+ context = gdk_display_get_app_launch_context (display);
+ gdk_app_launch_context_set_screen (context, screen);
+ gdk_app_launch_context_set_timestamp (context, user_time);
+
+ res = g_app_info_launch (app, list,
+ G_APP_LAUNCH_CONTEXT (context), NULL);
+ g_object_unref (context);
+
+ return res;
}
/**
@@ -732,68 +684,62 @@ ephy_file_launch_application (GAppInfo *app,
**/
gboolean
ephy_file_launch_desktop_file (const char *filename,
- const char *parameter,
- guint32 user_time,
- GtkWidget *widget)
+ const char *parameter,
+ guint32 user_time,
+ GtkWidget *widget)
{
- GDesktopAppInfo *app;
- GFile *file = NULL;
- GList *list = NULL;
- gboolean ret;
-
- app = g_desktop_app_info_new (filename);
- if (parameter)
- {
- file = g_file_new_for_path (parameter);
- list = g_list_append (list, file);
- }
-
- ret = ephy_file_launch_application (G_APP_INFO (app), list, user_time, widget);
- g_list_free (list);
- if (file)
- g_object_unref (file);
- return ret;
+ GDesktopAppInfo *app;
+ GFile *file = NULL;
+ GList *list = NULL;
+ gboolean ret;
+
+ app = g_desktop_app_info_new (filename);
+ if (parameter) {
+ file = g_file_new_for_path (parameter);
+ list = g_list_append (list, file);
+ }
+
+ ret = ephy_file_launch_application (G_APP_INFO (app), list, user_time, widget);
+ g_list_free (list);
+ if (file)
+ g_object_unref (file);
+ return ret;
}
GAppInfo *
-ephy_file_launcher_get_app_info_for_file (GFile *file,
- const char *mime_type)
+ephy_file_launcher_get_app_info_for_file (GFile *file,
+ const char *mime_type)
{
- GAppInfo *app = NULL;
-
- g_return_val_if_fail (file || mime_type, FALSE);
-
- if (mime_type != NULL)
- {
- app = g_app_info_get_default_for_type (mime_type,
- FALSE);
- }
- else
- {
- GFileInfo *file_info;
- char *type;
-
- /* Sniff mime type and check if it's safe to open */
- file_info = g_file_query_info (file,
- G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
- 0, NULL, NULL);
- if (file_info == NULL)
- {
- return FALSE;
- }
- type = g_strdup (g_file_info_get_content_type (file_info));
-
- g_object_unref (file_info);
-
- if (type != NULL && type[0] != '\0' &&
- ephy_file_check_mime (type) == EPHY_MIME_PERMISSION_SAFE)
- {
- app = g_app_info_get_default_for_type (type, FALSE);
- }
- g_free (type);
- }
-
- return app;
+ GAppInfo *app = NULL;
+
+ g_return_val_if_fail (file || mime_type, FALSE);
+
+ if (mime_type != NULL) {
+ app = g_app_info_get_default_for_type (mime_type,
+ FALSE);
+ } else {
+ GFileInfo *file_info;
+ char *type;
+
+ /* Sniff mime type and check if it's safe to open */
+ file_info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+ 0, NULL, NULL);
+ if (file_info == NULL) {
+ return FALSE;
+ }
+ type = g_strdup (g_file_info_get_content_type (file_info));
+
+ g_object_unref (file_info);
+
+ if (type != NULL && type[0] != '\0' &&
+ ephy_file_check_mime (type) == EPHY_MIME_PERMISSION_SAFE) {
+ app = g_app_info_get_default_for_type (type, FALSE);
+ }
+ g_free (type);
+ }
+
+ return app;
}
/**
@@ -809,58 +755,56 @@ ephy_file_launcher_get_app_info_for_file (GFile *file,
**/
gboolean
ephy_file_launch_handler (const char *mime_type,
- GFile *file,
- guint32 user_time)
+ GFile *file,
+ guint32 user_time)
{
- GAppInfo *app = NULL;
- gboolean ret = FALSE;
+ GAppInfo *app = NULL;
+ gboolean ret = FALSE;
+
+ g_return_val_if_fail (file != NULL, FALSE);
- g_return_val_if_fail (file != NULL, FALSE);
+ app = ephy_file_launcher_get_app_info_for_file (file, mime_type);
- app = ephy_file_launcher_get_app_info_for_file (file, mime_type);
+ if (app != NULL) {
+ GList *list = NULL;
- if (app != NULL)
- {
- GList *list = NULL;
-
- list = g_list_append (list, file);
- ret = ephy_file_launch_application (app, list, user_time, NULL);
- g_list_free (list);
- }
+ list = g_list_append (list, file);
+ ret = ephy_file_launch_application (app, list, user_time, NULL);
+ g_list_free (list);
+ }
- return ret;
+ return ret;
}
gboolean
ephy_file_open_uri_in_default_browser (const char *uri,
- guint32 timestamp,
- GdkScreen *screen)
+ guint32 timestamp,
+ GdkScreen *screen)
{
- GdkAppLaunchContext *context;
- GAppInfo *appinfo;
- GList uris;
- gboolean retval = TRUE;
- GError *error = NULL;
-
- context = gdk_display_get_app_launch_context (screen ? gdk_screen_get_display (screen) :
gdk_display_get_default ());
- gdk_app_launch_context_set_screen (context, screen);
- gdk_app_launch_context_set_timestamp (context, timestamp);
-
- appinfo = g_app_info_get_default_for_type ("x-scheme-handler/http", TRUE);
- uris.data = (gpointer)uri;
- uris.next = uris.prev = NULL;
-
- if (!g_app_info_launch_uris (appinfo, &uris, G_APP_LAUNCH_CONTEXT (context), &error))
- {
- g_warning ("Failed to launch %s: %s", uri, error->message);
- g_error_free (error);
- retval = FALSE;
- }
-
- g_object_unref (context);
- g_object_unref (appinfo);
-
- return retval;
+ GdkAppLaunchContext *context;
+ GAppInfo *appinfo;
+ GList uris;
+ gboolean retval = TRUE;
+ GError *error = NULL;
+
+ context = gdk_display_get_app_launch_context (screen ? gdk_screen_get_display (screen) :
gdk_display_get_default ());
+ gdk_app_launch_context_set_screen (context, screen);
+ gdk_app_launch_context_set_timestamp (context, timestamp);
+
+ appinfo = g_app_info_get_default_for_type ("x-scheme-handler/http", TRUE);
+ uris.data = (gpointer)uri;
+ uris.next = uris.prev = NULL;
+
+ if (!g_app_info_launch_uris (appinfo, &uris, G_APP_LAUNCH_CONTEXT (context), &error)) {
+ g_warning ("Failed to launch %s: %s", uri, error->message);
+ g_error_free (error);
+ retval = FALSE;
+ }
+
+ g_object_unref (context);
+ g_object_unref (appinfo);
+
+ return retval;
}
/**
@@ -875,10 +819,10 @@ ephy_file_open_uri_in_default_browser (const char *uri,
* Returns: %TRUE if the launch succeeded
**/
gboolean
-ephy_file_browse_to (GFile *file,
- guint32 user_time)
+ephy_file_browse_to (GFile *file,
+ guint32 user_time)
{
- return ephy_file_launch_handler ("inode/directory", file, user_time);
+ return ephy_file_launch_handler ("inode/directory", file, user_time);
}
/**
@@ -893,60 +837,54 @@ ephy_file_browse_to (GFile *file,
gboolean
ephy_file_delete_dir_recursively (const char *directory, GError **error)
{
- GDir* dir;
- const char* file_name;
- gboolean failed = FALSE;
-
- dir = g_dir_open (directory, 0, error);
- if (!dir)
- return FALSE;
-
- file_name = g_dir_read_name (dir);
- while (file_name && !failed) {
- char *file_path;
-
- file_path = g_build_filename (directory, file_name, NULL);
- if (g_file_test (file_path, G_FILE_TEST_IS_DIR))
- {
- failed = !ephy_file_delete_dir_recursively (file_path, error);
- }
- else
- {
- int result = g_unlink (file_path);
-
- if (result == -1)
- {
- int errsv = errno;
-
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errsv),
- "Error removing file %s: %s",
- file_path, g_strerror (errsv));
- failed = TRUE;
- }
- }
- g_free (file_path);
- file_name = g_dir_read_name (dir);
- }
- g_dir_close (dir);
-
- if (!failed)
- {
- int result = g_rmdir (directory);
-
- if (result == -1)
- {
- int errsv = errno;
-
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errsv),
- "Error removing directory %s: %s",
- directory, g_strerror (errsv));
- failed = TRUE;
- }
- }
-
- return !failed;
+ GDir *dir;
+ const char *file_name;
+ gboolean failed = FALSE;
+
+ dir = g_dir_open (directory, 0, error);
+ if (!dir)
+ return FALSE;
+
+ file_name = g_dir_read_name (dir);
+ while (file_name && !failed) {
+ char *file_path;
+
+ file_path = g_build_filename (directory, file_name, NULL);
+ if (g_file_test (file_path, G_FILE_TEST_IS_DIR)) {
+ failed = !ephy_file_delete_dir_recursively (file_path, error);
+ } else {
+ int result = g_unlink (file_path);
+
+ if (result == -1) {
+ int errsv = errno;
+
+ g_set_error (error, G_IO_ERROR,
+ g_io_error_from_errno (errsv),
+ "Error removing file %s: %s",
+ file_path, g_strerror (errsv));
+ failed = TRUE;
+ }
+ }
+ g_free (file_path);
+ file_name = g_dir_read_name (dir);
+ }
+ g_dir_close (dir);
+
+ if (!failed) {
+ int result = g_rmdir (directory);
+
+ if (result == -1) {
+ int errsv = errno;
+
+ g_set_error (error, G_IO_ERROR,
+ g_io_error_from_errno (errsv),
+ "Error removing directory %s: %s",
+ directory, g_strerror (errsv));
+ failed = TRUE;
+ }
+ }
+
+ return !failed;
}
/**
@@ -958,24 +896,21 @@ ephy_file_delete_dir_recursively (const char *directory, GError **error)
void
ephy_file_delete_uri (const char *uri)
{
- GFile *file;
- gboolean ret;
+ GFile *file;
+ gboolean ret;
- g_return_if_fail (uri);
+ g_return_if_fail (uri);
- file = g_file_new_for_uri (uri);
+ file = g_file_new_for_uri (uri);
- ret = g_file_delete (file, NULL, NULL);
+ ret = g_file_delete (file, NULL, NULL);
- if (ret == TRUE)
- {
- LOG ("Deleted file at URI '%s'", uri);
- }
- else
- {
- LOG ("Couldn't file at URI '%s'", uri);
- }
- g_object_unref (file);
+ if (ret == TRUE) {
+ LOG ("Deleted file at URI '%s'", uri);
+ } else {
+ LOG ("Couldn't file at URI '%s'", uri);
+ }
+ g_object_unref (file);
}
/**
@@ -990,29 +925,26 @@ ephy_file_delete_uri (const char *uri)
gboolean
ephy_file_move_uri (const char *source_uri, const char *dest_uri)
{
- GFile *src;
- GFile *dest;
- gboolean ret;
-
- g_return_val_if_fail (source_uri && dest_uri, FALSE);
-
- src = g_file_new_for_uri (source_uri);
- dest = g_file_new_for_uri (dest_uri);
-
- ret = g_file_move (src, dest, G_FILE_COPY_OVERWRITE | G_FILE_COPY_ALL_METADATA,
- NULL, NULL, NULL, NULL);
-
- if (ret == TRUE)
- {
- LOG ("Moved file '%s' to '%s'", source_uri, dest_uri);
- }
- else
- {
- LOG ("Couldn't move file '%s' to '%s'", source_uri, dest_uri);
- }
- g_object_unref (src);
- g_object_unref (dest);
- return ret;
+ GFile *src;
+ GFile *dest;
+ gboolean ret;
+
+ g_return_val_if_fail (source_uri && dest_uri, FALSE);
+
+ src = g_file_new_for_uri (source_uri);
+ dest = g_file_new_for_uri (dest_uri);
+
+ ret = g_file_move (src, dest, G_FILE_COPY_OVERWRITE | G_FILE_COPY_ALL_METADATA,
+ NULL, NULL, NULL, NULL);
+
+ if (ret == TRUE) {
+ LOG ("Moved file '%s' to '%s'", source_uri, dest_uri);
+ } else {
+ LOG ("Couldn't move file '%s' to '%s'", source_uri, dest_uri);
+ }
+ g_object_unref (src);
+ g_object_unref (dest);
+ return ret;
}
/**
@@ -1029,42 +961,42 @@ ephy_file_move_uri (const char *source_uri, const char *dest_uri)
*/
char *
ephy_file_create_data_uri_for_filename (const char *filename,
- const char *mime_type)
+ const char *mime_type)
{
- gchar *data;
- gsize data_length;
- gchar *base64;
- gchar *uri = NULL;
- GFileInfo *file_info = NULL;
+ gchar *data;
+ gsize data_length;
+ gchar *base64;
+ gchar *uri = NULL;
+ GFileInfo *file_info = NULL;
- g_return_val_if_fail (filename != NULL, NULL);
+ g_return_val_if_fail (filename != NULL, NULL);
- if (!g_file_get_contents (filename, &data, &data_length, NULL))
- return NULL;
+ if (!g_file_get_contents (filename, &data, &data_length, NULL))
+ return NULL;
- base64 = g_base64_encode ((const guchar *)data, data_length);
- g_free (data);
+ base64 = g_base64_encode ((const guchar *)data, data_length);
+ g_free (data);
- if (!mime_type) {
- GFile *file;
+ if (!mime_type) {
+ GFile *file;
- file = g_file_new_for_path (filename);
- file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
- G_FILE_QUERY_INFO_NONE, NULL, NULL);
- if (file_info)
- mime_type = g_file_info_get_content_type (file_info);
+ file = g_file_new_for_path (filename);
+ file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+ G_FILE_QUERY_INFO_NONE, NULL, NULL);
+ if (file_info)
+ mime_type = g_file_info_get_content_type (file_info);
- g_object_unref (file);
- }
+ g_object_unref (file);
+ }
- if (mime_type)
- uri = g_strdup_printf ("data:%s;charset=utf8;base64,%s", mime_type, base64);
- g_free(base64);
+ if (mime_type)
+ uri = g_strdup_printf ("data:%s;charset=utf8;base64,%s", mime_type, base64);
+ g_free (base64);
- if (file_info)
- g_object_unref (file_info);
+ if (file_info)
+ g_object_unref (file_info);
- return uri;
+ return uri;
}
/**
@@ -1083,31 +1015,31 @@ ephy_file_create_data_uri_for_filename (const char *filename,
char *
ephy_sanitize_filename (char *filename)
{
- g_return_val_if_fail (filename != NULL, NULL);
+ g_return_val_if_fail (filename != NULL, NULL);
- return g_strdelimit (filename, G_DIR_SEPARATOR_S, '_');
+ return g_strdelimit (filename, G_DIR_SEPARATOR_S, '_');
}
void
ephy_open_incognito_window (const char *uri)
{
- char *command;
- GError *error = NULL;
+ char *command;
+ GError *error = NULL;
- command = g_strdup_printf ("epiphany --incognito-mode --profile %s ", ephy_dot_dir ());
+ command = g_strdup_printf ("epiphany --incognito-mode --profile %s ", ephy_dot_dir ());
- if (uri) {
- char *str = g_strconcat (command, uri, NULL);
- g_free (command);
- command = str;
- }
+ if (uri) {
+ char *str = g_strconcat (command, uri, NULL);
+ g_free (command);
+ command = str;
+ }
- g_spawn_command_line_async (command, &error);
+ g_spawn_command_line_async (command, &error);
- if (error) {
- g_warning ("Couldn't open link in incognito window: %s", error->message);
- g_error_free (error);
- }
+ if (error) {
+ g_warning ("Couldn't open link in incognito window: %s", error->message);
+ g_error_free (error);
+ }
- g_free (command);
+ g_free (command);
}
diff --git a/lib/ephy-form-auth-data.c b/lib/ephy-form-auth-data.c
index 020c13a..7985e31 100644
--- a/lib/ephy-form-auth-data.c
+++ b/lib/ephy-form-auth-data.c
@@ -42,8 +42,8 @@ ephy_form_auth_data_get_password_schema (void)
}
static void
-normalize_and_prepare_uri (SoupURI *uri,
- gboolean remove_path)
+normalize_and_prepare_uri (SoupURI *uri,
+ gboolean remove_path)
{
g_assert (uri != NULL);
@@ -81,8 +81,8 @@ ephy_form_auth_data_get_secret_attributes_table (const char *uri,
static void
store_form_password_cb (SecretService *service,
- GAsyncResult *res,
- GTask *task)
+ GAsyncResult *res,
+ GTask *task)
{
GError *error = NULL;
@@ -96,13 +96,13 @@ store_form_password_cb (SecretService *service,
}
void
-ephy_form_auth_data_store (const char *uri,
- const char *form_username,
- const char *form_password,
- const char *username,
- const char *password,
+ephy_form_auth_data_store (const char *uri,
+ const char *form_username,
+ const char *form_password,
+ const char *username,
+ const char *password,
GAsyncReadyCallback callback,
- gpointer userdata)
+ gpointer userdata)
{
SoupURI *fake_uri;
char *fake_uri_str;
@@ -160,7 +160,7 @@ ephy_form_auth_data_store (const char *uri,
gboolean
ephy_form_auth_data_store_finish (GAsyncResult *result,
- GError **error)
+ GError **error)
{
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
g_return_val_if_fail (g_task_is_valid (result, NULL), FALSE);
@@ -168,8 +168,7 @@ ephy_form_auth_data_store_finish (GAsyncResult *result,
return g_task_propagate_boolean (G_TASK (result), error);
}
-typedef struct
-{
+typedef struct {
EphyFormAuthDataQueryCallback callback;
gpointer data;
GDestroyNotify destroy_data;
@@ -185,13 +184,13 @@ ephy_form_auth_data_query_closure_free (EphyFormAuthDataQueryClosure *closure)
}
static void
-search_form_data_cb (SecretService *service,
- GAsyncResult *res,
+search_form_data_cb (SecretService *service,
+ GAsyncResult *res,
EphyFormAuthDataQueryClosure *closure)
{
GList *results;
SecretItem *item;
- const char* username = NULL, *password = NULL;
+ const char *username = NULL, *password = NULL;
SecretValue *value = NULL;
GHashTable *attributes = NULL;
GError *error = NULL;
@@ -206,7 +205,7 @@ search_form_data_cb (SecretService *service,
if (!results)
goto out;
- item = (SecretItem*)results->data;
+ item = (SecretItem *)results->data;
attributes = secret_item_get_attributes (item);
username = g_hash_table_lookup (attributes, USERNAME_KEY);
value = secret_item_get_secret (item);
@@ -214,7 +213,7 @@ search_form_data_cb (SecretService *service,
g_list_free_full (results, (GDestroyNotify)g_object_unref);
-out:
+ out:
if (closure->callback)
closure->callback (username, password, closure->data);
@@ -227,13 +226,13 @@ out:
}
void
-ephy_form_auth_data_query (const char *uri,
- const char *form_username,
- const char *form_password,
- const char *username,
+ephy_form_auth_data_query (const char *uri,
+ const char *form_username,
+ const char *form_password,
+ const char *username,
EphyFormAuthDataQueryCallback callback,
- gpointer user_data,
- GDestroyNotify destroy_data)
+ gpointer user_data,
+ GDestroyNotify destroy_data)
{
SoupURI *key;
char *key_str;
@@ -301,8 +300,8 @@ ephy_form_auth_data_free (EphyFormAuthData *data)
}
static void
-screcet_service_search_finished (SecretService *service,
- GAsyncResult *result,
+screcet_service_search_finished (SecretService *service,
+ GAsyncResult *result,
EphyFormAuthDataCache *cache)
{
GList *results, *p;
@@ -391,10 +390,10 @@ ephy_form_auth_data_cache_free (EphyFormAuthDataCache *cache)
void
ephy_form_auth_data_cache_add (EphyFormAuthDataCache *cache,
- const char *uri,
- const char *form_username,
- const char *form_password,
- const char *username)
+ const char *uri,
+ const char *form_username,
+ const char *form_password,
+ const char *username)
{
EphyFormAuthData *data;
GSList *l;
@@ -412,7 +411,7 @@ ephy_form_auth_data_cache_add (EphyFormAuthDataCache *cache,
GSList *
ephy_form_auth_data_cache_get_list (EphyFormAuthDataCache *cache,
- const char *uri)
+ const char *uri)
{
g_return_val_if_fail (cache, NULL);
g_return_val_if_fail (uri, NULL);
diff --git a/lib/ephy-gui.c b/lib/ephy-gui.c
index 331d3d1..bc5bc77 100644
--- a/lib/ephy-gui.c
+++ b/lib/ephy-gui.c
@@ -28,70 +28,69 @@
#include <unistd.h>
void
-ephy_gui_sanitise_popup_position (GtkMenu *menu,
- GtkWidget *widget,
- gint *x,
- gint *y)
+ephy_gui_sanitise_popup_position (GtkMenu *menu,
+ GtkWidget *widget,
+ gint *x,
+ gint *y)
{
- GdkScreen *screen = gtk_widget_get_screen (widget);
- gint monitor_num;
- GdkRectangle monitor;
- GtkRequisition req;
+ GdkScreen *screen = gtk_widget_get_screen (widget);
+ gint monitor_num;
+ GdkRectangle monitor;
+ GtkRequisition req;
- g_return_if_fail (widget != NULL);
+ g_return_if_fail (widget != NULL);
- gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
- monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
- gtk_menu_set_monitor (menu, monitor_num);
- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+ monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
+ gtk_menu_set_monitor (menu, monitor_num);
+ gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
- *x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width));
- *y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));
+ *x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width));
+ *y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));
}
void
-ephy_gui_menu_position_tree_selection (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data)
+ephy_gui_menu_position_tree_selection (GtkMenu *menu,
+ gint *x,
+ gint *y,
+ gboolean *push_in,
+ gpointer user_data)
{
- GtkTreeSelection *selection;
- GList *selected_rows;
- GtkTreeModel *model;
- GtkTreeView *tree_view = GTK_TREE_VIEW (user_data);
- GtkWidget *widget = GTK_WIDGET (user_data);
- GtkRequisition req;
- GtkAllocation allocation;
- GdkRectangle visible;
+ GtkTreeSelection *selection;
+ GList *selected_rows;
+ GtkTreeModel *model;
+ GtkTreeView *tree_view = GTK_TREE_VIEW (user_data);
+ GtkWidget *widget = GTK_WIDGET (user_data);
+ GtkRequisition req;
+ GtkAllocation allocation;
+ GdkRectangle visible;
- gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
- gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
- gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
+ gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
+ gtk_widget_get_allocation (widget, &allocation);
- *x += (allocation.width - req.width) / 2;
+ *x += (allocation.width - req.width) / 2;
- /* Add on height for the treeview title */
- gtk_tree_view_get_visible_rect (tree_view, &visible);
- *y += allocation.height - visible.height;
+ /* Add on height for the treeview title */
+ gtk_tree_view_get_visible_rect (tree_view, &visible);
+ *y += allocation.height - visible.height;
- selection = gtk_tree_view_get_selection (tree_view);
- selected_rows = gtk_tree_selection_get_selected_rows (selection, &model);
- if (selected_rows)
- {
- GdkRectangle cell_rect;
+ selection = gtk_tree_view_get_selection (tree_view);
+ selected_rows = gtk_tree_selection_get_selected_rows (selection, &model);
+ if (selected_rows) {
+ GdkRectangle cell_rect;
- gtk_tree_view_get_cell_area (tree_view, selected_rows->data,
- NULL, &cell_rect);
+ gtk_tree_view_get_cell_area (tree_view, selected_rows->data,
+ NULL, &cell_rect);
- *y += CLAMP (cell_rect.y + cell_rect.height, 0, visible.height);
+ *y += CLAMP (cell_rect.y + cell_rect.height, 0, visible.height);
- g_list_foreach (selected_rows, (GFunc)gtk_tree_path_free, NULL);
- g_list_free (selected_rows);
- }
+ g_list_foreach (selected_rows, (GFunc)gtk_tree_path_free, NULL);
+ g_list_free (selected_rows);
+ }
- ephy_gui_sanitise_popup_position (menu, widget, x, y);
+ ephy_gui_sanitise_popup_position (menu, widget, x, y);
}
/**
@@ -101,167 +100,160 @@ ephy_gui_menu_position_tree_selection (GtkMenu *menu,
* @y:
* @push_in:
* @user_data: a #GtkWidget
- *
+ *
* Positions @menu under (or over, depending on space available) the widget
* @user_data.
*/
void
-ephy_gui_menu_position_under_widget (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data)
+ephy_gui_menu_position_under_widget (GtkMenu *menu,
+ gint *x,
+ gint *y,
+ gboolean *push_in,
+ gpointer user_data)
{
- /* Adapted from gtktoolbar.c */
- GtkWidget *widget = GTK_WIDGET (user_data);
- GtkWidget *container;
- GtkRequisition req;
- GtkRequisition menu_req;
- GtkAllocation allocation;
- GdkRectangle monitor;
- GdkWindow *window;
- int monitor_num;
- GdkScreen *screen;
-
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- container = gtk_widget_get_ancestor (widget, GTK_TYPE_CONTAINER);
- g_return_if_fail (container != NULL);
-
- gtk_widget_get_preferred_size (widget, &req, NULL);
- gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_req, NULL);
-
- screen = gtk_widget_get_screen (GTK_WIDGET (menu));
- window = gtk_widget_get_window (widget);
- monitor_num = gdk_screen_get_monitor_at_window (screen, window);
- if (monitor_num < 0)
- monitor_num = 0;
- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
-
- gtk_widget_get_allocation (widget, &allocation);
- gdk_window_get_origin (window, x, y);
- if (!gtk_widget_get_has_window (widget))
- {
- *x += allocation.x;
- *y += allocation.y;
- }
-
- if (gtk_widget_get_direction (container) == GTK_TEXT_DIR_LTR)
- *x += allocation.width - req.width;
- else
- *x += req.width - menu_req.width;
-
- if ((*y + allocation.height + menu_req.height) <= monitor.y + monitor.height)
- *y += allocation.height;
- else if ((*y - menu_req.height) >= monitor.y)
- *y -= menu_req.height;
- else if (monitor.y + monitor.height - (*y + allocation.height) > *y)
- *y += allocation.height;
- else
- *y -= menu_req.height;
-
- *push_in = FALSE;
+ /* Adapted from gtktoolbar.c */
+ GtkWidget *widget = GTK_WIDGET (user_data);
+ GtkWidget *container;
+ GtkRequisition req;
+ GtkRequisition menu_req;
+ GtkAllocation allocation;
+ GdkRectangle monitor;
+ GdkWindow *window;
+ int monitor_num;
+ GdkScreen *screen;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ container = gtk_widget_get_ancestor (widget, GTK_TYPE_CONTAINER);
+ g_return_if_fail (container != NULL);
+
+ gtk_widget_get_preferred_size (widget, &req, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_req, NULL);
+
+ screen = gtk_widget_get_screen (GTK_WIDGET (menu));
+ window = gtk_widget_get_window (widget);
+ monitor_num = gdk_screen_get_monitor_at_window (screen, window);
+ if (monitor_num < 0)
+ monitor_num = 0;
+ gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+
+ gtk_widget_get_allocation (widget, &allocation);
+ gdk_window_get_origin (window, x, y);
+ if (!gtk_widget_get_has_window (widget)) {
+ *x += allocation.x;
+ *y += allocation.y;
+ }
+
+ if (gtk_widget_get_direction (container) == GTK_TEXT_DIR_LTR)
+ *x += allocation.width - req.width;
+ else
+ *x += req.width - menu_req.width;
+
+ if ((*y + allocation.height + menu_req.height) <= monitor.y + monitor.height)
+ *y += allocation.height;
+ else if ((*y - menu_req.height) >= monitor.y)
+ *y -= menu_req.height;
+ else if (monitor.y + monitor.height - (*y + allocation.height) > *y)
+ *y += allocation.height;
+ else
+ *y -= menu_req.height;
+
+ *push_in = FALSE;
}
GtkWindowGroup *
ephy_gui_ensure_window_group (GtkWindow *window)
{
- GtkWindowGroup *group;
+ GtkWindowGroup *group;
- group = gtk_window_get_group (window);
- if (group == NULL)
- {
- group = gtk_window_group_new ();
- gtk_window_group_add_window (group, window);
- g_object_unref (group);
- }
+ group = gtk_window_get_group (window);
+ if (group == NULL) {
+ group = gtk_window_group_new ();
+ gtk_window_group_add_window (group, window);
+ g_object_unref (group);
+ }
- return group;
+ return group;
}
gboolean
-ephy_gui_check_location_writable (GtkWidget *parent,
- const char *filename)
+ephy_gui_check_location_writable (GtkWidget *parent,
+ const char *filename)
{
- GtkWidget *dialog;
- char *display_name;
+ GtkWidget *dialog;
+ char *display_name;
- if (filename == NULL) return FALSE;
+ if (filename == NULL) return FALSE;
- if (!g_file_test (filename, G_FILE_TEST_EXISTS))
- {
- char *path = g_path_get_dirname (filename);
- gboolean writable = access (path, W_OK) == 0;
+ if (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
+ char *path = g_path_get_dirname (filename);
+ gboolean writable = access (path, W_OK) == 0;
- /* check if path is writable to */
- if (!writable)
- {
- dialog = gtk_message_dialog_new (
- parent ? GTK_WINDOW(parent) : NULL,
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- _("Directory “%s” is not writable"), path);
+ /* check if path is writable to */
+ if (!writable) {
+ dialog = gtk_message_dialog_new (
+ parent ? GTK_WINDOW (parent) : NULL,
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("Directory “%s” is not writable"), path);
- gtk_message_dialog_format_secondary_text (
- GTK_MESSAGE_DIALOG (dialog),
- _("You do not have permission to "
- "create files in this directory."));
+ gtk_message_dialog_format_secondary_text (
+ GTK_MESSAGE_DIALOG (dialog),
+ _("You do not have permission to "
+ "create files in this directory."));
- gtk_window_set_title (GTK_WINDOW (dialog), _("Directory not Writable"));
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Directory not Writable"));
- if (parent != NULL)
- {
- gtk_window_group_add_window (
- ephy_gui_ensure_window_group (GTK_WINDOW (parent)),
- GTK_WINDOW (dialog));
- }
+ if (parent != NULL) {
+ gtk_window_group_add_window (
+ ephy_gui_ensure_window_group (GTK_WINDOW (parent)),
+ GTK_WINDOW (dialog));
+ }
- gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- }
+ gtk_widget_destroy (dialog);
+ }
- g_free (path);
+ g_free (path);
- return writable;
- }
+ return writable;
+ }
- display_name = g_filename_display_basename (filename);
+ display_name = g_filename_display_basename (filename);
- /* check if file is writable */
- if (access (filename, W_OK) != 0)
- {
- dialog = gtk_message_dialog_new (
- parent ? GTK_WINDOW(parent) : NULL,
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- _("Cannot overwrite existing file “%s”"), display_name);
+ /* check if file is writable */
+ if (access (filename, W_OK) != 0) {
+ dialog = gtk_message_dialog_new (
+ parent ? GTK_WINDOW (parent) : NULL,
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("Cannot overwrite existing file “%s”"), display_name);
- gtk_message_dialog_format_secondary_text (
- GTK_MESSAGE_DIALOG (dialog),
- _("A file with this name already exists and "
- "you don't have permission to overwrite it."));
+ gtk_message_dialog_format_secondary_text (
+ GTK_MESSAGE_DIALOG (dialog),
+ _("A file with this name already exists and "
+ "you don't have permission to overwrite it."));
- gtk_window_set_title (GTK_WINDOW (dialog), _("Cannot Overwrite File"));
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Cannot Overwrite File"));
- if (parent != NULL)
- {
- gtk_window_group_add_window (
- ephy_gui_ensure_window_group (GTK_WINDOW (parent)),
- GTK_WINDOW (dialog));
- }
+ if (parent != NULL) {
+ gtk_window_group_add_window (
+ ephy_gui_ensure_window_group (GTK_WINDOW (parent)),
+ GTK_WINDOW (dialog));
+ }
- gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_widget_destroy (dialog);
- return FALSE;
- }
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
/**
@@ -275,130 +267,119 @@ ephy_gui_check_location_writable (GtkWidget *parent,
* window.
**/
void
-ephy_gui_help (GtkWidget *parent,
- const char *page)
+ephy_gui_help (GtkWidget *parent,
+ const char *page)
{
- GError *error = NULL;
- GdkScreen *screen;
- char *url;
-
- if (page)
- url = g_strdup_printf ("help:epiphany/%s", page);
- else
- url = g_strdup ("help:epiphany");
-
- if (parent)
- screen = gtk_widget_get_screen (parent);
- else
- screen = gdk_screen_get_default ();
-
- gtk_show_uri (screen, url, gtk_get_current_event_time (), &error);
-
- if (error != NULL)
- {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("Could not display help: %s"),
- error->message);
- g_error_free (error);
-
- g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
- gtk_widget_show (dialog);
- }
-
- g_free (url);
+ GError *error = NULL;
+ GdkScreen *screen;
+ char *url;
+
+ if (page)
+ url = g_strdup_printf ("help:epiphany/%s", page);
+ else
+ url = g_strdup ("help:epiphany");
+
+ if (parent)
+ screen = gtk_widget_get_screen (parent);
+ else
+ screen = gdk_screen_get_default ();
+
+ gtk_show_uri (screen, url, gtk_get_current_event_time (), &error);
+
+ if (error != NULL) {
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Could not display help: %s"),
+ error->message);
+ g_error_free (error);
+
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (gtk_widget_destroy), NULL);
+ gtk_widget_show (dialog);
+ }
+
+ g_free (url);
}
void
ephy_gui_get_current_event (GdkEventType *otype,
- guint *ostate,
- guint *obutton)
+ guint *ostate,
+ guint *obutton)
{
- GdkEvent *event;
- GdkEventType type = GDK_NOTHING;
- guint state = 0, button = (guint) -1;
-
- event = gtk_get_current_event ();
- if (event != NULL)
- {
- type = event->type;
-
- if (type == GDK_KEY_PRESS ||
- type == GDK_KEY_RELEASE)
- {
- state = event->key.state;
- }
- else if (type == GDK_BUTTON_PRESS ||
- type == GDK_BUTTON_RELEASE ||
- type == GDK_2BUTTON_PRESS ||
- type == GDK_3BUTTON_PRESS)
- {
- button = event->button.button;
- state = event->button.state;
- }
-
- gdk_event_free (event);
- }
-
- if (otype) *otype = type;
- if (ostate) *ostate = state & gtk_accelerator_get_default_mod_mask ();
- if (obutton) *obutton = button;
+ GdkEvent *event;
+ GdkEventType type = GDK_NOTHING;
+ guint state = 0, button = (guint) - 1;
+
+ event = gtk_get_current_event ();
+ if (event != NULL) {
+ type = event->type;
+
+ if (type == GDK_KEY_PRESS ||
+ type == GDK_KEY_RELEASE) {
+ state = event->key.state;
+ } else if (type == GDK_BUTTON_PRESS ||
+ type == GDK_BUTTON_RELEASE ||
+ type == GDK_2BUTTON_PRESS ||
+ type == GDK_3BUTTON_PRESS) {
+ button = event->button.button;
+ state = event->button.state;
+ }
+
+ gdk_event_free (event);
+ }
+
+ if (otype) *otype = type;
+ if (ostate) *ostate = state & gtk_accelerator_get_default_mod_mask ();
+ if (obutton) *obutton = button;
}
gboolean
ephy_gui_is_middle_click (void)
{
- gboolean is_middle_click = FALSE;
- GdkEvent *event;
-
- event = gtk_get_current_event ();
- if (event != NULL)
- {
- if (event->type == GDK_BUTTON_RELEASE)
- {
- guint modifiers, button, state;
-
- modifiers = gtk_accelerator_get_default_mod_mask ();
- button = event->button.button;
- state = event->button.state;
-
- /* middle-click or control-click */
- if ((button == 1 && ((state & modifiers) == GDK_CONTROL_MASK)) ||
- (button == 2 && ((state & modifiers) == 0)))
- {
- is_middle_click = TRUE;
- }
- }
-
- gdk_event_free (event);
- }
-
- return is_middle_click;
+ gboolean is_middle_click = FALSE;
+ GdkEvent *event;
+
+ event = gtk_get_current_event ();
+ if (event != NULL) {
+ if (event->type == GDK_BUTTON_RELEASE) {
+ guint modifiers, button, state;
+
+ modifiers = gtk_accelerator_get_default_mod_mask ();
+ button = event->button.button;
+ state = event->button.state;
+
+ /* middle-click or control-click */
+ if ((button == 1 && ((state & modifiers) == GDK_CONTROL_MASK)) ||
+ (button == 2 && ((state & modifiers) == 0))) {
+ is_middle_click = TRUE;
+ }
+ }
+
+ gdk_event_free (event);
+ }
+
+ return is_middle_click;
}
void
ephy_gui_window_update_user_time (GtkWidget *window,
- guint32 user_time)
+ guint32 user_time)
{
- LOG ("updating user time on window %p to %d", window, user_time);
+ LOG ("updating user time on window %p to %d", window, user_time);
- if (user_time != 0)
- {
- gtk_widget_realize (window);
+ if (user_time != 0) {
+ gtk_widget_realize (window);
#ifdef GDK_WINDOWING_X11
- if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
- {
- gdk_x11_window_set_user_time (gtk_widget_get_window (window),
- user_time);
- }
+ if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+ gdk_x11_window_set_user_time (gtk_widget_get_window (window),
+ user_time);
+ }
#endif
- }
-
+ }
}
diff --git a/lib/ephy-initial-state.c b/lib/ephy-initial-state.c
index 99cbb38..2b4aa18 100644
--- a/lib/ephy-initial-state.c
+++ b/lib/ephy-initial-state.c
@@ -33,8 +33,7 @@
#define EPHY_STATES_XML_ROOT (const xmlChar *)"ephy_states"
#define EPHY_STATES_XML_VERSION (const xmlChar *)"1.0"
-enum
-{
+enum {
EPHY_NODE_INITIAL_STATE_PROP_NAME = 2,
EPHY_NODE_INITIAL_STATE_PROP_WIDTH = 3,
EPHY_NODE_INITIAL_STATE_PROP_HEIGHT = 4,
@@ -58,15 +57,15 @@ ephy_states_save (void)
EPHY_STATES_XML_FILE,
NULL);
- ephy_node_db_write_to_xml_safe (states_db,
+ ephy_node_db_write_to_xml_safe (states_db,
(const xmlChar *)xml_file,
EPHY_STATES_XML_ROOT,
EPHY_STATES_XML_VERSION,
NULL, /* comment */
states, NULL, NULL,
NULL);
-
- g_free (xml_file);
+
+ g_free (xml_file);
}
static EphyNode *
@@ -84,7 +83,7 @@ find_by_name (const char *name)
kid = g_ptr_array_index (children, i);
node_name = ephy_node_get_property_string
- (kid, EPHY_NODE_INITIAL_STATE_PROP_NAME);
+ (kid, EPHY_NODE_INITIAL_STATE_PROP_NAME);
if (strcmp (node_name, name) == 0)
result = kid;
@@ -108,7 +107,7 @@ ensure_states (void)
ephy_node_db_load_from_file (states_db, xml_file,
EPHY_STATES_XML_ROOT,
EPHY_STATES_XML_VERSION);
-
+
g_free (xml_file);
}
}
@@ -165,7 +164,7 @@ ephy_state_window_set_position (GtkWidget *window, EphyNode *node)
y = ephy_node_get_property_int (node, EPHY_NODE_INITIAL_STATE_PROP_POSITION_Y);
screen = gtk_window_get_screen (GTK_WINDOW (window));
- screen_width = gdk_screen_get_width (screen);
+ screen_width = gdk_screen_get_width (screen);
screen_height = gdk_screen_get_height (screen);
if ((x <= screen_width) && (y <= screen_height) &&
@@ -207,12 +206,12 @@ ephy_state_window_save_size (GtkWidget *window, EphyNode *node)
state = gdk_window_get_state (gtk_widget_get_window (GTK_WIDGET (window)));
maximize = ((state & GDK_WINDOW_STATE_MAXIMIZED) > 0);
- gtk_window_get_size (GTK_WINDOW(window),
+ gtk_window_get_size (GTK_WINDOW (window),
&width, &height);
if (!maximize)
ephy_state_save_unmaximized_size (node, width, height);
-
+
ephy_node_set_property_boolean (node,
EPHY_NODE_INITIAL_STATE_PROP_MAXIMIZE,
maximize);
@@ -221,7 +220,7 @@ ephy_state_window_save_size (GtkWidget *window, EphyNode *node)
static void
ephy_state_window_save_position (GtkWidget *window, EphyNode *node)
{
- int x,y;
+ int x, y;
gboolean maximize;
GdkWindowState state;
@@ -250,9 +249,9 @@ ephy_state_window_save (GtkWidget *widget, EphyNode *node)
}
static gboolean
-window_configure_event_cb (GtkWidget *widget,
+window_configure_event_cb (GtkWidget *widget,
GdkEventConfigure *event,
- EphyNode *node)
+ EphyNode *node)
{
GdkWindowState state;
@@ -265,9 +264,9 @@ window_configure_event_cb (GtkWidget *widget,
}
static gboolean
-window_state_event_cb (GtkWidget *widget,
+window_state_event_cb (GtkWidget *widget,
GdkEventWindowState *event,
- EphyNode *node)
+ EphyNode *node)
{
if (!(event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN))
ephy_state_window_save (widget, node);
@@ -276,10 +275,10 @@ window_state_event_cb (GtkWidget *widget,
}
static EphyNode *
-create_window_node (const char *name,
- int default_width,
- int default_height,
- gboolean maximize,
+create_window_node (const char *name,
+ int default_width,
+ int default_height,
+ gboolean maximize,
EphyInitialStateWindowFlags flags)
{
EphyNode *node;
@@ -315,21 +314,21 @@ create_window_node (const char *name,
* @default_height: the default height we want to give it
* @maximize: whether it should be maximized by default
* @flags: #EphyInitialStateWindowFlags defining what state we want to saze
- *
+ *
* This method will set the correct default size and position for
* @window given the previously stored state information for its type
* (defined by @name). If there's no data available, the default
* values passed as parameters will be used. The @flags parameter
* controls whether we want to track the window's size or position in
* order to update our default values for this type.
- *
+ *
**/
void
-ephy_initial_state_add_window (GtkWidget *window,
- const char *name,
- int default_width,
- int default_height,
- gboolean maximize,
+ephy_initial_state_add_window (GtkWidget *window,
+ const char *name,
+ int default_width,
+ int default_height,
+ gboolean maximize,
EphyInitialStateWindowFlags flags)
{
EphyNode *node;
@@ -357,9 +356,9 @@ ephy_initial_state_add_window (GtkWidget *window,
}
static gboolean
-paned_sync_position_cb (GtkWidget *paned,
+paned_sync_position_cb (GtkWidget *paned,
GParamSpec *pspec,
- EphyNode *node)
+ EphyNode *node)
{
int width;
@@ -370,9 +369,9 @@ paned_sync_position_cb (GtkWidget *paned,
}
void
-ephy_initial_state_add_paned (GtkWidget *paned,
+ephy_initial_state_add_paned (GtkWidget *paned,
const char *name,
- int default_width)
+ int default_width)
{
EphyNode *node;
int width;
@@ -402,8 +401,8 @@ ephy_initial_state_add_paned (GtkWidget *paned,
static void
sync_expander_cb (GtkExpander *expander,
- GParamSpec *pspec,
- EphyNode *node)
+ GParamSpec *pspec,
+ EphyNode *node)
{
gboolean is_expanded;
@@ -415,8 +414,8 @@ sync_expander_cb (GtkExpander *expander,
static void
sync_toggle_cb (GtkToggleButton *toggle,
- GParamSpec *pspec,
- EphyNode *node)
+ GParamSpec *pspec,
+ EphyNode *node)
{
gboolean is_active;
@@ -426,10 +425,10 @@ sync_toggle_cb (GtkToggleButton *toggle,
is_active);
}
-void
-ephy_initial_state_add_expander (GtkWidget *widget,
+void
+ephy_initial_state_add_expander (GtkWidget *widget,
const char *name,
- gboolean default_state)
+ gboolean default_state)
{
EphyNode *node;
gboolean active;
@@ -451,7 +450,7 @@ ephy_initial_state_add_expander (GtkWidget *widget,
}
active = ephy_node_get_property_boolean
- (node, EPHY_NODE_INITIAL_STATE_PROP_ACTIVE);
+ (node, EPHY_NODE_INITIAL_STATE_PROP_ACTIVE);
if (GTK_IS_TOGGLE_BUTTON (widget)) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), active);
diff --git a/lib/ephy-langs.c b/lib/ephy-langs.c
index cae80de..01135a1 100644
--- a/lib/ephy-langs.c
+++ b/lib/ephy-langs.c
@@ -33,304 +33,269 @@
void
ephy_langs_sanitise (GArray *array)
{
- char *lang1, *lang2;
- int i, j;
-
- /* if we have 'xy-ab' in list but not 'xy', append 'xy' */
- for (i = 0; i < (int) array->len; i++)
- {
- gboolean found = FALSE;
- char *dash, *prefix;
-
- lang1 = (char *) g_array_index (array,char *, i);
-
- dash = strchr (lang1, '-');
- if (dash == NULL) continue;
-
- for (j = i + 1; j < (int) array->len; j++)
- {
- lang2 = (char *) g_array_index (array, char *, j);
- if (strchr (lang2, '-') == NULL &&
- g_str_has_prefix (lang1, lang2))
- {
- found = TRUE;
- }
- }
-
- if (found == FALSE)
- {
- prefix = g_strndup (lang1, dash - lang1);
- g_array_append_val (array, prefix);
- }
- }
-
- /* uniquify */
- for (i = 0; i < (int) array->len - 1; i++)
- {
- for (j = (int) array->len - 1; j > i; j--)
- {
- lang1 = (char *) g_array_index (array,char *, i);
- lang2 = (char *) g_array_index (array, char *, j);
-
- if (strcmp (lang1, lang2) == 0)
- {
- g_array_remove_index (array, j);
- g_free (lang2);
- }
- }
- }
-
- /* move 'xy' code behind all 'xy-ab' codes */
- for (i = (int) array->len - 2; i >= 0; i--)
- {
- for (j = (int) array->len - 1; j > i; j--)
- {
- lang1 = (char *) g_array_index (array, char *, i);
- lang2 = (char *) g_array_index (array, char *, j);
-
- if (strchr (lang1, '-') == NULL &&
- strchr (lang2, '-') != NULL &&
- g_str_has_prefix (lang2, lang1))
- {
- g_array_insert_val (array, j + 1, lang1);
- g_array_remove_index (array, i);
- break;
- }
- }
- }
+ char *lang1, *lang2;
+ int i, j;
+
+ /* if we have 'xy-ab' in list but not 'xy', append 'xy' */
+ for (i = 0; i < (int)array->len; i++) {
+ gboolean found = FALSE;
+ char *dash, *prefix;
+
+ lang1 = (char *)g_array_index (array, char *, i);
+
+ dash = strchr (lang1, '-');
+ if (dash == NULL) continue;
+
+ for (j = i + 1; j < (int)array->len; j++) {
+ lang2 = (char *)g_array_index (array, char *, j);
+ if (strchr (lang2, '-') == NULL &&
+ g_str_has_prefix (lang1, lang2)) {
+ found = TRUE;
+ }
+ }
+
+ if (found == FALSE) {
+ prefix = g_strndup (lang1, dash - lang1);
+ g_array_append_val (array, prefix);
+ }
+ }
+
+ /* uniquify */
+ for (i = 0; i < (int)array->len - 1; i++) {
+ for (j = (int)array->len - 1; j > i; j--) {
+ lang1 = (char *)g_array_index (array, char *, i);
+ lang2 = (char *)g_array_index (array, char *, j);
+
+ if (strcmp (lang1, lang2) == 0) {
+ g_array_remove_index (array, j);
+ g_free (lang2);
+ }
+ }
+ }
+
+ /* move 'xy' code behind all 'xy-ab' codes */
+ for (i = (int)array->len - 2; i >= 0; i--) {
+ for (j = (int)array->len - 1; j > i; j--) {
+ lang1 = (char *)g_array_index (array, char *, i);
+ lang2 = (char *)g_array_index (array, char *, j);
+
+ if (strchr (lang1, '-') == NULL &&
+ strchr (lang2, '-') != NULL &&
+ g_str_has_prefix (lang2, lang1)) {
+ g_array_insert_val (array, j + 1, lang1);
+ g_array_remove_index (array, i);
+ break;
+ }
+ }
+ }
}
void
ephy_langs_append_languages (GArray *array)
{
- const char * const * languages;
- char *lang;
- int i;
-
- languages = g_get_language_names ();
- g_return_if_fail (languages != NULL);
-
- /* FIXME: maybe just use the first, instead of all of them? */
- for (i = 0; languages[i] != NULL; i++)
- {
-
- if (strstr (languages[i], ".") == 0 &&
- strstr (languages[i], "@") == 0 &&
- strcmp (languages[i], "C") != 0)
- {
- /* change to lowercase and '_' to '-' */
- lang = g_strdelimit (g_ascii_strdown
- (languages[i], -1), "_", '-');
-
- g_array_append_val (array, lang);
- }
- }
-
- /* Fallback: add "en" if list is empty */
- if (array->len == 0)
- {
- lang = g_strdup ("en");
- g_array_append_val (array, lang);
- }
+ const char * const *languages;
+ char *lang;
+ int i;
+
+ languages = g_get_language_names ();
+ g_return_if_fail (languages != NULL);
+
+ /* FIXME: maybe just use the first, instead of all of them? */
+ for (i = 0; languages[i] != NULL; i++) {
+ if (strstr (languages[i], ".") == 0 &&
+ strstr (languages[i], "@") == 0 &&
+ strcmp (languages[i], "C") != 0) {
+ /* change to lowercase and '_' to '-' */
+ lang = g_strdelimit (g_ascii_strdown
+ (languages[i], -1), "_", '-');
+
+ g_array_append_val (array, lang);
+ }
+ }
+
+ /* Fallback: add "en" if list is empty */
+ if (array->len == 0) {
+ lang = g_strdup ("en");
+ g_array_append_val (array, lang);
+ }
}
char **
ephy_langs_get_languages (void)
{
- GArray *array;
+ GArray *array;
- array = g_array_new (TRUE, FALSE, sizeof (char *));
+ array = g_array_new (TRUE, FALSE, sizeof (char *));
- ephy_langs_append_languages (array);
+ ephy_langs_append_languages (array);
- ephy_langs_sanitise (array);
+ ephy_langs_sanitise (array);
- return (char **)(void *) g_array_free (array, FALSE);
+ return (char **)(void *)g_array_free (array, FALSE);
}
static void
ephy_langs_bind_iso_domains (void)
{
- static gboolean bound = FALSE;
+ static gboolean bound = FALSE;
- if (bound == FALSE)
- {
- bindtextdomain (ISO_639_DOMAIN, LOCALEDIR);
- bind_textdomain_codeset (ISO_639_DOMAIN, "UTF-8");
+ if (bound == FALSE) {
+ bindtextdomain (ISO_639_DOMAIN, LOCALEDIR);
+ bind_textdomain_codeset (ISO_639_DOMAIN, "UTF-8");
- bindtextdomain(ISO_3166_DOMAIN, LOCALEDIR);
- bind_textdomain_codeset (ISO_3166_DOMAIN, "UTF-8");
+ bindtextdomain (ISO_3166_DOMAIN, LOCALEDIR);
+ bind_textdomain_codeset (ISO_3166_DOMAIN, "UTF-8");
- bound = TRUE;
- }
+ bound = TRUE;
+ }
}
static void
read_iso_639_entry (xmlTextReaderPtr reader,
- GHashTable *table)
+ GHashTable *table)
{
- xmlChar *code, *name;
-
- code = xmlTextReaderGetAttribute (reader, (const xmlChar *) "iso_639_1_code");
- name = xmlTextReaderGetAttribute (reader, (const xmlChar *) "name");
-
- /* Get iso-639-2 code */
- if (code == NULL || code[0] == '\0')
- {
- xmlFree (code);
- /* FIXME: use the 2T or 2B code? */
- code = xmlTextReaderGetAttribute (reader, (const xmlChar *) "iso_639_2T_code");
- }
-
- if (code != NULL && code[0] != '\0' && name != NULL && name[0] != '\0')
- {
- g_hash_table_insert (table, code, name);
- }
- else
- {
- xmlFree (code);
- xmlFree (name);
- }
+ xmlChar *code, *name;
+
+ code = xmlTextReaderGetAttribute (reader, (const xmlChar *)"iso_639_1_code");
+ name = xmlTextReaderGetAttribute (reader, (const xmlChar *)"name");
+
+ /* Get iso-639-2 code */
+ if (code == NULL || code[0] == '\0') {
+ xmlFree (code);
+ /* FIXME: use the 2T or 2B code? */
+ code = xmlTextReaderGetAttribute (reader, (const xmlChar *)"iso_639_2T_code");
+ }
+
+ if (code != NULL && code[0] != '\0' && name != NULL && name[0] != '\0') {
+ g_hash_table_insert (table, code, name);
+ } else {
+ xmlFree (code);
+ xmlFree (name);
+ }
}
static void
read_iso_3166_entry (xmlTextReaderPtr reader,
- GHashTable *table)
+ GHashTable *table)
{
- xmlChar *code, *name;
+ xmlChar *code, *name;
- code = xmlTextReaderGetAttribute (reader, (const xmlChar *) "alpha_2_code");
- name = xmlTextReaderGetAttribute (reader, (const xmlChar *) "name");
+ code = xmlTextReaderGetAttribute (reader, (const xmlChar *)"alpha_2_code");
+ name = xmlTextReaderGetAttribute (reader, (const xmlChar *)"name");
- if (code != NULL && code[0] != '\0' && name != NULL && name[0] != '\0')
- {
- char *lcode;
+ if (code != NULL && code[0] != '\0' && name != NULL && name[0] != '\0') {
+ char *lcode;
- lcode = g_ascii_strdown ((char *) code, -1);
- xmlFree (code);
-
- g_hash_table_insert (table, lcode, name);
- }
- else
- {
- xmlFree (code);
- xmlFree (name);
- }
+ lcode = g_ascii_strdown ((char *)code, -1);
+ xmlFree (code);
+ g_hash_table_insert (table, lcode, name);
+ } else {
+ xmlFree (code);
+ xmlFree (name);
+ }
}
-typedef enum
-{
- STATE_START,
- STATE_STOP,
- STATE_ENTRIES,
+typedef enum {
+ STATE_START,
+ STATE_STOP,
+ STATE_ENTRIES,
} ParserState;
static void
-load_iso_entries (int iso,
- GFunc read_entry_func,
- gpointer user_data)
+load_iso_entries (int iso,
+ GFunc read_entry_func,
+ gpointer user_data)
{
- xmlTextReaderPtr reader;
- ParserState state = STATE_START;
- xmlChar iso_entries[32], iso_entry[32];
- char *filename;
- int ret = -1;
-
- LOG ("Loading ISO-%d codes", iso);
-
- START_PROFILER ("Loading ISO codes")
-
- filename = g_strdup_printf (ISO_CODES_PREFIX "/share/xml/iso-codes/iso_%d.xml", iso);
- reader = xmlNewTextReaderFilename (filename);
- if (reader == NULL) goto out;
-
- xmlStrPrintf (iso_entries, sizeof (iso_entries), (const xmlChar *)"iso_%d_entries", iso);
- xmlStrPrintf (iso_entry, sizeof (iso_entry), (const xmlChar *)"iso_%d_entry", iso);
-
- ret = xmlTextReaderRead (reader);
-
- while (ret == 1)
- {
- const xmlChar *tag;
- xmlReaderTypes type;
-
- tag = xmlTextReaderConstName (reader);
- type = xmlTextReaderNodeType (reader);
-
- if (state == STATE_ENTRIES &&
- type == XML_READER_TYPE_ELEMENT &&
- xmlStrEqual (tag, iso_entry))
- {
- read_entry_func (reader, user_data);
- }
- else if (state == STATE_START &&
- type == XML_READER_TYPE_ELEMENT &&
- xmlStrEqual (tag, iso_entries))
- {
- state = STATE_ENTRIES;
- }
- else if (state == STATE_ENTRIES &&
- type == XML_READER_TYPE_END_ELEMENT &&
- xmlStrEqual (tag, iso_entries))
- {
- state = STATE_STOP;
- }
- else if (type == XML_READER_TYPE_SIGNIFICANT_WHITESPACE ||
- type == XML_READER_TYPE_WHITESPACE ||
- type == XML_READER_TYPE_TEXT ||
- type == XML_READER_TYPE_COMMENT)
- {
- /* eat it */
- }
- else
- {
- /* ignore it */
- }
-
- ret = xmlTextReaderRead (reader);
- }
-
- xmlFreeTextReader (reader);
-
-out:
- if (ret < 0 || state != STATE_STOP)
- {
- g_warning ("Failed to load ISO-%d codes from %s!\n",
- iso, filename);
- }
-
- g_free (filename);
-
- STOP_PROFILER ("Loading ISO codes")
+ xmlTextReaderPtr reader;
+ ParserState state = STATE_START;
+ xmlChar iso_entries[32], iso_entry[32];
+ char *filename;
+ int ret = -1;
+
+ LOG ("Loading ISO-%d codes", iso);
+
+ START_PROFILER ("Loading ISO codes")
+
+ filename = g_strdup_printf (ISO_CODES_PREFIX "/share/xml/iso-codes/iso_%d.xml", iso);
+ reader = xmlNewTextReaderFilename (filename);
+ if (reader == NULL) goto out;
+
+ xmlStrPrintf (iso_entries, sizeof (iso_entries), (const xmlChar *)"iso_%d_entries", iso);
+ xmlStrPrintf (iso_entry, sizeof (iso_entry), (const xmlChar *)"iso_%d_entry", iso);
+
+ ret = xmlTextReaderRead (reader);
+
+ while (ret == 1) {
+ const xmlChar *tag;
+ xmlReaderTypes type;
+
+ tag = xmlTextReaderConstName (reader);
+ type = xmlTextReaderNodeType (reader);
+
+ if (state == STATE_ENTRIES &&
+ type == XML_READER_TYPE_ELEMENT &&
+ xmlStrEqual (tag, iso_entry)) {
+ read_entry_func (reader, user_data);
+ } else if (state == STATE_START &&
+ type == XML_READER_TYPE_ELEMENT &&
+ xmlStrEqual (tag, iso_entries)) {
+ state = STATE_ENTRIES;
+ } else if (state == STATE_ENTRIES &&
+ type == XML_READER_TYPE_END_ELEMENT &&
+ xmlStrEqual (tag, iso_entries)) {
+ state = STATE_STOP;
+ } else if (type == XML_READER_TYPE_SIGNIFICANT_WHITESPACE ||
+ type == XML_READER_TYPE_WHITESPACE ||
+ type == XML_READER_TYPE_TEXT ||
+ type == XML_READER_TYPE_COMMENT) {
+ /* eat it */
+ } else {
+ /* ignore it */
+ }
+
+ ret = xmlTextReaderRead (reader);
+ }
+
+ xmlFreeTextReader (reader);
+
+ out:
+ if (ret < 0 || state != STATE_STOP) {
+ g_warning ("Failed to load ISO-%d codes from %s!\n",
+ iso, filename);
+ }
+
+ g_free (filename);
+
+ STOP_PROFILER ("Loading ISO codes")
}
GHashTable *
ephy_langs_iso_639_table (void)
{
- GHashTable *table;
+ GHashTable *table;
- ephy_langs_bind_iso_domains ();
- table = g_hash_table_new_full (g_str_hash, g_str_equal,
- (GDestroyNotify) xmlFree,
- (GDestroyNotify) xmlFree);
+ ephy_langs_bind_iso_domains ();
+ table = g_hash_table_new_full (g_str_hash, g_str_equal,
+ (GDestroyNotify)xmlFree,
+ (GDestroyNotify)xmlFree);
- load_iso_entries (639, (GFunc) read_iso_639_entry, table);
+ load_iso_entries (639, (GFunc)read_iso_639_entry, table);
- return table;
+ return table;
}
GHashTable *
ephy_langs_iso_3166_table (void)
{
- GHashTable *table;
+ GHashTable *table;
+
+ ephy_langs_bind_iso_domains ();
+ table = g_hash_table_new_full (g_str_hash, g_str_equal,
+ (GDestroyNotify)g_free,
+ (GDestroyNotify)xmlFree);
- ephy_langs_bind_iso_domains ();
- table = g_hash_table_new_full (g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) xmlFree);
-
- load_iso_entries (3166, (GFunc) read_iso_3166_entry, table);
+ load_iso_entries (3166, (GFunc)read_iso_3166_entry, table);
- return table;
+ return table;
}
diff --git a/lib/ephy-node-db.c b/lib/ephy-node-db.c
index 11a0c12..7847724 100644
--- a/lib/ephy-node-db.c
+++ b/lib/ephy-node-db.c
@@ -32,99 +32,95 @@
/* FIXME I want to find a better way to deal with "root" nodes */
#define RESERVED_IDS 30
-enum
-{
- PROP_0,
- PROP_NAME,
- PROP_IMMUTABLE,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_NAME,
+ PROP_IMMUTABLE,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
-struct _EphyNodeDb
-{
- GObject parent_instance;
+struct _EphyNodeDb {
+ GObject parent_instance;
- char *name;
- gboolean immutable;
+ char *name;
+ gboolean immutable;
- guint id_factory;
+ guint id_factory;
- GPtrArray *id_to_node;
+ GPtrArray *id_to_node;
};
G_DEFINE_TYPE (EphyNodeDb, ephy_node_db, G_TYPE_OBJECT)
static void
-ephy_node_db_get_property (GObject *object,
- guint prop_id,
- GValue *value,
+ephy_node_db_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
GParamSpec *pspec)
{
- EphyNodeDb *db = EPHY_NODE_DB (object);
-
- switch (prop_id)
- {
- case PROP_NAME:
- g_value_set_string (value, db->name);
- break;
- case PROP_IMMUTABLE:
- g_value_set_boolean (value, ephy_node_db_is_immutable (db));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
+ EphyNodeDb *db = EPHY_NODE_DB (object);
+
+ switch (prop_id) {
+ case PROP_NAME:
+ g_value_set_string (value, db->name);
+ break;
+ case PROP_IMMUTABLE:
+ g_value_set_boolean (value, ephy_node_db_is_immutable (db));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
-ephy_node_db_set_property (GObject *object,
- guint prop_id,
+ephy_node_db_set_property (GObject *object,
+ guint prop_id,
const GValue *value,
- GParamSpec *pspec)
+ GParamSpec *pspec)
{
- EphyNodeDb *db = EPHY_NODE_DB (object);
-
- switch (prop_id)
- {
- case PROP_NAME:
- db->name = g_value_dup_string (value);
- break;
- case PROP_IMMUTABLE:
- ephy_node_db_set_immutable (db, g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
+ EphyNodeDb *db = EPHY_NODE_DB (object);
+
+ switch (prop_id) {
+ case PROP_NAME:
+ db->name = g_value_dup_string (value);
+ break;
+ case PROP_IMMUTABLE:
+ ephy_node_db_set_immutable (db, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
ephy_node_db_free_func (EphyNode *node)
{
- if (node)
- ephy_node_unref (node);
+ if (node)
+ ephy_node_unref (node);
}
static void
ephy_node_db_init (EphyNodeDb *db)
{
- /* id to node */
- db->id_to_node = g_ptr_array_new_with_free_func ((GDestroyNotify)ephy_node_db_free_func);
+ /* id to node */
+ db->id_to_node = g_ptr_array_new_with_free_func ((GDestroyNotify)ephy_node_db_free_func);
- /* id factory */
- db->id_factory = RESERVED_IDS;
+ /* id factory */
+ db->id_factory = RESERVED_IDS;
}
static void
ephy_node_db_finalize (GObject *object)
{
- EphyNodeDb *db = EPHY_NODE_DB (object);
+ EphyNodeDb *db = EPHY_NODE_DB (object);
- g_ptr_array_free (db->id_to_node, TRUE);
+ g_ptr_array_free (db->id_to_node, TRUE);
- g_free (db->name);
+ g_free (db->name);
- G_OBJECT_CLASS (ephy_node_db_parent_class)->finalize (object);
+ G_OBJECT_CLASS (ephy_node_db_parent_class)->finalize (object);
}
/**
@@ -138,24 +134,24 @@ ephy_node_db_finalize (GObject *object)
EphyNodeDb *
ephy_node_db_new (const char *name)
{
- EphyNodeDb *db;
+ EphyNodeDb *db;
- db = EPHY_NODE_DB (g_object_new (EPHY_TYPE_NODE_DB,
- "name", name,
- NULL));
+ db = EPHY_NODE_DB (g_object_new (EPHY_TYPE_NODE_DB,
+ "name", name,
+ NULL));
- return db;
+ return db;
}
static inline EphyNode *
node_from_id_real (EphyNodeDb *db, guint id)
{
- EphyNode *ret = NULL;
+ EphyNode *ret = NULL;
- if (id < db->id_to_node->len)
- ret = g_ptr_array_index (db->id_to_node, id);
+ if (id < db->id_to_node->len)
+ ret = g_ptr_array_index (db->id_to_node, id);
- return ret;
+ return ret;
}
/**
@@ -167,7 +163,7 @@ node_from_id_real (EphyNodeDb *db, guint id)
const char *
ephy_node_db_get_name (EphyNodeDb *db)
{
- return db->name;
+ return db->name;
}
/**
@@ -179,7 +175,7 @@ ephy_node_db_get_name (EphyNodeDb *db)
gboolean
ephy_node_db_is_immutable (EphyNodeDb *db)
{
- return db->immutable;
+ return db->immutable;
}
/**
@@ -193,9 +189,9 @@ ephy_node_db_is_immutable (EphyNodeDb *db)
void
ephy_node_db_set_immutable (EphyNodeDb *db, gboolean immutable)
{
- db->immutable = immutable;
+ db->immutable = immutable;
- g_object_notify_by_pspec (G_OBJECT (db), obj_properties[PROP_IMMUTABLE]);
+ g_object_notify_by_pspec (G_OBJECT (db), obj_properties[PROP_IMMUTABLE]);
}
/**
@@ -210,48 +206,47 @@ ephy_node_db_set_immutable (EphyNodeDb *db, gboolean immutable)
EphyNode *
ephy_node_db_get_node_from_id (EphyNodeDb *db, guint id)
{
- EphyNode *ret = NULL;
+ EphyNode *ret = NULL;
- ret = node_from_id_real (db, id);
+ ret = node_from_id_real (db, id);
- return ret;
+ return ret;
}
guint
_ephy_node_db_new_id (EphyNodeDb *db)
{
- guint ret;
+ guint ret;
- while (node_from_id_real (db, db->id_factory) != NULL)
- {
- db->id_factory++;
- }
+ while (node_from_id_real (db, db->id_factory) != NULL) {
+ db->id_factory++;
+ }
- ret = db->id_factory;
+ ret = db->id_factory;
- return ret;
+ return ret;
}
void
_ephy_node_db_add_id (EphyNodeDb *db,
- guint id,
- EphyNode *node)
+ guint id,
+ EphyNode *node)
{
- /* resize array if needed */
- if (id >= db->id_to_node->len)
- g_ptr_array_set_size (db->id_to_node, id + 1);
+ /* resize array if needed */
+ if (id >= db->id_to_node->len)
+ g_ptr_array_set_size (db->id_to_node, id + 1);
- g_ptr_array_index (db->id_to_node, id) = node;
+ g_ptr_array_index (db->id_to_node, id) = node;
}
void
_ephy_node_db_remove_id (EphyNodeDb *db,
- guint id)
+ guint id)
{
- g_ptr_array_index (db->id_to_node, id) = NULL;
+ g_ptr_array_index (db->id_to_node, id) = NULL;
- /* reset id factory so we use the freed node id */
- db->id_factory = RESERVED_IDS;
+ /* reset id factory so we use the freed node id */
+ db->id_factory = RESERVED_IDS;
}
/**
@@ -272,176 +267,163 @@ _ephy_node_db_remove_id (EphyNodeDb *db,
* Return value: %TRUE if successful
**/
gboolean
-ephy_node_db_load_from_file (EphyNodeDb *db,
- const char *xml_file,
- const xmlChar *xml_root,
- const xmlChar *xml_version)
+ephy_node_db_load_from_file (EphyNodeDb *db,
+ const char *xml_file,
+ const xmlChar *xml_root,
+ const xmlChar *xml_version)
{
- xmlTextReaderPtr reader;
- gboolean success = TRUE;
- gboolean was_immutable;
- int ret;
+ xmlTextReaderPtr reader;
+ gboolean success = TRUE;
+ gboolean was_immutable;
+ int ret;
- LOG ("ephy_node_db_load_from_file %s", xml_file);
+ LOG ("ephy_node_db_load_from_file %s", xml_file);
- START_PROFILER ("loading node db")
+ START_PROFILER ("loading node db")
- if (g_file_test (xml_file, G_FILE_TEST_EXISTS) == FALSE)
- {
- return FALSE;
- }
+ if (g_file_test (xml_file, G_FILE_TEST_EXISTS) == FALSE) {
+ return FALSE;
+ }
- reader = xmlNewTextReaderFilename (xml_file);
- if (reader == NULL)
- {
- return FALSE;
- }
+ reader = xmlNewTextReaderFilename (xml_file);
+ if (reader == NULL) {
+ return FALSE;
+ }
- was_immutable = db->immutable;
- db->immutable = FALSE;
+ was_immutable = db->immutable;
+ db->immutable = FALSE;
- ret = xmlTextReaderRead (reader);
- while (ret == 1)
- {
- const xmlChar *name;
- xmlReaderTypes type;
- gboolean skip = FALSE;
+ ret = xmlTextReaderRead (reader);
+ while (ret == 1) {
+ const xmlChar *name;
+ xmlReaderTypes type;
+ gboolean skip = FALSE;
- name = xmlTextReaderConstName (reader);
- type = xmlTextReaderNodeType (reader);
+ name = xmlTextReaderConstName (reader);
+ type = xmlTextReaderNodeType (reader);
- if (xmlStrEqual (name, (const xmlChar *)"node")
- && type == XML_READER_TYPE_ELEMENT)
- {
- xmlNodePtr subtree;
+ if (xmlStrEqual (name, (const xmlChar *)"node")
+ && type == XML_READER_TYPE_ELEMENT) {
+ xmlNodePtr subtree;
- /* grow the subtree and load the node from it */
- subtree = xmlTextReaderExpand (reader);
+ /* grow the subtree and load the node from it */
+ subtree = xmlTextReaderExpand (reader);
- if (subtree != NULL)
- {
- ephy_node_new_from_xml (db, subtree);
- }
+ if (subtree != NULL) {
+ ephy_node_new_from_xml (db, subtree);
+ }
- skip = TRUE;
- }
- else if (xmlStrEqual (name, xml_root)
- && type == XML_READER_TYPE_ELEMENT)
- {
- xmlChar *version;
+ skip = TRUE;
+ } else if (xmlStrEqual (name, xml_root)
+ && type == XML_READER_TYPE_ELEMENT) {
+ xmlChar *version;
- /* check version info */
- version = xmlTextReaderGetAttribute (reader, (const xmlChar *)"version");
- if (xmlStrEqual (version, xml_version) == FALSE)
- {
- success = FALSE;
- xmlFree (version);
+ /* check version info */
+ version = xmlTextReaderGetAttribute (reader, (const xmlChar *)"version");
+ if (xmlStrEqual (version, xml_version) == FALSE) {
+ success = FALSE;
+ xmlFree (version);
- break;
- }
+ break;
+ }
- xmlFree (version);
- }
+ xmlFree (version);
+ }
- /* next one, please */
- ret = skip ? xmlTextReaderNext (reader)
- : xmlTextReaderRead (reader);
- }
+ /* next one, please */
+ ret = skip ? xmlTextReaderNext (reader)
+ : xmlTextReaderRead (reader);
+ }
- xmlFreeTextReader (reader);
+ xmlFreeTextReader (reader);
- db->immutable = was_immutable;
+ db->immutable = was_immutable;
- STOP_PROFILER ("loading node db")
+ STOP_PROFILER ("loading node db")
- return (success && ret == 0);
+ return (success && ret == 0);
}
static int
-ephy_node_db_write_to_xml_valist (EphyNodeDb *db,
- xmlBuffer *buffer,
- const xmlChar *root,
- const xmlChar *version,
- const xmlChar *comment,
- EphyNode *first_node,
- va_list argptr)
+ephy_node_db_write_to_xml_valist (EphyNodeDb *db,
+ xmlBuffer *buffer,
+ const xmlChar *root,
+ const xmlChar *version,
+ const xmlChar *comment,
+ EphyNode *first_node,
+ va_list argptr)
{
- xmlTextWriterPtr writer;
- EphyNode *node;
- int ret;
+ xmlTextWriterPtr writer;
+ EphyNode *node;
+ int ret;
- START_PROFILER ("Saving node db")
+ START_PROFILER ("Saving node db")
- /* FIXME: do we want to turn compression on ? */
- writer = xmlNewTextWriterMemory (buffer, 0);
- if (writer == NULL)
- {
- return -1;
- }
+ /* FIXME: do we want to turn compression on ? */
+ writer = xmlNewTextWriterMemory (buffer, 0);
+ if (writer == NULL) {
+ return -1;
+ }
- ret = xmlTextWriterSetIndent (writer, 1);
- if (ret < 0) goto out;
+ ret = xmlTextWriterSetIndent (writer, 1);
+ if (ret < 0) goto out;
- ret = xmlTextWriterSetIndentString (writer, (const xmlChar *)" ");
- if (ret < 0) goto out;
+ ret = xmlTextWriterSetIndentString (writer, (const xmlChar *)" ");
+ if (ret < 0) goto out;
- ret = xmlTextWriterStartDocument (writer, "1.0", NULL, NULL);
- if (ret < 0) goto out;
+ ret = xmlTextWriterStartDocument (writer, "1.0", NULL, NULL);
+ if (ret < 0) goto out;
- ret = xmlTextWriterStartElement (writer, root);
- if (ret < 0) goto out;
+ ret = xmlTextWriterStartElement (writer, root);
+ if (ret < 0) goto out;
- ret = xmlTextWriterWriteAttribute (writer, (const xmlChar *)"version", version);
- if (ret < 0) goto out;
+ ret = xmlTextWriterWriteAttribute (writer, (const xmlChar *)"version", version);
+ if (ret < 0) goto out;
- if (comment != NULL)
- {
- ret = xmlTextWriterWriteComment (writer, comment);
- if (ret < 0) goto out;
- }
+ if (comment != NULL) {
+ ret = xmlTextWriterWriteComment (writer, comment);
+ if (ret < 0) goto out;
+ }
- node = first_node;
- while (node != NULL)
- {
- GPtrArray *children;
- EphyNodeFilterFunc filter;
- gpointer user_data;
- guint i;
+ node = first_node;
+ while (node != NULL) {
+ GPtrArray *children;
+ EphyNodeFilterFunc filter;
+ gpointer user_data;
+ guint i;
- filter = va_arg (argptr, EphyNodeFilterFunc);
- user_data = va_arg (argptr, gpointer);
+ filter = va_arg (argptr, EphyNodeFilterFunc);
+ user_data = va_arg (argptr, gpointer);
- children = ephy_node_get_children (node);
- for (i = 0; i < children->len; i++)
- {
- EphyNode *kid;
+ children = ephy_node_get_children (node);
+ for (i = 0; i < children->len; i++) {
+ EphyNode *kid;
- kid = g_ptr_array_index (children, i);
+ kid = g_ptr_array_index (children, i);
- if (!filter || filter (kid, user_data))
- {
- ret = ephy_node_write_to_xml (kid, writer);
- if (ret < 0) break;
- }
- }
- if (ret < 0) break;
+ if (!filter || filter (kid, user_data)) {
+ ret = ephy_node_write_to_xml (kid, writer);
+ if (ret < 0) break;
+ }
+ }
+ if (ret < 0) break;
- node = va_arg (argptr, EphyNode *);
- }
- if (ret < 0) goto out;
+ node = va_arg (argptr, EphyNode *);
+ }
+ if (ret < 0) goto out;
- ret = xmlTextWriterEndElement (writer); /* root */
- if (ret < 0) goto out;
+ ret = xmlTextWriterEndElement (writer); /* root */
+ if (ret < 0) goto out;
- ret = xmlTextWriterEndDocument (writer);
- if (ret < 0) goto out;
+ ret = xmlTextWriterEndDocument (writer);
+ if (ret < 0) goto out;
-out:
- xmlFreeTextWriter (writer);
+ out:
+ xmlFreeTextWriter (writer);
- STOP_PROFILER ("Saving node db")
+ STOP_PROFILER ("Saving node db")
- return ret >= 0 ? 0 : -1;
+ return ret >= 0 ? 0 : -1;
}
/**
@@ -453,7 +435,7 @@ out:
* @comment: a comment to place directly inside the @root element of @filename
* @node: The first node of data to write
* @Varargs: number of exceptions, list of their #EphyNodes, and more such
- * sequences, followed by %NULL
+ * sequences, followed by %NULL
*
* Writes @db's data to an XML file for storage. The data can be retrieved in
* the future using ephy_node_db_load_from_file().
@@ -479,68 +461,66 @@ out:
**/
int
ephy_node_db_write_to_xml_safe (EphyNodeDb *db,
- const xmlChar *filename,
- const xmlChar *root,
- const xmlChar *version,
- const xmlChar *comment,
- EphyNode *node, ...)
+ const xmlChar *filename,
+ const xmlChar *root,
+ const xmlChar *version,
+ const xmlChar *comment,
+ EphyNode *node, ...)
{
- va_list argptr;
- xmlBuffer *buffer;
- GError *error = NULL;
- int ret = 0;
+ va_list argptr;
+ xmlBuffer *buffer;
+ GError *error = NULL;
+ int ret = 0;
- LOG ("Saving node db to %s", filename);
+ LOG ("Saving node db to %s", filename);
- va_start (argptr, node);
+ va_start (argptr, node);
- buffer = xmlBufferCreate ();
- ret = ephy_node_db_write_to_xml_valist
- (db, buffer, root, version, comment, node, argptr);
+ buffer = xmlBufferCreate ();
+ ret = ephy_node_db_write_to_xml_valist
+ (db, buffer, root, version, comment, node, argptr);
- va_end (argptr);
+ va_end (argptr);
- if (ret < 0)
- {
- g_warning ("Failed to write XML data");
- goto failed;
- }
+ if (ret < 0) {
+ g_warning ("Failed to write XML data");
+ goto failed;
+ }
- if (g_file_set_contents ((const char *)filename, (const char *)buffer->content, buffer->use, &error)
== FALSE)
- {
- g_warning ("Error saving EphyNodeDB as XML: %s", error->message);
- g_error_free (error);
- ret = -1;
- }
+ if (g_file_set_contents ((const char *)filename, (const char *)buffer->content, buffer->use, &error) ==
FALSE) {
+ g_warning ("Error saving EphyNodeDB as XML: %s", error->message);
+ g_error_free (error);
+ ret = -1;
+ }
-failed:
- xmlBufferFree (buffer);
+ failed:
+ xmlBufferFree (buffer);
- return ret;
+ return ret;
}
static void
ephy_node_db_class_init (EphyNodeDbClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = ephy_node_db_finalize;
- object_class->set_property = ephy_node_db_set_property;
- object_class->get_property = ephy_node_db_get_property;
-
- obj_properties[PROP_NAME] =
- g_param_spec_string ("name",
- "Name",
- "Name",
- NULL,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
-
- obj_properties[PROP_IMMUTABLE] =
- g_param_spec_boolean ("immutable",
- "Immutable",
- "Immutable",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = ephy_node_db_finalize;
+ object_class->set_property = ephy_node_db_set_property;
+ object_class->get_property = ephy_node_db_get_property;
+
+ obj_properties[PROP_NAME] =
+ g_param_spec_string ("name",
+ "Name",
+ "Name",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+
+ obj_properties[PROP_IMMUTABLE] =
+ g_param_spec_boolean ("immutable",
+ "Immutable",
+ "Immutable",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
}
diff --git a/lib/ephy-node-filter.c b/lib/ephy-node-filter.c
index e981d7d..3ba8bc3 100644
--- a/lib/ephy-node-filter.c
+++ b/lib/ephy-node-filter.c
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright © 2002 Olivier Martin <omartin ifrance com>
* (C) 2002 Jorn Baayen <jorn nl linux org>
*
@@ -26,45 +26,38 @@
static void ephy_node_filter_finalize (GObject *object);
static gboolean ephy_node_filter_expression_evaluate (EphyNodeFilterExpression *expression,
- EphyNode *node);
+ EphyNode *node);
-enum
-{
- CHANGED,
- LAST_SIGNAL
+enum {
+ CHANGED,
+ LAST_SIGNAL
};
-struct _EphyNodeFilter
-{
- GObject parent_instance;
+struct _EphyNodeFilter {
+ GObject parent_instance;
- GPtrArray *levels;
+ GPtrArray *levels;
};
-struct _EphyNodeFilterExpression
-{
- EphyNodeFilterExpressionType type;
-
- union
- {
- struct
- {
- EphyNode *a;
- EphyNode *b;
- } node_args;
-
- struct
- {
- int prop_id;
-
- union
- {
- EphyNode *node;
- char *string;
- int number;
- } second_arg;
- } prop_args;
- } args;
+struct _EphyNodeFilterExpression {
+ EphyNodeFilterExpressionType type;
+
+ union {
+ struct {
+ EphyNode *a;
+ EphyNode *b;
+ } node_args;
+
+ struct {
+ int prop_id;
+
+ union {
+ EphyNode *node;
+ char *string;
+ int number;
+ } second_arg;
+ } prop_args;
+ } args;
};
static guint ephy_node_filter_signals[LAST_SIGNAL] = { 0 };
@@ -74,349 +67,342 @@ G_DEFINE_TYPE (EphyNodeFilter, ephy_node_filter, G_TYPE_OBJECT)
static void
ephy_node_filter_class_init (EphyNodeFilterClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = ephy_node_filter_finalize;
+ object_class->finalize = ephy_node_filter_finalize;
- ephy_node_filter_signals[CHANGED] =
- g_signal_new ("changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 0);
+ ephy_node_filter_signals[CHANGED] =
+ g_signal_new ("changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 0);
}
static void
ephy_node_filter_init (EphyNodeFilter *filter)
{
- filter->levels = g_ptr_array_new ();
+ filter->levels = g_ptr_array_new ();
}
static void
ephy_node_filter_finalize (GObject *object)
{
- EphyNodeFilter *filter = EPHY_NODE_FILTER (object);
+ EphyNodeFilter *filter = EPHY_NODE_FILTER (object);
- ephy_node_filter_empty (filter);
+ ephy_node_filter_empty (filter);
- g_ptr_array_free (filter->levels, TRUE);
+ g_ptr_array_free (filter->levels, TRUE);
- G_OBJECT_CLASS (ephy_node_filter_parent_class)->finalize (object);
+ G_OBJECT_CLASS (ephy_node_filter_parent_class)->finalize (object);
}
EphyNodeFilter *
ephy_node_filter_new (void)
{
- return EPHY_NODE_FILTER (g_object_new (EPHY_TYPE_NODE_FILTER, NULL));
+ return EPHY_NODE_FILTER (g_object_new (EPHY_TYPE_NODE_FILTER, NULL));
}
void
-ephy_node_filter_add_expression (EphyNodeFilter *filter,
- EphyNodeFilterExpression *exp,
- int level)
+ephy_node_filter_add_expression (EphyNodeFilter *filter,
+ EphyNodeFilterExpression *exp,
+ int level)
{
- while (level >= (int)filter->levels->len)
- g_ptr_array_add (filter->levels, NULL);
+ while (level >= (int)filter->levels->len)
+ g_ptr_array_add (filter->levels, NULL);
- /* FIXME bogosity! This only works because g_list_append (x, data) == x */
- g_ptr_array_index (filter->levels, level) =
- g_list_append (g_ptr_array_index (filter->levels, level), exp);
+ /* FIXME bogosity! This only works because g_list_append (x, data) == x */
+ g_ptr_array_index (filter->levels, level) =
+ g_list_append (g_ptr_array_index (filter->levels, level), exp);
}
void
ephy_node_filter_empty (EphyNodeFilter *filter)
{
- int i;
-
- for (i = filter->levels->len - 1; i >= 0; i--)
- {
- GList *list, *l;
+ int i;
+
+ for (i = filter->levels->len - 1; i >= 0; i--) {
+ GList *list, *l;
- list = g_ptr_array_index (filter->levels, i);
+ list = g_ptr_array_index (filter->levels, i);
- for (l = list; l != NULL; l = g_list_next (l))
- {
- EphyNodeFilterExpression *exp;
+ for (l = list; l != NULL; l = g_list_next (l)) {
+ EphyNodeFilterExpression *exp;
- exp = (EphyNodeFilterExpression *) l->data;
+ exp = (EphyNodeFilterExpression *)l->data;
- ephy_node_filter_expression_free (exp);
- }
+ ephy_node_filter_expression_free (exp);
+ }
- g_list_free (list);
+ g_list_free (list);
- g_ptr_array_remove_index (filter->levels, i);
- }
+ g_ptr_array_remove_index (filter->levels, i);
+ }
}
void
ephy_node_filter_done_changing (EphyNodeFilter *filter)
{
- g_signal_emit (G_OBJECT (filter), ephy_node_filter_signals[CHANGED], 0);
+ g_signal_emit (G_OBJECT (filter), ephy_node_filter_signals[CHANGED], 0);
}
/*
- * We go through each level evaluating the filter expressions.
+ * We go through each level evaluating the filter expressions.
* Every time we get a match we immediately do a break and jump
- * to the next level. We'll return FALSE if we arrive to a level
+ * to the next level. We'll return FALSE if we arrive to a level
* without matches, TRUE otherwise.
*/
gboolean
ephy_node_filter_evaluate (EphyNodeFilter *filter,
- EphyNode *node)
+ EphyNode *node)
{
- guint i;
+ guint i;
+
+ for (i = 0; i < filter->levels->len; i++) {
+ GList *l, *list;
+ gboolean handled;
- for (i = 0; i < filter->levels->len; i++) {
- GList *l, *list;
- gboolean handled;
+ handled = FALSE;
- handled = FALSE;
+ list = g_ptr_array_index (filter->levels, i);
- list = g_ptr_array_index (filter->levels, i);
+ for (l = list; l != NULL; l = g_list_next (l)) {
+ if (ephy_node_filter_expression_evaluate (l->data, node) == TRUE) {
+ handled = TRUE;
+ break;
+ }
+ }
- for (l = list; l != NULL; l = g_list_next (l)) {
- if (ephy_node_filter_expression_evaluate (l->data, node) == TRUE) {
- handled = TRUE;
- break;
- }
- }
+ if (list != NULL && handled == FALSE)
+ return FALSE;
+ }
- if (list != NULL && handled == FALSE)
- return FALSE;
- }
-
- return TRUE;
+ return TRUE;
}
EphyNodeFilterExpression *
ephy_node_filter_expression_new (EphyNodeFilterExpressionType type,
- ...)
+ ...)
{
- EphyNodeFilterExpression *exp;
- va_list valist;
-
- va_start (valist, type);
-
- exp = g_new0 (EphyNodeFilterExpression, 1);
-
- exp->type = type;
-
- switch (type)
- {
- case EPHY_NODE_FILTER_EXPRESSION_NODE_EQUALS:
- exp->args.node_args.a = va_arg (valist, EphyNode *);
- exp->args.node_args.b = va_arg (valist, EphyNode *);
- break;
- case EPHY_NODE_FILTER_EXPRESSION_EQUALS:
- case EPHY_NODE_FILTER_EXPRESSION_HAS_PARENT:
- case EPHY_NODE_FILTER_EXPRESSION_HAS_CHILD:
- exp->args.node_args.a = va_arg (valist, EphyNode *);
- break;
- case EPHY_NODE_FILTER_EXPRESSION_NODE_PROP_EQUALS:
- case EPHY_NODE_FILTER_EXPRESSION_CHILD_PROP_EQUALS:
- exp->args.prop_args.prop_id = va_arg (valist, int);
- exp->args.prop_args.second_arg.node = va_arg (valist, EphyNode *);
- break;
- case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_CONTAINS:
- case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_EQUALS:
- exp->args.prop_args.prop_id = va_arg (valist, int);
- exp->args.prop_args.second_arg.string = g_utf8_casefold (va_arg (valist, char *), -1);
- break;
- case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_CONTAINS:
- case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_EQUALS:
- {
- char *folded;
-
- exp->args.prop_args.prop_id = va_arg (valist, int);
-
- folded = g_utf8_casefold (va_arg (valist, char *), -1);
- exp->args.prop_args.second_arg.string = g_utf8_collate_key (folded, -1);
- g_free (folded);
- break;
- }
- case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_EQUALS:
- case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_BIGGER_THAN:
- case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_LESS_THAN:
- exp->args.prop_args.prop_id = va_arg (valist, int);
- exp->args.prop_args.second_arg.number = va_arg (valist, int);
- break;
- case EPHY_NODE_FILTER_EXPRESSION_ALWAYS_TRUE:
- default:
- break;
- }
-
- va_end (valist);
-
- return exp;
+ EphyNodeFilterExpression *exp;
+ va_list valist;
+
+ va_start (valist, type);
+
+ exp = g_new0 (EphyNodeFilterExpression, 1);
+
+ exp->type = type;
+
+ switch (type) {
+ case EPHY_NODE_FILTER_EXPRESSION_NODE_EQUALS:
+ exp->args.node_args.a = va_arg (valist, EphyNode *);
+ exp->args.node_args.b = va_arg (valist, EphyNode *);
+ break;
+ case EPHY_NODE_FILTER_EXPRESSION_EQUALS:
+ case EPHY_NODE_FILTER_EXPRESSION_HAS_PARENT:
+ case EPHY_NODE_FILTER_EXPRESSION_HAS_CHILD:
+ exp->args.node_args.a = va_arg (valist, EphyNode *);
+ break;
+ case EPHY_NODE_FILTER_EXPRESSION_NODE_PROP_EQUALS:
+ case EPHY_NODE_FILTER_EXPRESSION_CHILD_PROP_EQUALS:
+ exp->args.prop_args.prop_id = va_arg (valist, int);
+ exp->args.prop_args.second_arg.node = va_arg (valist, EphyNode *);
+ break;
+ case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_CONTAINS:
+ case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_EQUALS:
+ exp->args.prop_args.prop_id = va_arg (valist, int);
+ exp->args.prop_args.second_arg.string = g_utf8_casefold (va_arg (valist, char *), -1);
+ break;
+ case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_CONTAINS:
+ case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_EQUALS:
+ {
+ char *folded;
+
+ exp->args.prop_args.prop_id = va_arg (valist, int);
+
+ folded = g_utf8_casefold (va_arg (valist, char *), -1);
+ exp->args.prop_args.second_arg.string = g_utf8_collate_key (folded, -1);
+ g_free (folded);
+ break;
+ }
+ case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_EQUALS:
+ case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_BIGGER_THAN:
+ case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_LESS_THAN:
+ exp->args.prop_args.prop_id = va_arg (valist, int);
+ exp->args.prop_args.second_arg.number = va_arg (valist, int);
+ break;
+ case EPHY_NODE_FILTER_EXPRESSION_ALWAYS_TRUE:
+ default:
+ break;
+ }
+
+ va_end (valist);
+
+ return exp;
}
void
ephy_node_filter_expression_free (EphyNodeFilterExpression *exp)
{
- switch (exp->type)
- {
- case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_CONTAINS:
- case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_EQUALS:
- case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_CONTAINS:
- case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_EQUALS:
- g_free (exp->args.prop_args.second_arg.string);
- break;
- case EPHY_NODE_FILTER_EXPRESSION_ALWAYS_TRUE:
- case EPHY_NODE_FILTER_EXPRESSION_NODE_EQUALS:
- case EPHY_NODE_FILTER_EXPRESSION_EQUALS:
- case EPHY_NODE_FILTER_EXPRESSION_HAS_PARENT:
- case EPHY_NODE_FILTER_EXPRESSION_HAS_CHILD:
- case EPHY_NODE_FILTER_EXPRESSION_NODE_PROP_EQUALS:
- case EPHY_NODE_FILTER_EXPRESSION_CHILD_PROP_EQUALS:
- case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_EQUALS:
- case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_BIGGER_THAN:
- case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_LESS_THAN:
- default:
- break;
- }
-
- g_free (exp);
+ switch (exp->type) {
+ case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_CONTAINS:
+ case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_EQUALS:
+ case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_CONTAINS:
+ case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_EQUALS:
+ g_free (exp->args.prop_args.second_arg.string);
+ break;
+ case EPHY_NODE_FILTER_EXPRESSION_ALWAYS_TRUE:
+ case EPHY_NODE_FILTER_EXPRESSION_NODE_EQUALS:
+ case EPHY_NODE_FILTER_EXPRESSION_EQUALS:
+ case EPHY_NODE_FILTER_EXPRESSION_HAS_PARENT:
+ case EPHY_NODE_FILTER_EXPRESSION_HAS_CHILD:
+ case EPHY_NODE_FILTER_EXPRESSION_NODE_PROP_EQUALS:
+ case EPHY_NODE_FILTER_EXPRESSION_CHILD_PROP_EQUALS:
+ case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_EQUALS:
+ case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_BIGGER_THAN:
+ case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_LESS_THAN:
+ default:
+ break;
+ }
+
+ g_free (exp);
}
static gboolean
ephy_node_filter_expression_evaluate (EphyNodeFilterExpression *exp,
- EphyNode *node)
+ EphyNode *node)
{
- switch (exp->type)
- {
- case EPHY_NODE_FILTER_EXPRESSION_ALWAYS_TRUE:
- return TRUE;
- case EPHY_NODE_FILTER_EXPRESSION_NODE_EQUALS:
- return (exp->args.node_args.a == exp->args.node_args.b);
- case EPHY_NODE_FILTER_EXPRESSION_EQUALS:
- return (exp->args.node_args.a == node);
- case EPHY_NODE_FILTER_EXPRESSION_HAS_PARENT:
- return ephy_node_has_child (exp->args.node_args.a, node);
- case EPHY_NODE_FILTER_EXPRESSION_HAS_CHILD:
- return ephy_node_has_child (node, exp->args.node_args.a);
- case EPHY_NODE_FILTER_EXPRESSION_NODE_PROP_EQUALS:
- {
- EphyNode *prop;
-
- prop = ephy_node_get_property_node (node,
- exp->args.prop_args.prop_id);
-
- return (prop == exp->args.prop_args.second_arg.node);
- }
- case EPHY_NODE_FILTER_EXPRESSION_CHILD_PROP_EQUALS:
- {
- EphyNode *prop;
- GPtrArray *children;
- guint i;
-
- children = ephy_node_get_children (node);
- for (i = 0; i < children->len; i++)
- {
- EphyNode *child;
-
- child = g_ptr_array_index (children, i);
- prop = ephy_node_get_property_node
- (child, exp->args.prop_args.prop_id);
-
- if (prop == exp->args.prop_args.second_arg.node)
- {
- return TRUE;
- }
- }
-
- return FALSE;
- }
- case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_CONTAINS:
- {
- const char *prop;
- char *folded_case;
- gboolean ret;
-
- prop = ephy_node_get_property_string (node,
- exp->args.prop_args.prop_id);
- if (prop == NULL)
- return FALSE;
-
- folded_case = g_utf8_casefold (prop, -1);
- ret = (strstr (folded_case, exp->args.prop_args.second_arg.string) != NULL);
- g_free (folded_case);
-
- return ret;
- }
- case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_EQUALS:
- {
- const char *prop;
- char *folded_case;
- gboolean ret;
-
- prop = ephy_node_get_property_string (node,
- exp->args.prop_args.prop_id);
-
- if (prop == NULL)
- return FALSE;
-
- folded_case = g_utf8_casefold (prop, -1);
- ret = (strcmp (folded_case, exp->args.prop_args.second_arg.string) == 0);
- g_free (folded_case);
-
- return ret;
- }
- case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_CONTAINS:
- {
- const char *prop;
-
- prop = ephy_node_get_property_string (node,
- exp->args.prop_args.prop_id);
-
- if (prop == NULL)
- return FALSE;
-
- return (strstr (prop, exp->args.prop_args.second_arg.string) != NULL);
- }
- case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_EQUALS:
- {
- const char *prop;
-
- prop = ephy_node_get_property_string (node,
- exp->args.prop_args.prop_id);
-
- if (prop == NULL)
- return FALSE;
-
- return (strcmp (prop, exp->args.prop_args.second_arg.string) == 0);
- }
- case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_EQUALS:
- {
- int prop;
-
- prop = ephy_node_get_property_int (node,
- exp->args.prop_args.prop_id);
-
- return (prop == exp->args.prop_args.second_arg.number);
- }
- case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_BIGGER_THAN:
- {
- int prop;
-
- prop = ephy_node_get_property_int (node,
- exp->args.prop_args.prop_id);
-
- return (prop > exp->args.prop_args.second_arg.number);
- }
- case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_LESS_THAN:
- {
- int prop;
-
- prop = ephy_node_get_property_int (node,
- exp->args.prop_args.prop_id);
-
- return (prop < exp->args.prop_args.second_arg.number);
- }
- default:
- break;
- }
-
- return FALSE;
+ switch (exp->type) {
+ case EPHY_NODE_FILTER_EXPRESSION_ALWAYS_TRUE:
+ return TRUE;
+ case EPHY_NODE_FILTER_EXPRESSION_NODE_EQUALS:
+ return (exp->args.node_args.a == exp->args.node_args.b);
+ case EPHY_NODE_FILTER_EXPRESSION_EQUALS:
+ return (exp->args.node_args.a == node);
+ case EPHY_NODE_FILTER_EXPRESSION_HAS_PARENT:
+ return ephy_node_has_child (exp->args.node_args.a, node);
+ case EPHY_NODE_FILTER_EXPRESSION_HAS_CHILD:
+ return ephy_node_has_child (node, exp->args.node_args.a);
+ case EPHY_NODE_FILTER_EXPRESSION_NODE_PROP_EQUALS:
+ {
+ EphyNode *prop;
+
+ prop = ephy_node_get_property_node (node,
+ exp->args.prop_args.prop_id);
+
+ return (prop == exp->args.prop_args.second_arg.node);
+ }
+ case EPHY_NODE_FILTER_EXPRESSION_CHILD_PROP_EQUALS:
+ {
+ EphyNode *prop;
+ GPtrArray *children;
+ guint i;
+
+ children = ephy_node_get_children (node);
+ for (i = 0; i < children->len; i++) {
+ EphyNode *child;
+
+ child = g_ptr_array_index (children, i);
+ prop = ephy_node_get_property_node
+ (child, exp->args.prop_args.prop_id);
+
+ if (prop == exp->args.prop_args.second_arg.node) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+ }
+ case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_CONTAINS:
+ {
+ const char *prop;
+ char *folded_case;
+ gboolean ret;
+
+ prop = ephy_node_get_property_string (node,
+ exp->args.prop_args.prop_id);
+ if (prop == NULL)
+ return FALSE;
+
+ folded_case = g_utf8_casefold (prop, -1);
+ ret = (strstr (folded_case, exp->args.prop_args.second_arg.string) != NULL);
+ g_free (folded_case);
+
+ return ret;
+ }
+ case EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_EQUALS:
+ {
+ const char *prop;
+ char *folded_case;
+ gboolean ret;
+
+ prop = ephy_node_get_property_string (node,
+ exp->args.prop_args.prop_id);
+
+ if (prop == NULL)
+ return FALSE;
+
+ folded_case = g_utf8_casefold (prop, -1);
+ ret = (strcmp (folded_case, exp->args.prop_args.second_arg.string) == 0);
+ g_free (folded_case);
+
+ return ret;
+ }
+ case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_CONTAINS:
+ {
+ const char *prop;
+
+ prop = ephy_node_get_property_string (node,
+ exp->args.prop_args.prop_id);
+
+ if (prop == NULL)
+ return FALSE;
+
+ return (strstr (prop, exp->args.prop_args.second_arg.string) != NULL);
+ }
+ case EPHY_NODE_FILTER_EXPRESSION_KEY_PROP_EQUALS:
+ {
+ const char *prop;
+
+ prop = ephy_node_get_property_string (node,
+ exp->args.prop_args.prop_id);
+
+ if (prop == NULL)
+ return FALSE;
+
+ return (strcmp (prop, exp->args.prop_args.second_arg.string) == 0);
+ }
+ case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_EQUALS:
+ {
+ int prop;
+
+ prop = ephy_node_get_property_int (node,
+ exp->args.prop_args.prop_id);
+
+ return (prop == exp->args.prop_args.second_arg.number);
+ }
+ case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_BIGGER_THAN:
+ {
+ int prop;
+
+ prop = ephy_node_get_property_int (node,
+ exp->args.prop_args.prop_id);
+
+ return (prop > exp->args.prop_args.second_arg.number);
+ }
+ case EPHY_NODE_FILTER_EXPRESSION_INT_PROP_LESS_THAN:
+ {
+ int prop;
+
+ prop = ephy_node_get_property_int (node,
+ exp->args.prop_args.prop_id);
+
+ return (prop < exp->args.prop_args.second_arg.number);
+ }
+ default:
+ break;
+ }
+
+ return FALSE;
}
diff --git a/lib/ephy-node.c b/lib/ephy-node.c
index 9216a38..0303fda 100644
--- a/lib/ephy-node.c
+++ b/lib/ephy-node.c
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright © 2002 Jorn Baayen <jorn nl linux org>
* Copyright © 2003 Marco Pesenti Gritti
* Copyright © 2003 Christian Persch
@@ -29,356 +29,348 @@
#include "ephy-node.h"
-typedef struct
-{
- EphyNode *node;
- int id;
- EphyNodeCallback callback;
- EphyNodeSignalType type;
- gpointer data;
- gboolean invalidated;
+typedef struct {
+ EphyNode *node;
+ int id;
+ EphyNodeCallback callback;
+ EphyNodeSignalType type;
+ gpointer data;
+ gboolean invalidated;
} EphyNodeSignalData;
-typedef struct
-{
- EphyNode *node;
- guint index;
+typedef struct {
+ EphyNode *node;
+ guint index;
} EphyNodeParent;
-typedef struct
-{
- EphyNode *node;
- guint property_id;
+typedef struct {
+ EphyNode *node;
+ guint property_id;
} EphyNodeChange;
-struct _EphyNode
-{
- int ref_count;
+struct _EphyNode {
+ int ref_count;
- guint id;
+ guint id;
- GPtrArray *properties;
+ GPtrArray *properties;
- GHashTable *parents;
- GPtrArray *children;
+ GHashTable *parents;
+ GPtrArray *children;
- GHashTable *signals;
- int signal_id;
- guint emissions;
- guint invalidated_signals;
- guint is_drag_source : 1;
- guint is_drag_dest : 1;
+ GHashTable *signals;
+ int signal_id;
+ guint emissions;
+ guint invalidated_signals;
+ guint is_drag_source : 1;
+ guint is_drag_dest : 1;
- EphyNodeDb *db;
+ EphyNodeDb *db;
};
-typedef struct
-{
- EphyNodeSignalType type;
- va_list valist;
+typedef struct {
+ EphyNodeSignalType type;
+ va_list valist;
} ENESCData;
static gboolean
int_equal (gconstpointer a,
- gconstpointer b)
+ gconstpointer b)
{
- return GPOINTER_TO_INT (a) == GPOINTER_TO_INT (b);
+ return GPOINTER_TO_INT (a) == GPOINTER_TO_INT (b);
}
static guint
int_hash (gconstpointer a)
{
- return GPOINTER_TO_INT (a);
+ return GPOINTER_TO_INT (a);
}
static void
callback (long id, EphyNodeSignalData *data, gpointer *dummy)
{
- ENESCData *user_data;
- va_list valist;
+ ENESCData *user_data;
+ va_list valist;
+
+ if (data->invalidated) return;
+
+ user_data = (ENESCData *)dummy;
- if (data->invalidated) return;
+ G_VA_COPY (valist, user_data->valist);
- user_data = (ENESCData *) dummy;
+ if (data->type != user_data->type) return;
- G_VA_COPY(valist, user_data->valist);
+ switch (data->type) {
+ case EPHY_NODE_DESTROY:
+ case EPHY_NODE_RESTORED:
+ data->callback (data->node, data->data);
+ break;
- if (data->type != user_data->type) return;
+ case EPHY_NODE_CHANGED:
+ {
+ guint property_id;
- switch (data->type)
- {
- case EPHY_NODE_DESTROY:
- case EPHY_NODE_RESTORED:
- data->callback (data->node, data->data);
- break;
+ property_id = va_arg (valist, guint);
- case EPHY_NODE_CHANGED:
- {
- guint property_id;
+ data->callback (data->node, property_id, data->data);
+ }
+ break;
- property_id = va_arg (valist, guint);
-
- data->callback (data->node, property_id, data->data);
- }
- break;
+ case EPHY_NODE_CHILD_ADDED:
+ {
+ EphyNode *node;
- case EPHY_NODE_CHILD_ADDED:
- {
- EphyNode *node;
+ node = va_arg (valist, EphyNode *);
- node = va_arg (valist, EphyNode *);
-
- data->callback (data->node, node, data->data);
- }
- break;
+ data->callback (data->node, node, data->data);
+ }
+ break;
- case EPHY_NODE_CHILD_CHANGED:
- {
- EphyNode *node;
- guint property_id;
+ case EPHY_NODE_CHILD_CHANGED:
+ {
+ EphyNode *node;
+ guint property_id;
- node = va_arg (valist, EphyNode *);
- property_id = va_arg (valist, guint);
-
- data->callback (data->node, node, property_id, data->data);
- }
- break;
+ node = va_arg (valist, EphyNode *);
+ property_id = va_arg (valist, guint);
- case EPHY_NODE_CHILD_REMOVED:
- {
- EphyNode *node;
- guint last_index;
+ data->callback (data->node, node, property_id, data->data);
+ }
+ break;
- node = va_arg (valist, EphyNode *);
- last_index = va_arg (valist, guint);
+ case EPHY_NODE_CHILD_REMOVED:
+ {
+ EphyNode *node;
+ guint last_index;
- data->callback (data->node, node, last_index, data->data);
- }
- break;
+ node = va_arg (valist, EphyNode *);
+ last_index = va_arg (valist, guint);
- case EPHY_NODE_CHILDREN_REORDERED:
- data->callback (data->node, va_arg (valist, int *), data->data);
- break;
+ data->callback (data->node, node, last_index, data->data);
+ }
+ break;
- default:
- break;
- }
+ case EPHY_NODE_CHILDREN_REORDERED:
+ data->callback (data->node, va_arg (valist, int *), data->data);
+ break;
- va_end(valist);
+ default:
+ break;
+ }
+
+ va_end (valist);
}
static gboolean
-remove_invalidated_signals (long id,
- EphyNodeSignalData *data,
- gpointer user_data)
+remove_invalidated_signals (long id,
+ EphyNodeSignalData *data,
+ gpointer user_data)
{
- return data->invalidated;
+ return data->invalidated;
}
static void
ephy_node_emit_signal (EphyNode *node, EphyNodeSignalType type, ...)
{
- ENESCData data;
+ ENESCData data;
- ++node->emissions;
+ ++node->emissions;
- va_start (data.valist, type);
+ va_start (data.valist, type);
- data.type = type;
+ data.type = type;
- g_hash_table_foreach (node->signals,
- (GHFunc) callback,
- &data);
+ g_hash_table_foreach (node->signals,
+ (GHFunc)callback,
+ &data);
- va_end (data.valist);
+ va_end (data.valist);
- if (G_UNLIKELY (--node->emissions == 0 && node->invalidated_signals))
- {
- guint removed;
+ if (G_UNLIKELY (--node->emissions == 0 && node->invalidated_signals)) {
+ guint removed;
- removed = g_hash_table_foreach_remove
- (node->signals,
- (GHRFunc) remove_invalidated_signals,
- NULL);
- g_assert (removed == node->invalidated_signals);
+ removed = g_hash_table_foreach_remove
+ (node->signals,
+ (GHRFunc)remove_invalidated_signals,
+ NULL);
+ g_assert (removed == node->invalidated_signals);
- node->invalidated_signals = 0;
- }
+ node->invalidated_signals = 0;
+ }
}
static inline void
real_remove_child (EphyNode *node,
- EphyNode *child,
- gboolean remove_from_parent,
- gboolean remove_from_child)
+ EphyNode *child,
+ gboolean remove_from_parent,
+ gboolean remove_from_child)
{
- EphyNodeParent *node_info;
+ EphyNodeParent *node_info;
- node_info = g_hash_table_lookup (child->parents,
- GINT_TO_POINTER (node->id));
+ node_info = g_hash_table_lookup (child->parents,
+ GINT_TO_POINTER (node->id));
- if (remove_from_parent) {
- guint i;
- guint old_index;
+ if (remove_from_parent) {
+ guint i;
+ guint old_index;
- old_index = node_info->index;
+ old_index = node_info->index;
- g_ptr_array_remove_index (node->children,
- node_info->index);
+ g_ptr_array_remove_index (node->children,
+ node_info->index);
- /* correct indices on kids */
- for (i = node_info->index; i < node->children->len; i++) {
- EphyNode *borked_node;
- EphyNodeParent *borked_node_info;
+ /* correct indices on kids */
+ for (i = node_info->index; i < node->children->len; i++) {
+ EphyNode *borked_node;
+ EphyNodeParent *borked_node_info;
- borked_node = g_ptr_array_index (node->children, i);
+ borked_node = g_ptr_array_index (node->children, i);
- borked_node_info = g_hash_table_lookup (borked_node->parents,
- GINT_TO_POINTER (node->id));
- borked_node_info->index--;
- }
+ borked_node_info = g_hash_table_lookup (borked_node->parents,
+ GINT_TO_POINTER (node->id));
+ borked_node_info->index--;
+ }
- ephy_node_emit_signal (node, EPHY_NODE_CHILD_REMOVED, child, old_index);
- }
+ ephy_node_emit_signal (node, EPHY_NODE_CHILD_REMOVED, child, old_index);
+ }
- if (remove_from_child) {
- g_hash_table_remove (child->parents,
- GINT_TO_POINTER (node->id));
- }
+ if (remove_from_child) {
+ g_hash_table_remove (child->parents,
+ GINT_TO_POINTER (node->id));
+ }
}
static void
-remove_child (long id,
- EphyNodeParent *node_info,
- EphyNode *node)
+remove_child (long id,
+ EphyNodeParent *node_info,
+ EphyNode *node)
{
- real_remove_child (node_info->node, node, TRUE, FALSE);
+ real_remove_child (node_info->node, node, TRUE, FALSE);
}
static void
signal_object_weak_notify (EphyNodeSignalData *signal_data,
- GObject *where_the_object_was)
+ GObject *where_the_object_was)
{
- signal_data->data = NULL;
- ephy_node_signal_disconnect (signal_data->node, signal_data->id);
+ signal_data->data = NULL;
+ ephy_node_signal_disconnect (signal_data->node, signal_data->id);
}
static void
destroy_signal_data (EphyNodeSignalData *signal_data)
{
- if (signal_data->data)
- {
- g_object_weak_unref (G_OBJECT (signal_data->data),
- (GWeakNotify)signal_object_weak_notify,
- signal_data);
- }
-
- g_slice_free (EphyNodeSignalData, signal_data);
+ if (signal_data->data) {
+ g_object_weak_unref (G_OBJECT (signal_data->data),
+ (GWeakNotify)signal_object_weak_notify,
+ signal_data);
+ }
+
+ g_slice_free (EphyNodeSignalData, signal_data);
}
static void
node_parent_free (EphyNodeParent *parent)
{
- g_slice_free (EphyNodeParent, parent);
+ g_slice_free (EphyNodeParent, parent);
}
static void
ephy_node_destroy (EphyNode *node)
{
- guint i;
+ guint i;
- ephy_node_emit_signal (node, EPHY_NODE_DESTROY);
+ ephy_node_emit_signal (node, EPHY_NODE_DESTROY);
- /* Remove from parents. */
- g_hash_table_foreach (node->parents,
- (GHFunc) remove_child,
- node);
- g_hash_table_destroy (node->parents);
+ /* Remove from parents. */
+ g_hash_table_foreach (node->parents,
+ (GHFunc)remove_child,
+ node);
+ g_hash_table_destroy (node->parents);
- /* Remove children. */
- for (i = 0; i < node->children->len; i++) {
- EphyNode *child;
+ /* Remove children. */
+ for (i = 0; i < node->children->len; i++) {
+ EphyNode *child;
- child = g_ptr_array_index (node->children, i);
+ child = g_ptr_array_index (node->children, i);
- real_remove_child (node, child, FALSE, TRUE);
- }
- g_ptr_array_free (node->children, TRUE);
-
- /* Remove signals. */
- g_hash_table_destroy (node->signals);
+ real_remove_child (node, child, FALSE, TRUE);
+ }
+ g_ptr_array_free (node->children, TRUE);
- /* Remove id. */
- _ephy_node_db_remove_id (node->db, node->id);
+ /* Remove signals. */
+ g_hash_table_destroy (node->signals);
- /* Remove properties. */
- for (i = 0; i < node->properties->len; i++) {
- GValue *val;
+ /* Remove id. */
+ _ephy_node_db_remove_id (node->db, node->id);
- val = g_ptr_array_index (node->properties, i);
+ /* Remove properties. */
+ for (i = 0; i < node->properties->len; i++) {
+ GValue *val;
- if (val != NULL) {
- g_value_unset (val);
- g_slice_free (GValue, val);
- }
- }
- g_ptr_array_free (node->properties, TRUE);
+ val = g_ptr_array_index (node->properties, i);
- g_slice_free (EphyNode, node);
+ if (val != NULL) {
+ g_value_unset (val);
+ g_slice_free (GValue, val);
+ }
+ }
+ g_ptr_array_free (node->properties, TRUE);
+
+ g_slice_free (EphyNode, node);
}
EphyNode *
ephy_node_new (EphyNodeDb *db)
{
- long id;
+ long id;
- g_return_val_if_fail (EPHY_IS_NODE_DB (db), NULL);
+ g_return_val_if_fail (EPHY_IS_NODE_DB (db), NULL);
- if (ephy_node_db_is_immutable (db)) return NULL;
+ if (ephy_node_db_is_immutable (db)) return NULL;
- id = _ephy_node_db_new_id (db);
+ id = _ephy_node_db_new_id (db);
- return ephy_node_new_with_id (db, id);
+ return ephy_node_new_with_id (db, id);
}
EphyNode *
ephy_node_new_with_id (EphyNodeDb *db, guint reserved_id)
{
- EphyNode *node;
+ EphyNode *node;
- g_return_val_if_fail (EPHY_IS_NODE_DB (db), NULL);
+ g_return_val_if_fail (EPHY_IS_NODE_DB (db), NULL);
- if (ephy_node_db_is_immutable (db)) return NULL;
+ if (ephy_node_db_is_immutable (db)) return NULL;
- node = g_slice_new0 (EphyNode);
+ node = g_slice_new0 (EphyNode);
- node->ref_count = 1;
+ node->ref_count = 1;
- node->id = reserved_id;
+ node->id = reserved_id;
- node->db = db;
+ node->db = db;
- node->properties = g_ptr_array_new ();
+ node->properties = g_ptr_array_new ();
- node->children = g_ptr_array_new ();
+ node->children = g_ptr_array_new ();
- node->parents = g_hash_table_new_full
- (int_hash, int_equal, NULL, (GDestroyNotify) node_parent_free);
+ node->parents = g_hash_table_new_full
+ (int_hash, int_equal, NULL, (GDestroyNotify)node_parent_free);
- node->signals = g_hash_table_new_full
- (int_hash, int_equal, NULL,
- (GDestroyNotify)destroy_signal_data);
+ node->signals = g_hash_table_new_full
+ (int_hash, int_equal, NULL,
+ (GDestroyNotify)destroy_signal_data);
- node->signal_id = 0;
- node->emissions = 0;
- node->invalidated_signals = 0;
- node->is_drag_source = TRUE;
- node->is_drag_dest = TRUE;
+ node->signal_id = 0;
+ node->emissions = 0;
+ node->invalidated_signals = 0;
+ node->is_drag_source = TRUE;
+ node->is_drag_dest = TRUE;
- _ephy_node_db_add_id (db, reserved_id, node);
+ _ephy_node_db_add_id (db, reserved_id, node);
- return node;
+ return node;
}
/**
@@ -389,108 +381,107 @@ ephy_node_new_with_id (EphyNodeDb *db, guint reserved_id)
EphyNodeDb *
ephy_node_get_db (EphyNode *node)
{
- g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
-
- return node->db;
+ g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
+
+ return node->db;
}
guint
ephy_node_get_id (EphyNode *node)
{
- long ret;
+ long ret;
- g_return_val_if_fail (EPHY_IS_NODE (node), G_MAXUINT);
+ g_return_val_if_fail (EPHY_IS_NODE (node), G_MAXUINT);
- ret = node->id;
+ ret = node->id;
- return ret;
+ return ret;
}
void
ephy_node_ref (EphyNode *node)
{
- g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (EPHY_IS_NODE (node));
- node->ref_count++;
+ node->ref_count++;
}
void
ephy_node_unref (EphyNode *node)
{
- g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (EPHY_IS_NODE (node));
- node->ref_count--;
+ node->ref_count--;
- if (node->ref_count <= 0) {
- ephy_node_destroy (node);
- }
+ if (node->ref_count <= 0) {
+ ephy_node_destroy (node);
+ }
}
static void
-child_changed (guint id,
- EphyNodeParent *node_info,
- EphyNodeChange *change)
+child_changed (guint id,
+ EphyNodeParent *node_info,
+ EphyNodeChange *change)
{
- ephy_node_emit_signal (node_info->node, EPHY_NODE_CHILD_CHANGED,
- change->node, change->property_id);
+ ephy_node_emit_signal (node_info->node, EPHY_NODE_CHILD_CHANGED,
+ change->node, change->property_id);
}
static inline void
real_set_property (EphyNode *node,
- guint property_id,
- GValue *value)
+ guint property_id,
+ GValue *value)
{
- GValue *old;
+ GValue *old;
- if (property_id >= node->properties->len) {
- g_ptr_array_set_size (node->properties, property_id + 1);
- }
+ if (property_id >= node->properties->len) {
+ g_ptr_array_set_size (node->properties, property_id + 1);
+ }
- old = g_ptr_array_index (node->properties, property_id);
- if (old != NULL) {
- g_value_unset (old);
- g_slice_free (GValue, old);
- }
+ old = g_ptr_array_index (node->properties, property_id);
+ if (old != NULL) {
+ g_value_unset (old);
+ g_slice_free (GValue, old);
+ }
- g_ptr_array_index (node->properties, property_id) = value;
+ g_ptr_array_index (node->properties, property_id) = value;
}
static inline void
ephy_node_set_property_internal (EphyNode *node,
- guint property_id,
- GValue *value)
+ guint property_id,
+ GValue *value)
{
- EphyNodeChange change;
+ EphyNodeChange change;
- real_set_property (node, property_id, value);
+ real_set_property (node, property_id, value);
- change.node = node;
- change.property_id = property_id;
- g_hash_table_foreach (node->parents,
- (GHFunc) child_changed,
- &change);
-
- ephy_node_emit_signal (node, EPHY_NODE_CHANGED, property_id);
+ change.node = node;
+ change.property_id = property_id;
+ g_hash_table_foreach (node->parents,
+ (GHFunc)child_changed,
+ &change);
+ ephy_node_emit_signal (node, EPHY_NODE_CHANGED, property_id);
}
void
-ephy_node_set_property (EphyNode *node,
- guint property_id,
- const GValue *value)
+ephy_node_set_property (EphyNode *node,
+ guint property_id,
+ const GValue *value)
{
- GValue *new;
+ GValue *new;
- g_return_if_fail (EPHY_IS_NODE (node));
- g_return_if_fail (value != NULL);
+ g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (value != NULL);
- if (ephy_node_db_is_immutable (node->db)) return;
+ if (ephy_node_db_is_immutable (node->db)) return;
- new = g_slice_new0 (GValue);
- g_value_init (new, G_VALUE_TYPE (value));
- g_value_copy (value, new);
+ new = g_slice_new0 (GValue);
+ g_value_init (new, G_VALUE_TYPE (value));
+ g_value_copy (value, new);
- ephy_node_set_property_internal (node, property_id, new);
+ ephy_node_set_property_internal (node, property_id, new);
}
/**
@@ -500,273 +491,273 @@ ephy_node_set_property (EphyNode *node,
*/
gboolean
ephy_node_get_property (EphyNode *node,
- guint property_id,
- GValue *value)
+ guint property_id,
+ GValue *value)
{
- GValue *ret;
+ GValue *ret;
- g_return_val_if_fail (EPHY_IS_NODE (node), FALSE);
- g_return_val_if_fail (value != NULL, FALSE);
+ g_return_val_if_fail (EPHY_IS_NODE (node), FALSE);
+ g_return_val_if_fail (value != NULL, FALSE);
- if (property_id >= node->properties->len) {
- return FALSE;
- }
+ if (property_id >= node->properties->len) {
+ return FALSE;
+ }
- ret = g_ptr_array_index (node->properties, property_id);
- if (ret == NULL) {
- return FALSE;
- }
+ ret = g_ptr_array_index (node->properties, property_id);
+ if (ret == NULL) {
+ return FALSE;
+ }
- g_value_init (value, G_VALUE_TYPE (ret));
- g_value_copy (ret, value);
+ g_value_init (value, G_VALUE_TYPE (ret));
+ g_value_copy (ret, value);
- return TRUE;
+ return TRUE;
}
void
-ephy_node_set_property_string (EphyNode *node,
- guint property_id,
- const char *value)
+ephy_node_set_property_string (EphyNode *node,
+ guint property_id,
+ const char *value)
{
- GValue *new;
+ GValue *new;
- g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (EPHY_IS_NODE (node));
- if (ephy_node_db_is_immutable (node->db)) return;
+ if (ephy_node_db_is_immutable (node->db)) return;
- new = g_slice_new0 (GValue);
- g_value_init (new, G_TYPE_STRING);
- g_value_set_string (new, value);
+ new = g_slice_new0 (GValue);
+ g_value_init (new, G_TYPE_STRING);
+ g_value_set_string (new, value);
- ephy_node_set_property_internal (node, property_id, new);
+ ephy_node_set_property_internal (node, property_id, new);
}
const char *
ephy_node_get_property_string (EphyNode *node,
- guint property_id)
+ guint property_id)
{
- GValue *ret;
- const char *retval;
+ GValue *ret;
+ const char *retval;
- g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
+ g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
- if (property_id >= node->properties->len) {
- return NULL;
- }
+ if (property_id >= node->properties->len) {
+ return NULL;
+ }
- ret = g_ptr_array_index (node->properties, property_id);
- if (ret == NULL) {
- return NULL;
- }
+ ret = g_ptr_array_index (node->properties, property_id);
+ if (ret == NULL) {
+ return NULL;
+ }
- retval = g_value_get_string (ret);
+ retval = g_value_get_string (ret);
- return retval;
+ return retval;
}
void
ephy_node_set_property_boolean (EphyNode *node,
- guint property_id,
- gboolean value)
+ guint property_id,
+ gboolean value)
{
- GValue *new;
+ GValue *new;
- g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (EPHY_IS_NODE (node));
- if (ephy_node_db_is_immutable (node->db)) return;
+ if (ephy_node_db_is_immutable (node->db)) return;
- new = g_slice_new0 (GValue);
- g_value_init (new, G_TYPE_BOOLEAN);
- g_value_set_boolean (new, value);
+ new = g_slice_new0 (GValue);
+ g_value_init (new, G_TYPE_BOOLEAN);
+ g_value_set_boolean (new, value);
- ephy_node_set_property_internal (node, property_id, new);
+ ephy_node_set_property_internal (node, property_id, new);
}
gboolean
ephy_node_get_property_boolean (EphyNode *node,
- guint property_id)
+ guint property_id)
{
- GValue *ret;
- gboolean retval;
+ GValue *ret;
+ gboolean retval;
- g_return_val_if_fail (EPHY_IS_NODE (node), FALSE);
+ g_return_val_if_fail (EPHY_IS_NODE (node), FALSE);
- if (property_id >= node->properties->len) {
- return FALSE;
- }
+ if (property_id >= node->properties->len) {
+ return FALSE;
+ }
- ret = g_ptr_array_index (node->properties, property_id);
- if (ret == NULL) {
- return FALSE;
- }
+ ret = g_ptr_array_index (node->properties, property_id);
+ if (ret == NULL) {
+ return FALSE;
+ }
- retval = g_value_get_boolean (ret);
+ retval = g_value_get_boolean (ret);
- return retval;
+ return retval;
}
void
ephy_node_set_property_long (EphyNode *node,
- guint property_id,
- long value)
+ guint property_id,
+ long value)
{
- GValue *new;
+ GValue *new;
- g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (EPHY_IS_NODE (node));
- if (ephy_node_db_is_immutable (node->db)) return;
+ if (ephy_node_db_is_immutable (node->db)) return;
- new = g_slice_new0 (GValue);
- g_value_init (new, G_TYPE_LONG);
- g_value_set_long (new, value);
+ new = g_slice_new0 (GValue);
+ g_value_init (new, G_TYPE_LONG);
+ g_value_set_long (new, value);
- ephy_node_set_property_internal (node, property_id, new);
+ ephy_node_set_property_internal (node, property_id, new);
}
long
ephy_node_get_property_long (EphyNode *node,
- guint property_id)
+ guint property_id)
{
- GValue *ret;
- long retval;
+ GValue *ret;
+ long retval;
- g_return_val_if_fail (EPHY_IS_NODE (node), -1);
+ g_return_val_if_fail (EPHY_IS_NODE (node), -1);
- if (property_id >= node->properties->len) {
- return -1;
- }
+ if (property_id >= node->properties->len) {
+ return -1;
+ }
- ret = g_ptr_array_index (node->properties, property_id);
- if (ret == NULL) {
- return -1;
- }
+ ret = g_ptr_array_index (node->properties, property_id);
+ if (ret == NULL) {
+ return -1;
+ }
- retval = g_value_get_long (ret);
+ retval = g_value_get_long (ret);
- return retval;
+ return retval;
}
void
ephy_node_set_property_int (EphyNode *node,
- guint property_id,
- int value)
+ guint property_id,
+ int value)
{
- GValue *new;
+ GValue *new;
- g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (EPHY_IS_NODE (node));
- if (ephy_node_db_is_immutable (node->db)) return;
+ if (ephy_node_db_is_immutable (node->db)) return;
- new = g_slice_new0 (GValue);
- g_value_init (new, G_TYPE_INT);
- g_value_set_int (new, value);
+ new = g_slice_new0 (GValue);
+ g_value_init (new, G_TYPE_INT);
+ g_value_set_int (new, value);
- ephy_node_set_property_internal (node, property_id, new);
+ ephy_node_set_property_internal (node, property_id, new);
}
int
ephy_node_get_property_int (EphyNode *node,
- guint property_id)
+ guint property_id)
{
- GValue *ret;
- int retval;
+ GValue *ret;
+ int retval;
- g_return_val_if_fail (EPHY_IS_NODE (node), -1);
+ g_return_val_if_fail (EPHY_IS_NODE (node), -1);
- if (property_id >= node->properties->len) {
- return -1;
- }
+ if (property_id >= node->properties->len) {
+ return -1;
+ }
- ret = g_ptr_array_index (node->properties, property_id);
- if (ret == NULL) {
- return -1;
- }
+ ret = g_ptr_array_index (node->properties, property_id);
+ if (ret == NULL) {
+ return -1;
+ }
- retval = g_value_get_int (ret);
+ retval = g_value_get_int (ret);
- return retval;
+ return retval;
}
void
ephy_node_set_property_double (EphyNode *node,
- guint property_id,
- double value)
+ guint property_id,
+ double value)
{
- GValue *new;
+ GValue *new;
- g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (EPHY_IS_NODE (node));
- if (ephy_node_db_is_immutable (node->db)) return;
+ if (ephy_node_db_is_immutable (node->db)) return;
- new = g_slice_new0 (GValue);
- g_value_init (new, G_TYPE_DOUBLE);
- g_value_set_double (new, value);
+ new = g_slice_new0 (GValue);
+ g_value_init (new, G_TYPE_DOUBLE);
+ g_value_set_double (new, value);
- ephy_node_set_property_internal (node, property_id, new);
+ ephy_node_set_property_internal (node, property_id, new);
}
double
ephy_node_get_property_double (EphyNode *node,
- guint property_id)
+ guint property_id)
{
- GValue *ret;
- double retval;
+ GValue *ret;
+ double retval;
- g_return_val_if_fail (EPHY_IS_NODE (node), -1);
+ g_return_val_if_fail (EPHY_IS_NODE (node), -1);
- if (property_id >= node->properties->len) {
- return -1;
- }
+ if (property_id >= node->properties->len) {
+ return -1;
+ }
- ret = g_ptr_array_index (node->properties, property_id);
- if (ret == NULL) {
- return -1;
- }
+ ret = g_ptr_array_index (node->properties, property_id);
+ if (ret == NULL) {
+ return -1;
+ }
- retval = g_value_get_double (ret);
+ retval = g_value_get_double (ret);
- return retval;
+ return retval;
}
void
ephy_node_set_property_float (EphyNode *node,
- guint property_id,
- float value)
+ guint property_id,
+ float value)
{
- GValue *new;
+ GValue *new;
- g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (EPHY_IS_NODE (node));
- if (ephy_node_db_is_immutable (node->db)) return;
+ if (ephy_node_db_is_immutable (node->db)) return;
- new = g_slice_new0 (GValue);
- g_value_init (new, G_TYPE_FLOAT);
- g_value_set_float (new, value);
+ new = g_slice_new0 (GValue);
+ g_value_init (new, G_TYPE_FLOAT);
+ g_value_set_float (new, value);
- ephy_node_set_property_internal (node, property_id, new);
+ ephy_node_set_property_internal (node, property_id, new);
}
float
ephy_node_get_property_float (EphyNode *node,
- guint property_id)
+ guint property_id)
{
- GValue *ret;
- float retval;
+ GValue *ret;
+ float retval;
- g_return_val_if_fail (EPHY_IS_NODE (node), -1);
+ g_return_val_if_fail (EPHY_IS_NODE (node), -1);
- if (property_id >= node->properties->len) {
- return -1;
- }
+ if (property_id >= node->properties->len) {
+ return -1;
+ }
- ret = g_ptr_array_index (node->properties, property_id);
- if (ret == NULL) {
- return -1;
- }
+ ret = g_ptr_array_index (node->properties, property_id);
+ if (ret == NULL) {
+ return -1;
+ }
- retval = g_value_get_float (ret);
+ retval = g_value_get_float (ret);
- return retval;
+ return retval;
}
/**
@@ -776,371 +767,351 @@ ephy_node_get_property_float (EphyNode *node,
**/
EphyNode *
ephy_node_get_property_node (EphyNode *node,
- guint property_id)
+ guint property_id)
{
- GValue *ret;
- EphyNode *retval;
+ GValue *ret;
+ EphyNode *retval;
- g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
+ g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
- if (property_id >= node->properties->len) {
- return NULL;
- }
+ if (property_id >= node->properties->len) {
+ return NULL;
+ }
- ret = g_ptr_array_index (node->properties, property_id);
- if (ret == NULL) {
- return NULL;
- }
+ ret = g_ptr_array_index (node->properties, property_id);
+ if (ret == NULL) {
+ return NULL;
+ }
- retval = g_value_get_pointer (ret);
+ retval = g_value_get_pointer (ret);
- return retval;
+ return retval;
}
-typedef struct
-{
- xmlTextWriterPtr writer;
- int ret;
+typedef struct {
+ xmlTextWriterPtr writer;
+ int ret;
} ForEachData;
static void
-write_parent (guint id,
- EphyNodeParent *node_info,
- ForEachData* data)
+write_parent (guint id,
+ EphyNodeParent *node_info,
+ ForEachData *data)
{
- xmlTextWriterPtr writer = data->writer;
+ xmlTextWriterPtr writer = data->writer;
- /* there already was an error, do nothing. this works around
- * the fact that g_hash_table_foreach cannot be cancelled.
- */
- if (data->ret < 0) return;
+ /* there already was an error, do nothing. this works around
+ * the fact that g_hash_table_foreach cannot be cancelled.
+ */
+ if (data->ret < 0) return;
- data->ret = xmlTextWriterStartElement (writer, (const xmlChar *)"parent");
- if (data->ret < 0) return;
+ data->ret = xmlTextWriterStartElement (writer, (const xmlChar *)"parent");
+ if (data->ret < 0) return;
- data->ret = xmlTextWriterWriteFormatAttribute
- (writer, (const xmlChar *)"id", "%d", node_info->node->id);
- if (data->ret < 0) return;
+ data->ret = xmlTextWriterWriteFormatAttribute
+ (writer, (const xmlChar *)"id", "%d", node_info->node->id);
+ if (data->ret < 0) return;
- data->ret = xmlTextWriterEndElement (writer); /* parent */
- if (data->ret < 0) return;
+ data->ret = xmlTextWriterEndElement (writer); /* parent */
+ if (data->ret < 0) return;
}
static inline int
safe_write_string (xmlTextWriterPtr writer,
- const xmlChar *string)
+ const xmlChar *string)
{
- int ret;
- xmlChar *copy, *p;
-
- if (!string)
- return 0;
-
- /* http://www.w3.org/TR/REC-xml/#sec-well-formed :
- Character Range
- [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] |
- [#xE000-#xFFFD] | [#x10000-#x10FFFF]
- any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
- */
-
- copy = xmlStrdup (string);
- for (p = copy; *p; p++)
- {
- xmlChar c = *p;
- if (G_UNLIKELY (c < 0x20 && c != 0xd && c != 0xa && c != 0x9)) {
- *p = 0x20;
- }
- }
-
- ret = xmlTextWriterWriteString (writer, copy);
- xmlFree (copy);
-
- return ret;
+ int ret;
+ xmlChar *copy, *p;
+
+ if (!string)
+ return 0;
+
+ /* http://www.w3.org/TR/REC-xml/#sec-well-formed :
+ Character Range
+ [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] |
+ [#xE000-#xFFFD] | [#x10000-#x10FFFF]
+ any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
+ */
+
+ copy = xmlStrdup (string);
+ for (p = copy; *p; p++) {
+ xmlChar c = *p;
+ if (G_UNLIKELY (c < 0x20 && c != 0xd && c != 0xa && c != 0x9)) {
+ *p = 0x20;
+ }
+ }
+
+ ret = xmlTextWriterWriteString (writer, copy);
+ xmlFree (copy);
+
+ return ret;
}
int
-ephy_node_write_to_xml(EphyNode *node,
- xmlTextWriterPtr writer)
-{
- xmlChar xml_buf[G_ASCII_DTOSTR_BUF_SIZE];
- guint i;
- int ret;
- ForEachData data;
-
- g_return_val_if_fail (EPHY_IS_NODE (node), -1);
- g_return_val_if_fail (writer != NULL, -1);
-
- /* start writing the node */
- ret = xmlTextWriterStartElement (writer, (const xmlChar *)"node");
- if (ret < 0) goto out;
-
- /* write node id */
- ret = xmlTextWriterWriteFormatAttribute (writer, (const xmlChar *)"id", "%d", node->id);
- if (ret < 0) goto out;
-
- /* write node properties */
- for (i = 0; i < node->properties->len; i++)
- {
- GValue *value;
-
- value = g_ptr_array_index (node->properties, i);
-
- if (value == NULL) continue;
- if (G_VALUE_TYPE (value) == G_TYPE_STRING &&
- g_value_get_string (value) == NULL) continue;
-
- ret = xmlTextWriterStartElement (writer, (const xmlChar *)"property");
- if (ret < 0) break;
-
- ret = xmlTextWriterWriteFormatAttribute (writer, (const xmlChar *)"id", "%d", i);
- if (ret < 0) break;
-
- ret = xmlTextWriterWriteAttribute
- (writer, (const xmlChar *)"value_type",
- (const xmlChar *)g_type_name (G_VALUE_TYPE (value)));
- if (ret < 0) break;
-
- switch (G_VALUE_TYPE (value))
- {
- case G_TYPE_STRING:
- ret = safe_write_string
- (writer, (const xmlChar *)g_value_get_string (value));
- break;
- case G_TYPE_BOOLEAN:
- ret = xmlTextWriterWriteFormatString
- (writer, "%d", g_value_get_boolean (value));
- break;
- case G_TYPE_INT:
- ret = xmlTextWriterWriteFormatString
- (writer, "%d", g_value_get_int (value));
- break;
- case G_TYPE_LONG:
- ret = xmlTextWriterWriteFormatString
- (writer, "%ld", g_value_get_long (value));
- break;
- case G_TYPE_FLOAT:
- g_ascii_dtostr ((gchar *)xml_buf, sizeof (xml_buf),
- g_value_get_float (value));
- ret = xmlTextWriterWriteString (writer, xml_buf);
- break;
- case G_TYPE_DOUBLE:
- g_ascii_dtostr ((gchar *)xml_buf, sizeof (xml_buf),
- g_value_get_double (value));
- ret = xmlTextWriterWriteString (writer, xml_buf);
- break;
- default:
- g_assert_not_reached ();
- break;
- }
- if (ret < 0) break;
-
- ret = xmlTextWriterEndElement (writer); /* property */
- if (ret < 0) break;
- }
- if (ret < 0) goto out;
-
- /* now write parent node ids */
- data.writer = writer;
- data.ret = 0;
-
- g_hash_table_foreach (node->parents,
- (GHFunc) write_parent,
- &data);
- ret = data.ret;
- if (ret < 0) goto out;
-
- ret = xmlTextWriterEndElement (writer); /* node */
- if (ret < 0) goto out;
-
-out:
- return ret >= 0 ? 0 : -1;
+ephy_node_write_to_xml (EphyNode *node,
+ xmlTextWriterPtr writer)
+{
+ xmlChar xml_buf[G_ASCII_DTOSTR_BUF_SIZE];
+ guint i;
+ int ret;
+ ForEachData data;
+
+ g_return_val_if_fail (EPHY_IS_NODE (node), -1);
+ g_return_val_if_fail (writer != NULL, -1);
+
+ /* start writing the node */
+ ret = xmlTextWriterStartElement (writer, (const xmlChar *)"node");
+ if (ret < 0) goto out;
+
+ /* write node id */
+ ret = xmlTextWriterWriteFormatAttribute (writer, (const xmlChar *)"id", "%d", node->id);
+ if (ret < 0) goto out;
+
+ /* write node properties */
+ for (i = 0; i < node->properties->len; i++) {
+ GValue *value;
+
+ value = g_ptr_array_index (node->properties, i);
+
+ if (value == NULL) continue;
+ if (G_VALUE_TYPE (value) == G_TYPE_STRING &&
+ g_value_get_string (value) == NULL) continue;
+
+ ret = xmlTextWriterStartElement (writer, (const xmlChar *)"property");
+ if (ret < 0) break;
+
+ ret = xmlTextWriterWriteFormatAttribute (writer, (const xmlChar *)"id", "%d", i);
+ if (ret < 0) break;
+
+ ret = xmlTextWriterWriteAttribute
+ (writer, (const xmlChar *)"value_type",
+ (const xmlChar *)g_type_name (G_VALUE_TYPE (value)));
+ if (ret < 0) break;
+
+ switch (G_VALUE_TYPE (value)) {
+ case G_TYPE_STRING:
+ ret = safe_write_string
+ (writer, (const xmlChar *)g_value_get_string (value));
+ break;
+ case G_TYPE_BOOLEAN:
+ ret = xmlTextWriterWriteFormatString
+ (writer, "%d", g_value_get_boolean (value));
+ break;
+ case G_TYPE_INT:
+ ret = xmlTextWriterWriteFormatString
+ (writer, "%d", g_value_get_int (value));
+ break;
+ case G_TYPE_LONG:
+ ret = xmlTextWriterWriteFormatString
+ (writer, "%ld", g_value_get_long (value));
+ break;
+ case G_TYPE_FLOAT:
+ g_ascii_dtostr ((gchar *)xml_buf, sizeof (xml_buf),
+ g_value_get_float (value));
+ ret = xmlTextWriterWriteString (writer, xml_buf);
+ break;
+ case G_TYPE_DOUBLE:
+ g_ascii_dtostr ((gchar *)xml_buf, sizeof (xml_buf),
+ g_value_get_double (value));
+ ret = xmlTextWriterWriteString (writer, xml_buf);
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+ if (ret < 0) break;
+
+ ret = xmlTextWriterEndElement (writer); /* property */
+ if (ret < 0) break;
+ }
+ if (ret < 0) goto out;
+
+ /* now write parent node ids */
+ data.writer = writer;
+ data.ret = 0;
+
+ g_hash_table_foreach (node->parents,
+ (GHFunc)write_parent,
+ &data);
+ ret = data.ret;
+ if (ret < 0) goto out;
+
+ ret = xmlTextWriterEndElement (writer); /* node */
+ if (ret < 0) goto out;
+
+ out:
+ return ret >= 0 ? 0 : -1;
}
static inline void
real_add_child (EphyNode *node,
- EphyNode *child)
+ EphyNode *child)
{
- EphyNodeParent *node_info;
+ EphyNodeParent *node_info;
- if (g_hash_table_lookup (child->parents,
- GINT_TO_POINTER (node->id)) != NULL) {
- return;
- }
+ if (g_hash_table_lookup (child->parents,
+ GINT_TO_POINTER (node->id)) != NULL) {
+ return;
+ }
- g_ptr_array_add (node->children, child);
+ g_ptr_array_add (node->children, child);
- node_info = g_slice_new0 (EphyNodeParent);
- node_info->node = node;
- node_info->index = node->children->len - 1;
+ node_info = g_slice_new0 (EphyNodeParent);
+ node_info->node = node;
+ node_info->index = node->children->len - 1;
- g_hash_table_insert (child->parents,
- GINT_TO_POINTER (node->id),
- node_info);
+ g_hash_table_insert (child->parents,
+ GINT_TO_POINTER (node->id),
+ node_info);
}
EphyNode *
ephy_node_new_from_xml (EphyNodeDb *db, xmlNodePtr xml_node)
{
- EphyNode *node;
- xmlNodePtr xml_child;
- xmlChar *xml;
- long id;
-
- g_return_val_if_fail (EPHY_IS_NODE_DB (db), NULL);
- g_return_val_if_fail (xml_node != NULL, NULL);
-
- if (ephy_node_db_is_immutable (db)) return NULL;
-
- xml = xmlGetProp (xml_node, (const xmlChar *)"id");
- if (xml == NULL)
- return NULL;
- id = atol ((const char *)xml);
- xmlFree (xml);
-
- node = ephy_node_new_with_id (db, id);
-
- for (xml_child = xml_node->children; xml_child != NULL; xml_child = xml_child->next) {
- if (strcmp ((const char *)xml_child->name, "parent") == 0) {
- EphyNode *parent;
- long parent_id;
-
- xml = xmlGetProp (xml_child, (const xmlChar *)"id");
- g_assert (xml != NULL);
- parent_id = atol ((const char *)xml);
- xmlFree (xml);
-
- parent = ephy_node_db_get_node_from_id (db, parent_id);
-
- if (parent != NULL)
- {
- real_add_child (parent, node);
-
- ephy_node_emit_signal (parent, EPHY_NODE_CHILD_ADDED, node);
- }
- } else if (strcmp ((const char *)xml_child->name, "property") == 0) {
- GValue *value;
- xmlChar *xmlType, *xmlValue;
- int property_id;
-
- xml = xmlGetProp (xml_child, (const xmlChar *)"id");
- property_id = atoi ((const char *)xml);
- xmlFree (xml);
-
- xmlType = xmlGetProp (xml_child, (const xmlChar *)"value_type");
- xmlValue = xmlNodeGetContent (xml_child);
-
- value = g_slice_new0 (GValue);
-
- if (xmlStrEqual (xmlType, (const xmlChar *) "gchararray"))
- {
- g_value_init (value, G_TYPE_STRING);
- g_value_set_string (value, (const gchar *)xmlValue);
- }
- else if (xmlStrEqual (xmlType, (const xmlChar *) "gint"))
- {
- g_value_init (value, G_TYPE_INT);
- g_value_set_int (value, atoi ((const char *)xmlValue));
- }
- else if (xmlStrEqual (xmlType, (const xmlChar *) "gboolean"))
- {
- g_value_init (value, G_TYPE_BOOLEAN);
- g_value_set_boolean (value, atoi ((const char *)xmlValue));
- }
- else if (xmlStrEqual (xmlType, (const xmlChar *) "glong"))
- {
- g_value_init (value, G_TYPE_LONG);
- g_value_set_long (value, atol ((const char *)xmlValue));
- }
- else if (xmlStrEqual (xmlType, (const xmlChar *) "gfloat"))
- {
- g_value_init (value, G_TYPE_FLOAT);
- g_value_set_float (value, g_ascii_strtod ((const gchar *)xmlValue, NULL));
- }
- else if (xmlStrEqual (xmlType, (const xmlChar *) "gdouble"))
- {
- g_value_init (value, G_TYPE_DOUBLE);
- g_value_set_double (value, g_ascii_strtod ((const gchar *)xmlValue, NULL));
- }
- else if (xmlStrEqual (xmlType, (const xmlChar *) "gpointer"))
- {
- EphyNode *property_node;
-
- property_node = ephy_node_db_get_node_from_id (db, atol ((const char
*)xmlValue));
-
- g_value_set_pointer (value, property_node);
- break;
- }
- else
- {
- g_assert_not_reached ();
- }
-
- real_set_property (node, property_id, value);
-
- xmlFree (xmlValue);
- xmlFree (xmlType);
- }
- }
-
- ephy_node_emit_signal (node, EPHY_NODE_RESTORED);
-
- return node;
+ EphyNode *node;
+ xmlNodePtr xml_child;
+ xmlChar *xml;
+ long id;
+
+ g_return_val_if_fail (EPHY_IS_NODE_DB (db), NULL);
+ g_return_val_if_fail (xml_node != NULL, NULL);
+
+ if (ephy_node_db_is_immutable (db)) return NULL;
+
+ xml = xmlGetProp (xml_node, (const xmlChar *)"id");
+ if (xml == NULL)
+ return NULL;
+ id = atol ((const char *)xml);
+ xmlFree (xml);
+
+ node = ephy_node_new_with_id (db, id);
+
+ for (xml_child = xml_node->children; xml_child != NULL; xml_child = xml_child->next) {
+ if (strcmp ((const char *)xml_child->name, "parent") == 0) {
+ EphyNode *parent;
+ long parent_id;
+
+ xml = xmlGetProp (xml_child, (const xmlChar *)"id");
+ g_assert (xml != NULL);
+ parent_id = atol ((const char *)xml);
+ xmlFree (xml);
+
+ parent = ephy_node_db_get_node_from_id (db, parent_id);
+
+ if (parent != NULL) {
+ real_add_child (parent, node);
+
+ ephy_node_emit_signal (parent, EPHY_NODE_CHILD_ADDED, node);
+ }
+ } else if (strcmp ((const char *)xml_child->name, "property") == 0) {
+ GValue *value;
+ xmlChar *xmlType, *xmlValue;
+ int property_id;
+
+ xml = xmlGetProp (xml_child, (const xmlChar *)"id");
+ property_id = atoi ((const char *)xml);
+ xmlFree (xml);
+
+ xmlType = xmlGetProp (xml_child, (const xmlChar *)"value_type");
+ xmlValue = xmlNodeGetContent (xml_child);
+
+ value = g_slice_new0 (GValue);
+
+ if (xmlStrEqual (xmlType, (const xmlChar *)"gchararray")) {
+ g_value_init (value, G_TYPE_STRING);
+ g_value_set_string (value, (const gchar *)xmlValue);
+ } else if (xmlStrEqual (xmlType, (const xmlChar *)"gint")) {
+ g_value_init (value, G_TYPE_INT);
+ g_value_set_int (value, atoi ((const char *)xmlValue));
+ } else if (xmlStrEqual (xmlType, (const xmlChar *)"gboolean")) {
+ g_value_init (value, G_TYPE_BOOLEAN);
+ g_value_set_boolean (value, atoi ((const char *)xmlValue));
+ } else if (xmlStrEqual (xmlType, (const xmlChar *)"glong")) {
+ g_value_init (value, G_TYPE_LONG);
+ g_value_set_long (value, atol ((const char *)xmlValue));
+ } else if (xmlStrEqual (xmlType, (const xmlChar *)"gfloat")) {
+ g_value_init (value, G_TYPE_FLOAT);
+ g_value_set_float (value, g_ascii_strtod ((const gchar *)xmlValue, NULL));
+ } else if (xmlStrEqual (xmlType, (const xmlChar *)"gdouble")) {
+ g_value_init (value, G_TYPE_DOUBLE);
+ g_value_set_double (value, g_ascii_strtod ((const gchar *)xmlValue, NULL));
+ } else if (xmlStrEqual (xmlType, (const xmlChar *)"gpointer")) {
+ EphyNode *property_node;
+
+ property_node = ephy_node_db_get_node_from_id (db, atol ((const char *)xmlValue));
+
+ g_value_set_pointer (value, property_node);
+ break;
+ } else {
+ g_assert_not_reached ();
+ }
+
+ real_set_property (node, property_id, value);
+
+ xmlFree (xmlValue);
+ xmlFree (xmlType);
+ }
+ }
+
+ ephy_node_emit_signal (node, EPHY_NODE_RESTORED);
+
+ return node;
}
void
ephy_node_add_child (EphyNode *node,
- EphyNode *child)
+ EphyNode *child)
{
- g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (EPHY_IS_NODE (node));
- if (ephy_node_db_is_immutable (node->db)) return;
-
- real_add_child (node, child);
+ if (ephy_node_db_is_immutable (node->db)) return;
- ephy_node_emit_signal (node, EPHY_NODE_CHILD_ADDED, child);
+ real_add_child (node, child);
+
+ ephy_node_emit_signal (node, EPHY_NODE_CHILD_ADDED, child);
}
void
ephy_node_remove_child (EphyNode *node,
- EphyNode *child)
+ EphyNode *child)
{
- g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (EPHY_IS_NODE (node));
- if (ephy_node_db_is_immutable (node->db)) return;
+ if (ephy_node_db_is_immutable (node->db)) return;
- real_remove_child (node, child, TRUE, TRUE);
+ real_remove_child (node, child, TRUE, TRUE);
}
gboolean
ephy_node_has_child (EphyNode *node,
- EphyNode *child)
+ EphyNode *child)
{
- gboolean ret;
+ gboolean ret;
+
+ g_return_val_if_fail (EPHY_IS_NODE (node), FALSE);
- g_return_val_if_fail (EPHY_IS_NODE (node), FALSE);
-
- ret = (g_hash_table_lookup (child->parents,
- GINT_TO_POINTER (node->id)) != NULL);
+ ret = (g_hash_table_lookup (child->parents,
+ GINT_TO_POINTER (node->id)) != NULL);
- return ret;
+ return ret;
}
static int
ephy_node_real_get_child_index (EphyNode *node,
- EphyNode *child)
+ EphyNode *child)
{
- EphyNodeParent *node_info;
- int ret;
+ EphyNodeParent *node_info;
+ int ret;
- node_info = g_hash_table_lookup (child->parents,
- GINT_TO_POINTER (node->id));
+ node_info = g_hash_table_lookup (child->parents,
+ GINT_TO_POINTER (node->id));
- if (node_info == NULL)
- return -1;
+ if (node_info == NULL)
+ return -1;
- ret = node_info->index;
+ ret = node_info->index;
- return ret;
+ return ret;
}
/**
@@ -1152,83 +1123,81 @@ ephy_node_real_get_child_index (EphyNode *node,
*
**/
void
-ephy_node_sort_children (EphyNode *node,
- GCompareFunc compare_func)
+ephy_node_sort_children (EphyNode *node,
+ GCompareFunc compare_func)
{
- GPtrArray *newkids;
- guint i, *new_order;
+ GPtrArray *newkids;
+ guint i, *new_order;
- if (ephy_node_db_is_immutable (node->db)) return;
+ if (ephy_node_db_is_immutable (node->db)) return;
- g_return_if_fail (EPHY_IS_NODE (node));
- g_return_if_fail (compare_func != NULL);
+ g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (compare_func != NULL);
- newkids = g_ptr_array_new ();
- g_ptr_array_set_size (newkids, node->children->len);
+ newkids = g_ptr_array_new ();
+ g_ptr_array_set_size (newkids, node->children->len);
- /* dup the array */
- for (i = 0; i < node->children->len; i++)
- {
- g_ptr_array_index (newkids, i) = g_ptr_array_index (node->children, i);
- }
+ /* dup the array */
+ for (i = 0; i < node->children->len; i++) {
+ g_ptr_array_index (newkids, i) = g_ptr_array_index (node->children, i);
+ }
- g_ptr_array_sort (newkids, compare_func);
+ g_ptr_array_sort (newkids, compare_func);
- new_order = g_new (guint, newkids->len);
- memset (new_order, -1, sizeof (guint) * newkids->len);
+ new_order = g_new (guint, newkids->len);
+ memset (new_order, -1, sizeof (guint) * newkids->len);
- for (i = 0; i < newkids->len; i++)
- {
- EphyNodeParent *node_info;
- EphyNode *child;
+ for (i = 0; i < newkids->len; i++) {
+ EphyNodeParent *node_info;
+ EphyNode *child;
- child = g_ptr_array_index (newkids, i);
- new_order[ephy_node_real_get_child_index (node, child)] = i;
- node_info = g_hash_table_lookup (child->parents,
- GINT_TO_POINTER (node->id));
- node_info->index = i;
- }
+ child = g_ptr_array_index (newkids, i);
+ new_order[ephy_node_real_get_child_index (node, child)] = i;
+ node_info = g_hash_table_lookup (child->parents,
+ GINT_TO_POINTER (node->id));
+ node_info->index = i;
+ }
- g_ptr_array_free (node->children, FALSE);
- node->children = newkids;
+ g_ptr_array_free (node->children, FALSE);
+ node->children = newkids;
- ephy_node_emit_signal (node, EPHY_NODE_CHILDREN_REORDERED, new_order);
+ ephy_node_emit_signal (node, EPHY_NODE_CHILDREN_REORDERED, new_order);
- g_free (new_order);
+ g_free (new_order);
}
void
ephy_node_reorder_children (EphyNode *node,
- int *new_order)
+ int *new_order)
{
- GPtrArray *newkids;
- guint i;
+ GPtrArray *newkids;
+ guint i;
- g_return_if_fail (EPHY_IS_NODE (node));
- g_return_if_fail (new_order != NULL);
+ g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (new_order != NULL);
- if (ephy_node_db_is_immutable (node->db)) return;
+ if (ephy_node_db_is_immutable (node->db)) return;
- newkids = g_ptr_array_new ();
- g_ptr_array_set_size (newkids, node->children->len);
+ newkids = g_ptr_array_new ();
+ g_ptr_array_set_size (newkids, node->children->len);
- for (i = 0; i < node->children->len; i++) {
- EphyNode *child;
- EphyNodeParent *node_info;
+ for (i = 0; i < node->children->len; i++) {
+ EphyNode *child;
+ EphyNodeParent *node_info;
- child = g_ptr_array_index (node->children, i);
+ child = g_ptr_array_index (node->children, i);
- g_ptr_array_index (newkids, new_order[i]) = child;
+ g_ptr_array_index (newkids, new_order[i]) = child;
- node_info = g_hash_table_lookup (child->parents,
- GINT_TO_POINTER (node->id));
- node_info->index = new_order[i];
- }
+ node_info = g_hash_table_lookup (child->parents,
+ GINT_TO_POINTER (node->id));
+ node_info->index = new_order[i];
+ }
- g_ptr_array_free (node->children, FALSE);
- node->children = newkids;
+ g_ptr_array_free (node->children, FALSE);
+ node->children = newkids;
- ephy_node_emit_signal (node, EPHY_NODE_CHILDREN_REORDERED, new_order);
+ ephy_node_emit_signal (node, EPHY_NODE_CHILDREN_REORDERED, new_order);
}
/**
@@ -1239,21 +1208,21 @@ ephy_node_reorder_children (EphyNode *node,
GPtrArray *
ephy_node_get_children (EphyNode *node)
{
- g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
+ g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
- return node->children;
+ return node->children;
}
int
ephy_node_get_n_children (EphyNode *node)
{
- int ret;
+ int ret;
- g_return_val_if_fail (EPHY_IS_NODE (node), -1);
+ g_return_val_if_fail (EPHY_IS_NODE (node), -1);
- ret = node->children->len;
+ ret = node->children->len;
- return ret;
+ return ret;
}
/**
@@ -1263,49 +1232,49 @@ ephy_node_get_n_children (EphyNode *node)
**/
EphyNode *
ephy_node_get_nth_child (EphyNode *node,
- guint n)
+ guint n)
{
- EphyNode *ret;
+ EphyNode *ret;
- g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
+ g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
- if (n < node->children->len) {
- ret = g_ptr_array_index (node->children, n);
- } else {
- ret = NULL;
- }
+ if (n < node->children->len) {
+ ret = g_ptr_array_index (node->children, n);
+ } else {
+ ret = NULL;
+ }
- return ret;
+ return ret;
}
static inline int
get_child_index_real (EphyNode *node,
- EphyNode *child)
+ EphyNode *child)
{
- EphyNodeParent *node_info;
+ EphyNodeParent *node_info;
- node_info = g_hash_table_lookup (child->parents,
- GINT_TO_POINTER (node->id));
+ node_info = g_hash_table_lookup (child->parents,
+ GINT_TO_POINTER (node->id));
- if (node_info == NULL)
- return -1;
+ if (node_info == NULL)
+ return -1;
- return node_info->index;
+ return node_info->index;
}
int
ephy_node_get_child_index (EphyNode *node,
- EphyNode *child)
+ EphyNode *child)
{
- int ret;
+ int ret;
- g_return_val_if_fail (EPHY_IS_NODE (node), -1);
- g_return_val_if_fail (EPHY_IS_NODE (child), -1);
+ g_return_val_if_fail (EPHY_IS_NODE (node), -1);
+ g_return_val_if_fail (EPHY_IS_NODE (child), -1);
- ret = ephy_node_real_get_child_index (node, child);
+ ret = ephy_node_real_get_child_index (node, child);
- return ret;
+ return ret;
}
/**
@@ -1315,23 +1284,23 @@ ephy_node_get_child_index (EphyNode *node,
**/
EphyNode *
ephy_node_get_next_child (EphyNode *node,
- EphyNode *child)
+ EphyNode *child)
{
- EphyNode *ret;
- guint idx;
+ EphyNode *ret;
+ guint idx;
+
+ g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
+ g_return_val_if_fail (EPHY_IS_NODE (child), NULL);
- g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
- g_return_val_if_fail (EPHY_IS_NODE (child), NULL);
-
- idx = get_child_index_real (node, child);
+ idx = get_child_index_real (node, child);
- if ((idx + 1) < node->children->len) {
- ret = g_ptr_array_index (node->children, idx + 1);
- } else {
- ret = NULL;
- }
+ if ((idx + 1) < node->children->len) {
+ ret = g_ptr_array_index (node->children, idx + 1);
+ } else {
+ ret = NULL;
+ }
- return ret;
+ return ret;
}
/**
@@ -1341,23 +1310,23 @@ ephy_node_get_next_child (EphyNode *node,
**/
EphyNode *
ephy_node_get_previous_child (EphyNode *node,
- EphyNode *child)
+ EphyNode *child)
{
- EphyNode *ret;
- int idx;
+ EphyNode *ret;
+ int idx;
- g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
- g_return_val_if_fail (EPHY_IS_NODE (child), NULL);
-
- idx = get_child_index_real (node, child);
+ g_return_val_if_fail (EPHY_IS_NODE (node), NULL);
+ g_return_val_if_fail (EPHY_IS_NODE (child), NULL);
- if ((idx - 1) >= 0) {
- ret = g_ptr_array_index (node->children, idx - 1);
- } else {
- ret = NULL;
- }
+ idx = get_child_index_real (node, child);
- return ret;
+ if ((idx - 1) >= 0) {
+ ret = g_ptr_array_index (node->children, idx - 1);
+ } else {
+ ret = NULL;
+ }
+
+ return ret;
}
/**
@@ -1372,64 +1341,62 @@ ephy_node_get_previous_child (EphyNode *node,
* Returns: an identifier for the connected signal
**/
int
-ephy_node_signal_connect_object (EphyNode *node,
- EphyNodeSignalType type,
- EphyNodeCallback cb,
- GObject *object)
-{
- EphyNodeSignalData *signal_data;
- int ret;
-
- g_return_val_if_fail (EPHY_IS_NODE (node), -1);
- /* FIXME: */
- g_return_val_if_fail (node->emissions == 0, -1);
-
- signal_data = g_slice_new0 (EphyNodeSignalData);
- signal_data->node = node;
- signal_data->id = node->signal_id;
- signal_data->callback = cb;
- signal_data->type = type;
- signal_data->data = object;
-
- g_hash_table_insert (node->signals,
- GINT_TO_POINTER (node->signal_id),
- signal_data);
- if (object)
- {
- g_object_weak_ref (object,
- (GWeakNotify)signal_object_weak_notify,
- signal_data);
- }
-
- ret = node->signal_id;
- node->signal_id++;
-
- return ret;
+ephy_node_signal_connect_object (EphyNode *node,
+ EphyNodeSignalType type,
+ EphyNodeCallback cb,
+ GObject *object)
+{
+ EphyNodeSignalData *signal_data;
+ int ret;
+
+ g_return_val_if_fail (EPHY_IS_NODE (node), -1);
+ /* FIXME: */
+ g_return_val_if_fail (node->emissions == 0, -1);
+
+ signal_data = g_slice_new0 (EphyNodeSignalData);
+ signal_data->node = node;
+ signal_data->id = node->signal_id;
+ signal_data->callback = cb;
+ signal_data->type = type;
+ signal_data->data = object;
+
+ g_hash_table_insert (node->signals,
+ GINT_TO_POINTER (node->signal_id),
+ signal_data);
+ if (object) {
+ g_object_weak_ref (object,
+ (GWeakNotify)signal_object_weak_notify,
+ signal_data);
+ }
+
+ ret = node->signal_id;
+ node->signal_id++;
+
+ return ret;
}
static gboolean
-remove_matching_signal_data (gpointer key,
- EphyNodeSignalData *signal_data,
- EphyNodeSignalData *user_data)
+remove_matching_signal_data (gpointer key,
+ EphyNodeSignalData *signal_data,
+ EphyNodeSignalData *user_data)
{
- return (user_data->data == signal_data->data &&
- user_data->type == signal_data->type &&
- user_data->callback == signal_data->callback);
+ return (user_data->data == signal_data->data &&
+ user_data->type == signal_data->type &&
+ user_data->callback == signal_data->callback);
}
static void
-invalidate_matching_signal_data (gpointer key,
- EphyNodeSignalData *signal_data,
- EphyNodeSignalData *user_data)
-{
- if (user_data->data == signal_data->data &&
- user_data->type == signal_data->type &&
- user_data->callback == signal_data->callback &&
- !signal_data->invalidated)
- {
- signal_data->invalidated = TRUE;
- ++signal_data->node->invalidated_signals;
- }
+invalidate_matching_signal_data (gpointer key,
+ EphyNodeSignalData *signal_data,
+ EphyNodeSignalData *user_data)
+{
+ if (user_data->data == signal_data->data &&
+ user_data->type == signal_data->type &&
+ user_data->callback == signal_data->callback &&
+ !signal_data->invalidated) {
+ signal_data->invalidated = TRUE;
+ ++signal_data->node->invalidated_signals;
+ }
}
/**
@@ -1445,97 +1412,90 @@ invalidate_matching_signal_data (gpointer key,
* Returns: the number of signal handlers removed
**/
guint
-ephy_node_signal_disconnect_object (EphyNode *node,
+ephy_node_signal_disconnect_object (EphyNode *node,
EphyNodeSignalType type,
- EphyNodeCallback cb,
- GObject *object)
-{
- EphyNodeSignalData user_data;
-
- g_return_val_if_fail (EPHY_IS_NODE (node), 0);
-
- user_data.callback = cb;
- user_data.type = type;
- user_data.data = object;
-
- if (G_LIKELY (node->emissions == 0))
- {
- return g_hash_table_foreach_remove (node->signals,
- (GHRFunc) remove_matching_signal_data,
- &user_data);
- }
- else
- {
- g_hash_table_foreach (node->signals,
- (GHFunc) invalidate_matching_signal_data,
- &user_data);
- return 0;
- }
+ EphyNodeCallback cb,
+ GObject *object)
+{
+ EphyNodeSignalData user_data;
+
+ g_return_val_if_fail (EPHY_IS_NODE (node), 0);
+
+ user_data.callback = cb;
+ user_data.type = type;
+ user_data.data = object;
+
+ if (G_LIKELY (node->emissions == 0)) {
+ return g_hash_table_foreach_remove (node->signals,
+ (GHRFunc)remove_matching_signal_data,
+ &user_data);
+ } else {
+ g_hash_table_foreach (node->signals,
+ (GHFunc)invalidate_matching_signal_data,
+ &user_data);
+ return 0;
+ }
}
void
ephy_node_signal_disconnect (EphyNode *node,
- int signal_id)
+ int signal_id)
{
- g_return_if_fail (EPHY_IS_NODE (node));
- g_return_if_fail (signal_id != -1);
-
- if (G_LIKELY (node->emissions == 0))
- {
- g_hash_table_remove (node->signals,
- GINT_TO_POINTER (signal_id));
- }
- else
- {
- EphyNodeSignalData *data;
-
- data = g_hash_table_lookup (node->signals,
- GINT_TO_POINTER (signal_id));
- g_return_if_fail (data != NULL);
- g_return_if_fail (!data->invalidated);
-
- data->invalidated = TRUE;
- node->invalidated_signals++;
- }
+ g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (signal_id != -1);
+
+ if (G_LIKELY (node->emissions == 0)) {
+ g_hash_table_remove (node->signals,
+ GINT_TO_POINTER (signal_id));
+ } else {
+ EphyNodeSignalData *data;
+
+ data = g_hash_table_lookup (node->signals,
+ GINT_TO_POINTER (signal_id));
+ g_return_if_fail (data != NULL);
+ g_return_if_fail (!data->invalidated);
+
+ data->invalidated = TRUE;
+ node->invalidated_signals++;
+ }
}
void
ephy_node_set_is_drag_source (EphyNode *node,
- gboolean allow)
+ gboolean allow)
{
- node->is_drag_source = allow != FALSE;
+ node->is_drag_source = allow != FALSE;
}
gboolean
ephy_node_get_is_drag_source (EphyNode *node)
{
- return node->is_drag_source;
+ return node->is_drag_source;
}
void
ephy_node_set_is_drag_dest (EphyNode *node,
- gboolean allow)
+ gboolean allow)
{
- node->is_drag_dest = allow != FALSE;
+ node->is_drag_dest = allow != FALSE;
}
gboolean
ephy_node_get_is_drag_dest (EphyNode *node)
{
- return node->is_drag_dest;
+ return node->is_drag_dest;
}
GType
ephy_node_get_type (void)
{
- static GType type = 0;
+ static GType type = 0;
- if (G_UNLIKELY (type == 0))
- {
- type = g_boxed_type_register_static ("EphyNode",
- (GBoxedCopyFunc) ephy_node_ref,
- (GBoxedFreeFunc) ephy_node_unref);
- }
+ if (G_UNLIKELY (type == 0)) {
+ type = g_boxed_type_register_static ("EphyNode",
+ (GBoxedCopyFunc)ephy_node_ref,
+ (GBoxedFreeFunc)ephy_node_unref);
+ }
- return type;
+ return type;
}
diff --git a/lib/ephy-nss-glue.c b/lib/ephy-nss-glue.c
index b9d01f5..70c9e18 100644
--- a/lib/ephy-nss-glue.c
+++ b/lib/ephy-nss-glue.c
@@ -40,10 +40,10 @@
static gboolean nss_initialized = FALSE;
static PK11SlotInfo *db_slot = NULL;
-static char*
+static char *
ask_for_nss_password (PK11SlotInfo *slot,
- PRBool retry,
- void *arg)
+ PRBool retry,
+ void *arg)
{
GtkWidget *dialog;
GtkWidget *entry;
@@ -69,11 +69,11 @@ ask_for_nss_password (PK11SlotInfo *slot,
result = gtk_dialog_run (GTK_DIALOG (dialog));
switch (result) {
- case GTK_RESPONSE_OK:
- password = PL_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
- break;
- default:
- break;
+ case GTK_RESPONSE_OK:
+ password = PL_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
+ break;
+ default:
+ break;
}
gtk_widget_destroy (dialog);
@@ -127,8 +127,7 @@ void ephy_nss_glue_close (void)
nss_initialized = FALSE;
}
-typedef struct SDRResult
-{
+typedef struct SDRResult {
SECItem keyid;
SECAlgorithmID alg;
SECItem data;
@@ -136,15 +135,15 @@ typedef struct SDRResult
static SEC_ASN1Template g_template[] = {
{ SEC_ASN1_SEQUENCE, 0, NULL, sizeof (SDRResult) },
- { SEC_ASN1_OCTET_STRING, offsetof(SDRResult, keyid) },
- { SEC_ASN1_INLINE | SEC_ASN1_XTRN, offsetof(SDRResult, alg),
- SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) },
- { SEC_ASN1_OCTET_STRING, offsetof(SDRResult, data) },
+ { SEC_ASN1_OCTET_STRING, offsetof (SDRResult, keyid) },
+ { SEC_ASN1_INLINE | SEC_ASN1_XTRN, offsetof (SDRResult, alg),
+ SEC_ASN1_SUB (SECOID_AlgorithmIDTemplate) },
+ { SEC_ASN1_OCTET_STRING, offsetof (SDRResult, data) },
{ 0 }
};
static SECStatus
-unpadBlock(SECItem *data, int blockSize, SECItem *result)
+unpadBlock (SECItem *data, int blockSize, SECItem *result)
{
SECStatus rv = SECSuccess;
int padLength;
@@ -154,24 +153,30 @@ unpadBlock(SECItem *data, int blockSize, SECItem *result)
result->len = 0;
/* Remove the padding from the end if the input data */
- if (data->len == 0 || data->len % blockSize != 0) { rv = SECFailure; goto loser; }
+ if (data->len == 0 || data->len % blockSize != 0) {
+ rv = SECFailure; goto loser;
+ }
- padLength = data->data[data->len-1];
- if (padLength > blockSize) { rv = SECFailure; goto loser; }
+ padLength = data->data[data->len - 1];
+ if (padLength > blockSize) {
+ rv = SECFailure; goto loser;
+ }
/* verify padding */
- for (i=data->len - padLength; (uint32)i < data->len; i++) {
+ for (i = data->len - padLength; (uint32)i < data->len; i++) {
if (data->data[i] != padLength) {
- rv = SECFailure;
- goto loser;
+ rv = SECFailure;
+ goto loser;
}
}
result->len = data->len - padLength;
- result->data = (unsigned char *)PORT_Alloc(result->len);
- if (!result->data) { rv = SECFailure; goto loser; }
+ result->data = (unsigned char *)PORT_Alloc (result->len);
+ if (!result->data) {
+ rv = SECFailure; goto loser;
+ }
- PORT_Memcpy(result->data, data->data, result->len);
+ PORT_Memcpy (result->data, data->data, result->len);
if (padLength < 2) {
/* Chromium returns an error here, but it seems to be harmless and
@@ -180,13 +185,13 @@ unpadBlock(SECItem *data, int blockSize, SECItem *result)
/* return SECWouldBlock; */
}
-loser:
+ loser:
return rv;
}
static SECStatus
-pk11Decrypt (PK11SlotInfo *slot, PLArenaPool *arena,
- CK_MECHANISM_TYPE type, PK11SymKey *key,
+pk11Decrypt (PK11SlotInfo *slot, PLArenaPool *arena,
+ CK_MECHANISM_TYPE type, PK11SymKey *key,
SECItem *params, SECItem *in, SECItem *result)
{
PK11Context *ctx = 0;
@@ -203,22 +208,22 @@ pk11Decrypt (PK11SlotInfo *slot, PLArenaPool *arena,
}
paddedResult.len = in->len;
- paddedResult.data = (unsigned char*)PORT_ArenaAlloc (arena, paddedResult.len);
+ paddedResult.data = (unsigned char *)PORT_ArenaAlloc (arena, paddedResult.len);
- rv = PK11_CipherOp (ctx, paddedResult.data,
- (int*)&paddedResult.len, paddedResult.len,
+ rv = PK11_CipherOp (ctx, paddedResult.data,
+ (int *)&paddedResult.len, paddedResult.len,
in->data, in->len);
if (rv != SECSuccess)
goto loser;
- PK11_Finalize(ctx);
+ PK11_Finalize (ctx);
/* Remove the padding */
- rv = unpadBlock (&paddedResult, PK11_GetBlockSize(type, 0), result);
+ rv = unpadBlock (&paddedResult, PK11_GetBlockSize (type, 0), result);
if (rv)
goto loser;
-loser:
+ loser:
if (ctx)
PK11_DestroyContext (ctx, PR_TRUE);
@@ -258,10 +263,10 @@ PK11SDR_DecryptWithSlot (PK11SlotInfo *slot, SECItem *data, SECItem *result, voi
/* Use triple-DES (Should look up the algorithm) */
type = CKM_DES3_CBC;
key = PK11_FindFixedKey (slot, type, &sdrResult.keyid, cx);
- if (!key) {
- rv = SECFailure;
+ if (!key) {
+ rv = SECFailure;
} else {
- rv = pk11Decrypt (slot, arena, type, key, params,
+ rv = pk11Decrypt (slot, arena, type, key, params,
&sdrResult.data, result);
}
@@ -270,18 +275,18 @@ PK11SDR_DecryptWithSlot (PK11SlotInfo *slot, SECItem *data, SECItem *result, voi
PORT_FreeArena (arena, PR_TRUE);
if (key)
- PK11_FreeSymKey(key);
+ PK11_FreeSymKey (key);
if (params)
- SECITEM_ZfreeItem(params, PR_TRUE);
+ SECITEM_ZfreeItem (params, PR_TRUE);
if (possibleResult.data)
- SECITEM_ZfreeItem(&possibleResult, PR_FALSE);
+ SECITEM_ZfreeItem (&possibleResult, PR_FALSE);
return rv;
}
-char * ephy_nss_glue_decrypt (const unsigned char *data, gsize length)
+char *ephy_nss_glue_decrypt (const unsigned char *data, gsize length)
{
char *plain = NULL;
SECItem request, reply;
@@ -291,14 +296,14 @@ char * ephy_nss_glue_decrypt (const unsigned char *data, gsize length)
if (result != SECSuccess)
return NULL;
- request.data = (unsigned char*)data;
+ request.data = (unsigned char *)data;
request.len = length;
reply.data = NULL;
reply.len = 0;
result = PK11SDR_DecryptWithSlot (db_slot, &request, &reply, NULL);
if (result == SECSuccess)
- plain = g_strndup ((const char*)reply.data, reply.len);
+ plain = g_strndup ((const char *)reply.data, reply.len);
SECITEM_FreeItem (&reply, PR_FALSE);
diff --git a/lib/ephy-profile-migrator.c b/lib/ephy-profile-migrator.c
index 96dfa11..b613f79 100644
--- a/lib/ephy-profile-migrator.c
+++ b/lib/ephy-profile-migrator.c
@@ -110,7 +110,7 @@ migrate_cookies (void)
cookies = soup_cookie_jar_all_cookies (txt);
for (p = cookies; p; p = p->next) {
- SoupCookie *cookie = (SoupCookie*)p->data;
+ SoupCookie *cookie = (SoupCookie *)p->data;
/* Cookie is stolen, so we won't free it */
soup_cookie_jar_add_cookie (sqlite, cookie);
}
@@ -127,7 +127,7 @@ migrate_cookies (void)
}
#ifdef ENABLE_NSS
-static char*
+static char *
decrypt (const char *data)
{
unsigned char *plain;
@@ -142,15 +142,15 @@ decrypt (const char *data)
decrypted = ephy_nss_glue_decrypt (plain, out_len);
g_free (plain);
- plain = (unsigned char*)decrypted;
+ plain = (unsigned char *)decrypted;
}
- return (char*)plain;
+ return (char *)plain;
}
static void
parse_and_decrypt_signons (const char *signons,
- gboolean handle_forms)
+ gboolean handle_forms)
{
int version;
gchar **lines;
@@ -224,7 +224,7 @@ parse_and_decrypt_signons (const char *signons,
g_free (url);
start += strlen (realmBracketBegin);
- end_ptr = g_strstr_len (full_url, -1, realmBracketEnd) -1;
+ end_ptr = g_strstr_len (full_url, -1, realmBracketEnd) - 1;
ending = g_utf8_pointer_to_offset (full_url, end_ptr);
realm = g_utf8_substring (full_url, start, ending);
@@ -297,7 +297,7 @@ parse_and_decrypt_signons (const char *signons,
/* We skip the '*' at the beginning of form_password. */
ephy_form_auth_data_store (u,
form_username,
- form_password+1,
+ form_password + 1,
username,
password,
NULL, NULL);
@@ -470,7 +470,7 @@ history_parse_text (GMarkupParseContext *context,
{
HistoryParseData *parse_data = user_data;
- if (!parse_data || ! parse_data->current)
+ if (!parse_data || !parse_data->current)
return;
if (g_str_equal (parse_data->current, "2")) {
@@ -691,7 +691,7 @@ migrate_profile_gnome2_to_xdg (void)
static char *
fix_desktop_file_and_return_new_location (const char *dir)
{
- GRegex * regex;
+ GRegex *regex;
char *result, *old_profile_dir, *replacement, *contents, *new_contents;
gsize length;
@@ -729,40 +729,40 @@ migrate_web_app_links (void)
apps = ephy_web_application_get_application_list ();
for (p = apps; p; p = p->next) {
char *desktop_file, *app_link;
- EphyWebApplication *app = (EphyWebApplication*)p->data;
+ EphyWebApplication *app = (EphyWebApplication *)p->data;
desktop_file = app->desktop_file;
/* Update the link in applications. */
app_link = g_build_filename (g_get_user_data_dir (), "applications", desktop_file, NULL);
if (g_file_test (app_link, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_SYMLINK)) {
- /* Change the link to point to the new profile dir. */
- GFileInfo *info;
- const char *target;
- GFile *file = g_file_new_for_path (app_link);
-
- info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET,
- 0, NULL, NULL);
- if (info) {
- char *new_target;
-
- target = g_file_info_get_symlink_target (info);
- new_target = fix_desktop_file_and_return_new_location (target);
-
- /* FIXME: Updating the file info and setting it again should
- * work, but it does not? Just delete and create the link
- * again. */
- g_file_delete (file, 0, 0);
- g_object_unref (file);
-
- file = g_file_new_for_path (app_link);
- g_file_make_symbolic_link (file, new_target, NULL, NULL);
-
- g_object_unref (info);
- g_free (new_target);
- }
-
+ /* Change the link to point to the new profile dir. */
+ GFileInfo *info;
+ const char *target;
+ GFile *file = g_file_new_for_path (app_link);
+
+ info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET,
+ 0, NULL, NULL);
+ if (info) {
+ char *new_target;
+
+ target = g_file_info_get_symlink_target (info);
+ new_target = fix_desktop_file_and_return_new_location (target);
+
+ /* FIXME: Updating the file info and setting it again should
+ * work, but it does not? Just delete and create the link
+ * again. */
+ g_file_delete (file, 0, 0);
g_object_unref (file);
+
+ file = g_file_new_for_path (app_link);
+ g_file_make_symbolic_link (file, new_target, NULL, NULL);
+
+ g_object_unref (info);
+ g_free (new_target);
+ }
+
+ g_object_unref (file);
}
g_free (app_link);
@@ -821,8 +821,8 @@ static int form_passwords_migrating = 0;
static void
password_cleared_cb (SecretService *service,
- GAsyncResult *res,
- gpointer userdata)
+ GAsyncResult *res,
+ gpointer userdata)
{
secret_service_clear_finish (service, res, NULL);
@@ -831,9 +831,9 @@ password_cleared_cb (SecretService *service,
}
static void
-store_form_auth_data_cb (GObject *object,
+store_form_auth_data_cb (GObject *object,
GAsyncResult *res,
- GHashTable *attributes)
+ GHashTable *attributes)
{
GError *error = NULL;
@@ -848,7 +848,7 @@ store_form_auth_data_cb (GObject *object,
attributes, NULL, (GAsyncReadyCallback)password_cleared_cb,
NULL);
-out:
+ out:
if (g_atomic_int_dec_and_test (&form_passwords_migrating))
g_main_loop_quit (loop);
@@ -857,8 +857,8 @@ out:
static void
load_collection_items_cb (SecretCollection *collection,
- GAsyncResult *res,
- gpointer data)
+ GAsyncResult *res,
+ gpointer data)
{
SecretItem *item;
SecretValue *secret;
@@ -880,7 +880,7 @@ load_collection_items_cb (SecretCollection *collection,
items = secret_collection_get_items (collection);
for (l = items; l; l = l->next) {
- item = (SecretItem*)l->data;
+ item = (SecretItem *)l->data;
attributes = secret_item_get_attributes (item);
server = g_hash_table_lookup (attributes, "server");
@@ -940,7 +940,7 @@ migrate_form_passwords_to_libsecret (void)
for (c = collections; c; c = c->next) {
g_atomic_int_inc (&form_passwords_migrating);
- secret_collection_load_items ((SecretCollection*)c->data, NULL,
(GAsyncReadyCallback)load_collection_items_cb,
+ secret_collection_load_items ((SecretCollection *)c->data, NULL,
(GAsyncReadyCallback)load_collection_items_cb,
NULL);
}
@@ -959,7 +959,7 @@ migrate_app_desktop_file_categories (void)
web_apps = ephy_web_application_get_application_list ();
for (l = web_apps; l; l = l->next) {
- EphyWebApplication *app = (EphyWebApplication *) l->data;
+ EphyWebApplication *app = (EphyWebApplication *)l->data;
GKeyFile *file;
char *data = NULL;
char *app_path;
@@ -989,8 +989,8 @@ migrate_app_desktop_file_categories (void)
const EphyProfileMigrator migrators[] = {
migrate_cookies,
migrate_passwords,
- /* Yes, again! Version 2 had some bugs, so we need to run
- migrate_passwords again to possibly migrate more passwords*/
+ /* Yes, again! Version 2 had some bugs, so we need to run
+ migrate_passwords again to possibly migrate more passwords*/
migrate_passwords,
/* Very similar to migrate_passwords, but this migrates
* login/passwords for page forms, which we previously ignored */
@@ -1025,7 +1025,7 @@ ephy_migrator (void)
LOG ("Running only migrator: %d", do_step_n);
m = migrators[do_step_n];
- m();
+ m ();
return TRUE;
}
@@ -1046,7 +1046,7 @@ ephy_migrator (void)
continue;
m = migrators[i];
- m();
+ m ();
}
if (ephy_profile_utils_set_migration_version (EPHY_PROFILE_MIGRATION_VERSION) != TRUE) {
@@ -1099,13 +1099,13 @@ main (int argc, char *argv[])
return 1;
}
-
+
g_option_context_free (option_context);
if (migration_version != -1 && migration_version != EPHY_PROFILE_MIGRATION_VERSION) {
g_print ("Version mismatch, version %d requested but our version is %d\n",
migration_version, EPHY_PROFILE_MIGRATION_VERSION);
-
+
return 1;
}
@@ -1113,7 +1113,7 @@ main (int argc, char *argv[])
if (profile_dir != NULL)
file_helpers_flags = EPHY_FILE_HELPERS_PRIVATE_PROFILE |
- EPHY_FILE_HELPERS_KEEP_DIR;
+ EPHY_FILE_HELPERS_KEEP_DIR;
if (!ephy_file_helpers_init (profile_dir, file_helpers_flags, NULL)) {
LOG ("Something wrong happened with ephy_file_helpers_init()");
diff --git a/lib/ephy-profile-utils.c b/lib/ephy-profile-utils.c
index 20b05a5..b5dbb08 100644
--- a/lib/ephy-profile-utils.c
+++ b/lib/ephy-profile-utils.c
@@ -41,7 +41,7 @@ ephy_profile_utils_get_migration_version (void)
g_file_get_contents (migrated_file, &contents, &size, NULL);
if (contents != NULL)
- result = sscanf(contents, "%d", &latest);
+ result = sscanf (contents, "%d", &latest);
g_free (contents);
@@ -126,7 +126,7 @@ ephy_profile_utils_do_migration (const char *profile_directory, int test_to_run,
argv[i++] = NULL;
if (debug)
- argv[0] = ABS_TOP_BUILD_DIR"/lib/"EPHY_PROFILE_MIGRATOR;
+ argv[0] = ABS_TOP_BUILD_DIR "/lib/"EPHY_PROFILE_MIGRATOR;
ret = g_spawn_sync (NULL, (char **)argv, envp, G_SPAWN_SEARCH_PATH,
NULL, NULL, NULL, NULL,
@@ -134,7 +134,7 @@ ephy_profile_utils_do_migration (const char *profile_directory, int test_to_run,
g_free (index);
g_free (version);
g_strfreev (envp);
-
+
if (error) {
LOG ("Failed to run migrator: %s", error->message);
g_error_free (error);
diff --git a/lib/ephy-security-levels.c b/lib/ephy-security-levels.c
index 37c4fec..8782fb5 100644
--- a/lib/ephy-security-levels.c
+++ b/lib/ephy-security-levels.c
@@ -33,20 +33,20 @@ ephy_security_level_to_icon_name (EphySecurityLevel level)
const char *result;
switch (level) {
- case EPHY_SECURITY_LEVEL_LOCAL_PAGE:
- case EPHY_SECURITY_LEVEL_TO_BE_DETERMINED:
- result = NULL;
- break;
- case EPHY_SECURITY_LEVEL_NO_SECURITY:
- case EPHY_SECURITY_LEVEL_MIXED_CONTENT:
- case EPHY_SECURITY_LEVEL_UNACCEPTABLE_CERTIFICATE:
- result = "channel-insecure-symbolic";
- break;
- case EPHY_SECURITY_LEVEL_STRONG_SECURITY:
- result = "channel-secure-symbolic";
- break;
- default:
- g_assert_not_reached ();
+ case EPHY_SECURITY_LEVEL_LOCAL_PAGE:
+ case EPHY_SECURITY_LEVEL_TO_BE_DETERMINED:
+ result = NULL;
+ break;
+ case EPHY_SECURITY_LEVEL_NO_SECURITY:
+ case EPHY_SECURITY_LEVEL_MIXED_CONTENT:
+ case EPHY_SECURITY_LEVEL_UNACCEPTABLE_CERTIFICATE:
+ result = "channel-insecure-symbolic";
+ break;
+ case EPHY_SECURITY_LEVEL_STRONG_SECURITY:
+ result = "channel-secure-symbolic";
+ break;
+ default:
+ g_assert_not_reached ();
}
return result;
diff --git a/lib/ephy-signal-accumulator.c b/lib/ephy-signal-accumulator.c
index fc2a3b6..17831fb 100644
--- a/lib/ephy-signal-accumulator.c
+++ b/lib/ephy-signal-accumulator.c
@@ -1,58 +1,55 @@
/*
-* Copyright © 2004 Christian Persch
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, or (at your option)
-* any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
+ * Copyright © 2004 Christian Persch
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
#include "config.h"
#include "ephy-signal-accumulator.h"
-typedef GType (* GetTypeFunc) (void);
+typedef GType (*GetTypeFunc) (void);
gboolean
ephy_signal_accumulator_object (GSignalInvocationHint *ihint,
- GValue *return_accu,
- const GValue *handler_return,
- gpointer accu_data)
+ GValue *return_accu,
+ const GValue *handler_return,
+ gpointer accu_data)
{
- GObject *object;
- GetTypeFunc get_type = (GetTypeFunc) accu_data;
-
- object = g_value_get_object (handler_return);
- if (object != NULL &&
- G_TYPE_CHECK_INSTANCE_TYPE (object, get_type ()))
- {
- g_value_set_object (return_accu, object);
-
- return FALSE;
- }
- else if (object != NULL)
- {
- g_return_val_if_reached (TRUE);
- }
-
- return TRUE;
+ GObject *object;
+ GetTypeFunc get_type = (GetTypeFunc)accu_data;
+
+ object = g_value_get_object (handler_return);
+ if (object != NULL &&
+ G_TYPE_CHECK_INSTANCE_TYPE (object, get_type ())) {
+ g_value_set_object (return_accu, object);
+
+ return FALSE;
+ } else if (object != NULL) {
+ g_return_val_if_reached (TRUE);
+ }
+
+ return TRUE;
}
gboolean
ephy_signal_accumulator_string (GSignalInvocationHint *ihint,
- GValue *return_accu,
- const GValue *handler_return,
- gpointer accu_data)
+ GValue *return_accu,
+ const GValue *handler_return,
+ gpointer accu_data)
{
- g_value_copy (handler_return, return_accu);
-
- return g_value_get_string (handler_return) == NULL;
+ g_value_copy (handler_return, return_accu);
+
+ return g_value_get_string (handler_return) == NULL;
}
diff --git a/lib/ephy-smaps.c b/lib/ephy-smaps.c
index 9f15363..fbf4439 100644
--- a/lib/ephy-smaps.c
+++ b/lib/ephy-smaps.c
@@ -69,21 +69,21 @@ typedef enum {
static const char *get_ephy_process_name (EphyProcess process)
{
switch (process) {
- case EPHY_PROCESS_EPIPHANY:
- return "Browser";
- case EPHY_PROCESS_WEB:
- return "Web Process";
- case EPHY_PROCESS_PLUGIN:
- return "Plugin Process";
- case EPHY_PROCESS_OTHER:
- default:
- g_assert_not_reached ();
+ case EPHY_PROCESS_EPIPHANY:
+ return "Browser";
+ case EPHY_PROCESS_WEB:
+ return "Web Process";
+ case EPHY_PROCESS_PLUGIN:
+ return "Plugin Process";
+ case EPHY_PROCESS_OTHER:
+ default:
+ g_assert_not_reached ();
}
return NULL;
}
-static void vma_free (VMA_t* vma)
+static void vma_free (VMA_t *vma)
{
g_free (vma->start);
g_free (vma->end);
@@ -207,7 +207,7 @@ static void ephy_smaps_pid_to_html (EphySMaps *smaps, GString *str, pid_t pid, E
stream = g_file_read (file, NULL, &error);
g_object_unref (file);
- if (error && error->code == G_IO_ERROR_NOT_FOUND ) {
+ if (error && error->code == G_IO_ERROR_NOT_FOUND) {
/* This is not GNU/Linux, do nothing. */
g_error_free (error);
return;
@@ -238,7 +238,7 @@ static void ephy_smaps_pid_to_html (EphySMaps *smaps, GString *str, pid_t pid, E
vma->inode = g_match_info_fetch (match_info, 7);
vma->filename = g_match_info_fetch (match_info, 8);
}
-
+
g_match_info_free (match_info);
if (matched)
@@ -271,7 +271,7 @@ static void ephy_smaps_pid_to_html (EphySMaps *smaps, GString *str, pid_t pid, E
}
g_match_info_free (match_info);
- out:
+ out:
g_free (line);
}
@@ -292,7 +292,7 @@ static void ephy_smaps_pid_to_html (EphySMaps *smaps, GString *str, pid_t pid, E
(GDestroyNotify)perm_entry_free);
for (p = vma_entries; p; p = p->next) {
- VMA_t *entry = (VMA_t*)p->data;
+ VMA_t *entry = (VMA_t *)p->data;
if (g_strcmp0 (entry->major, "00") && g_strcmp0 (entry->minor, "00"))
add_to_perm_entry (anon_hash, entry);
@@ -438,7 +438,7 @@ static void ephy_smaps_pid_children_to_html (EphySMaps *smaps, GString *str, pid
g_dir_close (proc);
}
-char* ephy_smaps_to_html (EphySMaps *smaps)
+char *ephy_smaps_to_html (EphySMaps *smaps)
{
GString *str = g_string_new ("");
pid_t pid = getpid ();
diff --git a/lib/ephy-snapshot-service.c b/lib/ephy-snapshot-service.c
index ac176eb..dd2103b 100644
--- a/lib/ephy-snapshot-service.c
+++ b/lib/ephy-snapshot-service.c
@@ -30,8 +30,7 @@
/* Update snapshots after one week. */
#define SNAPSHOT_UPDATE_THRESHOLD (60 * 60 * 24 * 7)
-struct _EphySnapshotService
-{
+struct _EphySnapshotService {
GObject parent_instance;
GnomeDesktopThumbnailFactory *factory;
GHashTable *cache;
@@ -103,7 +102,7 @@ ephy_snapshot_service_prepare_snapshot (cairo_surface_t *surface,
x_offset = 6;
if (favicon) {
- GdkPixbuf* fav_pixbuf;
+ GdkPixbuf *fav_pixbuf;
int favicon_size = 16;
int y_offset = gdk_pixbuf_get_height (scaled) - favicon_size - x_offset;
@@ -129,7 +128,7 @@ typedef struct {
static SnapshotAsyncData *
snapshot_async_data_new (WebKitWebView *web_view,
- time_t mtime)
+ time_t mtime)
{
SnapshotAsyncData *data;
@@ -144,7 +143,7 @@ snapshot_async_data_new (WebKitWebView *web_view,
static SnapshotAsyncData *
snapshot_async_data_new_for_snapshot (WebKitWebView *web_view,
- time_t mtime)
+ time_t mtime)
{
SnapshotAsyncData *data = snapshot_async_data_new (web_view, mtime);
@@ -158,7 +157,7 @@ snapshot_async_data_free (SnapshotAsyncData *data)
{
if (data->web_view)
g_object_remove_weak_pointer (G_OBJECT (data->web_view), (gpointer *)&data->web_view);
- g_clear_object(&data->snapshot);
+ g_clear_object (&data->snapshot);
g_free (data->path);
g_slice_free (SnapshotAsyncData, data);
@@ -166,8 +165,8 @@ snapshot_async_data_free (SnapshotAsyncData *data)
static void
snapshot_saved (EphySnapshotService *service,
- GAsyncResult *result,
- GTask *task)
+ GAsyncResult *result,
+ GTask *task)
{
SnapshotAsyncData *data = g_task_get_task_data (task);
char *path;
@@ -184,7 +183,7 @@ snapshot_saved (EphySnapshotService *service,
static void
save_snapshot (cairo_surface_t *surface,
- GTask *task)
+ GTask *task)
{
SnapshotAsyncData *data = g_task_get_task_data (task);
@@ -202,8 +201,8 @@ save_snapshot (cairo_surface_t *surface,
static void
on_snapshot_ready (WebKitWebView *web_view,
- GAsyncResult *result,
- GTask *task)
+ GAsyncResult *result,
+ GTask *task)
{
cairo_surface_t *surface;
GError *error = NULL;
@@ -244,7 +243,7 @@ retrieve_snapshot_from_web_view (GTask *task)
static void
webview_destroyed_cb (GtkWidget *web_view,
- GTask *task)
+ GTask *task)
{
g_task_return_new_error (task,
EPHY_SNAPSHOT_SERVICE_ERROR,
@@ -254,16 +253,16 @@ webview_destroyed_cb (GtkWidget *web_view,
}
static void
-webview_load_changed_cb (WebKitWebView *web_view,
+webview_load_changed_cb (WebKitWebView *web_view,
WebKitLoadEvent load_event,
- GTask *task)
+ GTask *task)
{
if (load_event != WEBKIT_LOAD_FINISHED)
return;
/* Load finished doesn't ensure that we actually have visible content yet,
so hold a bit before retrieving the snapshot. */
- g_idle_add ((GSourceFunc) retrieve_snapshot_from_web_view, task);
+ g_idle_add ((GSourceFunc)retrieve_snapshot_from_web_view, task);
/* Some pages might end up causing this condition to happen twice, so remove
the handler in order to avoid calling the above idle function twice. */
@@ -272,11 +271,11 @@ webview_load_changed_cb (WebKitWebView *web_view,
}
static gboolean
-webview_load_failed_cb (WebKitWebView *web_view,
+webview_load_failed_cb (WebKitWebView *web_view,
WebKitLoadEvent load_event,
- const char failing_uri,
- GError *error,
- GTask *task)
+ const char failing_uri,
+ GError *error,
+ GTask *task)
{
g_signal_handlers_disconnect_by_func (web_view, webview_load_changed_cb, task);
g_signal_handlers_disconnect_by_func (web_view, webview_load_failed_cb, task);
@@ -356,7 +355,7 @@ typedef struct {
static SnapshotForURLAsyncData *
snapshot_for_url_async_data_new (const char *url,
- time_t mtime)
+ time_t mtime)
{
SnapshotForURLAsyncData *data;
@@ -385,7 +384,7 @@ typedef struct {
static gboolean
idle_cache_snapshot_path (gpointer user_data)
{
- CacheData* data = (CacheData*)user_data;
+ CacheData *data = (CacheData *)user_data;
g_hash_table_insert (data->cache, data->url, data->path);
g_hash_table_unref (data->cache);
g_free (data);
@@ -394,10 +393,10 @@ idle_cache_snapshot_path (gpointer user_data)
}
static void
-get_snapshot_for_url_thread (GTask *task,
- EphySnapshotService *service,
+get_snapshot_for_url_thread (GTask *task,
+ EphySnapshotService *service,
SnapshotForURLAsyncData *data,
- GCancellable *cancellable)
+ GCancellable *cancellable)
{
GdkPixbuf *snapshot;
GError *error = NULL;
@@ -445,11 +444,11 @@ get_snapshot_for_url_thread (GTask *task,
**/
void
ephy_snapshot_service_get_snapshot_for_url_async (EphySnapshotService *service,
- const char *url,
- const time_t mtime,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+ const char *url,
+ const time_t mtime,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GTask *task;
@@ -479,9 +478,9 @@ ephy_snapshot_service_get_snapshot_for_url_async (EphySnapshotService *service,
**/
GdkPixbuf *
ephy_snapshot_service_get_snapshot_for_url_finish (EphySnapshotService *service,
- GAsyncResult *result,
- gchar **path,
- GError **error)
+ GAsyncResult *result,
+ gchar **path,
+ GError **error)
{
GTask *task = G_TASK (result);
GdkPixbuf *snapshot;
@@ -505,8 +504,8 @@ ephy_snapshot_service_get_snapshot_for_url_finish (EphySnapshotService *service,
static void
got_snapshot_for_url (EphySnapshotService *service,
- GAsyncResult *result,
- GTask *task)
+ GAsyncResult *result,
+ GTask *task)
{
GdkPixbuf *snapshot;
SnapshotAsyncData *data;
@@ -537,11 +536,11 @@ got_snapshot_for_url (EphySnapshotService *service,
**/
void
ephy_snapshot_service_get_snapshot_async (EphySnapshotService *service,
- WebKitWebView *web_view,
- const time_t mtime,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+ WebKitWebView *web_view,
+ const time_t mtime,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GTask *task;
const char *uri;
@@ -580,9 +579,9 @@ ephy_snapshot_service_get_snapshot_async (EphySnapshotService *service,
**/
GdkPixbuf *
ephy_snapshot_service_get_snapshot_finish (EphySnapshotService *service,
- GAsyncResult *result,
- gchar **path,
- GError **error)
+ GAsyncResult *result,
+ gchar **path,
+ GError **error)
{
GTask *task = G_TASK (result);
GdkPixbuf *snapshot;
@@ -611,9 +610,9 @@ typedef struct {
} SaveSnapshotAsyncData;
static SaveSnapshotAsyncData *
-save_snapshot_async_data_new (GdkPixbuf *snapshot,
+save_snapshot_async_data_new (GdkPixbuf *snapshot,
const char *url,
- time_t mtime)
+ time_t mtime)
{
SaveSnapshotAsyncData *data;
@@ -635,10 +634,10 @@ save_snapshot_async_data_free (SaveSnapshotAsyncData *data)
}
static void
-save_snapshot_thread (GTask *task,
- EphySnapshotService *service,
+save_snapshot_thread (GTask *task,
+ EphySnapshotService *service,
SaveSnapshotAsyncData *data,
- GCancellable *cancellable)
+ GCancellable *cancellable)
{
char *path;
CacheData *cache_data;
@@ -661,12 +660,12 @@ save_snapshot_thread (GTask *task,
void
ephy_snapshot_service_save_snapshot_async (EphySnapshotService *service,
- GdkPixbuf *snapshot,
- const char *url,
- time_t mtime,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+ GdkPixbuf *snapshot,
+ const char *url,
+ time_t mtime,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GTask *task;
@@ -685,8 +684,8 @@ ephy_snapshot_service_save_snapshot_async (EphySnapshotService *service,
char *
ephy_snapshot_service_save_snapshot_finish (EphySnapshotService *service,
- GAsyncResult *result,
- GError **error)
+ GAsyncResult *result,
+ GError **error)
{
g_return_val_if_fail (g_task_is_valid (result, service), NULL);
@@ -695,7 +694,7 @@ ephy_snapshot_service_save_snapshot_finish (EphySnapshotService *service,
const char *
ephy_snapshot_service_lookup_snapshot_path (EphySnapshotService *service,
- const char *url)
+ const char *url)
{
g_return_val_if_fail (EPHY_IS_SNAPSHOT_SERVICE (service), NULL);
@@ -703,10 +702,10 @@ ephy_snapshot_service_lookup_snapshot_path (EphySnapshotService *service,
}
static void
-get_snapshot_path_for_url_thread (GTask *task,
- EphySnapshotService *service,
+get_snapshot_path_for_url_thread (GTask *task,
+ EphySnapshotService *service,
SnapshotForURLAsyncData *data,
- GCancellable *cancellable)
+ GCancellable *cancellable)
{
char *path;
CacheData *cache_data;
@@ -731,11 +730,11 @@ get_snapshot_path_for_url_thread (GTask *task,
void
ephy_snapshot_service_get_snapshot_path_for_url_async (EphySnapshotService *service,
- const char *url,
- const time_t mtime,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+ const char *url,
+ const time_t mtime,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GTask *task;
const char *path;
@@ -762,8 +761,8 @@ ephy_snapshot_service_get_snapshot_path_for_url_async (EphySnapshotService *serv
char *
ephy_snapshot_service_get_snapshot_path_for_url_finish (EphySnapshotService *service,
- GAsyncResult *result,
- GError **error)
+ GAsyncResult *result,
+ GError **error)
{
g_return_val_if_fail (g_task_is_valid (result, service), NULL);
@@ -772,8 +771,8 @@ ephy_snapshot_service_get_snapshot_path_for_url_finish (EphySnapshotService *ser
static void
got_snapshot_path_for_url (EphySnapshotService *service,
- GAsyncResult *result,
- GTask *task)
+ GAsyncResult *result,
+ GTask *task)
{
char *path;
@@ -788,11 +787,11 @@ got_snapshot_path_for_url (EphySnapshotService *service,
void
ephy_snapshot_service_get_snapshot_path_async (EphySnapshotService *service,
- WebKitWebView *web_view,
- const time_t mtime,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+ WebKitWebView *web_view,
+ const time_t mtime,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GTask *task;
const char *uri;
@@ -829,8 +828,8 @@ ephy_snapshot_service_get_snapshot_path_async (EphySnapshotService *service,
char *
ephy_snapshot_service_get_snapshot_path_finish (EphySnapshotService *service,
- GAsyncResult *result,
- GError **error)
+ GAsyncResult *result,
+ GError **error)
{
g_return_val_if_fail (g_task_is_valid (result, service), NULL);
diff --git a/lib/ephy-sqlite-connection.c b/lib/ephy-sqlite-connection.c
index 10bc5d6..90266a4 100644
--- a/lib/ephy-sqlite-connection.c
+++ b/lib/ephy-sqlite-connection.c
@@ -53,7 +53,7 @@ static GQuark get_ephy_sqlite_quark (void)
}
static void
-set_error_from_string (const char* string, GError **error)
+set_error_from_string (const char *string, GError **error)
{
if (error)
*error = g_error_new_literal (get_ephy_sqlite_quark (), 0, string);
@@ -72,7 +72,7 @@ ephy_sqlite_connection_open (EphySQLiteConnection *self, const gchar *filename,
set_error_from_string ("Connection already open.", error);
return FALSE;
}
-
+
if (sqlite3_open (filename, &self->database) != SQLITE_OK) {
ephy_sqlite_connection_get_error (self, error);
self->database = NULL;
@@ -105,7 +105,7 @@ ephy_sqlite_connection_execute (EphySQLiteConnection *self, const char *sql, GEr
set_error_from_string ("Connection not open.", error);
return FALSE;
}
-
+
return sqlite3_exec (self->database, sql, NULL, NULL, NULL) == SQLITE_OK;
}
@@ -161,7 +161,7 @@ ephy_sqlite_connection_table_exists (EphySQLiteConnection *self, const char *tab
gboolean table_exists = FALSE;
EphySQLiteStatement *statement = ephy_sqlite_connection_create_statement (self,
- "SELECT COUNT(type) FROM sqlite_master WHERE type='table' and name=?", &error);
+ "SELECT COUNT(type) FROM
sqlite_master WHERE type='table' and name=?", &error);
if (error) {
g_warning ("Could not detect table existence: %s", error->message);
g_error_free (error);
diff --git a/lib/ephy-sqlite-statement.c b/lib/ephy-sqlite-statement.c
index 7958879..41f2748 100644
--- a/lib/ephy-sqlite-statement.c
+++ b/lib/ephy-sqlite-statement.c
@@ -21,8 +21,7 @@
#include "ephy-sqlite-connection.h"
#include <sqlite3.h>
-enum
-{
+enum {
PROP_0,
PROP_PREPARED_STATEMENT,
PROP_CONNECTION,
@@ -236,13 +235,13 @@ ephy_sqlite_statement_get_column_as_double (EphySQLiteStatement *self, int colum
return sqlite3_column_double (self->prepared_statement, column);
}
-const char*
+const char *
ephy_sqlite_statement_get_column_as_string (EphySQLiteStatement *self, int column)
{
- return (const char*) sqlite3_column_text (self->prepared_statement, column);
+ return (const char *)sqlite3_column_text (self->prepared_statement, column);
}
-const void*
+const void *
ephy_sqlite_statement_get_column_as_blob (EphySQLiteStatement *self, int column)
{
return sqlite3_column_blob (self->prepared_statement, column);
diff --git a/lib/ephy-string.c b/lib/ephy-string.c
index 5e866cf..57e2d50 100644
--- a/lib/ephy-string.c
+++ b/lib/ephy-string.c
@@ -68,7 +68,7 @@ ephy_string_blank_chr (char *source)
p = source;
while (*p != '\0') {
- if ((guchar) *p < 0x20)
+ if ((guchar) * p < 0x20)
*p = ' ';
p++;
@@ -81,10 +81,10 @@ ephy_string_blank_chr (char *source)
* ephy_string_shorten: shortens a string
* @str: the string to shorten, in UTF-8
* @target_length: the length of the shortened string (in characters)
- *
+ *
* If @str is already short enough, it is returned. Otherwise a new string
* is allocated and @str is consumed.
- *
+ *
* Return value: a newly allocated string, not longer than target_length
* characters.
*/
@@ -105,23 +105,23 @@ ephy_string_shorten (char *str,
* it can still split a sequence of combining characters.
*/
actual_length = g_utf8_strlen (str, -1);
-
+
/* if the string is already short enough, or if it's too short for
* us to shorten it, return a new copy */
if ((gsize)actual_length <= target_length)
return str;
-
+
/* create string */
bytes = GPOINTER_TO_UINT (g_utf8_offset_to_pointer (str, target_length - 1) - str);
-
- new_str = g_new (gchar, bytes + strlen(ELLIPSIS) + 1);
-
+
+ new_str = g_new (gchar, bytes + strlen (ELLIPSIS) + 1);
+
strncpy (new_str, str, bytes);
strncpy (new_str + bytes, ELLIPSIS, strlen (ELLIPSIS));
new_str[bytes + strlen (ELLIPSIS)] = '\0';
-
+
g_free (str);
-
+
return new_str;
}
@@ -136,12 +136,12 @@ ephy_string_shorten (char *str,
* ephy_string_collate_key_for_domain:
* @host:
* @len: the length of @host, or -1 to use the entire null-terminated @host string
- *
+ *
* Return value: a collation key for @host.
*/
-char*
+char *
ephy_string_collate_key_for_domain (const char *str,
- gssize len)
+ gssize len)
{
GString *result;
const char *dot;
@@ -176,7 +176,7 @@ ephy_string_get_host_name (const char *url)
{
SoupURI *uri;
char *ret;
-
+
if (url == NULL ||
g_str_has_prefix (url, "file://") ||
g_str_has_prefix (url, "about:") ||
@@ -188,9 +188,9 @@ ephy_string_get_host_name (const char *url)
* something without a scheme, let's try to prepend
* 'http://' */
if (uri == NULL) {
- char *effective_url = g_strconcat ("http://", url, NULL);
- uri = soup_uri_new (effective_url);
- g_free (effective_url);
+ char *effective_url = g_strconcat ("http://", url, NULL);
+ uri = soup_uri_new (effective_url);
+ g_free (effective_url);
}
if (uri == NULL) return NULL;
@@ -229,7 +229,7 @@ ephy_string_commandline_args_to_uris (char **arguments, GError **error)
args[i] = g_file_get_uri (file);
} else {
args[i] = g_locale_to_utf8 (arguments [i], -1,
- NULL, NULL, error);
+ NULL, NULL, error);
if (error && *error) {
g_strfreev (args);
return NULL;
diff --git a/lib/ephy-time-helpers.c b/lib/ephy-time-helpers.c
index dc3fe74..8586330 100644
--- a/lib/ephy-time-helpers.c
+++ b/lib/ephy-time-helpers.c
@@ -64,223 +64,223 @@
char *
eel_strdup_strftime (const char *format, struct tm *time_pieces)
{
- GString *string;
- const char *remainder, *percent;
- char code[4], buffer[512];
- char *piece, *result, *converted;
- size_t string_length;
- gboolean strip_leading_zeros, turn_leading_zeros_to_spaces;
- char modifier;
- int i;
+ GString *string;
+ const char *remainder, *percent;
+ char code[4], buffer[512];
+ char *piece, *result, *converted;
+ size_t string_length;
+ gboolean strip_leading_zeros, turn_leading_zeros_to_spaces;
+ char modifier;
+ int i;
- /* Format could be translated, and contain UTF-8 chars,
- * so convert to locale encoding which strftime uses */
- converted = g_locale_from_utf8 (format, -1, NULL, NULL, NULL);
- g_return_val_if_fail (converted != NULL, NULL);
+ /* Format could be translated, and contain UTF-8 chars,
+ * so convert to locale encoding which strftime uses */
+ converted = g_locale_from_utf8 (format, -1, NULL, NULL, NULL);
+ g_return_val_if_fail (converted != NULL, NULL);
- string = g_string_new ("");
- remainder = converted;
+ string = g_string_new ("");
+ remainder = converted;
- /* Walk from % character to % character. */
- for (;;) {
- percent = strchr (remainder, '%');
- if (percent == NULL) {
- g_string_append (string, remainder);
- break;
- }
- g_string_append_len (string, remainder,
- percent - remainder);
+ /* Walk from % character to % character. */
+ for (;; ) {
+ percent = strchr (remainder, '%');
+ if (percent == NULL) {
+ g_string_append (string, remainder);
+ break;
+ }
+ g_string_append_len (string, remainder,
+ percent - remainder);
- /* Handle the "%" character. */
- remainder = percent + 1;
- switch (*remainder) {
- case '-':
- strip_leading_zeros = TRUE;
- turn_leading_zeros_to_spaces = FALSE;
- remainder++;
- break;
- case '_':
- strip_leading_zeros = FALSE;
- turn_leading_zeros_to_spaces = TRUE;
- remainder++;
- break;
- case '%':
- g_string_append_c (string, '%');
- remainder++;
- continue;
- case '\0':
- g_warning ("Trailing %% passed to eel_strdup_strftime");
- g_string_append_c (string, '%');
- continue;
- default:
- strip_leading_zeros = FALSE;
- turn_leading_zeros_to_spaces = FALSE;
- break;
- }
+ /* Handle the "%" character. */
+ remainder = percent + 1;
+ switch (*remainder) {
+ case '-':
+ strip_leading_zeros = TRUE;
+ turn_leading_zeros_to_spaces = FALSE;
+ remainder++;
+ break;
+ case '_':
+ strip_leading_zeros = FALSE;
+ turn_leading_zeros_to_spaces = TRUE;
+ remainder++;
+ break;
+ case '%':
+ g_string_append_c (string, '%');
+ remainder++;
+ continue;
+ case '\0':
+ g_warning ("Trailing %% passed to eel_strdup_strftime");
+ g_string_append_c (string, '%');
+ continue;
+ default:
+ strip_leading_zeros = FALSE;
+ turn_leading_zeros_to_spaces = FALSE;
+ break;
+ }
- modifier = 0;
- if (strchr (SUS_EXTENDED_STRFTIME_MODIFIERS, *remainder) != NULL) {
- modifier = *remainder;
- remainder++;
+ modifier = 0;
+ if (strchr (SUS_EXTENDED_STRFTIME_MODIFIERS, *remainder) != NULL) {
+ modifier = *remainder;
+ remainder++;
- if (*remainder == 0) {
- g_warning ("Unfinished %%%c modifier passed to eel_strdup_strftime",
modifier);
- break;
- }
- }
+ if (*remainder == 0) {
+ g_warning ("Unfinished %%%c modifier passed to eel_strdup_strftime", modifier);
+ break;
+ }
+ }
- if (strchr (C_STANDARD_STRFTIME_CHARACTERS, *remainder) == NULL) {
- g_warning ("eel_strdup_strftime does not support "
- "non-standard escape code %%%c",
- *remainder);
- }
+ if (strchr (C_STANDARD_STRFTIME_CHARACTERS, *remainder) == NULL) {
+ g_warning ("eel_strdup_strftime does not support "
+ "non-standard escape code %%%c",
+ *remainder);
+ }
- /* Convert code to strftime format. We have a fixed
- * limit here that each code can expand to a maximum
- * of 512 bytes, which is probably OK. There's no
- * limit on the total size of the result string.
- */
- i = 0;
- code[i++] = '%';
- if (modifier != 0) {
+ /* Convert code to strftime format. We have a fixed
+ * limit here that each code can expand to a maximum
+ * of 512 bytes, which is probably OK. There's no
+ * limit on the total size of the result string.
+ */
+ i = 0;
+ code[i++] = '%';
+ if (modifier != 0) {
#ifdef HAVE_STRFTIME_EXTENSION
- code[i++] = modifier;
+ code[i++] = modifier;
#endif
- }
- code[i++] = *remainder;
- code[i++] = '\0';
+ }
+ code[i++] = *remainder;
+ code[i++] = '\0';
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
- /* Format string under control of caller, since this is a wrapper for strftime. */
- string_length = strftime (buffer, sizeof (buffer),
- code, time_pieces);
+ /* Format string under control of caller, since this is a wrapper for strftime. */
+ string_length = strftime (buffer, sizeof (buffer),
+ code, time_pieces);
#pragma GCC diagnostic pop
- if (string_length == 0) {
- /* We could put a warning here, but there's no
- * way to tell a successful conversion to
- * empty string from a failure.
- */
- buffer[0] = '\0';
- }
+ if (string_length == 0) {
+ /* We could put a warning here, but there's no
+ * way to tell a successful conversion to
+ * empty string from a failure.
+ */
+ buffer[0] = '\0';
+ }
- /* Strip leading zeros if requested. */
- piece = buffer;
- if (strip_leading_zeros || turn_leading_zeros_to_spaces) {
- if (strchr (C_STANDARD_NUMERIC_STRFTIME_CHARACTERS, *remainder) == NULL) {
- g_warning ("eel_strdup_strftime does not support "
- "modifier for non-numeric escape code %%%c%c",
- remainder[-1],
- *remainder);
- }
- if (*piece == '0') {
- do {
- piece++;
- } while (*piece == '0');
- if (!g_ascii_isdigit (*piece)) {
- piece--;
- }
- }
- if (turn_leading_zeros_to_spaces) {
- memset (buffer, ' ', piece - buffer);
- piece = buffer;
- }
- }
- remainder++;
+ /* Strip leading zeros if requested. */
+ piece = buffer;
+ if (strip_leading_zeros || turn_leading_zeros_to_spaces) {
+ if (strchr (C_STANDARD_NUMERIC_STRFTIME_CHARACTERS, *remainder) == NULL) {
+ g_warning ("eel_strdup_strftime does not support "
+ "modifier for non-numeric escape code %%%c%c",
+ remainder[-1],
+ *remainder);
+ }
+ if (*piece == '0') {
+ do {
+ piece++;
+ } while (*piece == '0');
+ if (!g_ascii_isdigit (*piece)) {
+ piece--;
+ }
+ }
+ if (turn_leading_zeros_to_spaces) {
+ memset (buffer, ' ', piece - buffer);
+ piece = buffer;
+ }
+ }
+ remainder++;
- /* Add this piece. */
- g_string_append (string, piece);
- }
+ /* Add this piece. */
+ g_string_append (string, piece);
+ }
- /* Convert the string back into utf-8. */
- result = g_locale_to_utf8 (string->str, -1, NULL, NULL, NULL);
+ /* Convert the string back into utf-8. */
+ result = g_locale_to_utf8 (string->str, -1, NULL, NULL, NULL);
- g_string_free (string, TRUE);
- g_free (converted);
+ g_string_free (string, TRUE);
+ g_free (converted);
- return result;
+ return result;
}
/* Based on evolution/mail/message-list.c:filter_date() */
char *
ephy_time_helpers_utf_friendly_time (time_t date)
{
- time_t nowdate;
- time_t yesdate;
- struct tm then, now, yesterday;
- const char *format = NULL;
- char *str = NULL;
- gboolean done = FALSE;
+ time_t nowdate;
+ time_t yesdate;
+ struct tm then, now, yesterday;
+ const char *format = NULL;
+ char *str = NULL;
+ gboolean done = FALSE;
- nowdate = time (NULL);
+ nowdate = time (NULL);
- if (date == 0)
- return NULL;
+ if (date == 0)
+ return NULL;
- localtime_r (&date, &then);
- localtime_r (&nowdate, &now);
+ localtime_r (&date, &then);
+ localtime_r (&nowdate, &now);
- if (then.tm_mday == now.tm_mday &&
- then.tm_mon == now.tm_mon &&
- then.tm_year == now.tm_year) {
- /* Translators: "friendly time" string for the current day, strftime format. like "Today
12:34 am" */
- format = _("Today %I:%M %p");
- done = TRUE;
- }
+ if (then.tm_mday == now.tm_mday &&
+ then.tm_mon == now.tm_mon &&
+ then.tm_year == now.tm_year) {
+ /* Translators: "friendly time" string for the current day, strftime format. like "Today 12:34 am" */
+ format = _("Today %I:%M %p");
+ done = TRUE;
+ }
- if (! done) {
- yesdate = nowdate - 60 * 60 * 24;
- localtime_r (&yesdate, &yesterday);
- if (then.tm_mday == yesterday.tm_mday &&
- then.tm_mon == yesterday.tm_mon &&
- then.tm_year == yesterday.tm_year) {
- /* Translators: "friendly time" string for the previous day,
- * strftime format. e.g. "Yesterday 12:34 am"
- */
- format = _("Yesterday %I:%M %p");
- done = TRUE;
- }
- }
+ if (!done) {
+ yesdate = nowdate - 60 * 60 * 24;
+ localtime_r (&yesdate, &yesterday);
+ if (then.tm_mday == yesterday.tm_mday &&
+ then.tm_mon == yesterday.tm_mon &&
+ then.tm_year == yesterday.tm_year) {
+ /* Translators: "friendly time" string for the previous day,
+ * strftime format. e.g. "Yesterday 12:34 am"
+ */
+ format = _("Yesterday %I:%M %p");
+ done = TRUE;
+ }
+ }
- if (! done) {
- int i;
- for (i = 2; i < 7; i++) {
- yesdate = nowdate - 60 * 60 * 24 * i;
- localtime_r (&yesdate, &yesterday);
- if (then.tm_mday == yesterday.tm_mday &&
- then.tm_mon == yesterday.tm_mon &&
- then.tm_year == yesterday.tm_year) {
- /* Translators: "friendly time" string for a day in the current week,
- * strftime format. e.g. "Wed 12:34 am"
- */
- format = _("%a %I:%M %p");
- done = TRUE;
- break;
- }
- }
- }
+ if (!done) {
+ int i;
+ for (i = 2; i < 7; i++) {
+ yesdate = nowdate - 60 * 60 * 24 * i;
+ localtime_r (&yesdate, &yesterday);
+ if (then.tm_mday == yesterday.tm_mday &&
+ then.tm_mon == yesterday.tm_mon &&
+ then.tm_year == yesterday.tm_year) {
+ /* Translators: "friendly time" string for a day in the current week,
+ * strftime format. e.g. "Wed 12:34 am"
+ */
+ format = _("%a %I:%M %p");
+ done = TRUE;
+ break;
+ }
+ }
+ }
- if (! done) {
- if (then.tm_year == now.tm_year) {
- /* Translators: "friendly time" string for a day in the current year,
- * strftime format. e.g. "Feb 12 12:34 am"
- */
- format = _("%b %d %I:%M %p");
- } else {
- /* Translators: "friendly time" string for a day in a different year,
- * strftime format. e.g. "Feb 12 1997"
- */
- format = _("%b %d %Y");
- }
- }
+ if (!done) {
+ if (then.tm_year == now.tm_year) {
+ /* Translators: "friendly time" string for a day in the current year,
+ * strftime format. e.g. "Feb 12 12:34 am"
+ */
+ format = _("%b %d %I:%M %p");
+ } else {
+ /* Translators: "friendly time" string for a day in a different year,
+ * strftime format. e.g. "Feb 12 1997"
+ */
+ format = _("%b %d %Y");
+ }
+ }
- if (format != NULL) {
- str = eel_strdup_strftime (format, &then);
- }
+ if (format != NULL) {
+ str = eel_strdup_strftime (format, &then);
+ }
- if (str == NULL) {
- /* impossible time or broken locale settings */
- str = g_strdup (_("Unknown"));
- }
+ if (str == NULL) {
+ /* impossible time or broken locale settings */
+ str = g_strdup (_("Unknown"));
+ }
- return str;
+ return str;
}
diff --git a/lib/ephy-uri-helpers.c b/lib/ephy-uri-helpers.c
index 95b258f..f7c3503 100644
--- a/lib/ephy-uri-helpers.c
+++ b/lib/ephy-uri-helpers.c
@@ -127,7 +127,7 @@ query_concat (GList *items)
}
g_ptr_array_add (array, NULL);
- ret = g_strjoinv ("&", (char **) array->pdata);
+ ret = g_strjoinv ("&", (char **)array->pdata);
g_ptr_array_free (array, TRUE);
return ret;
@@ -142,31 +142,31 @@ is_garbage (const char *name,
const char *host;
} const fields[] = {
/* analytics.google.com */
- { "utm_source", NULL },
- { "utm_medium", NULL },
- { "utm_term", NULL },
- { "utm_content", NULL },
- { "utm_campaign", NULL },
- { "utm_reader", NULL },
+ { "utm_source", NULL },
+ { "utm_medium", NULL },
+ { "utm_term", NULL },
+ { "utm_content", NULL },
+ { "utm_campaign", NULL },
+ { "utm_reader", NULL },
/* metrika.yandex.ru */
- { "yclid", NULL },
+ { "yclid", NULL },
/* youtube.com */
- { "feature", "youtube.com" },
+ { "feature", "youtube.com" },
/* facebook.com */
- { "fb_action_ids", NULL},
- { "fb_action_types", NULL },
- { "fb_ref", NULL },
- { "fb_source", NULL },
- { "action_object_map", NULL },
- { "action_type_map", NULL },
- { "action_ref_map", NULL },
- { "ref", "facebook.com" },
- { "fref", "facebook.com" },
- { "hc_location", "facebook.com" },
+ { "fb_action_ids", NULL },
+ { "fb_action_types", NULL },
+ { "fb_ref", NULL },
+ { "fb_source", NULL },
+ { "action_object_map", NULL },
+ { "action_type_map", NULL },
+ { "action_ref_map", NULL },
+ { "ref", "facebook.com" },
+ { "fref", "facebook.com" },
+ { "hc_location", "facebook.com" },
/* imdb.com */
- { "ref_", "imdb.com" },
+ { "ref_", "imdb.com" },
/* addons.mozilla.org */
- { "src", "addons.mozilla.org" }
+ { "src", "addons.mozilla.org" }
};
guint i;
@@ -239,10 +239,10 @@ ephy_remove_tracking_from_uri (const char *uri_string)
ret = soup_uri_to_string (uri, FALSE);
}
- g_list_free_full (items, (GDestroyNotify) query_item_free);
+ g_list_free_full (items, (GDestroyNotify)query_item_free);
g_list_free (new_items);
-bail:
+ bail:
soup_uri_free (uri);
return ret;
}
diff --git a/lib/ephy-web-app-utils.c b/lib/ephy-web-app-utils.c
index 37b6be7..aaf1f7c 100644
--- a/lib/ephy-web-app-utils.c
+++ b/lib/ephy-web-app-utils.c
@@ -111,10 +111,10 @@ ephy_web_application_get_profile_directory (const char *name)
/**
* ephy_web_application_delete:
* @name: the name of the web application do delete
- *
+ *
* Deletes all the data associated with a Web Application created by
* Epiphany.
- *
+ *
* Returns: %TRUE if the web app was succesfully deleted, %FALSE otherwise
**/
gboolean
@@ -158,7 +158,7 @@ ephy_web_application_delete (const char *name)
}
return_value = TRUE;
-out:
+ out:
g_free (profile_dir);
@@ -174,7 +174,7 @@ static char *
create_desktop_file (const char *address,
const char *profile_dir,
const char *title,
- GdkPixbuf *icon)
+ GdkPixbuf *icon)
{
GKeyFile *file = NULL;
char *exec_string;
@@ -213,7 +213,7 @@ create_desktop_file (const char *address,
path = g_build_filename (profile_dir, EPHY_WEB_APP_ICON_NAME, NULL);
image = g_file_new_for_path (path);
- stream = (GOutputStream*)g_file_create (image, 0, NULL, NULL);
+ stream = (GOutputStream *)g_file_create (image, 0, NULL, NULL);
gdk_pixbuf_save_to_stream (icon, stream, "png", NULL, NULL, NULL);
g_key_file_set_value (file, "Desktop Entry", "Icon", path);
@@ -248,7 +248,7 @@ create_desktop_file (const char *address,
g_free (apps_path);
g_free (filename);
-out:
+ out:
g_free (wm_class);
g_free (data);
g_key_file_free (file);
@@ -268,7 +268,7 @@ static SoupCookieJar *get_current_cookie_jar (void)
*/
dot_dir = !ephy_dot_dir_is_default () ? ephy_default_dot_dir () : NULL;
filename = g_build_filename (dot_dir ? dot_dir : ephy_dot_dir (), "cookies.sqlite", NULL);
- jar = (SoupCookieJar*)soup_cookie_jar_db_new (filename, TRUE);
+ jar = (SoupCookieJar *)soup_cookie_jar_db_new (filename, TRUE);
g_free (filename);
g_free (dot_dir);
@@ -285,7 +285,7 @@ create_cookie_jar_for_domain (const char *address, const char *directory)
/* Create the new cookie jar */
filename = g_build_filename (directory, "cookies.sqlite", NULL);
- new_jar = (SoupCookieJar*)soup_cookie_jar_db_new (filename, FALSE);
+ new_jar = (SoupCookieJar *)soup_cookie_jar_db_new (filename, FALSE);
g_free (filename);
/* The app domain for the current view */
@@ -302,7 +302,7 @@ create_cookie_jar_for_domain (const char *address, const char *directory)
cookies = soup_cookie_jar_all_cookies (current_jar);
for (p = cookies; p; p = p->next) {
- SoupCookie *cookie = (SoupCookie*)p->data;
+ SoupCookie *cookie = (SoupCookie *)p->data;
if (soup_cookie_domain_matches (cookie, domain))
soup_cookie_jar_add_cookie (new_jar, cookie);
@@ -321,9 +321,9 @@ create_cookie_jar_for_domain (const char *address, const char *directory)
* @address: the address of the new web application
* @name: the name for the new web application
* @icon: the icon for the new web application
- *
+ *
* Creates a new Web Application for @address.
- *
+ *
* Returns: (transfer-full): the path to the desktop file representing the new application
**/
char *
@@ -349,13 +349,13 @@ ephy_web_application_create (const char *address, const char *name, GdkPixbuf *i
/* Things we need in a WebApp's profile:
- Our own cookies file, copying the relevant cookies for the
app's domain.
- */
+ */
create_cookie_jar_for_domain (address, profile_dir);
/* Create the deskop file. */
desktop_file_path = create_desktop_file (address, profile_dir, name, icon);
-out:
+ out:
if (profile_dir)
g_free (profile_dir);
@@ -458,7 +458,7 @@ ephy_web_application_setup_from_desktop_file (GDesktopAppInfo *desktop_info)
}
g_clear_object (&file);
} else if (G_IS_THEMED_ICON (icon)) {
- const char *const *names = g_themed_icon_get_names (G_THEMED_ICON (icon));
+ const char * const *names = g_themed_icon_get_names (G_THEMED_ICON (icon));
if (names)
gtk_window_set_default_icon_name (names[0]);
}
@@ -597,7 +597,7 @@ ephy_web_application_free_application_list (GList *list)
GList *p;
for (p = list; p; p = p->next)
- ephy_web_application_free ((EphyWebApplication*)p->data);
+ ephy_web_application_free ((EphyWebApplication *)p->data);
g_list_free (list);
}
diff --git a/lib/ephy-zoom.c b/lib/ephy-zoom.c
index c2c6780..6b77f61 100644
--- a/lib/ephy-zoom.c
+++ b/lib/ephy-zoom.c
@@ -48,7 +48,7 @@ ephy_zoom_get_changed_zoom_level (float level, int steps)
int index;
index = ephy_zoom_get_zoom_level_index (level);
- return zoom_levels[CLAMP(index + steps, 0, (int) n_zoom_levels - 1)].level;
+ return zoom_levels[CLAMP (index + steps, 0, (int)n_zoom_levels - 1)].level;
}
float
diff --git a/lib/history/ephy-history-service-hosts-table.c b/lib/history/ephy-history-service-hosts-table.c
index 2cfeeaa..ad27403 100644
--- a/lib/history/ephy-history-service-hosts-table.c
+++ b/lib/history/ephy-history-service-hosts-table.c
@@ -33,12 +33,12 @@ ephy_history_service_initialize_hosts_table (EphyHistoryService *self)
return TRUE;
}
ephy_sqlite_connection_execute (self->history_database,
- "CREATE TABLE hosts ("
- "id INTEGER PRIMARY KEY,"
- "url LONGVARCAR,"
- "title LONGVARCAR,"
- "visit_count INTEGER DEFAULT 0 NOT NULL,"
- "zoom_level REAL DEFAULT 1.0)", &error);
+ "CREATE TABLE hosts ("
+ "id INTEGER PRIMARY KEY,"
+ "url LONGVARCAR,"
+ "title LONGVARCAR,"
+ "visit_count INTEGER DEFAULT 0 NOT NULL,"
+ "zoom_level REAL DEFAULT 1.0)", &error);
if (error) {
g_warning ("Could not create hosts table: %s", error->message);
@@ -59,8 +59,8 @@ ephy_history_service_add_host_row (EphyHistoryService *self, EphyHistoryHost *ho
g_assert (self->history_database != NULL);
statement = ephy_sqlite_connection_create_statement (self->history_database,
- "INSERT INTO hosts (url, title, visit_count, zoom_level) "
- "VALUES (?, ?, ?, ?)", &error);
+ "INSERT INTO hosts (url, title, visit_count,
zoom_level) "
+ "VALUES (?, ?, ?, ?)", &error);
if (error) {
g_warning ("Could not build hosts table addition statement: %s", error->message);
@@ -99,8 +99,8 @@ ephy_history_service_update_host_row (EphyHistoryService *self, EphyHistoryHost
g_assert (self->history_database != NULL);
statement = ephy_sqlite_connection_create_statement (self->history_database,
- "UPDATE hosts SET url=?, title=?, visit_count=?, zoom_level=?"
- "WHERE id=?", &error);
+ "UPDATE hosts SET url=?, title=?, visit_count=?,
zoom_level=?"
+ "WHERE id=?", &error);
if (error) {
g_warning ("Could not build hosts table modification statement: %s", error->message);
g_error_free (error);
@@ -126,7 +126,7 @@ ephy_history_service_update_host_row (EphyHistoryService *self, EphyHistoryHost
g_object_unref (statement);
}
-EphyHistoryHost*
+EphyHistoryHost *
ephy_history_service_get_host_row (EphyHistoryService *self, const gchar *host_string, EphyHistoryHost *host)
{
EphySQLiteStatement *statement = NULL;
@@ -138,16 +138,16 @@ ephy_history_service_get_host_row (EphyHistoryService *self, const gchar *host_s
if (host_string == NULL && host != NULL)
host_string = host->url;
- g_assert (host_string || host->id !=-1);
+ g_assert (host_string || host->id != -1);
if (host != NULL && host->id != -1) {
statement = ephy_sqlite_connection_create_statement (self->history_database,
- "SELECT id, url, title, visit_count, zoom_level FROM hosts "
- "WHERE id=?", &error);
+ "SELECT id, url, title, visit_count, zoom_level
FROM hosts "
+ "WHERE id=?", &error);
} else {
statement = ephy_sqlite_connection_create_statement (self->history_database,
- "SELECT id, url, title, visit_count, zoom_level FROM hosts "
- "WHERE url=?", &error);
+ "SELECT id, url, title, visit_count, zoom_level
FROM hosts "
+ "WHERE url=?", &error);
}
if (error) {
@@ -194,7 +194,7 @@ ephy_history_service_get_host_row (EphyHistoryService *self, const gchar *host_s
return host;
}
-static EphyHistoryHost*
+static EphyHistoryHost *
create_host_from_statement (EphySQLiteStatement *statement)
{
EphyHistoryHost *host =
@@ -207,7 +207,7 @@ create_host_from_statement (EphySQLiteStatement *statement)
return host;
}
-GList*
+GList *
ephy_history_service_get_all_hosts (EphyHistoryService *self)
{
EphySQLiteStatement *statement = NULL;
@@ -218,7 +218,7 @@ ephy_history_service_get_all_hosts (EphyHistoryService *self)
g_assert (self->history_database != NULL);
statement = ephy_sqlite_connection_create_statement (self->history_database,
- "SELECT id, url, title, visit_count, zoom_level FROM hosts", &error);
+ "SELECT id, url, title, visit_count, zoom_level FROM
hosts", &error);
if (error) {
g_warning ("Could not build hosts query statement: %s", error->message);
@@ -240,7 +240,7 @@ ephy_history_service_get_all_hosts (EphyHistoryService *self)
return hosts;
}
-GList*
+GList *
ephy_history_service_find_host_rows (EphyHistoryService *self, EphyHistoryQuery *query)
{
EphySQLiteStatement *statement = NULL;
@@ -249,14 +249,14 @@ ephy_history_service_find_host_rows (EphyHistoryService *self, EphyHistoryQuery
GList *hosts = NULL;
GError *error = NULL;
const char *base_statement = ""
- "SELECT "
- "DISTINCT hosts.id, "
- "hosts.url, "
- "hosts.title, "
- "hosts.visit_count, "
- "hosts.zoom_level "
- "FROM "
- "hosts ";
+ "SELECT "
+ "DISTINCT hosts.id, "
+ "hosts.url, "
+ "hosts.title, "
+ "hosts.visit_count, "
+ "hosts.zoom_level "
+ "FROM "
+ "hosts ";
int i = 0;
@@ -267,7 +267,7 @@ ephy_history_service_find_host_rows (EphyHistoryService *self, EphyHistoryQuery
/* In either of these cases we need to at least join with the urls table. */
if (query->substring_list || query->from > 0 || query->to > 0)
- statement_str = g_string_append (statement_str, "JOIN urls on hosts.id = urls.host ");
+ statement_str = g_string_append (statement_str, "JOIN urls on hosts.id = urls.host ");
/* In these cases, we additionally need to join with the visits table. */
if (query->from > 0 || query->to > 0) {
@@ -287,7 +287,7 @@ ephy_history_service_find_host_rows (EphyHistoryService *self, EphyHistoryQuery
statement_str = g_string_append (statement_str, "1 ");
statement = ephy_sqlite_connection_create_statement (self->history_database,
- statement_str->str, &error);
+ statement_str->str, &error);
g_string_free (statement_str, TRUE);
if (error) {
@@ -316,7 +316,7 @@ ephy_history_service_find_host_rows (EphyHistoryService *self, EphyHistoryQuery
char *string = ephy_sqlite_create_match_pattern (substring->data);
while (j--)
/* The bitwise operation ensures we only skip two characters for titles. */
- if (ephy_sqlite_statement_bind_string (statement, i++, string + 2*((j+1) & 1), &error) == FALSE) {
+ if (ephy_sqlite_statement_bind_string (statement, i++, string + 2 * ((j + 1) & 1), &error) == FALSE) {
g_warning ("Could not build hosts table query statement: %s", error->message);
g_error_free (error);
g_object_unref (statement);
@@ -344,13 +344,13 @@ ephy_history_service_find_host_rows (EphyHistoryService *self, EphyHistoryQuery
static GList *
get_hostname_and_locations (const gchar *url, gchar **hostname)
{
- GList *host_locations = NULL;
- char *scheme = NULL;
+ GList *host_locations = NULL;
+ char *scheme = NULL;
if (url) {
- scheme = g_uri_parse_scheme (url);
- *hostname = ephy_string_get_host_name (url);
- }
+ scheme = g_uri_parse_scheme (url);
+ *hostname = ephy_string_get_host_name (url);
+ }
/* Build an host name */
if (scheme == NULL || *hostname == NULL) {
*hostname = g_strdup (_("Others"));
@@ -391,9 +391,9 @@ get_hostname_and_locations (const gchar *url, gchar **hostname)
return host_locations;
}
-EphyHistoryHost*
+EphyHistoryHost *
ephy_history_service_get_host_row_from_url (EphyHistoryService *self,
- const gchar *url)
+ const gchar *url)
{
GList *host_locations, *l;
char *hostname;
@@ -413,14 +413,14 @@ ephy_history_service_get_host_row_from_url (EphyHistoryService *self,
}
g_free (hostname);
- g_list_free_full (host_locations, (GDestroyNotify) g_free);
+ g_list_free_full (host_locations, (GDestroyNotify)g_free);
return host;
}
void
ephy_history_service_delete_host_row (EphyHistoryService *self,
- EphyHistoryHost *host)
+ EphyHistoryHost *host)
{
EphySQLiteStatement *statement = NULL;
gchar *sql_statement;
diff --git a/lib/history/ephy-history-service-urls-table.c b/lib/history/ephy-history-service-urls-table.c
index ead8475..56675bd 100644
--- a/lib/history/ephy-history-service-urls-table.c
+++ b/lib/history/ephy-history-service-urls-table.c
@@ -31,16 +31,16 @@ ephy_history_service_initialize_urls_table (EphyHistoryService *self)
return TRUE;
}
ephy_sqlite_connection_execute (self->history_database,
- "CREATE TABLE urls ("
- "id INTEGER PRIMARY KEY,"
- "host INTEGER NOT NULL REFERENCES hosts(id) ON DELETE CASCADE,"
- "url LONGVARCAR,"
- "title LONGVARCAR,"
- "visit_count INTEGER DEFAULT 0 NOT NULL,"
- "typed_count INTEGER DEFAULT 0 NOT NULL,"
- "last_visit_time INTEGER,"
- "thumbnail_update_time INTEGER DEFAULT 0,"
- "hidden_from_overview INTEGER DEFAULT 0)", &error);
+ "CREATE TABLE urls ("
+ "id INTEGER PRIMARY KEY,"
+ "host INTEGER NOT NULL REFERENCES hosts(id) ON DELETE CASCADE,"
+ "url LONGVARCAR,"
+ "title LONGVARCAR,"
+ "visit_count INTEGER DEFAULT 0 NOT NULL,"
+ "typed_count INTEGER DEFAULT 0 NOT NULL,"
+ "last_visit_time INTEGER,"
+ "thumbnail_update_time INTEGER DEFAULT 0,"
+ "hidden_from_overview INTEGER DEFAULT 0)", &error);
if (error) {
g_warning ("Could not create urls table: %s", error->message);
@@ -54,7 +54,7 @@ ephy_history_service_initialize_urls_table (EphyHistoryService *self)
EphyHistoryURL *
ephy_history_service_get_url_row (EphyHistoryService *self, const char *url_string, EphyHistoryURL *url)
{
- EphySQLiteStatement *statement = NULL;
+ EphySQLiteStatement *statement = NULL;
GError *error = NULL;
g_assert (self->history_thread == g_thread_self ());
@@ -67,12 +67,12 @@ ephy_history_service_get_url_row (EphyHistoryService *self, const char *url_stri
if (url != NULL && url->id != -1) {
statement = ephy_sqlite_connection_create_statement (self->history_database,
- "SELECT id, url, title, visit_count, typed_count, last_visit_time, hidden_from_overview,
thumbnail_update_time FROM urls "
- "WHERE id=?", &error);
+ "SELECT id, url, title, visit_count, typed_count,
last_visit_time, hidden_from_overview, thumbnail_update_time FROM urls "
+ "WHERE id=?", &error);
} else {
statement = ephy_sqlite_connection_create_statement (self->history_database,
- "SELECT id, url, title, visit_count, typed_count, last_visit_time, hidden_from_overview,
thumbnail_update_time FROM urls "
- "WHERE url=?", &error);
+ "SELECT id, url, title, visit_count, typed_count,
last_visit_time, hidden_from_overview, thumbnail_update_time FROM urls "
+ "WHERE url=?", &error);
}
if (error) {
@@ -124,15 +124,15 @@ ephy_history_service_get_url_row (EphyHistoryService *self, const char *url_stri
void
ephy_history_service_add_url_row (EphyHistoryService *self, EphyHistoryURL *url)
{
- EphySQLiteStatement *statement = NULL;
+ EphySQLiteStatement *statement = NULL;
GError *error = NULL;
g_assert (self->history_thread == g_thread_self ());
g_assert (self->history_database != NULL);
statement = ephy_sqlite_connection_create_statement (self->history_database,
- "INSERT INTO urls (url, title, visit_count, typed_count, last_visit_time, host) "
- " VALUES (?, ?, ?, ?, ?, ?)", &error);
+ "INSERT INTO urls (url, title, visit_count,
typed_count, last_visit_time, host) "
+ " VALUES (?, ?, ?, ?, ?, ?)", &error);
if (error) {
g_warning ("Could not build urls table addition statement: %s", error->message);
g_error_free (error);
@@ -140,7 +140,7 @@ ephy_history_service_add_url_row (EphyHistoryService *self, EphyHistoryURL *url)
}
if (ephy_sqlite_statement_bind_string (statement, 0, url->url, &error) == FALSE ||
- ephy_sqlite_statement_bind_string (statement, 1, url->title, &error) == FALSE ||
+ ephy_sqlite_statement_bind_string (statement, 1, url->title, &error) == FALSE ||
ephy_sqlite_statement_bind_int (statement, 2, url->visit_count, &error) == FALSE ||
ephy_sqlite_statement_bind_int (statement, 3, url->typed_count, &error) == FALSE ||
ephy_sqlite_statement_bind_int (statement, 4, url->last_visit_time, &error) == FALSE ||
@@ -172,15 +172,15 @@ ephy_history_service_update_url_row (EphyHistoryService *self, EphyHistoryURL *u
g_assert (self->history_database != NULL);
statement = ephy_sqlite_connection_create_statement (self->history_database,
- "UPDATE urls SET title=?, visit_count=?, typed_count=?, last_visit_time=?, hidden_from_overview=?,
thumbnail_update_time=? "
- "WHERE id=?", &error);
+ "UPDATE urls SET title=?, visit_count=?,
typed_count=?, last_visit_time=?, hidden_from_overview=?, thumbnail_update_time=? "
+ "WHERE id=?", &error);
if (error) {
g_warning ("Could not build urls table modification statement: %s", error->message);
g_error_free (error);
return;
}
- if (ephy_sqlite_statement_bind_string (statement, 0, url->title, &error) == FALSE ||
+ if (ephy_sqlite_statement_bind_string (statement, 0, url->title, &error) == FALSE ||
ephy_sqlite_statement_bind_int (statement, 1, url->visit_count, &error) == FALSE ||
ephy_sqlite_statement_bind_int (statement, 2, url->typed_count, &error) == FALSE ||
ephy_sqlite_statement_bind_int (statement, 3, url->last_visit_time, &error) == FALSE ||
@@ -228,18 +228,18 @@ ephy_history_service_find_url_rows (EphyHistoryService *self, EphyHistoryQuery *
GList *urls = NULL;
GError *error = NULL;
const char *base_statement = ""
- "SELECT "
- "DISTINCT urls.id, "
- "urls.url, "
- "urls.title, "
- "urls.visit_count, "
- "urls.typed_count, "
- "urls.last_visit_time, "
- "urls.hidden_from_overview, "
- "urls.thumbnail_update_time, "
- "urls.host "
- "FROM "
- "urls ";
+ "SELECT "
+ "DISTINCT urls.id, "
+ "urls.url, "
+ "urls.title, "
+ "urls.visit_count, "
+ "urls.typed_count, "
+ "urls.last_visit_time, "
+ "urls.hidden_from_overview, "
+ "urls.thumbnail_update_time, "
+ "urls.host "
+ "FROM "
+ "urls ";
int i = 0;
@@ -273,33 +273,33 @@ ephy_history_service_find_url_rows (EphyHistoryService *self, EphyHistoryQuery *
statement_str = g_string_append (statement_str, "1 ");
switch (query->sort_type) {
- case EPHY_HISTORY_SORT_MOST_VISITED:
- statement_str = g_string_append (statement_str, "ORDER BY urls.visit_count DESC ");
- break;
- case EPHY_HISTORY_SORT_LEAST_VISITED:
- statement_str = g_string_append (statement_str, "ORDER BY urls.visit_count ");
- break;
- case EPHY_HISTORY_SORT_MOST_RECENTLY_VISITED:
- statement_str = g_string_append (statement_str, "ORDER BY urls.last_visit_time DESC ");
- break;
- case EPHY_HISTORY_SORT_LEAST_RECENTLY_VISITED:
- statement_str = g_string_append (statement_str, "ORDER BY urls.last_visit_time ");
- break;
- case EPHY_HISTORY_SORT_TITLE_ASCENDING:
- statement_str = g_string_append (statement_str, "ORDER BY LOWER(urls.title) ");
- break;
- case EPHY_HISTORY_SORT_TITLE_DESCENDING:
- statement_str = g_string_append (statement_str, "ORDER BY LOWER(urls.title) DESC ");
- break;
- case EPHY_HISTORY_SORT_URL_ASCENDING:
- statement_str = g_string_append (statement_str, "ORDER BY LOWER(urls.url) ");
- break;
- case EPHY_HISTORY_SORT_URL_DESCENDING:
- statement_str = g_string_append (statement_str, "ORDER BY LOWER(urls.url) DESC ");
- break;
- case EPHY_HISTORY_SORT_NONE:
- default:
- g_warning ("We don't support this sorting method yet.");
+ case EPHY_HISTORY_SORT_MOST_VISITED:
+ statement_str = g_string_append (statement_str, "ORDER BY urls.visit_count DESC ");
+ break;
+ case EPHY_HISTORY_SORT_LEAST_VISITED:
+ statement_str = g_string_append (statement_str, "ORDER BY urls.visit_count ");
+ break;
+ case EPHY_HISTORY_SORT_MOST_RECENTLY_VISITED:
+ statement_str = g_string_append (statement_str, "ORDER BY urls.last_visit_time DESC ");
+ break;
+ case EPHY_HISTORY_SORT_LEAST_RECENTLY_VISITED:
+ statement_str = g_string_append (statement_str, "ORDER BY urls.last_visit_time ");
+ break;
+ case EPHY_HISTORY_SORT_TITLE_ASCENDING:
+ statement_str = g_string_append (statement_str, "ORDER BY LOWER(urls.title) ");
+ break;
+ case EPHY_HISTORY_SORT_TITLE_DESCENDING:
+ statement_str = g_string_append (statement_str, "ORDER BY LOWER(urls.title) DESC ");
+ break;
+ case EPHY_HISTORY_SORT_URL_ASCENDING:
+ statement_str = g_string_append (statement_str, "ORDER BY LOWER(urls.url) ");
+ break;
+ case EPHY_HISTORY_SORT_URL_DESCENDING:
+ statement_str = g_string_append (statement_str, "ORDER BY LOWER(urls.url) DESC ");
+ break;
+ case EPHY_HISTORY_SORT_NONE:
+ default:
+ g_warning ("We don't support this sorting method yet.");
}
if (query->limit) {
@@ -307,7 +307,7 @@ ephy_history_service_find_url_rows (EphyHistoryService *self, EphyHistoryQuery *
}
statement = ephy_sqlite_connection_create_statement (self->history_database,
- statement_str->str, &error);
+ statement_str->str, &error);
g_string_free (statement_str, TRUE);
if (error) {
diff --git a/lib/history/ephy-history-service-visits-table.c b/lib/history/ephy-history-service-visits-table.c
index 5438ffc..75c052b 100644
--- a/lib/history/ephy-history-service-visits-table.c
+++ b/lib/history/ephy-history-service-visits-table.c
@@ -29,12 +29,12 @@ ephy_history_service_initialize_visits_table (EphyHistoryService *self)
return TRUE;
ephy_sqlite_connection_execute (self->history_database,
- "CREATE TABLE visits ("
- "id INTEGER PRIMARY KEY,"
- "url INTEGER NOT NULL REFERENCES urls(id) ON DELETE CASCADE,"
- "visit_time INTEGER NOT NULL,"
- "visit_type INTEGER NOT NULL,"
- "referring_visit INTEGER)", &error);
+ "CREATE TABLE visits ("
+ "id INTEGER PRIMARY KEY,"
+ "url INTEGER NOT NULL REFERENCES urls(id) ON DELETE CASCADE,"
+ "visit_time INTEGER NOT NULL,"
+ "visit_type INTEGER NOT NULL,"
+ "referring_visit INTEGER)", &error);
if (error) {
g_warning ("Could not create visits table: %s", error->message);
@@ -66,7 +66,7 @@ ephy_history_service_add_visit_row (EphyHistoryService *self, EphyHistoryPageVis
if (ephy_sqlite_statement_bind_int (statement, 0, visit->url->id, &error) == FALSE ||
ephy_sqlite_statement_bind_int (statement, 1, visit->visit_time, &error) == FALSE ||
- ephy_sqlite_statement_bind_int (statement, 2, visit->visit_type, &error) == FALSE ) {
+ ephy_sqlite_statement_bind_int (statement, 2, visit->visit_type, &error) == FALSE) {
g_warning ("Could not build visits table addition statement: %s", error->message);
g_error_free (error);
g_object_unref (statement);
@@ -88,7 +88,7 @@ ephy_history_service_add_visit_row (EphyHistoryService *self, EphyHistoryPageVis
static EphyHistoryPageVisit *
create_page_visit_from_statement (EphySQLiteStatement *statement)
{
- EphyHistoryPageVisit *visit =
+ EphyHistoryPageVisit *visit =
ephy_history_page_visit_new (NULL,
ephy_sqlite_statement_get_column_as_int (statement, 1),
ephy_sqlite_statement_get_column_as_int (statement, 2));
@@ -105,16 +105,16 @@ ephy_history_service_find_visit_rows (EphyHistoryService *self, EphyHistoryQuery
GList *visits = NULL;
GError *error = NULL;
const char *base_statement = ""
- "SELECT "
- "visits.url, "
- "visits.visit_time, "
- "visits.visit_type ";
+ "SELECT "
+ "visits.url, "
+ "visits.visit_time, "
+ "visits.visit_type ";
const char *from_join_statement = ""
- "FROM "
- "visits JOIN urls ON visits.url = urls.id ";
+ "FROM "
+ "visits JOIN urls ON visits.url = urls.id ";
const char *from_visits_statement = ""
- "FROM "
- "visits ";
+ "FROM "
+ "visits ";
int i = 0;
@@ -145,7 +145,7 @@ ephy_history_service_find_visit_rows (EphyHistoryService *self, EphyHistoryQuery
statement_str = g_string_append (statement_str, "1");
statement = ephy_sqlite_connection_create_statement (self->history_database,
- statement_str->str, &error);
+ statement_str->str, &error);
g_string_free (statement_str, TRUE);
if (error) {
diff --git a/lib/history/ephy-history-service.c b/lib/history/ephy-history-service.c
index ea72a66..276f264 100644
--- a/lib/history/ephy-history-service.c
+++ b/lib/history/ephy-history-service.c
@@ -71,10 +71,10 @@ typedef struct _EphyHistoryServiceMessage {
EphyHistoryJobCallback callback;
} EphyHistoryServiceMessage;
-static gpointer run_history_service_thread (EphyHistoryService *self);
-static void ephy_history_service_process_message (EphyHistoryService *self, EphyHistoryServiceMessage
*message);
+static gpointer run_history_service_thread (EphyHistoryService *self);
+static void ephy_history_service_process_message (EphyHistoryService *self, EphyHistoryServiceMessage
*message);
static gboolean ephy_history_service_execute_quit (EphyHistoryService *self, gpointer data, gpointer
*result);
-static void ephy_history_service_quit (EphyHistoryService *self, EphyHistoryJobCallback
callback, gpointer user_data);
+static void ephy_history_service_quit (EphyHistoryService *self, EphyHistoryJobCallback callback, gpointer
user_data);
enum {
PROP_0,
@@ -173,7 +173,7 @@ ephy_history_service_class_init (EphyHistoryServiceClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = ephy_history_service_finalize;
- gobject_class->dispose = ephy_history_service_dispose;
+ gobject_class->dispose = ephy_history_service_dispose;
gobject_class->get_property = ephy_history_service_get_property;
gobject_class->set_property = ephy_history_service_set_property;
@@ -261,13 +261,13 @@ ephy_history_service_class_init (EphyHistoryServiceClass *klass)
static void
ephy_history_service_init (EphyHistoryService *self)
{
- self->history_thread = g_thread_new ("EphyHistoryService", (GThreadFunc) run_history_service_thread, self);
+ self->history_thread = g_thread_new ("EphyHistoryService", (GThreadFunc)run_history_service_thread, self);
self->queue = g_async_queue_new ();
}
EphyHistoryService *
ephy_history_service_new (const char *history_filename,
- gboolean read_only)
+ gboolean read_only)
{
return EPHY_HISTORY_SERVICE (g_object_new (EPHY_TYPE_HISTORY_SERVICE,
"history-filename", history_filename,
@@ -276,19 +276,19 @@ ephy_history_service_new (const char *history_filename,
}
static gint
-sort_messages (EphyHistoryServiceMessage* a, EphyHistoryServiceMessage* b, gpointer user_data)
+sort_messages (EphyHistoryServiceMessage *a, EphyHistoryServiceMessage *b, gpointer user_data)
{
return a->type > b->type ? 1 : a->type == b->type ? 0 : -1;
}
static EphyHistoryServiceMessage *
-ephy_history_service_message_new (EphyHistoryService *service,
+ephy_history_service_message_new (EphyHistoryService *service,
EphyHistoryServiceMessageType type,
- gpointer method_argument,
- GDestroyNotify method_argument_cleanup,
- GCancellable *cancellable,
- EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer method_argument,
+ GDestroyNotify method_argument_cleanup,
+ GCancellable *cancellable,
+ EphyHistoryJobCallback callback,
+ gpointer user_data)
{
EphyHistoryServiceMessage *message = g_slice_alloc0 (sizeof (EphyHistoryServiceMessage));
@@ -426,7 +426,7 @@ ephy_history_service_clear_all (EphyHistoryService *self)
"DELETE FROM hosts;", &error);
if (error) {
g_warning ("Couldn't clear history database: %s", error->message);
- g_error_free(error);
+ g_error_free (error);
}
}
@@ -487,7 +487,6 @@ run_history_service_thread (EphyHistoryService *self)
/* Process item. */
ephy_history_service_process_message (self, message);
-
} while (!ephy_history_service_is_scheduled_to_quit (self));
ephy_history_service_close_database_connections (self);
@@ -498,7 +497,7 @@ run_history_service_thread (EphyHistoryService *self)
static gboolean
ephy_history_service_execute_job_callback (gpointer data)
{
- EphyHistoryServiceMessage *message = (EphyHistoryServiceMessage*) data;
+ EphyHistoryServiceMessage *message = (EphyHistoryServiceMessage *)data;
g_assert (message->callback || message->type == CLEAR);
@@ -535,8 +534,8 @@ signal_emission_context_free (SignalEmissionContext *ctx)
static SignalEmissionContext *
signal_emission_context_new (EphyHistoryService *service,
- gpointer user_data,
- GDestroyNotify destroy_func)
+ gpointer user_data,
+ GDestroyNotify destroy_func)
{
SignalEmissionContext *ctx = g_slice_new0 (SignalEmissionContext);
@@ -576,7 +575,6 @@ ephy_history_service_execute_add_visit_helper (EphyHistoryService *self, EphyHis
g_warning ("Adding visit failed after failed URL addition.");
return FALSE;
}
-
} else {
visit->url->visit_count++;
@@ -613,7 +611,7 @@ ephy_history_service_execute_add_visits (EphyHistoryService *self, GList *visits
return FALSE;
while (visits) {
- success = success && ephy_history_service_execute_add_visit_helper (self, (EphyHistoryPageVisit *)
visits->data);
+ success = success && ephy_history_service_execute_add_visit_helper (self, (EphyHistoryPageVisit
*)visits->data);
visits = visits->next;
}
@@ -630,7 +628,7 @@ ephy_history_service_execute_find_visits (EphyHistoryService *self, EphyHistoryQ
/* FIXME: We don't have a good way to tell the difference between failures and empty returns */
while (current) {
- EphyHistoryPageVisit *visit = (EphyHistoryPageVisit *) current->data;
+ EphyHistoryPageVisit *visit = (EphyHistoryPageVisit *)current->data;
if (NULL == ephy_history_service_get_url_row (self, NULL, visit->url)) {
ephy_history_page_visit_list_free (visits);
g_warning ("Tried to process an orphaned page visit");
@@ -678,7 +676,7 @@ ephy_history_service_add_visit (EphyHistoryService *self, EphyHistoryPageVisit *
message = ephy_history_service_message_new (self, ADD_VISIT,
ephy_history_page_visit_copy (visit),
- (GDestroyNotify) ephy_history_page_visit_free,
+ (GDestroyNotify)ephy_history_page_visit_free,
cancellable, callback, user_data);
ephy_history_service_send_message (self, message);
}
@@ -693,7 +691,7 @@ ephy_history_service_add_visits (EphyHistoryService *self, GList *visits, GCance
message = ephy_history_service_message_new (self, ADD_VISITS,
ephy_history_page_visit_list_copy (visits),
- (GDestroyNotify) ephy_history_page_visit_list_free,
+ (GDestroyNotify)ephy_history_page_visit_list_free,
cancellable, callback, user_data);
ephy_history_service_send_message (self, message);
}
@@ -722,7 +720,7 @@ ephy_history_service_query_visits (EphyHistoryService *self, EphyHistoryQuery *q
g_return_if_fail (query != NULL);
message = ephy_history_service_message_new (self, QUERY_VISITS,
- ephy_history_query_copy (query), (GDestroyNotify)
ephy_history_query_free, cancellable, callback, user_data);
+ ephy_history_query_copy (query),
(GDestroyNotify)ephy_history_query_free, cancellable, callback, user_data);
ephy_history_service_send_message (self, message);
}
@@ -745,16 +743,16 @@ ephy_history_service_query_urls (EphyHistoryService *self, EphyHistoryQuery *que
g_return_if_fail (query != NULL);
message = ephy_history_service_message_new (self, QUERY_URLS,
- ephy_history_query_copy (query), (GDestroyNotify)
ephy_history_query_free,
+ ephy_history_query_copy (query),
(GDestroyNotify)ephy_history_query_free,
cancellable, callback, user_data);
ephy_history_service_send_message (self, message);
}
void
-ephy_history_service_get_hosts (EphyHistoryService *self,
- GCancellable *cancellable,
+ephy_history_service_get_hosts (EphyHistoryService *self,
+ GCancellable *cancellable,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryServiceMessage *message;
@@ -767,11 +765,11 @@ ephy_history_service_get_hosts (EphyHistoryService *self,
}
void
-ephy_history_service_query_hosts (EphyHistoryService *self,
- EphyHistoryQuery *query,
- GCancellable *cancellable,
+ephy_history_service_query_hosts (EphyHistoryService *self,
+ EphyHistoryQuery *query,
+ GCancellable *cancellable,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryServiceMessage *message;
@@ -779,7 +777,7 @@ ephy_history_service_query_hosts (EphyHistoryService *self,
message = ephy_history_service_message_new (self, QUERY_HOSTS,
ephy_history_query_copy (query),
- (GDestroyNotify) ephy_history_query_free,
+ (GDestroyNotify)ephy_history_query_free,
cancellable, callback, user_data);
ephy_history_service_send_message (self, message);
}
@@ -796,8 +794,8 @@ set_url_title_signal_emit (SignalEmissionContext *ctx)
static gboolean
ephy_history_service_execute_set_url_title (EphyHistoryService *self,
- EphyHistoryURL *url,
- gpointer *result)
+ EphyHistoryURL *url,
+ gpointer *result)
{
char *title = g_strdup (url->title);
@@ -827,12 +825,12 @@ ephy_history_service_execute_set_url_title (EphyHistoryService *self,
}
void
-ephy_history_service_set_url_title (EphyHistoryService *self,
- const char *orig_url,
- const char *title,
- GCancellable *cancellable,
+ephy_history_service_set_url_title (EphyHistoryService *self,
+ const char *orig_url,
+ const char *title,
+ GCancellable *cancellable,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryURL *url;
EphyHistoryServiceMessage *message;
@@ -844,15 +842,15 @@ ephy_history_service_set_url_title (EphyHistoryService *self,
url = ephy_history_url_new (orig_url, title, 0, 0, 0);
message = ephy_history_service_message_new (self, SET_URL_TITLE,
- url, (GDestroyNotify) ephy_history_url_free,
+ url, (GDestroyNotify)ephy_history_url_free,
cancellable, callback, user_data);
ephy_history_service_send_message (self, message);
}
static gboolean
ephy_history_service_execute_set_url_zoom_level (EphyHistoryService *self,
- GVariant *variant,
- gpointer *result)
+ GVariant *variant,
+ gpointer *result)
{
char *url_string;
double zoom_level;
@@ -876,12 +874,12 @@ ephy_history_service_execute_set_url_zoom_level (EphyHistoryService *self,
}
void
-ephy_history_service_set_url_zoom_level (EphyHistoryService *self,
- const char *url,
- const double zoom_level,
- GCancellable *cancellable,
+ephy_history_service_set_url_zoom_level (EphyHistoryService *self,
+ const char *url,
+ const double zoom_level,
+ GCancellable *cancellable,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryServiceMessage *message;
GVariant *variant;
@@ -899,8 +897,8 @@ ephy_history_service_set_url_zoom_level (EphyHistoryService *self,
static gboolean
ephy_history_service_execute_set_url_hidden (EphyHistoryService *self,
- EphyHistoryURL *url,
- gpointer *result)
+ EphyHistoryURL *url,
+ gpointer *result)
{
gboolean hidden;
@@ -921,12 +919,12 @@ ephy_history_service_execute_set_url_hidden (EphyHistoryService *self,
}
void
-ephy_history_service_set_url_hidden (EphyHistoryService *self,
- const char *orig_url,
- gboolean hidden,
- GCancellable *cancellable,
+ephy_history_service_set_url_hidden (EphyHistoryService *self,
+ const char *orig_url,
+ gboolean hidden,
+ GCancellable *cancellable,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryServiceMessage *message;
EphyHistoryURL *url;
@@ -945,8 +943,8 @@ ephy_history_service_set_url_hidden (EphyHistoryService *self,
static gboolean
ephy_history_service_execute_set_url_thumbnail_time (EphyHistoryService *self,
- EphyHistoryURL *url,
- gpointer *result)
+ EphyHistoryURL *url,
+ gpointer *result)
{
int thumbnail_time;
@@ -966,12 +964,12 @@ ephy_history_service_execute_set_url_thumbnail_time (EphyHistoryService *self,
}
void
-ephy_history_service_set_url_thumbnail_time (EphyHistoryService *self,
- const char *orig_url,
- int thumbnail_time,
- GCancellable *cancellable,
+ephy_history_service_set_url_thumbnail_time (EphyHistoryService *self,
+ const char *orig_url,
+ int thumbnail_time,
+ GCancellable *cancellable,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryURL *url;
EphyHistoryServiceMessage *message;
@@ -982,15 +980,15 @@ ephy_history_service_set_url_thumbnail_time (EphyHistoryService *self,
url = ephy_history_url_new (orig_url, NULL, 0, 0, 0);
url->thumbnail_time = thumbnail_time;
message = ephy_history_service_message_new (self, SET_URL_THUMBNAIL_TIME,
- url, (GDestroyNotify) ephy_history_url_free,
+ url, (GDestroyNotify)ephy_history_url_free,
cancellable, callback, user_data);
ephy_history_service_send_message (self, message);
}
static gboolean
ephy_history_service_execute_get_url (EphyHistoryService *self,
- const gchar *orig_url,
- gpointer *result)
+ const gchar *orig_url,
+ gpointer *result)
{
EphyHistoryURL *url;
@@ -1002,27 +1000,27 @@ ephy_history_service_execute_get_url (EphyHistoryService *self,
}
void
-ephy_history_service_get_url (EphyHistoryService *self,
- const char *url,
- GCancellable *cancellable,
+ephy_history_service_get_url (EphyHistoryService *self,
+ const char *url,
+ GCancellable *cancellable,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryServiceMessage *message;
g_return_if_fail (EPHY_IS_HISTORY_SERVICE (self));
g_return_if_fail (url != NULL);
- message = ephy_history_service_message_new (self, GET_URL,
- g_strdup (url), g_free,
- cancellable, callback, user_data);
+ message = ephy_history_service_message_new (self, GET_URL,
+ g_strdup (url), g_free,
+ cancellable, callback, user_data);
ephy_history_service_send_message (self, message);
}
static gboolean
ephy_history_service_execute_get_host_for_url (EphyHistoryService *self,
- const gchar *url,
- gpointer *result)
+ const gchar *url,
+ gpointer *result)
{
EphyHistoryHost *host;
@@ -1035,11 +1033,11 @@ ephy_history_service_execute_get_host_for_url (EphyHistoryService *self,
}
void
-ephy_history_service_get_host_for_url (EphyHistoryService *self,
- const char *url,
- GCancellable *cancellable,
+ephy_history_service_get_host_for_url (EphyHistoryService *self,
+ const char *url,
+ GCancellable *cancellable,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryServiceMessage *message;
@@ -1064,8 +1062,8 @@ delete_urls_signal_emit (SignalEmissionContext *ctx)
static gboolean
ephy_history_service_execute_delete_urls (EphyHistoryService *self,
- GList *urls,
- gpointer *result)
+ GList *urls,
+ gpointer *result)
{
GList *l;
EphyHistoryURL *url;
@@ -1079,7 +1077,7 @@ ephy_history_service_execute_delete_urls (EphyHistoryService *self,
ephy_history_service_delete_url (self, url);
ctx = signal_emission_context_new (self, g_strdup (url->url),
- (GDestroyNotify) g_free);
+ (GDestroyNotify)g_free);
g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
(GSourceFunc)delete_urls_signal_emit,
ctx,
@@ -1103,10 +1101,10 @@ delete_host_signal_emit (SignalEmissionContext *ctx)
}
static gboolean
-ephy_history_service_execute_delete_host (EphyHistoryService *self,
- EphyHistoryHost *host,
+ephy_history_service_execute_delete_host (EphyHistoryService *self,
+ EphyHistoryHost *host,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
SignalEmissionContext *ctx;
@@ -1119,17 +1117,17 @@ ephy_history_service_execute_delete_host (EphyHistoryService *self,
ctx = signal_emission_context_new (self, g_strdup (host->url),
(GDestroyNotify)g_free);
g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
- (GSourceFunc) delete_host_signal_emit,
+ (GSourceFunc)delete_host_signal_emit,
ctx,
- (GDestroyNotify) signal_emission_context_free);
+ (GDestroyNotify)signal_emission_context_free);
return TRUE;
}
static gboolean
ephy_history_service_execute_clear (EphyHistoryService *self,
- gpointer pointer,
- gpointer *result)
+ gpointer pointer,
+ gpointer *result)
{
if (self->read_only)
return FALSE;
@@ -1141,11 +1139,11 @@ ephy_history_service_execute_clear (EphyHistoryService *self,
}
void
-ephy_history_service_delete_urls (EphyHistoryService *self,
- GList *urls,
- GCancellable *cancellable,
+ephy_history_service_delete_urls (EphyHistoryService *self,
+ GList *urls,
+ GCancellable *cancellable,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryServiceMessage *message;
@@ -1159,11 +1157,11 @@ ephy_history_service_delete_urls (EphyHistoryService *self,
}
void
-ephy_history_service_delete_host (EphyHistoryService *self,
- EphyHistoryHost *host,
- GCancellable *cancellable,
+ephy_history_service_delete_host (EphyHistoryService *self,
+ EphyHistoryHost *host,
+ GCancellable *cancellable,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryServiceMessage *message =
ephy_history_service_message_new (self, DELETE_HOST,
@@ -1173,10 +1171,10 @@ ephy_history_service_delete_host (EphyHistoryService *self,
}
void
-ephy_history_service_clear (EphyHistoryService *self,
- GCancellable *cancellable,
+ephy_history_service_clear (EphyHistoryService *self,
+ GCancellable *cancellable,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryServiceMessage *message;
@@ -1189,9 +1187,9 @@ ephy_history_service_clear (EphyHistoryService *self,
}
static void
-ephy_history_service_quit (EphyHistoryService *self,
+ephy_history_service_quit (EphyHistoryService *self,
EphyHistoryJobCallback callback,
- gpointer user_data)
+ gpointer user_data)
{
EphyHistoryServiceMessage *message =
ephy_history_service_message_new (self, QUIT,
@@ -1226,7 +1224,7 @@ ephy_history_service_message_is_write (EphyHistoryServiceMessage *message)
}
static void
-ephy_history_service_process_message (EphyHistoryService *self,
+ephy_history_service_process_message (EphyHistoryService *self,
EphyHistoryServiceMessage *message)
{
EphyHistoryServiceMethod method;
@@ -1287,8 +1285,8 @@ ephy_history_service_find_urls (EphyHistoryService *self,
}
void
-ephy_history_service_visit_url (EphyHistoryService *self,
- const char *url,
+ephy_history_service_visit_url (EphyHistoryService *self,
+ const char *url,
EphyHistoryPageVisitType visit_type)
{
EphyHistoryPageVisit *visit;
diff --git a/lib/history/ephy-history-types.c b/lib/history/ephy-history-types.c
index af7821c..693052c 100644
--- a/lib/history/ephy-history-types.c
+++ b/lib/history/ephy-history-types.c
@@ -64,7 +64,7 @@ ephy_history_page_visit_list_copy (GList *original)
GList *new = g_list_copy (original);
GList *current = new;
while (current) {
- current->data = ephy_history_page_visit_copy ((EphyHistoryPageVisit *) current->data);
+ current->data = ephy_history_page_visit_copy ((EphyHistoryPageVisit *)current->data);
current = current->next;
}
return new;
@@ -73,7 +73,7 @@ ephy_history_page_visit_list_copy (GList *original)
void
ephy_history_page_visit_list_free (GList *list)
{
- g_list_free_full (list, (GDestroyNotify) ephy_history_page_visit_free);
+ g_list_free_full (list, (GDestroyNotify)ephy_history_page_visit_free);
}
EphyHistoryHost *
@@ -187,13 +187,13 @@ ephy_history_url_list_copy (GList *original)
void
ephy_history_url_list_free (GList *list)
{
- g_list_free_full (list, (GDestroyNotify) ephy_history_url_free);
+ g_list_free_full (list, (GDestroyNotify)ephy_history_url_free);
}
EphyHistoryQuery *
ephy_history_query_new (void)
{
- return (EphyHistoryQuery*) g_slice_alloc0 (sizeof (EphyHistoryQuery));
+ return (EphyHistoryQuery *)g_slice_alloc0 (sizeof (EphyHistoryQuery));
}
void
diff --git a/lib/widgets/ephy-certificate-dialog.c b/lib/widgets/ephy-certificate-dialog.c
index 5e038b8..ab21ae1 100644
--- a/lib/widgets/ephy-certificate-dialog.c
+++ b/lib/widgets/ephy-certificate-dialog.c
@@ -32,8 +32,7 @@
* #EphyCertificateDialog shows information about SSL certificates.
*/
-enum
-{
+enum {
PROP_0,
PROP_ADDRESS,
PROP_CERTIFICATE,
@@ -44,8 +43,7 @@ enum
static GParamSpec *obj_properties[LAST_PROP];
-struct _EphyCertificateDialog
-{
+struct _EphyCertificateDialog {
GtkDialog parent_object;
GtkWidget *icon;
@@ -60,7 +58,7 @@ G_DEFINE_TYPE (EphyCertificateDialog, ephy_certificate_dialog, GTK_TYPE_DIALOG)
static void
ephy_certificate_dialog_set_address (EphyCertificateDialog *dialog,
- const char *address)
+ const char *address)
{
SoupURI *uri;
@@ -71,7 +69,7 @@ ephy_certificate_dialog_set_address (EphyCertificateDialog *dialog,
static void
ephy_certificate_dialog_set_certificate (EphyCertificateDialog *dialog,
- GTlsCertificate *certificate)
+ GTlsCertificate *certificate)
{
GcrCertificate *simple_certificate;
GByteArray *certificate_data;
@@ -80,7 +78,7 @@ ephy_certificate_dialog_set_certificate (EphyCertificateDialog *dialog,
g_object_get (certificate, "certificate", &certificate_data, NULL);
simple_certificate = gcr_simple_certificate_new ((const guchar *)certificate_data->data,
- certificate_data->len);
+ certificate_data->len);
g_byte_array_unref (certificate_data);
certificate_widget = GTK_WIDGET (gcr_certificate_widget_new (simple_certificate));
@@ -126,9 +124,9 @@ get_error_messages_from_tls_errors (GTlsCertificateFlags tls_errors)
for (i = 0; i < errors->len; i++) {
g_string_append_printf (message, "• %s",
- (char *)g_ptr_array_index (errors, i));
+ (char *)g_ptr_array_index (errors, i));
if (i < errors->len - 1)
- g_string_append_c (message, '\n');
+ g_string_append_c (message, '\n');
}
retval = g_string_free (message, FALSE);
@@ -157,9 +155,9 @@ ephy_certificate_dialog_constructed (GObject *object)
}
markup = g_strdup_printf ("<span weight=\"bold\" size=\"large\">%s</span>",
- dialog->tls_errors == 0 ?
- _("The identity of this website has been verified.") :
- _("The identity of this website has not been verified."));
+ dialog->tls_errors == 0 ?
+ _("The identity of this website has been verified.") :
+ _("The identity of this website has not been verified."));
gtk_label_set_markup (GTK_LABEL (dialog->title), markup);
g_free (markup);
@@ -169,48 +167,48 @@ ephy_certificate_dialog_constructed (GObject *object)
g_free (text);
} else {
switch (dialog->security_level) {
- case EPHY_SECURITY_LEVEL_STRONG_SECURITY:
- /* Message on certificte dialog ertificate dialog */
- gtk_label_set_text (GTK_LABEL (dialog->text), _("No problems have been detected with your
connection."));
- break;
- case EPHY_SECURITY_LEVEL_MIXED_CONTENT:
- gtk_label_set_text (GTK_LABEL (dialog->text), _("This certificate is valid. However, "
- "resources on this page were sent insecurely."));
- break;
- case EPHY_SECURITY_LEVEL_TO_BE_DETERMINED:
- case EPHY_SECURITY_LEVEL_NO_SECURITY:
- case EPHY_SECURITY_LEVEL_UNACCEPTABLE_CERTIFICATE:
- case EPHY_SECURITY_LEVEL_LOCAL_PAGE:
- default:
- g_assert_not_reached ();
+ case EPHY_SECURITY_LEVEL_STRONG_SECURITY:
+ /* Message on certificte dialog ertificate dialog */
+ gtk_label_set_text (GTK_LABEL (dialog->text), _("No problems have been detected with your
connection."));
+ break;
+ case EPHY_SECURITY_LEVEL_MIXED_CONTENT:
+ gtk_label_set_text (GTK_LABEL (dialog->text), _("This certificate is valid. However, "
+ "resources on this page were sent insecurely."));
+ break;
+ case EPHY_SECURITY_LEVEL_TO_BE_DETERMINED:
+ case EPHY_SECURITY_LEVEL_NO_SECURITY:
+ case EPHY_SECURITY_LEVEL_UNACCEPTABLE_CERTIFICATE:
+ case EPHY_SECURITY_LEVEL_LOCAL_PAGE:
+ default:
+ g_assert_not_reached ();
}
}
gtk_widget_show (dialog->text);
}
static void
-ephy_certificate_dialog_set_property (GObject *object,
- guint prop_id,
+ephy_certificate_dialog_set_property (GObject *object,
+ guint prop_id,
const GValue *value,
- GParamSpec *pspec)
+ GParamSpec *pspec)
{
EphyCertificateDialog *dialog = EPHY_CERTIFICATE_DIALOG (object);
switch (prop_id) {
- case PROP_ADDRESS:
- ephy_certificate_dialog_set_address (dialog, g_value_get_string (value));
- break;
- case PROP_CERTIFICATE:
- ephy_certificate_dialog_set_certificate (dialog, g_value_get_object (value));
- break;
- case PROP_SECURITY_LEVEL:
- dialog->security_level = g_value_get_enum (value);
- break;
- case PROP_TLS_ERRORS:
- dialog->tls_errors = g_value_get_flags (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ case PROP_ADDRESS:
+ ephy_certificate_dialog_set_address (dialog, g_value_get_string (value));
+ break;
+ case PROP_CERTIFICATE:
+ ephy_certificate_dialog_set_certificate (dialog, g_value_get_object (value));
+ break;
+ case PROP_SECURITY_LEVEL:
+ dialog->security_level = g_value_get_enum (value);
+ break;
+ case PROP_TLS_ERRORS:
+ dialog->tls_errors = g_value_get_flags (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
@@ -299,7 +297,7 @@ ephy_certificate_dialog_init (EphyCertificateDialog *dialog)
dialog->title = gtk_label_new (NULL);
gtk_label_set_use_markup (GTK_LABEL (dialog->title), TRUE);
- gtk_label_set_line_wrap (GTK_LABEL (dialog->title), TRUE);
+ gtk_label_set_line_wrap (GTK_LABEL (dialog->title), TRUE);
gtk_label_set_selectable (GTK_LABEL (dialog->title), TRUE);
gtk_widget_set_halign (dialog->title, GTK_ALIGN_START);
gtk_widget_set_valign (dialog->title, GTK_ALIGN_CENTER);
@@ -310,7 +308,7 @@ ephy_certificate_dialog_init (EphyCertificateDialog *dialog)
gtk_widget_show (dialog->title);
dialog->text = gtk_label_new (NULL);
- gtk_label_set_line_wrap (GTK_LABEL (dialog->text), TRUE);
+ gtk_label_set_line_wrap (GTK_LABEL (dialog->text), TRUE);
gtk_label_set_selectable (GTK_LABEL (dialog->text), TRUE);
gtk_widget_set_halign (dialog->text, GTK_ALIGN_START);
gtk_widget_set_valign (dialog->text, GTK_ALIGN_START);
@@ -326,11 +324,11 @@ ephy_certificate_dialog_init (EphyCertificateDialog *dialog)
}
GtkWidget *
-ephy_certificate_dialog_new (GtkWindow *parent,
- const char *address,
- GTlsCertificate *certificate,
+ephy_certificate_dialog_new (GtkWindow *parent,
+ const char *address,
+ GTlsCertificate *certificate,
GTlsCertificateFlags tls_errors,
- EphySecurityLevel security_level)
+ EphySecurityLevel security_level)
{
GtkWidget *dialog;
@@ -338,13 +336,13 @@ ephy_certificate_dialog_new (GtkWindow *parent,
g_return_val_if_fail (G_IS_TLS_CERTIFICATE (certificate), NULL);
dialog = GTK_WIDGET (g_object_new (EPHY_TYPE_CERTIFICATE_DIALOG,
- "address", address,
- "certificate", certificate,
- "security-level", security_level,
- "tls-errors", tls_errors,
+ "address", address,
+ "certificate", certificate,
+ "security-level", security_level,
+ "tls-errors", tls_errors,
"modal", TRUE,
"use-header-bar", TRUE,
- NULL));
+ NULL));
if (parent)
gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
diff --git a/lib/widgets/ephy-download-widget.c b/lib/widgets/ephy-download-widget.c
index ed11528..5ad18cd 100644
--- a/lib/widgets/ephy-download-widget.c
+++ b/lib/widgets/ephy-download-widget.c
@@ -31,8 +31,7 @@
#include <glib/gi18n.h>
#include <webkit2/webkit2.h>
-struct _EphyDownloadWidget
-{
+struct _EphyDownloadWidget {
GtkGrid parent_instance;
EphyDownload *download;
@@ -46,8 +45,7 @@ struct _EphyDownloadWidget
G_DEFINE_TYPE (EphyDownloadWidget, ephy_download_widget, GTK_TYPE_GRID)
-enum
-{
+enum {
PROP_0,
PROP_DOWNLOAD,
LAST_PROP
@@ -79,41 +77,30 @@ get_destination_basename_from_download (EphyDownload *ephy_download)
static gchar *
duration_to_string (guint seconds)
{
- if (seconds < 60)
- {
- return g_strdup_printf (ngettext ("%d second left",
- "%d seconds left", seconds), seconds);
- }
- else if (seconds < (60 * 60))
- {
- seconds /= 60;
- return g_strdup_printf (ngettext ("%d minute left",
- "%d minutes left", seconds), seconds);
- }
- else if (seconds < (60 * 60 * 24))
- {
- seconds /= 60 * 60;
- return g_strdup_printf (ngettext ("%d hour left",
- "%d hours left", seconds), seconds);
- }
- else if (seconds < (60 * 60 * 24 * 7))
- {
- seconds /= 60 * 60 * 24;
- return g_strdup_printf (ngettext ("%d day left",
- "%d days left", seconds), seconds);
- }
- else if (seconds < (60 * 60 * 24 * 30))
- {
- seconds /= 60 * 60 * 24 * 7;
- return g_strdup_printf (ngettext ("%d week left",
- "%d weeks left", seconds), seconds);
- }
- else
- {
- seconds /= 60 * 60 * 24 * 30;
- return g_strdup_printf (ngettext ("%d month left",
- "%d months left", seconds), seconds);
- }
+ if (seconds < 60) {
+ return g_strdup_printf (ngettext ("%d second left",
+ "%d seconds left", seconds), seconds);
+ } else if (seconds < (60 * 60)) {
+ seconds /= 60;
+ return g_strdup_printf (ngettext ("%d minute left",
+ "%d minutes left", seconds), seconds);
+ } else if (seconds < (60 * 60 * 24)) {
+ seconds /= 60 * 60;
+ return g_strdup_printf (ngettext ("%d hour left",
+ "%d hours left", seconds), seconds);
+ } else if (seconds < (60 * 60 * 24 * 7)) {
+ seconds /= 60 * 60 * 24;
+ return g_strdup_printf (ngettext ("%d day left",
+ "%d days left", seconds), seconds);
+ } else if (seconds < (60 * 60 * 24 * 30)) {
+ seconds /= 60 * 60 * 24 * 7;
+ return g_strdup_printf (ngettext ("%d week left",
+ "%d weeks left", seconds), seconds);
+ } else {
+ seconds /= 60 * 60 * 24 * 30;
+ return g_strdup_printf (ngettext ("%d month left",
+ "%d months left", seconds), seconds);
+ }
}
static gdouble
@@ -171,7 +158,7 @@ update_download_destination (EphyDownloadWidget *widget)
static void
update_status_label (EphyDownloadWidget *widget,
- const char *download_label)
+ const char *download_label)
{
char *markup;
@@ -181,8 +168,8 @@ update_status_label (EphyDownloadWidget *widget,
}
static void
-download_progress_cb (WebKitDownload *download,
- GParamSpec *pspec,
+download_progress_cb (WebKitDownload *download,
+ GParamSpec *pspec,
EphyDownloadWidget *widget)
{
gdouble progress;
@@ -200,24 +187,24 @@ download_progress_cb (WebKitDownload *download,
received_length = webkit_download_get_received_data_length (download);
if (content_length > 0 && received_length > 0) {
- gdouble time;
- char *remaining;
- char *received;
- char *total;
-
- received = g_format_size (received_length);
- total = g_format_size (content_length);
-
- time = get_remaining_time (content_length, received_length,
- webkit_download_get_elapsed_time (download));
- remaining = duration_to_string ((guint)time);
- download_label = g_strdup_printf ("%s / %s — %s", received, total, remaining);
- g_free (received);
- g_free (total);
- g_free (remaining);
-
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (widget->progress),
- progress);
+ gdouble time;
+ char *remaining;
+ char *received;
+ char *total;
+
+ received = g_format_size (received_length);
+ total = g_format_size (content_length);
+
+ time = get_remaining_time (content_length, received_length,
+ webkit_download_get_elapsed_time (download));
+ remaining = duration_to_string ((guint)time);
+ download_label = g_strdup_printf ("%s / %s — %s", received, total, remaining);
+ g_free (received);
+ g_free (total);
+ g_free (remaining);
+
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (widget->progress),
+ progress);
} else if (received_length > 0) {
download_label = g_format_size (received_length);
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (widget->progress));
@@ -230,7 +217,7 @@ download_progress_cb (WebKitDownload *download,
}
static void
-download_finished_cb (EphyDownload *download,
+download_finished_cb (EphyDownload *download,
EphyDownloadWidget *widget)
{
gtk_widget_hide (widget->progress);
@@ -241,8 +228,8 @@ download_finished_cb (EphyDownload *download,
}
static void
-download_failed_cb (EphyDownload *download,
- GError *error,
+download_failed_cb (EphyDownload *download,
+ GError *error,
EphyDownloadWidget *widget)
{
char *error_msg;
@@ -260,8 +247,8 @@ download_failed_cb (EphyDownload *download,
}
static void
-download_content_type_changed_cb (EphyDownload *download,
- GParamSpec *spec,
+download_content_type_changed_cb (EphyDownload *download,
+ GParamSpec *spec,
EphyDownloadWidget *widget)
{
update_download_icon (widget);
@@ -294,8 +281,8 @@ widget_action_button_clicked_cb (EphyDownloadWidget *widget)
}
static void
-download_destination_changed_cb (WebKitDownload *download,
- GParamSpec *pspec,
+download_destination_changed_cb (WebKitDownload *download,
+ GParamSpec *pspec,
EphyDownloadWidget *widget)
{
update_download_destination (widget);
@@ -402,7 +389,7 @@ ephy_download_widget_constructed (GObject *object)
gtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR (widget->progress), 0.05);
gtk_grid_attach (GTK_GRID (widget), widget->progress, 0, 1, 2, 1);
if (ephy_download_is_active (widget->download))
- gtk_widget_show (widget->progress);
+ gtk_widget_show (widget->progress);
widget->status = gtk_label_new (NULL);
gtk_widget_set_valign (widget->status, GTK_ALIGN_CENTER);
@@ -411,15 +398,15 @@ ephy_download_widget_constructed (GObject *object)
gtk_label_set_max_width_chars (GTK_LABEL (widget->status), 30);
gtk_label_set_ellipsize (GTK_LABEL (widget->status), PANGO_ELLIPSIZE_END);
if (ephy_download_failed (widget->download, &error)) {
- char *error_msg;
+ char *error_msg;
- error_msg = g_strdup_printf (_("Error downloading: %s"), error->message);
- update_status_label (widget, error_msg);
- g_free (error_msg);
+ error_msg = g_strdup_printf (_("Error downloading: %s"), error->message);
+ update_status_label (widget, error_msg);
+ g_free (error_msg);
} else if (ephy_download_succeeded (widget->download)) {
- update_status_label (widget, _("Finished"));
+ update_status_label (widget, _("Finished"));
} else {
- update_status_label (widget, _("Starting…"));
+ update_status_label (widget, _("Starting…"));
}
gtk_grid_attach (GTK_GRID (widget), widget->status, 0, 2, 2, 1);
gtk_widget_show (widget->status);
diff --git a/lib/widgets/ephy-downloads-popover.c b/lib/widgets/ephy-downloads-popover.c
index 65d1516..a0f1e4e 100644
--- a/lib/widgets/ephy-downloads-popover.c
+++ b/lib/widgets/ephy-downloads-popover.c
@@ -26,8 +26,7 @@
#include <glib/gi18n.h>
-struct _EphyDownloadsPopover
-{
+struct _EphyDownloadsPopover {
GtkPopover parent_instance;
GtkWidget *downloads_box;
diff --git a/lib/widgets/ephy-downloads-progress-icon.c b/lib/widgets/ephy-downloads-progress-icon.c
index 05c87c8..0957c51 100644
--- a/lib/widgets/ephy-downloads-progress-icon.c
+++ b/lib/widgets/ephy-downloads-progress-icon.c
@@ -23,8 +23,7 @@
#include "ephy-downloads-manager.h"
#include "ephy-embed-shell.h"
-struct _EphyDownloadsProgressIcon
-{
+struct _EphyDownloadsProgressIcon {
GtkDrawingArea parent_instance;
GtkWidget *downloads_box;
diff --git a/lib/widgets/ephy-file-chooser.c b/lib/widgets/ephy-file-chooser.c
index add1806..b34cc94 100644
--- a/lib/widgets/ephy-file-chooser.c
+++ b/lib/widgets/ephy-file-chooser.c
@@ -28,15 +28,14 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
-static void ephy_file_chooser_image_preview (GtkFileChooser *file_chooser,
- gpointer user_data);
+static void ephy_file_chooser_image_preview (GtkFileChooser *file_chooser,
+ gpointer user_data);
#define PREVIEW_WIDTH 150
#define PREVIEW_HEIGHT 150
-struct _EphyFileChooser
-{
- GtkFileChooserDialog parent_instance;
+struct _EphyFileChooser {
+ GtkFileChooserDialog parent_instance;
};
G_DEFINE_TYPE (EphyFileChooser, ephy_file_chooser, GTK_TYPE_FILE_CHOOSER_DIALOG)
@@ -47,215 +46,207 @@ ephy_file_chooser_init (EphyFileChooser *dialog)
}
static GObject *
-ephy_file_chooser_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_params)
+ephy_file_chooser_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_params)
{
- GObject *object;
- char *downloads_dir;
+ GObject *object;
+ char *downloads_dir;
- object = G_OBJECT_CLASS (ephy_file_chooser_parent_class)->constructor (type, n_construct_properties,
- construct_params);
+ object = G_OBJECT_CLASS (ephy_file_chooser_parent_class)->constructor (type, n_construct_properties,
+ construct_params);
- downloads_dir = ephy_file_get_downloads_dir ();
- gtk_file_chooser_add_shortcut_folder
- (GTK_FILE_CHOOSER (object), downloads_dir, NULL);
- g_free (downloads_dir);
+ downloads_dir = ephy_file_get_downloads_dir ();
+ gtk_file_chooser_add_shortcut_folder
+ (GTK_FILE_CHOOSER (object), downloads_dir, NULL);
+ g_free (downloads_dir);
- return object;
+ return object;
}
GtkFileFilter *
ephy_file_chooser_add_pattern_filter (EphyFileChooser *dialog,
- const char *title,
- const char *first_pattern,
- ...)
+ const char *title,
+ const char *first_pattern,
+ ...)
{
- GtkFileFilter *filth;
- va_list args;
- const char *pattern;
+ GtkFileFilter *filth;
+ va_list args;
+ const char *pattern;
- filth = gtk_file_filter_new ();
+ filth = gtk_file_filter_new ();
- va_start (args, first_pattern);
+ va_start (args, first_pattern);
- pattern = first_pattern;
- while (pattern != NULL)
- {
- gtk_file_filter_add_pattern (filth, pattern);
- pattern = va_arg (args, const char *);
- }
- va_end (args);
+ pattern = first_pattern;
+ while (pattern != NULL) {
+ gtk_file_filter_add_pattern (filth, pattern);
+ pattern = va_arg (args, const char *);
+ }
+ va_end (args);
- gtk_file_filter_set_name (filth, title);
+ gtk_file_filter_set_name (filth, title);
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filth);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filth);
- return filth;
+ return filth;
}
GtkFileFilter *
ephy_file_chooser_add_mime_filter (EphyFileChooser *dialog,
- const char *title,
- const char *first_mimetype,
- ...)
+ const char *title,
+ const char *first_mimetype,
+ ...)
{
- GtkFileFilter *filth;
- va_list args;
- const char *mimetype;
+ GtkFileFilter *filth;
+ va_list args;
+ const char *mimetype;
- filth = gtk_file_filter_new ();
+ filth = gtk_file_filter_new ();
- va_start (args, first_mimetype);
+ va_start (args, first_mimetype);
- mimetype = first_mimetype;
- while (mimetype != NULL)
- {
- gtk_file_filter_add_mime_type (filth, mimetype);
- mimetype = va_arg (args, const char *);
- }
- va_end (args);
+ mimetype = first_mimetype;
+ while (mimetype != NULL) {
+ gtk_file_filter_add_mime_type (filth, mimetype);
+ mimetype = va_arg (args, const char *);
+ }
+ va_end (args);
- gtk_file_filter_set_name (filth, title);
+ gtk_file_filter_set_name (filth, title);
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filth);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filth);
- return filth;
+ return filth;
}
static void
ephy_file_chooser_class_init (EphyFileChooserClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->constructor = ephy_file_chooser_constructor;
+ object_class->constructor = ephy_file_chooser_constructor;
}
static void
-ephy_file_chooser_image_preview (GtkFileChooser *file_chooser,
- gpointer user_data)
+ephy_file_chooser_image_preview (GtkFileChooser *file_chooser,
+ gpointer user_data)
{
- char *filename;
- GtkWidget *preview;
- GdkPixbuf *pixbuf;
- gboolean have_preview;
-
- pixbuf = NULL;
- preview = GTK_WIDGET (user_data);
- filename = gtk_file_chooser_get_preview_filename (file_chooser);
-
- if (filename)
- pixbuf = gdk_pixbuf_new_from_file_at_size (filename,
- PREVIEW_WIDTH, PREVIEW_HEIGHT, NULL);
- g_free (filename);
-
- have_preview = (pixbuf != NULL);
- gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf);
-
- if (pixbuf)
- g_object_unref (pixbuf);
-
- gtk_file_chooser_set_preview_widget_active (file_chooser, have_preview);
-
+ char *filename;
+ GtkWidget *preview;
+ GdkPixbuf *pixbuf;
+ gboolean have_preview;
+
+ pixbuf = NULL;
+ preview = GTK_WIDGET (user_data);
+ filename = gtk_file_chooser_get_preview_filename (file_chooser);
+
+ if (filename)
+ pixbuf = gdk_pixbuf_new_from_file_at_size (filename,
+ PREVIEW_WIDTH, PREVIEW_HEIGHT, NULL);
+ g_free (filename);
+
+ have_preview = (pixbuf != NULL);
+ gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf);
+
+ if (pixbuf)
+ g_object_unref (pixbuf);
+
+ gtk_file_chooser_set_preview_widget_active (file_chooser, have_preview);
}
-EphyFileChooser *
-ephy_file_chooser_new (const char *title,
- GtkWidget *parent,
- GtkFileChooserAction action,
- EphyFileFilterDefault default_filter)
+EphyFileChooser *
+ephy_file_chooser_new (const char *title,
+ GtkWidget *parent,
+ GtkFileChooserAction action,
+ EphyFileFilterDefault default_filter)
{
- EphyFileChooser *dialog;
- GtkFileFilter *filter[EPHY_FILE_FILTER_LAST];
- GtkWidget *preview;
-
- g_return_val_if_fail (default_filter >= 0 && default_filter <= EPHY_FILE_FILTER_LAST, NULL);
-
- dialog = EPHY_FILE_CHOOSER (g_object_new (EPHY_TYPE_FILE_CHOOSER,
- "title", title,
- "action", action,
- NULL));
-
- if (action == GTK_FILE_CHOOSER_ACTION_OPEN ||
- action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
- action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
- {
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- _("_Cancel"), GTK_RESPONSE_CANCEL,
- _("_Open"), GTK_RESPONSE_ACCEPT,
- NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog),
- GTK_RESPONSE_ACCEPT);
- }
- else if (action == GTK_FILE_CHOOSER_ACTION_SAVE)
- {
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- _("_Cancel"), GTK_RESPONSE_CANCEL,
- _("_Save"), GTK_RESPONSE_ACCEPT,
- NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog),
- GTK_RESPONSE_ACCEPT);
- }
-
- preview = gtk_image_new ();
- gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER (dialog), preview);
- gtk_file_chooser_set_preview_widget_active (GTK_FILE_CHOOSER (dialog), FALSE);
- g_signal_connect (dialog, "update-preview", G_CALLBACK (ephy_file_chooser_image_preview), preview);
-
- if (default_filter != EPHY_FILE_FILTER_NONE)
- {
- filter[EPHY_FILE_FILTER_ALL_SUPPORTED] =
- ephy_file_chooser_add_mime_filter
- (dialog,
- _("All supported types"),
- "text/html",
- "application/xhtml+xml",
- "text/xml",
- "message/rfc822", /* MHTML */
- "multipart/related", /* MHTML */
- "application/x-mimearchive", /* MHTML */
- "image/png",
- "image/jpeg",
- "image/gif",
- NULL);
-
- filter[EPHY_FILE_FILTER_WEBPAGES] =
- ephy_file_chooser_add_mime_filter
- (dialog, _("Web pages"),
- "text/html",
- "application/xhtml+xml",
- "text/xml",
- "message/rfc822", /* MHTML */
- "multipart/related", /* MHTML */
- "application/x-mimearchive", /* MHTML */
- NULL);
-
- filter[EPHY_FILE_FILTER_IMAGES] =
- ephy_file_chooser_add_mime_filter
- (dialog, _("Images"),
- "image/png",
- "image/jpeg",
- "image/gif",
- NULL);
-
- filter[EPHY_FILE_FILTER_ALL] =
- ephy_file_chooser_add_pattern_filter
- (dialog, _("All files"), "*", NULL);
-
- gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog),
- filter[default_filter]);
- }
-
- if (parent != NULL)
- {
- gtk_window_set_transient_for (GTK_WINDOW (dialog),
- GTK_WINDOW (parent));
- gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
- gtk_window_group_add_window (ephy_gui_ensure_window_group (GTK_WINDOW (parent)),
- GTK_WINDOW (dialog));
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
- }
-
- return dialog;
+ EphyFileChooser *dialog;
+ GtkFileFilter *filter[EPHY_FILE_FILTER_LAST];
+ GtkWidget *preview;
+
+ g_return_val_if_fail (default_filter >= 0 && default_filter <= EPHY_FILE_FILTER_LAST, NULL);
+
+ dialog = EPHY_FILE_CHOOSER (g_object_new (EPHY_TYPE_FILE_CHOOSER,
+ "title", title,
+ "action", action,
+ NULL));
+
+ if (action == GTK_FILE_CHOOSER_ACTION_OPEN ||
+ action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
+ action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER) {
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ _("_Cancel"), GTK_RESPONSE_CANCEL,
+ _("_Open"), GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog),
+ GTK_RESPONSE_ACCEPT);
+ } else if (action == GTK_FILE_CHOOSER_ACTION_SAVE) {
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ _("_Cancel"), GTK_RESPONSE_CANCEL,
+ _("_Save"), GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog),
+ GTK_RESPONSE_ACCEPT);
+ }
+
+ preview = gtk_image_new ();
+ gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER (dialog), preview);
+ gtk_file_chooser_set_preview_widget_active (GTK_FILE_CHOOSER (dialog), FALSE);
+ g_signal_connect (dialog, "update-preview", G_CALLBACK (ephy_file_chooser_image_preview), preview);
+
+ if (default_filter != EPHY_FILE_FILTER_NONE) {
+ filter[EPHY_FILE_FILTER_ALL_SUPPORTED] =
+ ephy_file_chooser_add_mime_filter
+ (dialog,
+ _("All supported types"),
+ "text/html",
+ "application/xhtml+xml",
+ "text/xml",
+ "message/rfc822", /* MHTML */
+ "multipart/related", /* MHTML */
+ "application/x-mimearchive", /* MHTML */
+ "image/png",
+ "image/jpeg",
+ "image/gif",
+ NULL);
+
+ filter[EPHY_FILE_FILTER_WEBPAGES] =
+ ephy_file_chooser_add_mime_filter
+ (dialog, _("Web pages"),
+ "text/html",
+ "application/xhtml+xml",
+ "text/xml",
+ "message/rfc822", /* MHTML */
+ "multipart/related", /* MHTML */
+ "application/x-mimearchive", /* MHTML */
+ NULL);
+
+ filter[EPHY_FILE_FILTER_IMAGES] =
+ ephy_file_chooser_add_mime_filter
+ (dialog, _("Images"),
+ "image/png",
+ "image/jpeg",
+ "image/gif",
+ NULL);
+
+ filter[EPHY_FILE_FILTER_ALL] =
+ ephy_file_chooser_add_pattern_filter
+ (dialog, _("All files"), "*", NULL);
+
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog),
+ filter[default_filter]);
+ }
+
+ if (parent != NULL) {
+ gtk_window_set_transient_for (GTK_WINDOW (dialog),
+ GTK_WINDOW (parent));
+ gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+ gtk_window_group_add_window (ephy_gui_ensure_window_group (GTK_WINDOW (parent)),
+ GTK_WINDOW (dialog));
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
+ }
+
+ return dialog;
}
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index ff77c0a..8ddeb15 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -50,1037 +50,1003 @@
* #EphyLocationEntry implements the location bar in the main Epiphany window.
*/
-struct _EphyLocationEntry
-{
- GtkEntry parent_instance;
+struct _EphyLocationEntry {
+ GtkEntry parent_instance;
- GdkPixbuf *favicon;
- GtkTreeModel *model;
+ GdkPixbuf *favicon;
+ GtkTreeModel *model;
- GSList *search_terms;
+ GSList *search_terms;
- char *before_completion;
- char *saved_text;
+ char *before_completion;
+ char *saved_text;
- guint text_col;
- guint action_col;
- guint keywords_col;
- guint relevance_col;
- guint url_col;
- guint extra_col;
- guint favicon_col;
+ guint text_col;
+ guint action_col;
+ guint keywords_col;
+ guint relevance_col;
+ guint url_col;
+ guint extra_col;
+ guint favicon_col;
- guint hash;
+ guint hash;
- gulong dns_prefetch_handler;
+ gulong dns_prefetch_handler;
- guint user_changed : 1;
- guint can_redo : 1;
- guint block_update : 1;
- guint original_address : 1;
- guint apply_colors : 1;
- guint needs_reset : 1;
- guint show_favicon : 1;
+ guint user_changed : 1;
+ guint can_redo : 1;
+ guint block_update : 1;
+ guint original_address : 1;
+ guint apply_colors : 1;
+ guint needs_reset : 1;
+ guint show_favicon : 1;
- GtkTargetList *drag_targets;
- GdkDragAction drag_actions;
+ GtkTargetList *drag_targets;
+ GdkDragAction drag_actions;
};
static const GtkTargetEntry url_drag_types [] =
{
- { (char *)EPHY_DND_URL_TYPE, 0, 0 },
- { (char *)EPHY_DND_URI_LIST_TYPE, 0, 1 },
- { (char *)EPHY_DND_TEXT_TYPE, 0, 2 }
+ { (char *)EPHY_DND_URL_TYPE, 0, 0 },
+ { (char *)EPHY_DND_URI_LIST_TYPE, 0, 1 },
+ { (char *)EPHY_DND_TEXT_TYPE, 0, 2 }
};
static gboolean ephy_location_entry_reset_internal (EphyLocationEntry *, gboolean);
-static void extracell_data_func (GtkCellLayout *cell_layout,
- GtkCellRenderer *cell,
- GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- gpointer data);
-
-enum
-{
- PROP_0,
- PROP_LOCATION,
- PROP_FAVICON,
- PROP_SECURITY_LEVEL,
- PROP_SHOW_FAVICON,
- LAST_PROP
+static void extracell_data_func (GtkCellLayout *cell_layout,
+ GtkCellRenderer *cell,
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ gpointer data);
+
+enum {
+ PROP_0,
+ PROP_LOCATION,
+ PROP_FAVICON,
+ PROP_SECURITY_LEVEL,
+ PROP_SHOW_FAVICON,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
-enum signalsEnum
-{
- USER_CHANGED,
- LOCK_CLICKED,
- GET_LOCATION,
- GET_TITLE,
- LAST_SIGNAL
+enum signalsEnum {
+ USER_CHANGED,
+ LOCK_CLICKED,
+ GET_LOCATION,
+ GET_TITLE,
+ LAST_SIGNAL
};
static gint signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (EphyLocationEntry, ephy_location_entry, GTK_TYPE_ENTRY)
static void
-ephy_location_entry_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ephy_location_entry_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (object);
-
- switch (prop_id)
- {
- case PROP_LOCATION:
- ephy_location_entry_set_location (entry,
- g_value_get_string (value));
- break;
- case PROP_FAVICON:
- ephy_location_entry_set_favicon (entry,
- g_value_get_object (value));
- break;
- case PROP_SECURITY_LEVEL:
- ephy_location_entry_set_security_level (entry,
- g_value_get_enum (value));
- break;
- case PROP_SHOW_FAVICON:
- ephy_location_entry_set_show_favicon (entry,
- g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id,pspec);
- }
+ EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (object);
+
+ switch (prop_id) {
+ case PROP_LOCATION:
+ ephy_location_entry_set_location (entry,
+ g_value_get_string (value));
+ break;
+ case PROP_FAVICON:
+ ephy_location_entry_set_favicon (entry,
+ g_value_get_object (value));
+ break;
+ case PROP_SECURITY_LEVEL:
+ ephy_location_entry_set_security_level (entry,
+ g_value_get_enum (value));
+ break;
+ case PROP_SHOW_FAVICON:
+ ephy_location_entry_set_show_favicon (entry,
+ g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
-ephy_location_entry_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ephy_location_entry_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (object);
-
- switch (prop_id)
- {
- case PROP_LOCATION:
- g_value_set_string (value, ephy_location_entry_get_location (entry));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id,pspec);
- }
+ EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (object);
+
+ switch (prop_id) {
+ case PROP_LOCATION:
+ g_value_set_string (value, ephy_location_entry_get_location (entry));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
ephy_location_entry_finalize (GObject *object)
{
- EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (object);
+ EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (object);
- g_free (entry->saved_text);
+ g_free (entry->saved_text);
- if (entry->drag_targets != NULL)
- {
- gtk_target_list_unref (entry->drag_targets);
- }
+ if (entry->drag_targets != NULL) {
+ gtk_target_list_unref (entry->drag_targets);
+ }
- if (entry->favicon != NULL)
- {
- g_object_unref (entry->favicon);
- }
+ if (entry->favicon != NULL) {
+ g_object_unref (entry->favicon);
+ }
- G_OBJECT_CLASS (ephy_location_entry_parent_class)->finalize (object);
+ G_OBJECT_CLASS (ephy_location_entry_parent_class)->finalize (object);
}
static void
-ephy_location_entry_get_preferred_width (GtkWidget *widget,
- gint *minimum_width,
- gint *natural_width)
+ephy_location_entry_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width)
{
- if (minimum_width)
- *minimum_width = -1;
+ if (minimum_width)
+ *minimum_width = -1;
- if (natural_width)
- *natural_width = 848;
+ if (natural_width)
+ *natural_width = 848;
}
static void
ephy_location_entry_copy_clipboard (GtkEntry *entry)
{
- char *text;
- gint start;
- gint end;
-
- if (!gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start, &end))
- return;
-
- text = gtk_editable_get_chars (GTK_EDITABLE (entry), start, end);
-
- if (start == 0)
- {
- char *tmp = text;
- text = ephy_uri_normalize (tmp);
- g_free (tmp);
- }
-
- gtk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (entry),
- GDK_SELECTION_CLIPBOARD),
- text, -1);
- g_free (text);
+ char *text;
+ gint start;
+ gint end;
+
+ if (!gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start, &end))
+ return;
+
+ text = gtk_editable_get_chars (GTK_EDITABLE (entry), start, end);
+
+ if (start == 0) {
+ char *tmp = text;
+ text = ephy_uri_normalize (tmp);
+ g_free (tmp);
+ }
+
+ gtk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (entry),
+ GDK_SELECTION_CLIPBOARD),
+ text, -1);
+ g_free (text);
}
static void
ephy_location_entry_cut_clipboard (GtkEntry *entry)
{
- if (!gtk_editable_get_editable (GTK_EDITABLE (entry)))
- {
- gtk_widget_error_bell (GTK_WIDGET (entry));
- return;
- }
-
- ephy_location_entry_copy_clipboard (entry);
- gtk_editable_delete_selection (GTK_EDITABLE (entry));
+ if (!gtk_editable_get_editable (GTK_EDITABLE (entry))) {
+ gtk_widget_error_bell (GTK_WIDGET (entry));
+ return;
+ }
+
+ ephy_location_entry_copy_clipboard (entry);
+ gtk_editable_delete_selection (GTK_EDITABLE (entry));
}
static void
ephy_location_entry_class_init (EphyLocationEntryClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- GtkEntryClass *entry_class = GTK_ENTRY_CLASS (klass);
-
- object_class->get_property = ephy_location_entry_get_property;
- object_class->set_property = ephy_location_entry_set_property;
- object_class->finalize = ephy_location_entry_finalize;
- widget_class->get_preferred_width = ephy_location_entry_get_preferred_width;
- entry_class->copy_clipboard = ephy_location_entry_copy_clipboard;
- entry_class->cut_clipboard = ephy_location_entry_cut_clipboard;
-
- /**
- * EphyLocationEntry:location:
- *
- * The current location.
- */
- obj_properties[PROP_LOCATION] =
- g_param_spec_string ("location",
- "Location",
- "The current location",
- "",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- /**
- * EphyLocationEntry:favicon:
- *
- * The icon corresponding to the current location.
- */
- obj_properties[PROP_FAVICON] =
- g_param_spec_object ("favicon",
- "Favicon",
- "The icon corresponding to the current location",
- GDK_TYPE_PIXBUF,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
-
- /**
- * EphyLocationEntry:security-level:
- *
- * State of the security icon.
- */
- obj_properties[PROP_SECURITY_LEVEL] =
- g_param_spec_enum ("security-level",
- "Security level",
- "State of the security icon",
- EPHY_TYPE_SECURITY_LEVEL,
- EPHY_SECURITY_LEVEL_TO_BE_DETERMINED,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
-
- obj_properties[PROP_SHOW_FAVICON] =
- g_param_spec_boolean ("show-favicon",
- "Show Favicon",
- "Whether to show the favicon",
- TRUE,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
-
- /**
- * EphyLocationEntry::user-changed:
- * @entry: the object on which the signal is emitted
- *
- * Emitted when the user changes the contents of the internal #GtkEntry
- *
- */
- signals[USER_CHANGED] = g_signal_new (
- "user_changed", G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 0,
- G_TYPE_NONE);
-
- /**
- * EphyLocationEntry::lock-clicked:
- * @entry: the object on which the signal is emitted
- *
- * Emitted when the user clicks the security icon inside the
- * #EphyLocationEntry.
- *
- */
- signals[LOCK_CLICKED] = g_signal_new (
- "lock-clicked",
- EPHY_TYPE_LOCATION_ENTRY,
- G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 0);
-
- /**
- * EphyLocationEntry::get-location:
- * @entry: the object on which the signal is emitted
- * Returns: the current page address as a string
- *
- * For drag and drop purposes, the location bar will request you the
- * real address of where it is pointing to. The signal handler for this
- * function should return the address of the currently loaded site.
- *
- */
- signals[GET_LOCATION] = g_signal_new (
- "get-location", G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
- 0, ephy_signal_accumulator_string,
- NULL, NULL,
- G_TYPE_STRING,
- 0,
- G_TYPE_NONE);
-
- /**
- * EphyLocationEntry::get-title:
- * @entry: the object on which the signal is emitted
- * Returns: the current page title as a string
- *
- * For drag and drop purposes, the location bar will request you the
- * title of where it is pointing to. The signal handler for this
- * function should return the title of the currently loaded site.
- *
- */
- signals[GET_TITLE] = g_signal_new (
- "get-title", G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
- 0, ephy_signal_accumulator_string,
- NULL, NULL,
- G_TYPE_STRING,
- 0,
- G_TYPE_NONE);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GtkEntryClass *entry_class = GTK_ENTRY_CLASS (klass);
+
+ object_class->get_property = ephy_location_entry_get_property;
+ object_class->set_property = ephy_location_entry_set_property;
+ object_class->finalize = ephy_location_entry_finalize;
+ widget_class->get_preferred_width = ephy_location_entry_get_preferred_width;
+ entry_class->copy_clipboard = ephy_location_entry_copy_clipboard;
+ entry_class->cut_clipboard = ephy_location_entry_cut_clipboard;
+
+ /**
+ * EphyLocationEntry:location:
+ *
+ * The current location.
+ */
+ obj_properties[PROP_LOCATION] =
+ g_param_spec_string ("location",
+ "Location",
+ "The current location",
+ "",
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ /**
+ * EphyLocationEntry:favicon:
+ *
+ * The icon corresponding to the current location.
+ */
+ obj_properties[PROP_FAVICON] =
+ g_param_spec_object ("favicon",
+ "Favicon",
+ "The icon corresponding to the current location",
+ GDK_TYPE_PIXBUF,
+ G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
+
+ /**
+ * EphyLocationEntry:security-level:
+ *
+ * State of the security icon.
+ */
+ obj_properties[PROP_SECURITY_LEVEL] =
+ g_param_spec_enum ("security-level",
+ "Security level",
+ "State of the security icon",
+ EPHY_TYPE_SECURITY_LEVEL,
+ EPHY_SECURITY_LEVEL_TO_BE_DETERMINED,
+ G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
+
+ obj_properties[PROP_SHOW_FAVICON] =
+ g_param_spec_boolean ("show-favicon",
+ "Show Favicon",
+ "Whether to show the favicon",
+ TRUE,
+ G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+
+ /**
+ * EphyLocationEntry::user-changed:
+ * @entry: the object on which the signal is emitted
+ *
+ * Emitted when the user changes the contents of the internal #GtkEntry
+ *
+ */
+ signals[USER_CHANGED] = g_signal_new (
+ "user_changed", G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 0,
+ G_TYPE_NONE);
+
+ /**
+ * EphyLocationEntry::lock-clicked:
+ * @entry: the object on which the signal is emitted
+ *
+ * Emitted when the user clicks the security icon inside the
+ * #EphyLocationEntry.
+ *
+ */
+ signals[LOCK_CLICKED] = g_signal_new (
+ "lock-clicked",
+ EPHY_TYPE_LOCATION_ENTRY,
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 0);
+
+ /**
+ * EphyLocationEntry::get-location:
+ * @entry: the object on which the signal is emitted
+ * Returns: the current page address as a string
+ *
+ * For drag and drop purposes, the location bar will request you the
+ * real address of where it is pointing to. The signal handler for this
+ * function should return the address of the currently loaded site.
+ *
+ */
+ signals[GET_LOCATION] = g_signal_new (
+ "get-location", G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+ 0, ephy_signal_accumulator_string,
+ NULL, NULL,
+ G_TYPE_STRING,
+ 0,
+ G_TYPE_NONE);
+
+ /**
+ * EphyLocationEntry::get-title:
+ * @entry: the object on which the signal is emitted
+ * Returns: the current page title as a string
+ *
+ * For drag and drop purposes, the location bar will request you the
+ * title of where it is pointing to. The signal handler for this
+ * function should return the title of the currently loaded site.
+ *
+ */
+ signals[GET_TITLE] = g_signal_new (
+ "get-title", G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+ 0, ephy_signal_accumulator_string,
+ NULL, NULL,
+ G_TYPE_STRING,
+ 0,
+ G_TYPE_NONE);
}
static void
update_address_state (EphyLocationEntry *entry)
{
- const char *text;
+ const char *text;
- text = gtk_entry_get_text (GTK_ENTRY (entry));
- entry->original_address = text != NULL &&
- g_str_hash (text) == entry->hash;
+ text = gtk_entry_get_text (GTK_ENTRY (entry));
+ entry->original_address = text != NULL &&
+ g_str_hash (text) == entry->hash;
}
static void
update_favicon (EphyLocationEntry *lentry)
{
- GtkEntry *entry = GTK_ENTRY (lentry);
-
- /* Only show the favicon if the entry's text is the
- * address of the current page.
- */
- if (lentry->show_favicon && lentry->favicon != NULL && lentry->original_address)
- {
- gtk_entry_set_icon_from_pixbuf (entry,
- GTK_ENTRY_ICON_PRIMARY,
- lentry->favicon);
- }
- else if (lentry->show_favicon)
- {
- const char *icon_name;
-
- /* Here we could consider using fallback favicon that matches
- * the page MIME type, though text/html should be good enough
- * most of the time. See #337140
- */
- if (gtk_entry_get_text_length (entry) > 0)
- icon_name = "text-x-generic-symbolic";
- else
- icon_name = "edit-find-symbolic";
-
- gtk_entry_set_icon_from_icon_name (entry,
- GTK_ENTRY_ICON_PRIMARY,
- icon_name);
- }
- else
- {
- gtk_entry_set_icon_from_icon_name (entry,
- GTK_ENTRY_ICON_PRIMARY,
- NULL);
- }
+ GtkEntry *entry = GTK_ENTRY (lentry);
+
+ /* Only show the favicon if the entry's text is the
+ * address of the current page.
+ */
+ if (lentry->show_favicon && lentry->favicon != NULL && lentry->original_address) {
+ gtk_entry_set_icon_from_pixbuf (entry,
+ GTK_ENTRY_ICON_PRIMARY,
+ lentry->favicon);
+ } else if (lentry->show_favicon) {
+ const char *icon_name;
+
+ /* Here we could consider using fallback favicon that matches
+ * the page MIME type, though text/html should be good enough
+ * most of the time. See #337140
+ */
+ if (gtk_entry_get_text_length (entry) > 0)
+ icon_name = "text-x-generic-symbolic";
+ else
+ icon_name = "edit-find-symbolic";
+
+ gtk_entry_set_icon_from_icon_name (entry,
+ GTK_ENTRY_ICON_PRIMARY,
+ icon_name);
+ } else {
+ gtk_entry_set_icon_from_icon_name (entry,
+ GTK_ENTRY_ICON_PRIMARY,
+ NULL);
+ }
}
static void
-editable_changed_cb (GtkEditable *editable,
- EphyLocationEntry *entry)
+editable_changed_cb (GtkEditable *editable,
+ EphyLocationEntry *entry)
{
- update_address_state (entry);
+ update_address_state (entry);
- if (entry->block_update == TRUE)
- return;
- else
- {
- entry->user_changed = TRUE;
- entry->can_redo = FALSE;
- }
+ if (entry->block_update == TRUE)
+ return;
+ else {
+ entry->user_changed = TRUE;
+ entry->can_redo = FALSE;
+ }
- g_signal_emit (entry, signals[USER_CHANGED], 0);
+ g_signal_emit (entry, signals[USER_CHANGED], 0);
}
static gboolean
-entry_key_press_cb (GtkEntry *entry,
- GdkEventKey *event,
- EphyLocationEntry *location_entry)
+entry_key_press_cb (GtkEntry *entry,
+ GdkEventKey *event,
+ EphyLocationEntry *location_entry)
{
- guint state = event->state & gtk_accelerator_get_default_mod_mask ();
+ guint state = event->state & gtk_accelerator_get_default_mod_mask ();
- if (event->keyval == GDK_KEY_Escape && state == 0)
- {
- ephy_location_entry_reset_internal (location_entry, TRUE);
- /* don't return TRUE since we want to cancel the autocompletion popup too */
- }
+ if (event->keyval == GDK_KEY_Escape && state == 0) {
+ ephy_location_entry_reset_internal (location_entry, TRUE);
+ /* don't return TRUE since we want to cancel the autocompletion popup too */
+ }
- if (event->keyval == GDK_KEY_l && state == GDK_CONTROL_MASK)
- {
- /* Make sure the location is activated on CTRL+l even when the
- * completion popup is shown and have an active keyboard grab.
- */
- ephy_location_entry_activate (location_entry);
- }
+ if (event->keyval == GDK_KEY_l && state == GDK_CONTROL_MASK) {
+ /* Make sure the location is activated on CTRL+l even when the
+ * completion popup is shown and have an active keyboard grab.
+ */
+ ephy_location_entry_activate (location_entry);
+ }
- return FALSE;
+ return FALSE;
}
static gboolean
-entry_key_press_after_cb (GtkEntry *entry,
- GdkEventKey *event,
- EphyLocationEntry *lentry)
+entry_key_press_after_cb (GtkEntry *entry,
+ GdkEventKey *event,
+ EphyLocationEntry *lentry)
{
- guint state = event->state & gtk_accelerator_get_default_mod_mask ();
-
- if ((event->keyval == GDK_KEY_Return ||
- event->keyval == GDK_KEY_KP_Enter ||
- event->keyval == GDK_KEY_ISO_Enter) &&
- (state == GDK_CONTROL_MASK ||
- state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK)))
- {
- //gtk_im_context_reset (entry->im_context);
-
- lentry->needs_reset = TRUE;
- g_signal_emit_by_name (entry, "activate");
-
- return TRUE;
- }
-
- if ((event->keyval == GDK_KEY_Down || event->keyval == GDK_KEY_KP_Down)
- && state == 0)
- {
- /* If we are focusing the entry, with the cursor at the end of it
- * we emit the changed signal, so that the completion popup appears */
- const char *string;
-
- string = gtk_entry_get_text (entry);
- if (gtk_editable_get_position (GTK_EDITABLE (entry)) == (int)strlen (string))
- {
- g_signal_emit_by_name (entry, "changed", 0);
- return TRUE;
- }
- }
-
- return FALSE;
+ guint state = event->state & gtk_accelerator_get_default_mod_mask ();
+
+ if ((event->keyval == GDK_KEY_Return ||
+ event->keyval == GDK_KEY_KP_Enter ||
+ event->keyval == GDK_KEY_ISO_Enter) &&
+ (state == GDK_CONTROL_MASK ||
+ state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK))) {
+ /* gtk_im_context_reset (entry->im_context); */
+
+ lentry->needs_reset = TRUE;
+ g_signal_emit_by_name (entry, "activate");
+
+ return TRUE;
+ }
+
+ if ((event->keyval == GDK_KEY_Down || event->keyval == GDK_KEY_KP_Down)
+ && state == 0) {
+ /* If we are focusing the entry, with the cursor at the end of it
+ * we emit the changed signal, so that the completion popup appears */
+ const char *string;
+
+ string = gtk_entry_get_text (entry);
+ if (gtk_editable_get_position (GTK_EDITABLE (entry)) == (int)strlen (string)) {
+ g_signal_emit_by_name (entry, "changed", 0);
+ return TRUE;
+ }
+ }
+
+ return FALSE;
}
static void
-entry_activate_after_cb (GtkEntry *entry,
- EphyLocationEntry *lentry)
+entry_activate_after_cb (GtkEntry *entry,
+ EphyLocationEntry *lentry)
{
- lentry->user_changed = FALSE;
+ lentry->user_changed = FALSE;
- if (lentry->needs_reset)
- {
- ephy_location_entry_reset_internal (lentry, TRUE);
- lentry->needs_reset = FALSE;
- }
+ if (lentry->needs_reset) {
+ ephy_location_entry_reset_internal (lentry, TRUE);
+ lentry->needs_reset = FALSE;
+ }
}
static gboolean
match_selected_cb (GtkEntryCompletion *completion,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- EphyLocationEntry *entry)
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ EphyLocationEntry *entry)
{
- char *item = NULL;
- guint state;
+ char *item = NULL;
+ guint state;
- gtk_tree_model_get (model, iter,
- entry->action_col, &item, -1);
- if (item == NULL) return FALSE;
+ gtk_tree_model_get (model, iter,
+ entry->action_col, &item, -1);
+ if (item == NULL) return FALSE;
- ephy_gui_get_current_event (NULL, &state, NULL);
+ ephy_gui_get_current_event (NULL, &state, NULL);
- entry->needs_reset = (state == GDK_CONTROL_MASK ||
- state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK));
+ entry->needs_reset = (state == GDK_CONTROL_MASK ||
+ state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK));
- ephy_location_entry_set_location (entry, item);
- //gtk_im_context_reset (GTK_ENTRY (entry)->im_context);
- g_signal_emit_by_name (entry, "activate");
+ ephy_location_entry_set_location (entry, item);
+ /* gtk_im_context_reset (GTK_ENTRY (entry)->im_context); */
+ g_signal_emit_by_name (entry, "activate");
- g_free (item);
+ g_free (item);
- return TRUE;
+ return TRUE;
}
static void
action_activated_after_cb (GtkEntryCompletion *completion,
- gint index,
- EphyLocationEntry *lentry)
+ gint index,
+ EphyLocationEntry *lentry)
{
- guint state, button;
-
- ephy_gui_get_current_event (NULL, &state, &button);
- if ((state == GDK_CONTROL_MASK ||
- state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) ||
- button == 2)
- {
- ephy_location_entry_reset_internal (lentry, TRUE);
- }
+ guint state, button;
+
+ ephy_gui_get_current_event (NULL, &state, &button);
+ if ((state == GDK_CONTROL_MASK ||
+ state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) ||
+ button == 2) {
+ ephy_location_entry_reset_internal (lentry, TRUE);
+ }
}
static gboolean
-entry_drag_motion_cb (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
+entry_drag_motion_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time)
{
- return FALSE;
+ return FALSE;
}
static gboolean
-entry_drag_drop_cb (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
+entry_drag_drop_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time)
{
- return FALSE;
+ return FALSE;
}
static void
-entry_clear_activate_cb (GtkMenuItem *item,
- EphyLocationEntry *entry)
+entry_clear_activate_cb (GtkMenuItem *item,
+ EphyLocationEntry *entry)
{
- entry->block_update = TRUE;
- gtk_entry_set_text (GTK_ENTRY (entry), "");
- entry->block_update = FALSE;
- entry->user_changed = TRUE;
+ entry->block_update = TRUE;
+ gtk_entry_set_text (GTK_ENTRY (entry), "");
+ entry->block_update = FALSE;
+ entry->user_changed = TRUE;
}
static void
-entry_redo_activate_cb (GtkMenuItem *item,
- EphyLocationEntry *entry)
+entry_redo_activate_cb (GtkMenuItem *item,
+ EphyLocationEntry *entry)
{
- ephy_location_entry_undo_reset (entry);
+ ephy_location_entry_undo_reset (entry);
}
static void
-entry_undo_activate_cb (GtkMenuItem *item,
- EphyLocationEntry *entry)
+entry_undo_activate_cb (GtkMenuItem *item,
+ EphyLocationEntry *entry)
{
- ephy_location_entry_reset_internal (entry, FALSE);
+ ephy_location_entry_reset_internal (entry, FALSE);
}
static void
-entry_populate_popup_cb (GtkEntry *entry,
- GtkMenu *menu,
- EphyLocationEntry *lentry)
+entry_populate_popup_cb (GtkEntry *entry,
+ GtkMenu *menu,
+ EphyLocationEntry *lentry)
{
- GtkWidget *clear_menuitem, *undo_menuitem, *redo_menuitem, *separator;
- GList *children, *item;
- int pos = 0, sep = 0;
- gboolean is_editable;
-
- /* Translators: the mnemonic shouldn't conflict with any of the
- * standard items in the GtkEntry context menu (Cut, Copy, Paste, Delete,
- * Select All, Input Methods and Insert Unicode control character.)
- */
- clear_menuitem = gtk_menu_item_new_with_mnemonic (_("Cl_ear"));
- g_signal_connect (clear_menuitem , "activate",
- G_CALLBACK (entry_clear_activate_cb), lentry);
- is_editable = gtk_editable_get_editable (GTK_EDITABLE (entry));
- gtk_widget_set_sensitive (clear_menuitem, is_editable);
- gtk_widget_show (clear_menuitem);
-
- /* search for the 2nd separator (the one after Select All) in the context
- * menu, and insert this menu item before it.
- * It's a bit of a hack, but there seems to be no better way to do it :/
- */
- children = gtk_container_get_children (GTK_CONTAINER (menu));
- for (item = children; item != NULL && sep < 2; item = item->next, pos++)
- {
- if (GTK_IS_SEPARATOR_MENU_ITEM (item->data)) sep++;
- }
-
- gtk_menu_shell_insert (GTK_MENU_SHELL (menu), clear_menuitem, pos - 1);
-
- undo_menuitem = gtk_menu_item_new_with_mnemonic (_("_Undo"));
- gtk_widget_set_sensitive (undo_menuitem, lentry->user_changed);
- g_signal_connect (undo_menuitem, "activate",
- G_CALLBACK (entry_undo_activate_cb), lentry);
- gtk_widget_show (undo_menuitem);
- gtk_menu_shell_insert (GTK_MENU_SHELL (menu), undo_menuitem, 0);
-
- redo_menuitem = gtk_menu_item_new_with_mnemonic (_("_Redo"));
- gtk_widget_set_sensitive (redo_menuitem, lentry->can_redo);
- g_signal_connect (redo_menuitem, "activate",
- G_CALLBACK (entry_redo_activate_cb), lentry);
- gtk_widget_show (redo_menuitem);
- gtk_menu_shell_insert (GTK_MENU_SHELL (menu), redo_menuitem, 1);
-
- separator = gtk_separator_menu_item_new ();
- gtk_widget_show (separator);
- gtk_menu_shell_insert (GTK_MENU_SHELL (menu), separator, 2);
+ GtkWidget *clear_menuitem, *undo_menuitem, *redo_menuitem, *separator;
+ GList *children, *item;
+ int pos = 0, sep = 0;
+ gboolean is_editable;
+
+ /* Translators: the mnemonic shouldn't conflict with any of the
+ * standard items in the GtkEntry context menu (Cut, Copy, Paste, Delete,
+ * Select All, Input Methods and Insert Unicode control character.)
+ */
+ clear_menuitem = gtk_menu_item_new_with_mnemonic (_("Cl_ear"));
+ g_signal_connect (clear_menuitem, "activate",
+ G_CALLBACK (entry_clear_activate_cb), lentry);
+ is_editable = gtk_editable_get_editable (GTK_EDITABLE (entry));
+ gtk_widget_set_sensitive (clear_menuitem, is_editable);
+ gtk_widget_show (clear_menuitem);
+
+ /* search for the 2nd separator (the one after Select All) in the context
+ * menu, and insert this menu item before it.
+ * It's a bit of a hack, but there seems to be no better way to do it :/
+ */
+ children = gtk_container_get_children (GTK_CONTAINER (menu));
+ for (item = children; item != NULL && sep < 2; item = item->next, pos++) {
+ if (GTK_IS_SEPARATOR_MENU_ITEM (item->data)) sep++;
+ }
+
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu), clear_menuitem, pos - 1);
+
+ undo_menuitem = gtk_menu_item_new_with_mnemonic (_("_Undo"));
+ gtk_widget_set_sensitive (undo_menuitem, lentry->user_changed);
+ g_signal_connect (undo_menuitem, "activate",
+ G_CALLBACK (entry_undo_activate_cb), lentry);
+ gtk_widget_show (undo_menuitem);
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu), undo_menuitem, 0);
+
+ redo_menuitem = gtk_menu_item_new_with_mnemonic (_("_Redo"));
+ gtk_widget_set_sensitive (redo_menuitem, lentry->can_redo);
+ g_signal_connect (redo_menuitem, "activate",
+ G_CALLBACK (entry_redo_activate_cb), lentry);
+ gtk_widget_show (redo_menuitem);
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu), redo_menuitem, 1);
+
+ separator = gtk_separator_menu_item_new ();
+ gtk_widget_show (separator);
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu), separator, 2);
}
static void
each_url_get_data_binder (EphyDragEachSelectedItemDataGet iteratee,
- gpointer iterator_context,
- gpointer return_data)
+ gpointer iterator_context,
+ gpointer return_data)
{
- EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (iterator_context);
- char *title = NULL, *address = NULL;
+ EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (iterator_context);
+ char *title = NULL, *address = NULL;
- g_signal_emit (entry, signals[GET_LOCATION], 0, &address);
- g_signal_emit (entry, signals[GET_TITLE], 0, &title);
- g_return_if_fail (address != NULL && title != NULL);
+ g_signal_emit (entry, signals[GET_LOCATION], 0, &address);
+ g_signal_emit (entry, signals[GET_TITLE], 0, &title);
+ g_return_if_fail (address != NULL && title != NULL);
- iteratee (address, title, return_data);
+ iteratee (address, title, return_data);
- g_free (address);
- g_free (title);
+ g_free (address);
+ g_free (title);
}
static void
sanitize_location (char **url)
{
- char *str;
-
- /* Do not show internal ephy-about: protocol to users */
- if (g_str_has_prefix (*url, EPHY_ABOUT_SCHEME)) {
- str = g_strdup_printf ("about:%s", *url + strlen (EPHY_ABOUT_SCHEME) + 1);
- g_free (*url);
- *url = str;
- }
+ char *str;
+
+ /* Do not show internal ephy-about: protocol to users */
+ if (g_str_has_prefix (*url, EPHY_ABOUT_SCHEME)) {
+ str = g_strdup_printf ("about:%s", *url + strlen (EPHY_ABOUT_SCHEME) + 1);
+ g_free (*url);
+ *url = str;
+ }
}
-#define DRAG_ICON_LAYOUT_PADDING 5
-#define DRAG_ICON_ICON_PADDING 10
-#define DRAG_ICON_MAX_WIDTH_CHARS 32
+#define DRAG_ICON_LAYOUT_PADDING 5
+#define DRAG_ICON_ICON_PADDING 10
+#define DRAG_ICON_MAX_WIDTH_CHARS 32
static cairo_surface_t *
favicon_create_drag_surface (EphyLocationEntry *entry,
- GtkWidget *widget)
+ GtkWidget *widget)
{
- char *title = NULL, *address = NULL;
- GString *text;
- GtkStyleContext *style;
- const PangoFontDescription *font_desc;
- cairo_surface_t *surface;
- PangoContext *context;
- PangoLayout *layout;
- PangoFontMetrics *metrics;
- int surface_height, surface_width;
- int layout_width, layout_height;
- int icon_width = 0, icon_height = 0, favicon_offset_x = 0;
- int char_width;
- cairo_t *cr;
- GtkStateFlags state;
- GdkRGBA color;
- GdkPixbuf *favicon;
-
- g_signal_emit (entry, signals[GET_LOCATION], 0, &address);
- sanitize_location (&address);
- g_signal_emit (entry, signals[GET_TITLE], 0, &title);
- if (address == NULL || title == NULL) return NULL;
-
- /* Compute text */
- title = g_strstrip (title);
-
- text = g_string_sized_new (strlen (address) + strlen (title) + 2);
- if (title[0] != '\0')
- {
- g_string_append (text, title);
- g_string_append (text, "\n");
- }
-
- if (address[0] != '\0')
- {
- g_string_append (text, address);
- }
-
- if (entry->favicon != NULL)
- favicon = g_object_ref (entry->favicon);
- else
- favicon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
- "text-x-generic-symbolic",
- 16,
- 0, NULL);
- if (favicon != NULL)
- {
- icon_width = gdk_pixbuf_get_width (favicon);
- icon_height = gdk_pixbuf_get_height (favicon);
- }
-
- context = gtk_widget_get_pango_context (widget);
- layout = pango_layout_new (context);
-
- style = gtk_widget_get_style_context (GTK_WIDGET (entry));
- state = gtk_style_context_get_state (style);
-
- gtk_style_context_save (style);
- gtk_style_context_set_state (style, GTK_STATE_FLAG_NORMAL);
- gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL,
- "font", &font_desc, NULL);
- gtk_style_context_restore (style);
-
- metrics = pango_context_get_metrics (context,
- font_desc,
- pango_context_get_language (context));
-
- char_width = pango_font_metrics_get_approximate_digit_width (metrics);
- pango_font_metrics_unref (metrics);
-
- pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
- pango_layout_set_width (layout, char_width * DRAG_ICON_MAX_WIDTH_CHARS);
- pango_layout_set_text (layout, text->str, text->len);
-
- pango_layout_get_pixel_size (layout, &layout_width, &layout_height);
-
- if (favicon != NULL)
- {
- favicon_offset_x = icon_width + (2 * DRAG_ICON_ICON_PADDING);
- }
-
- surface_width = layout_width + favicon_offset_x +
- (DRAG_ICON_LAYOUT_PADDING * 3);
- surface_height = MAX (layout_height, icon_height) +
- (DRAG_ICON_LAYOUT_PADDING * 2);
-
- surface = gdk_window_create_similar_surface (gtk_widget_get_window (widget),
- CAIRO_CONTENT_COLOR,
- surface_width + 2,
- surface_height + 2);
- cr = cairo_create (surface);
-
- cairo_rectangle (cr, 1, 1, surface_width, surface_height);
- cairo_set_line_width (cr, 1.0);
-
- cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
- cairo_stroke_preserve (cr);
-
- gtk_style_context_get_background_color (style, state, &color);
- gdk_cairo_set_source_rgba (cr, &color);
- cairo_fill (cr);
-
- if (favicon != NULL)
- {
- double x;
- double y;
-
- x = 1 + DRAG_ICON_LAYOUT_PADDING + DRAG_ICON_ICON_PADDING;
- y = (surface_height - icon_height) / 2;
- gdk_cairo_set_source_pixbuf (cr, favicon, x, y);
- cairo_rectangle (cr, x, y, icon_width, icon_height);
- cairo_fill (cr);
- }
-
- cairo_move_to (cr,
- 1 + DRAG_ICON_LAYOUT_PADDING + favicon_offset_x,
- 1 + DRAG_ICON_LAYOUT_PADDING);
- gtk_style_context_get_color (style, state, &color);
- gdk_cairo_set_source_rgba (cr, &color);
- pango_cairo_show_layout (cr, layout);
-
- cairo_destroy (cr);
- g_object_unref (layout);
-
- g_free (address);
- g_free (title);
- g_string_free (text, TRUE);
- g_clear_object (&favicon);
-
- return surface;
+ char *title = NULL, *address = NULL;
+ GString *text;
+ GtkStyleContext *style;
+ const PangoFontDescription *font_desc;
+ cairo_surface_t *surface;
+ PangoContext *context;
+ PangoLayout *layout;
+ PangoFontMetrics *metrics;
+ int surface_height, surface_width;
+ int layout_width, layout_height;
+ int icon_width = 0, icon_height = 0, favicon_offset_x = 0;
+ int char_width;
+ cairo_t *cr;
+ GtkStateFlags state;
+ GdkRGBA color;
+ GdkPixbuf *favicon;
+
+ g_signal_emit (entry, signals[GET_LOCATION], 0, &address);
+ sanitize_location (&address);
+ g_signal_emit (entry, signals[GET_TITLE], 0, &title);
+ if (address == NULL || title == NULL) return NULL;
+
+ /* Compute text */
+ title = g_strstrip (title);
+
+ text = g_string_sized_new (strlen (address) + strlen (title) + 2);
+ if (title[0] != '\0') {
+ g_string_append (text, title);
+ g_string_append (text, "\n");
+ }
+
+ if (address[0] != '\0') {
+ g_string_append (text, address);
+ }
+
+ if (entry->favicon != NULL)
+ favicon = g_object_ref (entry->favicon);
+ else
+ favicon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+ "text-x-generic-symbolic",
+ 16,
+ 0, NULL);
+ if (favicon != NULL) {
+ icon_width = gdk_pixbuf_get_width (favicon);
+ icon_height = gdk_pixbuf_get_height (favicon);
+ }
+
+ context = gtk_widget_get_pango_context (widget);
+ layout = pango_layout_new (context);
+
+ style = gtk_widget_get_style_context (GTK_WIDGET (entry));
+ state = gtk_style_context_get_state (style);
+
+ gtk_style_context_save (style);
+ gtk_style_context_set_state (style, GTK_STATE_FLAG_NORMAL);
+ gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL,
+ "font", &font_desc, NULL);
+ gtk_style_context_restore (style);
+
+ metrics = pango_context_get_metrics (context,
+ font_desc,
+ pango_context_get_language (context));
+
+ char_width = pango_font_metrics_get_approximate_digit_width (metrics);
+ pango_font_metrics_unref (metrics);
+
+ pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
+ pango_layout_set_width (layout, char_width * DRAG_ICON_MAX_WIDTH_CHARS);
+ pango_layout_set_text (layout, text->str, text->len);
+
+ pango_layout_get_pixel_size (layout, &layout_width, &layout_height);
+
+ if (favicon != NULL) {
+ favicon_offset_x = icon_width + (2 * DRAG_ICON_ICON_PADDING);
+ }
+
+ surface_width = layout_width + favicon_offset_x +
+ (DRAG_ICON_LAYOUT_PADDING * 3);
+ surface_height = MAX (layout_height, icon_height) +
+ (DRAG_ICON_LAYOUT_PADDING * 2);
+
+ surface = gdk_window_create_similar_surface (gtk_widget_get_window (widget),
+ CAIRO_CONTENT_COLOR,
+ surface_width + 2,
+ surface_height + 2);
+ cr = cairo_create (surface);
+
+ cairo_rectangle (cr, 1, 1, surface_width, surface_height);
+ cairo_set_line_width (cr, 1.0);
+
+ cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
+ cairo_stroke_preserve (cr);
+
+ gtk_style_context_get_background_color (style, state, &color);
+ gdk_cairo_set_source_rgba (cr, &color);
+ cairo_fill (cr);
+
+ if (favicon != NULL) {
+ double x;
+ double y;
+
+ x = 1 + DRAG_ICON_LAYOUT_PADDING + DRAG_ICON_ICON_PADDING;
+ y = (surface_height - icon_height) / 2;
+ gdk_cairo_set_source_pixbuf (cr, favicon, x, y);
+ cairo_rectangle (cr, x, y, icon_width, icon_height);
+ cairo_fill (cr);
+ }
+
+ cairo_move_to (cr,
+ 1 + DRAG_ICON_LAYOUT_PADDING + favicon_offset_x,
+ 1 + DRAG_ICON_LAYOUT_PADDING);
+ gtk_style_context_get_color (style, state, &color);
+ gdk_cairo_set_source_rgba (cr, &color);
+ pango_cairo_show_layout (cr, layout);
+
+ cairo_destroy (cr);
+ g_object_unref (layout);
+
+ g_free (address);
+ g_free (title);
+ g_string_free (text, TRUE);
+ g_clear_object (&favicon);
+
+ return surface;
}
static void
-favicon_drag_begin_cb (GtkWidget *widget,
- GdkDragContext *context,
- EphyLocationEntry *lentry)
+favicon_drag_begin_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ EphyLocationEntry *lentry)
{
- cairo_surface_t *surface;
- GtkEntry *entry;
- gint index;
+ cairo_surface_t *surface;
+ GtkEntry *entry;
+ gint index;
- entry = GTK_ENTRY (widget);
+ entry = GTK_ENTRY (widget);
- index = gtk_entry_get_current_icon_drag_source (entry);
- if (index != GTK_ENTRY_ICON_PRIMARY)
- return;
+ index = gtk_entry_get_current_icon_drag_source (entry);
+ if (index != GTK_ENTRY_ICON_PRIMARY)
+ return;
- surface = favicon_create_drag_surface (lentry, widget);
+ surface = favicon_create_drag_surface (lentry, widget);
- if (surface != NULL)
- {
- gtk_drag_set_icon_surface (context, surface);
- cairo_surface_destroy (surface);
- }
+ if (surface != NULL) {
+ gtk_drag_set_icon_surface (context, surface);
+ cairo_surface_destroy (surface);
+ }
}
static void
-favicon_drag_data_get_cb (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint info,
- guint32 time,
- EphyLocationEntry *lentry)
+favicon_drag_data_get_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint32 time,
+ EphyLocationEntry *lentry)
{
- gint index;
- GtkEntry *entry;
+ gint index;
+ GtkEntry *entry;
- g_assert (widget != NULL);
- g_return_if_fail (context != NULL);
+ g_assert (widget != NULL);
+ g_return_if_fail (context != NULL);
- entry = GTK_ENTRY (widget);
+ entry = GTK_ENTRY (widget);
- index = gtk_entry_get_current_icon_drag_source (entry);
- if (index == GTK_ENTRY_ICON_PRIMARY)
- {
- ephy_dnd_drag_data_get (widget, context, selection_data,
- time, lentry, each_url_get_data_binder);
- }
+ index = gtk_entry_get_current_icon_drag_source (entry);
+ if (index == GTK_ENTRY_ICON_PRIMARY) {
+ ephy_dnd_drag_data_get (widget, context, selection_data,
+ time, lentry, each_url_get_data_binder);
+ }
}
static gboolean
-icon_button_press_event_cb (GtkWidget *entry,
- GtkEntryIconPosition position,
- GdkEventButton *event,
- EphyLocationEntry *lentry)
+icon_button_press_event_cb (GtkWidget *entry,
+ GtkEntryIconPosition position,
+ GdkEventButton *event,
+ EphyLocationEntry *lentry)
{
- guint state = event->state & gtk_accelerator_get_default_mod_mask ();
-
- if (event->type == GDK_BUTTON_PRESS &&
- event->button == 1 &&
- state == 0 /* left */)
- {
- if (position == GTK_ENTRY_ICON_PRIMARY)
- {
- GtkWidget *toplevel;
-
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (entry));
- gtk_window_set_focus (GTK_WINDOW (toplevel), entry);
-
- gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
- }
- else
- {
- g_signal_emit (lentry, signals[LOCK_CLICKED], 0);
- }
-
- return TRUE;
- }
-
- return FALSE;
+ guint state = event->state & gtk_accelerator_get_default_mod_mask ();
+
+ if (event->type == GDK_BUTTON_PRESS &&
+ event->button == 1 &&
+ state == 0 /* left */) {
+ if (position == GTK_ENTRY_ICON_PRIMARY) {
+ GtkWidget *toplevel;
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (entry));
+ gtk_window_set_focus (GTK_WINDOW (toplevel), entry);
+
+ gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
+ } else {
+ g_signal_emit (lentry, signals[LOCK_CLICKED], 0);
+ }
+
+ return TRUE;
+ }
+
+ return FALSE;
}
static void
ephy_location_entry_construct_contents (EphyLocationEntry *lentry)
{
- GtkWidget *entry = GTK_WIDGET (lentry);
-
- LOG ("EphyLocationEntry constructing contents %p", lentry);
-
- /* Favicon */
- lentry->drag_targets = gtk_target_list_new (url_drag_types,
- G_N_ELEMENTS (url_drag_types));
- lentry->drag_actions = GDK_ACTION_ASK | GDK_ACTION_COPY | GDK_ACTION_LINK;
-
- gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_PRIMARY,
- lentry->drag_targets,
- lentry->drag_actions);
-
- gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_PRIMARY,
- _("Drag and drop this icon to create a link to this page"));
-
- gtk_drag_dest_set (entry,
- GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
- url_drag_types,
- G_N_ELEMENTS (url_drag_types),
- GDK_ACTION_MOVE | GDK_ACTION_COPY);
-
- g_object_connect (entry,
- "signal::icon-press", G_CALLBACK (icon_button_press_event_cb), lentry,
- "signal::populate-popup", G_CALLBACK (entry_populate_popup_cb), lentry,
- "signal::key-press-event", G_CALLBACK (entry_key_press_cb), lentry,
- "signal::changed", G_CALLBACK (editable_changed_cb), lentry,
- "signal::drag-motion", G_CALLBACK (entry_drag_motion_cb), lentry,
- "signal::drag-drop", G_CALLBACK (entry_drag_drop_cb), lentry,
- "signal::drag-data-get", G_CALLBACK (favicon_drag_data_get_cb), lentry,
- NULL);
-
- g_signal_connect_after (entry, "key-press-event",
- G_CALLBACK (entry_key_press_after_cb), lentry);
- g_signal_connect_after (entry, "activate",
- G_CALLBACK (entry_activate_after_cb), lentry);
- g_signal_connect_after (entry, "drag-begin",
- G_CALLBACK (favicon_drag_begin_cb), lentry);
+ GtkWidget *entry = GTK_WIDGET (lentry);
+
+ LOG ("EphyLocationEntry constructing contents %p", lentry);
+
+ /* Favicon */
+ lentry->drag_targets = gtk_target_list_new (url_drag_types,
+ G_N_ELEMENTS (url_drag_types));
+ lentry->drag_actions = GDK_ACTION_ASK | GDK_ACTION_COPY | GDK_ACTION_LINK;
+
+ gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_PRIMARY,
+ lentry->drag_targets,
+ lentry->drag_actions);
+
+ gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_PRIMARY,
+ _("Drag and drop this icon to create a link to this page"));
+
+ gtk_drag_dest_set (entry,
+ GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
+ url_drag_types,
+ G_N_ELEMENTS (url_drag_types),
+ GDK_ACTION_MOVE | GDK_ACTION_COPY);
+
+ g_object_connect (entry,
+ "signal::icon-press", G_CALLBACK (icon_button_press_event_cb), lentry,
+ "signal::populate-popup", G_CALLBACK (entry_populate_popup_cb), lentry,
+ "signal::key-press-event", G_CALLBACK (entry_key_press_cb), lentry,
+ "signal::changed", G_CALLBACK (editable_changed_cb), lentry,
+ "signal::drag-motion", G_CALLBACK (entry_drag_motion_cb), lentry,
+ "signal::drag-drop", G_CALLBACK (entry_drag_drop_cb), lentry,
+ "signal::drag-data-get", G_CALLBACK (favicon_drag_data_get_cb), lentry,
+ NULL);
+
+ g_signal_connect_after (entry, "key-press-event",
+ G_CALLBACK (entry_key_press_after_cb), lentry);
+ g_signal_connect_after (entry, "activate",
+ G_CALLBACK (entry_activate_after_cb), lentry);
+ g_signal_connect_after (entry, "drag-begin",
+ G_CALLBACK (favicon_drag_begin_cb), lentry);
}
static void
ephy_location_entry_init (EphyLocationEntry *le)
{
- LOG ("EphyLocationEntry initialising %p", le);
+ LOG ("EphyLocationEntry initialising %p", le);
- le->user_changed = FALSE;
- le->block_update = FALSE;
- le->saved_text = NULL;
- le->show_favicon = TRUE;
- le->dns_prefetch_handler = 0;
+ le->user_changed = FALSE;
+ le->block_update = FALSE;
+ le->saved_text = NULL;
+ le->show_favicon = TRUE;
+ le->dns_prefetch_handler = 0;
- ephy_location_entry_construct_contents (le);
+ ephy_location_entry_construct_contents (le);
}
GtkWidget *
ephy_location_entry_new (void)
{
- return GTK_WIDGET (g_object_new (EPHY_TYPE_LOCATION_ENTRY, NULL));
+ return GTK_WIDGET (g_object_new (EPHY_TYPE_LOCATION_ENTRY, NULL));
}
#if 0
/* FIXME: Refactor the DNS prefetch, this is a layering violation */
typedef struct {
- SoupURI *uri;
- EphyLocationEntry *entry;
+ SoupURI *uri;
+ EphyLocationEntry *entry;
} PrefetchHelper;
static void
free_prefetch_helper (PrefetchHelper *helper)
{
- soup_uri_free (helper->uri);
- g_object_unref (helper->entry);
- g_slice_free (PrefetchHelper, helper);
+ soup_uri_free (helper->uri);
+ g_object_unref (helper->entry);
+ g_slice_free (PrefetchHelper, helper);
}
static gboolean
do_dns_prefetch (PrefetchHelper *helper)
{
- EphyEmbedShell *shell = ephy_embed_shell_get_default ();
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
- if (helper->uri)
- webkit_web_context_prefetch_dns (ephy_embed_shell_get_web_context (shell), helper->uri->host);
+ if (helper->uri)
+ webkit_web_context_prefetch_dns (ephy_embed_shell_get_web_context (shell), helper->uri->host);
- helper->entry->dns_prefetch_handler = 0;
+ helper->entry->dns_prefetch_handler = 0;
- return FALSE;
+ return FALSE;
}
static void
schedule_dns_prefetch (EphyLocationEntry *entry, guint interval, const gchar *url)
{
- PrefetchHelper *helper;
- SoupURI *uri;
-
- uri = soup_uri_new (url);
- if (!uri || !uri->host) {
- soup_uri_free (uri);
- return;
- }
-
- if (entry->dns_prefetch_handler)
- g_source_remove (entry->dns_prefetch_handler);
-
- helper = g_slice_new0 (PrefetchHelper);
- helper->entry = g_object_ref (entry);
- helper->uri = uri;
-
- entry->dns_prefetch_handler =
- g_timeout_add_full (G_PRIORITY_DEFAULT, interval,
- (GSourceFunc) do_dns_prefetch, helper,
- (GDestroyNotify) free_prefetch_helper);
- g_source_set_name_by_id (entry->dns_prefetch_handler, "[epiphany] do_dns_prefetch");
+ PrefetchHelper *helper;
+ SoupURI *uri;
+
+ uri = soup_uri_new (url);
+ if (!uri || !uri->host) {
+ soup_uri_free (uri);
+ return;
+ }
+
+ if (entry->dns_prefetch_handler)
+ g_source_remove (entry->dns_prefetch_handler);
+
+ helper = g_slice_new0 (PrefetchHelper);
+ helper->entry = g_object_ref (entry);
+ helper->uri = uri;
+
+ entry->dns_prefetch_handler =
+ g_timeout_add_full (G_PRIORITY_DEFAULT, interval,
+ (GSourceFunc)do_dns_prefetch, helper,
+ (GDestroyNotify)free_prefetch_helper);
+ g_source_set_name_by_id (entry->dns_prefetch_handler, "[epiphany] do_dns_prefetch");
}
#endif
static gboolean
-cursor_on_match_cb (GtkEntryCompletion *completion,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- EphyLocationEntry *le)
+cursor_on_match_cb (GtkEntryCompletion *completion,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ EphyLocationEntry *le)
{
- char *url = NULL;
- GtkWidget *entry;
-
- gtk_tree_model_get (model, iter,
- le->url_col,
- &url, -1);
- entry = gtk_entry_completion_get_entry (completion);
-
- /* Prevent the update so we keep the highlight from our input.
- * See textcell_data_func().
- */
- le->block_update = TRUE;
- gtk_entry_set_text (GTK_ENTRY (entry), url);
- gtk_editable_set_position (GTK_EDITABLE (entry), -1);
- le->block_update = FALSE;
+ char *url = NULL;
+ GtkWidget *entry;
+
+ gtk_tree_model_get (model, iter,
+ le->url_col,
+ &url, -1);
+ entry = gtk_entry_completion_get_entry (completion);
+
+ /* Prevent the update so we keep the highlight from our input.
+ * See textcell_data_func().
+ */
+ le->block_update = TRUE;
+ gtk_entry_set_text (GTK_ENTRY (entry), url);
+ gtk_editable_set_position (GTK_EDITABLE (entry), -1);
+ le->block_update = FALSE;
#if 0
/* FIXME: Refactor the DNS prefetch, this is a layering violation */
- schedule_dns_prefetch (le, 250, (const gchar*) url);
+ schedule_dns_prefetch (le, 250, (const gchar *)url);
#endif
- g_free (url);
+ g_free (url);
- return TRUE;
+ return TRUE;
}
static void
-extracell_data_func (GtkCellLayout *cell_layout,
- GtkCellRenderer *cell,
- GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- gpointer data)
+extracell_data_func (GtkCellLayout *cell_layout,
+ GtkCellRenderer *cell,
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ gpointer data)
{
- EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (data);
- gboolean is_bookmark = FALSE;
- GValue visible = { 0, };
-
- gtk_tree_model_get (tree_model, iter,
- entry->extra_col, &is_bookmark,
- -1);
-
- if (is_bookmark)
- g_object_set (cell,
- "icon-name", "user-bookmarks-symbolic",
- NULL);
-
- g_value_init (&visible, G_TYPE_BOOLEAN);
- g_value_set_boolean (&visible, is_bookmark);
- g_object_set_property (G_OBJECT (cell), "visible", &visible);
- g_value_unset (&visible);
+ EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (data);
+ gboolean is_bookmark = FALSE;
+ GValue visible = { 0, };
+
+ gtk_tree_model_get (tree_model, iter,
+ entry->extra_col, &is_bookmark,
+ -1);
+
+ if (is_bookmark)
+ g_object_set (cell,
+ "icon-name", "user-bookmarks-symbolic",
+ NULL);
+
+ g_value_init (&visible, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&visible, is_bookmark);
+ g_object_set_property (G_OBJECT (cell), "visible", &visible);
+ g_value_unset (&visible);
}
/**
@@ -1095,15 +1061,15 @@ extracell_data_func (GtkCellLayout *cell_layout,
*
**/
void
-ephy_location_entry_set_match_func (EphyLocationEntry *entry,
- GtkEntryCompletionMatchFunc match_func,
- gpointer user_data,
- GDestroyNotify notify)
+ephy_location_entry_set_match_func (EphyLocationEntry *entry,
+ GtkEntryCompletionMatchFunc match_func,
+ gpointer user_data,
+ GDestroyNotify notify)
{
- GtkEntryCompletion *completion;
+ GtkEntryCompletion *completion;
- completion = gtk_entry_get_completion (GTK_ENTRY (entry));
- gtk_entry_completion_set_match_func (completion, match_func, user_data, notify);
+ completion = gtk_entry_get_completion (GTK_ENTRY (entry));
+ gtk_entry_completion_set_match_func (completion, match_func, user_data, notify);
}
/**
@@ -1126,64 +1092,64 @@ ephy_location_entry_set_match_func (EphyLocationEntry *entry,
**/
void
ephy_location_entry_set_completion (EphyLocationEntry *entry,
- GtkTreeModel *model,
- guint text_col,
- guint action_col,
- guint keywords_col,
- guint relevance_col,
- guint url_col,
- guint extra_col,
- guint favicon_col)
+ GtkTreeModel *model,
+ guint text_col,
+ guint action_col,
+ guint keywords_col,
+ guint relevance_col,
+ guint url_col,
+ guint extra_col,
+ guint favicon_col)
{
- GtkEntryCompletion *completion;
- GtkCellRenderer *cell;
-
- entry->text_col = text_col;
- entry->action_col = action_col;
- entry->keywords_col = keywords_col;
- entry->relevance_col = relevance_col;
- entry->url_col = url_col;
- entry->extra_col = extra_col;
- entry->favicon_col = favicon_col;
-
- completion = gtk_entry_completion_new ();
- gtk_entry_completion_set_model (completion, model);
- g_signal_connect (completion, "match-selected",
- G_CALLBACK (match_selected_cb), entry);
- g_signal_connect_after (completion, "action-activated",
- G_CALLBACK (action_activated_after_cb), entry);
-
- cell = gtk_cell_renderer_pixbuf_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion),
- cell, FALSE);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
- cell, "pixbuf", favicon_col);
-
- /* Pixel-perfect aligment with the location entry favicon
- * (16x16). Consider that this /might/ depend on the theme.
- *
- * The GtkEntryCompletion can not be themed so we work-around
- * that with padding and fixed sizes.
- * For the first cell, this is:
- *
- * ___+++++iiiiiiiiiiiiiiii++__ttt...bbb++++++__
- *
- * _ = widget spacing, can not be handled (3 px)
- * + = padding (5 px) (ICON_PADDING_LEFT)
- * i = the icon (16 px) (ICON_CONTENT_WIDTH)
- * + = padding (2 px) (ICON_PADDING_RIGHT) (cut by the fixed_size)
- * _ = spacing between cells, can not be handled (2 px)
- * t = the text (expands)
- * b = bookmark icon (16 px)
- * + = padding (6 px) (BKMK_PADDING_RIGHT)
- * _ = widget spacing, can not be handled (2 px)
- *
- * Each character is a pixel.
- *
- * The text cell and the bookmark icon cell are much more
- * flexible in its aligment, because they do not have to align
- * with anything in the entry.
- */
+ GtkEntryCompletion *completion;
+ GtkCellRenderer *cell;
+
+ entry->text_col = text_col;
+ entry->action_col = action_col;
+ entry->keywords_col = keywords_col;
+ entry->relevance_col = relevance_col;
+ entry->url_col = url_col;
+ entry->extra_col = extra_col;
+ entry->favicon_col = favicon_col;
+
+ completion = gtk_entry_completion_new ();
+ gtk_entry_completion_set_model (completion, model);
+ g_signal_connect (completion, "match-selected",
+ G_CALLBACK (match_selected_cb), entry);
+ g_signal_connect_after (completion, "action-activated",
+ G_CALLBACK (action_activated_after_cb), entry);
+
+ cell = gtk_cell_renderer_pixbuf_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion),
+ cell, FALSE);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
+ cell, "pixbuf", favicon_col);
+
+ /* Pixel-perfect aligment with the location entry favicon
+ * (16x16). Consider that this /might/ depend on the theme.
+ *
+ * The GtkEntryCompletion can not be themed so we work-around
+ * that with padding and fixed sizes.
+ * For the first cell, this is:
+ *
+ * ___+++++iiiiiiiiiiiiiiii++__ttt...bbb++++++__
+ *
+ * _ = widget spacing, can not be handled (3 px)
+ * + = padding (5 px) (ICON_PADDING_LEFT)
+ * i = the icon (16 px) (ICON_CONTENT_WIDTH)
+ * + = padding (2 px) (ICON_PADDING_RIGHT) (cut by the fixed_size)
+ * _ = spacing between cells, can not be handled (2 px)
+ * t = the text (expands)
+ * b = bookmark icon (16 px)
+ * + = padding (6 px) (BKMK_PADDING_RIGHT)
+ * _ = widget spacing, can not be handled (2 px)
+ *
+ * Each character is a pixel.
+ *
+ * The text cell and the bookmark icon cell are much more
+ * flexible in its aligment, because they do not have to align
+ * with anything in the entry.
+ */
#define ROW_PADDING_VERT 4
@@ -1197,64 +1163,64 @@ ephy_location_entry_set_completion (EphyLocationEntry *entry,
#define BKMK_PADDING_RIGHT 6
- gtk_cell_renderer_set_padding
- (cell, ICON_PADDING_LEFT, ROW_PADDING_VERT);
- gtk_cell_renderer_set_fixed_size
- (cell,
- (ICON_PADDING_LEFT + ICON_CONTENT_WIDTH + ICON_PADDING_RIGHT),
- ICON_CONTENT_HEIGHT);
- gtk_cell_renderer_set_alignment (cell, 0.0, 0.5);
-
- cell = gd_two_lines_renderer_new ();
- g_object_set (cell,
- "ellipsize", PANGO_ELLIPSIZE_END,
- "text-lines", 2,
- NULL);
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion),
- cell, TRUE);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
- cell, "text", text_col);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
- cell, "line-two", url_col);
-
- /* Pixel-perfect aligment with the text in the location entry.
- * See above.
- */
- gtk_cell_renderer_set_padding
- (cell, TEXT_PADDING_LEFT, ROW_PADDING_VERT);
- gtk_cell_renderer_set_alignment (cell, 0.0, 0.5);
-
- /*
- * As the width of the entry completion is known in advance
- * (as big as the entry you are completing on), we can set
- * any fixed width (the 1 is just this random number here)
- * Since the height is known too, we avoid computing the actual
- * sizes of the cells, which takes a lot of CPU time and does
- * not get used anyway.
- */
- gtk_cell_renderer_set_fixed_size (cell, 1, -1);
- gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (cell), 2);
-
- cell = gtk_cell_renderer_pixbuf_new ();
- g_object_set (cell, "follow-state", TRUE, NULL);
- gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (completion),
- cell, FALSE);
- gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (completion),
- cell, extracell_data_func,
- entry,
- NULL);
-
- /* Pixel-perfect aligment. This just keeps the same margin from
- * the border than the favicon on the other side. See above. */
- gtk_cell_renderer_set_padding
- (cell, BKMK_PADDING_RIGHT, ROW_PADDING_VERT);
-
- g_object_set (completion, "inline-selection", TRUE, NULL);
- g_signal_connect (completion, "cursor-on-match",
- G_CALLBACK (cursor_on_match_cb), entry);
-
- gtk_entry_set_completion (GTK_ENTRY (entry), completion);
- g_object_unref (completion);
+ gtk_cell_renderer_set_padding
+ (cell, ICON_PADDING_LEFT, ROW_PADDING_VERT);
+ gtk_cell_renderer_set_fixed_size
+ (cell,
+ (ICON_PADDING_LEFT + ICON_CONTENT_WIDTH + ICON_PADDING_RIGHT),
+ ICON_CONTENT_HEIGHT);
+ gtk_cell_renderer_set_alignment (cell, 0.0, 0.5);
+
+ cell = gd_two_lines_renderer_new ();
+ g_object_set (cell,
+ "ellipsize", PANGO_ELLIPSIZE_END,
+ "text-lines", 2,
+ NULL);
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion),
+ cell, TRUE);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
+ cell, "text", text_col);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
+ cell, "line-two", url_col);
+
+ /* Pixel-perfect aligment with the text in the location entry.
+ * See above.
+ */
+ gtk_cell_renderer_set_padding
+ (cell, TEXT_PADDING_LEFT, ROW_PADDING_VERT);
+ gtk_cell_renderer_set_alignment (cell, 0.0, 0.5);
+
+ /*
+ * As the width of the entry completion is known in advance
+ * (as big as the entry you are completing on), we can set
+ * any fixed width (the 1 is just this random number here)
+ * Since the height is known too, we avoid computing the actual
+ * sizes of the cells, which takes a lot of CPU time and does
+ * not get used anyway.
+ */
+ gtk_cell_renderer_set_fixed_size (cell, 1, -1);
+ gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (cell), 2);
+
+ cell = gtk_cell_renderer_pixbuf_new ();
+ g_object_set (cell, "follow-state", TRUE, NULL);
+ gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (completion),
+ cell, FALSE);
+ gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (completion),
+ cell, extracell_data_func,
+ entry,
+ NULL);
+
+ /* Pixel-perfect aligment. This just keeps the same margin from
+ * the border than the favicon on the other side. See above. */
+ gtk_cell_renderer_set_padding
+ (cell, BKMK_PADDING_RIGHT, ROW_PADDING_VERT);
+
+ g_object_set (completion, "inline-selection", TRUE, NULL);
+ g_signal_connect (completion, "cursor-on-match",
+ G_CALLBACK (cursor_on_match_cb), entry);
+
+ gtk_entry_set_completion (GTK_ENTRY (entry), completion);
+ g_object_unref (completion);
}
/**
@@ -1266,76 +1232,70 @@ ephy_location_entry_set_completion (EphyLocationEntry *entry,
**/
void
ephy_location_entry_set_location (EphyLocationEntry *entry,
- const char *address)
+ const char *address)
{
- GtkWidget *widget = GTK_WIDGET (entry);
- GtkClipboard *clipboard;
- const char *text;
- char *effective_text = NULL, *selection = NULL;
- int start, end;
-
- /* Setting a new text will clear the clipboard. This makes it impossible
- * to copy&paste from the location entry of one tab into another tab, see
- * bug #155824. So we save the selection iff the clipboard was owned by
- * the location entry.
- */
- if (gtk_widget_get_realized (widget))
- {
- clipboard = gtk_widget_get_clipboard (widget,
- GDK_SELECTION_PRIMARY);
- g_return_if_fail (clipboard != NULL);
-
- if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (widget) &&
- gtk_editable_get_selection_bounds (GTK_EDITABLE (widget),
- &start, &end))
- {
- selection = gtk_editable_get_chars (GTK_EDITABLE (widget),
- start, end);
- }
- }
-
- if (address != NULL)
- {
- if (g_str_has_prefix (address, EPHY_ABOUT_SCHEME))
- effective_text = g_strdup_printf ("about:%s",
- address + strlen (EPHY_ABOUT_SCHEME) + 1);
- text = address;
- gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_PRIMARY,
- entry->drag_targets,
- entry->drag_actions);
- }
- else
- {
- text = "";
- gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_PRIMARY,
- NULL,
- GDK_ACTION_DEFAULT);
- }
-
- /* First record the new hash, then update the entry text */
- entry->hash = g_str_hash (effective_text ? effective_text : text);
-
- entry->block_update = TRUE;
- gtk_entry_set_text (GTK_ENTRY (widget), effective_text ? effective_text : text);
- entry->block_update = FALSE;
- g_free (effective_text);
-
- /* We need to call update_address_state() here, as the 'changed' signal
- * may not get called if the user has typed in the exact correct url */
- update_address_state (entry);
- update_favicon (entry);
-
- /* Now restore the selection.
- * Note that it's not owned by the entry anymore!
- */
- if (selection != NULL)
- {
- gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_PRIMARY),
- selection, strlen (selection));
- g_free (selection);
- }
+ GtkWidget *widget = GTK_WIDGET (entry);
+ GtkClipboard *clipboard;
+ const char *text;
+ char *effective_text = NULL, *selection = NULL;
+ int start, end;
+
+ /* Setting a new text will clear the clipboard. This makes it impossible
+ * to copy&paste from the location entry of one tab into another tab, see
+ * bug #155824. So we save the selection iff the clipboard was owned by
+ * the location entry.
+ */
+ if (gtk_widget_get_realized (widget)) {
+ clipboard = gtk_widget_get_clipboard (widget,
+ GDK_SELECTION_PRIMARY);
+ g_return_if_fail (clipboard != NULL);
+
+ if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (widget) &&
+ gtk_editable_get_selection_bounds (GTK_EDITABLE (widget),
+ &start, &end)) {
+ selection = gtk_editable_get_chars (GTK_EDITABLE (widget),
+ start, end);
+ }
+ }
+
+ if (address != NULL) {
+ if (g_str_has_prefix (address, EPHY_ABOUT_SCHEME))
+ effective_text = g_strdup_printf ("about:%s",
+ address + strlen (EPHY_ABOUT_SCHEME) + 1);
+ text = address;
+ gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_PRIMARY,
+ entry->drag_targets,
+ entry->drag_actions);
+ } else {
+ text = "";
+ gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_PRIMARY,
+ NULL,
+ GDK_ACTION_DEFAULT);
+ }
+
+ /* First record the new hash, then update the entry text */
+ entry->hash = g_str_hash (effective_text ? effective_text : text);
+
+ entry->block_update = TRUE;
+ gtk_entry_set_text (GTK_ENTRY (widget), effective_text ? effective_text : text);
+ entry->block_update = FALSE;
+ g_free (effective_text);
+
+ /* We need to call update_address_state() here, as the 'changed' signal
+ * may not get called if the user has typed in the exact correct url */
+ update_address_state (entry);
+ update_favicon (entry);
+
+ /* Now restore the selection.
+ * Note that it's not owned by the entry anymore!
+ */
+ if (selection != NULL) {
+ gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_PRIMARY),
+ selection, strlen (selection));
+ g_free (selection);
+ }
}
/**
@@ -1351,7 +1311,7 @@ ephy_location_entry_set_location (EphyLocationEntry *entry,
gboolean
ephy_location_entry_get_can_undo (EphyLocationEntry *entry)
{
- return entry->user_changed;
+ return entry->user_changed;
}
/**
@@ -1367,7 +1327,7 @@ ephy_location_entry_get_can_undo (EphyLocationEntry *entry)
gboolean
ephy_location_entry_get_can_redo (EphyLocationEntry *entry)
{
- return entry->can_redo;
+ return entry->can_redo;
}
/**
@@ -1383,39 +1343,38 @@ ephy_location_entry_get_can_redo (EphyLocationEntry *entry)
const char *
ephy_location_entry_get_location (EphyLocationEntry *entry)
{
- return gtk_entry_get_text (GTK_ENTRY (entry));
+ return gtk_entry_get_text (GTK_ENTRY (entry));
}
static gboolean
ephy_location_entry_reset_internal (EphyLocationEntry *entry,
- gboolean notify)
+ gboolean notify)
{
- const char *text, *old_text;
- char *url = NULL;
- gboolean retval;
+ const char *text, *old_text;
+ char *url = NULL;
+ gboolean retval;
- g_signal_emit (entry, signals[GET_LOCATION], 0, &url);
- text = url != NULL ? url : "";
- old_text = gtk_entry_get_text (GTK_ENTRY (entry));
- old_text = old_text != NULL ? old_text : "";
+ g_signal_emit (entry, signals[GET_LOCATION], 0, &url);
+ text = url != NULL ? url : "";
+ old_text = gtk_entry_get_text (GTK_ENTRY (entry));
+ old_text = old_text != NULL ? old_text : "";
- g_free (entry->saved_text);
- entry->saved_text = g_strdup (old_text);
- entry->can_redo = TRUE;
+ g_free (entry->saved_text);
+ entry->saved_text = g_strdup (old_text);
+ entry->can_redo = TRUE;
- retval = g_str_hash (text) != g_str_hash (old_text);
+ retval = g_str_hash (text) != g_str_hash (old_text);
- ephy_location_entry_set_location (entry, text);
- g_free (url);
+ ephy_location_entry_set_location (entry, text);
+ g_free (url);
- if (notify)
- {
- g_signal_emit (entry, signals[USER_CHANGED], 0);
- }
+ if (notify) {
+ g_signal_emit (entry, signals[USER_CHANGED], 0);
+ }
- entry->user_changed = FALSE;
+ entry->user_changed = FALSE;
- return retval;
+ return retval;
}
/**
@@ -1428,9 +1387,9 @@ ephy_location_entry_reset_internal (EphyLocationEntry *entry,
void
ephy_location_entry_undo_reset (EphyLocationEntry *entry)
{
- gtk_entry_set_text (GTK_ENTRY (entry), entry->saved_text);
- entry->can_redo = FALSE;
- entry->user_changed = TRUE;
+ gtk_entry_set_text (GTK_ENTRY (entry), entry->saved_text);
+ entry->can_redo = FALSE;
+ entry->user_changed = TRUE;
}
/**
@@ -1447,7 +1406,7 @@ ephy_location_entry_undo_reset (EphyLocationEntry *entry)
gboolean
ephy_location_entry_reset (EphyLocationEntry *entry)
{
- return ephy_location_entry_reset_internal (entry, FALSE);
+ return ephy_location_entry_reset_internal (entry, FALSE);
}
/**
@@ -1461,14 +1420,14 @@ ephy_location_entry_reset (EphyLocationEntry *entry)
void
ephy_location_entry_activate (EphyLocationEntry *entry)
{
- GtkWidget *toplevel, *widget = GTK_WIDGET (entry);
+ GtkWidget *toplevel, *widget = GTK_WIDGET (entry);
- toplevel = gtk_widget_get_toplevel (widget);
+ toplevel = gtk_widget_get_toplevel (widget);
- gtk_editable_select_region (GTK_EDITABLE (entry),
- 0, -1);
- gtk_window_set_focus (GTK_WINDOW (toplevel),
- widget);
+ gtk_editable_select_region (GTK_EDITABLE (entry),
+ 0, -1);
+ gtk_window_set_focus (GTK_WINDOW (toplevel),
+ widget);
}
/**
@@ -1481,27 +1440,26 @@ ephy_location_entry_activate (EphyLocationEntry *entry)
**/
void
ephy_location_entry_set_favicon (EphyLocationEntry *entry,
- GdkPixbuf *pixbuf)
+ GdkPixbuf *pixbuf)
{
- if (entry->favicon != NULL)
- {
- g_object_unref (entry->favicon);
- }
+ if (entry->favicon != NULL) {
+ g_object_unref (entry->favicon);
+ }
- entry->favicon = pixbuf ? g_object_ref (pixbuf) : NULL;
+ entry->favicon = pixbuf ? g_object_ref (pixbuf) : NULL;
- update_favicon (entry);
+ update_favicon (entry);
}
void
ephy_location_entry_set_show_favicon (EphyLocationEntry *entry,
- gboolean show_favicon)
+ gboolean show_favicon)
{
- g_return_if_fail (EPHY_IS_LOCATION_ENTRY (entry));
+ g_return_if_fail (EPHY_IS_LOCATION_ENTRY (entry));
- entry->show_favicon = show_favicon != FALSE;
+ entry->show_favicon = show_favicon != FALSE;
- update_favicon (entry);
+ update_favicon (entry);
}
/**
@@ -1514,17 +1472,17 @@ ephy_location_entry_set_show_favicon (EphyLocationEntry *entry,
**/
void
ephy_location_entry_set_security_level (EphyLocationEntry *entry,
- EphySecurityLevel security_level)
+ EphySecurityLevel security_level)
{
- const char *icon_name;
+ const char *icon_name;
- g_return_if_fail (EPHY_IS_LOCATION_ENTRY (entry));
+ g_return_if_fail (EPHY_IS_LOCATION_ENTRY (entry));
- icon_name = ephy_security_level_to_icon_name (security_level);
- gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_SECONDARY,
- icon_name);
+ icon_name = ephy_security_level_to_icon_name (security_level);
+ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ icon_name);
}
/**
@@ -1537,11 +1495,11 @@ ephy_location_entry_set_security_level (EphyLocationEntry *entry,
**/
void
ephy_location_entry_set_lock_tooltip (EphyLocationEntry *entry,
- const char *tooltip)
+ const char *tooltip)
{
- gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_SECONDARY,
- tooltip);
+ gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ tooltip);
}
/**
@@ -1557,5 +1515,5 @@ ephy_location_entry_set_lock_tooltip (EphyLocationEntry *entry,
GSList *
ephy_location_entry_get_search_terms (EphyLocationEntry *entry)
{
- return entry->search_terms;
+ return entry->search_terms;
}
diff --git a/lib/widgets/ephy-middle-clickable-button.c b/lib/widgets/ephy-middle-clickable-button.c
index aa7ad55..c9bf478 100644
--- a/lib/widgets/ephy-middle-clickable-button.c
+++ b/lib/widgets/ephy-middle-clickable-button.c
@@ -20,16 +20,15 @@
#include "config.h"
#include "ephy-middle-clickable-button.h"
-struct _EphyMiddleClickableButton
-{
+struct _EphyMiddleClickableButton {
GtkButton parent_instance;
};
G_DEFINE_TYPE (EphyMiddleClickableButton, ephy_middle_clickable_button, GTK_TYPE_BUTTON)
-static gboolean
-ephy_middle_clickable_button_handle_event (GtkWidget * widget,
- GdkEventButton * event)
+static gboolean
+ephy_middle_clickable_button_handle_event (GtkWidget *widget,
+ GdkEventButton *event)
{
gboolean ret;
int actual_button;
@@ -44,7 +43,7 @@ ephy_middle_clickable_button_handle_event (GtkWidget * widget,
ret = widget_class->button_press_event (widget, event);
else
ret = widget_class->button_release_event (widget, event);
-
+
event->button = actual_button;
return ret;
diff --git a/lib/widgets/ephy-node-view.c b/lib/widgets/ephy-node-view.c
index efc2213..f9361f5 100644
--- a/lib/widgets/ephy-node-view.c
+++ b/lib/widgets/ephy-node-view.c
@@ -1,5 +1,5 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* Copyright © 2002 Jorn Baayen <jorn nl linux org>
*
* This program is free software; you can redistribute it and/or modify
@@ -36,63 +36,60 @@
* elements. It implements drag and dropping.
*/
-struct _EphyNodeView
-{
- GtkTreeView parent_instance;
+struct _EphyNodeView {
+ GtkTreeView parent_instance;
- EphyNode *root;
+ EphyNode *root;
- EphyTreeModelNode *nodemodel;
- GtkTreeModel *filtermodel;
- GtkTreeModel *sortmodel;
- GtkCellRenderer *editable_renderer;
- GtkTreeViewColumn *editable_column;
- int editable_node_column;
- int toggle_column;
+ EphyTreeModelNode *nodemodel;
+ GtkTreeModel *filtermodel;
+ GtkTreeModel *sortmodel;
+ GtkCellRenderer *editable_renderer;
+ GtkTreeViewColumn *editable_column;
+ int editable_node_column;
+ int toggle_column;
- EphyNodeFilter *filter;
+ EphyNodeFilter *filter;
- GtkTargetList *drag_targets;
+ GtkTargetList *drag_targets;
- int sort_column;
- GtkSortType sort_type;
- guint priority_prop_id;
- int priority_column;
+ int sort_column;
+ GtkSortType sort_type;
+ guint priority_prop_id;
+ int priority_column;
- EphyNode *edited_node;
- gboolean remove_if_cancelled;
- int editable_property;
+ EphyNode *edited_node;
+ gboolean remove_if_cancelled;
+ int editable_property;
- gboolean drag_started;
- int drag_button;
- int drag_x;
- int drag_y;
- GtkTargetList *source_target_list;
+ gboolean drag_started;
+ int drag_button;
+ int drag_x;
+ int drag_y;
+ GtkTargetList *source_target_list;
- gboolean drop_occurred;
- gboolean have_drag_data;
- GtkSelectionData *drag_data;
- guint scroll_id;
+ gboolean drop_occurred;
+ gboolean have_drag_data;
+ GtkSelectionData *drag_data;
+ guint scroll_id;
- guint changing_selection : 1;
+ guint changing_selection : 1;
};
-enum
-{
- NODE_TOGGLED,
- NODE_ACTIVATED,
- NODE_SELECTED,
- NODE_DROPPED,
- NODE_MIDDLE_CLICKED,
- LAST_SIGNAL
+enum {
+ NODE_TOGGLED,
+ NODE_ACTIVATED,
+ NODE_SELECTED,
+ NODE_DROPPED,
+ NODE_MIDDLE_CLICKED,
+ LAST_SIGNAL
};
-enum
-{
- PROP_0,
- PROP_ROOT,
- PROP_FILTER,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_ROOT,
+ PROP_FILTER,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
@@ -106,321 +103,297 @@ G_DEFINE_TYPE (EphyNodeView, ephy_node_view, GTK_TYPE_TREE_VIEW)
static void
ephy_node_view_finalize (GObject *object)
{
- EphyNodeView *view = EPHY_NODE_VIEW (object);
+ EphyNodeView *view = EPHY_NODE_VIEW (object);
- g_object_unref (view->sortmodel);
- g_object_unref (view->filtermodel);
- g_object_unref (view->nodemodel);
+ g_object_unref (view->sortmodel);
+ g_object_unref (view->filtermodel);
+ g_object_unref (view->nodemodel);
- if (view->source_target_list)
- {
- gtk_target_list_unref (view->source_target_list);
- }
+ if (view->source_target_list) {
+ gtk_target_list_unref (view->source_target_list);
+ }
- if (view->drag_targets)
- {
- gtk_target_list_unref (view->drag_targets);
- }
+ if (view->drag_targets) {
+ gtk_target_list_unref (view->drag_targets);
+ }
- G_OBJECT_CLASS (ephy_node_view_parent_class)->finalize (object);
+ G_OBJECT_CLASS (ephy_node_view_parent_class)->finalize (object);
}
static EphyNode *
get_node_from_path (EphyNodeView *view, GtkTreePath *path)
{
- EphyNode *node;
- GtkTreeIter iter, iter2, iter3;
+ EphyNode *node;
+ GtkTreeIter iter, iter2, iter3;
- if (path == NULL) return NULL;
+ if (path == NULL) return NULL;
- gtk_tree_model_get_iter (view->sortmodel, &iter, path);
- gtk_tree_model_sort_convert_iter_to_child_iter
- (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
+ gtk_tree_model_get_iter (view->sortmodel, &iter, path);
+ gtk_tree_model_sort_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
- if (iter2.stamp == 0) {
- return NULL;
- }
- gtk_tree_model_filter_convert_iter_to_child_iter
- (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter3, &iter2);
+ if (iter2.stamp == 0) {
+ return NULL;
+ }
+ gtk_tree_model_filter_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter3, &iter2);
- node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter3);
+ node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter3);
- return node;
+ return node;
}
static void
gtk_tree_view_vertical_autoscroll (GtkTreeView *tree_view)
{
- GdkRectangle visible_rect;
- GtkAdjustment *vadjustment;
- GdkWindow *window;
- int y;
- int offset;
- float value;
-
- window = gtk_tree_view_get_bin_window (tree_view);
- vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (tree_view));
-
- gdk_window_get_device_position (window,
- gdk_device_manager_get_client_pointer (
- gdk_display_get_device_manager (
- gtk_widget_get_display (GTK_WIDGET (tree_view)))),
- NULL, &y, NULL);
-
- y += gtk_adjustment_get_value (vadjustment);
-
- gtk_tree_view_get_visible_rect (tree_view, &visible_rect);
-
- offset = y - (visible_rect.y + 2 * AUTO_SCROLL_MARGIN);
- if (offset > 0)
- {
- offset = y - (visible_rect.y + visible_rect.height - 2 * AUTO_SCROLL_MARGIN);
- if (offset < 0)
- {
- return;
- }
- }
-
- value = CLAMP (gtk_adjustment_get_value (vadjustment) + offset, 0.0,
- gtk_adjustment_get_upper (vadjustment) - gtk_adjustment_get_page_size (vadjustment));
- gtk_adjustment_set_value (vadjustment, value);
+ GdkRectangle visible_rect;
+ GtkAdjustment *vadjustment;
+ GdkWindow *window;
+ int y;
+ int offset;
+ float value;
+
+ window = gtk_tree_view_get_bin_window (tree_view);
+ vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (tree_view));
+
+ gdk_window_get_device_position (window,
+ gdk_device_manager_get_client_pointer (
+ gdk_display_get_device_manager (
+ gtk_widget_get_display (GTK_WIDGET (tree_view)))),
+ NULL, &y, NULL);
+
+ y += gtk_adjustment_get_value (vadjustment);
+
+ gtk_tree_view_get_visible_rect (tree_view, &visible_rect);
+
+ offset = y - (visible_rect.y + 2 * AUTO_SCROLL_MARGIN);
+ if (offset > 0) {
+ offset = y - (visible_rect.y + visible_rect.height - 2 * AUTO_SCROLL_MARGIN);
+ if (offset < 0) {
+ return;
+ }
+ }
+
+ value = CLAMP (gtk_adjustment_get_value (vadjustment) + offset, 0.0,
+ gtk_adjustment_get_upper (vadjustment) - gtk_adjustment_get_page_size (vadjustment));
+ gtk_adjustment_set_value (vadjustment, value);
}
static int
scroll_timeout (gpointer data)
{
- GtkTreeView *tree_view = GTK_TREE_VIEW (data);
+ GtkTreeView *tree_view = GTK_TREE_VIEW (data);
- gtk_tree_view_vertical_autoscroll (tree_view);
+ gtk_tree_view_vertical_autoscroll (tree_view);
- return TRUE;
+ return TRUE;
}
static void
remove_scroll_timeout (EphyNodeView *view)
{
- if (view->scroll_id)
- {
- g_source_remove (view->scroll_id);
- view->scroll_id = 0;
- }
+ if (view->scroll_id) {
+ g_source_remove (view->scroll_id);
+ view->scroll_id = 0;
+ }
}
static void
set_drag_dest_row (EphyNodeView *view,
- GtkTreePath *path)
-{
- if (path)
- {
- gtk_tree_view_set_drag_dest_row
- (GTK_TREE_VIEW (view),
- path,
- GTK_TREE_VIEW_DROP_INTO_OR_BEFORE);
- }
- else
- {
- gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (view),
- NULL,
- 0);
- }
+ GtkTreePath *path)
+{
+ if (path) {
+ gtk_tree_view_set_drag_dest_row
+ (GTK_TREE_VIEW (view),
+ path,
+ GTK_TREE_VIEW_DROP_INTO_OR_BEFORE);
+ } else {
+ gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (view),
+ NULL,
+ 0);
+ }
}
static void
clear_drag_dest_row (EphyNodeView *view)
{
- gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (view), NULL, 0);
+ gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (view), NULL, 0);
}
static void
-get_drag_data (EphyNodeView *view,
- GdkDragContext *context,
- guint32 time)
+get_drag_data (EphyNodeView *view,
+ GdkDragContext *context,
+ guint32 time)
{
- GdkAtom target;
+ GdkAtom target;
- target = gtk_drag_dest_find_target (GTK_WIDGET (view),
- context,
- NULL);
+ target = gtk_drag_dest_find_target (GTK_WIDGET (view),
+ context,
+ NULL);
- gtk_drag_get_data (GTK_WIDGET (view),
- context, target, time);
+ gtk_drag_get_data (GTK_WIDGET (view),
+ context, target, time);
}
static void
free_drag_data (EphyNodeView *view)
{
- view->have_drag_data = FALSE;
+ view->have_drag_data = FALSE;
- if (view->drag_data)
- {
- gtk_selection_data_free (view->drag_data);
- view->drag_data = NULL;
- }
+ if (view->drag_data) {
+ gtk_selection_data_free (view->drag_data);
+ view->drag_data = NULL;
+ }
}
static gboolean
-drag_motion_cb (GtkWidget *widget,
- GdkDragContext *context,
- int x,
- int y,
- guint32 time,
- EphyNodeView *view)
-{
- EphyNode *node;
- GdkAtom target;
- GtkTreePath *path;
- GtkTreeViewDropPosition pos;
- guint action = 0;
- int priority;
-
- gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget),
- x, y, &path, &pos);
-
- if (!view->have_drag_data)
- {
- get_drag_data (view, context, time);
- }
-
- target = gtk_drag_dest_find_target (widget, context, NULL);
- node = get_node_from_path (view, path);
-
- if (target != GDK_NONE && node != NULL)
- {
- priority = ephy_node_get_property_int (node, view->priority_prop_id);
-
- if (priority != EPHY_NODE_VIEW_ALL_PRIORITY &&
- priority != EPHY_NODE_VIEW_SPECIAL_PRIORITY &&
- ephy_node_get_is_drag_source (node))
- {
- action = gdk_drag_context_get_suggested_action (context);
- }
- }
-
- if (action)
- {
- set_drag_dest_row (view, path);
- }
- else
- {
- clear_drag_dest_row (view);
- }
-
- if (path)
- {
- gtk_tree_path_free (path);
- }
-
- if (view->scroll_id == 0)
- {
- view->scroll_id =
- g_timeout_add (150,
- scroll_timeout,
- GTK_TREE_VIEW (view));
- g_source_set_name_by_id (view->scroll_id, "[epiphany] scroll_timeout");
- }
-
- gdk_drag_status (context, action, time);
-
- return TRUE;
+drag_motion_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ int x,
+ int y,
+ guint32 time,
+ EphyNodeView *view)
+{
+ EphyNode *node;
+ GdkAtom target;
+ GtkTreePath *path;
+ GtkTreeViewDropPosition pos;
+ guint action = 0;
+ int priority;
+
+ gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget),
+ x, y, &path, &pos);
+
+ if (!view->have_drag_data) {
+ get_drag_data (view, context, time);
+ }
+
+ target = gtk_drag_dest_find_target (widget, context, NULL);
+ node = get_node_from_path (view, path);
+
+ if (target != GDK_NONE && node != NULL) {
+ priority = ephy_node_get_property_int (node, view->priority_prop_id);
+
+ if (priority != EPHY_NODE_VIEW_ALL_PRIORITY &&
+ priority != EPHY_NODE_VIEW_SPECIAL_PRIORITY &&
+ ephy_node_get_is_drag_source (node)) {
+ action = gdk_drag_context_get_suggested_action (context);
+ }
+ }
+
+ if (action) {
+ set_drag_dest_row (view, path);
+ } else {
+ clear_drag_dest_row (view);
+ }
+
+ if (path) {
+ gtk_tree_path_free (path);
+ }
+
+ if (view->scroll_id == 0) {
+ view->scroll_id =
+ g_timeout_add (150,
+ scroll_timeout,
+ GTK_TREE_VIEW (view));
+ g_source_set_name_by_id (view->scroll_id, "[epiphany] scroll_timeout");
+ }
+
+ gdk_drag_status (context, action, time);
+
+ return TRUE;
}
static void
-drag_leave_cb (GtkWidget *widget,
- GdkDragContext *context,
- guint32 time,
- EphyNodeView *view)
+drag_leave_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ guint32 time,
+ EphyNodeView *view)
{
- clear_drag_dest_row (view);
+ clear_drag_dest_row (view);
- free_drag_data (view);
+ free_drag_data (view);
- remove_scroll_timeout (view);
+ remove_scroll_timeout (view);
}
static void
-drag_data_received_cb (GtkWidget *widget,
- GdkDragContext *context,
- int x,
- int y,
- GtkSelectionData *selection_data,
- guint info,
- guint32 time,
- EphyNodeView *view)
-{
- GtkTreeViewDropPosition pos;
-
- /* x and y here are valid only on drop ! */
-
- if ((gtk_selection_data_get_length (selection_data) <= 0) ||
- (gtk_selection_data_get_data (selection_data) == NULL))
- {
- return;
- }
-
- /* appease GtkTreeView by preventing its drag_data_receive
- * from being called */
- g_signal_stop_emission_by_name (view, "drag_data_received");
-
- if (!view->have_drag_data)
- {
- view->have_drag_data = TRUE;
- view->drag_data = gtk_selection_data_copy (selection_data);
- }
-
- if (view->drop_occurred)
- {
- EphyNode *node;
- char **uris;
- gboolean success = FALSE;
- GtkTreePath *path;
-
- if (gtk_tree_view_get_dest_row_at_pos
- (GTK_TREE_VIEW (widget), x, y, &path, &pos) == FALSE)
- {
- return;
- }
-
- node = get_node_from_path (view, path);
- if (node == NULL) return;
-
- uris = gtk_selection_data_get_uris (selection_data);
-
- if (uris != NULL && ephy_node_get_is_drag_dest (node))
- {
- /* FIXME fill success */
- g_signal_emit (G_OBJECT (view),
- ephy_node_view_signals[NODE_DROPPED], 0,
- node, uris);
- g_strfreev (uris);
-
- }
-
- view->drop_occurred = FALSE;
- free_drag_data (view);
- gtk_drag_finish (context, success, FALSE, time);
-
- if (path)
- {
- gtk_tree_path_free (path);
- }
- }
+drag_data_received_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ int x,
+ int y,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint32 time,
+ EphyNodeView *view)
+{
+ GtkTreeViewDropPosition pos;
+
+ /* x and y here are valid only on drop ! */
+
+ if ((gtk_selection_data_get_length (selection_data) <= 0) ||
+ (gtk_selection_data_get_data (selection_data) == NULL)) {
+ return;
+ }
+
+ /* appease GtkTreeView by preventing its drag_data_receive
+ * from being called */
+ g_signal_stop_emission_by_name (view, "drag_data_received");
+
+ if (!view->have_drag_data) {
+ view->have_drag_data = TRUE;
+ view->drag_data = gtk_selection_data_copy (selection_data);
+ }
+
+ if (view->drop_occurred) {
+ EphyNode *node;
+ char **uris;
+ gboolean success = FALSE;
+ GtkTreePath *path;
+
+ if (gtk_tree_view_get_dest_row_at_pos
+ (GTK_TREE_VIEW (widget), x, y, &path, &pos) == FALSE) {
+ return;
+ }
+
+ node = get_node_from_path (view, path);
+ if (node == NULL) return;
+
+ uris = gtk_selection_data_get_uris (selection_data);
+
+ if (uris != NULL && ephy_node_get_is_drag_dest (node)) {
+ /* FIXME fill success */
+ g_signal_emit (G_OBJECT (view),
+ ephy_node_view_signals[NODE_DROPPED], 0,
+ node, uris);
+ g_strfreev (uris);
+ }
+
+ view->drop_occurred = FALSE;
+ free_drag_data (view);
+ gtk_drag_finish (context, success, FALSE, time);
+
+ if (path) {
+ gtk_tree_path_free (path);
+ }
+ }
}
static gboolean
-drag_drop_cb (GtkWidget *widget,
- GdkDragContext *context,
- int x,
- int y,
- guint32 time,
- EphyNodeView *view)
+drag_drop_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ int x,
+ int y,
+ guint32 time,
+ EphyNodeView *view)
{
- view->drop_occurred = TRUE;
+ view->drop_occurred = TRUE;
- get_drag_data (view, context, time);
- remove_scroll_timeout (view);
- clear_drag_dest_row (view);
+ get_drag_data (view, context, time);
+ remove_scroll_timeout (view);
+ clear_drag_dest_row (view);
- return TRUE;
+ return TRUE;
}
/**
@@ -433,526 +406,490 @@ drag_drop_cb (GtkWidget *widget,
*
**/
void
-ephy_node_view_enable_drag_dest (EphyNodeView *view,
- const GtkTargetEntry *types,
- int n_types)
+ephy_node_view_enable_drag_dest (EphyNodeView *view,
+ const GtkTargetEntry *types,
+ int n_types)
{
- GtkWidget *treeview;
+ GtkWidget *treeview;
- g_return_if_fail (view != NULL);
+ g_return_if_fail (view != NULL);
- treeview = GTK_WIDGET (view);
+ treeview = GTK_WIDGET (view);
- gtk_drag_dest_set (GTK_WIDGET (treeview),
- 0, types, n_types,
- GDK_ACTION_COPY);
- view->drag_targets = gtk_target_list_new (types, n_types);
+ gtk_drag_dest_set (GTK_WIDGET (treeview),
+ 0, types, n_types,
+ GDK_ACTION_COPY);
+ view->drag_targets = gtk_target_list_new (types, n_types);
- g_signal_connect (treeview, "drag_data_received",
- G_CALLBACK (drag_data_received_cb), view);
- g_signal_connect (treeview, "drag_drop",
- G_CALLBACK (drag_drop_cb), view);
- g_signal_connect (treeview, "drag_motion",
- G_CALLBACK (drag_motion_cb), view);
- g_signal_connect (treeview, "drag_leave",
- G_CALLBACK (drag_leave_cb), view);
+ g_signal_connect (treeview, "drag_data_received",
+ G_CALLBACK (drag_data_received_cb), view);
+ g_signal_connect (treeview, "drag_drop",
+ G_CALLBACK (drag_drop_cb), view);
+ g_signal_connect (treeview, "drag_motion",
+ G_CALLBACK (drag_motion_cb), view);
+ g_signal_connect (treeview, "drag_leave",
+ G_CALLBACK (drag_leave_cb), view);
}
static void
filter_changed_cb (EphyNodeFilter *filter,
- EphyNodeView *view)
+ EphyNodeView *view)
{
- GtkWidget *window;
- GdkWindow *gdk_window;
+ GtkWidget *window;
+ GdkWindow *gdk_window;
- g_return_if_fail (EPHY_IS_NODE_VIEW (view));
+ g_return_if_fail (EPHY_IS_NODE_VIEW (view));
- window = gtk_widget_get_toplevel (GTK_WIDGET (view));
- gdk_window = gtk_widget_get_window (window);
+ window = gtk_widget_get_toplevel (GTK_WIDGET (view));
+ gdk_window = gtk_widget_get_window (window);
- if (window != NULL && gdk_window != NULL)
- {
- /* nice busy cursor */
- GdkCursor *cursor;
+ if (window != NULL && gdk_window != NULL) {
+ /* nice busy cursor */
+ GdkCursor *cursor;
- cursor = gdk_cursor_new (GDK_WATCH);
- gdk_window_set_cursor (gdk_window, cursor);
- g_object_unref (cursor);
+ cursor = gdk_cursor_new (GDK_WATCH);
+ gdk_window_set_cursor (gdk_window, cursor);
+ g_object_unref (cursor);
- gdk_flush ();
+ gdk_flush ();
- gdk_window_set_cursor (gdk_window, NULL);
+ gdk_window_set_cursor (gdk_window, NULL);
- /* no flush: this will cause the cursor to be reset
- * only when the UI is free again */
- }
+ /* no flush: this will cause the cursor to be reset
+ * only when the UI is free again */
+ }
- gtk_tree_model_filter_refilter
- (GTK_TREE_MODEL_FILTER (view->filtermodel));
+ gtk_tree_model_filter_refilter
+ (GTK_TREE_MODEL_FILTER (view->filtermodel));
}
static void
ephy_node_view_selection_changed_cb (GtkTreeSelection *selection,
- EphyNodeView *view)
+ EphyNodeView *view)
{
- GList *list;
- EphyNode *node = NULL;
+ GList *list;
+ EphyNode *node = NULL;
- /* Work around bug #346662 */
- if (view->changing_selection) return;
+ /* Work around bug #346662 */
+ if (view->changing_selection) return;
- list = ephy_node_view_get_selection (view);
- if (list)
- {
- node = list->data;
- }
- g_list_free (list);
+ list = ephy_node_view_get_selection (view);
+ if (list) {
+ node = list->data;
+ }
+ g_list_free (list);
- g_signal_emit (G_OBJECT (view), ephy_node_view_signals[NODE_SELECTED], 0, node);
+ g_signal_emit (G_OBJECT (view), ephy_node_view_signals[NODE_SELECTED], 0, node);
}
static void
-ephy_node_view_row_activated_cb (GtkTreeView *treeview,
- GtkTreePath *path,
- GtkTreeViewColumn *column,
- EphyNodeView *view)
+ephy_node_view_row_activated_cb (GtkTreeView *treeview,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ EphyNodeView *view)
{
- GtkTreeIter iter, iter2;
- EphyNode *node;
+ GtkTreeIter iter, iter2;
+ EphyNode *node;
- gtk_tree_model_get_iter (view->sortmodel, &iter, path);
- gtk_tree_model_sort_convert_iter_to_child_iter
- (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
- gtk_tree_model_filter_convert_iter_to_child_iter
- (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
+ gtk_tree_model_get_iter (view->sortmodel, &iter, path);
+ gtk_tree_model_sort_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
+ gtk_tree_model_filter_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
- node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
+ node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
- g_signal_emit (G_OBJECT (view), ephy_node_view_signals[NODE_ACTIVATED], 0, node);
+ g_signal_emit (G_OBJECT (view), ephy_node_view_signals[NODE_ACTIVATED], 0, node);
}
static void
path_toggled (GtkTreeModel *dummy_model, GtkTreePath *path,
- GtkTreeIter *dummy, gpointer data)
-{
- EphyNodeView *view = EPHY_NODE_VIEW (data);
- gboolean checked;
- EphyNode *node;
- GtkTreeIter iter, iter2;
- GValue value = {0, };
-
- gtk_tree_model_get_iter (view->sortmodel, &iter, path);
- gtk_tree_model_sort_convert_iter_to_child_iter
- (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
- gtk_tree_model_filter_convert_iter_to_child_iter
- (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
-
- node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
- gtk_tree_model_get_value (GTK_TREE_MODEL (view->nodemodel), &iter,
- view->toggle_column, &value);
- checked = !g_value_get_boolean (&value);
-
- g_signal_emit (G_OBJECT (view), ephy_node_view_signals[NODE_TOGGLED], 0,
- node, checked);
+ GtkTreeIter *dummy, gpointer data)
+{
+ EphyNodeView *view = EPHY_NODE_VIEW (data);
+ gboolean checked;
+ EphyNode *node;
+ GtkTreeIter iter, iter2;
+ GValue value = { 0, };
+
+ gtk_tree_model_get_iter (view->sortmodel, &iter, path);
+ gtk_tree_model_sort_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
+ gtk_tree_model_filter_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
+
+ node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
+ gtk_tree_model_get_value (GTK_TREE_MODEL (view->nodemodel), &iter,
+ view->toggle_column, &value);
+ checked = !g_value_get_boolean (&value);
+
+ g_signal_emit (G_OBJECT (view), ephy_node_view_signals[NODE_TOGGLED], 0,
+ node, checked);
}
static EphyNode *
-process_middle_click (GtkTreePath *path,
- EphyNodeView *view)
+process_middle_click (GtkTreePath *path,
+ EphyNodeView *view)
{
- EphyNode *node;
- GtkTreeIter iter, iter2;
+ EphyNode *node;
+ GtkTreeIter iter, iter2;
- gtk_tree_model_get_iter (view->sortmodel, &iter, path);
- gtk_tree_model_sort_convert_iter_to_child_iter
- (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
- gtk_tree_model_filter_convert_iter_to_child_iter
- (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
+ gtk_tree_model_get_iter (view->sortmodel, &iter, path);
+ gtk_tree_model_sort_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
+ gtk_tree_model_filter_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
- node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
+ node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
- return node;
+ return node;
}
static gboolean
-ephy_node_view_key_press_cb (GtkTreeView *treeview,
- GdkEventKey *event,
- EphyNodeView *view)
-{
- gboolean handled = FALSE;
-
- if (event->keyval == GDK_KEY_space ||
- event->keyval == GDK_KEY_Return ||
- event->keyval == GDK_KEY_KP_Enter ||
- event->keyval == GDK_KEY_ISO_Enter)
- {
- if (view->toggle_column >= 0)
- {
- GtkTreeSelection *selection;
-
- selection = gtk_tree_view_get_selection (treeview);
- gtk_tree_selection_selected_foreach (selection, path_toggled, view);
- handled = TRUE;
- }
- }
-
- return handled;
+ephy_node_view_key_press_cb (GtkTreeView *treeview,
+ GdkEventKey *event,
+ EphyNodeView *view)
+{
+ gboolean handled = FALSE;
+
+ if (event->keyval == GDK_KEY_space ||
+ event->keyval == GDK_KEY_Return ||
+ event->keyval == GDK_KEY_KP_Enter ||
+ event->keyval == GDK_KEY_ISO_Enter) {
+ if (view->toggle_column >= 0) {
+ GtkTreeSelection *selection;
+
+ selection = gtk_tree_view_get_selection (treeview);
+ gtk_tree_selection_selected_foreach (selection, path_toggled, view);
+ handled = TRUE;
+ }
+ }
+
+ return handled;
}
static void
selection_foreach (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data)
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data)
{
- GList **list;
+ GList **list;
- list = (GList**)data;
+ list = (GList **)data;
- *list = g_list_prepend (*list, gtk_tree_row_reference_new (model, path));
+ *list = g_list_prepend (*list, gtk_tree_row_reference_new (model, path));
}
static GList *
get_selection_refs (GtkTreeView *tree_view)
{
- GtkTreeSelection *selection;
- GList *ref_list = NULL;
-
- selection = gtk_tree_view_get_selection (tree_view);
- gtk_tree_selection_selected_foreach (selection,
- selection_foreach,
- &ref_list);
- ref_list = g_list_reverse (ref_list);
- return ref_list;
+ GtkTreeSelection *selection;
+ GList *ref_list = NULL;
+
+ selection = gtk_tree_view_get_selection (tree_view);
+ gtk_tree_selection_selected_foreach (selection,
+ selection_foreach,
+ &ref_list);
+ ref_list = g_list_reverse (ref_list);
+ return ref_list;
}
static void
ref_list_free (GList *ref_list)
{
- g_list_foreach (ref_list, (GFunc) gtk_tree_row_reference_free, NULL);
- g_list_free (ref_list);
+ g_list_foreach (ref_list, (GFunc)gtk_tree_row_reference_free, NULL);
+ g_list_free (ref_list);
}
static void
stop_drag_check (EphyNodeView *view)
{
- view->drag_button = 0;
+ view->drag_button = 0;
}
static gboolean
button_event_modifies_selection (GdkEventButton *event)
{
- return (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) != 0;
+ return (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) != 0;
}
static void
-did_not_drag (EphyNodeView *view,
- GdkEventButton *event)
-{
- GtkTreeView *tree_view;
- GtkTreeSelection *selection;
- GtkTreePath *path;
-
- tree_view = GTK_TREE_VIEW (view);
- selection = gtk_tree_view_get_selection (tree_view);
-
- if (gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y,
- &path, NULL, NULL, NULL))
- {
- if((event->button == 1 || event->button == 2) &&
- gtk_tree_selection_path_is_selected (selection, path) &&
- !button_event_modifies_selection (event))
- {
- if (gtk_tree_selection_get_mode (selection) == GTK_SELECTION_MULTIPLE)
- {
- gtk_tree_selection_unselect_all (selection);
- }
-
- gtk_tree_selection_select_path (selection, path);
- }
-
- gtk_tree_path_free (path);
- }
+did_not_drag (EphyNodeView *view,
+ GdkEventButton *event)
+{
+ GtkTreeView *tree_view;
+ GtkTreeSelection *selection;
+ GtkTreePath *path;
+
+ tree_view = GTK_TREE_VIEW (view);
+ selection = gtk_tree_view_get_selection (tree_view);
+
+ if (gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y,
+ &path, NULL, NULL, NULL)) {
+ if ((event->button == 1 || event->button == 2) &&
+ gtk_tree_selection_path_is_selected (selection, path) &&
+ !button_event_modifies_selection (event)) {
+ if (gtk_tree_selection_get_mode (selection) == GTK_SELECTION_MULTIPLE) {
+ gtk_tree_selection_unselect_all (selection);
+ }
+
+ gtk_tree_selection_select_path (selection, path);
+ }
+
+ gtk_tree_path_free (path);
+ }
}
-typedef struct
-{
- EphyNodeView *view;
- gboolean result;
+typedef struct {
+ EphyNodeView *view;
+ gboolean result;
}
ForeachData;
static void
check_node_is_drag_source (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- ForeachData *data)
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ ForeachData *data)
{
- EphyNode *node;
+ EphyNode *node;
- node = get_node_from_path (data->view, path);
- data->result = data->result &&
- node != NULL &&
- ephy_node_get_is_drag_source (node);
+ node = get_node_from_path (data->view, path);
+ data->result = data->result &&
+ node != NULL &&
+ ephy_node_get_is_drag_source (node);
}
static gboolean
can_drag_selection (EphyNodeView *view)
{
- GtkTreeView *tree_view = GTK_TREE_VIEW (view);
- GtkTreeSelection *selection;
- ForeachData data = { view, TRUE };
+ GtkTreeView *tree_view = GTK_TREE_VIEW (view);
+ GtkTreeSelection *selection;
+ ForeachData data = { view, TRUE };
- selection = gtk_tree_view_get_selection (tree_view);
- gtk_tree_selection_selected_foreach (selection,
- (GtkTreeSelectionForeachFunc) check_node_is_drag_source,
- &data);
+ selection = gtk_tree_view_get_selection (tree_view);
+ gtk_tree_selection_selected_foreach (selection,
+ (GtkTreeSelectionForeachFunc)check_node_is_drag_source,
+ &data);
- return data.result;
+ return data.result;
}
static void
-drag_data_get_cb (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint info,
- guint time)
+drag_data_get_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint time)
{
- GtkTreeView *tree_view;
- GtkTreeModel *model;
- GList *ref_list;
+ GtkTreeView *tree_view;
+ GtkTreeModel *model;
+ GList *ref_list;
- tree_view = GTK_TREE_VIEW (widget);
+ tree_view = GTK_TREE_VIEW (widget);
- model = gtk_tree_view_get_model (tree_view);
- g_return_if_fail (model != NULL);
+ model = gtk_tree_view_get_model (tree_view);
+ g_return_if_fail (model != NULL);
- ref_list = g_object_get_data (G_OBJECT (context), "drag-info");
+ ref_list = g_object_get_data (G_OBJECT (context), "drag-info");
- if (ref_list == NULL)
- {
- return;
- }
+ if (ref_list == NULL) {
+ return;
+ }
- if (EGG_IS_TREE_MULTI_DRAG_SOURCE (model))
- {
- egg_tree_multi_drag_source_drag_data_get (EGG_TREE_MULTI_DRAG_SOURCE (model),
- ref_list,
- selection_data);
- }
+ if (EGG_IS_TREE_MULTI_DRAG_SOURCE (model)) {
+ egg_tree_multi_drag_source_drag_data_get (EGG_TREE_MULTI_DRAG_SOURCE (model),
+ ref_list,
+ selection_data);
+ }
}
static gboolean
-button_release_cb (GtkWidget *widget,
- GdkEventButton *event,
- EphyNodeView *view)
-{
- if ((int)event->button == view->drag_button)
- {
- stop_drag_check (view);
- if (!view->drag_started)
- {
- did_not_drag (view, event);
- return TRUE;
- }
- view->drag_started = FALSE;
- }
- return FALSE;
+button_release_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ EphyNodeView *view)
+{
+ if ((int)event->button == view->drag_button) {
+ stop_drag_check (view);
+ if (!view->drag_started) {
+ did_not_drag (view, event);
+ return TRUE;
+ }
+ view->drag_started = FALSE;
+ }
+ return FALSE;
}
static gboolean
-motion_notify_cb (GtkWidget *widget,
- GdkEventMotion *event,
- EphyNodeView *view)
-{
- GdkDragContext *context;
- GList *ref_list;
-
- if (event->window != gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget)))
- {
- return FALSE;
- }
- if (view->drag_button != 0)
- {
- if (gtk_drag_check_threshold (widget, view->drag_x,
- view->drag_y, event->x,
- event->y)
- && can_drag_selection (view))
- {
- context = gtk_drag_begin
- (widget, view->source_target_list,
- GDK_ACTION_ASK | GDK_ACTION_COPY | GDK_ACTION_LINK,
- view->drag_button,
- (GdkEvent*)event);
-
- stop_drag_check (view);
- view->drag_started = TRUE;
-
- ref_list = get_selection_refs (GTK_TREE_VIEW (widget));
- g_object_set_data_full (G_OBJECT (context),
- "drag-info",
- ref_list,
- (GDestroyNotify)ref_list_free);
-
- gtk_drag_set_icon_default (context);
- }
- }
-
- return TRUE;
+motion_notify_cb (GtkWidget *widget,
+ GdkEventMotion *event,
+ EphyNodeView *view)
+{
+ GdkDragContext *context;
+ GList *ref_list;
+
+ if (event->window != gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget))) {
+ return FALSE;
+ }
+ if (view->drag_button != 0) {
+ if (gtk_drag_check_threshold (widget, view->drag_x,
+ view->drag_y, event->x,
+ event->y)
+ && can_drag_selection (view)) {
+ context = gtk_drag_begin
+ (widget, view->source_target_list,
+ GDK_ACTION_ASK | GDK_ACTION_COPY | GDK_ACTION_LINK,
+ view->drag_button,
+ (GdkEvent *)event);
+
+ stop_drag_check (view);
+ view->drag_started = TRUE;
+
+ ref_list = get_selection_refs (GTK_TREE_VIEW (widget));
+ g_object_set_data_full (G_OBJECT (context),
+ "drag-info",
+ ref_list,
+ (GDestroyNotify)ref_list_free);
+
+ gtk_drag_set_icon_default (context);
+ }
+ }
+
+ return TRUE;
}
static gboolean
-ephy_node_view_button_press_cb (GtkWidget *treeview,
- GdkEventButton *event,
- EphyNodeView *view)
-{
- GtkTreePath *path = NULL;
- GtkTreeSelection *selection;
- gboolean call_parent = TRUE, path_is_selected;
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
-
- if (event->window != gtk_tree_view_get_bin_window (GTK_TREE_VIEW (treeview)))
- {
- return GTK_WIDGET_CLASS (ephy_node_view_parent_class)->button_press_event (treeview, event);
- }
-
- if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (treeview),
- event->x,
- event->y,
- &path,
- NULL, NULL, NULL))
- {
- path_is_selected = gtk_tree_selection_path_is_selected (selection, path);
-
- if (!gtk_widget_is_focus (GTK_WIDGET (treeview)))
- {
- gtk_widget_grab_focus (GTK_WIDGET (treeview));
- }
-
- if (event->button == 3 && path_is_selected)
- {
- call_parent = FALSE;
- }
-
- if(!button_event_modifies_selection (event) &&
- event->button == 1 && path_is_selected &&
- gtk_tree_selection_count_selected_rows (selection) > 1)
- {
- call_parent = FALSE;
- }
-
- if (call_parent)
- {
- GTK_WIDGET_CLASS (ephy_node_view_parent_class)->button_press_event (treeview, event);
- }
-
- if (event->button == 3)
- {
- gboolean retval;
-
- g_signal_emit_by_name (view, "popup_menu", &retval);
- }
- else if (event->button == 2)
- {
- EphyNode *clicked_node;
-
- clicked_node = process_middle_click (path, view);
- g_signal_emit (G_OBJECT (view),
- ephy_node_view_signals[NODE_MIDDLE_CLICKED], 0, clicked_node);
- }
- else if (event->button == 1)
- {
- if (view->toggle_column >= 0)
- {
- path_toggled (NULL, path, NULL, view);
- }
- else
- {
- view->drag_started = FALSE;
- view->drag_button = event->button;
- view->drag_x = event->x;
- view->drag_y = event->y;
- }
- }
-
- gtk_tree_path_free (path);
- }
- else
- {
- gtk_tree_selection_unselect_all (selection);
- }
-
- return TRUE;
+ephy_node_view_button_press_cb (GtkWidget *treeview,
+ GdkEventButton *event,
+ EphyNodeView *view)
+{
+ GtkTreePath *path = NULL;
+ GtkTreeSelection *selection;
+ gboolean call_parent = TRUE, path_is_selected;
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
+
+ if (event->window != gtk_tree_view_get_bin_window (GTK_TREE_VIEW (treeview))) {
+ return GTK_WIDGET_CLASS (ephy_node_view_parent_class)->button_press_event (treeview, event);
+ }
+
+ if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (treeview),
+ event->x,
+ event->y,
+ &path,
+ NULL, NULL, NULL)) {
+ path_is_selected = gtk_tree_selection_path_is_selected (selection, path);
+
+ if (!gtk_widget_is_focus (GTK_WIDGET (treeview))) {
+ gtk_widget_grab_focus (GTK_WIDGET (treeview));
+ }
+
+ if (event->button == 3 && path_is_selected) {
+ call_parent = FALSE;
+ }
+
+ if (!button_event_modifies_selection (event) &&
+ event->button == 1 && path_is_selected &&
+ gtk_tree_selection_count_selected_rows (selection) > 1) {
+ call_parent = FALSE;
+ }
+
+ if (call_parent) {
+ GTK_WIDGET_CLASS (ephy_node_view_parent_class)->button_press_event (treeview, event);
+ }
+
+ if (event->button == 3) {
+ gboolean retval;
+
+ g_signal_emit_by_name (view, "popup_menu", &retval);
+ } else if (event->button == 2) {
+ EphyNode *clicked_node;
+
+ clicked_node = process_middle_click (path, view);
+ g_signal_emit (G_OBJECT (view),
+ ephy_node_view_signals[NODE_MIDDLE_CLICKED], 0, clicked_node);
+ } else if (event->button == 1) {
+ if (view->toggle_column >= 0) {
+ path_toggled (NULL, path, NULL, view);
+ } else {
+ view->drag_started = FALSE;
+ view->drag_button = event->button;
+ view->drag_x = event->x;
+ view->drag_y = event->y;
+ }
+ }
+
+ gtk_tree_path_free (path);
+ } else {
+ gtk_tree_selection_unselect_all (selection);
+ }
+
+ return TRUE;
}
static void
ephy_node_view_set_filter (EphyNodeView *view, EphyNodeFilter *filter)
{
- gboolean refilter = FALSE;
-
- if (view->filter)
- {
- g_object_unref (view->filter);
- refilter = TRUE;
- }
-
- if (filter)
- {
- view->filter = g_object_ref (filter);
- g_signal_connect_object (G_OBJECT (view->filter),
- "changed", G_CALLBACK (filter_changed_cb),
- G_OBJECT (view), 0);
- }
-
- if (refilter)
- {
- gtk_tree_model_filter_refilter
- (GTK_TREE_MODEL_FILTER (view->filtermodel));
- }
+ gboolean refilter = FALSE;
+
+ if (view->filter) {
+ g_object_unref (view->filter);
+ refilter = TRUE;
+ }
+
+ if (filter) {
+ view->filter = g_object_ref (filter);
+ g_signal_connect_object (G_OBJECT (view->filter),
+ "changed", G_CALLBACK (filter_changed_cb),
+ G_OBJECT (view), 0);
+ }
+
+ if (refilter) {
+ gtk_tree_model_filter_refilter
+ (GTK_TREE_MODEL_FILTER (view->filtermodel));
+ }
}
static void
-ephy_node_view_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EphyNodeView *view = EPHY_NODE_VIEW (object);
-
- switch (prop_id)
- {
- case PROP_ROOT:
- view->root = g_value_get_pointer (value);
- break;
- case PROP_FILTER:
- ephy_node_view_set_filter (view, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ephy_node_view_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EphyNodeView *view = EPHY_NODE_VIEW (object);
+
+ switch (prop_id) {
+ case PROP_ROOT:
+ view->root = g_value_get_pointer (value);
+ break;
+ case PROP_FILTER:
+ ephy_node_view_set_filter (view, g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-ephy_node_view_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EphyNodeView *view = EPHY_NODE_VIEW (object);
-
- switch (prop_id)
- {
- case PROP_ROOT:
- g_value_set_pointer (value, view->root);
- break;
- case PROP_FILTER:
- g_value_set_object (value, view->filter);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ephy_node_view_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EphyNodeView *view = EPHY_NODE_VIEW (object);
+
+ switch (prop_id) {
+ case PROP_ROOT:
+ g_value_set_pointer (value, view->root);
+ break;
+ case PROP_FILTER:
+ g_value_set_object (value, view->filter);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
/**
@@ -966,232 +903,201 @@ ephy_node_view_get_property (GObject *object,
* Returns: a new #EphyNodeView as a #GtkWidget
**/
GtkWidget *
-ephy_node_view_new (EphyNode *root,
- EphyNodeFilter *filter)
+ephy_node_view_new (EphyNode *root,
+ EphyNodeFilter *filter)
{
- EphyNodeView *view;
+ EphyNodeView *view;
- view = EPHY_NODE_VIEW (g_object_new (EPHY_TYPE_NODE_VIEW,
- "filter", filter,
- "root", root,
- NULL));
+ view = EPHY_NODE_VIEW (g_object_new (EPHY_TYPE_NODE_VIEW,
+ "filter", filter,
+ "root", root,
+ NULL));
- return GTK_WIDGET (view);
+ return GTK_WIDGET (view);
}
static void
cell_renderer_edited (GtkCellRendererText *cell,
- const char *path_str,
- const char *new_text,
- EphyNodeView *view)
+ const char *path_str,
+ const char *new_text,
+ EphyNodeView *view)
{
- GtkTreePath *path;
- GtkTreeIter iter, iter2;
- EphyNode *node;
+ GtkTreePath *path;
+ GtkTreeIter iter, iter2;
+ EphyNode *node;
- view->edited_node = NULL;
+ view->edited_node = NULL;
- g_object_set (G_OBJECT (view->editable_renderer),
- "editable", FALSE,
- NULL);
+ g_object_set (G_OBJECT (view->editable_renderer),
+ "editable", FALSE,
+ NULL);
- path = gtk_tree_path_new_from_string (path_str);
- gtk_tree_model_get_iter (view->sortmodel, &iter, path);
- gtk_tree_model_sort_convert_iter_to_child_iter
- (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
- gtk_tree_model_filter_convert_iter_to_child_iter
- (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
- node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
+ path = gtk_tree_path_new_from_string (path_str);
+ gtk_tree_model_get_iter (view->sortmodel, &iter, path);
+ gtk_tree_model_sort_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_SORT (view->sortmodel), &iter2, &iter);
+ gtk_tree_model_filter_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_FILTER (view->filtermodel), &iter, &iter2);
+ node = ephy_tree_model_node_node_from_iter (view->nodemodel, &iter);
- ephy_node_set_property_string (node, view->editable_property,
- new_text);
+ ephy_node_set_property_string (node, view->editable_property,
+ new_text);
- gtk_tree_path_free (path);
+ gtk_tree_path_free (path);
- view->remove_if_cancelled = FALSE;
+ view->remove_if_cancelled = FALSE;
}
static void
renderer_editing_canceled_cb (GtkCellRendererText *cell,
- EphyNodeView *view)
+ EphyNodeView *view)
{
- if (view->remove_if_cancelled)
- {
- ephy_node_unref (view->edited_node);
- view->remove_if_cancelled = FALSE;
- }
+ if (view->remove_if_cancelled) {
+ ephy_node_unref (view->edited_node);
+ view->remove_if_cancelled = FALSE;
+ }
}
static inline int
compare_string_values (const GValue *a_value, const GValue *b_value)
{
- const char *str1, *str2;
- int retval;
-
- str1 = g_value_get_string (a_value);
- str2 = g_value_get_string (b_value);
-
- if (str1 == NULL)
- {
- retval = -1;
- }
- else if (str2 == NULL)
- {
- retval = 1;
- }
- else
- {
- char *str_a;
- char *str_b;
-
- str_a = g_utf8_casefold (str1, -1);
- str_b = g_utf8_casefold (str2, -1);
- retval = g_utf8_collate (str_a, str_b);
- g_free (str_a);
- g_free (str_b);
- }
-
- return retval;
+ const char *str1, *str2;
+ int retval;
+
+ str1 = g_value_get_string (a_value);
+ str2 = g_value_get_string (b_value);
+
+ if (str1 == NULL) {
+ retval = -1;
+ } else if (str2 == NULL) {
+ retval = 1;
+ } else {
+ char *str_a;
+ char *str_b;
+
+ str_a = g_utf8_casefold (str1, -1);
+ str_b = g_utf8_casefold (str2, -1);
+ retval = g_utf8_collate (str_a, str_b);
+ g_free (str_a);
+ g_free (str_b);
+ }
+
+ return retval;
}
static int
ephy_node_view_sort_func (GtkTreeModel *model,
- GtkTreeIter *a,
- GtkTreeIter *b,
- EphyNodeView *view)
-{
- GValue a_value = {0, };
- GValue b_value = {0, };
- int p_column, column, retval = 0;
- GtkSortType sort_type;
-
- g_return_val_if_fail (model != NULL, 0);
- g_return_val_if_fail (view != NULL, 0);
-
- p_column = view->priority_column;
- column = view->sort_column;
- sort_type = view->sort_type;
-
- if (p_column >= 0)
- {
- gtk_tree_model_get_value (model, a, p_column, &a_value);
- gtk_tree_model_get_value (model, b, p_column, &b_value);
-
- if (g_value_get_int (&a_value) < g_value_get_int (&b_value))
- {
- retval = -1;
- }
- else if (g_value_get_int (&a_value) == g_value_get_int (&b_value))
- {
- retval = 0;
- }
- else
- {
- retval = 1;
- }
-
- g_value_unset (&a_value);
- g_value_unset (&b_value);
- }
-
-
- if (retval == 0)
- {
- GType type;
-
- type = gtk_tree_model_get_column_type (model, column);
-
- gtk_tree_model_get_value (model, a, column, &a_value);
- gtk_tree_model_get_value (model, b, column, &b_value);
-
- switch (G_TYPE_FUNDAMENTAL (type))
- {
- case G_TYPE_STRING:
- retval = compare_string_values (&a_value, &b_value);
- break;
- case G_TYPE_INT:
- if (g_value_get_int (&a_value) < g_value_get_int (&b_value))
- {
- retval = -1;
- }
- else if (g_value_get_int (&a_value) == g_value_get_int (&b_value))
- {
- retval = 0;
- }
- else
- {
- retval = 1;
- }
- break;
- case G_TYPE_BOOLEAN:
- if (g_value_get_boolean (&a_value) < g_value_get_boolean (&b_value))
- {
- retval = -1;
- }
- else if (g_value_get_boolean (&a_value) == g_value_get_boolean (&b_value))
- {
- retval = 0;
- }
- else
- {
- retval = 1;
- }
- break;
- default:
- g_warning ("Attempting to sort on invalid type %s\n", g_type_name (type));
- break;
- }
-
- g_value_unset (&a_value);
- g_value_unset (&b_value);
- }
-
- if (sort_type == GTK_SORT_DESCENDING)
- {
- if (retval > 0)
- {
- retval = -1;
- }
- else if (retval < 0)
- {
- retval = 1;
- }
- }
-
- return retval;
+ GtkTreeIter *a,
+ GtkTreeIter *b,
+ EphyNodeView *view)
+{
+ GValue a_value = { 0, };
+ GValue b_value = { 0, };
+ int p_column, column, retval = 0;
+ GtkSortType sort_type;
+
+ g_return_val_if_fail (model != NULL, 0);
+ g_return_val_if_fail (view != NULL, 0);
+
+ p_column = view->priority_column;
+ column = view->sort_column;
+ sort_type = view->sort_type;
+
+ if (p_column >= 0) {
+ gtk_tree_model_get_value (model, a, p_column, &a_value);
+ gtk_tree_model_get_value (model, b, p_column, &b_value);
+
+ if (g_value_get_int (&a_value) < g_value_get_int (&b_value)) {
+ retval = -1;
+ } else if (g_value_get_int (&a_value) == g_value_get_int (&b_value)) {
+ retval = 0;
+ } else {
+ retval = 1;
+ }
+
+ g_value_unset (&a_value);
+ g_value_unset (&b_value);
+ }
+
+
+ if (retval == 0) {
+ GType type;
+
+ type = gtk_tree_model_get_column_type (model, column);
+
+ gtk_tree_model_get_value (model, a, column, &a_value);
+ gtk_tree_model_get_value (model, b, column, &b_value);
+
+ switch (G_TYPE_FUNDAMENTAL (type)) {
+ case G_TYPE_STRING:
+ retval = compare_string_values (&a_value, &b_value);
+ break;
+ case G_TYPE_INT:
+ if (g_value_get_int (&a_value) < g_value_get_int (&b_value)) {
+ retval = -1;
+ } else if (g_value_get_int (&a_value) == g_value_get_int (&b_value)) {
+ retval = 0;
+ } else {
+ retval = 1;
+ }
+ break;
+ case G_TYPE_BOOLEAN:
+ if (g_value_get_boolean (&a_value) < g_value_get_boolean (&b_value)) {
+ retval = -1;
+ } else if (g_value_get_boolean (&a_value) == g_value_get_boolean (&b_value)) {
+ retval = 0;
+ } else {
+ retval = 1;
+ }
+ break;
+ default:
+ g_warning ("Attempting to sort on invalid type %s\n", g_type_name (type));
+ break;
+ }
+
+ g_value_unset (&a_value);
+ g_value_unset (&b_value);
+ }
+
+ if (sort_type == GTK_SORT_DESCENDING) {
+ if (retval > 0) {
+ retval = -1;
+ } else if (retval < 0) {
+ retval = 1;
+ }
+ }
+
+ return retval;
}
static void
provide_priority (EphyNode *node, GValue *value, EphyNodeView *view)
{
- int priority;
-
- g_value_init (value, G_TYPE_INT);
- priority = ephy_node_get_property_int (node, view->priority_prop_id);
- if (priority == EPHY_NODE_VIEW_ALL_PRIORITY ||
- priority == EPHY_NODE_VIEW_SPECIAL_PRIORITY)
- g_value_set_int (value, priority);
- else
- g_value_set_int (value, EPHY_NODE_VIEW_NORMAL_PRIORITY);
+ int priority;
+
+ g_value_init (value, G_TYPE_INT);
+ priority = ephy_node_get_property_int (node, view->priority_prop_id);
+ if (priority == EPHY_NODE_VIEW_ALL_PRIORITY ||
+ priority == EPHY_NODE_VIEW_SPECIAL_PRIORITY)
+ g_value_set_int (value, priority);
+ else
+ g_value_set_int (value, EPHY_NODE_VIEW_NORMAL_PRIORITY);
}
static void
provide_text_weight (EphyNode *node, GValue *value, EphyNodeView *view)
{
- int priority;
-
- g_value_init (value, G_TYPE_INT);
- priority = ephy_node_get_property_int
- (node, view->priority_prop_id);
- if (priority == EPHY_NODE_VIEW_ALL_PRIORITY ||
- priority == EPHY_NODE_VIEW_SPECIAL_PRIORITY)
- {
- g_value_set_int (value, PANGO_WEIGHT_BOLD);
- }
- else
- {
- g_value_set_int (value, PANGO_WEIGHT_NORMAL);
- }
+ int priority;
+
+ g_value_init (value, G_TYPE_INT);
+ priority = ephy_node_get_property_int
+ (node, view->priority_prop_id);
+ if (priority == EPHY_NODE_VIEW_ALL_PRIORITY ||
+ priority == EPHY_NODE_VIEW_SPECIAL_PRIORITY) {
+ g_value_set_int (value, PANGO_WEIGHT_BOLD);
+ } else {
+ g_value_set_int (value, PANGO_WEIGHT_NORMAL);
+ }
}
/**
@@ -1208,26 +1114,23 @@ provide_text_weight (EphyNode *node, GValue *value, EphyNodeView *view)
* Returns: the id of the new column
**/
int
-ephy_node_view_add_data_column (EphyNodeView *view,
- GType value_type,
- guint prop_id,
- EphyTreeModelNodeValueFunc func,
- gpointer data)
-{
- int column;
-
- if (func)
- {
- column = ephy_tree_model_node_add_func_column
- (view->nodemodel, value_type, func, data);
- }
- else
- {
- column = ephy_tree_model_node_add_prop_column
- (view->nodemodel, value_type, prop_id);
- }
-
- return column;
+ephy_node_view_add_data_column (EphyNodeView *view,
+ GType value_type,
+ guint prop_id,
+ EphyTreeModelNodeValueFunc func,
+ gpointer data)
+{
+ int column;
+
+ if (func) {
+ column = ephy_tree_model_node_add_func_column
+ (view->nodemodel, value_type, func, data);
+ } else {
+ column = ephy_tree_model_node_add_prop_column
+ (view->nodemodel, value_type, prop_id);
+ }
+
+ return column;
}
/**
@@ -1247,103 +1150,97 @@ ephy_node_view_add_data_column (EphyNodeView *view,
* Returns: the id of the new column
**/
int
-ephy_node_view_add_column_full (EphyNodeView *view,
- const char *title,
- GType value_type,
- guint prop_id,
- EphyNodeViewFlags flags,
- EphyTreeModelNodeValueFunc func,
- gpointer user_data,
- EphyTreeModelNodeValueFunc icon_func,
- GtkTreeViewColumn **ret)
-{
- GtkTreeViewColumn *gcolumn;
- GtkCellRenderer *renderer;
- int column;
- int icon_column;
-
- column = ephy_tree_model_node_add_column_full
- (view->nodemodel, value_type, prop_id, func, user_data);
-
- gcolumn = (GtkTreeViewColumn *) gtk_tree_view_column_new ();
-
- if (icon_func)
- {
- icon_column = ephy_tree_model_node_add_func_column
- (view->nodemodel, GDK_TYPE_PIXBUF, icon_func, view);
-
- renderer = gtk_cell_renderer_pixbuf_new ();
- gtk_tree_view_column_pack_start (gcolumn, renderer, FALSE);
- gtk_tree_view_column_set_attributes (gcolumn, renderer,
- "pixbuf", icon_column,
- NULL);
- }
-
- renderer = gtk_cell_renderer_text_new ();
-
- if (flags & EPHY_NODE_VIEW_EDITABLE)
- {
- view->editable_renderer = renderer;
- view->editable_column = gcolumn;
- view->editable_node_column = column;
- view->editable_property = prop_id;
-
- g_signal_connect (renderer, "edited",
- G_CALLBACK (cell_renderer_edited), view);
- g_signal_connect (renderer, "editing-canceled",
- G_CALLBACK (renderer_editing_canceled_cb), view);
- }
-
- gtk_tree_view_column_pack_start (gcolumn, renderer, TRUE);
- gtk_tree_view_column_set_attributes (gcolumn, renderer,
- "text", column,
- NULL);
-
- gtk_tree_view_column_set_title (gcolumn, title);
- gtk_tree_view_append_column (GTK_TREE_VIEW (view),
- gcolumn);
-
- if (flags & EPHY_NODE_VIEW_SHOW_PRIORITY)
- {
- int wcol;
-
- wcol = ephy_tree_model_node_add_func_column
- (view->nodemodel, G_TYPE_INT,
- (EphyTreeModelNodeValueFunc) provide_text_weight,
- view);
- gtk_tree_view_column_add_attribute (gcolumn, renderer,
- "weight", wcol);
- }
-
- if (flags & EPHY_NODE_VIEW_SORTABLE)
- {
- /* Now we have created a new column, re-create the
- * sort model, but ensure that the set_sort function
- * hasn't been called, see bug #320686 */
- g_assert (view->sort_column == -1);
- g_object_unref (view->sortmodel);
- view->sortmodel = ephy_tree_model_sort_new (view->filtermodel);
- gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (view->sortmodel));
-
- gtk_tree_view_column_set_sort_column_id (gcolumn, column);
- }
-
- if (flags & EPHY_NODE_VIEW_SEARCHABLE)
- {
- gtk_tree_view_set_search_column (GTK_TREE_VIEW (view), column);
- gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view), TRUE);
- }
-
- if (flags & EPHY_NODE_VIEW_ELLIPSIZED)
- {
- g_object_set (renderer, "ellipsize-set", TRUE,
- "ellipsize", PANGO_ELLIPSIZE_END, NULL);
- }
-
- if (ret != NULL)
- *ret = gcolumn;
-
- return column;
+ephy_node_view_add_column_full (EphyNodeView *view,
+ const char *title,
+ GType value_type,
+ guint prop_id,
+ EphyNodeViewFlags flags,
+ EphyTreeModelNodeValueFunc func,
+ gpointer user_data,
+ EphyTreeModelNodeValueFunc icon_func,
+ GtkTreeViewColumn **ret)
+{
+ GtkTreeViewColumn *gcolumn;
+ GtkCellRenderer *renderer;
+ int column;
+ int icon_column;
+
+ column = ephy_tree_model_node_add_column_full
+ (view->nodemodel, value_type, prop_id, func, user_data);
+
+ gcolumn = (GtkTreeViewColumn *)gtk_tree_view_column_new ();
+
+ if (icon_func) {
+ icon_column = ephy_tree_model_node_add_func_column
+ (view->nodemodel, GDK_TYPE_PIXBUF, icon_func, view);
+
+ renderer = gtk_cell_renderer_pixbuf_new ();
+ gtk_tree_view_column_pack_start (gcolumn, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (gcolumn, renderer,
+ "pixbuf", icon_column,
+ NULL);
+ }
+
+ renderer = gtk_cell_renderer_text_new ();
+
+ if (flags & EPHY_NODE_VIEW_EDITABLE) {
+ view->editable_renderer = renderer;
+ view->editable_column = gcolumn;
+ view->editable_node_column = column;
+ view->editable_property = prop_id;
+
+ g_signal_connect (renderer, "edited",
+ G_CALLBACK (cell_renderer_edited), view);
+ g_signal_connect (renderer, "editing-canceled",
+ G_CALLBACK (renderer_editing_canceled_cb), view);
+ }
+
+ gtk_tree_view_column_pack_start (gcolumn, renderer, TRUE);
+ gtk_tree_view_column_set_attributes (gcolumn, renderer,
+ "text", column,
+ NULL);
+
+ gtk_tree_view_column_set_title (gcolumn, title);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (view),
+ gcolumn);
+
+ if (flags & EPHY_NODE_VIEW_SHOW_PRIORITY) {
+ int wcol;
+
+ wcol = ephy_tree_model_node_add_func_column
+ (view->nodemodel, G_TYPE_INT,
+ (EphyTreeModelNodeValueFunc)provide_text_weight,
+ view);
+ gtk_tree_view_column_add_attribute (gcolumn, renderer,
+ "weight", wcol);
+ }
+
+ if (flags & EPHY_NODE_VIEW_SORTABLE) {
+ /* Now we have created a new column, re-create the
+ * sort model, but ensure that the set_sort function
+ * hasn't been called, see bug #320686 */
+ g_assert (view->sort_column == -1);
+ g_object_unref (view->sortmodel);
+ view->sortmodel = ephy_tree_model_sort_new (view->filtermodel);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (view->sortmodel));
+
+ gtk_tree_view_column_set_sort_column_id (gcolumn, column);
+ }
+
+ if (flags & EPHY_NODE_VIEW_SEARCHABLE) {
+ gtk_tree_view_set_search_column (GTK_TREE_VIEW (view), column);
+ gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view), TRUE);
+ }
+
+ if (flags & EPHY_NODE_VIEW_ELLIPSIZED) {
+ g_object_set (renderer, "ellipsize-set", TRUE,
+ "ellipsize", PANGO_ELLIPSIZE_END, NULL);
+ }
+
+ if (ret != NULL)
+ *ret = gcolumn;
+
+ return column;
}
/**
@@ -1361,16 +1258,16 @@ ephy_node_view_add_column_full (EphyNodeView *view,
* Returns: the id of the new column
**/
int
-ephy_node_view_add_column (EphyNodeView *view,
- const char *title,
- GType value_type,
- guint prop_id,
- EphyNodeViewFlags flags,
- EphyTreeModelNodeValueFunc icon_func,
- GtkTreeViewColumn **ret)
-{
- return ephy_node_view_add_column_full (view, title, value_type, prop_id,
- flags, NULL, NULL, icon_func, ret);
+ephy_node_view_add_column (EphyNodeView *view,
+ const char *title,
+ GType value_type,
+ guint prop_id,
+ EphyNodeViewFlags flags,
+ EphyTreeModelNodeValueFunc icon_func,
+ GtkTreeViewColumn **ret)
+{
+ return ephy_node_view_add_column_full (view, title, value_type, prop_id,
+ flags, NULL, NULL, icon_func, ret);
}
/**
@@ -1383,15 +1280,15 @@ ephy_node_view_add_column (EphyNodeView *view,
void
ephy_node_view_set_priority (EphyNodeView *view, EphyNodeViewPriority priority_prop_id)
{
- int priority_column;
+ int priority_column;
- priority_column = ephy_tree_model_node_add_func_column
- (view->nodemodel, G_TYPE_INT,
- (EphyTreeModelNodeValueFunc) provide_priority,
- view);
+ priority_column = ephy_tree_model_node_add_func_column
+ (view->nodemodel, G_TYPE_INT,
+ (EphyTreeModelNodeValueFunc)provide_priority,
+ view);
- view->priority_column = priority_column;
- view->priority_prop_id = priority_prop_id;
+ view->priority_column = priority_column;
+ view->priority_prop_id = priority_prop_id;
}
/**
@@ -1405,49 +1302,49 @@ ephy_node_view_set_priority (EphyNodeView *view, EphyNodeViewPriority priority_p
**/
void
ephy_node_view_set_sort (EphyNodeView *view, GType value_type, guint prop_id,
- GtkSortType sort_type)
-{
- GtkTreeSortable *sortable = GTK_TREE_SORTABLE (view->sortmodel);
- int column;
-
- column = ephy_tree_model_node_add_prop_column
- (view->nodemodel, value_type, prop_id);
- view->sort_column = column;
- view->sort_type = sort_type;
-
- gtk_tree_sortable_set_default_sort_func
- (sortable, (GtkTreeIterCompareFunc)ephy_node_view_sort_func,
- view, NULL);
- gtk_tree_sortable_set_sort_column_id
- (sortable, GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
- sort_type);
+ GtkSortType sort_type)
+{
+ GtkTreeSortable *sortable = GTK_TREE_SORTABLE (view->sortmodel);
+ int column;
+
+ column = ephy_tree_model_node_add_prop_column
+ (view->nodemodel, value_type, prop_id);
+ view->sort_column = column;
+ view->sort_type = sort_type;
+
+ gtk_tree_sortable_set_default_sort_func
+ (sortable, (GtkTreeIterCompareFunc)ephy_node_view_sort_func,
+ view, NULL);
+ gtk_tree_sortable_set_sort_column_id
+ (sortable, GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
+ sort_type);
}
static void
ephy_node_view_init (EphyNodeView *view)
{
- view->toggle_column = -1;
- view->priority_column = -1;
- view->priority_prop_id = 0;
- view->sort_column = -1;
- view->sort_type = GTK_SORT_ASCENDING;
+ view->toggle_column = -1;
+ view->priority_column = -1;
+ view->priority_prop_id = 0;
+ view->sort_column = -1;
+ view->sort_type = GTK_SORT_ASCENDING;
- gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view), FALSE);
+ gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view), FALSE);
}
static void
get_selection (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer *data)
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer *data)
{
- GList **list = data[0];
- EphyNodeView *view = EPHY_NODE_VIEW (data[1]);
- EphyNode *node;
+ GList **list = data[0];
+ EphyNodeView *view = EPHY_NODE_VIEW (data[1]);
+ EphyNode *node;
- node = get_node_from_path (view, path);
+ node = get_node_from_path (view, path);
- *list = g_list_prepend (*list, node);
+ *list = g_list_prepend (*list, node);
}
/**
@@ -1461,20 +1358,20 @@ get_selection (GtkTreeModel *model,
GList *
ephy_node_view_get_selection (EphyNodeView *view)
{
- GList *list = NULL;
- GtkTreeSelection *selection;
- gpointer data[2];
+ GList *list = NULL;
+ GtkTreeSelection *selection;
+ gpointer data[2];
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
- data[0] = &list;
- data[1] = view;
- gtk_tree_selection_selected_foreach
- (selection,
- (GtkTreeSelectionForeachFunc) get_selection,
- (gpointer) data);
+ data[0] = &list;
+ data[1] = view;
+ gtk_tree_selection_selected_foreach
+ (selection,
+ (GtkTreeSelectionForeachFunc)get_selection,
+ (gpointer)data);
- return list;
+ return list;
}
/**
@@ -1486,73 +1383,66 @@ ephy_node_view_get_selection (EphyNodeView *view)
void
ephy_node_view_remove (EphyNodeView *view)
{
- GList *list, *l;
- EphyNode *node;
- GtkTreeIter iter, iter2, iter3;
- GtkTreePath *path;
- GtkTreeRowReference *row_ref = NULL;
- GtkTreeSelection *selection;
-
- /* Before removing we try to get a reference to the next node in the view. If that is
- * not available we try with the previous one, and if that is absent too,
- * we will not select anything (which equals to select the topic "All")
- */
-
- list = ephy_node_view_get_selection (view);
- if (list == NULL) return;
-
- node = g_list_first (list)->data;
- ephy_tree_model_node_iter_from_node (EPHY_TREE_MODEL_NODE (view->nodemodel),
- node, &iter3);
- gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (view->filtermodel),
- &iter2, &iter3);
- gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (view->sortmodel),
- &iter, &iter2);
- iter2 = iter;
-
- if (gtk_tree_model_iter_next (GTK_TREE_MODEL (view->sortmodel), &iter))
- {
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->sortmodel), &iter);
- row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (view->sortmodel), path);
- }
- else
- {
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->sortmodel), &iter2);
- if (gtk_tree_path_prev (path))
- {
- row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (view->sortmodel), path);
- }
- }
- gtk_tree_path_free (path);
-
- /* Work around bug #346662 */
- view->changing_selection = TRUE;
- for (l = list; l != NULL; l = l->next)
- {
- ephy_node_unref (l->data);
- }
- view->changing_selection = FALSE;
-
- g_list_free (list);
-
- /* Fake a selection changed signal */
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
- g_signal_emit_by_name (selection, "changed");
-
- /* Select the "next" node */
-
- if (row_ref != NULL)
- {
- path = gtk_tree_row_reference_get_path (row_ref);
-
- if (path != NULL)
- {
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path, NULL, FALSE);
- gtk_tree_path_free (path);
- }
-
- gtk_tree_row_reference_free (row_ref);
- }
+ GList *list, *l;
+ EphyNode *node;
+ GtkTreeIter iter, iter2, iter3;
+ GtkTreePath *path;
+ GtkTreeRowReference *row_ref = NULL;
+ GtkTreeSelection *selection;
+
+ /* Before removing we try to get a reference to the next node in the view. If that is
+ * not available we try with the previous one, and if that is absent too,
+ * we will not select anything (which equals to select the topic "All")
+ */
+
+ list = ephy_node_view_get_selection (view);
+ if (list == NULL) return;
+
+ node = g_list_first (list)->data;
+ ephy_tree_model_node_iter_from_node (EPHY_TREE_MODEL_NODE (view->nodemodel),
+ node, &iter3);
+ gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (view->filtermodel),
+ &iter2, &iter3);
+ gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (view->sortmodel),
+ &iter, &iter2);
+ iter2 = iter;
+
+ if (gtk_tree_model_iter_next (GTK_TREE_MODEL (view->sortmodel), &iter)) {
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->sortmodel), &iter);
+ row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (view->sortmodel), path);
+ } else {
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->sortmodel), &iter2);
+ if (gtk_tree_path_prev (path)) {
+ row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (view->sortmodel), path);
+ }
+ }
+ gtk_tree_path_free (path);
+
+ /* Work around bug #346662 */
+ view->changing_selection = TRUE;
+ for (l = list; l != NULL; l = l->next) {
+ ephy_node_unref (l->data);
+ }
+ view->changing_selection = FALSE;
+
+ g_list_free (list);
+
+ /* Fake a selection changed signal */
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+ g_signal_emit_by_name (selection, "changed");
+
+ /* Select the "next" node */
+
+ if (row_ref != NULL) {
+ path = gtk_tree_row_reference_get_path (row_ref);
+
+ if (path != NULL) {
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path, NULL, FALSE);
+ gtk_tree_path_free (path);
+ }
+
+ gtk_tree_row_reference_free (row_ref);
+ }
}
/**
@@ -1564,21 +1454,21 @@ ephy_node_view_remove (EphyNodeView *view)
**/
void
ephy_node_view_select_node (EphyNodeView *view,
- EphyNode *node)
+ EphyNode *node)
{
- GtkTreeIter iter, iter2;
+ GtkTreeIter iter, iter2;
- g_return_if_fail (node != NULL);
+ g_return_if_fail (node != NULL);
- ephy_tree_model_node_iter_from_node (EPHY_TREE_MODEL_NODE (view->nodemodel),
- node, &iter);
- gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (view->filtermodel),
- &iter2, &iter);
- gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (view->sortmodel),
- &iter, &iter2);
+ ephy_tree_model_node_iter_from_node (EPHY_TREE_MODEL_NODE (view->nodemodel),
+ node, &iter);
+ gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (view->filtermodel),
+ &iter2, &iter);
+ gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (view->sortmodel),
+ &iter, &iter2);
- gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)),
- &iter);
+ gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)),
+ &iter);
}
/**
@@ -1592,37 +1482,37 @@ ephy_node_view_select_node (EphyNodeView *view,
* Sets @view as a drag source.
**/
void
-ephy_node_view_enable_drag_source (EphyNodeView *view,
- const GtkTargetEntry *types,
- int n_types,
- int base_drag_column_id,
- int extra_drag_column_id)
-{
- g_return_if_fail (view != NULL);
-
- view->source_target_list =
- gtk_target_list_new (types, n_types);
-
- ephy_tree_model_sort_set_base_drag_column_id (EPHY_TREE_MODEL_SORT (view->sortmodel),
- base_drag_column_id);
- ephy_tree_model_sort_set_extra_drag_column_id (EPHY_TREE_MODEL_SORT (view->sortmodel),
- extra_drag_column_id);
-
- g_signal_connect_object (G_OBJECT (view),
- "button_release_event",
- G_CALLBACK (button_release_cb),
- view,
- 0);
- g_signal_connect_object (G_OBJECT (view),
- "motion_notify_event",
- G_CALLBACK (motion_notify_cb),
- view,
- 0);
- g_signal_connect_object (G_OBJECT (view),
- "drag_data_get",
- G_CALLBACK (drag_data_get_cb),
- view,
- 0);
+ephy_node_view_enable_drag_source (EphyNodeView *view,
+ const GtkTargetEntry *types,
+ int n_types,
+ int base_drag_column_id,
+ int extra_drag_column_id)
+{
+ g_return_if_fail (view != NULL);
+
+ view->source_target_list =
+ gtk_target_list_new (types, n_types);
+
+ ephy_tree_model_sort_set_base_drag_column_id (EPHY_TREE_MODEL_SORT (view->sortmodel),
+ base_drag_column_id);
+ ephy_tree_model_sort_set_extra_drag_column_id (EPHY_TREE_MODEL_SORT (view->sortmodel),
+ extra_drag_column_id);
+
+ g_signal_connect_object (G_OBJECT (view),
+ "button_release_event",
+ G_CALLBACK (button_release_cb),
+ view,
+ 0);
+ g_signal_connect_object (G_OBJECT (view),
+ "motion_notify_event",
+ G_CALLBACK (motion_notify_cb),
+ view,
+ 0);
+ g_signal_connect_object (G_OBJECT (view),
+ "drag_data_get",
+ G_CALLBACK (drag_data_get_cb),
+ view,
+ 0);
}
/**
@@ -1636,33 +1526,33 @@ ephy_node_view_enable_drag_source (EphyNodeView *view,
void
ephy_node_view_edit (EphyNodeView *view, gboolean remove_if_cancelled)
{
- GtkTreePath *path;
- GtkTreeSelection *selection;
- GList *rows;
- GtkTreeModel *model;
+ GtkTreePath *path;
+ GtkTreeSelection *selection;
+ GList *rows;
+ GtkTreeModel *model;
- g_return_if_fail (view->editable_renderer != NULL);
+ g_return_if_fail (view->editable_renderer != NULL);
- selection = gtk_tree_view_get_selection
- (GTK_TREE_VIEW (view));
- rows = gtk_tree_selection_get_selected_rows (selection, &model);
- if (rows == NULL) return;
+ selection = gtk_tree_view_get_selection
+ (GTK_TREE_VIEW (view));
+ rows = gtk_tree_selection_get_selected_rows (selection, &model);
+ if (rows == NULL) return;
- path = rows->data;
+ path = rows->data;
- g_object_set (G_OBJECT (view->editable_renderer),
- "editable", TRUE,
- NULL);
+ g_object_set (G_OBJECT (view->editable_renderer),
+ "editable", TRUE,
+ NULL);
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path,
- view->editable_column,
- TRUE);
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path,
+ view->editable_column,
+ TRUE);
- view->edited_node = get_node_from_path (view, path);
- view->remove_if_cancelled = remove_if_cancelled;
+ view->edited_node = get_node_from_path (view, path);
+ view->remove_if_cancelled = remove_if_cancelled;
- g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
- g_list_free (rows);
+ g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
+ g_list_free (rows);
}
/**
@@ -1676,63 +1566,62 @@ ephy_node_view_edit (EphyNodeView *view, gboolean remove_if_cancelled)
gboolean
ephy_node_view_is_target (EphyNodeView *view)
{
- return gtk_widget_is_focus (GTK_WIDGET (view));
+ return gtk_widget_is_focus (GTK_WIDGET (view));
}
static gboolean
filter_visible_func (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
{
- EphyNode *node;
- EphyNodeView *view = EPHY_NODE_VIEW (data);
+ EphyNode *node;
+ EphyNodeView *view = EPHY_NODE_VIEW (data);
- if (view->filter)
- {
- node = ephy_tree_model_node_node_from_iter (view->nodemodel, iter);
+ if (view->filter) {
+ node = ephy_tree_model_node_node_from_iter (view->nodemodel, iter);
- return ephy_node_filter_evaluate (view->filter, node);
- }
+ return ephy_node_filter_evaluate (view->filter, node);
+ }
- return TRUE;
+ return TRUE;
}
static GObject *
ephy_node_view_constructor (GType type, guint n_construct_properties,
- GObjectConstructParam *construct_params)
-
-{
- GObject *object;
- EphyNodeView *view;
- GtkTreeSelection *selection;
-
- object = G_OBJECT_CLASS (ephy_node_view_parent_class)->constructor (type,
- n_construct_properties,
- construct_params);
- view = EPHY_NODE_VIEW (object);
-
- view->nodemodel = ephy_tree_model_node_new (view->root);
- view->filtermodel = gtk_tree_model_filter_new (GTK_TREE_MODEL (view->nodemodel),
- NULL);
- gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (view->filtermodel),
- filter_visible_func, view, NULL);
- view->sortmodel = ephy_tree_model_sort_new (view->filtermodel);
- gtk_tree_view_set_model (GTK_TREE_VIEW (object), GTK_TREE_MODEL (view->sortmodel));
- g_signal_connect_object (object, "button_press_event",
- G_CALLBACK (ephy_node_view_button_press_cb),
- view, 0);
- g_signal_connect (object, "key_press_event",
- G_CALLBACK (ephy_node_view_key_press_cb),
- view);
- g_signal_connect_object (object, "row_activated",
- G_CALLBACK (ephy_node_view_row_activated_cb),
- view, 0);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
- g_signal_connect_object (G_OBJECT (selection), "changed",
- G_CALLBACK (ephy_node_view_selection_changed_cb),
- view, 0);
-
- return object;
+ GObjectConstructParam *construct_params)
+
+{
+ GObject *object;
+ EphyNodeView *view;
+ GtkTreeSelection *selection;
+
+ object = G_OBJECT_CLASS (ephy_node_view_parent_class)->constructor (type,
+ n_construct_properties,
+ construct_params);
+ view = EPHY_NODE_VIEW (object);
+
+ view->nodemodel = ephy_tree_model_node_new (view->root);
+ view->filtermodel = gtk_tree_model_filter_new (GTK_TREE_MODEL (view->nodemodel),
+ NULL);
+ gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (view->filtermodel),
+ filter_visible_func, view, NULL);
+ view->sortmodel = ephy_tree_model_sort_new (view->filtermodel);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (object), GTK_TREE_MODEL (view->sortmodel));
+ g_signal_connect_object (object, "button_press_event",
+ G_CALLBACK (ephy_node_view_button_press_cb),
+ view, 0);
+ g_signal_connect (object, "key_press_event",
+ G_CALLBACK (ephy_node_view_key_press_cb),
+ view);
+ g_signal_connect_object (object, "row_activated",
+ G_CALLBACK (ephy_node_view_row_activated_cb),
+ view, 0);
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+ g_signal_connect_object (G_OBJECT (selection), "changed",
+ G_CALLBACK (ephy_node_view_selection_changed_cb),
+ view, 0);
+
+ return object;
}
/**
@@ -1746,20 +1635,20 @@ ephy_node_view_constructor (GType type, guint n_construct_properties,
**/
void
ephy_node_view_add_toggle (EphyNodeView *view, EphyTreeModelNodeValueFunc value_func,
- gpointer data)
+ gpointer data)
{
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *col;
- int column;
-
- column = ephy_tree_model_node_add_func_column
- (view->nodemodel, G_TYPE_BOOLEAN, value_func, data);
- view->toggle_column = column;
-
- renderer = gtk_cell_renderer_toggle_new ();
- col = gtk_tree_view_column_new_with_attributes
- ("", renderer, "active", column, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (view), col);
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *col;
+ int column;
+
+ column = ephy_tree_model_node_add_func_column
+ (view->nodemodel, G_TYPE_BOOLEAN, value_func, data);
+ view->toggle_column = column;
+
+ renderer = gtk_cell_renderer_toggle_new ();
+ col = gtk_tree_view_column_new_with_attributes
+ ("", renderer, "active", column, NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (view), col);
}
/**
@@ -1772,165 +1661,161 @@ ephy_node_view_add_toggle (EphyNodeView *view, EphyTreeModelNodeValueFunc value_
void
ephy_node_view_popup (EphyNodeView *view, GtkWidget *menu)
{
- GdkEvent *event;
-
- event = gtk_get_current_event ();
- if (event)
- {
- if (event->type == GDK_KEY_PRESS)
- {
- GdkEventKey *key = (GdkEventKey *) event;
-
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
- ephy_gui_menu_position_tree_selection,
- view, 0, key->time);
- gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
- }
- else if (event->type == GDK_BUTTON_PRESS)
- {
- GdkEventButton *button = (GdkEventButton *) event;
-
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL,
- NULL, button->button, button->time);
- }
-
- gdk_event_free (event);
- }
+ GdkEvent *event;
+
+ event = gtk_get_current_event ();
+ if (event) {
+ if (event->type == GDK_KEY_PRESS) {
+ GdkEventKey *key = (GdkEventKey *)event;
+
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
+ ephy_gui_menu_position_tree_selection,
+ view, 0, key->time);
+ gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
+ } else if (event->type == GDK_BUTTON_PRESS) {
+ GdkEventButton *button = (GdkEventButton *)event;
+
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL,
+ NULL, button->button, button->time);
+ }
+
+ gdk_event_free (event);
+ }
}
gboolean
ephy_node_view_get_iter_for_node (EphyNodeView *view,
- GtkTreeIter *iter,
- EphyNode *node)
+ GtkTreeIter *iter,
+ EphyNode *node)
{
- GtkTreeIter node_iter, filter_iter;
+ GtkTreeIter node_iter, filter_iter;
- ephy_tree_model_node_iter_from_node (EPHY_TREE_MODEL_NODE (view->nodemodel), node, &node_iter);
- if (!gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (view->filtermodel),
- &filter_iter, &node_iter))
- return FALSE;
+ ephy_tree_model_node_iter_from_node (EPHY_TREE_MODEL_NODE (view->nodemodel), node, &node_iter);
+ if (!gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (view->filtermodel),
+ &filter_iter, &node_iter))
+ return FALSE;
- if (!gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (view->sortmodel),
- iter, &filter_iter))
- return FALSE;
+ if (!gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (view->sortmodel),
+ iter, &filter_iter))
+ return FALSE;
- return TRUE;
+ return TRUE;
}
static void
ephy_node_view_class_init (EphyNodeViewClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->constructor = ephy_node_view_constructor;
- object_class->finalize = ephy_node_view_finalize;
-
- object_class->set_property = ephy_node_view_set_property;
- object_class->get_property = ephy_node_view_get_property;
-
- /**
- * EphyNodeView:root:
- *
- * A #gpointer to the root node of the #EphyNode elements of the view.
- */
- obj_properties[PROP_ROOT] =
- g_param_spec_pointer ("root",
- "Root node",
- "Root node",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
-
- /**
- * EphyNodeView:filter:
- *
- * An #EphyNodeFilter object to use in the view.
- */
- obj_properties[PROP_FILTER] =
- g_param_spec_object ("filter",
- "Filter object",
- "Filter object",
- EPHY_TYPE_NODE_FILTER,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
-
- /**
- * EphyNodeView::node-toggled:
- * @view: the object on which the signal is emitted
- * @node: the target #EphyNode
- * @checked: the new value of the toggle column
- *
- * Emitted when a row value is toggled, only emitted for toggle columns.
- */
- ephy_node_view_signals[NODE_TOGGLED] =
- g_signal_new ("node_toggled",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 2,
- G_TYPE_POINTER,
- G_TYPE_BOOLEAN);
- /**
- * EphyNodeView::node-activated:
- * @view: the object on which the signal is emitted
- * @node: the activated #EphyNode
- *
- * Emitted when a row is activated.
- */
- ephy_node_view_signals[NODE_ACTIVATED] =
- g_signal_new ("node_activated",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- G_TYPE_POINTER);
- /**
- * EphyNodeView::node-selected:
- * @view: the object on which the signal is emitted
- * @node: the selected #EphyNode
- *
- * Emitted when a row is selected.
- */
- ephy_node_view_signals[NODE_SELECTED] =
- g_signal_new ("node_selected",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- G_TYPE_POINTER);
- /**
- * EphyNodeView::node-dropped:
- * @view: the object on which the signal is emitted
- * @node: the dropped #EphyNode
- * @uris: URIs from the dragged data
- *
- * Emitted when an #EphyNode is dropped into the #EphyNodeView.
- */
- ephy_node_view_signals[NODE_DROPPED] =
- g_signal_new ("node_dropped",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 2,
- G_TYPE_POINTER,
- G_TYPE_POINTER);
-
- /**
- * EphyNodeView::node-middle-clicked:
- * @view: the object on which the signal is emitted
- * @node: the clicked #EphyNode
- *
- * Emitted when the user middle clicks on a row of the #EphyNodeView.
- */
- ephy_node_view_signals[NODE_MIDDLE_CLICKED] =
- g_signal_new ("node_middle_clicked",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- G_TYPE_POINTER);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->constructor = ephy_node_view_constructor;
+ object_class->finalize = ephy_node_view_finalize;
+
+ object_class->set_property = ephy_node_view_set_property;
+ object_class->get_property = ephy_node_view_get_property;
+
+ /**
+ * EphyNodeView:root:
+ *
+ * A #gpointer to the root node of the #EphyNode elements of the view.
+ */
+ obj_properties[PROP_ROOT] =
+ g_param_spec_pointer ("root",
+ "Root node",
+ "Root node",
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+
+ /**
+ * EphyNodeView:filter:
+ *
+ * An #EphyNodeFilter object to use in the view.
+ */
+ obj_properties[PROP_FILTER] =
+ g_param_spec_object ("filter",
+ "Filter object",
+ "Filter object",
+ EPHY_TYPE_NODE_FILTER,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+
+ /**
+ * EphyNodeView::node-toggled:
+ * @view: the object on which the signal is emitted
+ * @node: the target #EphyNode
+ * @checked: the new value of the toggle column
+ *
+ * Emitted when a row value is toggled, only emitted for toggle columns.
+ */
+ ephy_node_view_signals[NODE_TOGGLED] =
+ g_signal_new ("node_toggled",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_POINTER,
+ G_TYPE_BOOLEAN);
+ /**
+ * EphyNodeView::node-activated:
+ * @view: the object on which the signal is emitted
+ * @node: the activated #EphyNode
+ *
+ * Emitted when a row is activated.
+ */
+ ephy_node_view_signals[NODE_ACTIVATED] =
+ g_signal_new ("node_activated",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER);
+ /**
+ * EphyNodeView::node-selected:
+ * @view: the object on which the signal is emitted
+ * @node: the selected #EphyNode
+ *
+ * Emitted when a row is selected.
+ */
+ ephy_node_view_signals[NODE_SELECTED] =
+ g_signal_new ("node_selected",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER);
+ /**
+ * EphyNodeView::node-dropped:
+ * @view: the object on which the signal is emitted
+ * @node: the dropped #EphyNode
+ * @uris: URIs from the dragged data
+ *
+ * Emitted when an #EphyNode is dropped into the #EphyNodeView.
+ */
+ ephy_node_view_signals[NODE_DROPPED] =
+ g_signal_new ("node_dropped",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_POINTER,
+ G_TYPE_POINTER);
+
+ /**
+ * EphyNodeView::node-middle-clicked:
+ * @view: the object on which the signal is emitted
+ * @node: the clicked #EphyNode
+ *
+ * Emitted when the user middle clicks on a row of the #EphyNodeView.
+ */
+ ephy_node_view_signals[NODE_MIDDLE_CLICKED] =
+ g_signal_new ("node_middle_clicked",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER);
}
diff --git a/lib/widgets/ephy-security-popover.c b/lib/widgets/ephy-security-popover.c
index e1003b6..4e2c76b 100644
--- a/lib/widgets/ephy-security-popover.c
+++ b/lib/widgets/ephy-security-popover.c
@@ -34,8 +34,7 @@
* can also be used to show that a connection does not use TLS at all.
*/
-enum
-{
+enum {
PROP_0,
PROP_ADDRESS,
PROP_CERTIFICATE,
@@ -46,8 +45,7 @@ enum
static GParamSpec *obj_properties[LAST_PROP];
-struct _EphySecurityPopover
-{
+struct _EphySecurityPopover {
GtkPopover parent_instance;
char *address;
char *hostname;
@@ -64,7 +62,7 @@ G_DEFINE_TYPE (EphySecurityPopover, ephy_security_popover, GTK_TYPE_POPOVER)
static void
ephy_security_popover_set_address (EphySecurityPopover *popover,
- const char *address)
+ const char *address)
{
SoupURI *uri;
char *label_text;
@@ -86,7 +84,7 @@ ephy_security_popover_set_address (EphySecurityPopover *popover,
static void
ephy_security_popover_set_certificate (EphySecurityPopover *popover,
- GTlsCertificate *certificate)
+ GTlsCertificate *certificate)
{
if (certificate)
popover->certificate = g_object_ref (certificate);
@@ -94,7 +92,7 @@ ephy_security_popover_set_certificate (EphySecurityPopover *popover,
static void
ephy_security_popover_set_security_level (EphySecurityPopover *popover,
- EphySecurityLevel security_level)
+ EphySecurityLevel security_level)
{
GIcon *icon;
char *address_text;
@@ -105,38 +103,38 @@ ephy_security_popover_set_security_level (EphySecurityPopover *popover,
address_text = g_markup_printf_escaped ("<span weight=\"bold\">%s</span>", popover->hostname);
switch (security_level) {
- case EPHY_SECURITY_LEVEL_UNACCEPTABLE_CERTIFICATE:
- /* Label in certificate popover when site is untrusted. %s is a URL. */
- label_text = g_strdup_printf (_("This web site’s digital identification is not trusted. "
- "You may have connected to an attacker pretending to be %s."),
- address_text);
- gtk_label_set_markup (GTK_LABEL (popover->security_label), label_text);
- gtk_widget_hide (popover->host_label);
- break;
- case EPHY_SECURITY_LEVEL_NO_SECURITY:
- /* Label in certificate popover when site uses HTTP. %s is a URL. */
- label_text = g_strdup_printf (_("%s has no security. An attacker could see any information "
- "you send, or control the content that you see."),
- address_text);
- gtk_label_set_markup (GTK_LABEL (popover->security_label), label_text);
- gtk_widget_hide (popover->host_label);
- break;
- case EPHY_SECURITY_LEVEL_MIXED_CONTENT:
- gtk_label_set_text (GTK_LABEL (popover->security_label),
- /* Label in certificate popover when site sends mixed content. */
- _("This web site did not properly secure your connection."));
- gtk_widget_show (popover->host_label);
- break;
- case EPHY_SECURITY_LEVEL_STRONG_SECURITY:
- gtk_label_set_text (GTK_LABEL (popover->security_label),
- /* Label in certificate popover on secure sites. */
- _("Your connection seems to be secure."));
- gtk_widget_show (popover->host_label);
- break;
- case EPHY_SECURITY_LEVEL_TO_BE_DETERMINED:
- case EPHY_SECURITY_LEVEL_LOCAL_PAGE:
- default:
- g_assert_not_reached ();
+ case EPHY_SECURITY_LEVEL_UNACCEPTABLE_CERTIFICATE:
+ /* Label in certificate popover when site is untrusted. %s is a URL. */
+ label_text = g_strdup_printf (_("This web site’s digital identification is not trusted. "
+ "You may have connected to an attacker pretending to be %s."),
+ address_text);
+ gtk_label_set_markup (GTK_LABEL (popover->security_label), label_text);
+ gtk_widget_hide (popover->host_label);
+ break;
+ case EPHY_SECURITY_LEVEL_NO_SECURITY:
+ /* Label in certificate popover when site uses HTTP. %s is a URL. */
+ label_text = g_strdup_printf (_("%s has no security. An attacker could see any information "
+ "you send, or control the content that you see."),
+ address_text);
+ gtk_label_set_markup (GTK_LABEL (popover->security_label), label_text);
+ gtk_widget_hide (popover->host_label);
+ break;
+ case EPHY_SECURITY_LEVEL_MIXED_CONTENT:
+ gtk_label_set_text (GTK_LABEL (popover->security_label),
+ /* Label in certificate popover when site sends mixed content. */
+ _("This web site did not properly secure your connection."));
+ gtk_widget_show (popover->host_label);
+ break;
+ case EPHY_SECURITY_LEVEL_STRONG_SECURITY:
+ gtk_label_set_text (GTK_LABEL (popover->security_label),
+ /* Label in certificate popover on secure sites. */
+ _("Your connection seems to be secure."));
+ gtk_widget_show (popover->host_label);
+ break;
+ case EPHY_SECURITY_LEVEL_TO_BE_DETERMINED:
+ case EPHY_SECURITY_LEVEL_LOCAL_PAGE:
+ default:
+ g_assert_not_reached ();
}
icon = g_themed_icon_new_with_default_fallbacks (ephy_security_level_to_icon_name (security_level));
@@ -149,7 +147,7 @@ ephy_security_popover_set_security_level (EphySecurityPopover *popover,
static void
certificate_button_clicked_cb (GtkButton *button,
- gpointer user_data)
+ gpointer user_data)
{
EphySecurityPopover *popover = EPHY_SECURITY_POPOVER (user_data);
GtkWidget *dialog;
@@ -214,42 +212,42 @@ ephy_security_popover_finalize (GObject *object)
}
static void
-ephy_security_popover_set_property (GObject *object,
- guint prop_id,
+ephy_security_popover_set_property (GObject *object,
+ guint prop_id,
const GValue *value,
- GParamSpec *pspec)
+ GParamSpec *pspec)
{
EphySecurityPopover *popover = EPHY_SECURITY_POPOVER (object);
switch (prop_id) {
- case PROP_ADDRESS:
- ephy_security_popover_set_address (popover, g_value_get_string (value));
- break;
- case PROP_CERTIFICATE:
- ephy_security_popover_set_certificate (popover, g_value_get_object (value));
- break;
- case PROP_SECURITY_LEVEL:
- ephy_security_popover_set_security_level (popover, g_value_get_enum (value));
- break;
- case PROP_TLS_ERRORS:
- popover->tls_errors = g_value_get_flags (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ case PROP_ADDRESS:
+ ephy_security_popover_set_address (popover, g_value_get_string (value));
+ break;
+ case PROP_CERTIFICATE:
+ ephy_security_popover_set_certificate (popover, g_value_get_object (value));
+ break;
+ case PROP_SECURITY_LEVEL:
+ ephy_security_popover_set_security_level (popover, g_value_get_enum (value));
+ break;
+ case PROP_TLS_ERRORS:
+ popover->tls_errors = g_value_get_flags (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
ephy_security_popover_get_preferred_width (GtkWidget *widget,
- gint *minimum_width,
- gint *natural_width)
+ gint *minimum_width,
+ gint *natural_width)
{
GTK_WIDGET_CLASS (ephy_security_popover_parent_class)->get_preferred_width (widget,
- minimum_width,
- natural_width);
+ minimum_width,
+ natural_width);
if (*natural_width > 600)
- *natural_width = MAX(600, *minimum_width);
+ *natural_width = MAX (600, *minimum_width);
}
static void
@@ -342,11 +340,11 @@ ephy_security_popover_init (EphySecurityPopover *popover)
gtk_widget_show_all (popover->grid);
}
-GtkWidget *ephy_security_popover_new (GtkWidget *relative_to,
- const char *address,
- GTlsCertificate *certificate,
+GtkWidget *ephy_security_popover_new (GtkWidget *relative_to,
+ const char *address,
+ GTlsCertificate *certificate,
GTlsCertificateFlags tls_errors,
- EphySecurityLevel security_level)
+ EphySecurityLevel security_level)
{
g_return_val_if_fail (address != NULL, NULL);
diff --git a/lib/widgets/ephy-tree-model-node.c b/lib/widgets/ephy-tree-model-node.c
index bca8a36..d43c453 100644
--- a/lib/widgets/ephy-tree-model-node.c
+++ b/lib/widgets/ephy-tree-model-node.c
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright © 2002 Jorn Baayen <jorn nl linux org>
*
* This program is free software; you can redistribute it and/or modify
@@ -36,31 +36,28 @@
static void ephy_tree_model_node_finalize (GObject *object);
static void ephy_tree_model_node_tree_model_interface_init (GtkTreeModelIface *iface);
-struct _EphyTreeModelNode
-{
- GObject parent_instance;
+struct _EphyTreeModelNode {
+ GObject parent_instance;
- EphyNode *root;
+ EphyNode *root;
- GPtrArray *columns;
- int columns_num;
+ GPtrArray *columns;
+ int columns_num;
- int stamp;
+ int stamp;
};
-typedef struct
-{
- GType type;
- int prop_id;
- EphyTreeModelNodeValueFunc func;
- gpointer user_data;
+typedef struct {
+ GType type;
+ int prop_id;
+ EphyTreeModelNodeValueFunc func;
+ gpointer user_data;
} EphyTreeModelNodeColData;
-enum
-{
- PROP_0,
- PROP_ROOT,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_ROOT,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
@@ -70,204 +67,199 @@ G_DEFINE_TYPE_WITH_CODE (EphyTreeModelNode, ephy_tree_model_node, G_TYPE_OBJECT,
ephy_tree_model_node_tree_model_interface_init))
static void
-root_child_removed_cb (EphyNode *node,
- EphyNode *child,
- guint old_index,
- EphyTreeModelNode *model)
+root_child_removed_cb (EphyNode *node,
+ EphyNode *child,
+ guint old_index,
+ EphyTreeModelNode *model)
{
- GtkTreePath *path;
+ GtkTreePath *path;
- path = gtk_tree_path_new ();
- gtk_tree_path_append_index (path, old_index);
- gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
- gtk_tree_path_free (path);
+ path = gtk_tree_path_new ();
+ gtk_tree_path_append_index (path, old_index);
+ gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
+ gtk_tree_path_free (path);
}
static inline GtkTreePath *
get_path_real (EphyTreeModelNode *model,
- EphyNode *node)
+ EphyNode *node)
{
- GtkTreePath *retval;
+ GtkTreePath *retval;
- retval = gtk_tree_path_new ();
- gtk_tree_path_append_index (retval, ephy_node_get_child_index (model->root, node));
+ retval = gtk_tree_path_new ();
+ gtk_tree_path_append_index (retval, ephy_node_get_child_index (model->root, node));
- return retval;
+ return retval;
}
static void
-root_child_added_cb (EphyNode *node,
- EphyNode *child,
- EphyTreeModelNode *model)
+root_child_added_cb (EphyNode *node,
+ EphyNode *child,
+ EphyTreeModelNode *model)
{
- GtkTreePath *path;
- GtkTreeIter iter;
+ GtkTreePath *path;
+ GtkTreeIter iter;
- ephy_tree_model_node_iter_from_node (model, child, &iter);
+ ephy_tree_model_node_iter_from_node (model, child, &iter);
- path = get_path_real (model, child);
- gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, &iter);
- gtk_tree_path_free (path);
+ path = get_path_real (model, child);
+ gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, &iter);
+ gtk_tree_path_free (path);
}
static inline void
ephy_tree_model_node_update_node (EphyTreeModelNode *model,
- EphyNode *node,
- int idx)
+ EphyNode *node,
+ int idx)
{
- GtkTreePath *path;
- GtkTreeIter iter;
+ GtkTreePath *path;
+ GtkTreeIter iter;
- ephy_tree_model_node_iter_from_node (model, node, &iter);
+ ephy_tree_model_node_iter_from_node (model, node, &iter);
- if (idx >= 0)
- {
- path = gtk_tree_path_new ();
- gtk_tree_path_append_index (path, idx);
- }
- else
- {
- path = get_path_real (model, node);
- }
+ if (idx >= 0) {
+ path = gtk_tree_path_new ();
+ gtk_tree_path_append_index (path, idx);
+ } else {
+ path = get_path_real (model, node);
+ }
- LOG ("Updating row");
+ LOG ("Updating row");
- gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, &iter);
- gtk_tree_path_free (path);
+ gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, &iter);
+ gtk_tree_path_free (path);
}
static void
-root_child_changed_cb (EphyNode *node,
- EphyNode *child,
- guint property_id,
- EphyTreeModelNode *model)
+root_child_changed_cb (EphyNode *node,
+ EphyNode *child,
+ guint property_id,
+ EphyTreeModelNode *model)
{
- ephy_tree_model_node_update_node (model, child, -1);
+ ephy_tree_model_node_update_node (model, child, -1);
}
static void
-root_children_reordered_cb (EphyNode *node,
- int *new_order,
- EphyTreeModelNode *model)
+root_children_reordered_cb (EphyNode *node,
+ int *new_order,
+ EphyTreeModelNode *model)
{
- GtkTreePath *path;
+ GtkTreePath *path;
- path = gtk_tree_path_new ();
- gtk_tree_model_rows_reordered (GTK_TREE_MODEL (model), path, NULL, new_order);
- gtk_tree_path_free (path);
+ path = gtk_tree_path_new ();
+ gtk_tree_model_rows_reordered (GTK_TREE_MODEL (model), path, NULL, new_order);
+ gtk_tree_path_free (path);
}
static void
-root_destroy_cb (EphyNode *node,
- EphyTreeModelNode *model)
+root_destroy_cb (EphyNode *node,
+ EphyTreeModelNode *model)
{
- model->root = NULL;
+ model->root = NULL;
- /* no need to do other stuff since we should have had a bunch of child_removed
- * signals already */
+ /* no need to do other stuff since we should have had a bunch of child_removed
+ * signals already */
}
static void
-ephy_tree_model_node_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (object);
-
- switch (prop_id)
- {
- case PROP_ROOT:
- model->root = g_value_get_pointer (value);
-
- ephy_node_signal_connect_object (model->root,
- EPHY_NODE_CHILD_ADDED,
- (EphyNodeCallback) root_child_added_cb,
- G_OBJECT (model));
- ephy_node_signal_connect_object (model->root,
- EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback) root_child_removed_cb,
- G_OBJECT (model));
- ephy_node_signal_connect_object (model->root,
- EPHY_NODE_CHILD_CHANGED,
- (EphyNodeCallback) root_child_changed_cb,
- G_OBJECT (model));
- ephy_node_signal_connect_object (model->root,
- EPHY_NODE_CHILDREN_REORDERED,
- (EphyNodeCallback) root_children_reordered_cb,
- G_OBJECT (model));
- ephy_node_signal_connect_object (model->root,
- EPHY_NODE_DESTROY,
- (EphyNodeCallback) root_destroy_cb,
- G_OBJECT (model));
-
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ephy_tree_model_node_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (object);
+
+ switch (prop_id) {
+ case PROP_ROOT:
+ model->root = g_value_get_pointer (value);
+
+ ephy_node_signal_connect_object (model->root,
+ EPHY_NODE_CHILD_ADDED,
+ (EphyNodeCallback)root_child_added_cb,
+ G_OBJECT (model));
+ ephy_node_signal_connect_object (model->root,
+ EPHY_NODE_CHILD_REMOVED,
+ (EphyNodeCallback)root_child_removed_cb,
+ G_OBJECT (model));
+ ephy_node_signal_connect_object (model->root,
+ EPHY_NODE_CHILD_CHANGED,
+ (EphyNodeCallback)root_child_changed_cb,
+ G_OBJECT (model));
+ ephy_node_signal_connect_object (model->root,
+ EPHY_NODE_CHILDREN_REORDERED,
+ (EphyNodeCallback)root_children_reordered_cb,
+ G_OBJECT (model));
+ ephy_node_signal_connect_object (model->root,
+ EPHY_NODE_DESTROY,
+ (EphyNodeCallback)root_destroy_cb,
+ G_OBJECT (model));
+
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-ephy_tree_model_node_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (object);
-
- switch (prop_id)
- {
- case PROP_ROOT:
- g_value_set_pointer (value, model->root);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ephy_tree_model_node_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (object);
+
+ switch (prop_id) {
+ case PROP_ROOT:
+ g_value_set_pointer (value, model->root);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
ephy_tree_model_node_class_init (EphyTreeModelNodeClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = ephy_tree_model_node_finalize;
+ object_class->finalize = ephy_tree_model_node_finalize;
- object_class->set_property = ephy_tree_model_node_set_property;
- object_class->get_property = ephy_tree_model_node_get_property;
+ object_class->set_property = ephy_tree_model_node_set_property;
+ object_class->get_property = ephy_tree_model_node_get_property;
- /**
- * EphyTreeModelNode:root:
- *
- * The root #EphyNode of the model.
- */
- obj_properties[PROP_ROOT] =
- g_param_spec_pointer ("root",
- "Root node",
- "Root node",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+ /**
+ * EphyTreeModelNode:root:
+ *
+ * The root #EphyNode of the model.
+ */
+ obj_properties[PROP_ROOT] =
+ g_param_spec_pointer ("root",
+ "Root node",
+ "Root node",
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
}
static void
ephy_tree_model_node_init (EphyTreeModelNode *model)
{
- model->stamp = g_random_int ();
- model->columns = g_ptr_array_new ();
- model->columns_num = 0;
+ model->stamp = g_random_int ();
+ model->columns = g_ptr_array_new ();
+ model->columns_num = 0;
}
static void
ephy_tree_model_node_finalize (GObject *object)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (object);
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (object);
- g_ptr_array_foreach (model->columns, (GFunc) g_free, NULL);
- g_ptr_array_free (model->columns, TRUE);
+ g_ptr_array_foreach (model->columns, (GFunc)g_free, NULL);
+ g_ptr_array_free (model->columns, TRUE);
- G_OBJECT_CLASS (ephy_tree_model_node_parent_class)->finalize (object);
+ G_OBJECT_CLASS (ephy_tree_model_node_parent_class)->finalize (object);
}
/**
@@ -281,13 +273,13 @@ ephy_tree_model_node_finalize (GObject *object)
EphyTreeModelNode *
ephy_tree_model_node_new (EphyNode *root)
{
- EphyTreeModelNode *model;
+ EphyTreeModelNode *model;
- model = EPHY_TREE_MODEL_NODE (g_object_new (EPHY_TYPE_TREE_MODEL_NODE,
- "root", root,
- NULL));
+ model = EPHY_TREE_MODEL_NODE (g_object_new (EPHY_TYPE_TREE_MODEL_NODE,
+ "root", root,
+ NULL));
- return model;
+ return model;
}
/**
@@ -304,26 +296,26 @@ ephy_tree_model_node_new (EphyNode *root)
* Returns: the id of the new column
**/
int
-ephy_tree_model_node_add_column_full (EphyTreeModelNode *model,
- GType value_type,
- int prop_id,
- EphyTreeModelNodeValueFunc func,
- gpointer user_data)
-{
- EphyTreeModelNodeColData *col;
- int col_id;
-
- col = g_new0 (EphyTreeModelNodeColData, 1);
- col->prop_id = prop_id;
- col->type = value_type;
- col->func = func;
- col->user_data = user_data;
-
- g_ptr_array_add (model->columns, col);
- col_id = model->columns_num;
- model->columns_num++;
-
- return col_id;
+ephy_tree_model_node_add_column_full (EphyTreeModelNode *model,
+ GType value_type,
+ int prop_id,
+ EphyTreeModelNodeValueFunc func,
+ gpointer user_data)
+{
+ EphyTreeModelNodeColData *col;
+ int col_id;
+
+ col = g_new0 (EphyTreeModelNodeColData, 1);
+ col->prop_id = prop_id;
+ col->type = value_type;
+ col->func = func;
+ col->user_data = user_data;
+
+ g_ptr_array_add (model->columns, col);
+ col_id = model->columns_num;
+ model->columns_num++;
+
+ return col_id;
}
@@ -339,10 +331,10 @@ ephy_tree_model_node_add_column_full (EphyTreeModelNode *model,
**/
int
ephy_tree_model_node_add_prop_column (EphyTreeModelNode *model,
- GType value_type,
- int prop_id)
+ GType value_type,
+ int prop_id)
{
- return ephy_tree_model_node_add_column_full (model, value_type, prop_id, NULL, NULL);
+ return ephy_tree_model_node_add_column_full (model, value_type, prop_id, NULL, NULL);
}
/**
@@ -357,237 +349,230 @@ ephy_tree_model_node_add_prop_column (EphyTreeModelNode *model,
* Returns: the id of the new column
**/
int
-ephy_tree_model_node_add_func_column (EphyTreeModelNode *model,
- GType value_type,
- EphyTreeModelNodeValueFunc func,
- gpointer user_data)
+ephy_tree_model_node_add_func_column (EphyTreeModelNode *model,
+ GType value_type,
+ EphyTreeModelNodeValueFunc func,
+ gpointer user_data)
{
- return ephy_tree_model_node_add_column_full (model, value_type, -1, func, user_data);
+ return ephy_tree_model_node_add_column_full (model, value_type, -1, func, user_data);
}
static int
ephy_tree_model_node_get_n_columns (GtkTreeModel *tree_model)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- return model->columns_num;
+ return model->columns_num;
}
static GType
ephy_tree_model_node_get_column_type (GtkTreeModel *tree_model,
- int index)
+ int index)
{
- EphyTreeModelNodeColData *col;
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyTreeModelNodeColData *col;
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- col = g_ptr_array_index (model->columns, index);
+ col = g_ptr_array_index (model->columns, index);
- return col->type;
+ return col->type;
}
static void
ephy_tree_model_node_get_value (GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- int column,
- GValue *value)
+ GtkTreeIter *iter,
+ int column,
+ GValue *value)
{
- EphyTreeModelNodeColData *col;
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- EphyNode *node;
-
- g_return_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model));
- g_return_if_fail (iter != NULL);
- g_return_if_fail (iter->stamp == model->stamp);
-
- if (model->root == NULL)
- return;
-
- node = iter->user_data;
-
- col = g_ptr_array_index (model->columns, column);
-
- g_return_if_fail (col != NULL);
-
- if (col->prop_id >= 0)
- {
- if (!ephy_node_get_property (node, col->prop_id, value))
- {
- /* make sure to return a valid string anyway */
- g_value_init (value, col->type);
- if (col->type == G_TYPE_STRING)
- {
- g_value_set_string (value, "");
- }
- }
- }
-
- if (col->func)
- {
- col->func (node, value, col->user_data);
- }
+ EphyTreeModelNodeColData *col;
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyNode *node;
+
+ g_return_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model));
+ g_return_if_fail (iter != NULL);
+ g_return_if_fail (iter->stamp == model->stamp);
+
+ if (model->root == NULL)
+ return;
+
+ node = iter->user_data;
+
+ col = g_ptr_array_index (model->columns, column);
+
+ g_return_if_fail (col != NULL);
+
+ if (col->prop_id >= 0) {
+ if (!ephy_node_get_property (node, col->prop_id, value)) {
+ /* make sure to return a valid string anyway */
+ g_value_init (value, col->type);
+ if (col->type == G_TYPE_STRING) {
+ g_value_set_string (value, "");
+ }
+ }
+ }
+
+ if (col->func) {
+ col->func (node, value, col->user_data);
+ }
}
static GtkTreeModelFlags
ephy_tree_model_node_get_flags (GtkTreeModel *tree_model)
{
- return GTK_TREE_MODEL_ITERS_PERSIST | GTK_TREE_MODEL_LIST_ONLY;
+ return GTK_TREE_MODEL_ITERS_PERSIST | GTK_TREE_MODEL_LIST_ONLY;
}
static gboolean
ephy_tree_model_node_get_iter (GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- GtkTreePath *path)
+ GtkTreeIter *iter,
+ GtkTreePath *path)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- int i;
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ int i;
- g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (model), FALSE);
- g_return_val_if_fail (gtk_tree_path_get_depth (path) > 0, FALSE);
+ g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (model), FALSE);
+ g_return_val_if_fail (gtk_tree_path_get_depth (path) > 0, FALSE);
- if (model->root == NULL)
- return FALSE;
+ if (model->root == NULL)
+ return FALSE;
- i = gtk_tree_path_get_indices (path)[0];
+ i = gtk_tree_path_get_indices (path)[0];
- iter->stamp = model->stamp;
- iter->user_data = ephy_node_get_nth_child (model->root, i);
+ iter->stamp = model->stamp;
+ iter->user_data = ephy_node_get_nth_child (model->root, i);
- if (iter->user_data == NULL)
- {
- iter->stamp = 0;
- return FALSE;
- }
+ if (iter->user_data == NULL) {
+ iter->stamp = 0;
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
static GtkTreePath *
ephy_tree_model_node_get_path (GtkTreeModel *tree_model,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- EphyNode *node;
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyNode *node;
- g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model), NULL);
- g_return_val_if_fail (iter != NULL, NULL);
- g_return_val_if_fail (iter->user_data != NULL, NULL);
- g_return_val_if_fail (iter->stamp == model->stamp, NULL);
+ g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model), NULL);
+ g_return_val_if_fail (iter != NULL, NULL);
+ g_return_val_if_fail (iter->user_data != NULL, NULL);
+ g_return_val_if_fail (iter->stamp == model->stamp, NULL);
- if (model->root == NULL)
- return NULL;
+ if (model->root == NULL)
+ return NULL;
- node = iter->user_data;
+ node = iter->user_data;
- if (node == model->root)
- return gtk_tree_path_new ();
+ if (node == model->root)
+ return gtk_tree_path_new ();
- return get_path_real (model, node);
+ return get_path_real (model, node);
}
static gboolean
ephy_tree_model_node_iter_next (GtkTreeModel *tree_model,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- EphyNode *node;
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyNode *node;
- g_return_val_if_fail (iter != NULL, FALSE);
- g_return_val_if_fail (iter->user_data != NULL, FALSE);
- g_return_val_if_fail (iter->stamp == model->stamp, FALSE);
+ g_return_val_if_fail (iter != NULL, FALSE);
+ g_return_val_if_fail (iter->user_data != NULL, FALSE);
+ g_return_val_if_fail (iter->stamp == model->stamp, FALSE);
- if (model->root == NULL)
- return FALSE;
+ if (model->root == NULL)
+ return FALSE;
- node = iter->user_data;
+ node = iter->user_data;
- if (node == model->root)
- return FALSE;
+ if (node == model->root)
+ return FALSE;
- iter->user_data = ephy_node_get_next_child (model->root, node);
+ iter->user_data = ephy_node_get_next_child (model->root, node);
- return (iter->user_data != NULL);
+ return (iter->user_data != NULL);
}
static gboolean
ephy_tree_model_node_iter_children (GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- GtkTreeIter *parent)
+ GtkTreeIter *iter,
+ GtkTreeIter *parent)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- if (model->root == NULL)
- return FALSE;
+ if (model->root == NULL)
+ return FALSE;
- if (parent != NULL)
- return FALSE;
+ if (parent != NULL)
+ return FALSE;
- iter->stamp = model->stamp;
- iter->user_data = model->root;
+ iter->stamp = model->stamp;
+ iter->user_data = model->root;
- return TRUE;
+ return TRUE;
}
static gboolean
ephy_tree_model_node_iter_has_child (GtkTreeModel *tree_model,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
- return FALSE;
+ return FALSE;
}
static int
ephy_tree_model_node_iter_n_children (GtkTreeModel *tree_model,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model), -1);
+ g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model), -1);
- if (model->root == NULL)
- return 0;
+ if (model->root == NULL)
+ return 0;
- if (iter == NULL)
- return ephy_node_get_n_children (model->root);
+ if (iter == NULL)
+ return ephy_node_get_n_children (model->root);
- g_return_val_if_fail (model->stamp == iter->stamp, -1);
+ g_return_val_if_fail (model->stamp == iter->stamp, -1);
- return 0;
+ return 0;
}
static gboolean
ephy_tree_model_node_iter_nth_child (GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- GtkTreeIter *parent,
- int n)
+ GtkTreeIter *iter,
+ GtkTreeIter *parent,
+ int n)
{
- EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
- EphyNode *node;
+ EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model);
+ EphyNode *node;
- g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model), FALSE);
+ g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model), FALSE);
- if (model->root == NULL)
- return FALSE;
+ if (model->root == NULL)
+ return FALSE;
- if (parent != NULL)
- return FALSE;
+ if (parent != NULL)
+ return FALSE;
- node = ephy_node_get_nth_child (model->root, n);
+ node = ephy_node_get_nth_child (model->root, n);
- if (node != NULL)
- {
- iter->stamp = model->stamp;
- iter->user_data = node;
- return TRUE;
- }
- else
- return FALSE;
+ if (node != NULL) {
+ iter->stamp = model->stamp;
+ iter->user_data = node;
+ return TRUE;
+ } else
+ return FALSE;
}
static gboolean
ephy_tree_model_node_iter_parent (GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- GtkTreeIter *child)
+ GtkTreeIter *iter,
+ GtkTreeIter *child)
{
- return FALSE;
+ return FALSE;
}
/**
@@ -601,9 +586,9 @@ ephy_tree_model_node_iter_parent (GtkTreeModel *tree_model,
**/
EphyNode *
ephy_tree_model_node_node_from_iter (EphyTreeModelNode *model,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
- return iter->user_data;
+ return iter->user_data;
}
/**
@@ -616,26 +601,26 @@ ephy_tree_model_node_node_from_iter (EphyTreeModelNode *model,
**/
void
ephy_tree_model_node_iter_from_node (EphyTreeModelNode *model,
- EphyNode *node,
- GtkTreeIter *iter)
+ EphyNode *node,
+ GtkTreeIter *iter)
{
- iter->stamp = model->stamp;
- iter->user_data = node;
+ iter->stamp = model->stamp;
+ iter->user_data = node;
}
static void
ephy_tree_model_node_tree_model_interface_init (GtkTreeModelIface *iface)
{
- iface->get_flags = ephy_tree_model_node_get_flags;
- iface->get_iter = ephy_tree_model_node_get_iter;
- iface->get_path = ephy_tree_model_node_get_path;
- iface->iter_next = ephy_tree_model_node_iter_next;
- iface->iter_children = ephy_tree_model_node_iter_children;
- iface->iter_has_child = ephy_tree_model_node_iter_has_child;
- iface->iter_n_children = ephy_tree_model_node_iter_n_children;
- iface->iter_nth_child = ephy_tree_model_node_iter_nth_child;
- iface->iter_parent = ephy_tree_model_node_iter_parent;
- iface->get_n_columns = ephy_tree_model_node_get_n_columns;
- iface->get_column_type = ephy_tree_model_node_get_column_type;
- iface->get_value = ephy_tree_model_node_get_value;
+ iface->get_flags = ephy_tree_model_node_get_flags;
+ iface->get_iter = ephy_tree_model_node_get_iter;
+ iface->get_path = ephy_tree_model_node_get_path;
+ iface->iter_next = ephy_tree_model_node_iter_next;
+ iface->iter_children = ephy_tree_model_node_iter_children;
+ iface->iter_has_child = ephy_tree_model_node_iter_has_child;
+ iface->iter_n_children = ephy_tree_model_node_iter_n_children;
+ iface->iter_nth_child = ephy_tree_model_node_iter_nth_child;
+ iface->iter_parent = ephy_tree_model_node_iter_parent;
+ iface->get_n_columns = ephy_tree_model_node_get_n_columns;
+ iface->get_column_type = ephy_tree_model_node_get_column_type;
+ iface->get_value = ephy_tree_model_node_get_value;
}
diff --git a/lib/widgets/ephy-tree-model-sort.c b/lib/widgets/ephy-tree-model-sort.c
index 82d0441..96037f4 100644
--- a/lib/widgets/ephy-tree-model-sort.c
+++ b/lib/widgets/ephy-tree-model-sort.c
@@ -37,19 +37,18 @@
static void ephy_tree_model_sort_finalize (GObject *object);
static void ephy_tree_model_sort_multi_drag_source_interface_init (EggTreeMultiDragSourceIface *iface);
static gboolean ephy_tree_model_sort_multi_row_draggable (EggTreeMultiDragSource *drag_source,
- GList *path_list);
+ GList *path_list);
static gboolean ephy_tree_model_sort_multi_drag_data_get (EggTreeMultiDragSource *drag_source,
- GList *path_list,
- GtkSelectionData *selection_data);
+ GList *path_list,
+ GtkSelectionData *selection_data);
static gboolean ephy_tree_model_sort_multi_drag_data_delete (EggTreeMultiDragSource *drag_source,
- GList *path_list);
+ GList *path_list);
-struct _EphyTreeModelSort
-{
- GtkTreeModelSort parent_instance;
- char *str_list;
- int base_drag_column_id;
- int extra_drag_column_id;
+struct _EphyTreeModelSort {
+ GtkTreeModelSort parent_instance;
+ char *str_list;
+ int base_drag_column_id;
+ int extra_drag_column_id;
};
G_DEFINE_TYPE_WITH_CODE (EphyTreeModelSort, ephy_tree_model_sort, GTK_TYPE_TREE_MODEL_SORT,
@@ -59,26 +58,26 @@ G_DEFINE_TYPE_WITH_CODE (EphyTreeModelSort, ephy_tree_model_sort, GTK_TYPE_TREE_
static void
ephy_tree_model_sort_class_init (EphyTreeModelSortClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = ephy_tree_model_sort_finalize;
+ object_class->finalize = ephy_tree_model_sort_finalize;
}
static void
ephy_tree_model_sort_init (EphyTreeModelSort *ma)
{
- ma->base_drag_column_id = -1;
- ma->extra_drag_column_id = -1;
+ ma->base_drag_column_id = -1;
+ ma->extra_drag_column_id = -1;
}
static void
ephy_tree_model_sort_finalize (GObject *object)
{
- EphyTreeModelSort *model = EPHY_TREE_MODEL_SORT (object);
+ EphyTreeModelSort *model = EPHY_TREE_MODEL_SORT (object);
- g_free (model->str_list);
+ g_free (model->str_list);
- G_OBJECT_CLASS (ephy_tree_model_sort_parent_class)->finalize (object);
+ G_OBJECT_CLASS (ephy_tree_model_sort_parent_class)->finalize (object);
}
/**
@@ -89,32 +88,32 @@ ephy_tree_model_sort_finalize (GObject *object)
*
* Returns: a new #EphyTreeModelSort, as a #GtkWidget
**/
-GtkTreeModel*
+GtkTreeModel *
ephy_tree_model_sort_new (GtkTreeModel *child_model)
{
- GtkTreeModel *model;
+ GtkTreeModel *model;
- g_return_val_if_fail (child_model != NULL, NULL);
+ g_return_val_if_fail (child_model != NULL, NULL);
- model = GTK_TREE_MODEL (g_object_new (EPHY_TYPE_TREE_MODEL_SORT,
- "model", child_model,
- NULL));
+ model = GTK_TREE_MODEL (g_object_new (EPHY_TYPE_TREE_MODEL_SORT,
+ "model", child_model,
+ NULL));
- return model;
+ return model;
}
static void
ephy_tree_model_sort_multi_drag_source_interface_init (EggTreeMultiDragSourceIface *iface)
{
- iface->row_draggable = ephy_tree_model_sort_multi_row_draggable;
- iface->drag_data_get = ephy_tree_model_sort_multi_drag_data_get;
- iface->drag_data_delete = ephy_tree_model_sort_multi_drag_data_delete;
+ iface->row_draggable = ephy_tree_model_sort_multi_row_draggable;
+ iface->drag_data_get = ephy_tree_model_sort_multi_drag_data_get;
+ iface->drag_data_delete = ephy_tree_model_sort_multi_drag_data_delete;
}
static gboolean
ephy_tree_model_sort_multi_row_draggable (EggTreeMultiDragSource *drag_source, GList *path_list)
{
- return (EPHY_TREE_MODEL_SORT (drag_source)->base_drag_column_id >= 0);
+ return (EPHY_TREE_MODEL_SORT (drag_source)->base_drag_column_id >= 0);
}
/**
@@ -126,9 +125,9 @@ ephy_tree_model_sort_multi_row_draggable (EggTreeMultiDragSource *drag_source, G
**/
void
ephy_tree_model_sort_set_base_drag_column_id (EphyTreeModelSort *ms,
- int id)
+ int id)
{
- ms->base_drag_column_id = id;
+ ms->base_drag_column_id = id;
}
/**
@@ -140,76 +139,75 @@ ephy_tree_model_sort_set_base_drag_column_id (EphyTreeModelSort *ms,
**/
void
ephy_tree_model_sort_set_extra_drag_column_id (EphyTreeModelSort *ms,
- int id)
+ int id)
{
- ms->extra_drag_column_id = id;
+ ms->extra_drag_column_id = id;
}
static gboolean
ephy_tree_model_sort_multi_drag_data_delete (EggTreeMultiDragSource *drag_source,
- GList *path_list)
+ GList *path_list)
{
- return TRUE;
+ return TRUE;
}
static void
each_property_get_data_binder (EphyDragEachSelectedItemDataGet iteratee,
- gpointer iterator_context, gpointer data)
+ gpointer iterator_context, gpointer data)
{
- gpointer *context = (gpointer *) iterator_context;
- GList *path_list = (GList *) (context[0]);
- GList *i;
- EphyTreeModelSort *model = EPHY_TREE_MODEL_SORT (context[1]);
- GValue base_value = {0, }, extra_value = {0, };
-
- for (i = path_list; i != NULL; i = i->next)
- {
- GtkTreeIter iter;
- GtkTreePath *path = NULL;
- const char *base_data, *extra_data;
-
- path = gtk_tree_row_reference_get_path (i->data);
- gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
-
- gtk_tree_model_get_value (GTK_TREE_MODEL (model), &iter,
- model->base_drag_column_id,
- &base_value);
- base_data = g_value_get_string (&base_value);
-
- if (model->extra_drag_column_id >= 0) {
- gtk_tree_model_get_value (GTK_TREE_MODEL (model), &iter,
- model->extra_drag_column_id,
- &extra_value);
- extra_data = g_value_get_string (&extra_value);
- } else
- extra_data = NULL;
-
- g_return_if_fail (base_data != NULL);
-
- LOG ("Data get %s (%s)", base_data, extra_data);
-
- iteratee (base_data, extra_data, data);
-
- gtk_tree_path_free (path);
- g_value_unset (&base_value);
-
- if (model->extra_drag_column_id >= 0)
- g_value_unset (&extra_value);
- }
+ gpointer *context = (gpointer *)iterator_context;
+ GList *path_list = (GList *)(context[0]);
+ GList *i;
+ EphyTreeModelSort *model = EPHY_TREE_MODEL_SORT (context[1]);
+ GValue base_value = { 0, }, extra_value = { 0, };
+
+ for (i = path_list; i != NULL; i = i->next) {
+ GtkTreeIter iter;
+ GtkTreePath *path = NULL;
+ const char *base_data, *extra_data;
+
+ path = gtk_tree_row_reference_get_path (i->data);
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
+
+ gtk_tree_model_get_value (GTK_TREE_MODEL (model), &iter,
+ model->base_drag_column_id,
+ &base_value);
+ base_data = g_value_get_string (&base_value);
+
+ if (model->extra_drag_column_id >= 0) {
+ gtk_tree_model_get_value (GTK_TREE_MODEL (model), &iter,
+ model->extra_drag_column_id,
+ &extra_value);
+ extra_data = g_value_get_string (&extra_value);
+ } else
+ extra_data = NULL;
+
+ g_return_if_fail (base_data != NULL);
+
+ LOG ("Data get %s (%s)", base_data, extra_data);
+
+ iteratee (base_data, extra_data, data);
+
+ gtk_tree_path_free (path);
+ g_value_unset (&base_value);
+
+ if (model->extra_drag_column_id >= 0)
+ g_value_unset (&extra_value);
+ }
}
static gboolean
ephy_tree_model_sort_multi_drag_data_get (EggTreeMultiDragSource *drag_source,
- GList *path_list,
- GtkSelectionData *selection_data)
+ GList *path_list,
+ GtkSelectionData *selection_data)
{
- gpointer icontext[2];
+ gpointer icontext[2];
- icontext[0] = path_list;
- icontext[1] = drag_source;
+ icontext[0] = path_list;
+ icontext[1] = drag_source;
- ephy_dnd_drag_data_get (NULL, NULL, selection_data,
- 0, &icontext, each_property_get_data_binder);
+ ephy_dnd_drag_data_get (NULL, NULL, selection_data,
+ 0, &icontext, each_property_get_data_binder);
- return TRUE;
+ return TRUE;
}
diff --git a/lib/widgets/ephy-zoom-action.c b/lib/widgets/ephy-zoom-action.c
index fe1c899..5be4384 100644
--- a/lib/widgets/ephy-zoom-action.c
+++ b/lib/widgets/ephy-zoom-action.c
@@ -32,24 +32,21 @@
#define EPHY_ZOOM_ACTION_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_ZOOM_ACTION,
EphyZoomActionPrivate))
-struct _EphyZoomActionPrivate
-{
- float zoom;
+struct _EphyZoomActionPrivate {
+ float zoom;
};
-enum
-{
- PROP_0,
- PROP_ZOOM,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_ZOOM,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
-enum
-{
- ZOOM_TO_LEVEL_SIGNAL,
- LAST_SIGNAL
+enum {
+ ZOOM_TO_LEVEL_SIGNAL,
+ LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
@@ -59,149 +56,145 @@ G_DEFINE_TYPE (EphyZoomAction, ephy_zoom_action, GTK_TYPE_ACTION)
static void
proxy_menu_activate_cb (GtkMenuItem *menu_item, EphyZoomAction *action)
{
- gint index;
- float zoom;
+ gint index;
+ float zoom;
- /* menu item was toggled OFF */
- if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menu_item))) return;
+ /* menu item was toggled OFF */
+ if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menu_item))) return;
- index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "zoom-level"));
- zoom = zoom_levels[index].level;
+ index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "zoom-level"));
+ zoom = zoom_levels[index].level;
- if (zoom != action->priv->zoom)
- {
- g_signal_emit (action, signals[ZOOM_TO_LEVEL_SIGNAL], 0, zoom);
- }
+ if (zoom != action->priv->zoom) {
+ g_signal_emit (action, signals[ZOOM_TO_LEVEL_SIGNAL], 0, zoom);
+ }
}
static GtkWidget *
create_menu_item (GtkAction *action)
{
- EphyZoomActionPrivate *p = EPHY_ZOOM_ACTION (action)->priv;
- GtkWidget *menu, *menu_item;
- GSList *group = NULL;
- guint i;
+ EphyZoomActionPrivate *p = EPHY_ZOOM_ACTION (action)->priv;
+ GtkWidget *menu, *menu_item;
+ GSList *group = NULL;
+ guint i;
- menu = gtk_menu_new ();
+ menu = gtk_menu_new ();
- for (i = 0; i < n_zoom_levels; i++)
- {
- menu_item = gtk_radio_menu_item_new_with_label (group, _(zoom_levels[i].name));
- group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_item));
+ for (i = 0; i < n_zoom_levels; i++) {
+ menu_item = gtk_radio_menu_item_new_with_label (group, _(zoom_levels[i].name));
+ group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_item));
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
- p->zoom == zoom_levels[i].level);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
+ p->zoom == zoom_levels[i].level);
- gtk_widget_show (menu_item);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+ gtk_widget_show (menu_item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
- g_object_set_data (G_OBJECT (menu_item), "zoom-level", GINT_TO_POINTER (i));
- g_signal_connect_object (G_OBJECT (menu_item), "activate",
- G_CALLBACK (proxy_menu_activate_cb), action, 0);
- }
+ g_object_set_data (G_OBJECT (menu_item), "zoom-level", GINT_TO_POINTER (i));
+ g_signal_connect_object (G_OBJECT (menu_item), "activate",
+ G_CALLBACK (proxy_menu_activate_cb), action, 0);
+ }
- gtk_widget_show (menu);
+ gtk_widget_show (menu);
- menu_item = GTK_ACTION_CLASS (ephy_zoom_action_parent_class)->create_menu_item (action);
+ menu_item = GTK_ACTION_CLASS (ephy_zoom_action_parent_class)->create_menu_item (action);
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), menu);
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), menu);
- gtk_widget_show (menu_item);
+ gtk_widget_show (menu_item);
- return menu_item;
+ return menu_item;
}
static void
-ephy_zoom_action_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ephy_zoom_action_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- EphyZoomAction *action;
-
- action = EPHY_ZOOM_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_ZOOM:
- action->priv->zoom = g_value_get_float (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
+ EphyZoomAction *action;
+
+ action = EPHY_ZOOM_ACTION (object);
+
+ switch (prop_id) {
+ case PROP_ZOOM:
+ action->priv->zoom = g_value_get_float (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
-ephy_zoom_action_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ephy_zoom_action_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- EphyZoomAction *action;
-
- action = EPHY_ZOOM_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_ZOOM:
- g_value_set_float (value, action->priv->zoom);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
+ EphyZoomAction *action;
+
+ action = EPHY_ZOOM_ACTION (object);
+
+ switch (prop_id) {
+ case PROP_ZOOM:
+ g_value_set_float (value, action->priv->zoom);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
ephy_zoom_action_class_init (EphyZoomActionClass *class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
- GtkActionClass *action_class = GTK_ACTION_CLASS (class);
-
- object_class->set_property = ephy_zoom_action_set_property;
- object_class->get_property = ephy_zoom_action_get_property;
-
- action_class->create_menu_item = create_menu_item;
-
- /**
- * EphyZoomAction:zoom:
- *
- * The current value of #EphyZoomAction, as a float.
- */
- obj_properties[PROP_ZOOM] =
- g_param_spec_float ("zoom", NULL, NULL,
- ZOOM_MINIMAL,
- ZOOM_MAXIMAL,
- 1.0,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
-
- /**
- * EphyZoomAction::zoom-to-level:
- * @action: the object on which the signal is emitted
- * @level: new zoom level
- *
- * Emitted when the user changes the value of the #EphyZoomAction.
- */
- signals[ZOOM_TO_LEVEL_SIGNAL] =
- g_signal_new ("zoom-to-level",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EphyZoomActionClass, zoom_to_level),
- NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- G_TYPE_FLOAT);
-
- g_type_class_add_private (object_class, sizeof (EphyZoomActionPrivate));
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GtkActionClass *action_class = GTK_ACTION_CLASS (class);
+
+ object_class->set_property = ephy_zoom_action_set_property;
+ object_class->get_property = ephy_zoom_action_get_property;
+
+ action_class->create_menu_item = create_menu_item;
+
+ /**
+ * EphyZoomAction:zoom:
+ *
+ * The current value of #EphyZoomAction, as a float.
+ */
+ obj_properties[PROP_ZOOM] =
+ g_param_spec_float ("zoom", NULL, NULL,
+ ZOOM_MINIMAL,
+ ZOOM_MAXIMAL,
+ 1.0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+
+ /**
+ * EphyZoomAction::zoom-to-level:
+ * @action: the object on which the signal is emitted
+ * @level: new zoom level
+ *
+ * Emitted when the user changes the value of the #EphyZoomAction.
+ */
+ signals[ZOOM_TO_LEVEL_SIGNAL] =
+ g_signal_new ("zoom-to-level",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EphyZoomActionClass, zoom_to_level),
+ NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_FLOAT);
+
+ g_type_class_add_private (object_class, sizeof (EphyZoomActionPrivate));
}
static void
ephy_zoom_action_init (EphyZoomAction *action)
{
- action->priv = EPHY_ZOOM_ACTION_GET_PRIVATE (action);
+ action->priv = EPHY_ZOOM_ACTION_GET_PRIVATE (action);
- action->priv->zoom = 1.0;
+ action->priv->zoom = 1.0;
}
/**
@@ -214,12 +207,12 @@ ephy_zoom_action_init (EphyZoomAction *action)
void
ephy_zoom_action_set_zoom_level (EphyZoomAction *action, float zoom)
{
- g_return_if_fail (EPHY_IS_ZOOM_ACTION (action));
-
- if (zoom < ZOOM_MINIMAL || zoom > ZOOM_MAXIMAL) return;
+ g_return_if_fail (EPHY_IS_ZOOM_ACTION (action));
- action->priv->zoom = zoom;
- g_object_notify_by_pspec (G_OBJECT (action), obj_properties[PROP_ZOOM]);
+ if (zoom < ZOOM_MINIMAL || zoom > ZOOM_MAXIMAL) return;
+
+ action->priv->zoom = zoom;
+ g_object_notify_by_pspec (G_OBJECT (action), obj_properties[PROP_ZOOM]);
}
/**
@@ -233,7 +226,7 @@ ephy_zoom_action_set_zoom_level (EphyZoomAction *action, float zoom)
float
ephy_zoom_action_get_zoom_level (EphyZoomAction *action)
{
- g_return_val_if_fail (EPHY_IS_ZOOM_ACTION (action), 1.0);
-
- return action->priv->zoom;
+ g_return_val_if_fail (EPHY_IS_ZOOM_ACTION (action), 1.0);
+
+ return action->priv->zoom;
}
diff --git a/lib/widgets/nautilus-floating-bar.c b/lib/widgets/nautilus-floating-bar.c
index 52219b9..586dcd0 100644
--- a/lib/widgets/nautilus-floating-bar.c
+++ b/lib/widgets/nautilus-floating-bar.c
@@ -28,27 +28,27 @@
#include "nautilus-floating-bar.h"
struct _NautilusFloatingBarDetails {
- gchar *primary_label;
- gchar *details_label;
-
- GtkWidget *primary_label_widget;
- GtkWidget *details_label_widget;
- GtkWidget *spinner;
- gboolean show_spinner;
- gboolean is_interactive;
- guint hover_timeout_id;
+ gchar *primary_label;
+ gchar *details_label;
+
+ GtkWidget *primary_label_widget;
+ GtkWidget *details_label_widget;
+ GtkWidget *spinner;
+ gboolean show_spinner;
+ gboolean is_interactive;
+ guint hover_timeout_id;
};
enum {
- PROP_PRIMARY_LABEL = 1,
- PROP_DETAILS_LABEL,
- PROP_SHOW_SPINNER,
- NUM_PROPERTIES
+ PROP_PRIMARY_LABEL = 1,
+ PROP_DETAILS_LABEL,
+ PROP_SHOW_SPINNER,
+ NUM_PROPERTIES
};
enum {
- ACTION,
- NUM_SIGNALS
+ ACTION,
+ NUM_SIGNALS
};
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
@@ -58,458 +58,458 @@ G_DEFINE_TYPE (NautilusFloatingBar, nautilus_floating_bar,
GTK_TYPE_BOX);
static void
-action_button_clicked_cb (GtkButton *button,
- NautilusFloatingBar *self)
+action_button_clicked_cb (GtkButton *button,
+ NautilusFloatingBar *self)
{
- gint action_id;
+ gint action_id;
- action_id = GPOINTER_TO_INT
- (g_object_get_data (G_OBJECT (button), "action-id"));
-
- g_signal_emit (self, signals[ACTION], 0, action_id);
+ action_id = GPOINTER_TO_INT
+ (g_object_get_data (G_OBJECT (button), "action-id"));
+
+ g_signal_emit (self, signals[ACTION], 0, action_id);
}
static void
nautilus_floating_bar_finalize (GObject *obj)
{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (obj);
+ NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (obj);
- g_free (self->priv->primary_label);
- g_free (self->priv->details_label);
+ g_free (self->priv->primary_label);
+ g_free (self->priv->details_label);
- G_OBJECT_CLASS (nautilus_floating_bar_parent_class)->finalize (obj);
+ G_OBJECT_CLASS (nautilus_floating_bar_parent_class)->finalize (obj);
}
static void
-nautilus_floating_bar_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+nautilus_floating_bar_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (object);
-
- switch (property_id) {
- case PROP_PRIMARY_LABEL:
- g_value_set_string (value, self->priv->primary_label);
- break;
- case PROP_DETAILS_LABEL:
- g_value_set_string (value, self->priv->details_label);
- break;
- case PROP_SHOW_SPINNER:
- g_value_set_boolean (value, self->priv->show_spinner);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
+ NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (object);
+
+ switch (property_id) {
+ case PROP_PRIMARY_LABEL:
+ g_value_set_string (value, self->priv->primary_label);
+ break;
+ case PROP_DETAILS_LABEL:
+ g_value_set_string (value, self->priv->details_label);
+ break;
+ case PROP_SHOW_SPINNER:
+ g_value_set_boolean (value, self->priv->show_spinner);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
}
static void
-nautilus_floating_bar_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
+nautilus_floating_bar_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (object);
-
- switch (property_id) {
- case PROP_PRIMARY_LABEL:
- nautilus_floating_bar_set_primary_label (self, g_value_get_string (value));
- break;
- case PROP_DETAILS_LABEL:
- nautilus_floating_bar_set_details_label (self, g_value_get_string (value));
- break;
- case PROP_SHOW_SPINNER:
- nautilus_floating_bar_set_show_spinner (self, g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
+ NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (object);
+
+ switch (property_id) {
+ case PROP_PRIMARY_LABEL:
+ nautilus_floating_bar_set_primary_label (self, g_value_get_string (value));
+ break;
+ case PROP_DETAILS_LABEL:
+ nautilus_floating_bar_set_details_label (self, g_value_get_string (value));
+ break;
+ case PROP_SHOW_SPINNER:
+ nautilus_floating_bar_set_show_spinner (self, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
}
static void
update_labels (NautilusFloatingBar *self)
{
- gboolean primary_visible, details_visible;
+ gboolean primary_visible, details_visible;
- primary_visible = (self->priv->primary_label != NULL) &&
- (strlen (self->priv->primary_label) > 0);
- details_visible = (self->priv->details_label != NULL) &&
- (strlen (self->priv->details_label) > 0);
+ primary_visible = (self->priv->primary_label != NULL) &&
+ (strlen (self->priv->primary_label) > 0);
+ details_visible = (self->priv->details_label != NULL) &&
+ (strlen (self->priv->details_label) > 0);
- gtk_label_set_text (GTK_LABEL (self->priv->primary_label_widget),
- self->priv->primary_label);
- gtk_widget_set_visible (self->priv->primary_label_widget, primary_visible);
+ gtk_label_set_text (GTK_LABEL (self->priv->primary_label_widget),
+ self->priv->primary_label);
+ gtk_widget_set_visible (self->priv->primary_label_widget, primary_visible);
- gtk_label_set_text (GTK_LABEL (self->priv->details_label_widget),
- self->priv->details_label);
- gtk_widget_set_visible (self->priv->details_label_widget, details_visible);
+ gtk_label_set_text (GTK_LABEL (self->priv->details_label_widget),
+ self->priv->details_label);
+ gtk_widget_set_visible (self->priv->details_label_widget, details_visible);
}
static void
nautilus_floating_bar_show (GtkWidget *widget)
{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);
+ NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);
- /* Epiphany: never show the bar on top of the web view. */
- if (gtk_widget_get_valign (widget) == GTK_ALIGN_START)
- return;
+ /* Epiphany: never show the bar on top of the web view. */
+ if (gtk_widget_get_valign (widget) == GTK_ALIGN_START)
+ return;
- GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->show (widget);
+ GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->show (widget);
- if (self->priv->show_spinner) {
- gtk_spinner_start (GTK_SPINNER (self->priv->spinner));
- }
+ if (self->priv->show_spinner) {
+ gtk_spinner_start (GTK_SPINNER (self->priv->spinner));
+ }
}
static void
nautilus_floating_bar_hide (GtkWidget *widget)
{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);
+ NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);
- GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->hide (widget);
+ GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->hide (widget);
- gtk_spinner_stop (GTK_SPINNER (self->priv->spinner));
+ gtk_spinner_stop (GTK_SPINNER (self->priv->spinner));
}
typedef struct {
- GtkWidget *overlay;
- GtkWidget *floating_bar;
- GdkDevice *device;
- gint y_down_limit;
- gint y_upper_limit;
- gboolean first_time;
+ GtkWidget *overlay;
+ GtkWidget *floating_bar;
+ GdkDevice *device;
+ gint y_down_limit;
+ gint y_upper_limit;
+ gboolean first_time;
} CheckPointerData;
static gboolean
check_pointer_timeout (gpointer user_data)
{
- CheckPointerData *data = user_data;
- gint pointer_y = -1;
-
- gdk_window_get_device_position (gtk_widget_get_window (data->overlay), data->device,
- NULL, &pointer_y, NULL);
-
- if (pointer_y == -1 || pointer_y < data->y_down_limit || pointer_y > data->y_upper_limit) {
- if (!data->first_time) {
- gtk_widget_set_valign (data->floating_bar, GTK_ALIGN_END);
- nautilus_floating_bar_show (data->floating_bar);
- }
- NAUTILUS_FLOATING_BAR (data->floating_bar)->priv->hover_timeout_id = 0;
- return G_SOURCE_REMOVE;
- }
-
- if (data->first_time) {
- // Hide floating bar at top position of widget
- nautilus_floating_bar_hide (data->floating_bar);
- gtk_widget_set_valign (data->floating_bar, GTK_ALIGN_START);
- gtk_widget_queue_resize (data->floating_bar);
- }
-
- data->first_time = FALSE;
- return G_SOURCE_CONTINUE;
+ CheckPointerData *data = user_data;
+ gint pointer_y = -1;
+
+ gdk_window_get_device_position (gtk_widget_get_window (data->overlay), data->device,
+ NULL, &pointer_y, NULL);
+
+ if (pointer_y == -1 || pointer_y < data->y_down_limit || pointer_y > data->y_upper_limit) {
+ if (!data->first_time) {
+ gtk_widget_set_valign (data->floating_bar, GTK_ALIGN_END);
+ nautilus_floating_bar_show (data->floating_bar);
+ }
+ NAUTILUS_FLOATING_BAR (data->floating_bar)->priv->hover_timeout_id = 0;
+ return G_SOURCE_REMOVE;
+ }
+
+ if (data->first_time) {
+ /* Hide floating bar at top position of widget */
+ nautilus_floating_bar_hide (data->floating_bar);
+ gtk_widget_set_valign (data->floating_bar, GTK_ALIGN_START);
+ gtk_widget_queue_resize (data->floating_bar);
+ }
+
+ data->first_time = FALSE;
+ return G_SOURCE_CONTINUE;
}
static gboolean
overlay_enter_notify_cb (GtkWidget *parent,
- GdkEventCrossing *event,
- gpointer user_data)
+ GdkEventCrossing *event,
+ gpointer user_data)
{
- GtkWidget *widget = user_data;
- CheckPointerData *data;
- GtkAllocation alloc_parent;
- gint y_pos;
-
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);
-
- if (self->priv->hover_timeout_id != 0) {
- g_source_remove (self->priv->hover_timeout_id);
- self->priv->hover_timeout_id = 0;
- }
-
- if (event->window != gtk_widget_get_window (widget)) {
- return GDK_EVENT_PROPAGATE;
- }
-
- if (NAUTILUS_FLOATING_BAR (widget)->priv->is_interactive) {
- return GDK_EVENT_PROPAGATE;
- }
-
- gtk_widget_get_allocation (parent, &alloc_parent);
- gdk_window_get_position (gtk_widget_get_window (widget), NULL, &y_pos);
-
- data = g_new (CheckPointerData, 1);
- data->overlay = parent;
- data->floating_bar = widget;
- data->device = gdk_event_get_device ((GdkEvent *) event);
- data->y_down_limit = y_pos;
- data->y_upper_limit = alloc_parent.height;
- data->first_time = TRUE;
-
- self->priv->hover_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT, 250,
- check_pointer_timeout, data,
- g_free);
- g_source_set_name_by_id (self->priv->hover_timeout_id, "[nautilus-floating-bar]
overlay_enter_notify_cb");
-
- return GDK_EVENT_STOP;
+ GtkWidget *widget = user_data;
+ CheckPointerData *data;
+ GtkAllocation alloc_parent;
+ gint y_pos;
+
+ NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);
+
+ if (self->priv->hover_timeout_id != 0) {
+ g_source_remove (self->priv->hover_timeout_id);
+ self->priv->hover_timeout_id = 0;
+ }
+
+ if (event->window != gtk_widget_get_window (widget)) {
+ return GDK_EVENT_PROPAGATE;
+ }
+
+ if (NAUTILUS_FLOATING_BAR (widget)->priv->is_interactive) {
+ return GDK_EVENT_PROPAGATE;
+ }
+
+ gtk_widget_get_allocation (parent, &alloc_parent);
+ gdk_window_get_position (gtk_widget_get_window (widget), NULL, &y_pos);
+
+ data = g_new (CheckPointerData, 1);
+ data->overlay = parent;
+ data->floating_bar = widget;
+ data->device = gdk_event_get_device ((GdkEvent *)event);
+ data->y_down_limit = y_pos;
+ data->y_upper_limit = alloc_parent.height;
+ data->first_time = TRUE;
+
+ self->priv->hover_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT, 250,
+ check_pointer_timeout, data,
+ g_free);
+ g_source_set_name_by_id (self->priv->hover_timeout_id, "[nautilus-floating-bar] overlay_enter_notify_cb");
+
+ return GDK_EVENT_STOP;
}
static void
nautilus_floating_bar_parent_set (GtkWidget *widget,
- GtkWidget *old_parent)
+ GtkWidget *old_parent)
{
- GtkWidget *parent;
+ GtkWidget *parent;
- parent = gtk_widget_get_parent (widget);
+ parent = gtk_widget_get_parent (widget);
- if (old_parent != NULL) {
- g_signal_handlers_disconnect_by_func (old_parent,
- overlay_enter_notify_cb, widget);
- }
+ if (old_parent != NULL) {
+ g_signal_handlers_disconnect_by_func (old_parent,
+ overlay_enter_notify_cb, widget);
+ }
- if (parent != NULL) {
- g_signal_connect (parent, "enter-notify-event",
- G_CALLBACK (overlay_enter_notify_cb), widget);
- }
+ if (parent != NULL) {
+ g_signal_connect (parent, "enter-notify-event",
+ G_CALLBACK (overlay_enter_notify_cb), widget);
+ }
}
static gboolean
nautilus_floating_bar_draw (GtkWidget *widget,
- cairo_t *cr)
+ cairo_t *cr)
{
- GtkStyleContext *context;
+ GtkStyleContext *context;
- context = gtk_widget_get_style_context (widget);
+ context = gtk_widget_get_style_context (widget);
- gtk_style_context_save (context);
- gtk_style_context_set_state (context, gtk_widget_get_state_flags (widget));
+ gtk_style_context_save (context);
+ gtk_style_context_set_state (context, gtk_widget_get_state_flags (widget));
- gtk_render_background (context, cr, 0, 0,
- gtk_widget_get_allocated_width (widget),
- gtk_widget_get_allocated_height (widget));
+ gtk_render_background (context, cr, 0, 0,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
- gtk_render_frame (context, cr, 0, 0,
- gtk_widget_get_allocated_width (widget),
- gtk_widget_get_allocated_height (widget));
+ gtk_render_frame (context, cr, 0, 0,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
- gtk_style_context_restore (context);
+ gtk_style_context_restore (context);
- return GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->draw (widget, cr);;
+ return GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->draw (widget, cr);;
}
static void
nautilus_floating_bar_constructed (GObject *obj)
{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (obj);
- GtkWidget *w, *box, *labels_box;
-
- G_OBJECT_CLASS (nautilus_floating_bar_parent_class)->constructed (obj);
-
- box = GTK_WIDGET (obj);
-
- w = gtk_spinner_new ();
- gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0);
- gtk_widget_set_visible (w, self->priv->show_spinner);
- self->priv->spinner = w;
-
- gtk_widget_set_size_request (w, 16, 16);
- gtk_widget_set_margin_left (w, 8);
-
- labels_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_box_pack_start (GTK_BOX (box), labels_box, TRUE, TRUE, 0);
- g_object_set (labels_box,
- "margin-top", 2,
- "margin-bottom", 2,
- "margin-start", 12,
- "margin-end", 12,
- NULL);
- gtk_widget_show (labels_box);
-
- w = gtk_label_new (NULL);
- gtk_label_set_ellipsize (GTK_LABEL (w), PANGO_ELLIPSIZE_MIDDLE);
- gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
- gtk_container_add (GTK_CONTAINER (labels_box), w);
- self->priv->primary_label_widget = w;
- gtk_widget_show (w);
-
- w = gtk_label_new (NULL);
- gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
- gtk_container_add (GTK_CONTAINER (labels_box), w);
- self->priv->details_label_widget = w;
- gtk_widget_show (w);
+ NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (obj);
+ GtkWidget *w, *box, *labels_box;
+
+ G_OBJECT_CLASS (nautilus_floating_bar_parent_class)->constructed (obj);
+
+ box = GTK_WIDGET (obj);
+
+ w = gtk_spinner_new ();
+ gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0);
+ gtk_widget_set_visible (w, self->priv->show_spinner);
+ self->priv->spinner = w;
+
+ gtk_widget_set_size_request (w, 16, 16);
+ gtk_widget_set_margin_left (w, 8);
+
+ labels_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ gtk_box_pack_start (GTK_BOX (box), labels_box, TRUE, TRUE, 0);
+ g_object_set (labels_box,
+ "margin-top", 2,
+ "margin-bottom", 2,
+ "margin-start", 12,
+ "margin-end", 12,
+ NULL);
+ gtk_widget_show (labels_box);
+
+ w = gtk_label_new (NULL);
+ gtk_label_set_ellipsize (GTK_LABEL (w), PANGO_ELLIPSIZE_MIDDLE);
+ gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
+ gtk_container_add (GTK_CONTAINER (labels_box), w);
+ self->priv->primary_label_widget = w;
+ gtk_widget_show (w);
+
+ w = gtk_label_new (NULL);
+ gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
+ gtk_container_add (GTK_CONTAINER (labels_box), w);
+ self->priv->details_label_widget = w;
+ gtk_widget_show (w);
}
static void
nautilus_floating_bar_init (NautilusFloatingBar *self)
{
- GtkStyleContext *context;
+ GtkStyleContext *context;
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NAUTILUS_TYPE_FLOATING_BAR,
- NautilusFloatingBarDetails);
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NAUTILUS_TYPE_FLOATING_BAR,
+ NautilusFloatingBarDetails);
- context = gtk_widget_get_style_context (GTK_WIDGET (self));
- gtk_style_context_add_class (context, "floating-bar");
+ context = gtk_widget_get_style_context (GTK_WIDGET (self));
+ gtk_style_context_add_class (context, "floating-bar");
}
static void
nautilus_floating_bar_class_init (NautilusFloatingBarClass *klass)
{
- GObjectClass *oclass = G_OBJECT_CLASS (klass);
- GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass);
-
- oclass->constructed = nautilus_floating_bar_constructed;
- oclass->set_property = nautilus_floating_bar_set_property;
- oclass->get_property = nautilus_floating_bar_get_property;
- oclass->finalize = nautilus_floating_bar_finalize;
-
- wclass->draw = nautilus_floating_bar_draw;
- wclass->show = nautilus_floating_bar_show;
- wclass->hide = nautilus_floating_bar_hide;
- wclass->parent_set = nautilus_floating_bar_parent_set;
-
- properties[PROP_PRIMARY_LABEL] =
- g_param_spec_string ("primary-label",
- "Bar's primary label",
- "Primary label displayed by the bar",
- NULL,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
- properties[PROP_DETAILS_LABEL] =
- g_param_spec_string ("details-label",
- "Bar's details label",
- "Details label displayed by the bar",
- NULL,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
- properties[PROP_SHOW_SPINNER] =
- g_param_spec_boolean ("show-spinner",
- "Show spinner",
- "Whether a spinner should be shown in the floating bar",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- signals[ACTION] =
- g_signal_new ("action",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE, 1,
- G_TYPE_INT);
-
- g_type_class_add_private (klass, sizeof (NautilusFloatingBarDetails));
- g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
+ GObjectClass *oclass = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass);
+
+ oclass->constructed = nautilus_floating_bar_constructed;
+ oclass->set_property = nautilus_floating_bar_set_property;
+ oclass->get_property = nautilus_floating_bar_get_property;
+ oclass->finalize = nautilus_floating_bar_finalize;
+
+ wclass->draw = nautilus_floating_bar_draw;
+ wclass->show = nautilus_floating_bar_show;
+ wclass->hide = nautilus_floating_bar_hide;
+ wclass->parent_set = nautilus_floating_bar_parent_set;
+
+ properties[PROP_PRIMARY_LABEL] =
+ g_param_spec_string ("primary-label",
+ "Bar's primary label",
+ "Primary label displayed by the bar",
+ NULL,
+ G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
+ properties[PROP_DETAILS_LABEL] =
+ g_param_spec_string ("details-label",
+ "Bar's details label",
+ "Details label displayed by the bar",
+ NULL,
+ G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
+ properties[PROP_SHOW_SPINNER] =
+ g_param_spec_boolean ("show-spinner",
+ "Show spinner",
+ "Whether a spinner should be shown in the floating bar",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ signals[ACTION] =
+ g_signal_new ("action",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE, 1,
+ G_TYPE_INT);
+
+ g_type_class_add_private (klass, sizeof (NautilusFloatingBarDetails));
+ g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
}
void
nautilus_floating_bar_set_primary_label (NautilusFloatingBar *self,
- const gchar *label)
+ const gchar *label)
{
- if (g_strcmp0 (self->priv->primary_label, label) != 0) {
- g_free (self->priv->primary_label);
- self->priv->primary_label = g_strdup (label);
+ if (g_strcmp0 (self->priv->primary_label, label) != 0) {
+ g_free (self->priv->primary_label);
+ self->priv->primary_label = g_strdup (label);
- g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PRIMARY_LABEL]);
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PRIMARY_LABEL]);
- update_labels (self);
- }
+ update_labels (self);
+ }
}
void
nautilus_floating_bar_set_details_label (NautilusFloatingBar *self,
- const gchar *label)
+ const gchar *label)
{
- if (g_strcmp0 (self->priv->details_label, label) != 0) {
- g_free (self->priv->details_label);
- self->priv->details_label = g_strdup (label);
+ if (g_strcmp0 (self->priv->details_label, label) != 0) {
+ g_free (self->priv->details_label);
+ self->priv->details_label = g_strdup (label);
- g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DETAILS_LABEL]);
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DETAILS_LABEL]);
- update_labels (self);
- }
+ update_labels (self);
+ }
}
void
nautilus_floating_bar_set_labels (NautilusFloatingBar *self,
- const gchar *primary_label,
- const gchar *details_label)
+ const gchar *primary_label,
+ const gchar *details_label)
{
- nautilus_floating_bar_set_primary_label (self, primary_label);
- nautilus_floating_bar_set_details_label (self, details_label);
+ nautilus_floating_bar_set_primary_label (self, primary_label);
+ nautilus_floating_bar_set_details_label (self, details_label);
}
void
nautilus_floating_bar_set_show_spinner (NautilusFloatingBar *self,
- gboolean show_spinner)
+ gboolean show_spinner)
{
- if (self->priv->show_spinner != show_spinner) {
- self->priv->show_spinner = show_spinner;
- gtk_widget_set_visible (self->priv->spinner,
- show_spinner);
+ if (self->priv->show_spinner != show_spinner) {
+ self->priv->show_spinner = show_spinner;
+ gtk_widget_set_visible (self->priv->spinner,
+ show_spinner);
- g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHOW_SPINNER]);
- }
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHOW_SPINNER]);
+ }
}
GtkWidget *
nautilus_floating_bar_new (const gchar *primary_label,
- const gchar *details_label,
- gboolean show_spinner)
+ const gchar *details_label,
+ gboolean show_spinner)
{
- return g_object_new (NAUTILUS_TYPE_FLOATING_BAR,
- "primary-label", primary_label,
- "details-label", details_label,
- "show-spinner", show_spinner,
- "orientation", GTK_ORIENTATION_HORIZONTAL,
- "spacing", 8,
- NULL);
+ return g_object_new (NAUTILUS_TYPE_FLOATING_BAR,
+ "primary-label", primary_label,
+ "details-label", details_label,
+ "show-spinner", show_spinner,
+ "orientation", GTK_ORIENTATION_HORIZONTAL,
+ "spacing", 8,
+ NULL);
}
void
nautilus_floating_bar_add_action (NautilusFloatingBar *self,
- const gchar *icon_name,
- gint action_id)
+ const gchar *icon_name,
+ gint action_id)
{
- GtkWidget *w, *button;
+ GtkWidget *w, *button;
- w = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
- gtk_widget_show (w);
+ w = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
+ gtk_widget_show (w);
- button = gtk_button_new ();
- gtk_button_set_image (GTK_BUTTON (button), w);
- gtk_box_pack_end (GTK_BOX (self), button, FALSE, FALSE, 0);
- gtk_widget_show (button);
+ button = gtk_button_new ();
+ gtk_button_set_image (GTK_BUTTON (button), w);
+ gtk_box_pack_end (GTK_BOX (self), button, FALSE, FALSE, 0);
+ gtk_widget_show (button);
- g_object_set_data (G_OBJECT (button), "action-id",
- GINT_TO_POINTER (action_id));
+ g_object_set_data (G_OBJECT (button), "action-id",
+ GINT_TO_POINTER (action_id));
- g_signal_connect (button, "clicked",
- G_CALLBACK (action_button_clicked_cb), self);
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (action_button_clicked_cb), self);
- self->priv->is_interactive = TRUE;
+ self->priv->is_interactive = TRUE;
}
void
nautilus_floating_bar_cleanup_actions (NautilusFloatingBar *self)
{
- GtkWidget *widget;
- GList *children, *l;
- gpointer data;
+ GtkWidget *widget;
+ GList *children, *l;
+ gpointer data;
- children = gtk_container_get_children (GTK_CONTAINER (self));
- l = children;
+ children = gtk_container_get_children (GTK_CONTAINER (self));
+ l = children;
- while (l != NULL) {
- widget = l->data;
- data = g_object_get_data (G_OBJECT (widget), "action-id");
- l = l->next;
+ while (l != NULL) {
+ widget = l->data;
+ data = g_object_get_data (G_OBJECT (widget), "action-id");
+ l = l->next;
- if (data != NULL) {
- /* destroy this */
- gtk_widget_destroy (widget);
- }
- }
+ if (data != NULL) {
+ /* destroy this */
+ gtk_widget_destroy (widget);
+ }
+ }
- g_list_free (children);
+ g_list_free (children);
- self->priv->is_interactive = FALSE;
+ self->priv->is_interactive = FALSE;
}
diff --git a/src/bookmarks/ephy-bookmark-action-group.c b/src/bookmarks/ephy-bookmark-action-group.c
index a2ad23b..c96be07 100644
--- a/src/bookmarks/ephy-bookmark-action-group.c
+++ b/src/bookmarks/ephy-bookmark-action-group.c
@@ -31,141 +31,136 @@
#include <string.h>
static void
-smart_added_cb (EphyNode *parent,
- EphyNode *child,
- GtkActionGroup *action_group)
+smart_added_cb (EphyNode *parent,
+ EphyNode *child,
+ GtkActionGroup *action_group)
{
- GtkAction *action;
- char name[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE];
+ GtkAction *action;
+ char name[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE];
- EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, child);
+ EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, child);
- action = gtk_action_group_get_action (action_group, name);
-
- if (action != NULL)
- {
- ephy_bookmark_action_updated ((EphyBookmarkAction *) action);
- }
+ action = gtk_action_group_get_action (action_group, name);
+
+ if (action != NULL) {
+ ephy_bookmark_action_updated ((EphyBookmarkAction *)action);
+ }
}
static void
-smart_removed_cb (EphyNode *parent,
- EphyNode *child,
- guint index,
- GtkActionGroup *action_group)
+smart_removed_cb (EphyNode *parent,
+ EphyNode *child,
+ guint index,
+ GtkActionGroup *action_group)
{
- GtkAction *action;
- char name[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE];
+ GtkAction *action;
+ char name[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE];
+
+ EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, child);
- EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, child);
+ action = gtk_action_group_get_action (action_group, name);
- action = gtk_action_group_get_action (action_group, name);
-
- if (action != NULL)
- {
- ephy_bookmark_action_updated ((EphyBookmarkAction *) action);
- }
+ if (action != NULL) {
+ ephy_bookmark_action_updated ((EphyBookmarkAction *)action);
+ }
}
static void
-node_changed_cb (EphyNode *parent,
- EphyNode *child,
- guint property_id,
- GtkActionGroup *action_group)
+node_changed_cb (EphyNode *parent,
+ EphyNode *child,
+ guint property_id,
+ GtkActionGroup *action_group)
{
- GtkAction *action;
- char name[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE];
+ GtkAction *action;
+ char name[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE];
- EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, child);
+ EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, child);
- action = gtk_action_group_get_action (action_group, name);
-
- if (action != NULL)
- {
- ephy_bookmark_action_updated ((EphyBookmarkAction *) action);
- }
+ action = gtk_action_group_get_action (action_group, name);
+
+ if (action != NULL) {
+ ephy_bookmark_action_updated ((EphyBookmarkAction *)action);
+ }
}
static void
-node_added_cb (EphyNode *parent,
- EphyNode *child,
- GtkActionGroup *action_group)
+node_added_cb (EphyNode *parent,
+ EphyNode *child,
+ GtkActionGroup *action_group)
{
- GtkAction *action;
- char name[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE];
- char accel[256];
+ GtkAction *action;
+ char name[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE];
+ char accel[256];
- EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, child);
+ EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, child);
- action = ephy_bookmark_action_new (child, name);
+ action = ephy_bookmark_action_new (child, name);
- g_signal_connect_swapped (action, "open-link",
- G_CALLBACK (ephy_link_open), action_group);
+ g_signal_connect_swapped (action, "open-link",
+ G_CALLBACK (ephy_link_open), action_group);
- g_snprintf (accel, sizeof (accel), "<Actions>/%s/%s",
- gtk_action_group_get_name (action_group),
- name);
- gtk_action_set_accel_path (action, accel);
- gtk_action_group_add_action (action_group, action);
- g_object_unref (action);
+ g_snprintf (accel, sizeof (accel), "<Actions>/%s/%s",
+ gtk_action_group_get_name (action_group),
+ name);
+ gtk_action_set_accel_path (action, accel);
+ gtk_action_group_add_action (action_group, action);
+ g_object_unref (action);
}
static void
-node_removed_cb (EphyNode *parent,
- EphyNode *child,
- guint index,
- GtkActionGroup *action_group)
+node_removed_cb (EphyNode *parent,
+ EphyNode *child,
+ guint index,
+ GtkActionGroup *action_group)
{
- GtkAction *action;
- char name[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE];
+ GtkAction *action;
+ char name[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE];
+
+ EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, child);
- EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, child);
+ action = gtk_action_group_get_action (action_group, name);
- action = gtk_action_group_get_action (action_group, name);
-
- if (action != NULL)
- {
- gtk_action_group_remove_action (action_group, action);
- }
+ if (action != NULL) {
+ gtk_action_group_remove_action (action_group, action);
+ }
}
GtkActionGroup *
ephy_bookmark_group_new (EphyNode *node)
{
- EphyBookmarks *bookmarks;
- EphyNode *smart;
- GPtrArray *children;
- GtkActionGroup *action_group;
- guint i;
-
- bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
- smart = ephy_bookmarks_get_smart_bookmarks (bookmarks);
-
- action_group = (GtkActionGroup *) ephy_link_action_group_new ("BA");
-
- children = ephy_node_get_children (node);
- for (i = 0; i < children->len; i++)
- {
- node_added_cb (node, g_ptr_array_index (children, i),
- action_group);
- }
-
- ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_ADDED,
- (EphyNodeCallback) node_added_cb,
- (GObject *) action_group);
- ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback) node_removed_cb,
- (GObject *) action_group);
- ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_CHANGED,
- (EphyNodeCallback) node_changed_cb,
- (GObject *) action_group);
-
- ephy_node_signal_connect_object (smart, EPHY_NODE_CHILD_ADDED,
- (EphyNodeCallback) smart_added_cb,
- (GObject *) action_group);
- ephy_node_signal_connect_object (smart, EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback) smart_removed_cb,
- (GObject *) action_group);
-
- return action_group;
+ EphyBookmarks *bookmarks;
+ EphyNode *smart;
+ GPtrArray *children;
+ GtkActionGroup *action_group;
+ guint i;
+
+ bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
+ smart = ephy_bookmarks_get_smart_bookmarks (bookmarks);
+
+ action_group = (GtkActionGroup *)ephy_link_action_group_new ("BA");
+
+ children = ephy_node_get_children (node);
+ for (i = 0; i < children->len; i++) {
+ node_added_cb (node, g_ptr_array_index (children, i),
+ action_group);
+ }
+
+ ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_ADDED,
+ (EphyNodeCallback)node_added_cb,
+ (GObject *)action_group);
+ ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_REMOVED,
+ (EphyNodeCallback)node_removed_cb,
+ (GObject *)action_group);
+ ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_CHANGED,
+ (EphyNodeCallback)node_changed_cb,
+ (GObject *)action_group);
+
+ ephy_node_signal_connect_object (smart, EPHY_NODE_CHILD_ADDED,
+ (EphyNodeCallback)smart_added_cb,
+ (GObject *)action_group);
+ ephy_node_signal_connect_object (smart, EPHY_NODE_CHILD_REMOVED,
+ (EphyNodeCallback)smart_removed_cb,
+ (GObject *)action_group);
+
+ return action_group;
}
diff --git a/src/bookmarks/ephy-bookmark-action.c b/src/bookmarks/ephy-bookmark-action.c
index 3f0a28c..f323ecd 100644
--- a/src/bookmarks/ephy-bookmark-action.c
+++ b/src/bookmarks/ephy-bookmark-action.c
@@ -39,419 +39,401 @@
#define EPHY_BOOKMARK_ACTION_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object),
EPHY_TYPE_BOOKMARK_ACTION, EphyBookmarkActionPrivate))
-struct _EphyBookmarkActionPrivate
-{
- EphyNode *node;
- gboolean smart_url;
- guint cache_handler;
+struct _EphyBookmarkActionPrivate {
+ EphyNode *node;
+ gboolean smart_url;
+ guint cache_handler;
};
-enum
-{
- PROP_0,
- PROP_BOOKMARK,
- PROP_TOOLTIP,
- PROP_LOCATION,
- PROP_SMART_URL,
- PROP_ICON,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_BOOKMARK,
+ PROP_TOOLTIP,
+ PROP_LOCATION,
+ PROP_SMART_URL,
+ PROP_ICON,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
-typedef struct
-{
- GObject *weak_ptr;
- GtkWidget *entry;
- EphyLinkFlags flags;
+typedef struct {
+ GObject *weak_ptr;
+ GtkWidget *entry;
+ EphyLinkFlags flags;
} ClipboardCtx;
G_DEFINE_TYPE (EphyBookmarkAction, ephy_bookmark_action, EPHY_TYPE_LINK_ACTION)
static void
favicon_changed_cb (WebKitFaviconDatabase *database,
- const char *page_address,
- const char *icon_address,
- EphyBookmarkAction *action)
+ const char *page_address,
+ const char *icon_address,
+ EphyBookmarkAction *action)
{
- const char *icon;
+ const char *icon;
- icon = ephy_node_get_property_string (action->priv->node,
- EPHY_NODE_BMK_PROP_ICON);
- if (g_strcmp0 (icon, icon_address) == 0)
- {
- g_signal_handler_disconnect (database, action->priv->cache_handler);
- action->priv->cache_handler = 0;
+ icon = ephy_node_get_property_string (action->priv->node,
+ EPHY_NODE_BMK_PROP_ICON);
+ if (g_strcmp0 (icon, icon_address) == 0) {
+ g_signal_handler_disconnect (database, action->priv->cache_handler);
+ action->priv->cache_handler = 0;
- g_object_notify_by_pspec (G_OBJECT (action), obj_properties[PROP_ICON]);
- }
+ g_object_notify_by_pspec (G_OBJECT (action), obj_properties[PROP_ICON]);
+ }
}
static void
async_get_favicon_pixbuf_callback (GObject *source, GAsyncResult *result, gpointer user_data)
{
- GtkWidget *proxy = GTK_WIDGET (user_data);
- WebKitFaviconDatabase *database = WEBKIT_FAVICON_DATABASE (source);
- GdkPixbuf *pixbuf = NULL;
-
- cairo_surface_t *icon_surface = webkit_favicon_database_get_favicon_finish (database, result, NULL);
- if (icon_surface)
- {
- pixbuf = ephy_pixbuf_get_from_surface_scaled (icon_surface, FAVICON_SIZE, FAVICON_SIZE);
- cairo_surface_destroy (icon_surface);
- }
-
- if (pixbuf)
- {
- if (GTK_IS_MENU_ITEM (proxy))
- {
- GtkWidget *image;
-
- image = gtk_image_new_from_pixbuf (pixbuf);
- gtk_widget_show (image);
-
- gtk_image_menu_item_set_image
- (GTK_IMAGE_MENU_ITEM (proxy), image);
- gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (proxy),
- TRUE);
- }
- g_object_unref (pixbuf);
- }
-
- g_object_unref (proxy);
+ GtkWidget *proxy = GTK_WIDGET (user_data);
+ WebKitFaviconDatabase *database = WEBKIT_FAVICON_DATABASE (source);
+ GdkPixbuf *pixbuf = NULL;
+
+ cairo_surface_t *icon_surface = webkit_favicon_database_get_favicon_finish (database, result, NULL);
+ if (icon_surface) {
+ pixbuf = ephy_pixbuf_get_from_surface_scaled (icon_surface, FAVICON_SIZE, FAVICON_SIZE);
+ cairo_surface_destroy (icon_surface);
+ }
+
+ if (pixbuf) {
+ if (GTK_IS_MENU_ITEM (proxy)) {
+ GtkWidget *image;
+
+ image = gtk_image_new_from_pixbuf (pixbuf);
+ gtk_widget_show (image);
+
+ gtk_image_menu_item_set_image
+ (GTK_IMAGE_MENU_ITEM (proxy), image);
+ gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (proxy),
+ TRUE);
+ }
+ g_object_unref (pixbuf);
+ }
+
+ g_object_unref (proxy);
}
static void
-ephy_bookmark_action_sync_icon (GtkAction *action,
- GParamSpec *pspec,
- GtkWidget *proxy)
+ephy_bookmark_action_sync_icon (GtkAction *action,
+ GParamSpec *pspec,
+ GtkWidget *proxy)
{
- EphyBookmarkAction *bma = EPHY_BOOKMARK_ACTION (action);
- const char *page_location;
- WebKitFaviconDatabase *database;
- EphyEmbedShell *shell = ephy_embed_shell_get_default ();
-
- g_return_if_fail (bma->priv->node != NULL);
-
- page_location = ephy_node_get_property_string (bma->priv->node,
- EPHY_NODE_BMK_PROP_LOCATION);
-
- database = webkit_web_context_get_favicon_database (ephy_embed_shell_get_web_context (shell));
-
- if (page_location && *page_location)
- {
- webkit_favicon_database_get_favicon (database, page_location,
- 0, async_get_favicon_pixbuf_callback,
- g_object_ref (proxy));
- if (bma->priv->cache_handler == 0)
- {
- bma->priv->cache_handler =
- g_signal_connect_object
- (database, "favicon-changed",
- G_CALLBACK (favicon_changed_cb),
- action, 0);
- }
- }
+ EphyBookmarkAction *bma = EPHY_BOOKMARK_ACTION (action);
+ const char *page_location;
+ WebKitFaviconDatabase *database;
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
+
+ g_return_if_fail (bma->priv->node != NULL);
+
+ page_location = ephy_node_get_property_string (bma->priv->node,
+ EPHY_NODE_BMK_PROP_LOCATION);
+
+ database = webkit_web_context_get_favicon_database (ephy_embed_shell_get_web_context (shell));
+
+ if (page_location && *page_location) {
+ webkit_favicon_database_get_favicon (database, page_location,
+ 0, async_get_favicon_pixbuf_callback,
+ g_object_ref (proxy));
+ if (bma->priv->cache_handler == 0) {
+ bma->priv->cache_handler =
+ g_signal_connect_object
+ (database, "favicon-changed",
+ G_CALLBACK (favicon_changed_cb),
+ action, 0);
+ }
+ }
}
void
ephy_bookmark_action_activate (EphyBookmarkAction *action,
- GtkWidget *widget,
- EphyLinkFlags flags)
+ GtkWidget *widget,
+ EphyLinkFlags flags)
{
- EphyBookmarkActionPrivate *priv = action->priv;
- EphyBookmarks *bookmarks;
- const char *location;
- char *address = NULL, *text = NULL;
-
- g_return_if_fail (priv->node != NULL);
-
- location = ephy_node_get_property_string
- (priv->node, EPHY_NODE_BMK_PROP_LOCATION);
- g_return_if_fail (location != NULL);
-
- bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
-
- if (GTK_IS_EDITABLE (widget))
- {
- text = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
- }
-
- /* The entered search term is empty, and we have a smart bookmark */
- if ((text == NULL || text[0] == '\0') && strstr (location, "%s") != NULL)
- {
- char *scheme;
- char *host_name;
-
- scheme = g_uri_parse_scheme (location);
- host_name = ephy_string_get_host_name (location);
- address = g_strconcat (scheme,
- "://",
- host_name,
- NULL);
- g_free (scheme);
- g_free (host_name);
- }
-
- if (address == NULL)
- {
- address = ephy_bookmarks_resolve_address (bookmarks, location, text);
- }
- g_return_if_fail (address != NULL);
-
- flags |= EPHY_LINK_BOOKMARK;
-
- ephy_link_open (EPHY_LINK (action), address, NULL, flags);
-
- g_free (address);
- g_free (text);
+ EphyBookmarkActionPrivate *priv = action->priv;
+ EphyBookmarks *bookmarks;
+ const char *location;
+ char *address = NULL, *text = NULL;
+
+ g_return_if_fail (priv->node != NULL);
+
+ location = ephy_node_get_property_string
+ (priv->node, EPHY_NODE_BMK_PROP_LOCATION);
+ g_return_if_fail (location != NULL);
+
+ bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
+
+ if (GTK_IS_EDITABLE (widget)) {
+ text = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
+ }
+
+ /* The entered search term is empty, and we have a smart bookmark */
+ if ((text == NULL || text[0] == '\0') && strstr (location, "%s") != NULL) {
+ char *scheme;
+ char *host_name;
+
+ scheme = g_uri_parse_scheme (location);
+ host_name = ephy_string_get_host_name (location);
+ address = g_strconcat (scheme,
+ "://",
+ host_name,
+ NULL);
+ g_free (scheme);
+ g_free (host_name);
+ }
+
+ if (address == NULL) {
+ address = ephy_bookmarks_resolve_address (bookmarks, location, text);
+ }
+ g_return_if_fail (address != NULL);
+
+ flags |= EPHY_LINK_BOOKMARK;
+
+ ephy_link_open (EPHY_LINK (action), address, NULL, flags);
+
+ g_free (address);
+ g_free (text);
}
static void
-activate_cb (GtkWidget *widget,
- EphyBookmarkAction *action)
+activate_cb (GtkWidget *widget,
+ EphyBookmarkAction *action)
{
- gboolean control = FALSE;
- GdkEvent *event;
-
- event = gtk_get_current_event ();
- if (event)
- {
- if (event->type == GDK_KEY_PRESS ||
- event->type == GDK_KEY_RELEASE)
- {
- control = (event->key.state & gtk_accelerator_get_default_mod_mask ()) ==
GDK_CONTROL_MASK;
- }
-
- gdk_event_free (event);
- }
-
- ephy_bookmark_action_activate
- (action, widget, (control || ephy_gui_is_middle_click ()) ? EPHY_LINK_NEW_TAB : 0);
+ gboolean control = FALSE;
+ GdkEvent *event;
+
+ event = gtk_get_current_event ();
+ if (event) {
+ if (event->type == GDK_KEY_PRESS ||
+ event->type == GDK_KEY_RELEASE) {
+ control = (event->key.state & gtk_accelerator_get_default_mod_mask ()) == GDK_CONTROL_MASK;
+ }
+
+ gdk_event_free (event);
+ }
+
+ ephy_bookmark_action_activate
+ (action, widget, (control || ephy_gui_is_middle_click ()) ? EPHY_LINK_NEW_TAB : 0);
}
static void
connect_proxy (GtkAction *action,
- GtkWidget *proxy)
+ GtkWidget *proxy)
{
- LOG ("Connecting action %p to proxy %p", action, proxy);
+ LOG ("Connecting action %p to proxy %p", action, proxy);
- GTK_ACTION_CLASS (ephy_bookmark_action_parent_class)->connect_proxy (action, proxy);
+ GTK_ACTION_CLASS (ephy_bookmark_action_parent_class)->connect_proxy (action, proxy);
- ephy_bookmark_action_sync_icon (action, NULL, proxy);
- g_signal_connect_object (action, "notify::icon",
- G_CALLBACK (ephy_bookmark_action_sync_icon), proxy, 0);
+ ephy_bookmark_action_sync_icon (action, NULL, proxy);
+ g_signal_connect_object (action, "notify::icon",
+ G_CALLBACK (ephy_bookmark_action_sync_icon), proxy, 0);
- if (GTK_IS_MENU_ITEM (proxy))
- {
- GtkLabel *label;
+ if (GTK_IS_MENU_ITEM (proxy)) {
+ GtkLabel *label;
- label = GTK_LABEL (gtk_bin_get_child (GTK_BIN (proxy)));
+ label = GTK_LABEL (gtk_bin_get_child (GTK_BIN (proxy)));
- gtk_label_set_use_underline (label, FALSE);
- gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END);
- gtk_label_set_max_width_chars (label, LABEL_WIDTH_CHARS);
+ gtk_label_set_use_underline (label, FALSE);
+ gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END);
+ gtk_label_set_max_width_chars (label, LABEL_WIDTH_CHARS);
- g_signal_connect (proxy, "activate", G_CALLBACK (activate_cb), action);
- }
+ g_signal_connect (proxy, "activate", G_CALLBACK (activate_cb), action);
+ }
}
void
ephy_bookmark_action_updated (EphyBookmarkAction *action)
{
- GValue value = { 0, };
- EphyBookmarks *bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
- EphyNode *smart = ephy_bookmarks_get_smart_bookmarks (bookmarks);
- EphyNode *node = action->priv->node;
- const char *title;
-
- g_return_if_fail (action != NULL);
- g_return_if_fail (node != NULL);
-
- g_object_freeze_notify (G_OBJECT (action));
-
- /* Set smart_url */
- action->priv->smart_url = ephy_node_has_child (smart, node);
- g_object_notify_by_pspec (G_OBJECT (action), obj_properties[PROP_SMART_URL]);
-
- /* Set title */
- title = ephy_node_get_property_string (node, EPHY_NODE_BMK_PROP_TITLE);
- g_value_init (&value, G_TYPE_STRING);
- g_value_set_static_string (&value, title);
- g_object_set_property (G_OBJECT (action), "label", &value);
- g_value_unset (&value);
-
- /* Notify all other properties */
- g_object_notify_by_pspec (G_OBJECT (action), obj_properties[PROP_LOCATION]);
- g_object_notify_by_pspec (G_OBJECT (action), obj_properties[PROP_ICON]);
-
- g_object_thaw_notify (G_OBJECT (action));
-
- /* We could force a tooltip re-query with gtk_tooltip_trigger_tooltip_query
- * here, but it's not really worth it. Just show the updated tip next time
- * the tip is queried.
- */
+ GValue value = { 0, };
+ EphyBookmarks *bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
+ EphyNode *smart = ephy_bookmarks_get_smart_bookmarks (bookmarks);
+ EphyNode *node = action->priv->node;
+ const char *title;
+
+ g_return_if_fail (action != NULL);
+ g_return_if_fail (node != NULL);
+
+ g_object_freeze_notify (G_OBJECT (action));
+
+ /* Set smart_url */
+ action->priv->smart_url = ephy_node_has_child (smart, node);
+ g_object_notify_by_pspec (G_OBJECT (action), obj_properties[PROP_SMART_URL]);
+
+ /* Set title */
+ title = ephy_node_get_property_string (node, EPHY_NODE_BMK_PROP_TITLE);
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_set_static_string (&value, title);
+ g_object_set_property (G_OBJECT (action), "label", &value);
+ g_value_unset (&value);
+
+ /* Notify all other properties */
+ g_object_notify_by_pspec (G_OBJECT (action), obj_properties[PROP_LOCATION]);
+ g_object_notify_by_pspec (G_OBJECT (action), obj_properties[PROP_ICON]);
+
+ g_object_thaw_notify (G_OBJECT (action));
+
+ /* We could force a tooltip re-query with gtk_tooltip_trigger_tooltip_query
+ * here, but it's not really worth it. Just show the updated tip next time
+ * the tip is queried.
+ */
}
EphyNode *
ephy_bookmark_action_get_bookmark (EphyBookmarkAction *action)
{
- return action->priv->node;
+ return action->priv->node;
}
void
ephy_bookmark_action_set_bookmark (EphyBookmarkAction *action,
- EphyNode *node)
+ EphyNode *node)
{
- EphyBookmarkActionPrivate *priv = action->priv;
- GObject *object = G_OBJECT (action);
+ EphyBookmarkActionPrivate *priv = action->priv;
+ GObject *object = G_OBJECT (action);
- g_return_if_fail (node != NULL);
+ g_return_if_fail (node != NULL);
- priv->node = node;
+ priv->node = node;
- g_object_freeze_notify (object);
+ g_object_freeze_notify (object);
- g_object_notify_by_pspec (G_OBJECT (action), obj_properties[PROP_BOOKMARK]);
- ephy_bookmark_action_updated (action);
+ g_object_notify_by_pspec (G_OBJECT (action), obj_properties[PROP_BOOKMARK]);
+ ephy_bookmark_action_updated (action);
- g_object_thaw_notify (object);
+ g_object_thaw_notify (object);
}
static void
-ephy_bookmark_action_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ephy_bookmark_action_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- EphyBookmarkAction *action = EPHY_BOOKMARK_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_BOOKMARK:
- ephy_bookmark_action_set_bookmark (action, g_value_get_pointer (value));
- break;
- case PROP_TOOLTIP:
- case PROP_LOCATION:
- case PROP_SMART_URL:
- case PROP_ICON:
- /* not writable */
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
+ EphyBookmarkAction *action = EPHY_BOOKMARK_ACTION (object);
+
+ switch (prop_id) {
+ case PROP_BOOKMARK:
+ ephy_bookmark_action_set_bookmark (action, g_value_get_pointer (value));
+ break;
+ case PROP_TOOLTIP:
+ case PROP_LOCATION:
+ case PROP_SMART_URL:
+ case PROP_ICON:
+ /* not writable */
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
-ephy_bookmark_action_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ephy_bookmark_action_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- EphyBookmarkAction *action = EPHY_BOOKMARK_ACTION (object);
- EphyBookmarkActionPrivate *priv = action->priv;
-
- g_return_if_fail (priv->node != NULL);
-
- switch (prop_id)
- {
- case PROP_BOOKMARK:
- g_value_set_pointer (value, priv->node);
- break;
- case PROP_TOOLTIP:
- case PROP_LOCATION:
- g_value_set_string (value,
- ephy_node_get_property_string (priv->node,
- EPHY_NODE_BMK_PROP_LOCATION));
- break;
- case PROP_SMART_URL:
- g_value_set_boolean (value, priv->smart_url);
- break;
- case PROP_ICON:
- g_value_set_string (value,
- ephy_node_get_property_string (priv->node,
- EPHY_NODE_BMK_PROP_ICON));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
+ EphyBookmarkAction *action = EPHY_BOOKMARK_ACTION (object);
+ EphyBookmarkActionPrivate *priv = action->priv;
+
+ g_return_if_fail (priv->node != NULL);
+
+ switch (prop_id) {
+ case PROP_BOOKMARK:
+ g_value_set_pointer (value, priv->node);
+ break;
+ case PROP_TOOLTIP:
+ case PROP_LOCATION:
+ g_value_set_string (value,
+ ephy_node_get_property_string (priv->node,
+ EPHY_NODE_BMK_PROP_LOCATION));
+ break;
+ case PROP_SMART_URL:
+ g_value_set_boolean (value, priv->smart_url);
+ break;
+ case PROP_ICON:
+ g_value_set_string (value,
+ ephy_node_get_property_string (priv->node,
+ EPHY_NODE_BMK_PROP_ICON));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
ephy_bookmark_action_init (EphyBookmarkAction *action)
{
- action->priv = EPHY_BOOKMARK_ACTION_GET_PRIVATE (action);
+ action->priv = EPHY_BOOKMARK_ACTION_GET_PRIVATE (action);
- action->priv->cache_handler = 0;
+ action->priv->cache_handler = 0;
}
static void
ephy_bookmark_action_dispose (GObject *object)
{
- EphyBookmarkAction *action = (EphyBookmarkAction *) object;
- EphyBookmarkActionPrivate *priv = action->priv;
+ EphyBookmarkAction *action = (EphyBookmarkAction *)object;
+ EphyBookmarkActionPrivate *priv = action->priv;
- if (priv->cache_handler != 0)
- {
- EphyEmbedShell *shell = ephy_embed_shell_get_default ();
- WebKitFaviconDatabase *database;
+ if (priv->cache_handler != 0) {
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
+ WebKitFaviconDatabase *database;
- database = webkit_web_context_get_favicon_database (ephy_embed_shell_get_web_context
(shell));
- g_signal_handler_disconnect (database, priv->cache_handler);
- priv->cache_handler = 0;
- }
+ database = webkit_web_context_get_favicon_database (ephy_embed_shell_get_web_context (shell));
+ g_signal_handler_disconnect (database, priv->cache_handler);
+ priv->cache_handler = 0;
+ }
- G_OBJECT_CLASS (ephy_bookmark_action_parent_class)->dispose (object);
+ G_OBJECT_CLASS (ephy_bookmark_action_parent_class)->dispose (object);
}
static void
ephy_bookmark_action_class_init (EphyBookmarkActionClass *class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
- GtkActionClass *action_class = GTK_ACTION_CLASS (class);
-
- action_class->menu_item_type = GTK_TYPE_IMAGE_MENU_ITEM;
- action_class->connect_proxy = connect_proxy;
-
- object_class->dispose = ephy_bookmark_action_dispose;
- object_class->set_property = ephy_bookmark_action_set_property;
- object_class->get_property = ephy_bookmark_action_get_property;
-
- obj_properties[PROP_BOOKMARK] =
- g_param_spec_pointer ("bookmark", NULL, NULL,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
-
- /* overwrite GtkActionClass::tooltip, so we can use the url as tooltip */
- obj_properties[PROP_TOOLTIP] =
- g_param_spec_string ("tooltip", NULL, NULL,
- NULL,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- obj_properties[PROP_LOCATION] =
- g_param_spec_string ("location", NULL, NULL,
- NULL,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- obj_properties[PROP_SMART_URL] =
- g_param_spec_boolean ("smarturl", NULL, NULL,
- FALSE,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- obj_properties[PROP_ICON] =
- g_param_spec_string ("icon", NULL, NULL,
- NULL,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
-
- g_type_class_add_private (object_class, sizeof(EphyBookmarkActionPrivate));
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GtkActionClass *action_class = GTK_ACTION_CLASS (class);
+
+ action_class->menu_item_type = GTK_TYPE_IMAGE_MENU_ITEM;
+ action_class->connect_proxy = connect_proxy;
+
+ object_class->dispose = ephy_bookmark_action_dispose;
+ object_class->set_property = ephy_bookmark_action_set_property;
+ object_class->get_property = ephy_bookmark_action_get_property;
+
+ obj_properties[PROP_BOOKMARK] =
+ g_param_spec_pointer ("bookmark", NULL, NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+
+ /* overwrite GtkActionClass::tooltip, so we can use the url as tooltip */
+ obj_properties[PROP_TOOLTIP] =
+ g_param_spec_string ("tooltip", NULL, NULL,
+ NULL,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ obj_properties[PROP_LOCATION] =
+ g_param_spec_string ("location", NULL, NULL,
+ NULL,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ obj_properties[PROP_SMART_URL] =
+ g_param_spec_boolean ("smarturl", NULL, NULL,
+ FALSE,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ obj_properties[PROP_ICON] =
+ g_param_spec_string ("icon", NULL, NULL,
+ NULL,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+
+ g_type_class_add_private (object_class, sizeof (EphyBookmarkActionPrivate));
}
GtkAction *
-ephy_bookmark_action_new (EphyNode *node,
- const char *name)
+ephy_bookmark_action_new (EphyNode *node,
+ const char *name)
{
- g_assert (name != NULL);
+ g_assert (name != NULL);
- return GTK_ACTION (g_object_new (EPHY_TYPE_BOOKMARK_ACTION,
- "name", name,
- "bookmark", node,
- NULL));
+ return GTK_ACTION (g_object_new (EPHY_TYPE_BOOKMARK_ACTION,
+ "name", name,
+ "bookmark", node,
+ NULL));
}
diff --git a/src/bookmarks/ephy-bookmark-properties.c b/src/bookmarks/ephy-bookmark-properties.c
index 4549539..43aa168 100644
--- a/src/bookmarks/ephy-bookmark-properties.c
+++ b/src/bookmarks/ephy-bookmark-properties.c
@@ -39,40 +39,38 @@
#include <string.h>
-struct _EphyBookmarkProperties
-{
- GtkDialog parent_instance;
-
- /* construct properties */
- EphyBookmarks *bookmarks;
- EphyNode *bookmark;
- gboolean creating;
-
- /* counters */
- gint duplicate_count;
- gint duplicate_idle;
-
- /* from UI file */
- GtkGrid *grid;
- GtkEntry *title_entry;
- GtkEntry *adress_entry;
- GtkLabel *topics_label;
- GtkExpander *topics_expander;
- GtkTreeView *topics_tree_view;
- GtkScrolledWindow *topics_scrolled_window;
- GtkLabel *warning_label;
-
- /* model */
- EphyTopicsPalette *topics_model;
+struct _EphyBookmarkProperties {
+ GtkDialog parent_instance;
+
+ /* construct properties */
+ EphyBookmarks *bookmarks;
+ EphyNode *bookmark;
+ gboolean creating;
+
+ /* counters */
+ gint duplicate_count;
+ gint duplicate_idle;
+
+ /* from UI file */
+ GtkGrid *grid;
+ GtkEntry *title_entry;
+ GtkEntry *adress_entry;
+ GtkLabel *topics_label;
+ GtkExpander *topics_expander;
+ GtkTreeView *topics_tree_view;
+ GtkScrolledWindow *topics_scrolled_window;
+ GtkLabel *warning_label;
+
+ /* model */
+ EphyTopicsPalette *topics_model;
};
-enum
-{
- PROP_0,
- PROP_BOOKMARKS,
- PROP_BOOKMARK,
- PROP_CREATING,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_BOOKMARKS,
+ PROP_BOOKMARK,
+ PROP_CREATING,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
@@ -82,110 +80,105 @@ G_DEFINE_TYPE (EphyBookmarkProperties, ephy_bookmark_properties, GTK_TYPE_DIALOG
static gboolean
update_warning (EphyBookmarkProperties *properties)
{
- char *label;
+ char *label;
- properties->duplicate_idle = 0;
- properties->duplicate_count = ephy_bookmarks_get_similar
- (properties->bookmarks, properties->bookmark, NULL, NULL);
+ properties->duplicate_idle = 0;
+ properties->duplicate_count = ephy_bookmarks_get_similar
+ (properties->bookmarks, properties->bookmark, NULL, NULL);
- /* Translators: This string is used when counting bookmarks that
- * are similar to each other */
- label = g_strdup_printf (ngettext("%d bookmark is similar", "%d bookmarks are similar",
properties->duplicate_count), properties->duplicate_count);
- gtk_label_set_text (properties->warning_label, label);
- g_free (label);
+ /* Translators: This string is used when counting bookmarks that
+ * are similar to each other */
+ label = g_strdup_printf (ngettext ("%d bookmark is similar", "%d bookmarks are similar",
properties->duplicate_count), properties->duplicate_count);
+ gtk_label_set_text (properties->warning_label, label);
+ g_free (label);
- return FALSE;
+ return FALSE;
}
static void
update_warning_idle (EphyBookmarkProperties *properties)
{
- if (properties->duplicate_idle != 0)
- {
- g_source_remove (properties->duplicate_idle);
- }
-
- properties->duplicate_idle = g_timeout_add
- (500, (GSourceFunc)update_warning, properties);
- g_source_set_name_by_id (properties->duplicate_idle, "[epiphany] update_warning");
+ if (properties->duplicate_idle != 0) {
+ g_source_remove (properties->duplicate_idle);
+ }
+
+ properties->duplicate_idle = g_timeout_add
+ (500, (GSourceFunc)update_warning, properties);
+ g_source_set_name_by_id (properties->duplicate_idle, "[epiphany] update_warning");
}
static void
-node_added_cb (EphyNode *bookmarks,
- EphyNode *bookmark,
- EphyBookmarkProperties *properties)
+node_added_cb (EphyNode *bookmarks,
+ EphyNode *bookmark,
+ EphyBookmarkProperties *properties)
{
- update_warning_idle (properties);
+ update_warning_idle (properties);
}
static void
-node_changed_cb (EphyNode *bookmarks,
- EphyNode *bookmark,
- guint property,
- EphyBookmarkProperties *properties)
+node_changed_cb (EphyNode *bookmarks,
+ EphyNode *bookmark,
+ guint property,
+ EphyBookmarkProperties *properties)
{
- if (property == EPHY_NODE_BMK_PROP_LOCATION)
- {
- update_warning_idle (properties);
- }
+ if (property == EPHY_NODE_BMK_PROP_LOCATION) {
+ update_warning_idle (properties);
+ }
}
static void
-node_removed_cb (EphyNode *bookmarks,
- EphyNode *bookmark,
- guint index,
- EphyBookmarkProperties *properties)
+node_removed_cb (EphyNode *bookmarks,
+ EphyNode *bookmark,
+ guint index,
+ EphyBookmarkProperties *properties)
{
- update_warning_idle (properties);
+ update_warning_idle (properties);
}
static void
-node_destroy_cb (EphyNode *bookmark,
- GtkWidget *dialog)
+node_destroy_cb (EphyNode *bookmark,
+ GtkWidget *dialog)
{
- EPHY_BOOKMARK_PROPERTIES (dialog)->creating = FALSE;
- gtk_widget_destroy (dialog);
+ EPHY_BOOKMARK_PROPERTIES (dialog)->creating = FALSE;
+ gtk_widget_destroy (dialog);
}
static void
ephy_bookmark_properties_set_bookmark (EphyBookmarkProperties *properties,
- EphyNode *bookmark)
+ EphyNode *bookmark)
{
- LOG ("Set bookmark");
-
- if (properties->bookmark)
- {
- ephy_node_signal_disconnect_object (properties->bookmark,
- EPHY_NODE_DESTROY,
- (EphyNodeCallback) node_destroy_cb,
- G_OBJECT (properties));
- }
-
- properties->bookmark = bookmark;
-
- ephy_node_signal_connect_object (properties->bookmark,
- EPHY_NODE_DESTROY,
- (EphyNodeCallback) node_destroy_cb,
- G_OBJECT (properties));
+ LOG ("Set bookmark");
+
+ if (properties->bookmark) {
+ ephy_node_signal_disconnect_object (properties->bookmark,
+ EPHY_NODE_DESTROY,
+ (EphyNodeCallback)node_destroy_cb,
+ G_OBJECT (properties));
+ }
+
+ properties->bookmark = bookmark;
+
+ ephy_node_signal_connect_object (properties->bookmark,
+ EPHY_NODE_DESTROY,
+ (EphyNodeCallback)node_destroy_cb,
+ G_OBJECT (properties));
}
static void
ephy_bookmark_properties_destroy_cb (GtkDialog *dialog,
gpointer data)
{
- EphyBookmarkProperties *properties = EPHY_BOOKMARK_PROPERTIES (dialog);
-
- if (properties->creating)
- {
- ephy_node_unref (properties->bookmark);
- properties->creating = FALSE;
- }
-
- if (properties->duplicate_idle != 0)
- {
- g_source_remove (properties->duplicate_idle);
- properties->duplicate_idle = 0;
- }
+ EphyBookmarkProperties *properties = EPHY_BOOKMARK_PROPERTIES (dialog);
+
+ if (properties->creating) {
+ ephy_node_unref (properties->bookmark);
+ properties->creating = FALSE;
+ }
+
+ if (properties->duplicate_idle != 0) {
+ g_source_remove (properties->duplicate_idle);
+ properties->duplicate_idle = 0;
+ }
}
static void
@@ -193,61 +186,60 @@ ephy_bookmark_properties_response_cb (GtkDialog *dialog,
int response_id,
gpointer data)
{
- EphyBookmarkProperties *properties = EPHY_BOOKMARK_PROPERTIES (dialog);
-
- switch (response_id)
- {
- case GTK_RESPONSE_ACCEPT:
- properties->creating = FALSE;
- break;
- default:
- break;
- }
-
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ EphyBookmarkProperties *properties = EPHY_BOOKMARK_PROPERTIES (dialog);
+
+ switch (response_id) {
+ case GTK_RESPONSE_ACCEPT:
+ properties->creating = FALSE;
+ break;
+ default:
+ break;
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
}
static void
update_entry (EphyBookmarkProperties *properties,
- GtkWidget *entry,
- guint prop)
+ GtkWidget *entry,
+ guint prop)
{
- GValue value = { 0, };
- char *text;
-
- text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
- g_value_init (&value, G_TYPE_STRING);
- g_value_take_string (&value, text);
- ephy_node_set_property (properties->bookmark,
- prop,
- &value);
- g_value_unset (&value);
+ GValue value = { 0, };
+ char *text;
+
+ text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_take_string (&value, text);
+ ephy_node_set_property (properties->bookmark,
+ prop,
+ &value);
+ g_value_unset (&value);
}
static void
update_window_title (EphyBookmarkProperties *properties)
{
- char *title;
- const char *tmp;
+ char *title;
+ const char *tmp;
- tmp = ephy_node_get_property_string (properties->bookmark,
- EPHY_NODE_BMK_PROP_TITLE);
+ tmp = ephy_node_get_property_string (properties->bookmark,
+ EPHY_NODE_BMK_PROP_TITLE);
- if (properties->creating)
- title = g_strdup (_("Add Bookmark"));
- else
- title = g_strdup_printf (_("“%s” Properties"), tmp);
+ if (properties->creating)
+ title = g_strdup (_("Add Bookmark"));
+ else
+ title = g_strdup_printf (_("“%s” Properties"), tmp);
- gtk_window_set_title (GTK_WINDOW (properties), title);
- g_free (title);
+ gtk_window_set_title (GTK_WINDOW (properties), title);
+ g_free (title);
}
static void
title_entry_changed_cb (GtkWidget *entry,
EphyBookmarkProperties *properties)
{
- update_entry (properties, entry, EPHY_NODE_BMK_PROP_TITLE);
- update_window_title (properties);
+ update_entry (properties, entry, EPHY_NODE_BMK_PROP_TITLE);
+ update_window_title (properties);
}
static void
@@ -256,16 +248,13 @@ on_topic_edited (GtkCellRendererText *renderer,
const char *new_text,
EphyBookmarkProperties *properties)
{
- if (*new_text != 0)
- {
- EphyNode *node;
- node = ephy_bookmarks_add_keyword (properties->bookmarks, new_text);
- ephy_bookmarks_set_keyword (properties->bookmarks, node, properties->bookmark);
- }
- else
- {
- ephy_topics_palette_update_list (properties->topics_model);
- }
+ if (*new_text != 0) {
+ EphyNode *node;
+ node = ephy_bookmarks_add_keyword (properties->bookmarks, new_text);
+ ephy_bookmarks_set_keyword (properties->bookmarks, node, properties->bookmark);
+ } else {
+ ephy_topics_palette_update_list (properties->topics_model);
+ }
}
static void
@@ -273,32 +262,29 @@ on_topic_toggled (GtkCellRendererToggle *cell_renderer,
gchar *path,
EphyBookmarkProperties *properties)
{
- EphyNode *topic;
- GtkTreeModel *model;
- GtkTreeIter iter;
-
- model = gtk_tree_view_get_model (properties->topics_tree_view);
-
- g_return_if_fail (gtk_tree_model_get_iter_from_string (model, &iter, path));
-
- gtk_tree_model_get (model, &iter, EPHY_TOPICS_PALETTE_COLUMN_NODE, &topic, -1);
-
- /* Protect against toggling separators. */
- if (topic == NULL)
- return;
-
- if (ephy_node_has_child (topic, properties->bookmark))
- {
- ephy_bookmarks_unset_keyword (properties->bookmarks,
- topic,
- properties->bookmark);
- }
- else
- {
- ephy_bookmarks_set_keyword (properties->bookmarks,
- topic,
- properties->bookmark);
- }
+ EphyNode *topic;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ model = gtk_tree_view_get_model (properties->topics_tree_view);
+
+ g_return_if_fail (gtk_tree_model_get_iter_from_string (model, &iter, path));
+
+ gtk_tree_model_get (model, &iter, EPHY_TOPICS_PALETTE_COLUMN_NODE, &topic, -1);
+
+ /* Protect against toggling separators. */
+ if (topic == NULL)
+ return;
+
+ if (ephy_node_has_child (topic, properties->bookmark)) {
+ ephy_bookmarks_unset_keyword (properties->bookmarks,
+ topic,
+ properties->bookmark);
+ } else {
+ ephy_bookmarks_set_keyword (properties->bookmarks,
+ topic,
+ properties->bookmark);
+ }
}
static gboolean
@@ -306,18 +292,18 @@ is_separator (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer data)
{
- EphyNode *node;
- gtk_tree_model_get (model, iter, EPHY_TOPICS_PALETTE_COLUMN_NODE, &node, -1);
- return (node == NULL);
+ EphyNode *node;
+ gtk_tree_model_get (model, iter, EPHY_TOPICS_PALETTE_COLUMN_NODE, &node, -1);
+ return (node == NULL);
}
static void
-location_entry_changed_cb (GtkWidget *entry,
- EphyBookmarkProperties *properties)
+location_entry_changed_cb (GtkWidget *entry,
+ EphyBookmarkProperties *properties)
{
- ephy_bookmarks_set_address (properties->bookmarks,
- properties->bookmark,
- gtk_entry_get_text (GTK_ENTRY (entry)));
+ ephy_bookmarks_set_address (properties->bookmarks,
+ properties->bookmark,
+ gtk_entry_get_text (GTK_ENTRY (entry)));
}
static void
@@ -330,205 +316,201 @@ ephy_bookmark_properties_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_params)
{
- GObject *object;
- EphyBookmarkProperties *properties;
-
- gboolean lockdown;
- const char *tmp;
- char *decoded_url;
- GtkWidget *entry;
-
- object = G_OBJECT_CLASS (ephy_bookmark_properties_parent_class)->constructor (type,
- n_construct_properties,
- construct_params);
- properties = EPHY_BOOKMARK_PROPERTIES (object);
-
- gtk_widget_init_template (GTK_WIDGET (properties));
-
- if (!properties->creating)
- {
- ephy_initial_state_add_window (GTK_WIDGET (properties),
- "bookmark_properties",
- 290, 280, FALSE,
- EPHY_INITIAL_STATE_WINDOW_SAVE_POSITION |
- EPHY_INITIAL_STATE_WINDOW_SAVE_SIZE);
- }
- /* Lockdown */
- lockdown = g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
- EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING);
-
- update_window_title (properties);
-
- gtk_editable_set_editable (GTK_EDITABLE (properties->title_entry), !lockdown);
- tmp = ephy_node_get_property_string (properties->bookmark, EPHY_NODE_BMK_PROP_TITLE);
- gtk_entry_set_text (properties->title_entry, tmp);
-
- gtk_editable_set_editable (GTK_EDITABLE (properties->adress_entry), !lockdown);
- tmp = ephy_node_get_property_string (properties->bookmark, EPHY_NODE_BMK_PROP_LOCATION);
- decoded_url = ephy_uri_decode (tmp);
- gtk_entry_set_text (properties->adress_entry, decoded_url);
- g_free (decoded_url);
-
- entry = ephy_topics_entry_new (properties->bookmarks, properties->bookmark);
- gtk_editable_set_editable (GTK_EDITABLE (entry), !lockdown);
- gtk_label_set_mnemonic_widget (properties->topics_label, entry);
- gtk_widget_show (entry);
- gtk_grid_attach (properties->grid, entry, 1, 2, 1, 1);
- gtk_widget_set_hexpand (entry, TRUE);
-
- gtk_tree_view_set_row_separator_func (properties->topics_tree_view, is_separator, NULL, NULL);
-
- properties->topics_model = ephy_topics_palette_new (properties->bookmarks, properties->bookmark);
- gtk_tree_view_set_model (properties->topics_tree_view, GTK_TREE_MODEL (properties->topics_model));
-
- /* TODO bind; and the entry?! */
- gtk_widget_set_sensitive (GTK_WIDGET (properties->topics_scrolled_window), !lockdown);
-
- ephy_initial_state_add_expander (GTK_WIDGET (properties->topics_expander),
"bookmark_properties_list", FALSE);
-
- if (properties->creating)
- {
- gtk_dialog_add_button (GTK_DIALOG (properties), _("_Cancel"), GTK_RESPONSE_CANCEL);
- gtk_dialog_add_button (GTK_DIALOG (properties), _("_Add"), GTK_RESPONSE_ACCEPT);
- gtk_dialog_set_default_response (GTK_DIALOG (properties), GTK_RESPONSE_ACCEPT);
- }
-
- update_warning (properties);
-
- return object;
+ GObject *object;
+ EphyBookmarkProperties *properties;
+
+ gboolean lockdown;
+ const char *tmp;
+ char *decoded_url;
+ GtkWidget *entry;
+
+ object = G_OBJECT_CLASS (ephy_bookmark_properties_parent_class)->constructor (type,
+ n_construct_properties,
+ construct_params);
+ properties = EPHY_BOOKMARK_PROPERTIES (object);
+
+ gtk_widget_init_template (GTK_WIDGET (properties));
+
+ if (!properties->creating) {
+ ephy_initial_state_add_window (GTK_WIDGET (properties),
+ "bookmark_properties",
+ 290, 280, FALSE,
+ EPHY_INITIAL_STATE_WINDOW_SAVE_POSITION |
+ EPHY_INITIAL_STATE_WINDOW_SAVE_SIZE);
+ }
+ /* Lockdown */
+ lockdown = g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING);
+
+ update_window_title (properties);
+
+ gtk_editable_set_editable (GTK_EDITABLE (properties->title_entry), !lockdown);
+ tmp = ephy_node_get_property_string (properties->bookmark, EPHY_NODE_BMK_PROP_TITLE);
+ gtk_entry_set_text (properties->title_entry, tmp);
+
+ gtk_editable_set_editable (GTK_EDITABLE (properties->adress_entry), !lockdown);
+ tmp = ephy_node_get_property_string (properties->bookmark, EPHY_NODE_BMK_PROP_LOCATION);
+ decoded_url = ephy_uri_decode (tmp);
+ gtk_entry_set_text (properties->adress_entry, decoded_url);
+ g_free (decoded_url);
+
+ entry = ephy_topics_entry_new (properties->bookmarks, properties->bookmark);
+ gtk_editable_set_editable (GTK_EDITABLE (entry), !lockdown);
+ gtk_label_set_mnemonic_widget (properties->topics_label, entry);
+ gtk_widget_show (entry);
+ gtk_grid_attach (properties->grid, entry, 1, 2, 1, 1);
+ gtk_widget_set_hexpand (entry, TRUE);
+
+ gtk_tree_view_set_row_separator_func (properties->topics_tree_view, is_separator, NULL, NULL);
+
+ properties->topics_model = ephy_topics_palette_new (properties->bookmarks, properties->bookmark);
+ gtk_tree_view_set_model (properties->topics_tree_view, GTK_TREE_MODEL (properties->topics_model));
+
+ /* TODO bind; and the entry?! */
+ gtk_widget_set_sensitive (GTK_WIDGET (properties->topics_scrolled_window), !lockdown);
+
+ ephy_initial_state_add_expander (GTK_WIDGET (properties->topics_expander), "bookmark_properties_list",
FALSE);
+
+ if (properties->creating) {
+ gtk_dialog_add_button (GTK_DIALOG (properties), _("_Cancel"), GTK_RESPONSE_CANCEL);
+ gtk_dialog_add_button (GTK_DIALOG (properties), _("_Add"), GTK_RESPONSE_ACCEPT);
+ gtk_dialog_set_default_response (GTK_DIALOG (properties), GTK_RESPONSE_ACCEPT);
+ }
+
+ update_warning (properties);
+
+ return object;
}
static void
-ephy_bookmark_properties_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ephy_bookmark_properties_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- EphyBookmarkProperties *properties = EPHY_BOOKMARK_PROPERTIES (object);
- EphyNode *bookmarks;
-
- switch (prop_id)
- {
- case PROP_BOOKMARKS:
- properties->bookmarks = g_value_get_object (value);
- bookmarks = ephy_bookmarks_get_bookmarks (properties->bookmarks);
- ephy_node_signal_connect_object (bookmarks,
- EPHY_NODE_CHILD_ADDED,
- (EphyNodeCallback) node_added_cb,
- object);
- ephy_node_signal_connect_object (bookmarks,
- EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback) node_removed_cb,
- object);
- ephy_node_signal_connect_object (bookmarks,
- EPHY_NODE_CHILD_CHANGED,
- (EphyNodeCallback) node_changed_cb,
- object);
- break;
- case PROP_BOOKMARK:
- ephy_bookmark_properties_set_bookmark
- (properties, g_value_get_pointer (value));
- break;
- case PROP_CREATING:
- properties->creating = g_value_get_boolean (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ EphyBookmarkProperties *properties = EPHY_BOOKMARK_PROPERTIES (object);
+ EphyNode *bookmarks;
+
+ switch (prop_id) {
+ case PROP_BOOKMARKS:
+ properties->bookmarks = g_value_get_object (value);
+ bookmarks = ephy_bookmarks_get_bookmarks (properties->bookmarks);
+ ephy_node_signal_connect_object (bookmarks,
+ EPHY_NODE_CHILD_ADDED,
+ (EphyNodeCallback)node_added_cb,
+ object);
+ ephy_node_signal_connect_object (bookmarks,
+ EPHY_NODE_CHILD_REMOVED,
+ (EphyNodeCallback)node_removed_cb,
+ object);
+ ephy_node_signal_connect_object (bookmarks,
+ EPHY_NODE_CHILD_CHANGED,
+ (EphyNodeCallback)node_changed_cb,
+ object);
+ break;
+ case PROP_BOOKMARK:
+ ephy_bookmark_properties_set_bookmark
+ (properties, g_value_get_pointer (value));
+ break;
+ case PROP_CREATING:
+ properties->creating = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-ephy_bookmark_properties_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ephy_bookmark_properties_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- EphyBookmarkProperties *properties = EPHY_BOOKMARK_PROPERTIES (object);
-
- switch (prop_id)
- {
- case PROP_BOOKMARK:
- g_value_set_object (value, properties);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ EphyBookmarkProperties *properties = EPHY_BOOKMARK_PROPERTIES (object);
+
+ switch (prop_id) {
+ case PROP_BOOKMARK:
+ g_value_set_object (value, properties);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
ephy_bookmark_properties_class_init (EphyBookmarkPropertiesClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
- object_class->constructor = ephy_bookmark_properties_constructor;
- object_class->set_property = ephy_bookmark_properties_set_property;
- object_class->get_property = ephy_bookmark_properties_get_property;
-
- obj_properties[PROP_BOOKMARKS] =
- g_param_spec_object ("bookmarks",
- "bookmarks",
- "bookmarks",
- EPHY_TYPE_BOOKMARKS,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
-
- obj_properties[PROP_BOOKMARK] =
- g_param_spec_pointer ("bookmark",
- "bookmark",
- "bookmark",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT);
-
- obj_properties[PROP_CREATING] =
- g_param_spec_boolean ("creating",
- "creating",
- "creating",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
-
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
-
- /* from UI file */
- gtk_widget_class_set_template_from_resource (widget_class,
- "/org/gnome/epiphany/bookmark-properties.ui");
-
- gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, grid);
- gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, title_entry);
- gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, adress_entry);
- gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, topics_label);
- gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, topics_expander);
- gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, topics_tree_view);
- gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, topics_scrolled_window);
- gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, warning_label);
-
- gtk_widget_class_bind_template_callback (widget_class, title_entry_changed_cb);
- gtk_widget_class_bind_template_callback (widget_class, on_topic_toggled); // TODO make the row
activatable instead of a little togglebutton
- gtk_widget_class_bind_template_callback (widget_class, on_topic_edited); // TODO topics’ names are
not editable from there, they are synced with bookmarks... but this is used for... updating the entry \o/ yay
\o/
- gtk_widget_class_bind_template_callback (widget_class, location_entry_changed_cb);
- gtk_widget_class_bind_template_callback (widget_class, ephy_bookmark_properties_response_cb);
- gtk_widget_class_bind_template_callback (widget_class, ephy_bookmark_properties_destroy_cb);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->constructor = ephy_bookmark_properties_constructor;
+ object_class->set_property = ephy_bookmark_properties_set_property;
+ object_class->get_property = ephy_bookmark_properties_get_property;
+
+ obj_properties[PROP_BOOKMARKS] =
+ g_param_spec_object ("bookmarks",
+ "bookmarks",
+ "bookmarks",
+ EPHY_TYPE_BOOKMARKS,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+
+ obj_properties[PROP_BOOKMARK] =
+ g_param_spec_pointer ("bookmark",
+ "bookmark",
+ "bookmark",
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT);
+
+ obj_properties[PROP_CREATING] =
+ g_param_spec_boolean ("creating",
+ "creating",
+ "creating",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+
+ /* from UI file */
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/epiphany/bookmark-properties.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, grid);
+ gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, title_entry);
+ gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, adress_entry);
+ gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, topics_label);
+ gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, topics_expander);
+ gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, topics_tree_view);
+ gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, topics_scrolled_window);
+ gtk_widget_class_bind_template_child (widget_class, EphyBookmarkProperties, warning_label);
+
+ gtk_widget_class_bind_template_callback (widget_class, title_entry_changed_cb);
+ gtk_widget_class_bind_template_callback (widget_class, on_topic_toggled); /* TODO make the row
activatable instead of a little togglebutton */
+ gtk_widget_class_bind_template_callback (widget_class, on_topic_edited); /* TODO topics’ names
are not editable from there, they are synced with bookmarks... but this is used for... updating the entry \o/
yay \o/ */
+ gtk_widget_class_bind_template_callback (widget_class, location_entry_changed_cb);
+ gtk_widget_class_bind_template_callback (widget_class, ephy_bookmark_properties_response_cb);
+ gtk_widget_class_bind_template_callback (widget_class, ephy_bookmark_properties_destroy_cb);
}
/* public API */
GtkWidget *
ephy_bookmark_properties_new (EphyBookmarks *bookmarks,
- EphyNode *bookmark,
- gboolean creating)
+ EphyNode *bookmark,
+ gboolean creating)
{
- g_assert (bookmarks != NULL);
-
- return GTK_WIDGET (g_object_new (EPHY_TYPE_BOOKMARK_PROPERTIES,
- "bookmarks", bookmarks,
- "bookmark", bookmark,
- "creating", creating,
- "use-header-bar", TRUE,
- NULL));
+ g_assert (bookmarks != NULL);
+
+ return GTK_WIDGET (g_object_new (EPHY_TYPE_BOOKMARK_PROPERTIES,
+ "bookmarks", bookmarks,
+ "bookmark", bookmark,
+ "creating", creating,
+ "use-header-bar", TRUE,
+ NULL));
}
EphyNode *
ephy_bookmark_properties_get_node (EphyBookmarkProperties *properties)
{
- return properties->bookmark;
+ return properties->bookmark;
}
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c
index 9b73e9d..3852944 100644
--- a/src/bookmarks/ephy-bookmarks-editor.c
+++ b/src/bookmarks/ephy-bookmarks-editor.c
@@ -48,169 +48,166 @@
static const GtkTargetEntry topic_drag_dest_types [] =
{
- { (char *)EPHY_DND_URI_LIST_TYPE, 0, 0 }
+ { (char *)EPHY_DND_URI_LIST_TYPE, 0, 0 }
};
static const GtkTargetEntry bmk_drag_types [] =
{
- { (char *)EPHY_DND_URL_TYPE, 0, 0 },
- { (char *)EPHY_DND_URI_LIST_TYPE, 0, 1 },
- { (char *)EPHY_DND_TEXT_TYPE, 0, 2 }
+ { (char *)EPHY_DND_URL_TYPE, 0, 0 },
+ { (char *)EPHY_DND_URI_LIST_TYPE, 0, 1 },
+ { (char *)EPHY_DND_TEXT_TYPE, 0, 2 }
};
static const GtkTargetEntry topic_drag_types [] =
{
- { (char *)EPHY_DND_TOPIC_TYPE, 0, 0 }
+ { (char *)EPHY_DND_TOPIC_TYPE, 0, 0 }
};
-static const struct
-{
- const char *name;
- const char *extension;
+static const struct {
+ const char *name;
+ const char *extension;
}
-export_formats [] =
+export_formats [] =
/* Don't add or reoder those entries without updating export_dialog_response_cb too! */
{
- { N_("Web (RDF)"), "rdf" },
- { N_("Mozilla (HTML)"), "html" }
+ { N_("Web (RDF)"), "rdf" },
+ { N_("Mozilla (HTML)"), "html" }
};
static void ephy_bookmarks_editor_finalize (GObject *object);
-static void ephy_bookmarks_editor_dispose (GObject *object);
-static void ephy_bookmarks_editor_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void ephy_bookmarks_editor_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor);
-
-static void cmd_open_bookmarks_in_tabs (GtkAction *action,
- EphyBookmarksEditor *editor);
-static void cmd_open_bookmarks_in_browser (GtkAction *action,
- EphyBookmarksEditor *editor);
-static void cmd_delete (GtkAction *action,
- EphyBookmarksEditor *editor);
-static void cmd_bookmark_properties (GtkAction *action,
- EphyBookmarksEditor *editor);
-static void cmd_bookmarks_import (GtkAction *action,
- EphyBookmarksEditor *editor);
-static void cmd_bookmarks_export (GtkAction *action,
- EphyBookmarksEditor *editor);
-static void cmd_add_topic (GtkAction *action,
- EphyBookmarksEditor *editor);
-static void cmd_rename (GtkAction *action,
- EphyBookmarksEditor *editor);
-static void cmd_close (GtkAction *action,
- EphyBookmarksEditor *editor);
-static void cmd_cut (GtkAction *action,
- EphyBookmarksEditor *editor);
-static void cmd_copy (GtkAction *action,
- EphyBookmarksEditor *editor);
-static void cmd_paste (GtkAction *action,
- EphyBookmarksEditor *editor);
-static void cmd_select_all (GtkAction *action,
- EphyBookmarksEditor *editor);
-static void cmd_help_contents (GtkAction *action,
- EphyBookmarksEditor *editor);
+static void ephy_bookmarks_editor_dispose (GObject *object);
+static void ephy_bookmarks_editor_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void ephy_bookmarks_editor_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor);
+
+static void cmd_open_bookmarks_in_tabs (GtkAction *action,
+ EphyBookmarksEditor *editor);
+static void cmd_open_bookmarks_in_browser (GtkAction *action,
+ EphyBookmarksEditor *editor);
+static void cmd_delete (GtkAction *action,
+ EphyBookmarksEditor *editor);
+static void cmd_bookmark_properties (GtkAction *action,
+ EphyBookmarksEditor *editor);
+static void cmd_bookmarks_import (GtkAction *action,
+ EphyBookmarksEditor *editor);
+static void cmd_bookmarks_export (GtkAction *action,
+ EphyBookmarksEditor *editor);
+static void cmd_add_topic (GtkAction *action,
+ EphyBookmarksEditor *editor);
+static void cmd_rename (GtkAction *action,
+ EphyBookmarksEditor *editor);
+static void cmd_close (GtkAction *action,
+ EphyBookmarksEditor *editor);
+static void cmd_cut (GtkAction *action,
+ EphyBookmarksEditor *editor);
+static void cmd_copy (GtkAction *action,
+ EphyBookmarksEditor *editor);
+static void cmd_paste (GtkAction *action,
+ EphyBookmarksEditor *editor);
+static void cmd_select_all (GtkAction *action,
+ EphyBookmarksEditor *editor);
+static void cmd_help_contents (GtkAction *action,
+ EphyBookmarksEditor *editor);
#define RESERVED_STRING N_("Remove from this topic")
-struct _EphyBookmarksEditor
-{
- GtkWindow parent_instance;
-
- EphyBookmarks *bookmarks;
- GtkWidget *bm_view;
- GtkWidget *key_view;
- EphyNodeFilter *bookmarks_filter;
- GtkWidget *search_entry;
- GtkWidget *main_vbox;
- GtkWidget *window;
- GtkUIManager *ui_merge;
- GtkActionGroup *action_group;
- int priority_col;
-
- GtkTreeViewColumn *title_col;
- GtkTreeViewColumn *address_col;
+struct _EphyBookmarksEditor {
+ GtkWindow parent_instance;
+
+ EphyBookmarks *bookmarks;
+ GtkWidget *bm_view;
+ GtkWidget *key_view;
+ EphyNodeFilter *bookmarks_filter;
+ GtkWidget *search_entry;
+ GtkWidget *main_vbox;
+ GtkWidget *window;
+ GtkUIManager *ui_merge;
+ GtkActionGroup *action_group;
+ int priority_col;
+
+ GtkTreeViewColumn *title_col;
+ GtkTreeViewColumn *address_col;
};
-enum
-{
- PROP_0,
- PROP_BOOKMARKS,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_BOOKMARKS,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
static const GtkActionEntry ephy_bookmark_popup_entries [] = {
- /* Toplevel */
- { "File", NULL, N_("_File") },
- { "Edit", NULL, N_("_Edit") },
- { "View", NULL, N_("_View") },
- { "Help", NULL, N_("_Help") },
- { "PopupAction", NULL, "" },
-
- /* File Menu*/
- { "NewTopic", NULL, N_("_New Topic"), "<control>N",
- N_("Create a new topic"),
- G_CALLBACK (cmd_add_topic) },
- { "OpenInWindow", NULL, N_("Open in New _Window"), "<control>O",
- N_("Open the selected bookmark in a new window"),
- G_CALLBACK (cmd_open_bookmarks_in_browser) },
- { "OpenInTab", NULL, N_("Open in New _Tab"), "<shift><control>O",
- N_("Open the selected bookmark in a new tab"),
- G_CALLBACK (cmd_open_bookmarks_in_tabs) },
- { "Rename", NULL, N_("_Rename…"), "F2",
- N_("Rename the selected bookmark or topic"), G_CALLBACK (cmd_rename) },
- { "Properties", NULL, N_("_Properties"), "<alt>Return",
- N_("View or modify the properties of the selected bookmark"),
- G_CALLBACK (cmd_bookmark_properties) },
- { "Import", NULL, N_("_Import Bookmarks…"), NULL,
- N_("Import bookmarks from another browser or a bookmarks file"),
- G_CALLBACK (cmd_bookmarks_import) },
- { "Export", NULL, N_("_Export Bookmarks…"), NULL,
- N_("Export bookmarks to a file"),
- G_CALLBACK (cmd_bookmarks_export) },
- { "Close", NULL, N_("_Close"), "<control>W",
- N_("Close the bookmarks window"),
- G_CALLBACK (cmd_close) },
-
- /* Edit Menu */
- { "Cut", NULL, N_("Cu_t"), "<control>X",
- N_("Cut the selection"),
- G_CALLBACK (cmd_cut) },
- { "Copy", NULL, N_("_Copy"), "<control>C",
- N_("Copy the selection"),
- G_CALLBACK (cmd_copy) },
- { "Paste", NULL, N_("_Paste"), "<control>V",
- N_("Paste the clipboard"),
- G_CALLBACK (cmd_paste) },
- { "Delete", NULL, N_("_Delete"), "<control>T",
- N_("Delete the selected bookmark or topic"),
- G_CALLBACK (cmd_delete) },
- { "SelectAll", NULL, N_("Select _All"), "<control>A",
- N_("Select all bookmarks or text"),
- G_CALLBACK (cmd_select_all) },
-
- /* Help Menu */
- { "HelpContents", NULL, N_("_Contents"), "F1",
- N_("Display bookmarks help"),
- G_CALLBACK (cmd_help_contents) },
- { "HelpAbout", NULL, N_("_About"), NULL,
- N_("Display credits for the web browser creators"),
- G_CALLBACK (window_cmd_help_about) },
+ /* Toplevel */
+ { "File", NULL, N_("_File") },
+ { "Edit", NULL, N_("_Edit") },
+ { "View", NULL, N_("_View") },
+ { "Help", NULL, N_("_Help") },
+ { "PopupAction", NULL, "" },
+
+ /* File Menu*/
+ { "NewTopic", NULL, N_("_New Topic"), "<control>N",
+ N_("Create a new topic"),
+ G_CALLBACK (cmd_add_topic) },
+ { "OpenInWindow", NULL, N_("Open in New _Window"), "<control>O",
+ N_("Open the selected bookmark in a new window"),
+ G_CALLBACK (cmd_open_bookmarks_in_browser) },
+ { "OpenInTab", NULL, N_("Open in New _Tab"), "<shift><control>O",
+ N_("Open the selected bookmark in a new tab"),
+ G_CALLBACK (cmd_open_bookmarks_in_tabs) },
+ { "Rename", NULL, N_("_Rename…"), "F2",
+ N_("Rename the selected bookmark or topic"), G_CALLBACK (cmd_rename) },
+ { "Properties", NULL, N_("_Properties"), "<alt>Return",
+ N_("View or modify the properties of the selected bookmark"),
+ G_CALLBACK (cmd_bookmark_properties) },
+ { "Import", NULL, N_("_Import Bookmarks…"), NULL,
+ N_("Import bookmarks from another browser or a bookmarks file"),
+ G_CALLBACK (cmd_bookmarks_import) },
+ { "Export", NULL, N_("_Export Bookmarks…"), NULL,
+ N_("Export bookmarks to a file"),
+ G_CALLBACK (cmd_bookmarks_export) },
+ { "Close", NULL, N_("_Close"), "<control>W",
+ N_("Close the bookmarks window"),
+ G_CALLBACK (cmd_close) },
+
+ /* Edit Menu */
+ { "Cut", NULL, N_("Cu_t"), "<control>X",
+ N_("Cut the selection"),
+ G_CALLBACK (cmd_cut) },
+ { "Copy", NULL, N_("_Copy"), "<control>C",
+ N_("Copy the selection"),
+ G_CALLBACK (cmd_copy) },
+ { "Paste", NULL, N_("_Paste"), "<control>V",
+ N_("Paste the clipboard"),
+ G_CALLBACK (cmd_paste) },
+ { "Delete", NULL, N_("_Delete"), "<control>T",
+ N_("Delete the selected bookmark or topic"),
+ G_CALLBACK (cmd_delete) },
+ { "SelectAll", NULL, N_("Select _All"), "<control>A",
+ N_("Select all bookmarks or text"),
+ G_CALLBACK (cmd_select_all) },
+
+ /* Help Menu */
+ { "HelpContents", NULL, N_("_Contents"), "F1",
+ N_("Display bookmarks help"),
+ G_CALLBACK (cmd_help_contents) },
+ { "HelpAbout", NULL, N_("_About"), NULL,
+ N_("Display credits for the web browser creators"),
+ G_CALLBACK (window_cmd_help_about) },
};
static const GtkToggleActionEntry ephy_bookmark_toggle_entries [] = {
- /* View Menu */
- { "ViewTitle", NULL, N_("_Title"), NULL,
- N_("Show the title column"), NULL, TRUE },
- { "ViewAddress", NULL, N_("Address"), NULL,
- N_("Show the address column"), NULL, FALSE }
+ /* View Menu */
+ { "ViewTitle", NULL, N_("_Title"), NULL,
+ N_("Show the title column"), NULL, TRUE },
+ { "ViewAddress", NULL, N_("Address"), NULL,
+ N_("Show the address column"), NULL, FALSE }
};
G_DEFINE_TYPE (EphyBookmarksEditor, ephy_bookmarks_editor, GTK_TYPE_WINDOW)
@@ -218,1232 +215,1152 @@ G_DEFINE_TYPE (EphyBookmarksEditor, ephy_bookmarks_editor, GTK_TYPE_WINDOW)
static void
entry_selection_changed_cb (GtkWidget *widget, GParamSpec *pspec, EphyBookmarksEditor *editor)
{
- ephy_bookmarks_editor_update_menu (editor);
+ ephy_bookmarks_editor_update_menu (editor);
}
static void
add_entry_monitor (EphyBookmarksEditor *editor, GtkWidget *entry)
{
- g_signal_connect (G_OBJECT (entry),
- "notify::selection-bound",
- G_CALLBACK (entry_selection_changed_cb),
- editor);
- g_signal_connect (G_OBJECT (entry),
- "notify::cursor-position",
- G_CALLBACK (entry_selection_changed_cb),
- editor);
+ g_signal_connect (G_OBJECT (entry),
+ "notify::selection-bound",
+ G_CALLBACK (entry_selection_changed_cb),
+ editor);
+ g_signal_connect (G_OBJECT (entry),
+ "notify::cursor-position",
+ G_CALLBACK (entry_selection_changed_cb),
+ editor);
}
static void
add_text_renderer_monitor (EphyBookmarksEditor *editor)
{
- GtkWidget *entry;
+ GtkWidget *entry;
- entry = gtk_window_get_focus (GTK_WINDOW (editor));
- g_return_if_fail (GTK_IS_EDITABLE (entry));
+ entry = gtk_window_get_focus (GTK_WINDOW (editor));
+ g_return_if_fail (GTK_IS_EDITABLE (entry));
- add_entry_monitor (editor, entry);
+ add_entry_monitor (editor, entry);
}
static void
-cmd_add_topic (GtkAction *action,
- EphyBookmarksEditor *editor)
+cmd_add_topic (GtkAction *action,
+ EphyBookmarksEditor *editor)
{
- EphyNode *node;
-
- node = ephy_bookmarks_add_keyword (editor->bookmarks,
- _("Type a topic"));
- gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (editor->key_view)));
- ephy_node_view_select_node (EPHY_NODE_VIEW (editor->key_view), node);
- ephy_node_view_edit (EPHY_NODE_VIEW (editor->key_view), TRUE);
- add_text_renderer_monitor (editor);
+ EphyNode *node;
+
+ node = ephy_bookmarks_add_keyword (editor->bookmarks,
+ _("Type a topic"));
+ gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (editor->key_view)));
+ ephy_node_view_select_node (EPHY_NODE_VIEW (editor->key_view), node);
+ ephy_node_view_edit (EPHY_NODE_VIEW (editor->key_view), TRUE);
+ add_text_renderer_monitor (editor);
}
static void
-cmd_close (GtkAction *action,
- EphyBookmarksEditor *editor)
+cmd_close (GtkAction *action,
+ EphyBookmarksEditor *editor)
{
- gtk_widget_hide (GTK_WIDGET (editor));
+ gtk_widget_hide (GTK_WIDGET (editor));
}
static void
-cmd_rename (GtkAction *action,
- EphyBookmarksEditor *editor)
-{
- if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->bm_view)))
- {
- ephy_node_view_edit (EPHY_NODE_VIEW (editor->bm_view), FALSE);
- }
- else if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->key_view)))
- {
- ephy_node_view_edit (EPHY_NODE_VIEW (editor->key_view), FALSE);
- }
- add_text_renderer_monitor (editor);
+cmd_rename (GtkAction *action,
+ EphyBookmarksEditor *editor)
+{
+ if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->bm_view))) {
+ ephy_node_view_edit (EPHY_NODE_VIEW (editor->bm_view), FALSE);
+ } else if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->key_view))) {
+ ephy_node_view_edit (EPHY_NODE_VIEW (editor->key_view), FALSE);
+ }
+ add_text_renderer_monitor (editor);
}
static GtkWidget *
get_target_window (EphyBookmarksEditor *editor)
{
- if (editor->window)
- {
- return editor->window;
- }
- else
- {
- return GTK_WIDGET (gtk_application_get_active_window (GTK_APPLICATION (ephy_shell_get_default
())));
- }
+ if (editor->window) {
+ return editor->window;
+ } else {
+ return GTK_WIDGET (gtk_application_get_active_window (GTK_APPLICATION (ephy_shell_get_default ())));
+ }
}
static void
-load_bookmark_in_tab (EphyNode *node,
+load_bookmark_in_tab (EphyNode *node,
EphyEmbed *embed)
{
- const char *location;
+ const char *location;
- location = ephy_node_get_property_string (node,
- EPHY_NODE_BMK_PROP_LOCATION);
- ephy_web_view_load_url (ephy_embed_get_web_view (embed), location);
+ location = ephy_node_get_property_string (node,
+ EPHY_NODE_BMK_PROP_LOCATION);
+ ephy_web_view_load_url (ephy_embed_get_web_view (embed), location);
}
static void
-cmd_open_bookmarks_in_tabs (GtkAction *action,
- EphyBookmarksEditor *editor)
-{
- EphyWindow *window;
- GList *selection;
- GList *l;
-
- window = EPHY_WINDOW (get_target_window (editor));
- selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->bm_view));
-
- for (l = selection; l; l = l->next)
- {
- EphyNode *node = l->data;
- EphyEmbed *new_embed;
-
- new_embed = ephy_shell_new_tab (ephy_shell_get_default (),
- window, NULL,
- 0);
- load_bookmark_in_tab (node, new_embed);
-
- /* if there was no target window, a new one was opened. Get it
- * from the new tab so we open the remaining links in the
- * same window. See bug 138343.
- */
- if (window == NULL)
- {
- window = EPHY_WINDOW
- (gtk_widget_get_toplevel (GTK_WIDGET (new_embed)));
- }
- }
-
- g_list_free (selection);
+cmd_open_bookmarks_in_tabs (GtkAction *action,
+ EphyBookmarksEditor *editor)
+{
+ EphyWindow *window;
+ GList *selection;
+ GList *l;
+
+ window = EPHY_WINDOW (get_target_window (editor));
+ selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->bm_view));
+
+ for (l = selection; l; l = l->next) {
+ EphyNode *node = l->data;
+ EphyEmbed *new_embed;
+
+ new_embed = ephy_shell_new_tab (ephy_shell_get_default (),
+ window, NULL,
+ 0);
+ load_bookmark_in_tab (node, new_embed);
+
+ /* if there was no target window, a new one was opened. Get it
+ * from the new tab so we open the remaining links in the
+ * same window. See bug 138343.
+ */
+ if (window == NULL) {
+ window = EPHY_WINDOW
+ (gtk_widget_get_toplevel (GTK_WIDGET (new_embed)));
+ }
+ }
+
+ g_list_free (selection);
}
static void
-cmd_open_bookmarks_in_browser (GtkAction *action,
- EphyBookmarksEditor *editor)
+cmd_open_bookmarks_in_browser (GtkAction *action,
+ EphyBookmarksEditor *editor)
{
- EphyWindow *window;
- GList *selection;
- GList *l;
+ EphyWindow *window;
+ GList *selection;
+ GList *l;
- window = ephy_window_new ();
- selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->bm_view));
+ window = ephy_window_new ();
+ selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->bm_view));
- for (l = selection; l; l = l->next)
- {
- EphyNode *node = l->data;
- EphyEmbed *embed;
+ for (l = selection; l; l = l->next) {
+ EphyNode *node = l->data;
+ EphyEmbed *embed;
- embed = ephy_shell_new_tab (ephy_shell_get_default (),
- window, NULL, 0);
- load_bookmark_in_tab (node, embed);
- }
+ embed = ephy_shell_new_tab (ephy_shell_get_default (),
+ window, NULL, 0);
+ load_bookmark_in_tab (node, embed);
+ }
- g_list_free (selection);
+ g_list_free (selection);
}
-static GtkWidget*
-delete_topic_dialog_construct (GtkWindow *parent,
- const char *topic)
-{
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_CANCEL,
- _("Delete topic “%s”?"),
- topic);
-
- gtk_window_set_title (GTK_WINDOW (dialog), _("Delete this topic?"));
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("Deleting this topic will cause all its bookmarks to become "
- "uncategorized, unless they also belong to other topics. "
- "The bookmarks will not be deleted."));
- gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Delete Topic"), GTK_RESPONSE_ACCEPT);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
-
- gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (parent)),
- GTK_WINDOW (dialog));
-
- return dialog;
+static GtkWidget *
+delete_topic_dialog_construct (GtkWindow *parent,
+ const char *topic)
+{
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_CANCEL,
+ _("Delete topic “%s”?"),
+ topic);
+
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Delete this topic?"));
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ _("Deleting this topic will cause all its bookmarks to become "
+ "uncategorized, unless they also belong to other topics. "
+ "The bookmarks will not be deleted."));
+ gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Delete Topic"), GTK_RESPONSE_ACCEPT);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+
+ gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (parent)),
+ GTK_WINDOW (dialog));
+
+ return dialog;
}
static void
-cmd_delete (GtkAction *action,
- EphyBookmarksEditor *editor)
-{
- if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->bm_view)))
- {
- ephy_node_view_remove (EPHY_NODE_VIEW (editor->bm_view));
- }
- else if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->key_view)))
- {
- int priority;
- GList *selected;
- EphyNode *node;
-
- selected = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->key_view));
- node = selected->data;
- priority = ephy_node_get_property_int (node, EPHY_NODE_KEYWORD_PROP_PRIORITY);
-
- if (priority == -1) priority = EPHY_NODE_NORMAL_PRIORITY;
-
- if (priority == EPHY_NODE_NORMAL_PRIORITY)
- {
- GtkWidget *dialog;
- const char *title;
- int response;
- GPtrArray *children;
-
- children = ephy_node_get_children(node);
-
- /* Do not warn if the topic is empty */
- if (children->len == 0)
- {
- ephy_node_view_remove (EPHY_NODE_VIEW (editor->key_view));
- }
- else
- {
- title = ephy_node_get_property_string (node, EPHY_NODE_KEYWORD_PROP_NAME);
- dialog = delete_topic_dialog_construct (GTK_WINDOW (editor), title);
-
- response = gtk_dialog_run (GTK_DIALOG (dialog));
-
- gtk_widget_destroy (dialog);
-
- if (response == GTK_RESPONSE_ACCEPT)
- {
- ephy_node_view_remove (EPHY_NODE_VIEW (editor->key_view));
- }
- }
- }
- g_list_free (selected);
- }
+cmd_delete (GtkAction *action,
+ EphyBookmarksEditor *editor)
+{
+ if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->bm_view))) {
+ ephy_node_view_remove (EPHY_NODE_VIEW (editor->bm_view));
+ } else if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->key_view))) {
+ int priority;
+ GList *selected;
+ EphyNode *node;
+
+ selected = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->key_view));
+ node = selected->data;
+ priority = ephy_node_get_property_int (node, EPHY_NODE_KEYWORD_PROP_PRIORITY);
+
+ if (priority == -1) priority = EPHY_NODE_NORMAL_PRIORITY;
+
+ if (priority == EPHY_NODE_NORMAL_PRIORITY) {
+ GtkWidget *dialog;
+ const char *title;
+ int response;
+ GPtrArray *children;
+
+ children = ephy_node_get_children (node);
+
+ /* Do not warn if the topic is empty */
+ if (children->len == 0) {
+ ephy_node_view_remove (EPHY_NODE_VIEW (editor->key_view));
+ } else {
+ title = ephy_node_get_property_string (node, EPHY_NODE_KEYWORD_PROP_NAME);
+ dialog = delete_topic_dialog_construct (GTK_WINDOW (editor), title);
+
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+ gtk_widget_destroy (dialog);
+
+ if (response == GTK_RESPONSE_ACCEPT) {
+ ephy_node_view_remove (EPHY_NODE_VIEW (editor->key_view));
+ }
+ }
+ }
+ g_list_free (selected);
+ }
}
static GSList *
add_bookmarks_files (const char *dir,
- const char *filename,
- int max_depth)
+ const char *filename,
+ int max_depth)
{
- GSList *list;
- char *path;
+ GSList *list;
+ char *path;
- path = g_build_filename (g_get_home_dir (), dir, NULL);
- list = ephy_file_find (path, filename, max_depth);
- g_free (path);
+ path = g_build_filename (g_get_home_dir (), dir, NULL);
+ list = ephy_file_find (path, filename, max_depth);
+ g_free (path);
- return list;
+ return list;
}
static void
-add_bookmarks_source (const char *file,
- GtkListStore *store)
-{
- GtkTreeIter iter;
- char **path;
- char *description = NULL;
- int len, i;
-
- path = g_strsplit (file, G_DIR_SEPARATOR_S, -1);
- g_return_if_fail (path != NULL);
-
- len = g_strv_length (path);
-
- for (i = len - 2; i >= 0 && description == NULL; --i)
- {
- const char *p = (const char *) path[i];
-
- g_return_if_fail (p != NULL);
-
- if (strcmp (p, "firefox") == 0)
- {
- const char *profile = NULL, *dot;
-
- if (path[i+1] != NULL)
- {
- dot = strchr (path[i+1], '.');
- profile = dot ? dot + 1 : path[i+1];
- }
-
- if (profile != NULL && strcmp (profile, "default") != 0)
- {
- /* FIXME: proper i18n after freeze */
- description = g_strdup_printf ("%s “%s”", _("Firefox"), profile);
- }
- else
- {
- description = g_strdup (_("Firefox"));
- }
- }
- else if (strcmp (p, ".firefox") == 0)
- {
- description = g_strdup (_("Firebird"));
- }
- else if (strcmp (p, ".phoenix") == 0)
- {
- description = g_strdup (_("Firebird"));
- }
- else if (strcmp (p, ".mozilla") == 0)
- {
- /* Translators: The %s is the name of a Mozilla profile. */
- description = g_strdup_printf (_("Mozilla “%s” profile"), path[i+1]);
- }
- else if (strcmp (p, ".galeon") == 0)
- {
- description = g_strdup (_("Galeon"));
- }
- else if (strcmp (p, "konqueror") == 0)
- {
- description = g_strdup (_("Konqueror"));
- }
- }
-
- if (description != NULL)
- {
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter, 0, description, 1, file, -1);
-
- g_free (description);
- }
-
- g_strfreev (path);
+add_bookmarks_source (const char *file,
+ GtkListStore *store)
+{
+ GtkTreeIter iter;
+ char **path;
+ char *description = NULL;
+ int len, i;
+
+ path = g_strsplit (file, G_DIR_SEPARATOR_S, -1);
+ g_return_if_fail (path != NULL);
+
+ len = g_strv_length (path);
+
+ for (i = len - 2; i >= 0 && description == NULL; --i) {
+ const char *p = (const char *)path[i];
+
+ g_return_if_fail (p != NULL);
+
+ if (strcmp (p, "firefox") == 0) {
+ const char *profile = NULL, *dot;
+
+ if (path[i + 1] != NULL) {
+ dot = strchr (path[i + 1], '.');
+ profile = dot ? dot + 1 : path[i + 1];
+ }
+
+ if (profile != NULL && strcmp (profile, "default") != 0) {
+ /* FIXME: proper i18n after freeze */
+ description = g_strdup_printf ("%s “%s”", _("Firefox"), profile);
+ } else {
+ description = g_strdup (_("Firefox"));
+ }
+ } else if (strcmp (p, ".firefox") == 0) {
+ description = g_strdup (_("Firebird"));
+ } else if (strcmp (p, ".phoenix") == 0) {
+ description = g_strdup (_("Firebird"));
+ } else if (strcmp (p, ".mozilla") == 0) {
+ /* Translators: The %s is the name of a Mozilla profile. */
+ description = g_strdup_printf (_("Mozilla “%s” profile"), path[i + 1]);
+ } else if (strcmp (p, ".galeon") == 0) {
+ description = g_strdup (_("Galeon"));
+ } else if (strcmp (p, "konqueror") == 0) {
+ description = g_strdup (_("Konqueror"));
+ }
+ }
+
+ if (description != NULL) {
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, description, 1, file, -1);
+
+ g_free (description);
+ }
+
+ g_strfreev (path);
}
static void
import_bookmarks (EphyBookmarksEditor *editor,
- const char *filename)
-{
- if (ephy_bookmarks_import (editor->bookmarks, filename) == FALSE)
- {
- GtkWidget *dialog;
- char *basename;
-
- basename = g_filename_display_basename (filename);
- dialog = gtk_message_dialog_new (GTK_WINDOW (editor),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("Import failed"));
-
- gtk_window_set_title (GTK_WINDOW (dialog), _("Import Failed"));
- gtk_message_dialog_format_secondary_text
- (GTK_MESSAGE_DIALOG (dialog),
- _("The bookmarks from “%s” could not be imported "
- "because the file is corrupted or of an "
- "unsupported type."),
- basename);
-
- gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (editor)),
- GTK_WINDOW (dialog));
-
- gtk_dialog_run (GTK_DIALOG (dialog));
-
- g_free (basename);
- gtk_widget_destroy (dialog);
- }
+ const char *filename)
+{
+ if (ephy_bookmarks_import (editor->bookmarks, filename) == FALSE) {
+ GtkWidget *dialog;
+ char *basename;
+
+ basename = g_filename_display_basename (filename);
+ dialog = gtk_message_dialog_new (GTK_WINDOW (editor),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Import failed"));
+
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Import Failed"));
+ gtk_message_dialog_format_secondary_text
+ (GTK_MESSAGE_DIALOG (dialog),
+ _("The bookmarks from “%s” could not be imported "
+ "because the file is corrupted or of an "
+ "unsupported type."),
+ basename);
+
+ gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (editor)),
+ GTK_WINDOW (dialog));
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+
+ g_free (basename);
+ gtk_widget_destroy (dialog);
+ }
}
static void
-import_from_file_response_cb (GtkWidget *dialog,
- int response,
- EphyBookmarksEditor *editor)
+import_from_file_response_cb (GtkWidget *dialog,
+ int response,
+ EphyBookmarksEditor *editor)
{
- char *filename;
+ char *filename;
- gtk_widget_hide (dialog);
+ gtk_widget_hide (dialog);
- if (response == GTK_RESPONSE_ACCEPT)
- {
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+ if (response == GTK_RESPONSE_ACCEPT) {
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
- if (filename != NULL)
- {
- import_bookmarks (editor, filename);
+ if (filename != NULL) {
+ import_bookmarks (editor, filename);
- g_free (filename);
- }
- }
+ g_free (filename);
+ }
+ }
- gtk_widget_destroy (dialog);
+ gtk_widget_destroy (dialog);
}
static void
-import_dialog_response_cb (GtkDialog *dialog,
- int response,
- EphyBookmarksEditor *editor)
-{
- if (response == GTK_RESPONSE_OK)
- {
- GtkTreeIter iter;
- const char *filename;
- GtkWidget *combo;
- GtkTreeModel *model;
- GValue value = { 0, };
-
- combo = g_object_get_data (G_OBJECT (dialog), "combo_box");
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
- gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter);
- gtk_tree_model_get_value (model, &iter, 1, &value);
- filename = g_value_get_string (&value);
-
- if (filename == NULL)
- {
- EphyFileChooser *chooser;
- GtkFileFilter *filter;
-
- chooser = ephy_file_chooser_new (_("Import Bookmarks from File"),
- GTK_WIDGET (editor),
- GTK_FILE_CHOOSER_ACTION_OPEN,
- EPHY_FILE_FILTER_NONE);
-
- ephy_file_chooser_add_mime_filter
- (chooser,
- _("Firefox/Mozilla bookmarks"),
- "application/x-mozilla-bookmarks", NULL);
-
- ephy_file_chooser_add_mime_filter
- (chooser, _("Galeon/Konqueror bookmarks"),
- "application/x-xbel", NULL);
-
- ephy_file_chooser_add_mime_filter
- (chooser, _("Web bookmarks"),
- "text/rdf", "application/rdf+xml", NULL);
-
- filter = ephy_file_chooser_add_pattern_filter (chooser,
- _("All files"),
- "*", NULL);
-
- gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (chooser),
- filter);
-
- g_signal_connect (chooser, "response",
- G_CALLBACK (import_from_file_response_cb), editor);
-
- gtk_widget_show (GTK_WIDGET (chooser));
- }
- else
- {
- import_bookmarks (editor, filename);
- }
-
- g_value_unset (&value);
- }
-
- gtk_widget_destroy (GTK_WIDGET (dialog));
+import_dialog_response_cb (GtkDialog *dialog,
+ int response,
+ EphyBookmarksEditor *editor)
+{
+ if (response == GTK_RESPONSE_OK) {
+ GtkTreeIter iter;
+ const char *filename;
+ GtkWidget *combo;
+ GtkTreeModel *model;
+ GValue value = { 0, };
+
+ combo = g_object_get_data (G_OBJECT (dialog), "combo_box");
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
+ gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter);
+ gtk_tree_model_get_value (model, &iter, 1, &value);
+ filename = g_value_get_string (&value);
+
+ if (filename == NULL) {
+ EphyFileChooser *chooser;
+ GtkFileFilter *filter;
+
+ chooser = ephy_file_chooser_new (_("Import Bookmarks from File"),
+ GTK_WIDGET (editor),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ EPHY_FILE_FILTER_NONE);
+
+ ephy_file_chooser_add_mime_filter
+ (chooser,
+ _("Firefox/Mozilla bookmarks"),
+ "application/x-mozilla-bookmarks", NULL);
+
+ ephy_file_chooser_add_mime_filter
+ (chooser, _("Galeon/Konqueror bookmarks"),
+ "application/x-xbel", NULL);
+
+ ephy_file_chooser_add_mime_filter
+ (chooser, _("Web bookmarks"),
+ "text/rdf", "application/rdf+xml", NULL);
+
+ filter = ephy_file_chooser_add_pattern_filter (chooser,
+ _("All files"),
+ "*", NULL);
+
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (chooser),
+ filter);
+
+ g_signal_connect (chooser, "response",
+ G_CALLBACK (import_from_file_response_cb), editor);
+
+ gtk_widget_show (GTK_WIDGET (chooser));
+ } else {
+ import_bookmarks (editor, filename);
+ }
+
+ g_value_unset (&value);
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
}
static void
-export_format_combo_changed_cb (GtkComboBox *combo,
- GtkFileChooser *chooser)
-{
- char *filename, *basename, *dot, *newname;
- guint i;
- gint format;
-
- filename = gtk_file_chooser_get_filename (chooser);
- if (filename == NULL) return;
-
- basename = g_path_get_basename (filename);
- if (basename == NULL || basename[0] == '\0')
- {
- g_free (filename);
- g_free (basename);
- return;
- }
-
- format = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
- g_return_if_fail (format >= 0 && (guint)format < G_N_ELEMENTS (export_formats));
-
- dot = strrchr (basename, '.');
- if (dot != NULL)
- {
- for (i = 0; i < G_N_ELEMENTS (export_formats); ++i)
- {
- if (strcmp (dot + 1, export_formats[i].extension) == 0)
- {
- *dot = '\0';
- break;
- }
- }
- }
-
- newname = g_strconcat (basename, ".",
- export_formats[format].extension,
- NULL);
-
- gtk_file_chooser_set_current_name (chooser, newname);
-
- g_free (filename);
- g_free (basename);
- g_free (newname);
+export_format_combo_changed_cb (GtkComboBox *combo,
+ GtkFileChooser *chooser)
+{
+ char *filename, *basename, *dot, *newname;
+ guint i;
+ gint format;
+
+ filename = gtk_file_chooser_get_filename (chooser);
+ if (filename == NULL) return;
+
+ basename = g_path_get_basename (filename);
+ if (basename == NULL || basename[0] == '\0') {
+ g_free (filename);
+ g_free (basename);
+ return;
+ }
+
+ format = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
+ g_return_if_fail (format >= 0 && (guint)format < G_N_ELEMENTS (export_formats));
+
+ dot = strrchr (basename, '.');
+ if (dot != NULL) {
+ for (i = 0; i < G_N_ELEMENTS (export_formats); ++i) {
+ if (strcmp (dot + 1, export_formats[i].extension) == 0) {
+ *dot = '\0';
+ break;
+ }
+ }
+ }
+
+ newname = g_strconcat (basename, ".",
+ export_formats[format].extension,
+ NULL);
+
+ gtk_file_chooser_set_current_name (chooser, newname);
+
+ g_free (filename);
+ g_free (basename);
+ g_free (newname);
}
static void
-export_dialog_response_cb (GtkWidget *dialog,
- int response,
- EphyBookmarksEditor *editor)
+export_dialog_response_cb (GtkWidget *dialog,
+ int response,
+ EphyBookmarksEditor *editor)
{
- GtkWidget *combo;
- char *filename;
- int format;
-
- if (response != GTK_RESPONSE_ACCEPT)
- {
- gtk_widget_destroy (dialog);
- return;
- }
-
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
- if (filename == NULL) return;
-
- if (!ephy_gui_check_location_writable (GTK_WIDGET (dialog), filename))
- {
- g_free (filename);
- return;
- }
-
- combo = g_object_get_data (G_OBJECT (dialog), "format-combo");
- g_return_if_fail (combo != NULL);
-
- format = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
- g_return_if_fail (format >= 0 && (guint)format < G_N_ELEMENTS (export_formats));
-
- gtk_widget_destroy (dialog);
-
- /* 0 for ephy RDF format, 1 for mozilla HTML format */
- if (format == 0)
- {
- ephy_bookmarks_export_rdf (editor->bookmarks, filename);
- }
- else if (format == 1)
- {
- ephy_bookmarks_export_mozilla (editor->bookmarks, filename);
- }
-
- g_free (filename);
+ GtkWidget *combo;
+ char *filename;
+ int format;
+
+ if (response != GTK_RESPONSE_ACCEPT) {
+ gtk_widget_destroy (dialog);
+ return;
+ }
+
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+ if (filename == NULL) return;
+
+ if (!ephy_gui_check_location_writable (GTK_WIDGET (dialog), filename)) {
+ g_free (filename);
+ return;
+ }
+
+ combo = g_object_get_data (G_OBJECT (dialog), "format-combo");
+ g_return_if_fail (combo != NULL);
+
+ format = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
+ g_return_if_fail (format >= 0 && (guint)format < G_N_ELEMENTS (export_formats));
+
+ gtk_widget_destroy (dialog);
+
+ /* 0 for ephy RDF format, 1 for mozilla HTML format */
+ if (format == 0) {
+ ephy_bookmarks_export_rdf (editor->bookmarks, filename);
+ } else if (format == 1) {
+ ephy_bookmarks_export_mozilla (editor->bookmarks, filename);
+ }
+
+ g_free (filename);
}
static void
-cmd_bookmarks_export (GtkAction *action,
- EphyBookmarksEditor *editor)
+cmd_bookmarks_export (GtkAction *action,
+ EphyBookmarksEditor *editor)
{
- GtkWidget *dialog, *hbox, *label, *combo;
- guint format;
- char *filename;
-
- dialog = GTK_WIDGET (ephy_file_chooser_new (_("Export Bookmarks"),
- GTK_WIDGET (editor),
- GTK_FILE_CHOOSER_ACTION_SAVE,
- EPHY_FILE_FILTER_NONE));
-
- gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
-
- filename = g_strdup_printf ("%s.%s", _("Bookmarks"), export_formats[0].extension);
- gtk_file_chooser_set_current_name
- (GTK_FILE_CHOOSER (dialog), filename);
- g_free(filename);
-
- /* Make a format selection combo & label */
- label = gtk_label_new_with_mnemonic (_("File f_ormat:"));
-
- combo = gtk_combo_box_text_new ();
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
-
- for (format = 0; format < G_N_ELEMENTS (export_formats); ++format)
- {
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo),
- _(export_formats[format].name));
- }
-
- g_object_set_data (G_OBJECT (dialog), "format-combo", combo);
- g_signal_connect (combo, "changed",
- G_CALLBACK (export_format_combo_changed_cb), dialog);
- gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
- gtk_widget_show_all (hbox);
-
- gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), hbox);
-
- gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (editor)),
- GTK_WINDOW (dialog));
-
- g_signal_connect (dialog, "response",
- G_CALLBACK (export_dialog_response_cb), editor);
- gtk_widget_show (dialog);
+ GtkWidget *dialog, *hbox, *label, *combo;
+ guint format;
+ char *filename;
+
+ dialog = GTK_WIDGET (ephy_file_chooser_new (_("Export Bookmarks"),
+ GTK_WIDGET (editor),
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ EPHY_FILE_FILTER_NONE));
+
+ gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
+
+ filename = g_strdup_printf ("%s.%s", _("Bookmarks"), export_formats[0].extension);
+ gtk_file_chooser_set_current_name
+ (GTK_FILE_CHOOSER (dialog), filename);
+ g_free (filename);
+
+ /* Make a format selection combo & label */
+ label = gtk_label_new_with_mnemonic (_("File f_ormat:"));
+
+ combo = gtk_combo_box_text_new ();
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
+
+ for (format = 0; format < G_N_ELEMENTS (export_formats); ++format) {
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo),
+ _(export_formats[format].name));
+ }
+
+ g_object_set_data (G_OBJECT (dialog), "format-combo", combo);
+ g_signal_connect (combo, "changed",
+ G_CALLBACK (export_format_combo_changed_cb), dialog);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
+
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
+ gtk_widget_show_all (hbox);
+
+ gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), hbox);
+
+ gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (editor)),
+ GTK_WINDOW (dialog));
+
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (export_dialog_response_cb), editor);
+ gtk_widget_show (dialog);
}
static void
-cmd_bookmarks_import (GtkAction *action,
- EphyBookmarksEditor *editor)
-{
- GtkWidget *dialog;
- GtkWidget *content_area;
- GtkWidget *label;
- GtkWidget *vbox;
- GtkWidget *combo;
- GtkCellRenderer *cell;
- GtkListStore *store;
- GtkTreeIter iter;
- GtkTreeModel *sortmodel;
- GSList *files;
-
- dialog = gtk_dialog_new_with_buttons (_("Import Bookmarks"),
- GTK_WINDOW (editor),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- _("_Cancel"),
- GTK_RESPONSE_CANCEL,
- _("I_mport"),
- GTK_RESPONSE_OK,
- NULL);
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
- gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- gtk_box_set_spacing (GTK_BOX (content_area), 2);
-
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
- gtk_widget_show (vbox);
- gtk_box_pack_start (GTK_BOX (content_area), vbox,
- TRUE, TRUE, 0);
-
- label = gtk_label_new (_("Import bookmarks from:"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
- gtk_widget_show (label);
-
- store = GTK_LIST_STORE (gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING));
-
- files = add_bookmarks_files (FIREFOX_BOOKMARKS_DIR_0, "bookmarks.html", 2);
- files = g_slist_concat (add_bookmarks_files (FIREFOX_BOOKMARKS_DIR_1, "bookmarks.html", 2), files);
- /* FIREFOX_BOOKMARKS_DIR_2 is subdir of MOZILLA_BOOKMARKS_DIR, so don't search it twice */
- files = g_slist_concat (add_bookmarks_files (MOZILLA_BOOKMARKS_DIR, "bookmarks.html", 2), files);
- files = g_slist_concat (add_bookmarks_files (GALEON_BOOKMARKS_DIR, "bookmarks.xbel", 0), files);
- files = g_slist_concat (add_bookmarks_files (KDE_BOOKMARKS_DIR, "bookmarks.xml", 0), files);
-
- g_slist_foreach (files, (GFunc) add_bookmarks_source, store);
- g_slist_foreach (files, (GFunc) g_free, NULL);
- g_slist_free (files);
-
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter, 0, _("File"), 1, NULL, -1);
-
- sortmodel = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (store));
- g_object_unref (store);
-
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sortmodel), 0, GTK_SORT_ASCENDING);
-
- combo = gtk_combo_box_new ();
- gtk_combo_box_set_model(GTK_COMBO_BOX (combo), sortmodel);
- g_object_set_data (G_OBJECT (dialog), "combo_box", combo);
- g_object_unref (sortmodel);
-
- cell = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), cell,
- "text", 0,
- NULL);
-
- gtk_box_pack_start (GTK_BOX (vbox), combo, TRUE, TRUE, 0);
- gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
-
- gtk_widget_show (combo);
-
- g_signal_connect (dialog, "response",
- G_CALLBACK (import_dialog_response_cb),
- editor);
-
- gtk_widget_show (dialog);
+cmd_bookmarks_import (GtkAction *action,
+ EphyBookmarksEditor *editor)
+{
+ GtkWidget *dialog;
+ GtkWidget *content_area;
+ GtkWidget *label;
+ GtkWidget *vbox;
+ GtkWidget *combo;
+ GtkCellRenderer *cell;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GtkTreeModel *sortmodel;
+ GSList *files;
+
+ dialog = gtk_dialog_new_with_buttons (_("Import Bookmarks"),
+ GTK_WINDOW (editor),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ _("_Cancel"),
+ GTK_RESPONSE_CANCEL,
+ _("I_mport"),
+ GTK_RESPONSE_OK,
+ NULL);
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+ gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+ gtk_box_set_spacing (GTK_BOX (content_area), 2);
+
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+ gtk_widget_show (vbox);
+ gtk_box_pack_start (GTK_BOX (content_area), vbox,
+ TRUE, TRUE, 0);
+
+ label = gtk_label_new (_("Import bookmarks from:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
+ gtk_widget_show (label);
+
+ store = GTK_LIST_STORE (gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING));
+
+ files = add_bookmarks_files (FIREFOX_BOOKMARKS_DIR_0, "bookmarks.html", 2);
+ files = g_slist_concat (add_bookmarks_files (FIREFOX_BOOKMARKS_DIR_1, "bookmarks.html", 2), files);
+ /* FIREFOX_BOOKMARKS_DIR_2 is subdir of MOZILLA_BOOKMARKS_DIR, so don't search it twice */
+ files = g_slist_concat (add_bookmarks_files (MOZILLA_BOOKMARKS_DIR, "bookmarks.html", 2), files);
+ files = g_slist_concat (add_bookmarks_files (GALEON_BOOKMARKS_DIR, "bookmarks.xbel", 0), files);
+ files = g_slist_concat (add_bookmarks_files (KDE_BOOKMARKS_DIR, "bookmarks.xml", 0), files);
+
+ g_slist_foreach (files, (GFunc)add_bookmarks_source, store);
+ g_slist_foreach (files, (GFunc)g_free, NULL);
+ g_slist_free (files);
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, _("File"), 1, NULL, -1);
+
+ sortmodel = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (store));
+ g_object_unref (store);
+
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sortmodel), 0, GTK_SORT_ASCENDING);
+
+ combo = gtk_combo_box_new ();
+ gtk_combo_box_set_model (GTK_COMBO_BOX (combo), sortmodel);
+ g_object_set_data (G_OBJECT (dialog), "combo_box", combo);
+ g_object_unref (sortmodel);
+
+ cell = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), cell,
+ "text", 0,
+ NULL);
+
+ gtk_box_pack_start (GTK_BOX (vbox), combo, TRUE, TRUE, 0);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
+
+ gtk_widget_show (combo);
+
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (import_dialog_response_cb),
+ editor);
+
+ gtk_widget_show (dialog);
}
static void
-cmd_bookmark_properties (GtkAction *action,
- EphyBookmarksEditor *editor)
+cmd_bookmark_properties (GtkAction *action,
+ EphyBookmarksEditor *editor)
{
- GList *selection;
- GList *l;
+ GList *selection;
+ GList *l;
- selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->bm_view));
+ selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->bm_view));
- for (l = selection; l; l = l->next)
- {
- EphyNode *node = l->data;
+ for (l = selection; l; l = l->next) {
+ EphyNode *node = l->data;
- ephy_bookmarks_ui_show_bookmark (GTK_WINDOW (editor), node);
- }
+ ephy_bookmarks_ui_show_bookmark (GTK_WINDOW (editor), node);
+ }
- g_list_free (selection);
+ g_list_free (selection);
}
static void
-cmd_cut (GtkAction *action,
- EphyBookmarksEditor *editor)
+cmd_cut (GtkAction *action,
+ EphyBookmarksEditor *editor)
{
- GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (editor));
+ GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (editor));
- if (GTK_IS_EDITABLE (widget))
- {
- gtk_editable_cut_clipboard (GTK_EDITABLE (widget));
- }
+ if (GTK_IS_EDITABLE (widget)) {
+ gtk_editable_cut_clipboard (GTK_EDITABLE (widget));
+ }
}
static void
-cmd_copy (GtkAction *action,
- EphyBookmarksEditor *editor)
+cmd_copy (GtkAction *action,
+ EphyBookmarksEditor *editor)
{
- GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (editor));
-
- if (GTK_IS_EDITABLE (widget))
- {
- gtk_editable_copy_clipboard (GTK_EDITABLE (widget));
- }
+ GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (editor));
- else if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->bm_view)))
- {
- GList *selection;
+ if (GTK_IS_EDITABLE (widget)) {
+ gtk_editable_copy_clipboard (GTK_EDITABLE (widget));
+ } else if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->bm_view))) {
+ GList *selection;
- selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->bm_view));
+ selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->bm_view));
- if (g_list_length (selection) == 1)
- {
- const char *tmp;
- EphyNode *node = selection->data;
- tmp = ephy_node_get_property_string (node, EPHY_NODE_BMK_PROP_LOCATION);
- gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD), tmp, -1);
- }
+ if (g_list_length (selection) == 1) {
+ const char *tmp;
+ EphyNode *node = selection->data;
+ tmp = ephy_node_get_property_string (node, EPHY_NODE_BMK_PROP_LOCATION);
+ gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD), tmp, -1);
+ }
- g_list_free (selection);
- }
+ g_list_free (selection);
+ }
}
static void
-cmd_paste (GtkAction *action,
- EphyBookmarksEditor *editor)
+cmd_paste (GtkAction *action,
+ EphyBookmarksEditor *editor)
{
- GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (editor));
+ GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (editor));
- if (GTK_IS_EDITABLE (widget))
- {
- gtk_editable_paste_clipboard (GTK_EDITABLE (widget));
- }
+ if (GTK_IS_EDITABLE (widget)) {
+ gtk_editable_paste_clipboard (GTK_EDITABLE (widget));
+ }
}
static void
-cmd_select_all (GtkAction *action,
- EphyBookmarksEditor *editor)
+cmd_select_all (GtkAction *action,
+ EphyBookmarksEditor *editor)
{
- GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (editor));
- GtkWidget *bm_view = editor->bm_view;
-
- if (GTK_IS_EDITABLE (widget))
- {
- gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1);
- }
- else if (ephy_node_view_is_target (EPHY_NODE_VIEW (bm_view)))
- {
- GtkTreeSelection *sel;
-
- sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (bm_view));
- gtk_tree_selection_select_all (sel);
- }
+ GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (editor));
+ GtkWidget *bm_view = editor->bm_view;
+
+ if (GTK_IS_EDITABLE (widget)) {
+ gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1);
+ } else if (ephy_node_view_is_target (EPHY_NODE_VIEW (bm_view))) {
+ GtkTreeSelection *sel;
+
+ sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (bm_view));
+ gtk_tree_selection_select_all (sel);
+ }
}
static void
-cmd_help_contents (GtkAction *action,
- EphyBookmarksEditor *editor)
+cmd_help_contents (GtkAction *action,
+ EphyBookmarksEditor *editor)
{
- ephy_gui_help (GTK_WIDGET (editor), "bookmark");
+ ephy_gui_help (GTK_WIDGET (editor), "bookmark");
}
static void
ephy_bookmarks_editor_show (GtkWidget *widget)
{
- EphyBookmarksEditor *editor = EPHY_BOOKMARKS_EDITOR (widget);
+ EphyBookmarksEditor *editor = EPHY_BOOKMARKS_EDITOR (widget);
- gtk_widget_grab_focus (editor->search_entry);
+ gtk_widget_grab_focus (editor->search_entry);
- GTK_WIDGET_CLASS (ephy_bookmarks_editor_parent_class)->show (widget);
+ GTK_WIDGET_CLASS (ephy_bookmarks_editor_parent_class)->show (widget);
}
static void
ephy_bookmarks_editor_class_init (EphyBookmarksEditorClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = ephy_bookmarks_editor_finalize;
- object_class->dispose = ephy_bookmarks_editor_dispose;
+ object_class->finalize = ephy_bookmarks_editor_finalize;
+ object_class->dispose = ephy_bookmarks_editor_dispose;
- object_class->set_property = ephy_bookmarks_editor_set_property;
- object_class->get_property = ephy_bookmarks_editor_get_property;
+ object_class->set_property = ephy_bookmarks_editor_set_property;
+ object_class->get_property = ephy_bookmarks_editor_get_property;
- widget_class->show = ephy_bookmarks_editor_show;
+ widget_class->show = ephy_bookmarks_editor_show;
- obj_properties[PROP_BOOKMARKS] =
- g_param_spec_object ("bookmarks",
- "Bookmarks set",
- "Bookmarks set",
- EPHY_TYPE_BOOKMARKS,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+ obj_properties[PROP_BOOKMARKS] =
+ g_param_spec_object ("bookmarks",
+ "Bookmarks set",
+ "Bookmarks set",
+ EPHY_TYPE_BOOKMARKS,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
}
static void
ephy_bookmarks_editor_finalize (GObject *object)
{
- /* FIXME: This should all be done in dispose, not finalize, but got to make sure that's safe. */
- EphyBookmarksEditor *editor = EPHY_BOOKMARKS_EDITOR (object);
+ /* FIXME: This should all be done in dispose, not finalize, but got to make sure that's safe. */
+ EphyBookmarksEditor *editor = EPHY_BOOKMARKS_EDITOR (object);
- g_object_unref (G_OBJECT (editor->bookmarks_filter));
+ g_object_unref (G_OBJECT (editor->bookmarks_filter));
- g_object_unref (editor->action_group);
- g_object_unref (editor->ui_merge);
+ g_object_unref (editor->action_group);
+ g_object_unref (editor->ui_merge);
- if (editor->window)
- {
- GtkWidget **window = &editor->window;
- g_object_remove_weak_pointer
- (G_OBJECT(editor->window),
- (gpointer *)window);
- }
+ if (editor->window) {
+ GtkWidget **window = &editor->window;
+ g_object_remove_weak_pointer
+ (G_OBJECT (editor->window),
+ (gpointer *)window);
+ }
- G_OBJECT_CLASS (ephy_bookmarks_editor_parent_class)->finalize (object);
+ G_OBJECT_CLASS (ephy_bookmarks_editor_parent_class)->finalize (object);
}
static void
-ephy_bookmarks_editor_node_activated_cb (GtkWidget *view,
- EphyNode *node,
- EphyBookmarksEditor *editor)
+ephy_bookmarks_editor_node_activated_cb (GtkWidget *view,
+ EphyNode *node,
+ EphyBookmarksEditor *editor)
{
- EphyEmbed *embed;
+ EphyEmbed *embed;
- embed = ephy_shell_new_tab (ephy_shell_get_default (),
- NULL, NULL, 0);
- load_bookmark_in_tab (node, embed);
+ embed = ephy_shell_new_tab (ephy_shell_get_default (),
+ NULL, NULL, 0);
+ load_bookmark_in_tab (node, embed);
}
static void
-ephy_bookmarks_editor_node_middle_clicked_cb (GtkWidget *view,
- EphyNode *node,
- EphyBookmarksEditor *editor)
+ephy_bookmarks_editor_node_middle_clicked_cb (GtkWidget *view,
+ EphyNode *node,
+ EphyBookmarksEditor *editor)
{
- EphyWindow *window;
- EphyEmbed *embed;
+ EphyWindow *window;
+ EphyEmbed *embed;
- window = EPHY_WINDOW (get_target_window (editor));
+ window = EPHY_WINDOW (get_target_window (editor));
- embed = ephy_shell_new_tab (ephy_shell_get_default (),
- window, NULL, 0);
- load_bookmark_in_tab (node, embed);
+ embed = ephy_shell_new_tab (ephy_shell_get_default (),
+ window, NULL, 0);
+ load_bookmark_in_tab (node, embed);
}
static void
ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor)
{
- gboolean open_in_window, open_in_tab,
- rename, delete, properties;
- const gchar *open_in_window_label, *open_in_tab_label, *copy_label;
- gboolean bmk_focus, key_focus;
- gboolean key_selection, bmk_selection, single_bmk_selected;
- gboolean key_normal = FALSE;
- gboolean cut, copy, paste, select_all;
- gboolean mutable = TRUE;
- gboolean fullscreen_lockdown;
-
- GtkActionGroup *action_group;
- GtkAction *action;
- GList *selected;
- GtkWidget *focus_widget;
- int num_bmk_selected;
-
- LOG ("Update menu sensitivity");
-
- bmk_focus = ephy_node_view_is_target
- (EPHY_NODE_VIEW (editor->bm_view));
- key_focus = ephy_node_view_is_target
- (EPHY_NODE_VIEW (editor->key_view));
- focus_widget = gtk_window_get_focus (GTK_WINDOW (editor));
-
- num_bmk_selected = gtk_tree_selection_count_selected_rows
- (gtk_tree_view_get_selection (GTK_TREE_VIEW (editor->bm_view)));
- bmk_selection = num_bmk_selected > 0;
- single_bmk_selected = num_bmk_selected == 1;
-
- key_selection = gtk_tree_selection_count_selected_rows
- (gtk_tree_view_get_selection (GTK_TREE_VIEW (editor->key_view))) > 0;
-
- if (GTK_IS_EDITABLE (focus_widget))
- {
- gboolean has_selection;
-
- has_selection = gtk_editable_get_selection_bounds
- (GTK_EDITABLE (focus_widget), NULL, NULL);
-
- cut = has_selection;
- copy = has_selection;
- paste = TRUE;
- select_all = TRUE;
- }
- else
- {
- cut = FALSE;
- copy = (bmk_focus && single_bmk_selected);
- paste = FALSE;
- select_all = bmk_focus;
- }
-
- selected = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->key_view));
- if (key_focus && selected)
- {
- EphyNode *node = selected->data;
- int priority;
- char name[EPHY_TOPIC_ACTION_NAME_BUFFER_SIZE];
-
- priority = ephy_node_get_property_int
- (node, EPHY_NODE_KEYWORD_PROP_PRIORITY);
- if (priority == -1) priority = EPHY_NODE_NORMAL_PRIORITY;
- key_normal = (priority == EPHY_NODE_NORMAL_PRIORITY);
-
- EPHY_TOPIC_ACTION_NAME_PRINTF (name, node);
- }
- g_list_free (selected);
-
- selected = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->bm_view));
- if (bmk_focus && selected)
- {
- EphyNode *node = selected->data;
- char name[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE];
-
- if (node == NULL) return;
-
- mutable = !ephy_node_get_property_boolean (node, EPHY_NODE_BMK_PROP_IMMUTABLE);
-
- EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, node);
- }
- g_list_free (selected);
-
- open_in_window_label = ngettext ("Open in New _Window",
- "Open in New _Windows",
- num_bmk_selected);
- open_in_tab_label = ngettext ("Open in New _Tab",
- "Open in New _Tabs",
- num_bmk_selected);
-
- if (bmk_focus)
- {
- copy_label = _("_Copy Address");
- }
- else
- {
- copy_label = _("_Copy");
- }
-
- fullscreen_lockdown = g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
- EPHY_PREFS_LOCKDOWN_FULLSCREEN);
- open_in_window = (bmk_focus && bmk_selection && !fullscreen_lockdown);
- open_in_tab = (bmk_focus && bmk_selection);
- rename = (bmk_focus && single_bmk_selected && mutable) ||
- (key_selection && key_focus && key_normal);
- delete = (bmk_focus && bmk_selection && mutable) ||
- (key_selection && key_focus && key_normal);
- properties = bmk_focus && single_bmk_selected && mutable;
-
- action_group = editor->action_group;
- action = gtk_action_group_get_action (action_group, "OpenInWindow");
- gtk_action_set_sensitive (action, open_in_window);
- g_object_set (action, "label", open_in_window_label, NULL);
- action = gtk_action_group_get_action (action_group, "OpenInTab");
- gtk_action_set_sensitive (action, open_in_tab);
- g_object_set (action, "label", open_in_tab_label, NULL);
- action = gtk_action_group_get_action (action_group, "Rename");
- gtk_action_set_sensitive (action, rename);
- action = gtk_action_group_get_action (action_group, "Delete");
- gtk_action_set_sensitive (action, delete);
- action = gtk_action_group_get_action (action_group, "Properties");
- gtk_action_set_sensitive (action, properties);
- action = gtk_action_group_get_action (action_group, "Cut");
- gtk_action_set_sensitive (action, cut);
- action = gtk_action_group_get_action (action_group, "Copy");
- gtk_action_set_sensitive (action, copy);
- g_object_set (action, "label", copy_label, NULL);
- action = gtk_action_group_get_action (action_group, "Paste");
- gtk_action_set_sensitive (action, paste);
- action = gtk_action_group_get_action (action_group, "SelectAll");
- g_object_set (action, "sensitive", select_all, NULL);
+ gboolean open_in_window, open_in_tab,
+ rename, delete, properties;
+ const gchar *open_in_window_label, *open_in_tab_label, *copy_label;
+ gboolean bmk_focus, key_focus;
+ gboolean key_selection, bmk_selection, single_bmk_selected;
+ gboolean key_normal = FALSE;
+ gboolean cut, copy, paste, select_all;
+ gboolean mutable = TRUE;
+ gboolean fullscreen_lockdown;
+
+ GtkActionGroup *action_group;
+ GtkAction *action;
+ GList *selected;
+ GtkWidget *focus_widget;
+ int num_bmk_selected;
+
+ LOG ("Update menu sensitivity");
+
+ bmk_focus = ephy_node_view_is_target
+ (EPHY_NODE_VIEW (editor->bm_view));
+ key_focus = ephy_node_view_is_target
+ (EPHY_NODE_VIEW (editor->key_view));
+ focus_widget = gtk_window_get_focus (GTK_WINDOW (editor));
+
+ num_bmk_selected = gtk_tree_selection_count_selected_rows
+ (gtk_tree_view_get_selection (GTK_TREE_VIEW (editor->bm_view)));
+ bmk_selection = num_bmk_selected > 0;
+ single_bmk_selected = num_bmk_selected == 1;
+
+ key_selection = gtk_tree_selection_count_selected_rows
+ (gtk_tree_view_get_selection (GTK_TREE_VIEW (editor->key_view))) > 0;
+
+ if (GTK_IS_EDITABLE (focus_widget)) {
+ gboolean has_selection;
+
+ has_selection = gtk_editable_get_selection_bounds
+ (GTK_EDITABLE (focus_widget), NULL, NULL);
+
+ cut = has_selection;
+ copy = has_selection;
+ paste = TRUE;
+ select_all = TRUE;
+ } else {
+ cut = FALSE;
+ copy = (bmk_focus && single_bmk_selected);
+ paste = FALSE;
+ select_all = bmk_focus;
+ }
+
+ selected = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->key_view));
+ if (key_focus && selected) {
+ EphyNode *node = selected->data;
+ int priority;
+ char name[EPHY_TOPIC_ACTION_NAME_BUFFER_SIZE];
+
+ priority = ephy_node_get_property_int
+ (node, EPHY_NODE_KEYWORD_PROP_PRIORITY);
+ if (priority == -1) priority = EPHY_NODE_NORMAL_PRIORITY;
+ key_normal = (priority == EPHY_NODE_NORMAL_PRIORITY);
+
+ EPHY_TOPIC_ACTION_NAME_PRINTF (name, node);
+ }
+ g_list_free (selected);
+
+ selected = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->bm_view));
+ if (bmk_focus && selected) {
+ EphyNode *node = selected->data;
+ char name[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE];
+
+ if (node == NULL) return;
+
+ mutable = !ephy_node_get_property_boolean (node, EPHY_NODE_BMK_PROP_IMMUTABLE);
+
+ EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, node);
+ }
+ g_list_free (selected);
+
+ open_in_window_label = ngettext ("Open in New _Window",
+ "Open in New _Windows",
+ num_bmk_selected);
+ open_in_tab_label = ngettext ("Open in New _Tab",
+ "Open in New _Tabs",
+ num_bmk_selected);
+
+ if (bmk_focus) {
+ copy_label = _("_Copy Address");
+ } else {
+ copy_label = _("_Copy");
+ }
+
+ fullscreen_lockdown = g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_FULLSCREEN);
+ open_in_window = (bmk_focus && bmk_selection && !fullscreen_lockdown);
+ open_in_tab = (bmk_focus && bmk_selection);
+ rename = (bmk_focus && single_bmk_selected && mutable) ||
+ (key_selection && key_focus && key_normal);
+ delete = (bmk_focus && bmk_selection && mutable) ||
+ (key_selection && key_focus && key_normal);
+ properties = bmk_focus && single_bmk_selected && mutable;
+
+ action_group = editor->action_group;
+ action = gtk_action_group_get_action (action_group, "OpenInWindow");
+ gtk_action_set_sensitive (action, open_in_window);
+ g_object_set (action, "label", open_in_window_label, NULL);
+ action = gtk_action_group_get_action (action_group, "OpenInTab");
+ gtk_action_set_sensitive (action, open_in_tab);
+ g_object_set (action, "label", open_in_tab_label, NULL);
+ action = gtk_action_group_get_action (action_group, "Rename");
+ gtk_action_set_sensitive (action, rename);
+ action = gtk_action_group_get_action (action_group, "Delete");
+ gtk_action_set_sensitive (action, delete);
+ action = gtk_action_group_get_action (action_group, "Properties");
+ gtk_action_set_sensitive (action, properties);
+ action = gtk_action_group_get_action (action_group, "Cut");
+ gtk_action_set_sensitive (action, cut);
+ action = gtk_action_group_get_action (action_group, "Copy");
+ gtk_action_set_sensitive (action, copy);
+ g_object_set (action, "label", copy_label, NULL);
+ action = gtk_action_group_get_action (action_group, "Paste");
+ gtk_action_set_sensitive (action, paste);
+ action = gtk_action_group_get_action (action_group, "SelectAll");
+ g_object_set (action, "sensitive", select_all, NULL);
}
static gboolean
-view_focus_cb (EphyNodeView *view,
- GdkEventFocus *event,
- EphyBookmarksEditor *editor)
+view_focus_cb (EphyNodeView *view,
+ GdkEventFocus *event,
+ EphyBookmarksEditor *editor)
{
- ephy_bookmarks_editor_update_menu (editor);
+ ephy_bookmarks_editor_update_menu (editor);
- return FALSE;
+ return FALSE;
}
static void
add_focus_monitor (EphyBookmarksEditor *editor, GtkWidget *widget)
{
- g_signal_connect (G_OBJECT (widget),
- "focus_in_event",
- G_CALLBACK (view_focus_cb),
- editor);
- g_signal_connect (G_OBJECT (widget),
- "focus_out_event",
- G_CALLBACK (view_focus_cb),
- editor);
+ g_signal_connect (G_OBJECT (widget),
+ "focus_in_event",
+ G_CALLBACK (view_focus_cb),
+ editor);
+ g_signal_connect (G_OBJECT (widget),
+ "focus_out_event",
+ G_CALLBACK (view_focus_cb),
+ editor);
}
static void
remove_focus_monitor (EphyBookmarksEditor *editor, GtkWidget *widget)
{
- g_signal_handlers_disconnect_by_func (G_OBJECT (widget),
- G_CALLBACK (view_focus_cb),
- editor);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (widget),
+ G_CALLBACK (view_focus_cb),
+ editor);
}
static gboolean
-ephy_bookmarks_editor_show_popup_cb (GtkWidget *view,
- EphyBookmarksEditor *editor)
+ephy_bookmarks_editor_show_popup_cb (GtkWidget *view,
+ EphyBookmarksEditor *editor)
{
- GtkWidget *widget;
+ GtkWidget *widget;
- widget = gtk_ui_manager_get_widget (editor->ui_merge,
- "/EphyBookmarkEditorPopup");
- ephy_node_view_popup (EPHY_NODE_VIEW (view), widget);
+ widget = gtk_ui_manager_get_widget (editor->ui_merge,
+ "/EphyBookmarkEditorPopup");
+ ephy_node_view_popup (EPHY_NODE_VIEW (view), widget);
- return TRUE;
+ return TRUE;
}
static void
ephy_bookmarks_editor_dispose (GObject *object)
{
- EphyBookmarksEditor *editor;
- GList *selection;
+ EphyBookmarksEditor *editor;
+ GList *selection;
- g_return_if_fail (object != NULL);
- g_return_if_fail (EPHY_IS_BOOKMARKS_EDITOR (object));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (EPHY_IS_BOOKMARKS_EDITOR (object));
- editor = EPHY_BOOKMARKS_EDITOR (object);
+ editor = EPHY_BOOKMARKS_EDITOR (object);
- if (editor->key_view != NULL)
- {
- remove_focus_monitor (editor, editor->key_view);
- remove_focus_monitor (editor, editor->bm_view);
- remove_focus_monitor (editor, editor->search_entry);
+ if (editor->key_view != NULL) {
+ remove_focus_monitor (editor, editor->key_view);
+ remove_focus_monitor (editor, editor->bm_view);
+ remove_focus_monitor (editor, editor->search_entry);
- selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->key_view));
- if (selection == NULL || selection->data == NULL)
- {
- editor->key_view = NULL;
- G_OBJECT_CLASS (ephy_bookmarks_editor_parent_class)->dispose (object);
- return;
- }
+ selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->key_view));
+ if (selection == NULL || selection->data == NULL) {
+ editor->key_view = NULL;
+ G_OBJECT_CLASS (ephy_bookmarks_editor_parent_class)->dispose (object);
+ return;
+ }
- g_list_free (selection);
+ g_list_free (selection);
- editor->key_view = NULL;
- }
+ editor->key_view = NULL;
+ }
- G_OBJECT_CLASS (ephy_bookmarks_editor_parent_class)->dispose (object);
+ G_OBJECT_CLASS (ephy_bookmarks_editor_parent_class)->dispose (object);
}
static void
bookmarks_filter (EphyBookmarksEditor *editor,
- EphyNode *keyword)
-{
- ephy_node_filter_empty (editor->bookmarks_filter);
- ephy_node_filter_add_expression (editor->bookmarks_filter,
- ephy_node_filter_expression_new
(EPHY_NODE_FILTER_EXPRESSION_HAS_PARENT,
- keyword),
- 0);
- ephy_node_filter_done_changing (editor->bookmarks_filter);
+ EphyNode *keyword)
+{
+ ephy_node_filter_empty (editor->bookmarks_filter);
+ ephy_node_filter_add_expression (editor->bookmarks_filter,
+ ephy_node_filter_expression_new (EPHY_NODE_FILTER_EXPRESSION_HAS_PARENT,
+ keyword),
+ 0);
+ ephy_node_filter_done_changing (editor->bookmarks_filter);
}
static gboolean
-key_pressed_cb (EphyNodeView *view,
- GdkEventKey *event,
- EphyBookmarksEditor *editor)
+key_pressed_cb (EphyNodeView *view,
+ GdkEventKey *event,
+ EphyBookmarksEditor *editor)
{
- GtkAction *action;
-
- if (event->keyval == GDK_KEY_Delete || event->keyval == GDK_KEY_KP_Delete)
- {
- action = gtk_action_group_get_action (editor->action_group, "Delete");
- if (gtk_action_get_sensitive (action))
- {
- cmd_delete (NULL, editor);
- return TRUE;
- }
- }
-
- return FALSE;
+ GtkAction *action;
+
+ if (event->keyval == GDK_KEY_Delete || event->keyval == GDK_KEY_KP_Delete) {
+ action = gtk_action_group_get_action (editor->action_group, "Delete");
+ if (gtk_action_get_sensitive (action)) {
+ cmd_delete (NULL, editor);
+ return TRUE;
+ }
+ }
+
+ return FALSE;
}
static void
-keyword_node_selected_cb (EphyNodeView *view,
- EphyNode *node,
- EphyBookmarksEditor *editor)
-{
- EphyNode *bookmarks;
-
- if (node == NULL)
- {
- bookmarks = ephy_bookmarks_get_bookmarks (editor->bookmarks);
- ephy_node_view_select_node (EPHY_NODE_VIEW (editor->key_view), bookmarks);
- }
- else
- {
- gtk_entry_set_text (GTK_ENTRY (editor->search_entry), "");
- bookmarks_filter (editor, node);
- }
+keyword_node_selected_cb (EphyNodeView *view,
+ EphyNode *node,
+ EphyBookmarksEditor *editor)
+{
+ EphyNode *bookmarks;
+
+ if (node == NULL) {
+ bookmarks = ephy_bookmarks_get_bookmarks (editor->bookmarks);
+ ephy_node_view_select_node (EPHY_NODE_VIEW (editor->key_view), bookmarks);
+ } else {
+ gtk_entry_set_text (GTK_ENTRY (editor->search_entry), "");
+ bookmarks_filter (editor, node);
+ }
}
static gboolean
keyword_node_show_popup_cb (GtkWidget *view, EphyBookmarksEditor *editor)
{
- GtkWidget *widget;
+ GtkWidget *widget;
- widget = gtk_ui_manager_get_widget (editor->ui_merge,
- "/EphyBookmarkKeywordPopup");
- ephy_node_view_popup (EPHY_NODE_VIEW (view), widget);
+ widget = gtk_ui_manager_get_widget (editor->ui_merge,
+ "/EphyBookmarkKeywordPopup");
+ ephy_node_view_popup (EPHY_NODE_VIEW (view), widget);
- return TRUE;
+ return TRUE;
}
static void
search_entry_changed_cb (GtkWidget *entry, EphyBookmarksEditor *editor)
{
- EphyNode *all;
- const char *search_text;
-
- g_signal_handlers_block_by_func
- (G_OBJECT (editor->key_view),
- G_CALLBACK (keyword_node_selected_cb),
- editor);
- all = ephy_bookmarks_get_bookmarks (editor->bookmarks);
- ephy_node_view_select_node (EPHY_NODE_VIEW (editor->key_view),
- all);
- g_signal_handlers_unblock_by_func
- (G_OBJECT (editor->key_view),
- G_CALLBACK (keyword_node_selected_cb),
- editor);
-
- search_text = gtk_entry_get_text (GTK_ENTRY (entry));
-
- ephy_node_filter_empty (editor->bookmarks_filter);
- ephy_node_filter_add_expression (editor->bookmarks_filter,
- ephy_node_filter_expression_new
(EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_CONTAINS,
- EPHY_NODE_BMK_PROP_TITLE,
- search_text),
- 0);
- ephy_node_filter_add_expression (editor->bookmarks_filter,
- ephy_node_filter_expression_new
(EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_CONTAINS,
- EPHY_NODE_BMK_PROP_LOCATION,
- search_text),
- 0);
- ephy_node_filter_add_expression (editor->bookmarks_filter,
- ephy_node_filter_expression_new
(EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_CONTAINS,
- EPHY_NODE_BMK_PROP_KEYWORDS,
- search_text),
- 0);
- ephy_node_filter_done_changing (editor->bookmarks_filter);
+ EphyNode *all;
+ const char *search_text;
+
+ g_signal_handlers_block_by_func
+ (G_OBJECT (editor->key_view),
+ G_CALLBACK (keyword_node_selected_cb),
+ editor);
+ all = ephy_bookmarks_get_bookmarks (editor->bookmarks);
+ ephy_node_view_select_node (EPHY_NODE_VIEW (editor->key_view),
+ all);
+ g_signal_handlers_unblock_by_func
+ (G_OBJECT (editor->key_view),
+ G_CALLBACK (keyword_node_selected_cb),
+ editor);
+
+ search_text = gtk_entry_get_text (GTK_ENTRY (entry));
+
+ ephy_node_filter_empty (editor->bookmarks_filter);
+ ephy_node_filter_add_expression (editor->bookmarks_filter,
+ ephy_node_filter_expression_new
(EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_CONTAINS,
+ EPHY_NODE_BMK_PROP_TITLE,
+ search_text),
+ 0);
+ ephy_node_filter_add_expression (editor->bookmarks_filter,
+ ephy_node_filter_expression_new
(EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_CONTAINS,
+ EPHY_NODE_BMK_PROP_LOCATION,
+ search_text),
+ 0);
+ ephy_node_filter_add_expression (editor->bookmarks_filter,
+ ephy_node_filter_expression_new
(EPHY_NODE_FILTER_EXPRESSION_STRING_PROP_CONTAINS,
+ EPHY_NODE_BMK_PROP_KEYWORDS,
+ search_text),
+ 0);
+ ephy_node_filter_done_changing (editor->bookmarks_filter);
}
static GtkWidget *
build_search_box (EphyBookmarksEditor *editor)
{
- GtkWidget *box;
- GtkWidget *entry;
-
- box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_container_set_border_width (GTK_CONTAINER (box), 6);
- gtk_widget_show (box);
-
- entry = gtk_search_entry_new ();
- editor->search_entry = entry;
-
- g_signal_connect (G_OBJECT (entry), "changed",
- G_CALLBACK (search_entry_changed_cb),
- editor);
- add_entry_monitor (editor, entry);
- add_focus_monitor (editor, entry);
-
- gtk_widget_show_all (entry);
-
- gtk_box_pack_start (GTK_BOX (box),
- entry, TRUE, TRUE, 0);
-
- return box;
+ GtkWidget *box;
+ GtkWidget *entry;
+
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ gtk_container_set_border_width (GTK_CONTAINER (box), 6);
+ gtk_widget_show (box);
+
+ entry = gtk_search_entry_new ();
+ editor->search_entry = entry;
+
+ g_signal_connect (G_OBJECT (entry), "changed",
+ G_CALLBACK (search_entry_changed_cb),
+ editor);
+ add_entry_monitor (editor, entry);
+ add_focus_monitor (editor, entry);
+
+ gtk_widget_show_all (entry);
+
+ gtk_box_pack_start (GTK_BOX (box),
+ entry, TRUE, TRUE, 0);
+
+ return box;
}
static void
add_widget (GtkUIManager *merge, GtkWidget *widget, EphyBookmarksEditor *editor)
{
- gtk_box_pack_start (GTK_BOX (editor->main_vbox),
- widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
+ gtk_box_pack_start (GTK_BOX (editor->main_vbox),
+ widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
}
static gboolean
delete_event_cb (EphyBookmarksEditor *editor)
{
- gtk_widget_hide (GTK_WIDGET (editor));
+ gtk_widget_hide (GTK_WIDGET (editor));
- return TRUE;
+ return TRUE;
}
static void
-node_dropped_cb (EphyNodeView *view,
- EphyNode *node,
- const char * const *uris,
- EphyBookmarksEditor *editor)
+node_dropped_cb (EphyNodeView *view,
+ EphyNode *node,
+ const char * const *uris,
+ EphyBookmarksEditor *editor)
{
- EphyNode *bmk;
- int i;
+ EphyNode *bmk;
+ int i;
- g_return_if_fail (uris != NULL);
+ g_return_if_fail (uris != NULL);
- for (i = 0; uris[i] != NULL; i++)
- {
- bmk = ephy_bookmarks_find_bookmark (editor->bookmarks, uris[i]);
+ for (i = 0; uris[i] != NULL; i++) {
+ bmk = ephy_bookmarks_find_bookmark (editor->bookmarks, uris[i]);
- if (bmk != NULL)
- {
- ephy_bookmarks_set_keyword (editor->bookmarks, node, bmk);
- }
- }
+ if (bmk != NULL) {
+ ephy_bookmarks_set_keyword (editor->bookmarks, node, bmk);
+ }
+ }
}
/* TODO: Favicons */
@@ -1451,346 +1368,342 @@ node_dropped_cb (EphyNodeView *view,
static void
provide_favicon (EphyNode *node, GValue *value, gpointer user_data)
{
- GdkPixbuf *favicon = NULL;
+ GdkPixbuf *favicon = NULL;
- /* TODO: Favicons */
- g_value_init (value, GDK_TYPE_PIXBUF);
- g_value_take_object (value, favicon);
+ /* TODO: Favicons */
+ g_value_init (value, GDK_TYPE_PIXBUF);
+ g_value_take_object (value, favicon);
}
static void
view_selection_changed_cb (GtkWidget *view, EphyBookmarksEditor *editor)
{
- ephy_bookmarks_editor_update_menu (editor);
+ ephy_bookmarks_editor_update_menu (editor);
}
static void
provide_keyword_uri (EphyNode *node, GValue *value, gpointer data)
{
- EphyBookmarks *bookmarks = EPHY_BOOKMARKS_EDITOR (data)->bookmarks;
- char *uri;
+ EphyBookmarks *bookmarks = EPHY_BOOKMARKS_EDITOR (data)->bookmarks;
+ char *uri;
- uri = ephy_bookmarks_get_topic_uri (bookmarks, node);
+ uri = ephy_bookmarks_get_topic_uri (bookmarks, node);
- g_value_init (value, G_TYPE_STRING);
- g_value_set_string (value, uri);
- g_free (uri);
+ g_value_init (value, G_TYPE_STRING);
+ g_value_set_string (value, uri);
+ g_free (uri);
}
static void
decode_bookmark_uri (EphyNode *node,
- GValue *value,
- gpointer user_data)
+ GValue *value,
+ gpointer user_data)
{
- const char *url = g_value_get_string (value);
- g_value_take_string (value, ephy_uri_decode (url));
+ const char *url = g_value_get_string (value);
+ g_value_take_string (value, ephy_uri_decode (url));
}
static void
ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
{
- GtkTreeSelection *selection;
- GtkWidget *hpaned, *vbox;
- GtkWidget *bm_view, *key_view;
- GtkWidget *scrolled_window;
- EphyNode *node;
- GtkUIManager *ui_merge;
- GtkActionGroup *action_group;
- GtkAction *action;
- int col_id, url_col_id, title_col_id;
-
- ephy_gui_ensure_window_group (GTK_WINDOW (editor));
-
- gtk_window_set_title (GTK_WINDOW (editor), _("Bookmarks"));
-
- g_signal_connect (editor, "delete_event",
- G_CALLBACK (delete_event_cb), NULL);
-
- editor->main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_widget_show (editor->main_vbox);
- gtk_container_add (GTK_CONTAINER (editor), editor->main_vbox);
-
- ui_merge = gtk_ui_manager_new ();
- g_signal_connect (ui_merge, "add_widget", G_CALLBACK (add_widget), editor);
- action_group = gtk_action_group_new ("PopupActions");
- gtk_action_group_set_translation_domain (action_group, NULL);
- gtk_action_group_add_actions (action_group, ephy_bookmark_popup_entries,
- G_N_ELEMENTS (ephy_bookmark_popup_entries), editor);
- gtk_action_group_add_toggle_actions (action_group, ephy_bookmark_toggle_entries,
- G_N_ELEMENTS (ephy_bookmark_toggle_entries), editor);
-
- gtk_ui_manager_insert_action_group (ui_merge,
- action_group, 0);
- gtk_ui_manager_add_ui_from_resource (ui_merge,
- "/org/gnome/epiphany/epiphany-bookmark-editor-ui.xml",
- NULL);
- gtk_window_add_accel_group (GTK_WINDOW (editor),
- gtk_ui_manager_get_accel_group (ui_merge));
- gtk_ui_manager_ensure_update (ui_merge);
-
- editor->ui_merge = ui_merge;
- editor->action_group = action_group;
-
- hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
- gtk_container_set_border_width (GTK_CONTAINER (hpaned), 0);
- gtk_box_pack_end (GTK_BOX (editor->main_vbox), hpaned,
- TRUE, TRUE, 0);
- gtk_widget_show (hpaned);
-
- g_assert (editor->bookmarks);
-
- node = ephy_bookmarks_get_keywords (editor->bookmarks);
-
- scrolled_window = g_object_new (GTK_TYPE_SCROLLED_WINDOW,
- "hadjustment", NULL,
- "vadjustment", NULL,
- "hscrollbar_policy", GTK_POLICY_AUTOMATIC,
- "vscrollbar_policy", GTK_POLICY_AUTOMATIC,
- "shadow_type", GTK_SHADOW_IN,
- NULL);
- gtk_paned_pack1 (GTK_PANED (hpaned), GTK_WIDGET (scrolled_window), FALSE, TRUE);
- gtk_widget_show (scrolled_window);
-
- /* Keywords View */
- key_view = ephy_node_view_new (node, NULL);
- add_focus_monitor (editor, key_view);
- col_id = ephy_node_view_add_data_column (EPHY_NODE_VIEW (key_view),
- G_TYPE_STRING, -1,
- provide_keyword_uri, editor);
- ephy_node_view_add_column (EPHY_NODE_VIEW (key_view), _("Topics"),
- G_TYPE_STRING,
- EPHY_NODE_KEYWORD_PROP_NAME,
- EPHY_NODE_VIEW_SHOW_PRIORITY |
- EPHY_NODE_VIEW_EDITABLE |
- EPHY_NODE_VIEW_SEARCHABLE, NULL, NULL);
- ephy_node_view_enable_drag_source (EPHY_NODE_VIEW (key_view),
- topic_drag_types,
- G_N_ELEMENTS (topic_drag_types),
- col_id, -1);
- ephy_node_view_enable_drag_dest (EPHY_NODE_VIEW (key_view),
- topic_drag_dest_types,
- G_N_ELEMENTS (topic_drag_dest_types));
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (key_view));
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
- g_signal_connect (G_OBJECT (selection),
- "changed",
- G_CALLBACK (view_selection_changed_cb),
- editor);
- ephy_node_view_set_priority (EPHY_NODE_VIEW (key_view),
- (EphyNodeViewPriority)EPHY_NODE_KEYWORD_PROP_PRIORITY);
- ephy_node_view_set_sort (EPHY_NODE_VIEW (key_view), G_TYPE_STRING,
- EPHY_NODE_KEYWORD_PROP_NAME, GTK_SORT_ASCENDING);
- gtk_container_add (GTK_CONTAINER (scrolled_window), key_view);
- gtk_widget_set_size_request (key_view, 130, -1);
- gtk_widget_show (key_view);
- editor->key_view = key_view;
- g_signal_connect (G_OBJECT (key_view),
- "key_press_event",
- G_CALLBACK (key_pressed_cb),
- editor);
- g_signal_connect (G_OBJECT (key_view),
- "node_selected",
- G_CALLBACK (keyword_node_selected_cb),
- editor);
- g_signal_connect (G_OBJECT (key_view),
- "node_dropped",
- G_CALLBACK (node_dropped_cb),
- editor);
- g_signal_connect (G_OBJECT (key_view),
- "popup_menu",
- G_CALLBACK (keyword_node_show_popup_cb),
- editor);
-
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_paned_pack2 (GTK_PANED (hpaned), vbox, TRUE, TRUE);
- gtk_widget_show (vbox);
-
- gtk_box_pack_start (GTK_BOX (editor->main_vbox),
- build_search_box (editor),
- FALSE, FALSE, 0);
- add_focus_monitor (editor, editor->search_entry);
-
- scrolled_window = g_object_new (GTK_TYPE_SCROLLED_WINDOW,
- "hadjustment", NULL,
- "vadjustment", NULL,
- "hscrollbar_policy", GTK_POLICY_AUTOMATIC,
- "vscrollbar_policy", GTK_POLICY_AUTOMATIC,
- "shadow_type", GTK_SHADOW_IN,
- NULL);
- gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0);
- gtk_widget_show (scrolled_window);
-
- node = ephy_bookmarks_get_bookmarks (editor->bookmarks);
- editor->bookmarks_filter = ephy_node_filter_new ();
-
- /* Bookmarks View */
- bm_view = ephy_node_view_new (node, editor->bookmarks_filter);
- add_focus_monitor (editor, bm_view);
- title_col_id = ephy_node_view_add_column
- (EPHY_NODE_VIEW (bm_view), _("Title"),
- G_TYPE_STRING, EPHY_NODE_BMK_PROP_TITLE,
- EPHY_NODE_VIEW_EDITABLE |
- EPHY_NODE_VIEW_SEARCHABLE |
- EPHY_NODE_VIEW_SORTABLE |
- EPHY_NODE_VIEW_ELLIPSIZED,
- provide_favicon, &(editor->title_col));
- gtk_tree_view_column_set_min_width (editor->title_col, 300);
- gtk_tree_view_column_set_resizable (editor->title_col, TRUE);
-
- url_col_id = ephy_node_view_add_column_full
- (EPHY_NODE_VIEW (bm_view), _("Address"),
- G_TYPE_STRING, EPHY_NODE_BMK_PROP_LOCATION,
- EPHY_NODE_VIEW_SORTABLE |
- EPHY_NODE_VIEW_ELLIPSIZED,
- decode_bookmark_uri, NULL,
- NULL, &(editor->address_col));
- gtk_tree_view_column_set_min_width (editor->address_col, 300);
- gtk_tree_view_column_set_resizable (editor->address_col, TRUE);
-
- ephy_node_view_enable_drag_source (EPHY_NODE_VIEW (bm_view),
- bmk_drag_types,
- G_N_ELEMENTS (bmk_drag_types),
- url_col_id, title_col_id);
- ephy_node_view_set_sort (EPHY_NODE_VIEW (bm_view), G_TYPE_STRING,
- EPHY_NODE_BMK_PROP_TITLE, GTK_SORT_ASCENDING);
- gtk_container_add (GTK_CONTAINER (scrolled_window), bm_view);
- gtk_widget_show (bm_view);
- editor->bm_view = bm_view;
-
- action = gtk_action_group_get_action (action_group, "ViewTitle");
- g_settings_bind (EPHY_SETTINGS_STATE,
- EPHY_PREFS_STATE_BOOKMARKS_VIEW_TITLE,
- action, "active",
- G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (EPHY_SETTINGS_STATE,
- EPHY_PREFS_STATE_BOOKMARKS_VIEW_TITLE,
- editor->title_col, "visible",
- G_SETTINGS_BIND_DEFAULT);
-
- action = gtk_action_group_get_action (action_group, "ViewAddress");
- g_settings_bind (EPHY_SETTINGS_STATE,
- EPHY_PREFS_STATE_BOOKMARKS_VIEW_ADDRESS,
- action, "active",
- G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (EPHY_SETTINGS_STATE,
- EPHY_PREFS_STATE_BOOKMARKS_VIEW_ADDRESS,
- editor->address_col, "visible",
- G_SETTINGS_BIND_DEFAULT);
-
- g_signal_connect (G_OBJECT (bm_view),
- "key_press_event",
- G_CALLBACK (key_pressed_cb),
- editor);
- g_signal_connect (G_OBJECT (bm_view),
- "node_activated",
- G_CALLBACK (ephy_bookmarks_editor_node_activated_cb),
- editor);
- g_signal_connect (G_OBJECT (bm_view),
- "node_middle_clicked",
- G_CALLBACK (ephy_bookmarks_editor_node_middle_clicked_cb),
- editor);
- g_signal_connect (G_OBJECT (bm_view),
- "popup_menu",
- G_CALLBACK (ephy_bookmarks_editor_show_popup_cb),
- editor);
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (bm_view));
- g_signal_connect (G_OBJECT (selection),
- "changed",
- G_CALLBACK (view_selection_changed_cb),
- editor);
-
- ephy_initial_state_add_window (GTK_WIDGET(editor),
- "bookmarks_editor",
- 450, 400, FALSE,
- EPHY_INITIAL_STATE_WINDOW_SAVE_SIZE |
EPHY_INITIAL_STATE_WINDOW_SAVE_POSITION);
- ephy_initial_state_add_paned (GTK_WIDGET (hpaned),
- "bookmarks_paned",
- 130);
-
- /* Lockdown settings */
- action = gtk_action_group_get_action (action_group, "Export");
- gtk_action_set_sensitive (action,
- g_settings_get_boolean
- (EPHY_SETTINGS_LOCKDOWN,
- EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK) == FALSE);
+ GtkTreeSelection *selection;
+ GtkWidget *hpaned, *vbox;
+ GtkWidget *bm_view, *key_view;
+ GtkWidget *scrolled_window;
+ EphyNode *node;
+ GtkUIManager *ui_merge;
+ GtkActionGroup *action_group;
+ GtkAction *action;
+ int col_id, url_col_id, title_col_id;
+
+ ephy_gui_ensure_window_group (GTK_WINDOW (editor));
+
+ gtk_window_set_title (GTK_WINDOW (editor), _("Bookmarks"));
+
+ g_signal_connect (editor, "delete_event",
+ G_CALLBACK (delete_event_cb), NULL);
+
+ editor->main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ gtk_widget_show (editor->main_vbox);
+ gtk_container_add (GTK_CONTAINER (editor), editor->main_vbox);
+
+ ui_merge = gtk_ui_manager_new ();
+ g_signal_connect (ui_merge, "add_widget", G_CALLBACK (add_widget), editor);
+ action_group = gtk_action_group_new ("PopupActions");
+ gtk_action_group_set_translation_domain (action_group, NULL);
+ gtk_action_group_add_actions (action_group, ephy_bookmark_popup_entries,
+ G_N_ELEMENTS (ephy_bookmark_popup_entries), editor);
+ gtk_action_group_add_toggle_actions (action_group, ephy_bookmark_toggle_entries,
+ G_N_ELEMENTS (ephy_bookmark_toggle_entries), editor);
+
+ gtk_ui_manager_insert_action_group (ui_merge,
+ action_group, 0);
+ gtk_ui_manager_add_ui_from_resource (ui_merge,
+ "/org/gnome/epiphany/epiphany-bookmark-editor-ui.xml",
+ NULL);
+ gtk_window_add_accel_group (GTK_WINDOW (editor),
+ gtk_ui_manager_get_accel_group (ui_merge));
+ gtk_ui_manager_ensure_update (ui_merge);
+
+ editor->ui_merge = ui_merge;
+ editor->action_group = action_group;
+
+ hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
+ gtk_container_set_border_width (GTK_CONTAINER (hpaned), 0);
+ gtk_box_pack_end (GTK_BOX (editor->main_vbox), hpaned,
+ TRUE, TRUE, 0);
+ gtk_widget_show (hpaned);
+
+ g_assert (editor->bookmarks);
+
+ node = ephy_bookmarks_get_keywords (editor->bookmarks);
+
+ scrolled_window = g_object_new (GTK_TYPE_SCROLLED_WINDOW,
+ "hadjustment", NULL,
+ "vadjustment", NULL,
+ "hscrollbar_policy", GTK_POLICY_AUTOMATIC,
+ "vscrollbar_policy", GTK_POLICY_AUTOMATIC,
+ "shadow_type", GTK_SHADOW_IN,
+ NULL);
+ gtk_paned_pack1 (GTK_PANED (hpaned), GTK_WIDGET (scrolled_window), FALSE, TRUE);
+ gtk_widget_show (scrolled_window);
+
+ /* Keywords View */
+ key_view = ephy_node_view_new (node, NULL);
+ add_focus_monitor (editor, key_view);
+ col_id = ephy_node_view_add_data_column (EPHY_NODE_VIEW (key_view),
+ G_TYPE_STRING, -1,
+ provide_keyword_uri, editor);
+ ephy_node_view_add_column (EPHY_NODE_VIEW (key_view), _("Topics"),
+ G_TYPE_STRING,
+ EPHY_NODE_KEYWORD_PROP_NAME,
+ EPHY_NODE_VIEW_SHOW_PRIORITY |
+ EPHY_NODE_VIEW_EDITABLE |
+ EPHY_NODE_VIEW_SEARCHABLE, NULL, NULL);
+ ephy_node_view_enable_drag_source (EPHY_NODE_VIEW (key_view),
+ topic_drag_types,
+ G_N_ELEMENTS (topic_drag_types),
+ col_id, -1);
+ ephy_node_view_enable_drag_dest (EPHY_NODE_VIEW (key_view),
+ topic_drag_dest_types,
+ G_N_ELEMENTS (topic_drag_dest_types));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (key_view));
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
+ g_signal_connect (G_OBJECT (selection),
+ "changed",
+ G_CALLBACK (view_selection_changed_cb),
+ editor);
+ ephy_node_view_set_priority (EPHY_NODE_VIEW (key_view),
+ (EphyNodeViewPriority)EPHY_NODE_KEYWORD_PROP_PRIORITY);
+ ephy_node_view_set_sort (EPHY_NODE_VIEW (key_view), G_TYPE_STRING,
+ EPHY_NODE_KEYWORD_PROP_NAME, GTK_SORT_ASCENDING);
+ gtk_container_add (GTK_CONTAINER (scrolled_window), key_view);
+ gtk_widget_set_size_request (key_view, 130, -1);
+ gtk_widget_show (key_view);
+ editor->key_view = key_view;
+ g_signal_connect (G_OBJECT (key_view),
+ "key_press_event",
+ G_CALLBACK (key_pressed_cb),
+ editor);
+ g_signal_connect (G_OBJECT (key_view),
+ "node_selected",
+ G_CALLBACK (keyword_node_selected_cb),
+ editor);
+ g_signal_connect (G_OBJECT (key_view),
+ "node_dropped",
+ G_CALLBACK (node_dropped_cb),
+ editor);
+ g_signal_connect (G_OBJECT (key_view),
+ "popup_menu",
+ G_CALLBACK (keyword_node_show_popup_cb),
+ editor);
+
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ gtk_paned_pack2 (GTK_PANED (hpaned), vbox, TRUE, TRUE);
+ gtk_widget_show (vbox);
+
+ gtk_box_pack_start (GTK_BOX (editor->main_vbox),
+ build_search_box (editor),
+ FALSE, FALSE, 0);
+ add_focus_monitor (editor, editor->search_entry);
+
+ scrolled_window = g_object_new (GTK_TYPE_SCROLLED_WINDOW,
+ "hadjustment", NULL,
+ "vadjustment", NULL,
+ "hscrollbar_policy", GTK_POLICY_AUTOMATIC,
+ "vscrollbar_policy", GTK_POLICY_AUTOMATIC,
+ "shadow_type", GTK_SHADOW_IN,
+ NULL);
+ gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0);
+ gtk_widget_show (scrolled_window);
+
+ node = ephy_bookmarks_get_bookmarks (editor->bookmarks);
+ editor->bookmarks_filter = ephy_node_filter_new ();
+
+ /* Bookmarks View */
+ bm_view = ephy_node_view_new (node, editor->bookmarks_filter);
+ add_focus_monitor (editor, bm_view);
+ title_col_id = ephy_node_view_add_column
+ (EPHY_NODE_VIEW (bm_view), _("Title"),
+ G_TYPE_STRING, EPHY_NODE_BMK_PROP_TITLE,
+ EPHY_NODE_VIEW_EDITABLE |
+ EPHY_NODE_VIEW_SEARCHABLE |
+ EPHY_NODE_VIEW_SORTABLE |
+ EPHY_NODE_VIEW_ELLIPSIZED,
+ provide_favicon, &(editor->title_col));
+ gtk_tree_view_column_set_min_width (editor->title_col, 300);
+ gtk_tree_view_column_set_resizable (editor->title_col, TRUE);
+
+ url_col_id = ephy_node_view_add_column_full
+ (EPHY_NODE_VIEW (bm_view), _("Address"),
+ G_TYPE_STRING, EPHY_NODE_BMK_PROP_LOCATION,
+ EPHY_NODE_VIEW_SORTABLE |
+ EPHY_NODE_VIEW_ELLIPSIZED,
+ decode_bookmark_uri, NULL,
+ NULL, &(editor->address_col));
+ gtk_tree_view_column_set_min_width (editor->address_col, 300);
+ gtk_tree_view_column_set_resizable (editor->address_col, TRUE);
+
+ ephy_node_view_enable_drag_source (EPHY_NODE_VIEW (bm_view),
+ bmk_drag_types,
+ G_N_ELEMENTS (bmk_drag_types),
+ url_col_id, title_col_id);
+ ephy_node_view_set_sort (EPHY_NODE_VIEW (bm_view), G_TYPE_STRING,
+ EPHY_NODE_BMK_PROP_TITLE, GTK_SORT_ASCENDING);
+ gtk_container_add (GTK_CONTAINER (scrolled_window), bm_view);
+ gtk_widget_show (bm_view);
+ editor->bm_view = bm_view;
+
+ action = gtk_action_group_get_action (action_group, "ViewTitle");
+ g_settings_bind (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_BOOKMARKS_VIEW_TITLE,
+ action, "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_BOOKMARKS_VIEW_TITLE,
+ editor->title_col, "visible",
+ G_SETTINGS_BIND_DEFAULT);
+
+ action = gtk_action_group_get_action (action_group, "ViewAddress");
+ g_settings_bind (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_BOOKMARKS_VIEW_ADDRESS,
+ action, "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_BOOKMARKS_VIEW_ADDRESS,
+ editor->address_col, "visible",
+ G_SETTINGS_BIND_DEFAULT);
+
+ g_signal_connect (G_OBJECT (bm_view),
+ "key_press_event",
+ G_CALLBACK (key_pressed_cb),
+ editor);
+ g_signal_connect (G_OBJECT (bm_view),
+ "node_activated",
+ G_CALLBACK (ephy_bookmarks_editor_node_activated_cb),
+ editor);
+ g_signal_connect (G_OBJECT (bm_view),
+ "node_middle_clicked",
+ G_CALLBACK (ephy_bookmarks_editor_node_middle_clicked_cb),
+ editor);
+ g_signal_connect (G_OBJECT (bm_view),
+ "popup_menu",
+ G_CALLBACK (ephy_bookmarks_editor_show_popup_cb),
+ editor);
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (bm_view));
+ g_signal_connect (G_OBJECT (selection),
+ "changed",
+ G_CALLBACK (view_selection_changed_cb),
+ editor);
+
+ ephy_initial_state_add_window (GTK_WIDGET (editor),
+ "bookmarks_editor",
+ 450, 400, FALSE,
+ EPHY_INITIAL_STATE_WINDOW_SAVE_SIZE |
EPHY_INITIAL_STATE_WINDOW_SAVE_POSITION);
+ ephy_initial_state_add_paned (GTK_WIDGET (hpaned),
+ "bookmarks_paned",
+ 130);
+
+ /* Lockdown settings */
+ action = gtk_action_group_get_action (action_group, "Export");
+ gtk_action_set_sensitive (action,
+ g_settings_get_boolean
+ (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK) == FALSE);
}
void
ephy_bookmarks_editor_set_parent (EphyBookmarksEditor *ebe,
- GtkWidget *window)
-{
- GtkWidget **w;
- if (ebe->window)
- {
- w = &ebe->window;
- g_object_remove_weak_pointer
- (G_OBJECT(ebe->window),
- (gpointer *)w);
- }
-
- ebe->window = window;
- w = &ebe->window;
-
- g_object_add_weak_pointer
- (G_OBJECT(ebe->window),
- (gpointer *)w);
-
+ GtkWidget *window)
+{
+ GtkWidget **w;
+ if (ebe->window) {
+ w = &ebe->window;
+ g_object_remove_weak_pointer
+ (G_OBJECT (ebe->window),
+ (gpointer *)w);
+ }
+
+ ebe->window = window;
+ w = &ebe->window;
+
+ g_object_add_weak_pointer
+ (G_OBJECT (ebe->window),
+ (gpointer *)w);
}
GtkWidget *
ephy_bookmarks_editor_new (EphyBookmarks *bookmarks)
{
- EphyBookmarksEditor *editor;
+ EphyBookmarksEditor *editor;
- g_assert (bookmarks != NULL);
+ g_assert (bookmarks != NULL);
- editor = EPHY_BOOKMARKS_EDITOR (g_object_new
- (EPHY_TYPE_BOOKMARKS_EDITOR,
- "bookmarks", bookmarks,
- NULL));
+ editor = EPHY_BOOKMARKS_EDITOR (g_object_new
+ (EPHY_TYPE_BOOKMARKS_EDITOR,
+ "bookmarks", bookmarks,
+ NULL));
- ephy_bookmarks_editor_construct (editor);
+ ephy_bookmarks_editor_construct (editor);
- return GTK_WIDGET (editor);
+ return GTK_WIDGET (editor);
}
static void
-ephy_bookmarks_editor_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EphyBookmarksEditor *editor = EPHY_BOOKMARKS_EDITOR (object);
-
- switch (prop_id)
- {
- case PROP_BOOKMARKS:
- editor->bookmarks = g_value_get_object (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ephy_bookmarks_editor_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EphyBookmarksEditor *editor = EPHY_BOOKMARKS_EDITOR (object);
+
+ switch (prop_id) {
+ case PROP_BOOKMARKS:
+ editor->bookmarks = g_value_get_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-ephy_bookmarks_editor_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EphyBookmarksEditor *editor = EPHY_BOOKMARKS_EDITOR (object);
-
- switch (prop_id)
- {
- case PROP_BOOKMARKS:
- g_value_set_object (value, editor->bookmarks);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ephy_bookmarks_editor_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EphyBookmarksEditor *editor = EPHY_BOOKMARKS_EDITOR (object);
+
+ switch (prop_id) {
+ case PROP_BOOKMARKS:
+ g_value_set_object (value, editor->bookmarks);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
diff --git a/src/bookmarks/ephy-bookmarks-export.c b/src/bookmarks/ephy-bookmarks-export.c
index e8dd982..8dd6c44 100644
--- a/src/bookmarks/ephy-bookmarks-export.c
+++ b/src/bookmarks/ephy-bookmarks-export.c
@@ -34,475 +34,458 @@
static inline xmlChar *
sanitise_string (const xmlChar *string)
{
- xmlChar *copy, *p;
-
- if (!string)
- return xmlStrdup ((const xmlChar *) "");
-
- /* http://www.w3.org/TR/REC-xml/#sec-well-formed :
- Character Range
- [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] |
- [#xE000-#xFFFD] | [#x10000-#x10FFFF]
- any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
- */
-
- copy = xmlStrdup (string);
- for (p = copy; *p; p++)
- {
- xmlChar c = *p;
- if (G_UNLIKELY (c < 0x20 && c != 0xd && c != 0xa && c != 0x9)) {
- *p = 0x20;
- }
- }
-
- return copy;
+ xmlChar *copy, *p;
+
+ if (!string)
+ return xmlStrdup ((const xmlChar *)"");
+
+ /* http://www.w3.org/TR/REC-xml/#sec-well-formed :
+ Character Range
+ [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] |
+ [#xE000-#xFFFD] | [#x10000-#x10FFFF]
+ any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
+ */
+
+ copy = xmlStrdup (string);
+ for (p = copy; *p; p++) {
+ xmlChar c = *p;
+ if (G_UNLIKELY (c < 0x20 && c != 0xd && c != 0xa && c != 0x9)) {
+ *p = 0x20;
+ }
+ }
+
+ return copy;
}
static int
-write_topics_list (EphyNode *topics,
- EphyNode *bmk,
- xmlTextWriterPtr writer)
+write_topics_list (EphyNode *topics,
+ EphyNode *bmk,
+ xmlTextWriterPtr writer)
{
- GPtrArray *children;
- GList *keywords = NULL, *l;
- guint i;
- int ret = 0;
-
- children = ephy_node_get_children (topics);
- for (i = 0; i < children->len; i++)
- {
- EphyNode *kid;
- int priority;
-
- kid = g_ptr_array_index (children, i);
-
- priority = ephy_node_get_property_int (kid, EPHY_NODE_KEYWORD_PROP_PRIORITY);
- if (priority == -1) priority = EPHY_NODE_NORMAL_PRIORITY;
-
- if (priority == EPHY_NODE_NORMAL_PRIORITY &&
- ephy_node_has_child (kid, bmk))
- {
- keywords = g_list_prepend (keywords, kid);
- }
- }
-
- for (l = keywords; l != NULL; l = l->next)
- {
- EphyNode *node = l->data;
- const char *name;
- xmlChar *safeName;
-
- name = ephy_node_get_property_string
- (node, EPHY_NODE_KEYWORD_PROP_NAME);
- safeName = sanitise_string ((const xmlChar *) name);
-
- ret = xmlTextWriterWriteElementNS
- (writer,
- (xmlChar *) "dc",
- (xmlChar *) "subject",
- NULL,
- safeName);
- xmlFree (safeName);
-
- if (ret < 0) break;
- }
-
- g_list_free (keywords);
-
- return ret >= 0 ? 0 : -1;
+ GPtrArray *children;
+ GList *keywords = NULL, *l;
+ guint i;
+ int ret = 0;
+
+ children = ephy_node_get_children (topics);
+ for (i = 0; i < children->len; i++) {
+ EphyNode *kid;
+ int priority;
+
+ kid = g_ptr_array_index (children, i);
+
+ priority = ephy_node_get_property_int (kid, EPHY_NODE_KEYWORD_PROP_PRIORITY);
+ if (priority == -1) priority = EPHY_NODE_NORMAL_PRIORITY;
+
+ if (priority == EPHY_NODE_NORMAL_PRIORITY &&
+ ephy_node_has_child (kid, bmk)) {
+ keywords = g_list_prepend (keywords, kid);
+ }
+ }
+
+ for (l = keywords; l != NULL; l = l->next) {
+ EphyNode *node = l->data;
+ const char *name;
+ xmlChar *safeName;
+
+ name = ephy_node_get_property_string
+ (node, EPHY_NODE_KEYWORD_PROP_NAME);
+ safeName = sanitise_string ((const xmlChar *)name);
+
+ ret = xmlTextWriterWriteElementNS
+ (writer,
+ (xmlChar *)"dc",
+ (xmlChar *)"subject",
+ NULL,
+ safeName);
+ xmlFree (safeName);
+
+ if (ret < 0) break;
+ }
+
+ g_list_free (keywords);
+
+ return ret >= 0 ? 0 : -1;
}
static int
-write_rdf (EphyBookmarks *bookmarks,
- GFile *file,
- xmlTextWriterPtr writer)
+write_rdf (EphyBookmarks *bookmarks,
+ GFile *file,
+ xmlTextWriterPtr writer)
{
- EphyNode *bmks, *topics, *smart_bmks;
- GPtrArray *children;
- char *file_uri;
- guint i;
- gint ret;
- xmlChar *safeString;
+ EphyNode *bmks, *topics, *smart_bmks;
+ GPtrArray *children;
+ char *file_uri;
+ guint i;
+ gint ret;
+ xmlChar *safeString;
#ifdef ENABLE_ZEROCONF
- EphyNode *local;
+ EphyNode *local;
#endif
- START_PROFILER ("Writing RDF")
-
- ret = xmlTextWriterStartDocument (writer, "1.0", NULL, NULL);
- if (ret < 0) goto out;
-
- ret = xmlTextWriterStartElementNS
- (writer,
- (xmlChar *) "rdf",
- (xmlChar *) "RDF",
- (xmlChar *) "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
- if (ret < 0) goto out;
-
- ret = xmlTextWriterWriteAttribute
- (writer,
- (xmlChar *) "xmlns",
- (xmlChar *) "http://purl.org/rss/1.0/");
- if (ret < 0) goto out;
-
- ret = xmlTextWriterWriteAttributeNS
- (writer,
- (xmlChar *) "xmlns",
- (xmlChar *) "dc",
- NULL,
- (xmlChar *) "http://purl.org/dc/elements/1.1/");
- if (ret < 0) goto out;
-
- ret = xmlTextWriterWriteAttributeNS
- (writer,
- (xmlChar *) "xmlns",
- (xmlChar *) "ephy",
- NULL,
- (xmlChar *) "http://gnome.org/ns/epiphany#");
- if (ret < 0) goto out;
-
- ret = xmlTextWriterStartElement (writer, (xmlChar *) "channel");
- if (ret < 0) goto out;
-
- /* FIXME: sanitise file_uri? */
- file_uri = g_file_get_uri (file);
- safeString = sanitise_string ((const xmlChar *) file_uri);
- g_free (file_uri);
-
- ret = xmlTextWriterWriteAttributeNS
- (writer,
- (xmlChar *) "rdf",
- (xmlChar *) "about",
- NULL,
- safeString);
- xmlFree (safeString);
- if (ret < 0) goto out;
-
- ret = xmlTextWriterWriteElement
- (writer,
- (xmlChar *) "title",
- (xmlChar *) "Web bookmarks");
- if (ret < 0) goto out;
-
- ret = xmlTextWriterWriteElement
- (writer,
- (xmlChar *) "link",
- (xmlChar *) "https://wiki.gnome.org/Apps/Web");
- if (ret < 0) goto out;
-
- ret = xmlTextWriterStartElement (writer, (xmlChar *) "items");
- if (ret < 0) goto out;
-
- ret = xmlTextWriterStartElementNS
- (writer,
- (xmlChar *) "rdf",
- (xmlChar *) "Seq",
- NULL);
- if (ret < 0) goto out;
-
- bmks = ephy_bookmarks_get_bookmarks (bookmarks);
- topics = ephy_bookmarks_get_keywords (bookmarks);
- smart_bmks = ephy_bookmarks_get_smart_bookmarks (bookmarks);
+ START_PROFILER ("Writing RDF")
+
+ ret = xmlTextWriterStartDocument (writer, "1.0", NULL, NULL);
+ if (ret < 0) goto out;
+
+ ret = xmlTextWriterStartElementNS
+ (writer,
+ (xmlChar *)"rdf",
+ (xmlChar *)"RDF",
+ (xmlChar *)"http://www.w3.org/1999/02/22-rdf-syntax-ns#");
+ if (ret < 0) goto out;
+
+ ret = xmlTextWriterWriteAttribute
+ (writer,
+ (xmlChar *)"xmlns",
+ (xmlChar *)"http://purl.org/rss/1.0/");
+ if (ret < 0) goto out;
+
+ ret = xmlTextWriterWriteAttributeNS
+ (writer,
+ (xmlChar *)"xmlns",
+ (xmlChar *)"dc",
+ NULL,
+ (xmlChar *)"http://purl.org/dc/elements/1.1/");
+ if (ret < 0) goto out;
+
+ ret = xmlTextWriterWriteAttributeNS
+ (writer,
+ (xmlChar *)"xmlns",
+ (xmlChar *)"ephy",
+ NULL,
+ (xmlChar *)"http://gnome.org/ns/epiphany#");
+ if (ret < 0) goto out;
+
+ ret = xmlTextWriterStartElement (writer, (xmlChar *)"channel");
+ if (ret < 0) goto out;
+
+ /* FIXME: sanitise file_uri? */
+ file_uri = g_file_get_uri (file);
+ safeString = sanitise_string ((const xmlChar *)file_uri);
+ g_free (file_uri);
+
+ ret = xmlTextWriterWriteAttributeNS
+ (writer,
+ (xmlChar *)"rdf",
+ (xmlChar *)"about",
+ NULL,
+ safeString);
+ xmlFree (safeString);
+ if (ret < 0) goto out;
+
+ ret = xmlTextWriterWriteElement
+ (writer,
+ (xmlChar *)"title",
+ (xmlChar *)"Web bookmarks");
+ if (ret < 0) goto out;
+
+ ret = xmlTextWriterWriteElement
+ (writer,
+ (xmlChar *)"link",
+ (xmlChar *)"https://wiki.gnome.org/Apps/Web");
+ if (ret < 0) goto out;
+
+ ret = xmlTextWriterStartElement (writer, (xmlChar *)"items");
+ if (ret < 0) goto out;
+
+ ret = xmlTextWriterStartElementNS
+ (writer,
+ (xmlChar *)"rdf",
+ (xmlChar *)"Seq",
+ NULL);
+ if (ret < 0) goto out;
+
+ bmks = ephy_bookmarks_get_bookmarks (bookmarks);
+ topics = ephy_bookmarks_get_keywords (bookmarks);
+ smart_bmks = ephy_bookmarks_get_smart_bookmarks (bookmarks);
#ifdef ENABLE_ZEROCONF
- local = ephy_bookmarks_get_local (bookmarks);
+ local = ephy_bookmarks_get_local (bookmarks);
#endif
- children = ephy_node_get_children (bmks);
- for (i=0; i < children->len; i++)
- {
- EphyNode *kid;
- const char *url;
- char *link = NULL;
- gboolean smart_url;
- xmlChar *safeLink;
+ children = ephy_node_get_children (bmks);
+ for (i = 0; i < children->len; i++) {
+ EphyNode *kid;
+ const char *url;
+ char *link = NULL;
+ gboolean smart_url;
+ xmlChar *safeLink;
- kid = g_ptr_array_index (children, i);
+ kid = g_ptr_array_index (children, i);
#ifdef ENABLE_ZEROCONF
- /* Don't export the local bookmarks */
- if (ephy_node_has_child (local, kid)) continue;
+ /* Don't export the local bookmarks */
+ if (ephy_node_has_child (local, kid)) continue;
#endif
- smart_url = ephy_node_has_child (smart_bmks, kid);
- url = ephy_node_get_property_string
- (kid, EPHY_NODE_BMK_PROP_LOCATION);
- if (smart_url && url)
- {
- char *scheme;
- char *host_name;
-
- scheme = g_uri_parse_scheme (url);
- host_name = ephy_string_get_host_name (url);
- link = g_strconcat (scheme,
- "://",
- host_name,
- NULL);
-
- g_free (scheme);
- g_free (host_name);
- }
-
- safeLink = sanitise_string (link ? (const xmlChar *) link : (const xmlChar *) url);
- g_free (link);
-
- ret = xmlTextWriterStartElementNS
- (writer,
- (xmlChar *) "rdf",
- (xmlChar *) "li",
- NULL);
- if (ret < 0) break;
-
- ret = xmlTextWriterWriteAttributeNS
- (writer,
- (xmlChar *) "rdf",
- (xmlChar *) "resource",
- NULL,
- safeLink);
- xmlFree (safeLink);
- if (ret < 0) break;
-
- ret = xmlTextWriterEndElement (writer); /* rdf:li */
- if (ret < 0) break;
- }
- if (ret < 0) goto out;
-
- ret = xmlTextWriterEndElement (writer); /* rdf:Seq */
- if (ret < 0) goto out;
-
- ret = xmlTextWriterEndElement (writer); /* items */
- if (ret < 0) goto out;
-
- ret = xmlTextWriterEndElement (writer); /* channel */
- if (ret < 0) goto out;
-
- children = ephy_node_get_children (bmks);
- for (i=0; i < children->len; i++)
- {
- EphyNode *kid;
- const char *url, *title;
- char *link = NULL;
- gboolean smart_url;
- xmlChar *safeLink, *safeTitle;
-
- kid = g_ptr_array_index (children, i);
+ smart_url = ephy_node_has_child (smart_bmks, kid);
+ url = ephy_node_get_property_string
+ (kid, EPHY_NODE_BMK_PROP_LOCATION);
+ if (smart_url && url) {
+ char *scheme;
+ char *host_name;
+
+ scheme = g_uri_parse_scheme (url);
+ host_name = ephy_string_get_host_name (url);
+ link = g_strconcat (scheme,
+ "://",
+ host_name,
+ NULL);
+
+ g_free (scheme);
+ g_free (host_name);
+ }
+
+ safeLink = sanitise_string (link ? (const xmlChar *)link : (const xmlChar *)url);
+ g_free (link);
+
+ ret = xmlTextWriterStartElementNS
+ (writer,
+ (xmlChar *)"rdf",
+ (xmlChar *)"li",
+ NULL);
+ if (ret < 0) break;
+
+ ret = xmlTextWriterWriteAttributeNS
+ (writer,
+ (xmlChar *)"rdf",
+ (xmlChar *)"resource",
+ NULL,
+ safeLink);
+ xmlFree (safeLink);
+ if (ret < 0) break;
+
+ ret = xmlTextWriterEndElement (writer); /* rdf:li */
+ if (ret < 0) break;
+ }
+ if (ret < 0) goto out;
+
+ ret = xmlTextWriterEndElement (writer); /* rdf:Seq */
+ if (ret < 0) goto out;
+
+ ret = xmlTextWriterEndElement (writer); /* items */
+ if (ret < 0) goto out;
+
+ ret = xmlTextWriterEndElement (writer); /* channel */
+ if (ret < 0) goto out;
+
+ children = ephy_node_get_children (bmks);
+ for (i = 0; i < children->len; i++) {
+ EphyNode *kid;
+ const char *url, *title;
+ char *link = NULL;
+ gboolean smart_url;
+ xmlChar *safeLink, *safeTitle;
+
+ kid = g_ptr_array_index (children, i);
#ifdef ENABLE_ZEROCONF
- /* Don't export the local bookmarks */
- if (ephy_node_has_child (local, kid)) continue;
+ /* Don't export the local bookmarks */
+ if (ephy_node_has_child (local, kid)) continue;
#endif
- smart_url = ephy_node_has_child (smart_bmks, kid);
- url = ephy_node_get_property_string
- (kid, EPHY_NODE_BMK_PROP_LOCATION);
- title = ephy_node_get_property_string
- (kid, EPHY_NODE_BMK_PROP_TITLE);
-
- if (smart_url && url)
- {
- char *scheme;
- char *host_name;
-
- scheme = g_uri_parse_scheme (url);
- host_name = ephy_string_get_host_name (url);
-
- link = g_strconcat (scheme,
- "://",
- host_name,
- NULL);
- g_free (scheme);
- g_free (host_name);
- }
-
- if (link == NULL)
- {
- link = g_strdup (url);
- }
-
- ret = xmlTextWriterStartElement (writer, (xmlChar *) "item");
- if (ret < 0) break;
-
- safeLink = sanitise_string ((const xmlChar *) link);
- g_free (link);
-
- ret = xmlTextWriterWriteAttributeNS
- (writer,
- (xmlChar *) "rdf",
- (xmlChar *) "about",
- NULL,
- safeLink);
- if (ret < 0)
- {
- xmlFree (safeLink);
- break;
- }
-
- safeTitle = sanitise_string ((const xmlChar *) title);
- ret = xmlTextWriterWriteElement
- (writer,
- (xmlChar *) "title",
- safeTitle);
- xmlFree (safeTitle);
- if (ret < 0) break;
-
- ret = xmlTextWriterWriteElement
- (writer,
- (xmlChar *) "link",
- safeLink);
- xmlFree (safeLink);
- if (ret < 0) break;
-
- if (smart_url)
- {
- xmlChar *safeSmartLink;
-
- safeSmartLink = sanitise_string ((const xmlChar *) url);
- ret = xmlTextWriterWriteElementNS
- (writer,
- (xmlChar *) "ephy",
- (xmlChar *) "smartlink",
- NULL,
- safeSmartLink);
- xmlFree (safeSmartLink);
- if (ret < 0) break;
- }
-
- ret = write_topics_list (topics, kid, writer);
- if (ret < 0) break;
-
- ret = xmlTextWriterEndElement (writer); /* item */
- }
- if (ret < 0) goto out;
-
- ret = xmlTextWriterEndElement (writer); /* rdf:RDF */
- if (ret < 0) goto out;
-
- ret = xmlTextWriterEndDocument (writer);
-
-out:
- STOP_PROFILER ("Writing RDF")
-
- return ret;
+ smart_url = ephy_node_has_child (smart_bmks, kid);
+ url = ephy_node_get_property_string
+ (kid, EPHY_NODE_BMK_PROP_LOCATION);
+ title = ephy_node_get_property_string
+ (kid, EPHY_NODE_BMK_PROP_TITLE);
+
+ if (smart_url && url) {
+ char *scheme;
+ char *host_name;
+
+ scheme = g_uri_parse_scheme (url);
+ host_name = ephy_string_get_host_name (url);
+
+ link = g_strconcat (scheme,
+ "://",
+ host_name,
+ NULL);
+ g_free (scheme);
+ g_free (host_name);
+ }
+
+ if (link == NULL) {
+ link = g_strdup (url);
+ }
+
+ ret = xmlTextWriterStartElement (writer, (xmlChar *)"item");
+ if (ret < 0) break;
+
+ safeLink = sanitise_string ((const xmlChar *)link);
+ g_free (link);
+
+ ret = xmlTextWriterWriteAttributeNS
+ (writer,
+ (xmlChar *)"rdf",
+ (xmlChar *)"about",
+ NULL,
+ safeLink);
+ if (ret < 0) {
+ xmlFree (safeLink);
+ break;
+ }
+
+ safeTitle = sanitise_string ((const xmlChar *)title);
+ ret = xmlTextWriterWriteElement
+ (writer,
+ (xmlChar *)"title",
+ safeTitle);
+ xmlFree (safeTitle);
+ if (ret < 0) break;
+
+ ret = xmlTextWriterWriteElement
+ (writer,
+ (xmlChar *)"link",
+ safeLink);
+ xmlFree (safeLink);
+ if (ret < 0) break;
+
+ if (smart_url) {
+ xmlChar *safeSmartLink;
+
+ safeSmartLink = sanitise_string ((const xmlChar *)url);
+ ret = xmlTextWriterWriteElementNS
+ (writer,
+ (xmlChar *)"ephy",
+ (xmlChar *)"smartlink",
+ NULL,
+ safeSmartLink);
+ xmlFree (safeSmartLink);
+ if (ret < 0) break;
+ }
+
+ ret = write_topics_list (topics, kid, writer);
+ if (ret < 0) break;
+
+ ret = xmlTextWriterEndElement (writer); /* item */
+ }
+ if (ret < 0) goto out;
+
+ ret = xmlTextWriterEndElement (writer); /* rdf:RDF */
+ if (ret < 0) goto out;
+
+ ret = xmlTextWriterEndDocument (writer);
+
+ out:
+ STOP_PROFILER ("Writing RDF")
+
+ return ret;
}
void
ephy_bookmarks_export_rdf (EphyBookmarks *bookmarks,
- const char *file_path)
+ const char *file_path)
{
- xmlTextWriterPtr writer;
- xmlBufferPtr buf;
- GFile *file;
- int ret;
-
- LOG ("Exporting as RDF to %s", file_path);
-
- START_PROFILER ("Exporting as RDF")
-
- buf = xmlBufferCreate ();
- if (buf == NULL)
- {
- return;
- }
- /* FIXME: do we want to turn on compression here? */
- writer = xmlNewTextWriterMemory (buf, 0);
- if (writer == NULL)
- {
- xmlBufferFree (buf);
- return;
- }
-
- ret = xmlTextWriterSetIndent (writer, 1);
- if (ret < 0) goto out;
-
- ret = xmlTextWriterSetIndentString (writer, (xmlChar *) " ");
- if (ret < 0) goto out;
-
- file = g_file_new_for_path (file_path);
- ret = write_rdf (bookmarks, file, writer);
- g_object_unref (file);
- if (ret < 0) goto out;
-
- xmlFreeTextWriter (writer);
-out:
- if (ret >= 0)
- {
- if (g_file_set_contents (file_path,
- (const char *)buf->content,
- buf->use,
- NULL) == FALSE)
- {
- ret = -1;
- }
- }
-
- xmlBufferFree (buf);
-
- STOP_PROFILER ("Exporting as RDF")
-
- LOG ("Exporting as RDF %s.", ret >= 0 ? "succeeded" : "FAILED");
+ xmlTextWriterPtr writer;
+ xmlBufferPtr buf;
+ GFile *file;
+ int ret;
+
+ LOG ("Exporting as RDF to %s", file_path);
+
+ START_PROFILER ("Exporting as RDF")
+
+ buf = xmlBufferCreate ();
+ if (buf == NULL) {
+ return;
+ }
+ /* FIXME: do we want to turn on compression here? */
+ writer = xmlNewTextWriterMemory (buf, 0);
+ if (writer == NULL) {
+ xmlBufferFree (buf);
+ return;
+ }
+
+ ret = xmlTextWriterSetIndent (writer, 1);
+ if (ret < 0) goto out;
+
+ ret = xmlTextWriterSetIndentString (writer, (xmlChar *)" ");
+ if (ret < 0) goto out;
+
+ file = g_file_new_for_path (file_path);
+ ret = write_rdf (bookmarks, file, writer);
+ g_object_unref (file);
+ if (ret < 0) goto out;
+
+ xmlFreeTextWriter (writer);
+ out:
+ if (ret >= 0) {
+ if (g_file_set_contents (file_path,
+ (const char *)buf->content,
+ buf->use,
+ NULL) == FALSE) {
+ ret = -1;
+ }
+ }
+
+ xmlBufferFree (buf);
+
+ STOP_PROFILER ("Exporting as RDF")
+
+ LOG ("Exporting as RDF %s.", ret >= 0 ? "succeeded" : "FAILED");
}
void
ephy_bookmarks_export_mozilla (EphyBookmarks *bookmarks,
- const char *filename)
+ const char *filename)
{
- xsltStylesheetPtr cur = NULL;
- xmlTextWriterPtr writer;
- xmlDocPtr doc = NULL, res;
- char *tmp_file_path, *template;
- GFile *tmp_file;
- int ret = -1;
-
- LOG ("Exporting as Mozilla to %s", filename);
-
- template = g_build_filename (g_get_tmp_dir (),
- "export-bookmarks-XXXXXX", NULL);
- tmp_file_path = ephy_file_tmp_filename (template, "rdf");
- g_free (template);
- if (tmp_file_path == NULL) return;
-
- writer = xmlNewTextWriterDoc (&doc, 0);
- if (writer == NULL || doc == NULL)
- {
- g_free (tmp_file_path);
- return;
- }
-
- START_PROFILER ("Exporting as Mozilla");
-
- tmp_file = g_file_new_for_path (tmp_file_path);
- ret = write_rdf (bookmarks, tmp_file, writer);
- g_object_unref (tmp_file);
-
- if (ret < 0) goto out;
-
- /* Set up libxml stuff */
- xmlLoadExtDtdDefaultValue = 1;
- xmlSubstituteEntitiesDefault (1);
-
- cur = xsltParseStylesheetFile ((const xmlChar *) ephy_file ("epiphany-bookmarks-html.xsl"));
- if (cur == NULL) goto out;
-
- res = xsltApplyStylesheet (cur, doc, NULL);
- if (res == NULL)
- {
- xsltFreeStylesheet (cur);
- goto out;
- }
-
- ret = xsltSaveResultToFilename (filename, res, cur, FALSE);
-
- xsltFreeStylesheet (cur);
- xmlFreeDoc (res);
-
- /* Clean up libxslt stuff */
- xsltCleanupGlobals ();
-
-out:
- xmlFreeTextWriter (writer);
- xmlFreeDoc (doc);
- g_free (tmp_file_path);
-
- STOP_PROFILER ("Exporting as Mozilla")
-
- LOG ("Exporting as Mozilla %s.", ret >= 0 ? "succeeded" : "FAILED");
+ xsltStylesheetPtr cur = NULL;
+ xmlTextWriterPtr writer;
+ xmlDocPtr doc = NULL, res;
+ char *tmp_file_path, *template;
+ GFile *tmp_file;
+ int ret = -1;
+
+ LOG ("Exporting as Mozilla to %s", filename);
+
+ template = g_build_filename (g_get_tmp_dir (),
+ "export-bookmarks-XXXXXX", NULL);
+ tmp_file_path = ephy_file_tmp_filename (template, "rdf");
+ g_free (template);
+ if (tmp_file_path == NULL) return;
+
+ writer = xmlNewTextWriterDoc (&doc, 0);
+ if (writer == NULL || doc == NULL) {
+ g_free (tmp_file_path);
+ return;
+ }
+
+ START_PROFILER ("Exporting as Mozilla");
+
+ tmp_file = g_file_new_for_path (tmp_file_path);
+ ret = write_rdf (bookmarks, tmp_file, writer);
+ g_object_unref (tmp_file);
+
+ if (ret < 0) goto out;
+
+ /* Set up libxml stuff */
+ xmlLoadExtDtdDefaultValue = 1;
+ xmlSubstituteEntitiesDefault (1);
+
+ cur = xsltParseStylesheetFile ((const xmlChar *)ephy_file ("epiphany-bookmarks-html.xsl"));
+ if (cur == NULL) goto out;
+
+ res = xsltApplyStylesheet (cur, doc, NULL);
+ if (res == NULL) {
+ xsltFreeStylesheet (cur);
+ goto out;
+ }
+
+ ret = xsltSaveResultToFilename (filename, res, cur, FALSE);
+
+ xsltFreeStylesheet (cur);
+ xmlFreeDoc (res);
+
+ /* Clean up libxslt stuff */
+ xsltCleanupGlobals ();
+
+ out:
+ xmlFreeTextWriter (writer);
+ xmlFreeDoc (doc);
+ g_free (tmp_file_path);
+
+ STOP_PROFILER ("Exporting as Mozilla")
+
+ LOG ("Exporting as Mozilla %s.", ret >= 0 ? "succeeded" : "FAILED");
}
diff --git a/src/bookmarks/ephy-bookmarks-import.c b/src/bookmarks/ephy-bookmarks-import.c
index 72ce993..7447d71 100644
--- a/src/bookmarks/ephy-bookmarks-import.c
+++ b/src/bookmarks/ephy-bookmarks-import.c
@@ -34,471 +34,352 @@
/**
* NSItemType: netscape bookmark item type
*/
-typedef enum
-{
- NS_SITE,
- NS_NOTES,
- NS_FOLDER,
- NS_FOLDER_END,
- NS_SEPARATOR,
- NS_UNKNOWN
+typedef enum {
+ NS_SITE,
+ NS_NOTES,
+ NS_FOLDER,
+ NS_FOLDER_END,
+ NS_SEPARATOR,
+ NS_UNKNOWN
} NSItemType;
static EphyNode *
bookmark_add (EphyBookmarks *bookmarks,
- const char *title,
- const char *address)
+ const char *title,
+ const char *address)
{
- if (!ephy_bookmarks_find_bookmark (bookmarks, address))
- {
- return ephy_bookmarks_add (bookmarks, title, address);
- }
- else
- {
- return NULL;
- }
+ if (!ephy_bookmarks_find_bookmark (bookmarks, address)) {
+ return ephy_bookmarks_add (bookmarks, title, address);
+ } else {
+ return NULL;
+ }
}
gboolean
ephy_bookmarks_import (EphyBookmarks *bookmarks,
- const char *filename)
+ const char *filename)
{
- const char *type;
- char *basename;
- gboolean success = FALSE;
- GFile *file;
- GFileInfo *file_info;
-
- if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
- EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING))
- return FALSE;
-
- g_return_val_if_fail (filename != NULL, FALSE);
-
- file = g_file_new_for_path (filename);
- file_info = g_file_query_info (file,
- G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
- 0, NULL, NULL);
- type = g_file_info_get_content_type (file_info);
-
- g_debug ("Importing bookmarks of type %s", type ? type : "(null)");
-
- if (type != NULL && (strcmp (type, "application/rdf+xml") == 0 ||
- strcmp (type, "text/rdf") == 0))
- {
- success = ephy_bookmarks_import_rdf (bookmarks, filename);
- }
- else if ((type != NULL && strcmp (type, "application/x-xbel") == 0) ||
- strstr (filename, GALEON_BOOKMARKS_DIR) != NULL ||
- strstr (filename, KDE_BOOKMARKS_DIR) != NULL)
- {
- success = ephy_bookmarks_import_xbel (bookmarks, filename);
- }
- else if ((type != NULL && strcmp (type, "application/x-mozilla-bookmarks") == 0) ||
- (type != NULL && strcmp (type, "text/html") == 0) ||
- strstr (filename, MOZILLA_BOOKMARKS_DIR) != NULL ||
- strstr (filename, FIREFOX_BOOKMARKS_DIR_0) != NULL ||
- strstr (filename, FIREFOX_BOOKMARKS_DIR_1) != NULL ||
- strstr (filename, FIREFOX_BOOKMARKS_DIR_2) != NULL)
- {
- success = ephy_bookmarks_import_mozilla (bookmarks, filename);
- }
- else if (type == NULL)
- {
- basename = g_file_get_basename (file);
-
- if (g_str_has_suffix (basename, ".rdf"))
- {
- success = ephy_bookmarks_import_rdf (bookmarks, filename);
- }
- else if (g_str_has_suffix (basename, ".xbel"))
- {
- success = ephy_bookmarks_import_xbel (bookmarks, filename);
- }
- else if (g_str_has_suffix (basename, ".html"))
- {
- success = ephy_bookmarks_import_mozilla (bookmarks, filename);
- }
- else
- {
- /* else FIXME: put up some UI to warn user about unrecognised format? */
- g_warning ("Couldn't determine the type of the bookmarks file %s!\n", filename);
- }
-
- g_free (basename);
- }
-
- g_object_unref (file_info);
- g_object_unref (file);
-
- return success;
+ const char *type;
+ char *basename;
+ gboolean success = FALSE;
+ GFile *file;
+ GFileInfo *file_info;
+
+ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING))
+ return FALSE;
+
+ g_return_val_if_fail (filename != NULL, FALSE);
+
+ file = g_file_new_for_path (filename);
+ file_info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+ 0, NULL, NULL);
+ type = g_file_info_get_content_type (file_info);
+
+ g_debug ("Importing bookmarks of type %s", type ? type : "(null)");
+
+ if (type != NULL && (strcmp (type, "application/rdf+xml") == 0 ||
+ strcmp (type, "text/rdf") == 0)) {
+ success = ephy_bookmarks_import_rdf (bookmarks, filename);
+ } else if ((type != NULL && strcmp (type, "application/x-xbel") == 0) ||
+ strstr (filename, GALEON_BOOKMARKS_DIR) != NULL ||
+ strstr (filename, KDE_BOOKMARKS_DIR) != NULL) {
+ success = ephy_bookmarks_import_xbel (bookmarks, filename);
+ } else if ((type != NULL && strcmp (type, "application/x-mozilla-bookmarks") == 0) ||
+ (type != NULL && strcmp (type, "text/html") == 0) ||
+ strstr (filename, MOZILLA_BOOKMARKS_DIR) != NULL ||
+ strstr (filename, FIREFOX_BOOKMARKS_DIR_0) != NULL ||
+ strstr (filename, FIREFOX_BOOKMARKS_DIR_1) != NULL ||
+ strstr (filename, FIREFOX_BOOKMARKS_DIR_2) != NULL) {
+ success = ephy_bookmarks_import_mozilla (bookmarks, filename);
+ } else if (type == NULL) {
+ basename = g_file_get_basename (file);
+
+ if (g_str_has_suffix (basename, ".rdf")) {
+ success = ephy_bookmarks_import_rdf (bookmarks, filename);
+ } else if (g_str_has_suffix (basename, ".xbel")) {
+ success = ephy_bookmarks_import_xbel (bookmarks, filename);
+ } else if (g_str_has_suffix (basename, ".html")) {
+ success = ephy_bookmarks_import_mozilla (bookmarks, filename);
+ } else {
+ /* else FIXME: put up some UI to warn user about unrecognised format? */
+ g_warning ("Couldn't determine the type of the bookmarks file %s!\n", filename);
+ }
+
+ g_free (basename);
+ }
+
+ g_object_unref (file_info);
+ g_object_unref (file);
+
+ return success;
}
/* XBEL import */
-typedef enum
-{
- STATE_START,
- STATE_STOP,
- STATE_XBEL,
- STATE_FOLDER,
- STATE_BOOKMARK,
- STATE_TITLE,
- STATE_DESC,
- STATE_INFO,
- STATE_METADATA,
- STATE_SMARTURL
+typedef enum {
+ STATE_START,
+ STATE_STOP,
+ STATE_XBEL,
+ STATE_FOLDER,
+ STATE_BOOKMARK,
+ STATE_TITLE,
+ STATE_DESC,
+ STATE_INFO,
+ STATE_METADATA,
+ STATE_SMARTURL
} EphyXBELImporterState;
static int
xbel_parse_bookmark (EphyBookmarks *eb, xmlTextReaderPtr reader, EphyNode **ret_node)
{
- EphyXBELImporterState state = STATE_BOOKMARK;
- EphyNode *node;
- xmlChar *title = NULL;
- xmlChar *address = NULL;
- int ret = 1;
-
- while (ret == 1)
- {
- const xmlChar *tag;
- xmlReaderTypes type;
-
- tag = xmlTextReaderConstName (reader);
- g_return_val_if_fail (tag != NULL, ret);
-
- type = xmlTextReaderNodeType (reader);
-
- if (xmlStrEqual (tag, (xmlChar *) "#text"))
- {
- if (state == STATE_TITLE && title == NULL)
- {
- title = xmlTextReaderValue (reader);
- }
- else if (state == STATE_SMARTURL)
- {
- xmlFree (address);
- address = xmlTextReaderValue (reader);
- }
- else
- {
- /* eat it */
- }
- }
- else if (xmlStrEqual (tag, (xmlChar *) "bookmark"))
- {
- if (type == XML_READER_TYPE_ELEMENT && state == STATE_BOOKMARK && address == NULL)
- {
- address = xmlTextReaderGetAttribute (reader, (xmlChar *) "href");
- }
- else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_BOOKMARK)
- {
- /* we're done */
-
- break;
- }
- }
- else if (xmlStrEqual (tag, (xmlChar *) "title"))
- {
- if (type == XML_READER_TYPE_ELEMENT && state == STATE_BOOKMARK && title == NULL)
- {
- state = STATE_TITLE;
- }
- else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_TITLE)
- {
- state = STATE_BOOKMARK;
- }
- }
- else if (xmlStrEqual (tag, (xmlChar *) "desc"))
- {
- if (type == XML_READER_TYPE_ELEMENT && state == STATE_BOOKMARK)
- {
- state = STATE_DESC;
- }
- else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_DESC)
- {
- state = STATE_BOOKMARK;
- }
- }
- else if (xmlStrEqual (tag, (xmlChar *) "info"))
- {
- if (type == XML_READER_TYPE_ELEMENT && state == STATE_BOOKMARK)
- {
- state = STATE_INFO;
- }
- else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_INFO)
- {
- state = STATE_BOOKMARK;
- }
- }
- else if (xmlStrEqual (tag, (xmlChar *) "metadata"))
- {
- if (type == XML_READER_TYPE_ELEMENT && state == STATE_INFO)
- {
- state = STATE_METADATA;
- }
- else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_METADATA)
- {
- state = STATE_INFO;
- }
- }
- else if (xmlStrEqual (tag, (xmlChar *) "smarturl"))
- {
- if (type == XML_READER_TYPE_ELEMENT && state == STATE_METADATA)
- {
- state = STATE_SMARTURL;
- }
- else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_SMARTURL)
- {
- state = STATE_METADATA;
- }
- }
-
- /* next one, please */
- ret = xmlTextReaderRead (reader);
- }
-
- if (address == NULL)
- {
- return ret;
- }
-
- if (title == NULL)
- {
- title = xmlStrdup ((xmlChar *) _("Untitled"));
- }
-
- node = bookmark_add (eb, (const char *) title, (const char *) address);
- if (node == NULL)
- {
- /* probably a duplicate */
- node = ephy_bookmarks_find_bookmark (eb, (const char *) address);
- }
-
- xmlFree (title);
- xmlFree (address);
-
- *ret_node = node;
-
- return ret;
+ EphyXBELImporterState state = STATE_BOOKMARK;
+ EphyNode *node;
+ xmlChar *title = NULL;
+ xmlChar *address = NULL;
+ int ret = 1;
+
+ while (ret == 1) {
+ const xmlChar *tag;
+ xmlReaderTypes type;
+
+ tag = xmlTextReaderConstName (reader);
+ g_return_val_if_fail (tag != NULL, ret);
+
+ type = xmlTextReaderNodeType (reader);
+
+ if (xmlStrEqual (tag, (xmlChar *)"#text")) {
+ if (state == STATE_TITLE && title == NULL) {
+ title = xmlTextReaderValue (reader);
+ } else if (state == STATE_SMARTURL) {
+ xmlFree (address);
+ address = xmlTextReaderValue (reader);
+ } else {
+ /* eat it */
+ }
+ } else if (xmlStrEqual (tag, (xmlChar *)"bookmark")) {
+ if (type == XML_READER_TYPE_ELEMENT && state == STATE_BOOKMARK && address == NULL) {
+ address = xmlTextReaderGetAttribute (reader, (xmlChar *)"href");
+ } else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_BOOKMARK) {
+ /* we're done */
+
+ break;
+ }
+ } else if (xmlStrEqual (tag, (xmlChar *)"title")) {
+ if (type == XML_READER_TYPE_ELEMENT && state == STATE_BOOKMARK && title == NULL) {
+ state = STATE_TITLE;
+ } else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_TITLE) {
+ state = STATE_BOOKMARK;
+ }
+ } else if (xmlStrEqual (tag, (xmlChar *)"desc")) {
+ if (type == XML_READER_TYPE_ELEMENT && state == STATE_BOOKMARK) {
+ state = STATE_DESC;
+ } else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_DESC) {
+ state = STATE_BOOKMARK;
+ }
+ } else if (xmlStrEqual (tag, (xmlChar *)"info")) {
+ if (type == XML_READER_TYPE_ELEMENT && state == STATE_BOOKMARK) {
+ state = STATE_INFO;
+ } else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_INFO) {
+ state = STATE_BOOKMARK;
+ }
+ } else if (xmlStrEqual (tag, (xmlChar *)"metadata")) {
+ if (type == XML_READER_TYPE_ELEMENT && state == STATE_INFO) {
+ state = STATE_METADATA;
+ } else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_METADATA) {
+ state = STATE_INFO;
+ }
+ } else if (xmlStrEqual (tag, (xmlChar *)"smarturl")) {
+ if (type == XML_READER_TYPE_ELEMENT && state == STATE_METADATA) {
+ state = STATE_SMARTURL;
+ } else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_SMARTURL) {
+ state = STATE_METADATA;
+ }
+ }
+
+ /* next one, please */
+ ret = xmlTextReaderRead (reader);
+ }
+
+ if (address == NULL) {
+ return ret;
+ }
+
+ if (title == NULL) {
+ title = xmlStrdup ((xmlChar *)_("Untitled"));
+ }
+
+ node = bookmark_add (eb, (const char *)title, (const char *)address);
+ if (node == NULL) {
+ /* probably a duplicate */
+ node = ephy_bookmarks_find_bookmark (eb, (const char *)address);
+ }
+
+ xmlFree (title);
+ xmlFree (address);
+
+ *ret_node = node;
+
+ return ret;
}
static int
xbel_parse_folder (EphyBookmarks *eb, xmlTextReaderPtr reader, GList *folders)
{
- EphyXBELImporterState state = STATE_FOLDER;
- char *folder = NULL;
- int ret;
-
- ret = xmlTextReaderRead (reader);
-
- while (ret == 1)
- {
- const xmlChar *tag;
- xmlReaderTypes type;
-
- tag = xmlTextReaderConstName (reader);
- type = xmlTextReaderNodeType (reader);
-
- if (tag == NULL)
- {
- /* shouldn't happen but does anyway :) */
- }
- else if (xmlStrEqual (tag, (xmlChar *) "#text"))
- {
- if (state == STATE_TITLE && folder == NULL)
- {
- folder = (char *) xmlTextReaderValue (reader);
-
- folders = g_list_prepend (folders, folder);
- }
- else
- {
- /* eat it */
- }
- }
- else if (xmlStrEqual (tag, (xmlChar *) "bookmark") && type == 1 && state == STATE_FOLDER)
- {
- EphyNode *node = NULL, *keyword;
- GList *l;
-
- ret = xbel_parse_bookmark (eb, reader, &node);
-
- for (l = folders; l != NULL; l=l->next)
- {
- const char *title;
-
- title = l->data ? (char *) l->data : "";
-
- keyword = ephy_bookmarks_find_keyword (eb, title, FALSE);
-
- if (keyword == NULL && title[0] != '\0')
- {
- keyword = ephy_bookmarks_add_keyword (eb, title);
- }
-
- if (node != NULL && keyword != NULL)
- {
- ephy_bookmarks_set_keyword (eb, keyword, node);
- }
- }
-
- if (ret != 1) break;
- }
- else if ((xmlStrEqual (tag, (xmlChar *) "folder"))
- && state == STATE_FOLDER)
- {
- if (type == XML_READER_TYPE_ELEMENT)
- {
- ret = xbel_parse_folder (eb, reader, folders);
-
- if (ret != 1) break;
- }
- else if (type == XML_READER_TYPE_END_ELEMENT)
- {
- /* we're done */
-
- break;
- }
- }
- else if (xmlStrEqual (tag, (xmlChar *) "title"))
- {
- if (type == XML_READER_TYPE_ELEMENT && state == STATE_FOLDER)
- {
- state = STATE_TITLE;
- }
- else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_TITLE)
- {
- state = STATE_FOLDER;
- }
- }
- else if (xmlStrEqual (tag, (xmlChar *) "info"))
- {
- if (type == XML_READER_TYPE_ELEMENT && state == STATE_FOLDER)
- {
- state = STATE_INFO;
- }
- else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_INFO)
- {
- state = STATE_FOLDER;
- }
- }
- else if (xmlStrEqual (tag, (xmlChar *) "desc"))
- {
- if (type == XML_READER_TYPE_ELEMENT && state == STATE_FOLDER)
- {
- state = STATE_DESC;
- }
- else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_DESC)
- {
- state = STATE_FOLDER;
- }
- }
- else
- {
- /* eat it */
- }
-
- /* next one, please */
- ret = xmlTextReaderRead (reader);
- }
-
- if (folder)
- {
- folders = g_list_remove (folders, folder);
- g_free (folder);
- }
-
- return ret;
+ EphyXBELImporterState state = STATE_FOLDER;
+ char *folder = NULL;
+ int ret;
+
+ ret = xmlTextReaderRead (reader);
+
+ while (ret == 1) {
+ const xmlChar *tag;
+ xmlReaderTypes type;
+
+ tag = xmlTextReaderConstName (reader);
+ type = xmlTextReaderNodeType (reader);
+
+ if (tag == NULL) {
+ /* shouldn't happen but does anyway :) */
+ } else if (xmlStrEqual (tag, (xmlChar *)"#text")) {
+ if (state == STATE_TITLE && folder == NULL) {
+ folder = (char *)xmlTextReaderValue (reader);
+
+ folders = g_list_prepend (folders, folder);
+ } else {
+ /* eat it */
+ }
+ } else if (xmlStrEqual (tag, (xmlChar *)"bookmark") && type == 1 && state == STATE_FOLDER) {
+ EphyNode *node = NULL, *keyword;
+ GList *l;
+
+ ret = xbel_parse_bookmark (eb, reader, &node);
+
+ for (l = folders; l != NULL; l = l->next) {
+ const char *title;
+
+ title = l->data ? (char *)l->data : "";
+
+ keyword = ephy_bookmarks_find_keyword (eb, title, FALSE);
+
+ if (keyword == NULL && title[0] != '\0') {
+ keyword = ephy_bookmarks_add_keyword (eb, title);
+ }
+
+ if (node != NULL && keyword != NULL) {
+ ephy_bookmarks_set_keyword (eb, keyword, node);
+ }
+ }
+
+ if (ret != 1) break;
+ } else if ((xmlStrEqual (tag, (xmlChar *)"folder"))
+ && state == STATE_FOLDER) {
+ if (type == XML_READER_TYPE_ELEMENT) {
+ ret = xbel_parse_folder (eb, reader, folders);
+
+ if (ret != 1) break;
+ } else if (type == XML_READER_TYPE_END_ELEMENT) {
+ /* we're done */
+
+ break;
+ }
+ } else if (xmlStrEqual (tag, (xmlChar *)"title")) {
+ if (type == XML_READER_TYPE_ELEMENT && state == STATE_FOLDER) {
+ state = STATE_TITLE;
+ } else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_TITLE) {
+ state = STATE_FOLDER;
+ }
+ } else if (xmlStrEqual (tag, (xmlChar *)"info")) {
+ if (type == XML_READER_TYPE_ELEMENT && state == STATE_FOLDER) {
+ state = STATE_INFO;
+ } else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_INFO) {
+ state = STATE_FOLDER;
+ }
+ } else if (xmlStrEqual (tag, (xmlChar *)"desc")) {
+ if (type == XML_READER_TYPE_ELEMENT && state == STATE_FOLDER) {
+ state = STATE_DESC;
+ } else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_DESC) {
+ state = STATE_FOLDER;
+ }
+ } else {
+ /* eat it */
+ }
+
+ /* next one, please */
+ ret = xmlTextReaderRead (reader);
+ }
+
+ if (folder) {
+ folders = g_list_remove (folders, folder);
+ g_free (folder);
+ }
+
+ return ret;
}
static int
xbel_parse_xbel (EphyBookmarks *eb, xmlTextReaderPtr reader)
{
- EphyXBELImporterState state = STATE_XBEL;
- int ret;
-
- ret = xmlTextReaderRead (reader);
-
- while (ret == 1 && state != STATE_STOP)
- {
- const xmlChar *tag;
- xmlReaderTypes type;
-
- tag = xmlTextReaderConstName (reader);
- type = xmlTextReaderNodeType (reader);
-
- if (tag == NULL)
- {
- /* shouldn't happen but does anyway :( */
- }
- else if (xmlStrEqual (tag, (xmlChar *) "bookmark") && type == XML_READER_TYPE_ELEMENT
- && state == STATE_XBEL)
- {
- EphyNode *node = NULL;
-
- /* this will eat the </bookmark> too */
- ret = xbel_parse_bookmark (eb, reader, &node);
-
- if (ret != 1) break;
- }
- else if (xmlStrEqual (tag, (xmlChar *) "folder") && type == XML_READER_TYPE_ELEMENT
- && state == STATE_XBEL)
- {
- /* this will eat the </folder> too */
- ret = xbel_parse_folder (eb, reader, NULL);
-
- if (ret != 1) break;
- }
- else if ((xmlStrEqual (tag, (xmlChar *) "xbel")) && type == XML_READER_TYPE_ELEMENT
- && state == STATE_START)
- {
- state = STATE_XBEL;
- }
- else if ((xmlStrEqual (tag, (xmlChar *) "xbel")) && type == XML_READER_TYPE_END_ELEMENT
- && state == STATE_XBEL)
- {
- state = STATE_STOP;
- }
- else if (xmlStrEqual (tag, (xmlChar *) "title"))
- {
- if (type == XML_READER_TYPE_ELEMENT && state == STATE_XBEL)
- {
- state = STATE_TITLE;
- }
- else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_TITLE)
- {
- state = STATE_XBEL;
- }
- }
- else if (xmlStrEqual (tag, (xmlChar *) "info"))
- {
- if (type == XML_READER_TYPE_ELEMENT && state == STATE_XBEL)
- {
- state = STATE_INFO;
- }
- else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_INFO)
- {
- state = STATE_XBEL;
- }
- }
- else if (xmlStrEqual (tag, (xmlChar *) "desc"))
- {
- if (type == XML_READER_TYPE_ELEMENT && state == STATE_XBEL)
- {
- state = STATE_DESC;
- }
- else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_DESC)
- {
- state = STATE_XBEL;
- }
- }
-
- /* next one, please */
- ret = xmlTextReaderRead (reader);
- }
-
- return ret;
+ EphyXBELImporterState state = STATE_XBEL;
+ int ret;
+
+ ret = xmlTextReaderRead (reader);
+
+ while (ret == 1 && state != STATE_STOP) {
+ const xmlChar *tag;
+ xmlReaderTypes type;
+
+ tag = xmlTextReaderConstName (reader);
+ type = xmlTextReaderNodeType (reader);
+
+ if (tag == NULL) {
+ /* shouldn't happen but does anyway :( */
+ } else if (xmlStrEqual (tag, (xmlChar *)"bookmark") && type == XML_READER_TYPE_ELEMENT
+ && state == STATE_XBEL) {
+ EphyNode *node = NULL;
+
+ /* this will eat the </bookmark> too */
+ ret = xbel_parse_bookmark (eb, reader, &node);
+
+ if (ret != 1) break;
+ } else if (xmlStrEqual (tag, (xmlChar *)"folder") && type == XML_READER_TYPE_ELEMENT
+ && state == STATE_XBEL) {
+ /* this will eat the </folder> too */
+ ret = xbel_parse_folder (eb, reader, NULL);
+
+ if (ret != 1) break;
+ } else if ((xmlStrEqual (tag, (xmlChar *)"xbel")) && type == XML_READER_TYPE_ELEMENT
+ && state == STATE_START) {
+ state = STATE_XBEL;
+ } else if ((xmlStrEqual (tag, (xmlChar *)"xbel")) && type == XML_READER_TYPE_END_ELEMENT
+ && state == STATE_XBEL) {
+ state = STATE_STOP;
+ } else if (xmlStrEqual (tag, (xmlChar *)"title")) {
+ if (type == XML_READER_TYPE_ELEMENT && state == STATE_XBEL) {
+ state = STATE_TITLE;
+ } else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_TITLE) {
+ state = STATE_XBEL;
+ }
+ } else if (xmlStrEqual (tag, (xmlChar *)"info")) {
+ if (type == XML_READER_TYPE_ELEMENT && state == STATE_XBEL) {
+ state = STATE_INFO;
+ } else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_INFO) {
+ state = STATE_XBEL;
+ }
+ } else if (xmlStrEqual (tag, (xmlChar *)"desc")) {
+ if (type == XML_READER_TYPE_ELEMENT && state == STATE_XBEL) {
+ state = STATE_DESC;
+ } else if (type == XML_READER_TYPE_END_ELEMENT && state == STATE_DESC) {
+ state = STATE_XBEL;
+ }
+ }
+
+ /* next one, please */
+ ret = xmlTextReaderRead (reader);
+ }
+
+ return ret;
}
/* Mozilla/Netscape import */
@@ -506,19 +387,18 @@ xbel_parse_xbel (EphyBookmarks *eb, xmlTextReaderPtr reader)
static gchar *
gul_general_read_line_from_file (FILE *f)
{
- gchar *line = g_strdup ("");
- gchar *t;
- gchar *buf = g_new0 (gchar, 256);
- while ( ! ( strchr (buf, '\n') || feof (f) ) ) {
- if (fgets(buf, 256, f))
- {
- t = line;
- line = g_strconcat (line, buf, NULL);
- g_free (t);
- }
- }
- g_free (buf);
- return line;
+ gchar *line = g_strdup ("");
+ gchar *t;
+ gchar *buf = g_new0 (gchar, 256);
+ while (!(strchr (buf, '\n') || feof (f))) {
+ if (fgets (buf, 256, f)) {
+ t = line;
+ line = g_strconcat (line, buf, NULL);
+ g_free (t);
+ }
+ }
+ g_free (buf);
+ return line;
}
/**
@@ -528,88 +408,83 @@ gul_general_read_line_from_file (FILE *f)
static NSItemType
ns_get_bookmark_item (FILE *f, GString *name, GString *url)
{
- char *line = NULL;
- GRegex *regex;
- GMatchInfo *match_info;
- int ret = NS_UNKNOWN;
- char *match_url = NULL;
- char *match_name = NULL;
-
- line = gul_general_read_line_from_file (f);
-
- /*
- * Regex parsing of the html file:
- * 1. check if it's a bookmark, or a folder, or the end of a folder,
- * note that only ONE of this things is going to happen
- * 2. assign to the GStrings
- * 3. return the ret val to tell our caller what we found, by default
- * we don't know (NS_UNKWOWN).
- */
-
- /* check if it's a bookmark */
- regex = g_regex_new
- ("<a href=\"(?P<url>[^\"]*).*?>\\s*(?P<name>.*?)\\s*</a>",
- G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY, NULL);
- g_regex_match (regex, line, 0, &match_info);
-
- if (g_match_info_matches (match_info))
- {
- match_url = g_match_info_fetch_named (match_info, "url");
- match_name = g_match_info_fetch_named (match_info, "name");
- ret = NS_SITE;
- goto end;
- }
- g_match_info_free (match_info);
- g_regex_unref (regex);
-
- /* check if it's a folder start */
- regex = g_regex_new ("<h3.*>(?P<name>\\w.*)</h3>",
- G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY, NULL);
-
- g_regex_match (regex, line, 0, &match_info);
- if (g_match_info_matches (match_info))
- {
- match_name = g_match_info_fetch_named (match_info, "name");
- ret = NS_FOLDER;
- goto end;
- }
- g_match_info_free (match_info);
- g_regex_unref (regex);
-
- /* check if it's a folder end */
- regex = g_regex_new ("</dl>",
- G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY, NULL);
-
- g_regex_match (regex, line, 0, &match_info);
- if (g_match_info_matches (match_info))
- {
- ret = NS_FOLDER_END;
- goto end;
- }
-
- /* now let's use the collected stuff */
- end:
- /* Due to the goto we'll always have an unfreed @match_info and
- * @regex. Note that this two free/unrefs correspond to the last
- * if() block too.
- */
- g_match_info_free (match_info);
- g_regex_unref (regex);
-
- if (match_name)
- {
- g_string_assign (name, match_name);
- g_free (match_name);
- }
-
- if (match_url)
- {
- g_string_assign (url, match_url);
- g_free (match_url);
- }
-
- g_free (line);
- return ret;
+ char *line = NULL;
+ GRegex *regex;
+ GMatchInfo *match_info;
+ int ret = NS_UNKNOWN;
+ char *match_url = NULL;
+ char *match_name = NULL;
+
+ line = gul_general_read_line_from_file (f);
+
+ /*
+ * Regex parsing of the html file:
+ * 1. check if it's a bookmark, or a folder, or the end of a folder,
+ * note that only ONE of this things is going to happen
+ * 2. assign to the GStrings
+ * 3. return the ret val to tell our caller what we found, by default
+ * we don't know (NS_UNKWOWN).
+ */
+
+ /* check if it's a bookmark */
+ regex = g_regex_new
+ ("<a href=\"(?P<url>[^\"]*).*?>\\s*(?P<name>.*?)\\s*</a>",
+ G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY, NULL);
+ g_regex_match (regex, line, 0, &match_info);
+
+ if (g_match_info_matches (match_info)) {
+ match_url = g_match_info_fetch_named (match_info, "url");
+ match_name = g_match_info_fetch_named (match_info, "name");
+ ret = NS_SITE;
+ goto end;
+ }
+ g_match_info_free (match_info);
+ g_regex_unref (regex);
+
+ /* check if it's a folder start */
+ regex = g_regex_new ("<h3.*>(?P<name>\\w.*)</h3>",
+ G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY, NULL);
+
+ g_regex_match (regex, line, 0, &match_info);
+ if (g_match_info_matches (match_info)) {
+ match_name = g_match_info_fetch_named (match_info, "name");
+ ret = NS_FOLDER;
+ goto end;
+ }
+ g_match_info_free (match_info);
+ g_regex_unref (regex);
+
+ /* check if it's a folder end */
+ regex = g_regex_new ("</dl>",
+ G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY, NULL);
+
+ g_regex_match (regex, line, 0, &match_info);
+ if (g_match_info_matches (match_info)) {
+ ret = NS_FOLDER_END;
+ goto end;
+ }
+
+ /* now let's use the collected stuff */
+ end:
+ /* Due to the goto we'll always have an unfreed @match_info and
+ * @regex. Note that this two free/unrefs correspond to the last
+ * if() block too.
+ */
+ g_match_info_free (match_info);
+ g_regex_unref (regex);
+
+ if (match_name) {
+ g_string_assign (name, match_name);
+ g_free (match_name);
+ }
+
+ if (match_url) {
+ g_string_assign (url, match_url);
+ g_free (match_url);
+ }
+
+ g_free (line);
+ return ret;
}
/*
@@ -624,392 +499,353 @@ ns_get_bookmark_item (FILE *f, GString *name, GString *url)
static char *
ns_parse_bookmark_item (GString *string)
{
- char *iterator, *temp;
- int cnt = 0;
- GString *result = g_string_new (NULL);
-
- g_return_val_if_fail (string != NULL, NULL);
- g_return_val_if_fail (string->str != NULL, NULL);
-
- iterator = string->str;
-
- for (cnt = 0, iterator = string->str;
- cnt <= (int)(strlen (string->str));
- cnt++, iterator++) {
- if (*iterator == '&') {
- int jump = 0;
- int i;
-
- if (g_ascii_strncasecmp (iterator, "&", 5) == 0)
- {
- g_string_append_c (result, '&');
- jump = 5;
- }
- else if (g_ascii_strncasecmp (iterator, "<", 4) == 0)
- {
- g_string_append_c (result, '<');
- jump = 4;
- }
- else if (g_ascii_strncasecmp (iterator, ">", 4) == 0)
- {
- g_string_append_c (result, '>');
- jump = 4;
- }
- else if (g_ascii_strncasecmp (iterator, """, 6) == 0)
- {
- g_string_append_c (result, '\"');
- jump = 6;
- }
- else
- {
- /* It must be some numeric thing now */
-
- iterator++;
-
- if (iterator && *iterator == '#') {
- int val;
- char *num, *tmp;
-
- iterator++;
-
- val = atoi (iterator);
-
- tmp = g_strdup_printf ("%d", val);
- jump = strlen (tmp);
- g_free (tmp);
-
- num = g_strdup_printf ("%c", (char) val);
- g_string_append (result, num);
- g_free (num);
- }
- }
-
- for (i = jump - 1; i > 0; i--)
- {
- iterator++;
- if (*iterator == '\0')
- break;
- }
- }
- else
- {
- g_string_append_c (result, *iterator);
- }
- }
- temp = result->str;
- g_string_free (result, FALSE);
- return temp;
+ char *iterator, *temp;
+ int cnt = 0;
+ GString *result = g_string_new (NULL);
+
+ g_return_val_if_fail (string != NULL, NULL);
+ g_return_val_if_fail (string->str != NULL, NULL);
+
+ iterator = string->str;
+
+ for (cnt = 0, iterator = string->str;
+ cnt <= (int)(strlen (string->str));
+ cnt++, iterator++) {
+ if (*iterator == '&') {
+ int jump = 0;
+ int i;
+
+ if (g_ascii_strncasecmp (iterator, "&", 5) == 0) {
+ g_string_append_c (result, '&');
+ jump = 5;
+ } else if (g_ascii_strncasecmp (iterator, "<", 4) == 0) {
+ g_string_append_c (result, '<');
+ jump = 4;
+ } else if (g_ascii_strncasecmp (iterator, ">", 4) == 0) {
+ g_string_append_c (result, '>');
+ jump = 4;
+ } else if (g_ascii_strncasecmp (iterator, """, 6) == 0) {
+ g_string_append_c (result, '\"');
+ jump = 6;
+ } else {
+ /* It must be some numeric thing now */
+
+ iterator++;
+
+ if (iterator && *iterator == '#') {
+ int val;
+ char *num, *tmp;
+
+ iterator++;
+
+ val = atoi (iterator);
+
+ tmp = g_strdup_printf ("%d", val);
+ jump = strlen (tmp);
+ g_free (tmp);
+
+ num = g_strdup_printf ("%c", (char)val);
+ g_string_append (result, num);
+ g_free (num);
+ }
+ }
+
+ for (i = jump - 1; i > 0; i--) {
+ iterator++;
+ if (*iterator == '\0')
+ break;
+ }
+ } else {
+ g_string_append_c (result, *iterator);
+ }
+ }
+ temp = result->str;
+ g_string_free (result, FALSE);
+ return temp;
}
gboolean
ephy_bookmarks_import_mozilla (EphyBookmarks *bookmarks,
- const char *filename)
+ const char *filename)
{
- FILE *bf; /* bookmark file */
- GString *name, *url;
- char *parsedname;
- GList *folders = NULL;
- gboolean retval = TRUE;
-
- if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
- EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING))
- return FALSE;
-
- if (!(bf = fopen (filename, "r"))) {
- g_warning ("Failed to open file: %s\n", filename);
- return FALSE;
- }
-
- name = g_string_new (NULL);
- url = g_string_new (NULL);
-
- while (!feof (bf)) {
- EphyNode *node;
- NSItemType t;
- t = ns_get_bookmark_item (bf, name, url);
- switch (t)
- {
- case NS_FOLDER:
- folders = g_list_append (folders, ns_parse_bookmark_item (name));
- break;
- case NS_FOLDER_END:
- if (folders)
- {
- GList *last = g_list_last (folders);
-
- /* remove last entry */
- g_free (last->data);
- folders = g_list_delete_link (folders, last);
- }
- break;
- case NS_SITE:
- parsedname = ns_parse_bookmark_item (name);
-
- node = bookmark_add (bookmarks, parsedname, url->str);
-
- if (node == NULL)
- {
- node = ephy_bookmarks_find_bookmark (bookmarks, url->str);
- if (node == NULL) {
- g_warning ("%s: `node' is NULL", G_STRFUNC);
- retval = FALSE;
- goto out;
- }
- }
-
- if (folders != NULL)
- {
- EphyNode *keyword;
- GList *l;
-
- for (l = folders; l != NULL; l = l->next)
- {
- keyword = ephy_bookmarks_find_keyword (bookmarks, l->data, FALSE);
- if (keyword == NULL)
- {
- keyword = ephy_bookmarks_add_keyword (bookmarks, l->data);
- }
-
- ephy_bookmarks_set_keyword (bookmarks, keyword, node);
- }
- }
-
- g_free (parsedname);
-
- break;
- case NS_NOTES:
- case NS_SEPARATOR:
- case NS_UNKNOWN:
- default:
- break;
- }
- }
-out:
- fclose (bf);
- g_string_free (name, TRUE);
- g_string_free (url, TRUE);
-
- return retval;
+ FILE *bf; /* bookmark file */
+ GString *name, *url;
+ char *parsedname;
+ GList *folders = NULL;
+ gboolean retval = TRUE;
+
+ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING))
+ return FALSE;
+
+ if (!(bf = fopen (filename, "r"))) {
+ g_warning ("Failed to open file: %s\n", filename);
+ return FALSE;
+ }
+
+ name = g_string_new (NULL);
+ url = g_string_new (NULL);
+
+ while (!feof (bf)) {
+ EphyNode *node;
+ NSItemType t;
+ t = ns_get_bookmark_item (bf, name, url);
+ switch (t) {
+ case NS_FOLDER:
+ folders = g_list_append (folders, ns_parse_bookmark_item (name));
+ break;
+ case NS_FOLDER_END:
+ if (folders) {
+ GList *last = g_list_last (folders);
+
+ /* remove last entry */
+ g_free (last->data);
+ folders = g_list_delete_link (folders, last);
+ }
+ break;
+ case NS_SITE:
+ parsedname = ns_parse_bookmark_item (name);
+
+ node = bookmark_add (bookmarks, parsedname, url->str);
+
+ if (node == NULL) {
+ node = ephy_bookmarks_find_bookmark (bookmarks, url->str);
+ if (node == NULL) {
+ g_warning ("%s: `node' is NULL", G_STRFUNC);
+ retval = FALSE;
+ goto out;
+ }
+ }
+
+ if (folders != NULL) {
+ EphyNode *keyword;
+ GList *l;
+
+ for (l = folders; l != NULL; l = l->next) {
+ keyword = ephy_bookmarks_find_keyword (bookmarks, l->data, FALSE);
+ if (keyword == NULL) {
+ keyword = ephy_bookmarks_add_keyword (bookmarks, l->data);
+ }
+
+ ephy_bookmarks_set_keyword (bookmarks, keyword, node);
+ }
+ }
+
+ g_free (parsedname);
+
+ break;
+ case NS_NOTES:
+ case NS_SEPARATOR:
+ case NS_UNKNOWN:
+ default:
+ break;
+ }
+ }
+ out:
+ fclose (bf);
+ g_string_free (name, TRUE);
+ g_string_free (url, TRUE);
+
+ return retval;
}
gboolean
ephy_bookmarks_import_xbel (EphyBookmarks *bookmarks,
- const char *filename)
+ const char *filename)
{
- xmlTextReaderPtr reader;
- int ret;
+ xmlTextReaderPtr reader;
+ int ret;
+
+ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING))
+ return FALSE;
- if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
- EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING))
- return FALSE;
+ if (g_file_test (filename, G_FILE_TEST_EXISTS) == FALSE) {
+ return FALSE;
+ }
- if (g_file_test (filename, G_FILE_TEST_EXISTS) == FALSE)
- {
- return FALSE;
- }
-
- reader = xmlNewTextReaderFilename (filename);
- if (reader == NULL)
- {
- return FALSE;
- }
+ reader = xmlNewTextReaderFilename (filename);
+ if (reader == NULL) {
+ return FALSE;
+ }
- ret = xbel_parse_xbel (bookmarks, reader);
+ ret = xbel_parse_xbel (bookmarks, reader);
- xmlFreeTextReader (reader);
+ xmlFreeTextReader (reader);
- return ret >= 0 ? TRUE : FALSE;
+ return ret >= 0 ? TRUE : FALSE;
}
static void
parse_rdf_lang_tag (xmlNode *child,
- xmlChar **value,
- int *best_match)
+ xmlChar **value,
+ int *best_match)
{
- const char * const *locales;
- const char *this_language;
- xmlChar *lang;
- xmlChar *content;
- int i;
-
- if (*best_match == 0)
- /* there's no way we can do better */
- return;
-
- content = xmlNodeGetContent (child);
- if (!content)
- return;
-
- lang = xmlNodeGetLang (child);
- if (lang == NULL)
- {
- const char *translated;
-
- translated = _((char *) content);
- if ((char *) content != translated)
- {
- /* if we have a translation for the content of the
- * node, then we just use this */
- if (*value) xmlFree (*value);
- *value = (xmlChar *) g_strdup (translated);
- *best_match = 0;
-
- xmlFree (content);
- return;
- }
-
- this_language = "C";
- }
- else
- this_language = (char *) lang;
-
- locales = g_get_language_names ();
-
- for (i = 0; locales[i] && i < *best_match; i++) {
- if (!strcmp (locales[i], this_language)) {
- /* if we've already encountered a less accurate
- * translation, then free it */
- if (*value) xmlFree (*value);
-
- *value = content;
- *best_match = i;
-
- break;
- }
- }
-
- if (lang) xmlFree (lang);
- if (*value != content) xmlFree (content);
+ const char * const *locales;
+ const char *this_language;
+ xmlChar *lang;
+ xmlChar *content;
+ int i;
+
+ if (*best_match == 0)
+ /* there's no way we can do better */
+ return;
+
+ content = xmlNodeGetContent (child);
+ if (!content)
+ return;
+
+ lang = xmlNodeGetLang (child);
+ if (lang == NULL) {
+ const char *translated;
+
+ translated = _((char *)content);
+ if ((char *)content != translated) {
+ /* if we have a translation for the content of the
+ * node, then we just use this */
+ if (*value) xmlFree (*value);
+ *value = (xmlChar *)g_strdup (translated);
+ *best_match = 0;
+
+ xmlFree (content);
+ return;
+ }
+
+ this_language = "C";
+ } else
+ this_language = (char *)lang;
+
+ locales = g_get_language_names ();
+
+ for (i = 0; locales[i] && i < *best_match; i++) {
+ if (!strcmp (locales[i], this_language)) {
+ /* if we've already encountered a less accurate
+ * translation, then free it */
+ if (*value) xmlFree (*value);
+
+ *value = content;
+ *best_match = i;
+
+ break;
+ }
+ }
+
+ if (lang) xmlFree (lang);
+ if (*value != content) xmlFree (content);
}
static void
parse_rdf_item (EphyBookmarks *bookmarks,
- xmlNodePtr node)
+ xmlNodePtr node)
{
- xmlChar *title = NULL;
- int best_match_title = INT_MAX;
- xmlChar *link = NULL;
- int best_match_link = INT_MAX;
- /* we consider that it's better to use a non-localized smart link than
- * a localized link */
- gboolean use_smartlink = FALSE;
- xmlChar *subject = NULL;
- GList *subjects = NULL, *l = NULL;
- xmlNode *child;
- EphyNode *bmk = NULL;
-
- child = node->children;
-
- link = xmlGetProp (node, (xmlChar *) "about");
-
- while (child != NULL)
- {
- if (xmlStrEqual (child->name, (xmlChar *) "title"))
- {
- parse_rdf_lang_tag (child, &title, &best_match_title);
- }
- else if (xmlStrEqual (child->name, (xmlChar *) "link") &&
- !use_smartlink)
- {
- parse_rdf_lang_tag (child, &link, &best_match_link);
- }
- else if (child->ns &&
- xmlStrEqual (child->ns->prefix, (xmlChar *) "ephy") &&
- xmlStrEqual (child->name, (xmlChar *) "smartlink"))
- {
- if (!use_smartlink)
- {
- use_smartlink = TRUE;
- best_match_link = INT_MAX;
- }
-
- parse_rdf_lang_tag (child, &link, &best_match_link);
- }
- else if (child->ns &&
- xmlStrEqual (child->ns->prefix, (xmlChar *) "dc") &&
- xmlStrEqual (child->name, (xmlChar *) "subject"))
- {
- subject = xmlNodeGetContent (child);
- if (subject)
- subjects = g_list_prepend (subjects, subject);
- }
-
- child = child->next;
- }
-
- if (link)
- bmk = bookmark_add (bookmarks, (char *) title, (char *) link);
-
- if (bmk)
- {
- l = subjects;
- }
-
- for (; l != NULL; l = l->next)
- {
- char *topic_name = l->data;
- EphyNode *topic;
-
- topic = ephy_bookmarks_find_keyword (bookmarks, topic_name, FALSE);
-
- if (topic == NULL)
- {
- topic = ephy_bookmarks_add_keyword (bookmarks, topic_name);
- }
-
- if (topic != NULL)
- {
- ephy_bookmarks_set_keyword (bookmarks, topic, bmk);
- }
- }
-
- xmlFree (title);
- xmlFree (link);
-
- g_list_foreach (subjects, (GFunc)xmlFree, NULL);
- g_list_free (subjects);
+ xmlChar *title = NULL;
+ int best_match_title = INT_MAX;
+ xmlChar *link = NULL;
+ int best_match_link = INT_MAX;
+ /* we consider that it's better to use a non-localized smart link than
+ * a localized link */
+ gboolean use_smartlink = FALSE;
+ xmlChar *subject = NULL;
+ GList *subjects = NULL, *l = NULL;
+ xmlNode *child;
+ EphyNode *bmk = NULL;
+
+ child = node->children;
+
+ link = xmlGetProp (node, (xmlChar *)"about");
+
+ while (child != NULL) {
+ if (xmlStrEqual (child->name, (xmlChar *)"title")) {
+ parse_rdf_lang_tag (child, &title, &best_match_title);
+ } else if (xmlStrEqual (child->name, (xmlChar *)"link") &&
+ !use_smartlink) {
+ parse_rdf_lang_tag (child, &link, &best_match_link);
+ } else if (child->ns &&
+ xmlStrEqual (child->ns->prefix, (xmlChar *)"ephy") &&
+ xmlStrEqual (child->name, (xmlChar *)"smartlink")) {
+ if (!use_smartlink) {
+ use_smartlink = TRUE;
+ best_match_link = INT_MAX;
+ }
+
+ parse_rdf_lang_tag (child, &link, &best_match_link);
+ } else if (child->ns &&
+ xmlStrEqual (child->ns->prefix, (xmlChar *)"dc") &&
+ xmlStrEqual (child->name, (xmlChar *)"subject")) {
+ subject = xmlNodeGetContent (child);
+ if (subject)
+ subjects = g_list_prepend (subjects, subject);
+ }
+
+ child = child->next;
+ }
+
+ if (link)
+ bmk = bookmark_add (bookmarks, (char *)title, (char *)link);
+
+ if (bmk) {
+ l = subjects;
+ }
+
+ for (; l != NULL; l = l->next) {
+ char *topic_name = l->data;
+ EphyNode *topic;
+
+ topic = ephy_bookmarks_find_keyword (bookmarks, topic_name, FALSE);
+
+ if (topic == NULL) {
+ topic = ephy_bookmarks_add_keyword (bookmarks, topic_name);
+ }
+
+ if (topic != NULL) {
+ ephy_bookmarks_set_keyword (bookmarks, topic, bmk);
+ }
+ }
+
+ xmlFree (title);
+ xmlFree (link);
+
+ g_list_foreach (subjects, (GFunc)xmlFree, NULL);
+ g_list_free (subjects);
}
gboolean
ephy_bookmarks_import_rdf (EphyBookmarks *bookmarks,
- const char *filename)
+ const char *filename)
{
- xmlDocPtr doc;
- xmlNodePtr child;
- xmlNodePtr root;
+ xmlDocPtr doc;
+ xmlNodePtr child;
+ xmlNodePtr root;
- if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
- EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING))
- return FALSE;
+ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING))
+ return FALSE;
- if (g_file_test (filename, G_FILE_TEST_EXISTS) == FALSE)
- return FALSE;
+ if (g_file_test (filename, G_FILE_TEST_EXISTS) == FALSE)
+ return FALSE;
- doc = xmlParseFile (filename);
- if (doc == NULL)
- {
- /* FIXME: maybe put up a warning dialogue here, because this
- * is a severe dataloss?
- */
- g_warning ("Failed to re-import the bookmarks. All bookmarks lost!\n");
- return FALSE;
- }
+ doc = xmlParseFile (filename);
+ if (doc == NULL) {
+ /* FIXME: maybe put up a warning dialogue here, because this
+ * is a severe dataloss?
+ */
+ g_warning ("Failed to re-import the bookmarks. All bookmarks lost!\n");
+ return FALSE;
+ }
- root = xmlDocGetRootElement (doc);
+ root = xmlDocGetRootElement (doc);
- child = root->children;
+ child = root->children;
- while (child != NULL)
- {
- if (xmlStrEqual (child->name, (xmlChar *) "item"))
- {
- parse_rdf_item (bookmarks, child);
- }
+ while (child != NULL) {
+ if (xmlStrEqual (child->name, (xmlChar *)"item")) {
+ parse_rdf_item (bookmarks, child);
+ }
- child = child->next;
- }
+ child = child->next;
+ }
- xmlFreeDoc (doc);
+ xmlFreeDoc (doc);
- return TRUE;
+ return TRUE;
}
diff --git a/src/bookmarks/ephy-bookmarks-menu.c b/src/bookmarks/ephy-bookmarks-menu.c
index 4a4da38..e6cd7d5 100644
--- a/src/bookmarks/ephy-bookmarks-menu.c
+++ b/src/bookmarks/ephy-bookmarks-menu.c
@@ -37,33 +37,31 @@
#define MIN_MENU_SIZE 3
#define MAX_MENU_SIZE 21
-enum
-{
- BUILD_SUBDIVIS = 1 << 0,
- BUILD_SUBMENUS = 1 << 1,
- BUILD_CHILD_SUBDIVIS = 1 << 2,
- BUILD_CHILD_SUBMENUS = 1 << 3
+enum {
+ BUILD_SUBDIVIS = 1 << 0,
+ BUILD_SUBMENUS = 1 << 1,
+ BUILD_CHILD_SUBDIVIS = 1 << 2,
+ BUILD_CHILD_SUBMENUS = 1 << 3
};
/* Construct a block of bookmark actions. Note that no bookmark action appears
* more than once in a menu, so no need to supply names. */
static void
-append_bookmarks (GString *string,
- const GPtrArray *bookmarks)
+append_bookmarks (GString *string,
+ const GPtrArray *bookmarks)
{
- EphyNode *child;
- char name[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE];
+ EphyNode *child;
+ char name[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE];
+
+ long i;
- long i;
-
- for (i = 0; i < bookmarks->len; i++)
- {
- child = g_ptr_array_index (bookmarks, i);
+ for (i = 0; i < bookmarks->len; i++) {
+ child = g_ptr_array_index (bookmarks, i);
- EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, child);
+ EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, child);
- g_string_append_printf (string, "<menuitem action=\"%s\"/>", name);
- }
+ g_string_append_printf (string, "<menuitem action=\"%s\"/>", name);
+ }
}
/* Build a menu of the given bookmarks categorised by the given topics.
@@ -71,193 +69,175 @@ append_bookmarks (GString *string,
static void
append_menu (GString *string, const GPtrArray *topics, const GPtrArray *bookmarks, guint flags)
{
- GPtrArray *uncovered;
- guint i, j;
-
- gboolean use_subdivis = flags & BUILD_SUBDIVIS;
- gboolean use_submenus = flags & BUILD_SUBMENUS;
-
- if (use_subdivis || use_submenus)
- {
- GPtrArray *subset, *covering, *subdivisions, *submenus, *unused;
- GArray *sizes = 0;
- EphyNode *topic;
- gint size, total;
- gboolean separate = FALSE;
- char name[EPHY_TOPIC_ACTION_NAME_BUFFER_SIZE];
-
- /* Get the subtopics, uncovered bookmarks, and subtopic sizes. */
- sizes = g_array_sized_new (FALSE, FALSE, sizeof(int), topics->len);
- uncovered = g_ptr_array_sized_new (bookmarks->len);
- covering = ephy_nodes_get_covering (topics, bookmarks, 0, uncovered, sizes);
-
- /* Preallocate arrays for submenus, subdivisions, and bookmark subsets. */
- subdivisions = g_ptr_array_sized_new (topics->len);
- submenus = g_ptr_array_sized_new (topics->len);
- subset = g_ptr_array_sized_new (bookmarks->len);
- unused = g_ptr_array_sized_new (bookmarks->len);
-
- /* Get the total number of items in the menu. */
- total = uncovered->len;
- for (i = 0; i < covering->len; i++)
- total += g_array_index (sizes, int, i);
-
- /* Seperate covering into list of submenus and subdivisions */
- for (i = 0; i < covering->len; i++)
- {
- topic = g_ptr_array_index (covering, i);
- size = g_array_index (sizes, int, i);
-
- if (!use_submenus || (use_subdivis && (size < MIN_MENU_SIZE || total <
MAX_MENU_SIZE)))
- {
- g_ptr_array_add (subdivisions, topic);
- }
- else
- {
- g_ptr_array_add (submenus, topic);
- total = total - size + 1;
- }
- }
-
- /* Sort the list of submenus and subdivisions. */
- g_ptr_array_sort (submenus, ephy_bookmarks_compare_topic_pointers);
- g_ptr_array_sort (subdivisions, ephy_bookmarks_compare_topic_pointers);
-
- if (flags & BUILD_CHILD_SUBDIVIS) flags |= BUILD_SUBDIVIS;
- if (flags & BUILD_CHILD_SUBMENUS) flags |= BUILD_SUBMENUS;
-
- /* Create each of the submenus. */
- for (i = 0; i < submenus->len; i++)
- {
- topic = g_ptr_array_index (submenus, i);
- ephy_nodes_get_covered (topic, bookmarks, subset);
-
- EPHY_TOPIC_ACTION_NAME_PRINTF (name, topic);
-
- g_string_append_printf (string, "<menu action=\"%s\">",
- name);
- append_menu (string, topics, subset, flags);
- g_string_append (string, "</menu>");
- separate = TRUE;
- }
-
- /* Build a list of bookmarks which don't appear in any subdivision yet. */
- for (i = 0; i < bookmarks->len; i++)
- {
- g_ptr_array_add (unused, g_ptr_array_index (bookmarks, i));
- }
-
- /* Create each of the subdivisions. */
- for (i = 0; i < subdivisions->len; i++)
- {
- topic = g_ptr_array_index (subdivisions, i);
- ephy_nodes_get_covered (topic, unused, subset);
- g_ptr_array_sort (subset, ephy_bookmarks_compare_bookmark_pointers);
-
- if (separate) g_string_append (string, "<separator/>");
- append_bookmarks (string, subset);
- separate = TRUE;
-
- /* Record that each bookmark has been added. */
- for (j = 0; j < subset->len; j++)
- {
- g_ptr_array_remove_fast (unused, g_ptr_array_index (subset, j));
- }
- }
-
- g_array_free (sizes, TRUE);
- g_ptr_array_free (covering, TRUE);
- g_ptr_array_free (subdivisions, TRUE);
- g_ptr_array_free (submenus, TRUE);
- g_ptr_array_free (subset, TRUE);
- g_ptr_array_free (unused, TRUE);
-
- if (separate && uncovered->len) g_string_append (string, "<separator/>");
- }
- else
- {
- uncovered = g_ptr_array_sized_new (bookmarks->len);
- for (i = 0; i < bookmarks->len; i++)
- g_ptr_array_add (uncovered, g_ptr_array_index (bookmarks, i));
- g_ptr_array_sort (uncovered, ephy_bookmarks_compare_bookmark_pointers);
- }
-
- /* Create the final subdivision (uncovered bookmarks). */
- g_ptr_array_sort (uncovered, ephy_bookmarks_compare_bookmark_pointers);
- append_bookmarks (string, uncovered);
- g_ptr_array_free (uncovered, TRUE);
+ GPtrArray *uncovered;
+ guint i, j;
+
+ gboolean use_subdivis = flags & BUILD_SUBDIVIS;
+ gboolean use_submenus = flags & BUILD_SUBMENUS;
+
+ if (use_subdivis || use_submenus) {
+ GPtrArray *subset, *covering, *subdivisions, *submenus, *unused;
+ GArray *sizes = 0;
+ EphyNode *topic;
+ gint size, total;
+ gboolean separate = FALSE;
+ char name[EPHY_TOPIC_ACTION_NAME_BUFFER_SIZE];
+
+ /* Get the subtopics, uncovered bookmarks, and subtopic sizes. */
+ sizes = g_array_sized_new (FALSE, FALSE, sizeof (int), topics->len);
+ uncovered = g_ptr_array_sized_new (bookmarks->len);
+ covering = ephy_nodes_get_covering (topics, bookmarks, 0, uncovered, sizes);
+
+ /* Preallocate arrays for submenus, subdivisions, and bookmark subsets. */
+ subdivisions = g_ptr_array_sized_new (topics->len);
+ submenus = g_ptr_array_sized_new (topics->len);
+ subset = g_ptr_array_sized_new (bookmarks->len);
+ unused = g_ptr_array_sized_new (bookmarks->len);
+
+ /* Get the total number of items in the menu. */
+ total = uncovered->len;
+ for (i = 0; i < covering->len; i++)
+ total += g_array_index (sizes, int, i);
+
+ /* Seperate covering into list of submenus and subdivisions */
+ for (i = 0; i < covering->len; i++) {
+ topic = g_ptr_array_index (covering, i);
+ size = g_array_index (sizes, int, i);
+
+ if (!use_submenus || (use_subdivis && (size < MIN_MENU_SIZE || total < MAX_MENU_SIZE))) {
+ g_ptr_array_add (subdivisions, topic);
+ } else {
+ g_ptr_array_add (submenus, topic);
+ total = total - size + 1;
+ }
+ }
+
+ /* Sort the list of submenus and subdivisions. */
+ g_ptr_array_sort (submenus, ephy_bookmarks_compare_topic_pointers);
+ g_ptr_array_sort (subdivisions, ephy_bookmarks_compare_topic_pointers);
+
+ if (flags & BUILD_CHILD_SUBDIVIS) flags |= BUILD_SUBDIVIS;
+ if (flags & BUILD_CHILD_SUBMENUS) flags |= BUILD_SUBMENUS;
+
+ /* Create each of the submenus. */
+ for (i = 0; i < submenus->len; i++) {
+ topic = g_ptr_array_index (submenus, i);
+ ephy_nodes_get_covered (topic, bookmarks, subset);
+
+ EPHY_TOPIC_ACTION_NAME_PRINTF (name, topic);
+
+ g_string_append_printf (string, "<menu action=\"%s\">",
+ name);
+ append_menu (string, topics, subset, flags);
+ g_string_append (string, "</menu>");
+ separate = TRUE;
+ }
+
+ /* Build a list of bookmarks which don't appear in any subdivision yet. */
+ for (i = 0; i < bookmarks->len; i++) {
+ g_ptr_array_add (unused, g_ptr_array_index (bookmarks, i));
+ }
+
+ /* Create each of the subdivisions. */
+ for (i = 0; i < subdivisions->len; i++) {
+ topic = g_ptr_array_index (subdivisions, i);
+ ephy_nodes_get_covered (topic, unused, subset);
+ g_ptr_array_sort (subset, ephy_bookmarks_compare_bookmark_pointers);
+
+ if (separate) g_string_append (string, "<separator/>");
+ append_bookmarks (string, subset);
+ separate = TRUE;
+
+ /* Record that each bookmark has been added. */
+ for (j = 0; j < subset->len; j++) {
+ g_ptr_array_remove_fast (unused, g_ptr_array_index (subset, j));
+ }
+ }
+
+ g_array_free (sizes, TRUE);
+ g_ptr_array_free (covering, TRUE);
+ g_ptr_array_free (subdivisions, TRUE);
+ g_ptr_array_free (submenus, TRUE);
+ g_ptr_array_free (subset, TRUE);
+ g_ptr_array_free (unused, TRUE);
+
+ if (separate && uncovered->len) g_string_append (string, "<separator/>");
+ } else {
+ uncovered = g_ptr_array_sized_new (bookmarks->len);
+ for (i = 0; i < bookmarks->len; i++)
+ g_ptr_array_add (uncovered, g_ptr_array_index (bookmarks, i));
+ g_ptr_array_sort (uncovered, ephy_bookmarks_compare_bookmark_pointers);
+ }
+
+ /* Create the final subdivision (uncovered bookmarks). */
+ g_ptr_array_sort (uncovered, ephy_bookmarks_compare_bookmark_pointers);
+ append_bookmarks (string, uncovered);
+ g_ptr_array_free (uncovered, TRUE);
}
void
ephy_bookmarks_menu_build (GString *string, EphyNode *parent)
{
- GPtrArray *children, *topics;
- EphyBookmarks *eb;
- EphyNode *node;
- gint priority;
- guint flags, id, i;
-
- eb = ephy_shell_get_bookmarks (ephy_shell_get_default ());
-
- children = ephy_node_get_children (ephy_bookmarks_get_keywords (eb));
- topics = g_ptr_array_sized_new (children->len);
- for (i = 0; i < children->len; i++)
- {
- node = g_ptr_array_index (children, i);
- priority = ephy_node_get_property_int (node, EPHY_NODE_KEYWORD_PROP_PRIORITY);
- if (priority == EPHY_NODE_NORMAL_PRIORITY)
- g_ptr_array_add (topics, node);
- }
-
- /* If no parent was supplied, use the default 'All' */
- node = parent ? parent : ephy_bookmarks_get_bookmarks(eb);
- children = ephy_node_get_children (node);
-
- /* Determine what kind of menu we want. */
- id = ephy_node_get_id (node);
- switch(id)
- {
- case FAVORITES_NODE_ID:
- flags = 0;
- break;
- case BOOKMARKS_NODE_ID:
- flags = BUILD_SUBMENUS | BUILD_CHILD_SUBDIVIS;
- break;
- default:
- flags = BUILD_SUBMENUS | BUILD_SUBDIVIS | BUILD_CHILD_SUBDIVIS;
- /* flags = BUILD_SUBDIVIS; */
- break;
- }
-
- /* If this menu is the 'All' menu, be sure to include the 'local' topic. */
- if (id == BOOKMARKS_NODE_ID)
- {
- EphyNode *local_node;
-
- local_node = ephy_bookmarks_get_local (eb);
- if (local_node != NULL)
- {
- g_ptr_array_add (topics, ephy_bookmarks_get_local (eb));
- }
-
- append_menu (string, topics, children, flags);
- g_ptr_array_free (topics, TRUE);
- }
-
- /* Otherwise, build the menu with "Open in tabs". */
- else
- {
- char name[EPHY_OPEN_TABS_ACTION_NAME_BUFFER_SIZE];
-
- append_menu (string, topics, children, flags);
- g_ptr_array_free (topics, TRUE);
-
- if (children->len > 1)
- {
- EPHY_OPEN_TABS_ACTION_NAME_PRINTF (name, node);
-
- g_string_append_printf
- (string, "<separator/><menuitem action=\"%s\" name=\"OpenTabs\"/>", name);
- }
- }
+ GPtrArray *children, *topics;
+ EphyBookmarks *eb;
+ EphyNode *node;
+ gint priority;
+ guint flags, id, i;
+
+ eb = ephy_shell_get_bookmarks (ephy_shell_get_default ());
+
+ children = ephy_node_get_children (ephy_bookmarks_get_keywords (eb));
+ topics = g_ptr_array_sized_new (children->len);
+ for (i = 0; i < children->len; i++) {
+ node = g_ptr_array_index (children, i);
+ priority = ephy_node_get_property_int (node, EPHY_NODE_KEYWORD_PROP_PRIORITY);
+ if (priority == EPHY_NODE_NORMAL_PRIORITY)
+ g_ptr_array_add (topics, node);
+ }
+
+ /* If no parent was supplied, use the default 'All' */
+ node = parent ? parent : ephy_bookmarks_get_bookmarks (eb);
+ children = ephy_node_get_children (node);
+
+ /* Determine what kind of menu we want. */
+ id = ephy_node_get_id (node);
+ switch (id) {
+ case FAVORITES_NODE_ID:
+ flags = 0;
+ break;
+ case BOOKMARKS_NODE_ID:
+ flags = BUILD_SUBMENUS | BUILD_CHILD_SUBDIVIS;
+ break;
+ default:
+ flags = BUILD_SUBMENUS | BUILD_SUBDIVIS | BUILD_CHILD_SUBDIVIS;
+ /* flags = BUILD_SUBDIVIS; */
+ break;
+ }
+
+ /* If this menu is the 'All' menu, be sure to include the 'local' topic. */
+ if (id == BOOKMARKS_NODE_ID) {
+ EphyNode *local_node;
+
+ local_node = ephy_bookmarks_get_local (eb);
+ if (local_node != NULL) {
+ g_ptr_array_add (topics, ephy_bookmarks_get_local (eb));
+ }
+
+ append_menu (string, topics, children, flags);
+ g_ptr_array_free (topics, TRUE);
+ }
+ /* Otherwise, build the menu with "Open in tabs". */
+ else {
+ char name[EPHY_OPEN_TABS_ACTION_NAME_BUFFER_SIZE];
+
+ append_menu (string, topics, children, flags);
+ g_ptr_array_free (topics, TRUE);
+
+ if (children->len > 1) {
+ EPHY_OPEN_TABS_ACTION_NAME_PRINTF (name, node);
+
+ g_string_append_printf
+ (string, "<separator/><menuitem action=\"%s\" name=\"OpenTabs\"/>", name);
+ }
+ }
}
diff --git a/src/bookmarks/ephy-bookmarks-ui.c b/src/bookmarks/ephy-bookmarks-ui.c
index 2dc619a..465ca40 100644
--- a/src/bookmarks/ephy-bookmarks-ui.c
+++ b/src/bookmarks/ephy-bookmarks-ui.c
@@ -46,317 +46,307 @@
#define BM_WINDOW_DATA_KEY "bookmarks-window-data"
-typedef struct
-{
- guint bookmarks_menu;
- guint toolbar_menu;
+typedef struct {
+ guint bookmarks_menu;
+ guint toolbar_menu;
} BookmarksWindowData;
-enum
-{
- RESPONSE_SHOW_PROPERTIES = 1,
- RESPONSE_NEW_BOOKMARK = 2
+enum {
+ RESPONSE_SHOW_PROPERTIES = 1,
+ RESPONSE_NEW_BOOKMARK = 2
};
-static GString * bookmarks_menu_string = 0;
+static GString *bookmarks_menu_string = 0;
static GHashTable *properties_dialogs = 0;
static GtkAction *
find_action (GtkUIManager *manager, const char *name)
{
- GList *l = gtk_ui_manager_get_action_groups (manager);
- GtkAction *action;
-
- while (l != NULL)
- {
- action = gtk_action_group_get_action (GTK_ACTION_GROUP (l->data), name);
- if (action) return action;
- l = l->next;
- }
-
- return NULL;
+ GList *l = gtk_ui_manager_get_action_groups (manager);
+ GtkAction *action;
+
+ while (l != NULL) {
+ action = gtk_action_group_get_action (GTK_ACTION_GROUP (l->data), name);
+ if (action) return action;
+ l = l->next;
+ }
+
+ return NULL;
}
static void
activate_bookmarks_menu (GtkAction *action, EphyWindow *window)
{
- BookmarksWindowData *data = g_object_get_data (G_OBJECT (window), BM_WINDOW_DATA_KEY);
- if (data && !data->bookmarks_menu)
- {
- GtkUIManager *manager = ephy_window_get_ui_manager (window);
- gtk_ui_manager_ensure_update (manager);
-
- if (!bookmarks_menu_string->len)
- {
- g_string_append (bookmarks_menu_string,
- "<ui><popup name=\"PagePopup\" action=\"PagePopupAction\"><menu
name=\"BookmarksMenu\" action=\"Bookmarks\">");
- ephy_bookmarks_menu_build (bookmarks_menu_string, 0);
- g_string_append (bookmarks_menu_string, "</menu></popup></ui>");
- }
-
- data->bookmarks_menu = gtk_ui_manager_add_ui_from_string
- (manager, bookmarks_menu_string->str, bookmarks_menu_string->len, 0);
-
- gtk_ui_manager_ensure_update (manager);
- }
+ BookmarksWindowData *data = g_object_get_data (G_OBJECT (window), BM_WINDOW_DATA_KEY);
+ if (data && !data->bookmarks_menu) {
+ GtkUIManager *manager = ephy_window_get_ui_manager (window);
+ gtk_ui_manager_ensure_update (manager);
+
+ if (!bookmarks_menu_string->len) {
+ g_string_append (bookmarks_menu_string,
+ "<ui><popup name=\"PagePopup\" action=\"PagePopupAction\"><menu
name=\"BookmarksMenu\" action=\"Bookmarks\">");
+ ephy_bookmarks_menu_build (bookmarks_menu_string, 0);
+ g_string_append (bookmarks_menu_string, "</menu></popup></ui>");
+ }
+
+ data->bookmarks_menu = gtk_ui_manager_add_ui_from_string
+ (manager, bookmarks_menu_string->str, bookmarks_menu_string->len, 0);
+
+ gtk_ui_manager_ensure_update (manager);
+ }
}
static void
erase_bookmarks_menu (EphyWindow *window)
{
- BookmarksWindowData *data;
- GtkUIManager *manager;
+ BookmarksWindowData *data;
+ GtkUIManager *manager;
- manager = ephy_window_get_ui_manager (window);
- data = g_object_get_data (G_OBJECT (window), BM_WINDOW_DATA_KEY);
+ manager = ephy_window_get_ui_manager (window);
+ data = g_object_get_data (G_OBJECT (window), BM_WINDOW_DATA_KEY);
- if (data != NULL && data->bookmarks_menu != 0)
- {
- gtk_ui_manager_remove_ui (manager, data->bookmarks_menu);
- data->bookmarks_menu = 0;
- }
+ if (data != NULL && data->bookmarks_menu != 0) {
+ gtk_ui_manager_remove_ui (manager, data->bookmarks_menu);
+ data->bookmarks_menu = 0;
+ }
- g_string_truncate (bookmarks_menu_string, 0);
+ g_string_truncate (bookmarks_menu_string, 0);
}
static void
tree_changed_cb (EphyBookmarks *bookmarks,
- EphyWindow *window)
+ EphyWindow *window)
{
- erase_bookmarks_menu (window);
+ erase_bookmarks_menu (window);
}
static void
-node_added_cb (EphyNode *parent,
- EphyNode *child,
- EphyWindow *window)
+node_added_cb (EphyNode *parent,
+ EphyNode *child,
+ EphyWindow *window)
{
- erase_bookmarks_menu (window);
+ erase_bookmarks_menu (window);
}
static void
-node_changed_cb (EphyNode *parent,
- EphyNode *child,
- guint property_id,
- EphyWindow *window)
+node_changed_cb (EphyNode *parent,
+ EphyNode *child,
+ guint property_id,
+ EphyWindow *window)
{
- if (property_id == EPHY_NODE_KEYWORD_PROP_NAME ||
- property_id == EPHY_NODE_BMK_PROP_TITLE)
- {
- erase_bookmarks_menu (window);
- }
+ if (property_id == EPHY_NODE_KEYWORD_PROP_NAME ||
+ property_id == EPHY_NODE_BMK_PROP_TITLE) {
+ erase_bookmarks_menu (window);
+ }
}
static void
-node_removed_cb (EphyNode *parent,
- EphyNode *child,
- guint index,
- EphyWindow *window)
+node_removed_cb (EphyNode *parent,
+ EphyNode *child,
+ guint index,
+ EphyWindow *window)
{
- erase_bookmarks_menu (window);
+ erase_bookmarks_menu (window);
}
void
ephy_bookmarks_ui_attach_window (EphyWindow *window)
{
- EphyBookmarks *eb;
- EphyNode *bookmarks;
- EphyNode *topics;
- BookmarksWindowData *data;
- GtkUIManager *manager;
- GtkActionGroup *actions;
- GtkAction *action;
-
- eb = ephy_shell_get_bookmarks (ephy_shell_get_default ());
- bookmarks = ephy_bookmarks_get_bookmarks (eb);
- topics = ephy_bookmarks_get_keywords (eb);
- data = g_object_get_data (G_OBJECT (window), BM_WINDOW_DATA_KEY);
- g_return_if_fail (data == NULL);
-
- manager = ephy_window_get_ui_manager (window);
-
- data = g_new0 (BookmarksWindowData, 1);
- g_object_set_data_full (G_OBJECT (window), BM_WINDOW_DATA_KEY, data, g_free);
-
- /* Create the self-maintaining action groups for bookmarks and topics */
- actions = ephy_bookmark_group_new (bookmarks);
- gtk_ui_manager_insert_action_group (manager, actions, -1);
- g_signal_connect_object (actions, "open-link",
- G_CALLBACK (ephy_link_open), G_OBJECT (window),
- G_CONNECT_SWAPPED | G_CONNECT_AFTER);
- g_object_unref (actions);
-
- actions = ephy_topic_action_group_new (topics, manager);
- gtk_ui_manager_insert_action_group (manager, actions, -1);
- g_object_unref (actions);
-
- actions = ephy_open_tabs_group_new (topics);
- gtk_ui_manager_insert_action_group (manager, actions, -1);
- g_signal_connect_object (actions, "open-link",
- G_CALLBACK (ephy_link_open), G_OBJECT (window),
- G_CONNECT_SWAPPED | G_CONNECT_AFTER);
- g_object_unref (actions);
-
- /* Add signal handlers for the bookmark database */
- ephy_node_signal_connect_object (bookmarks, EPHY_NODE_CHILD_ADDED,
- (EphyNodeCallback)node_added_cb,
- G_OBJECT (window));
- ephy_node_signal_connect_object (topics, EPHY_NODE_CHILD_ADDED,
- (EphyNodeCallback)node_added_cb,
- G_OBJECT (window));
-
- ephy_node_signal_connect_object (bookmarks, EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback)node_removed_cb,
- G_OBJECT (window));
- ephy_node_signal_connect_object (topics, EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback)node_removed_cb,
- G_OBJECT (window));
-
- ephy_node_signal_connect_object (bookmarks, EPHY_NODE_CHILD_CHANGED,
- (EphyNodeCallback)node_changed_cb,
- G_OBJECT (window));
- ephy_node_signal_connect_object (topics, EPHY_NODE_CHILD_CHANGED,
- (EphyNodeCallback)node_changed_cb,
- G_OBJECT (window));
-
- g_signal_connect_object (eb, "tree_changed",
- G_CALLBACK (tree_changed_cb),
- G_OBJECT (window), 0);
-
- /* Setup empty menu strings and add signal handlers to build the menus on demand */
- if (!bookmarks_menu_string)
- bookmarks_menu_string = g_string_new ("");
-
- action = find_action (manager, "Bookmarks");
- g_signal_connect_object (action, "activate",
- G_CALLBACK (activate_bookmarks_menu),
- G_OBJECT (window), 0);
+ EphyBookmarks *eb;
+ EphyNode *bookmarks;
+ EphyNode *topics;
+ BookmarksWindowData *data;
+ GtkUIManager *manager;
+ GtkActionGroup *actions;
+ GtkAction *action;
+
+ eb = ephy_shell_get_bookmarks (ephy_shell_get_default ());
+ bookmarks = ephy_bookmarks_get_bookmarks (eb);
+ topics = ephy_bookmarks_get_keywords (eb);
+ data = g_object_get_data (G_OBJECT (window), BM_WINDOW_DATA_KEY);
+ g_return_if_fail (data == NULL);
+
+ manager = ephy_window_get_ui_manager (window);
+
+ data = g_new0 (BookmarksWindowData, 1);
+ g_object_set_data_full (G_OBJECT (window), BM_WINDOW_DATA_KEY, data, g_free);
+
+ /* Create the self-maintaining action groups for bookmarks and topics */
+ actions = ephy_bookmark_group_new (bookmarks);
+ gtk_ui_manager_insert_action_group (manager, actions, -1);
+ g_signal_connect_object (actions, "open-link",
+ G_CALLBACK (ephy_link_open), G_OBJECT (window),
+ G_CONNECT_SWAPPED | G_CONNECT_AFTER);
+ g_object_unref (actions);
+
+ actions = ephy_topic_action_group_new (topics, manager);
+ gtk_ui_manager_insert_action_group (manager, actions, -1);
+ g_object_unref (actions);
+
+ actions = ephy_open_tabs_group_new (topics);
+ gtk_ui_manager_insert_action_group (manager, actions, -1);
+ g_signal_connect_object (actions, "open-link",
+ G_CALLBACK (ephy_link_open), G_OBJECT (window),
+ G_CONNECT_SWAPPED | G_CONNECT_AFTER);
+ g_object_unref (actions);
+
+ /* Add signal handlers for the bookmark database */
+ ephy_node_signal_connect_object (bookmarks, EPHY_NODE_CHILD_ADDED,
+ (EphyNodeCallback)node_added_cb,
+ G_OBJECT (window));
+ ephy_node_signal_connect_object (topics, EPHY_NODE_CHILD_ADDED,
+ (EphyNodeCallback)node_added_cb,
+ G_OBJECT (window));
+
+ ephy_node_signal_connect_object (bookmarks, EPHY_NODE_CHILD_REMOVED,
+ (EphyNodeCallback)node_removed_cb,
+ G_OBJECT (window));
+ ephy_node_signal_connect_object (topics, EPHY_NODE_CHILD_REMOVED,
+ (EphyNodeCallback)node_removed_cb,
+ G_OBJECT (window));
+
+ ephy_node_signal_connect_object (bookmarks, EPHY_NODE_CHILD_CHANGED,
+ (EphyNodeCallback)node_changed_cb,
+ G_OBJECT (window));
+ ephy_node_signal_connect_object (topics, EPHY_NODE_CHILD_CHANGED,
+ (EphyNodeCallback)node_changed_cb,
+ G_OBJECT (window));
+
+ g_signal_connect_object (eb, "tree_changed",
+ G_CALLBACK (tree_changed_cb),
+ G_OBJECT (window), 0);
+
+ /* Setup empty menu strings and add signal handlers to build the menus on demand */
+ if (!bookmarks_menu_string)
+ bookmarks_menu_string = g_string_new ("");
+
+ action = find_action (manager, "Bookmarks");
+ g_signal_connect_object (action, "activate",
+ G_CALLBACK (activate_bookmarks_menu),
+ G_OBJECT (window), 0);
}
void
ephy_bookmarks_ui_detach_window (EphyWindow *window)
{
- EphyBookmarks *eb = ephy_shell_get_bookmarks (ephy_shell_get_default ());
- EphyNode *bookmarks = ephy_bookmarks_get_bookmarks (eb);
- EphyNode *topics = ephy_bookmarks_get_keywords (eb);
-
- BookmarksWindowData *data = g_object_get_data (G_OBJECT (window), BM_WINDOW_DATA_KEY);
- GtkUIManager *manager = ephy_window_get_ui_manager (window);
- GtkAction *action;
-
- g_return_if_fail (data != 0);
-
- if (data->bookmarks_menu)
- gtk_ui_manager_remove_ui (manager, data->bookmarks_menu);
-
- g_object_set_data (G_OBJECT (window), BM_WINDOW_DATA_KEY, 0);
-
- ephy_node_signal_disconnect_object (bookmarks, EPHY_NODE_CHILD_ADDED,
- (EphyNodeCallback)node_added_cb,
- G_OBJECT (window));
- ephy_node_signal_disconnect_object (topics, EPHY_NODE_CHILD_ADDED,
- (EphyNodeCallback)node_added_cb,
- G_OBJECT (window));
-
- ephy_node_signal_disconnect_object (bookmarks, EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback)node_removed_cb,
- G_OBJECT (window));
- ephy_node_signal_disconnect_object (topics, EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback)node_removed_cb,
- G_OBJECT (window));
-
- ephy_node_signal_disconnect_object (bookmarks, EPHY_NODE_CHILD_CHANGED,
- (EphyNodeCallback)node_changed_cb,
- G_OBJECT (window));
- ephy_node_signal_disconnect_object (topics, EPHY_NODE_CHILD_CHANGED,
- (EphyNodeCallback)node_changed_cb,
- G_OBJECT (window));
-
- g_signal_handlers_disconnect_by_func
- (G_OBJECT (eb), G_CALLBACK (tree_changed_cb), G_OBJECT (window));
-
- action = find_action (manager, "Bookmarks");
- g_signal_handlers_disconnect_by_func
- (G_OBJECT (action), G_CALLBACK (activate_bookmarks_menu), G_OBJECT (window));
+ EphyBookmarks *eb = ephy_shell_get_bookmarks (ephy_shell_get_default ());
+ EphyNode *bookmarks = ephy_bookmarks_get_bookmarks (eb);
+ EphyNode *topics = ephy_bookmarks_get_keywords (eb);
+
+ BookmarksWindowData *data = g_object_get_data (G_OBJECT (window), BM_WINDOW_DATA_KEY);
+ GtkUIManager *manager = ephy_window_get_ui_manager (window);
+ GtkAction *action;
+
+ g_return_if_fail (data != 0);
+
+ if (data->bookmarks_menu)
+ gtk_ui_manager_remove_ui (manager, data->bookmarks_menu);
+
+ g_object_set_data (G_OBJECT (window), BM_WINDOW_DATA_KEY, 0);
+
+ ephy_node_signal_disconnect_object (bookmarks, EPHY_NODE_CHILD_ADDED,
+ (EphyNodeCallback)node_added_cb,
+ G_OBJECT (window));
+ ephy_node_signal_disconnect_object (topics, EPHY_NODE_CHILD_ADDED,
+ (EphyNodeCallback)node_added_cb,
+ G_OBJECT (window));
+
+ ephy_node_signal_disconnect_object (bookmarks, EPHY_NODE_CHILD_REMOVED,
+ (EphyNodeCallback)node_removed_cb,
+ G_OBJECT (window));
+ ephy_node_signal_disconnect_object (topics, EPHY_NODE_CHILD_REMOVED,
+ (EphyNodeCallback)node_removed_cb,
+ G_OBJECT (window));
+
+ ephy_node_signal_disconnect_object (bookmarks, EPHY_NODE_CHILD_CHANGED,
+ (EphyNodeCallback)node_changed_cb,
+ G_OBJECT (window));
+ ephy_node_signal_disconnect_object (topics, EPHY_NODE_CHILD_CHANGED,
+ (EphyNodeCallback)node_changed_cb,
+ G_OBJECT (window));
+
+ g_signal_handlers_disconnect_by_func
+ (G_OBJECT (eb), G_CALLBACK (tree_changed_cb), G_OBJECT (window));
+
+ action = find_action (manager, "Bookmarks");
+ g_signal_handlers_disconnect_by_func
+ (G_OBJECT (action), G_CALLBACK (activate_bookmarks_menu), G_OBJECT (window));
}
static void
properties_dialog_destroy_cb (EphyBookmarkProperties *dialog,
- EphyNode *bookmark)
+ EphyNode *bookmark)
{
- g_hash_table_remove (properties_dialogs, bookmark);
+ g_hash_table_remove (properties_dialogs, bookmark);
}
void
-ephy_bookmarks_ui_add_bookmark (GtkWindow *parent,
- const char *location,
- const char *title)
+ephy_bookmarks_ui_add_bookmark (GtkWindow *parent,
+ const char *location,
+ const char *title)
{
- EphyBookmarks *bookmarks;
- EphyNode *bookmark;
- GtkWidget *dialog;
-
- if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
- EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING))
- return;
-
- bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
- bookmark = ephy_bookmarks_add (bookmarks, title, location);
-
- if (properties_dialogs == 0)
- {
- properties_dialogs = g_hash_table_new (g_direct_hash, g_direct_equal);
- }
-
- dialog = ephy_bookmark_properties_new (bookmarks, bookmark, TRUE);
-
- g_assert (parent != NULL);
-
- gtk_window_group_add_window (ephy_gui_ensure_window_group (parent),
- GTK_WINDOW (dialog));
- gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
-
- g_signal_connect (dialog, "destroy",
- G_CALLBACK (properties_dialog_destroy_cb), bookmark);
- g_hash_table_insert (properties_dialogs,
- bookmark, dialog);
-
- gtk_window_present_with_time (GTK_WINDOW (dialog),
- gtk_get_current_event_time ());
+ EphyBookmarks *bookmarks;
+ EphyNode *bookmark;
+ GtkWidget *dialog;
+
+ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING))
+ return;
+
+ bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
+ bookmark = ephy_bookmarks_add (bookmarks, title, location);
+
+ if (properties_dialogs == 0) {
+ properties_dialogs = g_hash_table_new (g_direct_hash, g_direct_equal);
+ }
+
+ dialog = ephy_bookmark_properties_new (bookmarks, bookmark, TRUE);
+
+ g_assert (parent != NULL);
+
+ gtk_window_group_add_window (ephy_gui_ensure_window_group (parent),
+ GTK_WINDOW (dialog));
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
+
+ g_signal_connect (dialog, "destroy",
+ G_CALLBACK (properties_dialog_destroy_cb), bookmark);
+ g_hash_table_insert (properties_dialogs,
+ bookmark, dialog);
+
+ gtk_window_present_with_time (GTK_WINDOW (dialog),
+ gtk_get_current_event_time ());
}
void
ephy_bookmarks_ui_show_bookmark (GtkWindow *parent, EphyNode *bookmark)
{
- EphyBookmarks *bookmarks;
- GtkWidget *dialog;
-
- bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
-
- g_return_if_fail (EPHY_IS_BOOKMARKS (bookmarks));
- g_return_if_fail (EPHY_IS_NODE (bookmark));
-
- if (properties_dialogs == 0)
- {
- properties_dialogs = g_hash_table_new (g_direct_hash, g_direct_equal);
- }
-
- dialog = g_hash_table_lookup (properties_dialogs, bookmark);
-
- if (dialog == NULL)
- {
- dialog = ephy_bookmark_properties_new (bookmarks, bookmark, FALSE);
-
- g_signal_connect (dialog, "destroy",
- G_CALLBACK (properties_dialog_destroy_cb), bookmark);
- g_hash_table_insert (properties_dialogs,
- bookmark, dialog);
- }
-
- gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
-
- gtk_window_present_with_time (GTK_WINDOW (dialog),
- gtk_get_current_event_time ());
+ EphyBookmarks *bookmarks;
+ GtkWidget *dialog;
+
+ bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
+
+ g_return_if_fail (EPHY_IS_BOOKMARKS (bookmarks));
+ g_return_if_fail (EPHY_IS_NODE (bookmark));
+
+ if (properties_dialogs == 0) {
+ properties_dialogs = g_hash_table_new (g_direct_hash, g_direct_equal);
+ }
+
+ dialog = g_hash_table_lookup (properties_dialogs, bookmark);
+
+ if (dialog == NULL) {
+ dialog = ephy_bookmark_properties_new (bookmarks, bookmark, FALSE);
+
+ g_signal_connect (dialog, "destroy",
+ G_CALLBACK (properties_dialog_destroy_cb), bookmark);
+ g_hash_table_insert (properties_dialogs,
+ bookmark, dialog);
+ }
+
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
+
+ gtk_window_present_with_time (GTK_WINDOW (dialog),
+ gtk_get_current_event_time ());
}
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index cca581c..d00e723 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -52,55 +52,53 @@
static const char zeroconf_protos[3][6] =
{
- "http",
- "https",
- "ftp"
+ "http",
+ "https",
+ "ftp"
};
-struct _EphyBookmarks
-{
- GObject parent_instance;
-
- gboolean init_defaults;
- gboolean dirty;
- guint save_timeout_id;
- char *xml_file;
- char *rdf_file;
- EphyNodeDb *db;
- EphyNode *bookmarks;
- EphyNode *keywords;
- EphyNode *notcategorized;
- EphyNode *smartbookmarks;
- EphyNode *lower_fav;
- double lower_score;
-
- /* Local sites */
- EphyNode *local;
- GaClient *ga_client;
- GaServiceBrowser *browse_handles[G_N_ELEMENTS (zeroconf_protos)];
- GHashTable *resolve_handles;
+struct _EphyBookmarks {
+ GObject parent_instance;
+
+ gboolean init_defaults;
+ gboolean dirty;
+ guint save_timeout_id;
+ char *xml_file;
+ char *rdf_file;
+ EphyNodeDb *db;
+ EphyNode *bookmarks;
+ EphyNode *keywords;
+ EphyNode *notcategorized;
+ EphyNode *smartbookmarks;
+ EphyNode *lower_fav;
+ double lower_score;
+
+ /* Local sites */
+ EphyNode *local;
+ GaClient *ga_client;
+ GaServiceBrowser *browse_handles[G_N_ELEMENTS (zeroconf_protos)];
+ GHashTable *resolve_handles;
};
static const char *default_topics [] =
{
- N_("Entertainment"),
- N_("News"),
- N_("Shopping"),
- N_("Sports"),
- N_("Travel"),
- N_("Work")
+ N_("Entertainment"),
+ N_("News"),
+ N_("Shopping"),
+ N_("Sports"),
+ N_("Travel"),
+ N_("Work")
};
/* Signals */
-enum
-{
- TREE_CHANGED,
- LAST_SIGNAL
+enum {
+ TREE_CHANGED,
+ LAST_SIGNAL
};
static guint ephy_bookmarks_signals[LAST_SIGNAL];
-static void ephy_bookmarks_finalize (GObject *object);
+static void ephy_bookmarks_finalize (GObject *object);
static void ephy_local_bookmarks_start_client (EphyBookmarks *bookmarks);
G_DEFINE_TYPE (EphyBookmarks, ephy_bookmarks, G_TYPE_OBJECT)
@@ -108,1467 +106,1366 @@ G_DEFINE_TYPE (EphyBookmarks, ephy_bookmarks, G_TYPE_OBJECT)
static void
ephy_bookmarks_init_defaults (EphyBookmarks *eb)
{
- guint i;
+ guint i;
- for (i = 0; i < G_N_ELEMENTS (default_topics); i++)
- {
- ephy_bookmarks_add_keyword (eb, _(default_topics[i]));
- }
+ for (i = 0; i < G_N_ELEMENTS (default_topics); i++) {
+ ephy_bookmarks_add_keyword (eb, _(default_topics[i]));
+ }
- ephy_bookmarks_import_rdf (eb, DATADIR "/default-bookmarks.rdf");
+ ephy_bookmarks_import_rdf (eb, DATADIR "/default-bookmarks.rdf");
}
static void
ephy_bookmarks_class_init (EphyBookmarksClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = ephy_bookmarks_finalize;
+ object_class->finalize = ephy_bookmarks_finalize;
- ephy_bookmarks_signals[TREE_CHANGED] =
- g_signal_new ("tree-changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 0);
+ ephy_bookmarks_signals[TREE_CHANGED] =
+ g_signal_new ("tree-changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 0);
}
static gboolean
-save_filter (EphyNode *node,
- EphyBookmarks *bookmarks)
+save_filter (EphyNode *node,
+ EphyBookmarks *bookmarks)
{
- return node != bookmarks->bookmarks &&
- node != bookmarks->notcategorized &&
- node != bookmarks->local;
+ return node != bookmarks->bookmarks &&
+ node != bookmarks->notcategorized &&
+ node != bookmarks->local;
}
static gboolean
-save_filter_local (EphyNode *node,
- EphyBookmarks *bookmarks)
+save_filter_local (EphyNode *node,
+ EphyBookmarks *bookmarks)
{
- return !ephy_node_has_child (bookmarks->local, node);
+ return !ephy_node_has_child (bookmarks->local, node);
}
static void
ephy_bookmarks_save (EphyBookmarks *eb)
{
+ LOG ("Saving bookmarks");
- LOG ("Saving bookmarks");
-
- ephy_node_db_write_to_xml_safe
- (eb->db,
- (xmlChar *) eb->xml_file,
- (xmlChar *) EPHY_BOOKMARKS_XML_ROOT,
- (xmlChar *) EPHY_BOOKMARKS_XML_VERSION,
- (xmlChar *) "Do not rely on this file, it's only for internal use. Use bookmarks.rdf
instead.",
- eb->keywords, (EphyNodeFilterFunc) save_filter, eb,
- eb->bookmarks, (EphyNodeFilterFunc) save_filter_local, eb,
- NULL);
+ ephy_node_db_write_to_xml_safe
+ (eb->db,
+ (xmlChar *)eb->xml_file,
+ (xmlChar *)EPHY_BOOKMARKS_XML_ROOT,
+ (xmlChar *)EPHY_BOOKMARKS_XML_VERSION,
+ (xmlChar *)"Do not rely on this file, it's only for internal use. Use bookmarks.rdf instead.",
+ eb->keywords, (EphyNodeFilterFunc)save_filter, eb,
+ eb->bookmarks, (EphyNodeFilterFunc)save_filter_local, eb,
+ NULL);
- /* Export bookmarks in rdf */
- ephy_bookmarks_export_rdf (eb, eb->rdf_file);
+ /* Export bookmarks in rdf */
+ ephy_bookmarks_export_rdf (eb, eb->rdf_file);
}
static gboolean
save_bookmarks_delayed (EphyBookmarks *bookmarks)
{
- ephy_bookmarks_save (bookmarks);
- bookmarks->dirty = FALSE;
- bookmarks->save_timeout_id = 0;
+ ephy_bookmarks_save (bookmarks);
+ bookmarks->dirty = FALSE;
+ bookmarks->save_timeout_id = 0;
- return FALSE;
+ return FALSE;
}
static void
ephy_bookmarks_save_delayed (EphyBookmarks *bookmarks, int delay)
{
- if (!bookmarks->dirty)
- {
- bookmarks->dirty = TRUE;
-
- if (delay > 0)
- {
- bookmarks->save_timeout_id =
- g_timeout_add_seconds (BOOKMARKS_SAVE_DELAY,
- (GSourceFunc) save_bookmarks_delayed,
- bookmarks);
- g_source_set_name_by_id (bookmarks->save_timeout_id, "[epiphany]
save_bookmarks_delayed");
- }
- else
- {
- bookmarks->save_timeout_id =
- g_idle_add ((GSourceFunc) save_bookmarks_delayed,
- bookmarks);
- }
- }
+ if (!bookmarks->dirty) {
+ bookmarks->dirty = TRUE;
+
+ if (delay > 0) {
+ bookmarks->save_timeout_id =
+ g_timeout_add_seconds (BOOKMARKS_SAVE_DELAY,
+ (GSourceFunc)save_bookmarks_delayed,
+ bookmarks);
+ g_source_set_name_by_id (bookmarks->save_timeout_id, "[epiphany] save_bookmarks_delayed");
+ } else {
+ bookmarks->save_timeout_id =
+ g_idle_add ((GSourceFunc)save_bookmarks_delayed,
+ bookmarks);
+ }
+ }
}
static void
icon_updated_cb (WebKitFaviconDatabase *favicon_database,
- const char *address,
- const char *icon,
- EphyBookmarks *eb)
+ const char *address,
+ const char *icon,
+ EphyBookmarks *eb)
{
- ephy_bookmarks_set_icon (eb, address, icon);
+ ephy_bookmarks_set_icon (eb, address, icon);
}
static void
ephy_setup_history_notifiers (EphyBookmarks *eb)
{
- WebKitFaviconDatabase *favicon_database;
- EphyEmbedShell *shell = ephy_embed_shell_get_default ();
+ WebKitFaviconDatabase *favicon_database;
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
- favicon_database = webkit_web_context_get_favicon_database (ephy_embed_shell_get_web_context (shell));
- g_signal_connect (favicon_database, "favicon-changed",
- G_CALLBACK (icon_updated_cb), eb);
+ favicon_database = webkit_web_context_get_favicon_database (ephy_embed_shell_get_web_context (shell));
+ g_signal_connect (favicon_database, "favicon-changed",
+ G_CALLBACK (icon_updated_cb), eb);
}
static void
update_bookmark_keywords (EphyBookmarks *eb, EphyNode *bookmark)
{
- GPtrArray *children;
- guint i;
- GString *list;
- const char *title;
- char *normalized_keywords, *case_normalized_keywords;
-
- list = g_string_new (NULL);
-
- children = ephy_node_get_children (eb->keywords);
- for (i = 0; i < children->len; i++)
- {
- EphyNode *kid;
-
- kid = g_ptr_array_index (children, i);
-
- if (kid != eb->notcategorized &&
- kid != eb->bookmarks &&
- kid != eb->local &&
- ephy_node_has_child (kid, bookmark))
- {
- const char *topic;
- topic = ephy_node_get_property_string
- (kid, EPHY_NODE_KEYWORD_PROP_NAME);
- g_string_append (list, topic);
- g_string_append (list, " ");
- }
- }
-
- title = ephy_node_get_property_string
- (bookmark, EPHY_NODE_BMK_PROP_TITLE);
- g_string_append (list, " ");
- g_string_append (list, title);
-
- normalized_keywords = g_utf8_normalize (list->str, -1, G_NORMALIZE_ALL);
- case_normalized_keywords = g_utf8_casefold (normalized_keywords, -1);
-
- ephy_node_set_property_string (bookmark, EPHY_NODE_BMK_PROP_KEYWORDS,
- case_normalized_keywords);
-
- g_string_free (list, TRUE);
- g_free (normalized_keywords);
- g_free (case_normalized_keywords);
+ GPtrArray *children;
+ guint i;
+ GString *list;
+ const char *title;
+ char *normalized_keywords, *case_normalized_keywords;
+
+ list = g_string_new (NULL);
+
+ children = ephy_node_get_children (eb->keywords);
+ for (i = 0; i < children->len; i++) {
+ EphyNode *kid;
+
+ kid = g_ptr_array_index (children, i);
+
+ if (kid != eb->notcategorized &&
+ kid != eb->bookmarks &&
+ kid != eb->local &&
+ ephy_node_has_child (kid, bookmark)) {
+ const char *topic;
+ topic = ephy_node_get_property_string
+ (kid, EPHY_NODE_KEYWORD_PROP_NAME);
+ g_string_append (list, topic);
+ g_string_append (list, " ");
+ }
+ }
+
+ title = ephy_node_get_property_string
+ (bookmark, EPHY_NODE_BMK_PROP_TITLE);
+ g_string_append (list, " ");
+ g_string_append (list, title);
+
+ normalized_keywords = g_utf8_normalize (list->str, -1, G_NORMALIZE_ALL);
+ case_normalized_keywords = g_utf8_casefold (normalized_keywords, -1);
+
+ ephy_node_set_property_string (bookmark, EPHY_NODE_BMK_PROP_KEYWORDS,
+ case_normalized_keywords);
+
+ g_string_free (list, TRUE);
+ g_free (normalized_keywords);
+ g_free (case_normalized_keywords);
}
static void
-bookmarks_changed_cb (EphyNode *node,
- EphyNode *child,
- guint property_id,
- EphyBookmarks *eb)
+bookmarks_changed_cb (EphyNode *node,
+ EphyNode *child,
+ guint property_id,
+ EphyBookmarks *eb)
{
- if (property_id == EPHY_NODE_BMK_PROP_TITLE)
- {
- update_bookmark_keywords (eb, child);
- }
+ if (property_id == EPHY_NODE_BMK_PROP_TITLE) {
+ update_bookmark_keywords (eb, child);
+ }
- ephy_bookmarks_save_delayed (eb, BOOKMARKS_SAVE_DELAY);
+ ephy_bookmarks_save_delayed (eb, BOOKMARKS_SAVE_DELAY);
}
static void
-bookmarks_removed_cb (EphyNode *node,
- EphyNode *child,
- guint old_index,
- EphyBookmarks *eb)
+bookmarks_removed_cb (EphyNode *node,
+ EphyNode *child,
+ guint old_index,
+ EphyBookmarks *eb)
{
- ephy_bookmarks_save_delayed (eb, BOOKMARKS_SAVE_DELAY);
+ ephy_bookmarks_save_delayed (eb, BOOKMARKS_SAVE_DELAY);
}
static gboolean
bookmark_is_categorized (EphyBookmarks *eb, EphyNode *bookmark)
{
- GPtrArray *children;
- guint i;
-
- children = ephy_node_get_children (eb->keywords);
- for (i = 0; i < children->len; i++)
- {
- EphyNode *kid;
-
- kid = g_ptr_array_index (children, i);
-
- if (kid != eb->notcategorized &&
- kid != eb->bookmarks &&
- kid != eb->local &&
- ephy_node_has_child (kid, bookmark))
- {
- return TRUE;
- }
- }
-
- return FALSE;
+ GPtrArray *children;
+ guint i;
+
+ children = ephy_node_get_children (eb->keywords);
+ for (i = 0; i < children->len; i++) {
+ EphyNode *kid;
+
+ kid = g_ptr_array_index (children, i);
+
+ if (kid != eb->notcategorized &&
+ kid != eb->bookmarks &&
+ kid != eb->local &&
+ ephy_node_has_child (kid, bookmark)) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
}
static void
-topics_removed_cb (EphyNode *node,
- EphyNode *child,
- guint old_index,
- EphyBookmarks *eb)
+topics_removed_cb (EphyNode *node,
+ EphyNode *child,
+ guint old_index,
+ EphyBookmarks *eb)
{
- GPtrArray *children;
- guint i;
+ GPtrArray *children;
+ guint i;
- children = ephy_node_get_children (child);
- for (i = 0; i < children->len; i++)
- {
- EphyNode *kid;
+ children = ephy_node_get_children (child);
+ for (i = 0; i < children->len; i++) {
+ EphyNode *kid;
- kid = g_ptr_array_index (children, i);
+ kid = g_ptr_array_index (children, i);
- if (!bookmark_is_categorized (eb, kid) &&
- !ephy_node_has_child (eb->notcategorized, kid))
- {
- ephy_node_add_child
- (eb->notcategorized, kid);
- }
+ if (!bookmark_is_categorized (eb, kid) &&
+ !ephy_node_has_child (eb->notcategorized, kid)) {
+ ephy_node_add_child
+ (eb->notcategorized, kid);
+ }
- update_bookmark_keywords (eb, kid);
- }
+ update_bookmark_keywords (eb, kid);
+ }
}
static void
fix_hierarchy_topic (EphyBookmarks *eb,
- EphyNode *topic)
-{
- GPtrArray *children;
- EphyNode *bookmark;
- const char *name;
- char **split;
- guint i, j;
-
- children = ephy_node_get_children (topic);
- name = ephy_node_get_property_string (topic, EPHY_NODE_KEYWORD_PROP_NAME);
- split = g_strsplit (name, "->", -1);
-
- for (i = 0; split[i]; i++)
- {
- if (split[i][0] == '\0') continue;
-
- topic = ephy_bookmarks_find_keyword (eb, split[i], FALSE);
- if (topic == NULL)
- {
- topic = ephy_bookmarks_add_keyword (eb, split[i]);
- }
- for (j = 0; j < children->len; j++)
- {
- bookmark = g_ptr_array_index (children, j);
- ephy_bookmarks_set_keyword (eb, topic, bookmark);
- }
- }
-
- g_strfreev (split);
+ EphyNode *topic)
+{
+ GPtrArray *children;
+ EphyNode *bookmark;
+ const char *name;
+ char **split;
+ guint i, j;
+
+ children = ephy_node_get_children (topic);
+ name = ephy_node_get_property_string (topic, EPHY_NODE_KEYWORD_PROP_NAME);
+ split = g_strsplit (name, "->", -1);
+
+ for (i = 0; split[i]; i++) {
+ if (split[i][0] == '\0') continue;
+
+ topic = ephy_bookmarks_find_keyword (eb, split[i], FALSE);
+ if (topic == NULL) {
+ topic = ephy_bookmarks_add_keyword (eb, split[i]);
+ }
+ for (j = 0; j < children->len; j++) {
+ bookmark = g_ptr_array_index (children, j);
+ ephy_bookmarks_set_keyword (eb, topic, bookmark);
+ }
+ }
+
+ g_strfreev (split);
}
static void
fix_hierarchy (EphyBookmarks *eb)
{
- GPtrArray *topics;
- EphyNode *topic;
- const char *name;
- int i;
-
- topics = ephy_node_get_children (eb->keywords);
- for (i = (int)topics->len - 1; i >= 0; i--)
- {
- topic = (EphyNode *)g_ptr_array_index (topics, i);
- name = ephy_node_get_property_string
- (topic, EPHY_NODE_KEYWORD_PROP_NAME);
- if (strstr (name, "->") != NULL)
- {
- fix_hierarchy_topic (eb, topic);
- ephy_node_remove_child (eb->keywords, topic);
- }
- }
+ GPtrArray *topics;
+ EphyNode *topic;
+ const char *name;
+ int i;
+
+ topics = ephy_node_get_children (eb->keywords);
+ for (i = (int)topics->len - 1; i >= 0; i--) {
+ topic = (EphyNode *)g_ptr_array_index (topics, i);
+ name = ephy_node_get_property_string
+ (topic, EPHY_NODE_KEYWORD_PROP_NAME);
+ if (strstr (name, "->") != NULL) {
+ fix_hierarchy_topic (eb, topic);
+ ephy_node_remove_child (eb->keywords, topic);
+ }
+ }
}
static void
backup_file (const char *original_filename, const char *extension)
{
- char *template, *backup_filename;
- int result = 0;
-
- if (g_file_test (original_filename, G_FILE_TEST_EXISTS) == FALSE)
- {
- return;
- }
-
- template = g_strconcat (original_filename, ".backup-XXXXXX", NULL);
- backup_filename = ephy_file_tmp_filename (template, extension);
-
- if (backup_filename != NULL)
- {
- result = rename (original_filename, backup_filename);
- }
-
- if (result >= 0)
- {
- g_message ("Your old bookmarks file was backed up as \"%s\".\n",
- backup_filename);
- }
- else
- {
- g_warning ("Backup failed! Your old bookmarks file was lost.\n");
- }
-
- g_free (template);
- g_free (backup_filename);
+ char *template, *backup_filename;
+ int result = 0;
+
+ if (g_file_test (original_filename, G_FILE_TEST_EXISTS) == FALSE) {
+ return;
+ }
+
+ template = g_strconcat (original_filename, ".backup-XXXXXX", NULL);
+ backup_filename = ephy_file_tmp_filename (template, extension);
+
+ if (backup_filename != NULL) {
+ result = rename (original_filename, backup_filename);
+ }
+
+ if (result >= 0) {
+ g_message ("Your old bookmarks file was backed up as \"%s\".\n",
+ backup_filename);
+ } else {
+ g_warning ("Backup failed! Your old bookmarks file was lost.\n");
+ }
+
+ g_free (template);
+ g_free (backup_filename);
}
/* C&P adapted from gnome-vfs-dns-sd.c */
static GHashTable *
decode_txt_record (AvahiStringList *input_text)
{
- GHashTable *hash;
- guint i;
- int len;
- char *key, *value, *end;
- char *key_dup, *value_dup;
- char *raw_txt;
- size_t raw_txt_len;
-
- if (!input_text)
- return NULL;
-
- raw_txt_len = avahi_string_list_serialize (input_text, NULL, 0);
- raw_txt = g_malloc (raw_txt_len);
- raw_txt_len = avahi_string_list_serialize (input_text, raw_txt, raw_txt_len);
-
- if (raw_txt == NULL)
- return NULL;
-
- hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
-
- i = 0;
- while (i < raw_txt_len) {
- len = raw_txt[i++];
-
- if (i + len > raw_txt_len) {
- break;
- }
-
- if (len == 0) {
- continue;
- }
-
- key = &raw_txt[i];
- end = &raw_txt[i + len];
- i += len;
-
- if (*key == '=') {
- /* 6.4 - silently ignore keys starting with = */
- continue;
- }
-
- value = memchr (key, '=', len);
- if (value) {
- key_dup = g_strndup (key, value - key);
- value++; /* Skip '=' */
- value_dup = g_strndup (value, end - value);
- } else {
- key_dup = g_strndup (key, len);
- value_dup = NULL;
- }
- if (!g_hash_table_lookup_extended (hash,
- key_dup,
- NULL, NULL)) {
- g_hash_table_insert (hash,
- key_dup,
- value_dup);
- } else {
- g_free (key_dup);
- g_free (value_dup);
- }
- }
-
- return hash;
+ GHashTable *hash;
+ guint i;
+ int len;
+ char *key, *value, *end;
+ char *key_dup, *value_dup;
+ char *raw_txt;
+ size_t raw_txt_len;
+
+ if (!input_text)
+ return NULL;
+
+ raw_txt_len = avahi_string_list_serialize (input_text, NULL, 0);
+ raw_txt = g_malloc (raw_txt_len);
+ raw_txt_len = avahi_string_list_serialize (input_text, raw_txt, raw_txt_len);
+
+ if (raw_txt == NULL)
+ return NULL;
+
+ hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
+ i = 0;
+ while (i < raw_txt_len) {
+ len = raw_txt[i++];
+
+ if (i + len > raw_txt_len) {
+ break;
+ }
+
+ if (len == 0) {
+ continue;
+ }
+
+ key = &raw_txt[i];
+ end = &raw_txt[i + len];
+ i += len;
+
+ if (*key == '=') {
+ /* 6.4 - silently ignore keys starting with = */
+ continue;
+ }
+
+ value = memchr (key, '=', len);
+ if (value) {
+ key_dup = g_strndup (key, value - key);
+ value++; /* Skip '=' */
+ value_dup = g_strndup (value, end - value);
+ } else {
+ key_dup = g_strndup (key, len);
+ value_dup = NULL;
+ }
+ if (!g_hash_table_lookup_extended (hash,
+ key_dup,
+ NULL, NULL)) {
+ g_hash_table_insert (hash,
+ key_dup,
+ value_dup);
+ } else {
+ g_free (key_dup);
+ g_free (value_dup);
+ }
+ }
+
+ return hash;
}
/* End of copied code */
static char *
get_id_for_response (const char *type,
- const char *domain,
- const char *name)
-{
- /* FIXME: limit length! */
- return g_strdup_printf ("%s\1%s\1%s",
- type,
- domain,
- name);
+ const char *domain,
+ const char *name)
+{
+ /* FIXME: limit length! */
+ return g_strdup_printf ("%s\1%s\1%s",
+ type,
+ domain,
+ name);
}
-typedef struct
-{
- EphyBookmarks *bookmarks;
- GaServiceResolver *resolver;
- EphyNode *node;
- char *name;
- char *type;
- char *domain;
+typedef struct {
+ EphyBookmarks *bookmarks;
+ GaServiceResolver *resolver;
+ EphyNode *node;
+ char *name;
+ char *type;
+ char *domain;
} ResolveData;
static void
-resolver_found_cb (GaServiceResolver *resolver,
- int interface,
- GaProtocol protocol,
- const char *name,
- const char *type,
- const char *domain,
- const char *host_name,
- const AvahiAddress *address,
- guint16 port,
- AvahiStringList *txt,
- glong flags,
- ResolveData *data)
-{
- EphyBookmarks *bookmarks = data->bookmarks;
- GValue value = { 0, };
- const char *path = NULL;
- char host[128];
- GHashTable *text_table;
- char *url;
- gboolean was_immutable;
- gboolean is_new_node = FALSE;
- guint i;
-
- LOG ("resolver_found_cb resolver %p\n", resolver);
-
- was_immutable = ephy_node_db_is_immutable (bookmarks->db);
- ephy_node_db_set_immutable (bookmarks->db, FALSE);
-
- /* Find the protocol */
- for (i = 0; i < G_N_ELEMENTS (zeroconf_protos); ++i)
- {
- char proto[20];
-
- g_snprintf (proto, sizeof (proto), "_%s._tcp", zeroconf_protos[i]);
- if (strcmp (type, proto) == 0) break;
- }
- if (i == G_N_ELEMENTS (zeroconf_protos)) return;
-
- if (address == NULL)
- {
- g_warning ("Zeroconf failed to resolve host %s", name);
- return;
- }
-
- text_table = decode_txt_record (txt);
-
- if (text_table != NULL)
- {
- path = g_hash_table_lookup (text_table, "path");
- }
- if (path == NULL || path[0] == '\0')
- {
- path = "/";
- }
-
- avahi_address_snprint (host, sizeof (host), address);
-
- LOG ("0conf RESOLVED type=%s domain=%s name=%s => proto=%s host=%s port=%d path=%s\n",
- type, domain, name,
- zeroconf_protos[i], host, port, path);
-
- was_immutable = ephy_node_db_is_immutable (bookmarks->db);
- ephy_node_db_set_immutable (bookmarks->db, FALSE);
-
- if (data->node == NULL)
- {
- is_new_node = TRUE;
-
- data->node = ephy_node_new (bookmarks->db);
- g_assert (data->node != NULL);
-
- /* don't allow dragging this node */
- ephy_node_set_is_drag_source (data->node, FALSE);
-
- g_value_init (&value, G_TYPE_STRING);
- g_value_take_string (&value,
- get_id_for_response (data->type,
- data->domain,
- data->name));
- ephy_node_set_property (data->node, EPHY_NODE_BMK_PROP_SERVICE_ID, &value);
- g_value_unset (&value);
-
- /* FIXME: limit length! */
- ephy_node_set_property_string (data->node,
- EPHY_NODE_BMK_PROP_TITLE,
- name);
-
- ephy_node_set_property_boolean (data->node,
- EPHY_NODE_BMK_PROP_IMMUTABLE,
- TRUE);
- }
-
- /* FIXME: limit length! */
- url = g_strdup_printf ("%s://%s:%d%s", zeroconf_protos[i], host, port, path);
-
- g_value_init (&value, G_TYPE_STRING);
- g_value_take_string (&value, url);
- ephy_node_set_property (data->node, EPHY_NODE_BMK_PROP_LOCATION, &value);
- g_value_unset (&value);
-
- if (is_new_node)
- {
- ephy_node_add_child (bookmarks->bookmarks, data->node);
- ephy_node_add_child (bookmarks->local, data->node);
- }
-
- ephy_node_db_set_immutable (bookmarks->db, was_immutable);
-
- if (text_table != NULL)
- {
- g_hash_table_unref (text_table);
- }
+resolver_found_cb (GaServiceResolver *resolver,
+ int interface,
+ GaProtocol protocol,
+ const char *name,
+ const char *type,
+ const char *domain,
+ const char *host_name,
+ const AvahiAddress *address,
+ guint16 port,
+ AvahiStringList *txt,
+ glong flags,
+ ResolveData *data)
+{
+ EphyBookmarks *bookmarks = data->bookmarks;
+ GValue value = { 0, };
+ const char *path = NULL;
+ char host[128];
+ GHashTable *text_table;
+ char *url;
+ gboolean was_immutable;
+ gboolean is_new_node = FALSE;
+ guint i;
+
+ LOG ("resolver_found_cb resolver %p\n", resolver);
+
+ was_immutable = ephy_node_db_is_immutable (bookmarks->db);
+ ephy_node_db_set_immutable (bookmarks->db, FALSE);
+
+ /* Find the protocol */
+ for (i = 0; i < G_N_ELEMENTS (zeroconf_protos); ++i) {
+ char proto[20];
+
+ g_snprintf (proto, sizeof (proto), "_%s._tcp", zeroconf_protos[i]);
+ if (strcmp (type, proto) == 0) break;
+ }
+ if (i == G_N_ELEMENTS (zeroconf_protos)) return;
+
+ if (address == NULL) {
+ g_warning ("Zeroconf failed to resolve host %s", name);
+ return;
+ }
+
+ text_table = decode_txt_record (txt);
+
+ if (text_table != NULL) {
+ path = g_hash_table_lookup (text_table, "path");
+ }
+ if (path == NULL || path[0] == '\0') {
+ path = "/";
+ }
+
+ avahi_address_snprint (host, sizeof (host), address);
+
+ LOG ("0conf RESOLVED type=%s domain=%s name=%s => proto=%s host=%s port=%d path=%s\n",
+ type, domain, name,
+ zeroconf_protos[i], host, port, path);
+
+ was_immutable = ephy_node_db_is_immutable (bookmarks->db);
+ ephy_node_db_set_immutable (bookmarks->db, FALSE);
+
+ if (data->node == NULL) {
+ is_new_node = TRUE;
+
+ data->node = ephy_node_new (bookmarks->db);
+ g_assert (data->node != NULL);
+
+ /* don't allow dragging this node */
+ ephy_node_set_is_drag_source (data->node, FALSE);
+
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_take_string (&value,
+ get_id_for_response (data->type,
+ data->domain,
+ data->name));
+ ephy_node_set_property (data->node, EPHY_NODE_BMK_PROP_SERVICE_ID, &value);
+ g_value_unset (&value);
+
+ /* FIXME: limit length! */
+ ephy_node_set_property_string (data->node,
+ EPHY_NODE_BMK_PROP_TITLE,
+ name);
+
+ ephy_node_set_property_boolean (data->node,
+ EPHY_NODE_BMK_PROP_IMMUTABLE,
+ TRUE);
+ }
+
+ /* FIXME: limit length! */
+ url = g_strdup_printf ("%s://%s:%d%s", zeroconf_protos[i], host, port, path);
+
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_take_string (&value, url);
+ ephy_node_set_property (data->node, EPHY_NODE_BMK_PROP_LOCATION, &value);
+ g_value_unset (&value);
+
+ if (is_new_node) {
+ ephy_node_add_child (bookmarks->bookmarks, data->node);
+ ephy_node_add_child (bookmarks->local, data->node);
+ }
+
+ ephy_node_db_set_immutable (bookmarks->db, was_immutable);
+
+ if (text_table != NULL) {
+ g_hash_table_unref (text_table);
+ }
}
static void
resolver_failure_cb (GaServiceResolver *resolver,
- GError *error,
- ResolveData *data)
-{
- LOG ("resolver_failure_cb resolver %p: %s\n", resolver, error?error->message:"(null)");
-
- /* Remove the node, if present */
- if (data->node != NULL)
- {
- EphyBookmarks *bookmarks = data->bookmarks;
- gboolean was_immutable;
-
- was_immutable = ephy_node_db_is_immutable (bookmarks->db);
- ephy_node_db_set_immutable (bookmarks->db, FALSE);
- ephy_node_unref (data->node);
- data->node = NULL;
- ephy_node_db_set_immutable (bookmarks->db, was_immutable);
- }
+ GError *error,
+ ResolveData *data)
+{
+ LOG ("resolver_failure_cb resolver %p: %s\n", resolver, error ? error->message : "(null)");
+
+ /* Remove the node, if present */
+ if (data->node != NULL) {
+ EphyBookmarks *bookmarks = data->bookmarks;
+ gboolean was_immutable;
+
+ was_immutable = ephy_node_db_is_immutable (bookmarks->db);
+ ephy_node_db_set_immutable (bookmarks->db, FALSE);
+ ephy_node_unref (data->node);
+ data->node = NULL;
+ ephy_node_db_set_immutable (bookmarks->db, was_immutable);
+ }
}
static void
-resolve_data_free (ResolveData* data)
+resolve_data_free (ResolveData *data)
{
- if (data->resolver)
- g_object_unref (data->resolver);
+ if (data->resolver)
+ g_object_unref (data->resolver);
- g_free (data->type);
- g_free (data->name);
- g_free (data->domain);
- g_slice_free (ResolveData, data);
+ g_free (data->type);
+ g_free (data->name);
+ g_free (data->domain);
+ g_slice_free (ResolveData, data);
}
static void
browser_new_service_cb (GaServiceBrowser *browser,
- int interface,
- GaProtocol protocol,
- const char *name,
- const char *type,
- const char *domain,
- glong flags,
- EphyBookmarks *bookmarks)
-{
- ResolveData *data;
- char *node_id;
- GError *error = NULL;
-
- node_id = get_id_for_response (type, domain, name);
-
- LOG ("0conf ADD: type=%s domain=%s name=%s\n",
- type, domain, name);
-
- if (g_hash_table_lookup (bookmarks->resolve_handles, node_id) != NULL)
- {
- g_free (node_id);
- return;
- }
-
- data = g_slice_new0 (ResolveData);
- data->bookmarks = bookmarks;
- data->node = NULL;
- data->type = g_strdup (type);
- data->name = g_strdup (name);
- data->domain = g_strdup (domain);
-
- data->resolver = ga_service_resolver_new (AVAHI_IF_UNSPEC,
- AVAHI_PROTO_UNSPEC,
- name, type, domain,
- AVAHI_PROTO_UNSPEC,
- GA_LOOKUP_USE_MULTICAST);
- g_signal_connect (data->resolver, "found",
- G_CALLBACK (resolver_found_cb), data);
- g_signal_connect (data->resolver, "failure",
- G_CALLBACK (resolver_failure_cb), data);
- if (!ga_service_resolver_attach (data->resolver,
- bookmarks->ga_client,
- &error))
- {
- g_warning ("Unable to resolve Zeroconf service %s: %s", name, error ? error->message :
"(null)");
- g_clear_error (&error);
- resolve_data_free (data);
- g_free (node_id);
- return;
- }
-
- g_hash_table_insert (bookmarks->resolve_handles,
- node_id /* transfer ownership */, data);
+ int interface,
+ GaProtocol protocol,
+ const char *name,
+ const char *type,
+ const char *domain,
+ glong flags,
+ EphyBookmarks *bookmarks)
+{
+ ResolveData *data;
+ char *node_id;
+ GError *error = NULL;
+
+ node_id = get_id_for_response (type, domain, name);
+
+ LOG ("0conf ADD: type=%s domain=%s name=%s\n",
+ type, domain, name);
+
+ if (g_hash_table_lookup (bookmarks->resolve_handles, node_id) != NULL) {
+ g_free (node_id);
+ return;
+ }
+
+ data = g_slice_new0 (ResolveData);
+ data->bookmarks = bookmarks;
+ data->node = NULL;
+ data->type = g_strdup (type);
+ data->name = g_strdup (name);
+ data->domain = g_strdup (domain);
+
+ data->resolver = ga_service_resolver_new (AVAHI_IF_UNSPEC,
+ AVAHI_PROTO_UNSPEC,
+ name, type, domain,
+ AVAHI_PROTO_UNSPEC,
+ GA_LOOKUP_USE_MULTICAST);
+ g_signal_connect (data->resolver, "found",
+ G_CALLBACK (resolver_found_cb), data);
+ g_signal_connect (data->resolver, "failure",
+ G_CALLBACK (resolver_failure_cb), data);
+ if (!ga_service_resolver_attach (data->resolver,
+ bookmarks->ga_client,
+ &error)) {
+ g_warning ("Unable to resolve Zeroconf service %s: %s", name, error ? error->message : "(null)");
+ g_clear_error (&error);
+ resolve_data_free (data);
+ g_free (node_id);
+ return;
+ }
+
+ g_hash_table_insert (bookmarks->resolve_handles,
+ node_id /* transfer ownership */, data);
}
static void
browser_removed_service_cb (GaServiceBrowser *browser,
- int interface,
- GaProtocol protocol,
- const char *name,
- const char *type,
- const char *domain,
- glong flags,
- EphyBookmarks *bookmarks)
-{
- char *node_id;
- ResolveData *data;
-
- node_id = get_id_for_response (type, domain, name);
- data = g_hash_table_lookup (bookmarks->resolve_handles, node_id);
- /* shouldn't really happen, but let's play safe */
- if (!data)
- {
- g_free (node_id);
- return;
- }
-
- if (data->node != NULL)
- {
- gboolean was_immutable;
-
- was_immutable = ephy_node_db_is_immutable (bookmarks->db);
- ephy_node_db_set_immutable (bookmarks->db, FALSE);
- ephy_node_unref (data->node);
- data->node = NULL;
- ephy_node_db_set_immutable (bookmarks->db, was_immutable);
- }
-
- g_hash_table_remove (bookmarks->resolve_handles, node_id);
- g_free (node_id);
+ int interface,
+ GaProtocol protocol,
+ const char *name,
+ const char *type,
+ const char *domain,
+ glong flags,
+ EphyBookmarks *bookmarks)
+{
+ char *node_id;
+ ResolveData *data;
+
+ node_id = get_id_for_response (type, domain, name);
+ data = g_hash_table_lookup (bookmarks->resolve_handles, node_id);
+ /* shouldn't really happen, but let's play safe */
+ if (!data) {
+ g_free (node_id);
+ return;
+ }
+
+ if (data->node != NULL) {
+ gboolean was_immutable;
+
+ was_immutable = ephy_node_db_is_immutable (bookmarks->db);
+ ephy_node_db_set_immutable (bookmarks->db, FALSE);
+ ephy_node_unref (data->node);
+ data->node = NULL;
+ ephy_node_db_set_immutable (bookmarks->db, was_immutable);
+ }
+
+ g_hash_table_remove (bookmarks->resolve_handles, node_id);
+ g_free (node_id);
}
static void
-start_browsing (GaClient *ga_client,
- EphyBookmarks *bookmarks)
-{
- guint i;
-
- for (i = 0; i < G_N_ELEMENTS (zeroconf_protos); ++i)
- {
- GaServiceBrowser *browser = NULL;
- char proto[20];
-
- g_snprintf (proto, sizeof (proto), "_%s._tcp", zeroconf_protos[i]);
-
- browser = ga_service_browser_new (proto);
- g_signal_connect (browser, "new-service",
- G_CALLBACK (browser_new_service_cb), bookmarks);
- g_signal_connect (browser, "removed-service",
- G_CALLBACK (browser_removed_service_cb), bookmarks);
- if (!ga_service_browser_attach (browser,
- ga_client,
- NULL))
- {
- g_warning ("Unable to start Zeroconf subsystem");
- g_object_unref (browser);
- return;
- }
-
- bookmarks->browse_handles[i] = browser;
- }
+start_browsing (GaClient *ga_client,
+ EphyBookmarks *bookmarks)
+{
+ guint i;
+
+ for (i = 0; i < G_N_ELEMENTS (zeroconf_protos); ++i) {
+ GaServiceBrowser *browser = NULL;
+ char proto[20];
+
+ g_snprintf (proto, sizeof (proto), "_%s._tcp", zeroconf_protos[i]);
+
+ browser = ga_service_browser_new (proto);
+ g_signal_connect (browser, "new-service",
+ G_CALLBACK (browser_new_service_cb), bookmarks);
+ g_signal_connect (browser, "removed-service",
+ G_CALLBACK (browser_removed_service_cb), bookmarks);
+ if (!ga_service_browser_attach (browser,
+ ga_client,
+ NULL)) {
+ g_warning ("Unable to start Zeroconf subsystem");
+ g_object_unref (browser);
+ return;
+ }
+
+ bookmarks->browse_handles[i] = browser;
+ }
}
static void
-ga_client_state_changed_cb (GaClient *ga_client,
- GaClientState state,
- EphyBookmarks *bookmarks)
-{
- if (state == GA_CLIENT_STATE_FAILURE)
- {
- if (avahi_client_errno (ga_client->avahi_client) == AVAHI_ERR_DISCONNECTED)
- {
- g_object_unref (bookmarks->ga_client);
- bookmarks->ga_client = NULL;
-
- ephy_local_bookmarks_start_client (bookmarks);
- }
- }
- if (state == GA_CLIENT_STATE_S_RUNNING)
- {
- start_browsing (ga_client, bookmarks);
- }
+ga_client_state_changed_cb (GaClient *ga_client,
+ GaClientState state,
+ EphyBookmarks *bookmarks)
+{
+ if (state == GA_CLIENT_STATE_FAILURE) {
+ if (avahi_client_errno (ga_client->avahi_client) == AVAHI_ERR_DISCONNECTED) {
+ g_object_unref (bookmarks->ga_client);
+ bookmarks->ga_client = NULL;
+
+ ephy_local_bookmarks_start_client (bookmarks);
+ }
+ }
+ if (state == GA_CLIENT_STATE_S_RUNNING) {
+ start_browsing (ga_client, bookmarks);
+ }
}
static void
ephy_local_bookmarks_start_client (EphyBookmarks *bookmarks)
{
- GaClient *ga_client;
-
- ga_client = ga_client_new (GA_CLIENT_FLAG_NO_FAIL);
- g_signal_connect (ga_client, "state-changed",
- G_CALLBACK (ga_client_state_changed_cb),
- bookmarks);
- if (!ga_client_start (ga_client, NULL))
- {
- g_warning ("Unable to start Zeroconf subsystem");
- g_object_unref (ga_client);
- return;
- }
- bookmarks->ga_client = ga_client;
+ GaClient *ga_client;
+
+ ga_client = ga_client_new (GA_CLIENT_FLAG_NO_FAIL);
+ g_signal_connect (ga_client, "state-changed",
+ G_CALLBACK (ga_client_state_changed_cb),
+ bookmarks);
+ if (!ga_client_start (ga_client, NULL)) {
+ g_warning ("Unable to start Zeroconf subsystem");
+ g_object_unref (ga_client);
+ return;
+ }
+ bookmarks->ga_client = ga_client;
}
static void
ephy_local_bookmarks_init (EphyBookmarks *bookmarks)
{
- bookmarks->resolve_handles = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free,
- (GDestroyNotify) resolve_data_free);
- ephy_local_bookmarks_start_client (bookmarks);
+ bookmarks->resolve_handles = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free,
+ (GDestroyNotify)resolve_data_free);
+ ephy_local_bookmarks_start_client (bookmarks);
}
static void
ephy_local_bookmarks_stop (EphyBookmarks *bookmarks)
{
- guint i;
-
- for (i = 0; i < G_N_ELEMENTS (zeroconf_protos); ++i)
- {
- if (bookmarks->browse_handles[i] != NULL)
- {
- g_object_unref (bookmarks->browse_handles[i]);
- bookmarks->browse_handles[i] = NULL;
- }
- }
-
- if (bookmarks->resolve_handles != NULL)
- {
- g_hash_table_destroy (bookmarks->resolve_handles);
- bookmarks->resolve_handles = NULL;
- }
-
- if (bookmarks->local != NULL)
- {
- ephy_node_unref (bookmarks->local);
- bookmarks->local = NULL;
- }
-
- if (bookmarks->ga_client != NULL)
- {
- g_object_unref (bookmarks->ga_client);
- bookmarks->ga_client = NULL;
- }
+ guint i;
+
+ for (i = 0; i < G_N_ELEMENTS (zeroconf_protos); ++i) {
+ if (bookmarks->browse_handles[i] != NULL) {
+ g_object_unref (bookmarks->browse_handles[i]);
+ bookmarks->browse_handles[i] = NULL;
+ }
+ }
+
+ if (bookmarks->resolve_handles != NULL) {
+ g_hash_table_destroy (bookmarks->resolve_handles);
+ bookmarks->resolve_handles = NULL;
+ }
+
+ if (bookmarks->local != NULL) {
+ ephy_node_unref (bookmarks->local);
+ bookmarks->local = NULL;
+ }
+
+ if (bookmarks->ga_client != NULL) {
+ g_object_unref (bookmarks->ga_client);
+ bookmarks->ga_client = NULL;
+ }
}
static void
ephy_bookmarks_init (EphyBookmarks *eb)
{
- EphyNodeDb *db;
-
- /* Translators: this topic contains all bookmarks */
- const char *bk_all = C_("bookmarks", "All");
-
- /* Translators: this topic contains the not categorized
- bookmarks */
- const char *bk_not_categorized = C_("bookmarks", "Not Categorized");
-
- /* Translators: this is an automatic topic containing local
- * websites bookmarks autodiscovered with zeroconf. */
- const char *bk_local_sites = C_("bookmarks", "Nearby Sites");
-
- db = ephy_node_db_new (EPHY_NODE_DB_BOOKMARKS);
- eb->db = db;
-
- eb->xml_file = g_build_filename (ephy_dot_dir (),
- EPHY_BOOKMARKS_FILE,
- NULL);
- eb->rdf_file = g_build_filename (ephy_dot_dir (),
- EPHY_BOOKMARKS_FILE_RDF,
- NULL);
-
- /* Bookmarks */
- eb->bookmarks = ephy_node_new_with_id (db, BOOKMARKS_NODE_ID);
-
- ephy_node_set_property_string (eb->bookmarks,
- EPHY_NODE_KEYWORD_PROP_NAME,
- bk_all);
- ephy_node_signal_connect_object (eb->bookmarks,
- EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback) bookmarks_removed_cb,
- G_OBJECT (eb));
- ephy_node_signal_connect_object (eb->bookmarks,
- EPHY_NODE_CHILD_CHANGED,
- (EphyNodeCallback) bookmarks_changed_cb,
- G_OBJECT (eb));
-
- /* Keywords */
- eb->keywords = ephy_node_new_with_id (db, KEYWORDS_NODE_ID);
- ephy_node_set_property_int (eb->bookmarks,
- EPHY_NODE_KEYWORD_PROP_PRIORITY,
- EPHY_NODE_ALL_PRIORITY);
-
- ephy_node_signal_connect_object (eb->keywords,
- EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback) topics_removed_cb,
- G_OBJECT (eb));
-
- ephy_node_add_child (eb->keywords,
- eb->bookmarks);
-
- /* Not categorized */
- eb->notcategorized = ephy_node_new_with_id (db, BMKS_NOTCATEGORIZED_NODE_ID);
-
-
- ephy_node_set_property_string (eb->notcategorized,
- EPHY_NODE_KEYWORD_PROP_NAME,
- bk_not_categorized);
-
- ephy_node_set_property_int (eb->notcategorized,
- EPHY_NODE_KEYWORD_PROP_PRIORITY,
- EPHY_NODE_SPECIAL_PRIORITY);
-
- ephy_node_add_child (eb->keywords, eb->notcategorized);
-
- /* Local Websites */
- eb->local = ephy_node_new_with_id (db, BMKS_LOCAL_NODE_ID);
-
- /* don't allow drags to this topic */
- ephy_node_set_is_drag_dest (eb->local, FALSE);
-
-
- ephy_node_set_property_string (eb->local,
- EPHY_NODE_KEYWORD_PROP_NAME,
- bk_local_sites);
- ephy_node_set_property_int (eb->local,
- EPHY_NODE_KEYWORD_PROP_PRIORITY,
- EPHY_NODE_SPECIAL_PRIORITY);
-
- ephy_node_add_child (eb->keywords, eb->local);
- ephy_local_bookmarks_init (eb);
-
- /* Smart bookmarks */
- eb->smartbookmarks = ephy_node_new_with_id (db, SMARTBOOKMARKS_NODE_ID);
-
- if (g_file_test (eb->xml_file, G_FILE_TEST_EXISTS) == FALSE
- && g_file_test (eb->rdf_file, G_FILE_TEST_EXISTS) == FALSE)
- {
- eb->init_defaults = TRUE;
- }
- else if (ephy_node_db_load_from_file (eb->db, eb->xml_file,
- (xmlChar *) EPHY_BOOKMARKS_XML_ROOT,
- (xmlChar *) EPHY_BOOKMARKS_XML_VERSION) == FALSE)
- {
- /* save the corrupted files so the user can late try to
- * manually recover them. See bug #128308.
- */
-
- g_warning ("Could not read bookmarks file \"%s\", trying to "
- "re-import bookmarks from \"%s\"\n",
- eb->xml_file, eb->rdf_file);
-
- backup_file (eb->xml_file, "xml");
-
- if (ephy_bookmarks_import_rdf (eb, eb->rdf_file) == FALSE)
- {
- backup_file (eb->rdf_file, "rdf");
-
- eb->init_defaults = TRUE;
- }
- }
-
- if (eb->init_defaults)
- {
- ephy_bookmarks_init_defaults (eb);
- }
-
- fix_hierarchy (eb);
-
- g_settings_bind (EPHY_SETTINGS_LOCKDOWN,
- EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING,
- eb->db, "immutable",
- G_SETTINGS_BIND_GET);
-
- ephy_setup_history_notifiers (eb);
+ EphyNodeDb *db;
+
+ /* Translators: this topic contains all bookmarks */
+ const char *bk_all = C_("bookmarks", "All");
+
+ /* Translators: this topic contains the not categorized
+ bookmarks */
+ const char *bk_not_categorized = C_("bookmarks", "Not Categorized");
+
+ /* Translators: this is an automatic topic containing local
+ * websites bookmarks autodiscovered with zeroconf. */
+ const char *bk_local_sites = C_("bookmarks", "Nearby Sites");
+
+ db = ephy_node_db_new (EPHY_NODE_DB_BOOKMARKS);
+ eb->db = db;
+
+ eb->xml_file = g_build_filename (ephy_dot_dir (),
+ EPHY_BOOKMARKS_FILE,
+ NULL);
+ eb->rdf_file = g_build_filename (ephy_dot_dir (),
+ EPHY_BOOKMARKS_FILE_RDF,
+ NULL);
+
+ /* Bookmarks */
+ eb->bookmarks = ephy_node_new_with_id (db, BOOKMARKS_NODE_ID);
+
+ ephy_node_set_property_string (eb->bookmarks,
+ EPHY_NODE_KEYWORD_PROP_NAME,
+ bk_all);
+ ephy_node_signal_connect_object (eb->bookmarks,
+ EPHY_NODE_CHILD_REMOVED,
+ (EphyNodeCallback)bookmarks_removed_cb,
+ G_OBJECT (eb));
+ ephy_node_signal_connect_object (eb->bookmarks,
+ EPHY_NODE_CHILD_CHANGED,
+ (EphyNodeCallback)bookmarks_changed_cb,
+ G_OBJECT (eb));
+
+ /* Keywords */
+ eb->keywords = ephy_node_new_with_id (db, KEYWORDS_NODE_ID);
+ ephy_node_set_property_int (eb->bookmarks,
+ EPHY_NODE_KEYWORD_PROP_PRIORITY,
+ EPHY_NODE_ALL_PRIORITY);
+
+ ephy_node_signal_connect_object (eb->keywords,
+ EPHY_NODE_CHILD_REMOVED,
+ (EphyNodeCallback)topics_removed_cb,
+ G_OBJECT (eb));
+
+ ephy_node_add_child (eb->keywords,
+ eb->bookmarks);
+
+ /* Not categorized */
+ eb->notcategorized = ephy_node_new_with_id (db, BMKS_NOTCATEGORIZED_NODE_ID);
+
+
+ ephy_node_set_property_string (eb->notcategorized,
+ EPHY_NODE_KEYWORD_PROP_NAME,
+ bk_not_categorized);
+
+ ephy_node_set_property_int (eb->notcategorized,
+ EPHY_NODE_KEYWORD_PROP_PRIORITY,
+ EPHY_NODE_SPECIAL_PRIORITY);
+
+ ephy_node_add_child (eb->keywords, eb->notcategorized);
+
+ /* Local Websites */
+ eb->local = ephy_node_new_with_id (db, BMKS_LOCAL_NODE_ID);
+
+ /* don't allow drags to this topic */
+ ephy_node_set_is_drag_dest (eb->local, FALSE);
+
+
+ ephy_node_set_property_string (eb->local,
+ EPHY_NODE_KEYWORD_PROP_NAME,
+ bk_local_sites);
+ ephy_node_set_property_int (eb->local,
+ EPHY_NODE_KEYWORD_PROP_PRIORITY,
+ EPHY_NODE_SPECIAL_PRIORITY);
+
+ ephy_node_add_child (eb->keywords, eb->local);
+ ephy_local_bookmarks_init (eb);
+
+ /* Smart bookmarks */
+ eb->smartbookmarks = ephy_node_new_with_id (db, SMARTBOOKMARKS_NODE_ID);
+
+ if (g_file_test (eb->xml_file, G_FILE_TEST_EXISTS) == FALSE
+ && g_file_test (eb->rdf_file, G_FILE_TEST_EXISTS) == FALSE) {
+ eb->init_defaults = TRUE;
+ } else if (ephy_node_db_load_from_file (eb->db, eb->xml_file,
+ (xmlChar *)EPHY_BOOKMARKS_XML_ROOT,
+ (xmlChar *)EPHY_BOOKMARKS_XML_VERSION) == FALSE) {
+ /* save the corrupted files so the user can late try to
+ * manually recover them. See bug #128308.
+ */
+
+ g_warning ("Could not read bookmarks file \"%s\", trying to "
+ "re-import bookmarks from \"%s\"\n",
+ eb->xml_file, eb->rdf_file);
+
+ backup_file (eb->xml_file, "xml");
+
+ if (ephy_bookmarks_import_rdf (eb, eb->rdf_file) == FALSE) {
+ backup_file (eb->rdf_file, "rdf");
+
+ eb->init_defaults = TRUE;
+ }
+ }
+
+ if (eb->init_defaults) {
+ ephy_bookmarks_init_defaults (eb);
+ }
+
+ fix_hierarchy (eb);
+
+ g_settings_bind (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING,
+ eb->db, "immutable",
+ G_SETTINGS_BIND_GET);
+
+ ephy_setup_history_notifiers (eb);
}
static void
ephy_bookmarks_finalize (GObject *object)
{
- EphyBookmarks *eb = EPHY_BOOKMARKS (object);
+ EphyBookmarks *eb = EPHY_BOOKMARKS (object);
- if (eb->save_timeout_id != 0)
- {
- g_source_remove (eb->save_timeout_id);
- }
+ if (eb->save_timeout_id != 0) {
+ g_source_remove (eb->save_timeout_id);
+ }
- ephy_bookmarks_save (eb);
+ ephy_bookmarks_save (eb);
- ephy_local_bookmarks_stop (eb);
+ ephy_local_bookmarks_stop (eb);
- ephy_node_unref (eb->bookmarks);
- ephy_node_unref (eb->keywords);
- ephy_node_unref (eb->notcategorized);
- ephy_node_unref (eb->smartbookmarks);
+ ephy_node_unref (eb->bookmarks);
+ ephy_node_unref (eb->keywords);
+ ephy_node_unref (eb->notcategorized);
+ ephy_node_unref (eb->smartbookmarks);
- g_object_unref (eb->db);
+ g_object_unref (eb->db);
- g_free (eb->xml_file);
- g_free (eb->rdf_file);
+ g_free (eb->xml_file);
+ g_free (eb->rdf_file);
- LOG ("Bookmarks finalized");
+ LOG ("Bookmarks finalized");
- G_OBJECT_CLASS (ephy_bookmarks_parent_class)->finalize (object);
+ G_OBJECT_CLASS (ephy_bookmarks_parent_class)->finalize (object);
}
EphyBookmarks *
ephy_bookmarks_new (void)
{
- return EPHY_BOOKMARKS (g_object_new (EPHY_TYPE_BOOKMARKS, NULL));
+ return EPHY_BOOKMARKS (g_object_new (EPHY_TYPE_BOOKMARKS, NULL));
}
static void
update_has_smart_address (EphyBookmarks *bookmarks, EphyNode *bmk, const char *address)
{
- EphyNode *smart_bmks;
- gboolean smart = FALSE, with_options = FALSE;
-
- smart_bmks = bookmarks->smartbookmarks;
-
- if (address)
- {
- smart = strstr (address, "%s") != NULL;
- with_options = strstr (address, "%s%{") != NULL;
- }
-
- /* if we have a smart bookmark with width specification,
- * remove from smart bookmarks first to force an update
- * in the toolbar
- */
- if (smart && with_options)
- {
- if (ephy_node_has_child (smart_bmks, bmk))
- {
- ephy_node_remove_child (smart_bmks, bmk);
- }
- ephy_node_add_child (smart_bmks, bmk);
- }
- else if (smart)
- {
- if (!ephy_node_has_child (smart_bmks, bmk))
- {
- ephy_node_add_child (smart_bmks, bmk);
- }
- }
- else
- {
- if (ephy_node_has_child (smart_bmks, bmk))
- {
- ephy_node_remove_child (smart_bmks, bmk);
- }
- }
+ EphyNode *smart_bmks;
+ gboolean smart = FALSE, with_options = FALSE;
+
+ smart_bmks = bookmarks->smartbookmarks;
+
+ if (address) {
+ smart = strstr (address, "%s") != NULL;
+ with_options = strstr (address, "%s%{") != NULL;
+ }
+
+ /* if we have a smart bookmark with width specification,
+ * remove from smart bookmarks first to force an update
+ * in the toolbar
+ */
+ if (smart && with_options) {
+ if (ephy_node_has_child (smart_bmks, bmk)) {
+ ephy_node_remove_child (smart_bmks, bmk);
+ }
+ ephy_node_add_child (smart_bmks, bmk);
+ } else if (smart) {
+ if (!ephy_node_has_child (smart_bmks, bmk)) {
+ ephy_node_add_child (smart_bmks, bmk);
+ }
+ } else {
+ if (ephy_node_has_child (smart_bmks, bmk)) {
+ ephy_node_remove_child (smart_bmks, bmk);
+ }
+ }
}
EphyNode *
ephy_bookmarks_add (EphyBookmarks *eb,
- const char *title,
- const char *url)
+ const char *title,
+ const char *url)
{
- EphyNode *bm;
- WebKitFaviconDatabase *favicon_database;
- EphyEmbedShell *shell = ephy_embed_shell_get_default ();
-
- bm = ephy_node_new (eb->db);
-
- if (bm == NULL) return NULL;
-
- if (url == NULL) return NULL;
- ephy_node_set_property_string (bm, EPHY_NODE_BMK_PROP_LOCATION, url);
-
- if (title == NULL || title[0] == '\0')
- {
- title = _("Untitled");
- }
- ephy_node_set_property_string (bm, EPHY_NODE_BMK_PROP_TITLE, title);
-
- favicon_database = webkit_web_context_get_favicon_database (ephy_embed_shell_get_web_context (shell));
- if (favicon_database != NULL)
- {
- char *icon = webkit_favicon_database_get_favicon_uri (favicon_database, url);
- if (icon != NULL)
- {
- ephy_node_set_property_string
- (bm, EPHY_NODE_BMK_PROP_ICON, icon);
- g_free (icon);
- }
- }
-
- update_has_smart_address (eb, bm, url);
- update_bookmark_keywords (eb, bm);
-
- ephy_node_add_child (eb->bookmarks, bm);
- ephy_node_add_child (eb->notcategorized, bm);
-
- ephy_bookmarks_save_delayed (eb, 0);
-
- return bm;
+ EphyNode *bm;
+ WebKitFaviconDatabase *favicon_database;
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
+
+ bm = ephy_node_new (eb->db);
+
+ if (bm == NULL) return NULL;
+
+ if (url == NULL) return NULL;
+ ephy_node_set_property_string (bm, EPHY_NODE_BMK_PROP_LOCATION, url);
+
+ if (title == NULL || title[0] == '\0') {
+ title = _("Untitled");
+ }
+ ephy_node_set_property_string (bm, EPHY_NODE_BMK_PROP_TITLE, title);
+
+ favicon_database = webkit_web_context_get_favicon_database (ephy_embed_shell_get_web_context (shell));
+ if (favicon_database != NULL) {
+ char *icon = webkit_favicon_database_get_favicon_uri (favicon_database, url);
+ if (icon != NULL) {
+ ephy_node_set_property_string
+ (bm, EPHY_NODE_BMK_PROP_ICON, icon);
+ g_free (icon);
+ }
+ }
+
+ update_has_smart_address (eb, bm, url);
+ update_bookmark_keywords (eb, bm);
+
+ ephy_node_add_child (eb->bookmarks, bm);
+ ephy_node_add_child (eb->notcategorized, bm);
+
+ ephy_bookmarks_save_delayed (eb, 0);
+
+ return bm;
}
void
ephy_bookmarks_set_address (EphyBookmarks *eb,
- EphyNode *bookmark,
- const char *address)
+ EphyNode *bookmark,
+ const char *address)
{
- ephy_node_set_property_string (bookmark, EPHY_NODE_BMK_PROP_LOCATION,
- address);
+ ephy_node_set_property_string (bookmark, EPHY_NODE_BMK_PROP_LOCATION,
+ address);
- update_has_smart_address (eb, bookmark, address);
+ update_has_smart_address (eb, bookmark, address);
}
EphyNode *
ephy_bookmarks_find_bookmark (EphyBookmarks *eb,
- const char *url)
+ const char *url)
{
- GPtrArray *children;
- guint i;
-
- g_return_val_if_fail (EPHY_IS_BOOKMARKS (eb), NULL);
- g_return_val_if_fail (eb->bookmarks != NULL, NULL);
- g_return_val_if_fail (url != NULL, NULL);
-
- children = ephy_node_get_children (eb->bookmarks);
- for (i = 0; i < children->len; i++)
- {
- EphyNode *kid;
- const char *location;
-
- kid = g_ptr_array_index (children, i);
- location = ephy_node_get_property_string
- (kid, EPHY_NODE_BMK_PROP_LOCATION);
-
- if (location != NULL && strcmp (url, location) == 0)
- {
- return kid;
- }
- }
-
- return NULL;
+ GPtrArray *children;
+ guint i;
+
+ g_return_val_if_fail (EPHY_IS_BOOKMARKS (eb), NULL);
+ g_return_val_if_fail (eb->bookmarks != NULL, NULL);
+ g_return_val_if_fail (url != NULL, NULL);
+
+ children = ephy_node_get_children (eb->bookmarks);
+ for (i = 0; i < children->len; i++) {
+ EphyNode *kid;
+ const char *location;
+
+ kid = g_ptr_array_index (children, i);
+ location = ephy_node_get_property_string
+ (kid, EPHY_NODE_BMK_PROP_LOCATION);
+
+ if (location != NULL && strcmp (url, location) == 0) {
+ return kid;
+ }
+ }
+
+ return NULL;
}
static gboolean
is_similar (const char *url1, const char *url2)
{
- int i, j;
-
- for (i = 0; url1[i]; i++)
- if (url1[i] == '#' || url1[i] == '?')
- break;
- while(i>0 && url1[i] == '/')
- i--;
-
- for (j = 0; url2[j]; j++)
- if (url2[j] == '#' || url2[j] == '?')
- break;
- while(j>0 && url2[j] == '/')
- j--;
-
- if (i != j) return FALSE;
- if (strncmp (url1, url2, i) != 0) return FALSE;
- return TRUE;
+ int i, j;
+
+ for (i = 0; url1[i]; i++)
+ if (url1[i] == '#' || url1[i] == '?')
+ break;
+ while (i > 0 && url1[i] == '/')
+ i--;
+
+ for (j = 0; url2[j]; j++)
+ if (url2[j] == '#' || url2[j] == '?')
+ break;
+ while (j > 0 && url2[j] == '/')
+ j--;
+
+ if (i != j) return FALSE;
+ if (strncmp (url1, url2, i) != 0) return FALSE;
+ return TRUE;
}
gint
ephy_bookmarks_get_similar (EphyBookmarks *eb,
- EphyNode *bookmark,
- GPtrArray *identical,
- GPtrArray *similar)
-{
- GPtrArray *children;
- const char *url;
- guint i, result;
-
- g_return_val_if_fail (EPHY_IS_BOOKMARKS (eb), -1);
- g_return_val_if_fail (eb->bookmarks != NULL, -1);
- g_return_val_if_fail (bookmark != NULL, -1);
-
- url = ephy_node_get_property_string
- (bookmark, EPHY_NODE_BMK_PROP_LOCATION);
-
- g_return_val_if_fail (url != NULL, -1);
-
- result = 0;
-
- children = ephy_node_get_children (eb->bookmarks);
- for (i = 0; i < children->len; i++)
- {
- EphyNode *kid;
- const char *location;
-
- kid = g_ptr_array_index (children, i);
- if (kid == bookmark)
- {
- continue;
- }
-
- location = ephy_node_get_property_string
- (kid, EPHY_NODE_BMK_PROP_LOCATION);
-
- if (location != NULL)
- {
- if(identical != NULL && strcmp (url, location) == 0)
- {
- g_ptr_array_add (identical, kid);
- result++;
- }
- else if(is_similar (url, location))
- {
- if (similar != NULL)
- {
- g_ptr_array_add (similar, kid);
- }
- result++;
- }
- }
- }
-
- return result;
+ EphyNode *bookmark,
+ GPtrArray *identical,
+ GPtrArray *similar)
+{
+ GPtrArray *children;
+ const char *url;
+ guint i, result;
+
+ g_return_val_if_fail (EPHY_IS_BOOKMARKS (eb), -1);
+ g_return_val_if_fail (eb->bookmarks != NULL, -1);
+ g_return_val_if_fail (bookmark != NULL, -1);
+
+ url = ephy_node_get_property_string
+ (bookmark, EPHY_NODE_BMK_PROP_LOCATION);
+
+ g_return_val_if_fail (url != NULL, -1);
+
+ result = 0;
+
+ children = ephy_node_get_children (eb->bookmarks);
+ for (i = 0; i < children->len; i++) {
+ EphyNode *kid;
+ const char *location;
+
+ kid = g_ptr_array_index (children, i);
+ if (kid == bookmark) {
+ continue;
+ }
+
+ location = ephy_node_get_property_string
+ (kid, EPHY_NODE_BMK_PROP_LOCATION);
+
+ if (location != NULL) {
+ if (identical != NULL && strcmp (url, location) == 0) {
+ g_ptr_array_add (identical, kid);
+ result++;
+ } else if (is_similar (url, location)) {
+ if (similar != NULL) {
+ g_ptr_array_add (similar, kid);
+ }
+ result++;
+ }
+ }
+ }
+
+ return result;
}
void
-ephy_bookmarks_set_icon (EphyBookmarks *eb,
- const char *url,
- const char *icon)
+ephy_bookmarks_set_icon (EphyBookmarks *eb,
+ const char *url,
+ const char *icon)
{
- EphyNode *node;
+ EphyNode *node;
- g_return_if_fail (icon != NULL);
+ g_return_if_fail (icon != NULL);
- node = ephy_bookmarks_find_bookmark (eb, url);
- if (node == NULL) return;
+ node = ephy_bookmarks_find_bookmark (eb, url);
+ if (node == NULL) return;
- ephy_node_set_property_string (node, EPHY_NODE_BMK_PROP_ICON, icon);
+ ephy_node_set_property_string (node, EPHY_NODE_BMK_PROP_ICON, icon);
}
void
ephy_bookmarks_set_usericon (EphyBookmarks *eb,
- const char *url,
- const char *icon)
+ const char *url,
+ const char *icon)
{
- EphyNode *node;
+ EphyNode *node;
- g_return_if_fail (icon != NULL);
+ g_return_if_fail (icon != NULL);
- node = ephy_bookmarks_find_bookmark (eb, url);
- if (node == NULL) return;
+ node = ephy_bookmarks_find_bookmark (eb, url);
+ if (node == NULL) return;
- ephy_node_set_property_string (node, EPHY_NODE_BMK_PROP_USERICON,
- icon);
+ ephy_node_set_property_string (node, EPHY_NODE_BMK_PROP_USERICON,
+ icon);
}
/* name must end with '=' */
static char *
-get_option (char *start,
- const char *name,
- char **optionsend)
+get_option (char *start,
+ const char *name,
+ char **optionsend)
{
- char *end, *p;
+ char *end, *p;
- *optionsend = start;
+ *optionsend = start;
- if (start == NULL || start[0] != '%' || start[1] != '{') return NULL;
- start += 2;
+ if (start == NULL || start[0] != '%' || start[1] != '{') return NULL;
+ start += 2;
- end = strstr (start, "}");
- if (end == NULL) return NULL;
- *optionsend = end + 1;
+ end = strstr (start, "}");
+ if (end == NULL) return NULL;
+ *optionsend = end + 1;
- start = strstr (start, name);
- if (start == NULL || start > end) return NULL;
- start += strlen (name);
+ start = strstr (start, name);
+ if (start == NULL || start > end) return NULL;
+ start += strlen (name);
- /* Find end of option, either ',' or '}' */
- end = strstr (start, ",");
- if (end == NULL || end >= *optionsend) end = *optionsend - 1;
+ /* Find end of option, either ',' or '}' */
+ end = strstr (start, ",");
+ if (end == NULL || end >= *optionsend) end = *optionsend - 1;
- /* limit option length and sanity-check it */
- if (end - start > 32) return NULL;
- for (p = start; p < end; ++p)
- {
- if (!g_ascii_isalnum (*p)) return NULL;
- }
+ /* limit option length and sanity-check it */
+ if (end - start > 32) return NULL;
+ for (p = start; p < end; ++p) {
+ if (!g_ascii_isalnum (*p)) return NULL;
+ }
- return g_strndup (start, end - start);
+ return g_strndup (start, end - start);
}
char *
ephy_bookmarks_resolve_address (EphyBookmarks *eb,
- const char *address,
- const char *content)
-{
- GString *result;
- char *pos, *oldpos, *arg, *escaped_arg, *encoding, *optionsend;
-
- g_return_val_if_fail (EPHY_IS_BOOKMARKS (eb), NULL);
- g_return_val_if_fail (address != NULL, NULL);
-
- if (content == NULL) content = "";
-
- result = g_string_new_len (NULL, strlen (content) + strlen (address));
-
- /* substitute %s's */
- oldpos = (char*) address;
- while ((pos = strstr (oldpos, "%s")) != NULL)
- {
- g_string_append_len (result, oldpos, pos - oldpos);
- pos += 2;
-
- encoding = get_option (pos, "encoding=", &optionsend);
- if (encoding != NULL)
- {
- GError *error = NULL;
-
- arg = g_convert (content, strlen (content), encoding,
- "UTF-8", NULL, NULL, &error);
- if (error != NULL)
- {
- g_warning ("Error when converting arg to encoding '%s': %s\n",
- encoding, error->message);
- g_error_free (error);
- }
- else
- {
- escaped_arg = g_uri_escape_string (arg, NULL, TRUE);
- g_string_append (result, escaped_arg);
- g_free (escaped_arg);
- g_free (arg);
- }
-
- g_free (encoding);
- }
- else
- {
- arg = g_uri_escape_string (content, NULL, TRUE);
- g_string_append (result, arg);
- g_free (arg);
- }
-
- oldpos = optionsend;
- }
- g_string_append (result, oldpos);
-
- return g_string_free (result, FALSE);
+ const char *address,
+ const char *content)
+{
+ GString *result;
+ char *pos, *oldpos, *arg, *escaped_arg, *encoding, *optionsend;
+
+ g_return_val_if_fail (EPHY_IS_BOOKMARKS (eb), NULL);
+ g_return_val_if_fail (address != NULL, NULL);
+
+ if (content == NULL) content = "";
+
+ result = g_string_new_len (NULL, strlen (content) + strlen (address));
+
+ /* substitute %s's */
+ oldpos = (char *)address;
+ while ((pos = strstr (oldpos, "%s")) != NULL) {
+ g_string_append_len (result, oldpos, pos - oldpos);
+ pos += 2;
+
+ encoding = get_option (pos, "encoding=", &optionsend);
+ if (encoding != NULL) {
+ GError *error = NULL;
+
+ arg = g_convert (content, strlen (content), encoding,
+ "UTF-8", NULL, NULL, &error);
+ if (error != NULL) {
+ g_warning ("Error when converting arg to encoding '%s': %s\n",
+ encoding, error->message);
+ g_error_free (error);
+ } else {
+ escaped_arg = g_uri_escape_string (arg, NULL, TRUE);
+ g_string_append (result, escaped_arg);
+ g_free (escaped_arg);
+ g_free (arg);
+ }
+
+ g_free (encoding);
+ } else {
+ arg = g_uri_escape_string (content, NULL, TRUE);
+ g_string_append (result, arg);
+ g_free (arg);
+ }
+
+ oldpos = optionsend;
+ }
+ g_string_append (result, oldpos);
+
+ return g_string_free (result, FALSE);
}
guint
ephy_bookmarks_get_smart_bookmark_width (EphyNode *bookmark)
{
- const char *url;
- char *option, *end, *number;
- guint width;
+ const char *url;
+ char *option, *end, *number;
+ guint width;
- url = ephy_node_get_property_string (bookmark, EPHY_NODE_BMK_PROP_LOCATION);
- if (url == NULL) return 0;
+ url = ephy_node_get_property_string (bookmark, EPHY_NODE_BMK_PROP_LOCATION);
+ if (url == NULL) return 0;
- /* this takes the first %s, but that's okay since we only support one text entry box */
- option = strstr (url, "%s%{");
- if (option == NULL) return 0;
- option += 2;
+ /* this takes the first %s, but that's okay since we only support one text entry box */
+ option = strstr (url, "%s%{");
+ if (option == NULL) return 0;
+ option += 2;
- number = get_option (option, "width=", &end);
- if (number == NULL) return 0;
+ number = get_option (option, "width=", &end);
+ if (number == NULL) return 0;
- width = (guint) g_ascii_strtoull (number, NULL, 10);
- g_free (number);
+ width = (guint)g_ascii_strtoull (number, NULL, 10);
+ g_free (number);
- return CLAMP (width, 1, 64);
+ return CLAMP (width, 1, 64);
}
EphyNode *
ephy_bookmarks_add_keyword (EphyBookmarks *eb,
- const char *name)
+ const char *name)
{
- EphyNode *key;
+ EphyNode *key;
+
+ key = ephy_node_new (eb->db);
- key = ephy_node_new (eb->db);
+ if (key == NULL) return NULL;
- if (key == NULL) return NULL;
+ ephy_node_set_property_string (key, EPHY_NODE_KEYWORD_PROP_NAME,
+ name);
+ ephy_node_set_property_int (key, EPHY_NODE_KEYWORD_PROP_PRIORITY,
+ EPHY_NODE_NORMAL_PRIORITY);
- ephy_node_set_property_string (key, EPHY_NODE_KEYWORD_PROP_NAME,
- name);
- ephy_node_set_property_int (key, EPHY_NODE_KEYWORD_PROP_PRIORITY,
- EPHY_NODE_NORMAL_PRIORITY);
-
- ephy_node_add_child (eb->keywords, key);
+ ephy_node_add_child (eb->keywords, key);
- return key;
+ return key;
}
void
ephy_bookmarks_remove_keyword (EphyBookmarks *eb,
- EphyNode *keyword)
+ EphyNode *keyword)
{
- ephy_node_remove_child (eb->keywords, keyword);
+ ephy_node_remove_child (eb->keywords, keyword);
}
char *
ephy_bookmarks_get_topic_uri (EphyBookmarks *eb,
- EphyNode *node)
+ EphyNode *node)
{
- char *uri;
-
- if (ephy_bookmarks_get_bookmarks (eb) == node)
- {
- uri = g_strdup ("topic://Special/All");
- }
- else if (ephy_bookmarks_get_not_categorized (eb) == node)
- {
- uri = g_strdup ("topic://Special/NotCategorized");
- }
- else if (ephy_bookmarks_get_local (eb) == node)
- {
- /* Note: do not change to "Nearby" because of existing custom toolbars */
- uri = g_strdup ("topic://Special/Local");
- }
- else
- {
- const char *name;
-
- name = ephy_node_get_property_string
- (node, EPHY_NODE_KEYWORD_PROP_NAME);
-
- uri = g_strdup_printf ("topic://%s", name);
- }
-
- return uri;
+ char *uri;
+
+ if (ephy_bookmarks_get_bookmarks (eb) == node) {
+ uri = g_strdup ("topic://Special/All");
+ } else if (ephy_bookmarks_get_not_categorized (eb) == node) {
+ uri = g_strdup ("topic://Special/NotCategorized");
+ } else if (ephy_bookmarks_get_local (eb) == node) {
+ /* Note: do not change to "Nearby" because of existing custom toolbars */
+ uri = g_strdup ("topic://Special/Local");
+ } else {
+ const char *name;
+
+ name = ephy_node_get_property_string
+ (node, EPHY_NODE_KEYWORD_PROP_NAME);
+
+ uri = g_strdup_printf ("topic://%s", name);
+ }
+
+ return uri;
}
EphyNode *
ephy_bookmarks_find_keyword (EphyBookmarks *eb,
- const char *name,
- gboolean partial_match)
-{
- EphyNode *node;
- GPtrArray *children;
- guint i;
- const char *topic_name;
-
- g_return_val_if_fail (name != NULL, NULL);
-
- topic_name = name;
-
- if (g_utf8_strlen (name, -1) == 0)
- {
- LOG ("Empty name, no keyword matches.");
- return NULL;
- }
-
- if (strcmp (name, "topic://Special/All") == 0)
- {
- return ephy_bookmarks_get_bookmarks (eb);
- }
- else if (strcmp (name, "topic://Special/NotCategorized") == 0)
- {
- return ephy_bookmarks_get_not_categorized (eb);
- }
- else if (strcmp (name, "topic://Special/Local") == 0)
- {
- return ephy_bookmarks_get_local (eb);
- }
- else if (g_str_has_prefix (name, "topic://"))
- {
- topic_name += strlen ("topic://");
- }
-
- children = ephy_node_get_children (eb->keywords);
- node = NULL;
- for (i = 0; i < children->len; i++)
- {
- EphyNode *kid;
- const char *key;
-
- kid = g_ptr_array_index (children, i);
- key = ephy_node_get_property_string (kid, EPHY_NODE_KEYWORD_PROP_NAME);
-
- if ((partial_match && g_str_has_prefix (key, topic_name) > 0) ||
- (!partial_match && strcmp (key, topic_name) == 0))
- {
- node = kid;
- }
- }
-
- return node;
+ const char *name,
+ gboolean partial_match)
+{
+ EphyNode *node;
+ GPtrArray *children;
+ guint i;
+ const char *topic_name;
+
+ g_return_val_if_fail (name != NULL, NULL);
+
+ topic_name = name;
+
+ if (g_utf8_strlen (name, -1) == 0) {
+ LOG ("Empty name, no keyword matches.");
+ return NULL;
+ }
+
+ if (strcmp (name, "topic://Special/All") == 0) {
+ return ephy_bookmarks_get_bookmarks (eb);
+ } else if (strcmp (name, "topic://Special/NotCategorized") == 0) {
+ return ephy_bookmarks_get_not_categorized (eb);
+ } else if (strcmp (name, "topic://Special/Local") == 0) {
+ return ephy_bookmarks_get_local (eb);
+ } else if (g_str_has_prefix (name, "topic://")) {
+ topic_name += strlen ("topic://");
+ }
+
+ children = ephy_node_get_children (eb->keywords);
+ node = NULL;
+ for (i = 0; i < children->len; i++) {
+ EphyNode *kid;
+ const char *key;
+
+ kid = g_ptr_array_index (children, i);
+ key = ephy_node_get_property_string (kid, EPHY_NODE_KEYWORD_PROP_NAME);
+
+ if ((partial_match && g_str_has_prefix (key, topic_name) > 0) ||
+ (!partial_match && strcmp (key, topic_name) == 0)) {
+ node = kid;
+ }
+ }
+
+ return node;
}
gboolean
ephy_bookmarks_has_keyword (EphyBookmarks *eb,
- EphyNode *keyword,
- EphyNode *bookmark)
+ EphyNode *keyword,
+ EphyNode *bookmark)
{
- return ephy_node_has_child (keyword, bookmark);
+ return ephy_node_has_child (keyword, bookmark);
}
void
ephy_bookmarks_set_keyword (EphyBookmarks *eb,
- EphyNode *keyword,
- EphyNode *bookmark)
+ EphyNode *keyword,
+ EphyNode *bookmark)
{
- if (ephy_node_has_child (keyword, bookmark)) return;
+ if (ephy_node_has_child (keyword, bookmark)) return;
- ephy_node_add_child (keyword, bookmark);
+ ephy_node_add_child (keyword, bookmark);
- if (ephy_node_has_child (eb->notcategorized, bookmark))
- {
- LOG ("Remove from categorized bookmarks");
- ephy_node_remove_child
- (eb->notcategorized, bookmark);
- }
+ if (ephy_node_has_child (eb->notcategorized, bookmark)) {
+ LOG ("Remove from categorized bookmarks");
+ ephy_node_remove_child
+ (eb->notcategorized, bookmark);
+ }
- update_bookmark_keywords (eb, bookmark);
+ update_bookmark_keywords (eb, bookmark);
- g_signal_emit (G_OBJECT (eb), ephy_bookmarks_signals[TREE_CHANGED], 0);
+ g_signal_emit (G_OBJECT (eb), ephy_bookmarks_signals[TREE_CHANGED], 0);
}
void
ephy_bookmarks_unset_keyword (EphyBookmarks *eb,
- EphyNode *keyword,
- EphyNode *bookmark)
+ EphyNode *keyword,
+ EphyNode *bookmark)
{
- if (!ephy_node_has_child (keyword, bookmark)) return;
+ if (!ephy_node_has_child (keyword, bookmark)) return;
- ephy_node_remove_child (keyword, bookmark);
+ ephy_node_remove_child (keyword, bookmark);
- if (!bookmark_is_categorized (eb, bookmark) &&
- !ephy_node_has_child (eb->notcategorized, bookmark))
- {
- LOG ("Add to not categorized bookmarks");
- ephy_node_add_child
- (eb->notcategorized, bookmark);
- }
+ if (!bookmark_is_categorized (eb, bookmark) &&
+ !ephy_node_has_child (eb->notcategorized, bookmark)) {
+ LOG ("Add to not categorized bookmarks");
+ ephy_node_add_child
+ (eb->notcategorized, bookmark);
+ }
- update_bookmark_keywords (eb, bookmark);
+ update_bookmark_keywords (eb, bookmark);
- g_signal_emit (G_OBJECT (eb), ephy_bookmarks_signals[TREE_CHANGED], 0);
+ g_signal_emit (G_OBJECT (eb), ephy_bookmarks_signals[TREE_CHANGED], 0);
}
/**
@@ -1579,7 +1476,7 @@ ephy_bookmarks_unset_keyword (EphyBookmarks *eb,
EphyNode *
ephy_bookmarks_get_smart_bookmarks (EphyBookmarks *eb)
{
- return eb->smartbookmarks;
+ return eb->smartbookmarks;
}
/**
@@ -1590,7 +1487,7 @@ ephy_bookmarks_get_smart_bookmarks (EphyBookmarks *eb)
EphyNode *
ephy_bookmarks_get_keywords (EphyBookmarks *eb)
{
- return eb->keywords;
+ return eb->keywords;
}
/**
@@ -1601,7 +1498,7 @@ ephy_bookmarks_get_keywords (EphyBookmarks *eb)
EphyNode *
ephy_bookmarks_get_bookmarks (EphyBookmarks *eb)
{
- return eb->bookmarks;
+ return eb->bookmarks;
}
/**
@@ -1612,7 +1509,7 @@ ephy_bookmarks_get_bookmarks (EphyBookmarks *eb)
EphyNode *
ephy_bookmarks_get_local (EphyBookmarks *eb)
{
- return eb->local;
+ return eb->local;
}
/**
@@ -1623,7 +1520,7 @@ ephy_bookmarks_get_local (EphyBookmarks *eb)
EphyNode *
ephy_bookmarks_get_not_categorized (EphyBookmarks *eb)
{
- return eb->notcategorized;
+ return eb->notcategorized;
}
/**
@@ -1634,62 +1531,62 @@ ephy_bookmarks_get_not_categorized (EphyBookmarks *eb)
EphyNode *
ephy_bookmarks_get_from_id (EphyBookmarks *eb, long id)
{
- return ephy_node_db_get_node_from_id (eb->db, id);
+ return ephy_node_db_get_node_from_id (eb->db, id);
}
int
ephy_bookmarks_compare_topics (gconstpointer a, gconstpointer b)
{
- EphyNode *node_a = (EphyNode *)a;
- EphyNode *node_b = (EphyNode *)b;
- const char *title1, *title2;
- int priority1, priority2;
-
- priority1 = ephy_node_get_property_int (node_a, EPHY_NODE_KEYWORD_PROP_PRIORITY);
- priority2 = ephy_node_get_property_int (node_b, EPHY_NODE_KEYWORD_PROP_PRIORITY);
-
- if (priority1 > priority2) return 1;
- if (priority1 < priority2) return -1;
-
- title1 = ephy_node_get_property_string (node_a, EPHY_NODE_KEYWORD_PROP_NAME);
- title2 = ephy_node_get_property_string (node_b, EPHY_NODE_KEYWORD_PROP_NAME);
-
- if (title1 == title2) return 0;
- if (title1 == NULL) return -1;
- if (title2 == NULL) return 1;
- return g_utf8_collate (title1, title2);
+ EphyNode *node_a = (EphyNode *)a;
+ EphyNode *node_b = (EphyNode *)b;
+ const char *title1, *title2;
+ int priority1, priority2;
+
+ priority1 = ephy_node_get_property_int (node_a, EPHY_NODE_KEYWORD_PROP_PRIORITY);
+ priority2 = ephy_node_get_property_int (node_b, EPHY_NODE_KEYWORD_PROP_PRIORITY);
+
+ if (priority1 > priority2) return 1;
+ if (priority1 < priority2) return -1;
+
+ title1 = ephy_node_get_property_string (node_a, EPHY_NODE_KEYWORD_PROP_NAME);
+ title2 = ephy_node_get_property_string (node_b, EPHY_NODE_KEYWORD_PROP_NAME);
+
+ if (title1 == title2) return 0;
+ if (title1 == NULL) return -1;
+ if (title2 == NULL) return 1;
+ return g_utf8_collate (title1, title2);
}
int
ephy_bookmarks_compare_topic_pointers (gconstpointer a, gconstpointer b)
{
- EphyNode *node_a = *(EphyNode **)a;
- EphyNode *node_b = *(EphyNode **)b;
-
- return ephy_bookmarks_compare_topics (node_a, node_b);
+ EphyNode *node_a = *(EphyNode **)a;
+ EphyNode *node_b = *(EphyNode **)b;
+
+ return ephy_bookmarks_compare_topics (node_a, node_b);
}
int
ephy_bookmarks_compare_bookmarks (gconstpointer a, gconstpointer b)
{
- EphyNode *node_a = (EphyNode *)a;
- EphyNode *node_b = (EphyNode *)b;
- const char *title1, *title2;
-
- title1 = ephy_node_get_property_string (node_a, EPHY_NODE_BMK_PROP_TITLE);
- title2 = ephy_node_get_property_string (node_b, EPHY_NODE_BMK_PROP_TITLE);
-
- if (title1 == title2) return 0;
- if (title1 == NULL) return -1;
- if (title2 == NULL) return 1;
- return g_utf8_collate (title1, title2);
+ EphyNode *node_a = (EphyNode *)a;
+ EphyNode *node_b = (EphyNode *)b;
+ const char *title1, *title2;
+
+ title1 = ephy_node_get_property_string (node_a, EPHY_NODE_BMK_PROP_TITLE);
+ title2 = ephy_node_get_property_string (node_b, EPHY_NODE_BMK_PROP_TITLE);
+
+ if (title1 == title2) return 0;
+ if (title1 == NULL) return -1;
+ if (title2 == NULL) return 1;
+ return g_utf8_collate (title1, title2);
}
int
ephy_bookmarks_compare_bookmark_pointers (gconstpointer a, gconstpointer b)
{
- EphyNode *node_a = *(EphyNode **)a;
- EphyNode *node_b = *(EphyNode **)b;
-
- return ephy_bookmarks_compare_bookmarks (node_a, node_b);
+ EphyNode *node_a = *(EphyNode **)a;
+ EphyNode *node_b = *(EphyNode **)b;
+
+ return ephy_bookmarks_compare_bookmarks (node_a, node_b);
}
diff --git a/src/bookmarks/ephy-nodes-cover.c b/src/bookmarks/ephy-nodes-cover.c
index 2e5fe7d..0abbc3a 100644
--- a/src/bookmarks/ephy-nodes-cover.c
+++ b/src/bookmarks/ephy-nodes-cover.c
@@ -23,56 +23,50 @@
gint
ephy_nodes_count_covered (EphyNode *parent, const GPtrArray *children)
{
- guint i, len = 0;
- EphyNode *child;
-
- for(i = 0; i < children->len; i++)
- {
- child = g_ptr_array_index (children, i);
- if (ephy_node_has_child (parent, child))
- {
- len++;
- }
- }
- return len;
+ guint i, len = 0;
+ EphyNode *child;
+
+ for (i = 0; i < children->len; i++) {
+ child = g_ptr_array_index (children, i);
+ if (ephy_node_has_child (parent, child)) {
+ len++;
+ }
+ }
+ return len;
}
/* Removes from the array of children those which are children of the given parent. */
gint
ephy_nodes_remove_covered (EphyNode *parent, GPtrArray *children)
{
- guint i, len = children->len;
- EphyNode *child;
-
- for(i = 0; i < children->len; i++)
- {
- child = g_ptr_array_index (children, i);
- if (ephy_node_has_child (parent, child))
- {
- g_ptr_array_remove_index_fast (children, i);
- i--;
- }
- }
- return len - children->len;
+ guint i, len = children->len;
+ EphyNode *child;
+
+ for (i = 0; i < children->len; i++) {
+ child = g_ptr_array_index (children, i);
+ if (ephy_node_has_child (parent, child)) {
+ g_ptr_array_remove_index_fast (children, i);
+ i--;
+ }
+ }
+ return len - children->len;
}
/* Removes from the array of children those which are children of the given parent. */
gint
ephy_nodes_remove_not_covered (EphyNode *parent, GPtrArray *children)
{
- guint i, len = children->len;
- EphyNode *child;
-
- for(i = 0; i < children->len; i++)
- {
- child = g_ptr_array_index (children, i);
- if (!ephy_node_has_child (parent, child))
- {
- g_ptr_array_remove_index_fast (children, i);
- i--;
- }
- }
- return len - children->len;
+ guint i, len = children->len;
+ EphyNode *child;
+
+ for (i = 0; i < children->len; i++) {
+ child = g_ptr_array_index (children, i);
+ if (!ephy_node_has_child (parent, child)) {
+ g_ptr_array_remove_index_fast (children, i);
+ i--;
+ }
+ }
+ return len - children->len;
}
/* Returns the subset of children which are childs of the given parent.
@@ -80,46 +74,42 @@ ephy_nodes_remove_not_covered (EphyNode *parent, GPtrArray *children)
GPtrArray *
ephy_nodes_get_covered (EphyNode *parent, const GPtrArray *children, GPtrArray *_covered)
{
- GPtrArray *covered = _covered?_covered:g_ptr_array_sized_new (children->len);
- EphyNode *child;
- guint i;
-
- covered->len = 0;
- for (i = 0; i < children->len; i++)
- {
- child = g_ptr_array_index (children, i);
- if (ephy_node_has_child (parent, child))
- {
- g_ptr_array_add (covered, child);
- }
- }
-
- return covered;
+ GPtrArray *covered = _covered ? _covered : g_ptr_array_sized_new (children->len);
+ EphyNode *child;
+ guint i;
+
+ covered->len = 0;
+ for (i = 0; i < children->len; i++) {
+ child = g_ptr_array_index (children, i);
+ if (ephy_node_has_child (parent, child)) {
+ g_ptr_array_add (covered, child);
+ }
+ }
+
+ return covered;
}
/* Returns true if the parent covers all the children. */
gboolean
ephy_nodes_covered (EphyNode *parent, const GPtrArray *children)
{
- EphyNode *child;
- guint i;
-
- for (i = 0; i < children->len; i++)
- {
- child = g_ptr_array_index (children, i);
- if (!ephy_node_has_child (parent, child))
- {
- return FALSE;
- }
- }
-
- return TRUE;
+ EphyNode *child;
+ guint i;
+
+ for (i = 0; i < children->len; i++) {
+ child = g_ptr_array_index (children, i);
+ if (!ephy_node_has_child (parent, child)) {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
}
static gint
compare_chosen (const guint *a, const guint *b, guint *count_c)
{
- return (count_c[*b] - count_c[*a]);
+ return (count_c[*b] - count_c[*a]);
}
/* Returns the subset of parents which provide a covering of children.
@@ -129,82 +119,75 @@ compare_chosen (const guint *a, const guint *b, guint *count_c)
* Uses the _sizes array to store the number of children covered by each parent. */
GPtrArray *
ephy_nodes_get_covering (const GPtrArray *parents, const GPtrArray *children,
- GPtrArray *_covering, GPtrArray *_uncovered, GArray *_sizes)
+ GPtrArray *_covering, GPtrArray *_uncovered, GArray *_sizes)
{
- GPtrArray *uncovered = _uncovered?_uncovered:g_ptr_array_sized_new (children->len);
- GPtrArray *covering = _covering?_covering:g_ptr_array_sized_new (parents->len);
- GArray *chosen = g_array_sized_new (FALSE, FALSE, sizeof(guint), parents->len);
- GArray *sizes = _sizes;
-
- /* Create arrays to store the number of children each parent has which
- * are currently not covered, and the number of children it has total. */
- guint *count_u = g_malloc (sizeof(guint) * parents->len);
- guint *count_c = g_malloc (sizeof(guint) * parents->len);
-
- EphyNode *parent;
- guint i, p;
-
- /* Empty all the returning arrays. */
- uncovered->len = 0;
- covering->len = 0;
- if (sizes) sizes->len = 0;
-
- /* Initialise the array of uncovered bookmarks. */
- for (i = 0; i < children->len; i++)
- {
- g_ptr_array_add (uncovered, g_ptr_array_index (children, i));
- }
-
- /* Initialise the count_u and count_c arrays.
- * NB: count_u[0] is set to 0 if the parent node
- covers the entire set of children. */
- for (i = 0, p = 0; i < parents->len; i++)
- {
- parent = g_ptr_array_index (parents, i);
- count_c[i] = ephy_nodes_count_covered (parent, children);
- count_u[i] = (count_c[i]<children->len) ? count_c[i] : 0;
- if (count_u[i] > count_u[p]) p = i;
- }
-
- /* While there are more suitable topics... */
- while (p < parents->len && count_u[p])
- {
- /* Update the arrays of uncovered bookmarks and covering topics. */
- parent = g_ptr_array_index (parents, p);
- ephy_nodes_remove_covered (parent, uncovered);
- g_array_append_val (chosen, p);
-
- /* Find the next most suitable topic. */
- count_u[p] = 0;
- for (i = 0; i < parents->len; i++)
- {
- /* Lazy update the count_u[i] array. */
- if (count_u[i] > count_u[p] || (count_u[i] == count_u[p] && count_c[i] < count_c[p]))
- {
- parent = g_ptr_array_index (parents, i);
- count_u[i] = ephy_nodes_count_covered (parent, uncovered);
- }
-
- if (count_u[i] > count_u[p] || (count_u[i] == count_u[p] && count_c[i] < count_c[p]))
- {
- p = i;
- }
- }
- }
-
- g_array_sort_with_data (chosen, (GCompareDataFunc)compare_chosen, count_c);
-
- for (i = 0; i < chosen->len; i++)
- {
- p = g_array_index (chosen, guint, i);
- g_ptr_array_add (covering, g_ptr_array_index (parents, p));
- if (sizes) g_array_append_val (sizes, count_c[p]);
- }
-
- if (_uncovered != uncovered) g_ptr_array_free (uncovered, TRUE);
- g_array_free (chosen, TRUE);
- g_free (count_u);
- g_free (count_c);
-
- return covering;
+ GPtrArray *uncovered = _uncovered ? _uncovered : g_ptr_array_sized_new (children->len);
+ GPtrArray *covering = _covering ? _covering : g_ptr_array_sized_new (parents->len);
+ GArray *chosen = g_array_sized_new (FALSE, FALSE, sizeof (guint), parents->len);
+ GArray *sizes = _sizes;
+
+ /* Create arrays to store the number of children each parent has which
+ * are currently not covered, and the number of children it has total. */
+ guint *count_u = g_malloc (sizeof (guint) * parents->len);
+ guint *count_c = g_malloc (sizeof (guint) * parents->len);
+
+ EphyNode *parent;
+ guint i, p;
+
+ /* Empty all the returning arrays. */
+ uncovered->len = 0;
+ covering->len = 0;
+ if (sizes) sizes->len = 0;
+
+ /* Initialise the array of uncovered bookmarks. */
+ for (i = 0; i < children->len; i++) {
+ g_ptr_array_add (uncovered, g_ptr_array_index (children, i));
+ }
+
+ /* Initialise the count_u and count_c arrays.
+ * NB: count_u[0] is set to 0 if the parent node
+ covers the entire set of children. */
+ for (i = 0, p = 0; i < parents->len; i++) {
+ parent = g_ptr_array_index (parents, i);
+ count_c[i] = ephy_nodes_count_covered (parent, children);
+ count_u[i] = (count_c[i] < children->len) ? count_c[i] : 0;
+ if (count_u[i] > count_u[p]) p = i;
+ }
+
+ /* While there are more suitable topics... */
+ while (p < parents->len && count_u[p]) {
+ /* Update the arrays of uncovered bookmarks and covering topics. */
+ parent = g_ptr_array_index (parents, p);
+ ephy_nodes_remove_covered (parent, uncovered);
+ g_array_append_val (chosen, p);
+
+ /* Find the next most suitable topic. */
+ count_u[p] = 0;
+ for (i = 0; i < parents->len; i++) {
+ /* Lazy update the count_u[i] array. */
+ if (count_u[i] > count_u[p] || (count_u[i] == count_u[p] && count_c[i] < count_c[p])) {
+ parent = g_ptr_array_index (parents, i);
+ count_u[i] = ephy_nodes_count_covered (parent, uncovered);
+ }
+
+ if (count_u[i] > count_u[p] || (count_u[i] == count_u[p] && count_c[i] < count_c[p])) {
+ p = i;
+ }
+ }
+ }
+
+ g_array_sort_with_data (chosen, (GCompareDataFunc)compare_chosen, count_c);
+
+ for (i = 0; i < chosen->len; i++) {
+ p = g_array_index (chosen, guint, i);
+ g_ptr_array_add (covering, g_ptr_array_index (parents, p));
+ if (sizes) g_array_append_val (sizes, count_c[p]);
+ }
+
+ if (_uncovered != uncovered) g_ptr_array_free (uncovered, TRUE);
+ g_array_free (chosen, TRUE);
+ g_free (count_u);
+ g_free (count_c);
+
+ return covering;
}
diff --git a/src/bookmarks/ephy-open-tabs-action.c b/src/bookmarks/ephy-open-tabs-action.c
index 99cf641..51b2972 100644
--- a/src/bookmarks/ephy-open-tabs-action.c
+++ b/src/bookmarks/ephy-open-tabs-action.c
@@ -32,103 +32,100 @@
static void
activate_cb (GtkAction *action,
- gpointer dummy)
+ gpointer dummy)
{
- GObject *object = G_OBJECT (action);
- EphyLink *link;
- EphyNode *node;
- GPtrArray *children;
- EphyEmbed *embed = NULL;
- const char *url;
- guint i;
-
- link = g_object_get_data (object, "ephy-link");
- node = g_object_get_data (object, "ephy-node");
-
- children = ephy_node_get_children (node);
- for (i = 0; i < children->len; ++i)
- {
- node = g_ptr_array_index (children, i);
-
- url = ephy_node_get_property_string (node, EPHY_NODE_BMK_PROP_LOCATION);
- embed = ephy_link_open (link, url, embed,
- EPHY_LINK_NEW_TAB | ephy_link_flags_from_current_event ());
- }
+ GObject *object = G_OBJECT (action);
+ EphyLink *link;
+ EphyNode *node;
+ GPtrArray *children;
+ EphyEmbed *embed = NULL;
+ const char *url;
+ guint i;
+
+ link = g_object_get_data (object, "ephy-link");
+ node = g_object_get_data (object, "ephy-node");
+
+ children = ephy_node_get_children (node);
+ for (i = 0; i < children->len; ++i) {
+ node = g_ptr_array_index (children, i);
+
+ url = ephy_node_get_property_string (node, EPHY_NODE_BMK_PROP_LOCATION);
+ embed = ephy_link_open (link, url, embed,
+ EPHY_LINK_NEW_TAB | ephy_link_flags_from_current_event ());
+ }
}
static void
-node_added_cb (EphyNode *parent,
- EphyNode *child,
- GtkActionGroup *action_group)
+node_added_cb (EphyNode *parent,
+ EphyNode *child,
+ GtkActionGroup *action_group)
{
- GObject *action_object;
- GtkAction *action;
- char name[EPHY_OPEN_TABS_ACTION_NAME_BUFFER_SIZE];
- char accel[256];
-
- EPHY_OPEN_TABS_ACTION_NAME_PRINTF (name, child);
-
- /* FIXME !!!! */
- action = gtk_action_new (name, _("Open in New _Tabs"),
- _("Open the bookmarks in this topic in new tabs"), NULL);
- action_object = (GObject *) action;
-
- g_object_set_data (action_object, "ephy-node", child);
- g_object_set_data (action_object, "ephy-link", EPHY_LINK (action_group));
-
- g_signal_connect (action, "activate",
- G_CALLBACK (activate_cb), NULL);
-
- g_snprintf (accel, sizeof (accel), "<Actions>/%s/%s",
- gtk_action_group_get_name (action_group),
- name);
-
- gtk_action_set_accel_path (action, accel);
- gtk_action_group_add_action (action_group, action);
- g_object_unref (action);
+ GObject *action_object;
+ GtkAction *action;
+ char name[EPHY_OPEN_TABS_ACTION_NAME_BUFFER_SIZE];
+ char accel[256];
+
+ EPHY_OPEN_TABS_ACTION_NAME_PRINTF (name, child);
+
+ /* FIXME !!!! */
+ action = gtk_action_new (name, _("Open in New _Tabs"),
+ _("Open the bookmarks in this topic in new tabs"), NULL);
+ action_object = (GObject *)action;
+
+ g_object_set_data (action_object, "ephy-node", child);
+ g_object_set_data (action_object, "ephy-link", EPHY_LINK (action_group));
+
+ g_signal_connect (action, "activate",
+ G_CALLBACK (activate_cb), NULL);
+
+ g_snprintf (accel, sizeof (accel), "<Actions>/%s/%s",
+ gtk_action_group_get_name (action_group),
+ name);
+
+ gtk_action_set_accel_path (action, accel);
+ gtk_action_group_add_action (action_group, action);
+ g_object_unref (action);
}
static void
-node_removed_cb (EphyNode *parent,
- EphyNode *child,
- guint index,
- GtkActionGroup *action_group)
+node_removed_cb (EphyNode *parent,
+ EphyNode *child,
+ guint index,
+ GtkActionGroup *action_group)
{
- GtkAction *action;
- char name[EPHY_OPEN_TABS_ACTION_NAME_BUFFER_SIZE];
+ GtkAction *action;
+ char name[EPHY_OPEN_TABS_ACTION_NAME_BUFFER_SIZE];
+
+ EPHY_OPEN_TABS_ACTION_NAME_PRINTF (name, child);
- EPHY_OPEN_TABS_ACTION_NAME_PRINTF (name, child);
-
- action = gtk_action_group_get_action (action_group, name);
+ action = gtk_action_group_get_action (action_group, name);
- if (action != NULL)
- {
- gtk_action_group_remove_action (action_group, action);
- }
+ if (action != NULL) {
+ gtk_action_group_remove_action (action_group, action);
+ }
}
GtkActionGroup *
ephy_open_tabs_group_new (EphyNode *node)
{
- GPtrArray *children;
- GtkActionGroup *action_group;
- guint i;
-
- children = ephy_node_get_children (node);
- action_group = (GtkActionGroup *) ephy_link_action_group_new ("OpenTabsActions");
-
- for (i = 0; i < children->len; i++)
- {
- node_added_cb (node, g_ptr_array_index (children, i),
- action_group);
- }
-
- ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_ADDED,
- (EphyNodeCallback) node_added_cb,
- (GObject *) action_group);
- ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback) node_removed_cb,
- (GObject *) action_group);
-
- return action_group;
+ GPtrArray *children;
+ GtkActionGroup *action_group;
+ guint i;
+
+ children = ephy_node_get_children (node);
+ action_group = (GtkActionGroup *)ephy_link_action_group_new ("OpenTabsActions");
+
+ for (i = 0; i < children->len; i++) {
+ node_added_cb (node, g_ptr_array_index (children, i),
+ action_group);
+ }
+
+ ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_ADDED,
+ (EphyNodeCallback)node_added_cb,
+ (GObject *)action_group);
+ ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_REMOVED,
+ (EphyNodeCallback)node_removed_cb,
+ (GObject *)action_group);
+
+ return action_group;
}
diff --git a/src/bookmarks/ephy-topic-action-group.c b/src/bookmarks/ephy-topic-action-group.c
index 521c9ac..18c428d 100644
--- a/src/bookmarks/ephy-topic-action-group.c
+++ b/src/bookmarks/ephy-topic-action-group.c
@@ -28,97 +28,94 @@
#include <gtk/gtk.h>
static void
-node_changed_cb (EphyNode *parent,
- EphyNode *child,
- guint property_id,
- GtkActionGroup *action_group)
+node_changed_cb (EphyNode *parent,
+ EphyNode *child,
+ guint property_id,
+ GtkActionGroup *action_group)
{
- GtkAction *action;
- char name[EPHY_TOPIC_ACTION_NAME_BUFFER_SIZE];
+ GtkAction *action;
+ char name[EPHY_TOPIC_ACTION_NAME_BUFFER_SIZE];
- EPHY_TOPIC_ACTION_NAME_PRINTF (name, child);
+ EPHY_TOPIC_ACTION_NAME_PRINTF (name, child);
- action = gtk_action_group_get_action (action_group, name);
-
- if (property_id == EPHY_NODE_KEYWORD_PROP_NAME)
- {
- ephy_topic_action_updated (EPHY_TOPIC_ACTION (action));
- }
+ action = gtk_action_group_get_action (action_group, name);
+
+ if (property_id == EPHY_NODE_KEYWORD_PROP_NAME) {
+ ephy_topic_action_updated (EPHY_TOPIC_ACTION (action));
+ }
}
static void
-node_added_cb (EphyNode *parent,
- EphyNode *child,
- GtkActionGroup *action_group)
+node_added_cb (EphyNode *parent,
+ EphyNode *child,
+ GtkActionGroup *action_group)
{
- GtkUIManager *manager;
- GtkAction *action;
- char name[EPHY_TOPIC_ACTION_NAME_BUFFER_SIZE];
- char accel[256];
+ GtkUIManager *manager;
+ GtkAction *action;
+ char name[EPHY_TOPIC_ACTION_NAME_BUFFER_SIZE];
+ char accel[256];
- EPHY_TOPIC_ACTION_NAME_PRINTF (name, child);
+ EPHY_TOPIC_ACTION_NAME_PRINTF (name, child);
- manager = g_object_get_data ((GObject *) action_group, "ui-manager");
+ manager = g_object_get_data ((GObject *)action_group, "ui-manager");
- action = ephy_topic_action_new (child, manager, name);
+ action = ephy_topic_action_new (child, manager, name);
- g_snprintf (accel, sizeof (accel), "<Actions>/%s/%s",
- gtk_action_group_get_name (action_group),
- name);
- gtk_action_set_accel_path (action, accel);
+ g_snprintf (accel, sizeof (accel), "<Actions>/%s/%s",
+ gtk_action_group_get_name (action_group),
+ name);
+ gtk_action_set_accel_path (action, accel);
- gtk_action_group_add_action (action_group, action);
- g_object_unref (action);
+ gtk_action_group_add_action (action_group, action);
+ g_object_unref (action);
- ephy_topic_action_updated ((EphyTopicAction *) action);
+ ephy_topic_action_updated ((EphyTopicAction *)action);
}
static void
node_removed_cb (EphyNode *parent,
- EphyNode *child, guint index,
- GtkActionGroup *action_group)
+ EphyNode *child, guint index,
+ GtkActionGroup *action_group)
{
- GtkAction *action;
- char name[EPHY_TOPIC_ACTION_NAME_BUFFER_SIZE];
-
- EPHY_TOPIC_ACTION_NAME_PRINTF (name, child);
-
- action = gtk_action_group_get_action (action_group, name);
-
- if (action)
- {
- gtk_action_group_remove_action (action_group, action);
- }
+ GtkAction *action;
+ char name[EPHY_TOPIC_ACTION_NAME_BUFFER_SIZE];
+
+ EPHY_TOPIC_ACTION_NAME_PRINTF (name, child);
+
+ action = gtk_action_group_get_action (action_group, name);
+
+ if (action) {
+ gtk_action_group_remove_action (action_group, action);
+ }
}
GtkActionGroup *
-ephy_topic_action_group_new (EphyNode *node,
- GtkUIManager *manager)
+ephy_topic_action_group_new (EphyNode *node,
+ GtkUIManager *manager)
{
- GPtrArray *children;
- GtkActionGroup *action_group;
- guint i;
-
- children = ephy_node_get_children (node);
- action_group = gtk_action_group_new ("TpAc");
-
- g_object_set_data ((GObject *) action_group, "ui-manager", manager);
-
- for (i = 0; i < children->len; i++)
- {
- node_added_cb (node, g_ptr_array_index (children, i),
- action_group);
- }
-
- ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_ADDED,
- (EphyNodeCallback) node_added_cb,
- (GObject *) action_group);
- ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback) node_removed_cb,
- (GObject *) action_group);
- ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_CHANGED,
- (EphyNodeCallback) node_changed_cb,
- (GObject *) action_group);
-
- return (GtkActionGroup *) action_group;
+ GPtrArray *children;
+ GtkActionGroup *action_group;
+ guint i;
+
+ children = ephy_node_get_children (node);
+ action_group = gtk_action_group_new ("TpAc");
+
+ g_object_set_data ((GObject *)action_group, "ui-manager", manager);
+
+ for (i = 0; i < children->len; i++) {
+ node_added_cb (node, g_ptr_array_index (children, i),
+ action_group);
+ }
+
+ ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_ADDED,
+ (EphyNodeCallback)node_added_cb,
+ (GObject *)action_group);
+ ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_REMOVED,
+ (EphyNodeCallback)node_removed_cb,
+ (GObject *)action_group);
+ ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_CHANGED,
+ (EphyNodeCallback)node_changed_cb,
+ (GObject *)action_group);
+
+ return (GtkActionGroup *)action_group;
}
diff --git a/src/bookmarks/ephy-topic-action.c b/src/bookmarks/ephy-topic-action.c
index 016dba1..d125ea0 100644
--- a/src/bookmarks/ephy-topic-action.c
+++ b/src/bookmarks/ephy-topic-action.c
@@ -36,19 +36,17 @@
#define EPHY_TOPIC_ACTION_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_TOPIC_ACTION,
EphyTopicActionPrivate))
-struct _EphyTopicActionPrivate
-{
- EphyNode *node;
- GtkUIManager *manager;
- guint merge_id;
+struct _EphyTopicActionPrivate {
+ EphyNode *node;
+ GtkUIManager *manager;
+ guint merge_id;
};
-enum
-{
- PROP_0,
- PROP_TOPIC,
- PROP_MANAGER,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_TOPIC,
+ PROP_MANAGER,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
@@ -56,321 +54,307 @@ static GParamSpec *obj_properties[LAST_PROP];
G_DEFINE_TYPE (EphyTopicAction, ephy_topic_action, GTK_TYPE_ACTION)
static void
-ephy_topic_action_sync_label (GtkAction *action,
- GParamSpec *pspec,
- GtkWidget *proxy)
+ephy_topic_action_sync_label (GtkAction *action,
+ GParamSpec *pspec,
+ GtkWidget *proxy)
{
- GtkWidget *label = NULL;
- GValue value = { 0, };
- const char *label_text;
-
- g_value_init (&value, G_TYPE_STRING);
- g_object_get_property (G_OBJECT (action), "label", &value);
-
- label_text = g_value_get_string (&value);
-
- if (GTK_IS_MENU_ITEM (proxy))
- {
- label = gtk_bin_get_child (GTK_BIN (proxy));
- }
- else
- {
- g_warning ("Unknown widget");
- return;
- }
-
- g_return_if_fail (label != NULL);
-
- if (label_text)
- {
- gtk_label_set_label (GTK_LABEL (label), label_text);
- }
-
- g_value_unset (&value);
+ GtkWidget *label = NULL;
+ GValue value = { 0, };
+ const char *label_text;
+
+ g_value_init (&value, G_TYPE_STRING);
+ g_object_get_property (G_OBJECT (action), "label", &value);
+
+ label_text = g_value_get_string (&value);
+
+ if (GTK_IS_MENU_ITEM (proxy)) {
+ label = gtk_bin_get_child (GTK_BIN (proxy));
+ } else {
+ g_warning ("Unknown widget");
+ return;
+ }
+
+ g_return_if_fail (label != NULL);
+
+ if (label_text) {
+ gtk_label_set_label (GTK_LABEL (label), label_text);
+ }
+
+ g_value_unset (&value);
}
static GtkWidget *
get_popup (EphyTopicAction *action)
{
- EphyTopicActionPrivate *priv = action->priv;
- char path[40];
+ EphyTopicActionPrivate *priv = action->priv;
+ char path[40];
- g_snprintf (path, sizeof (path), "/PopupTopic%ld",
- (long int) ephy_node_get_id (action->priv->node));
+ g_snprintf (path, sizeof (path), "/PopupTopic%ld",
+ (long int)ephy_node_get_id (action->priv->node));
- if (priv->merge_id == 0)
- {
- GString *popup_menu_string;
+ if (priv->merge_id == 0) {
+ GString *popup_menu_string;
- popup_menu_string = g_string_new (NULL);
- g_string_append_printf (popup_menu_string, "<ui><popup name=\"%s\">", path + 1);
+ popup_menu_string = g_string_new (NULL);
+ g_string_append_printf (popup_menu_string, "<ui><popup name=\"%s\">", path + 1);
- ephy_bookmarks_menu_build (popup_menu_string, priv->node);
- g_string_append (popup_menu_string, "</popup></ui>");
+ ephy_bookmarks_menu_build (popup_menu_string, priv->node);
+ g_string_append (popup_menu_string, "</popup></ui>");
- priv->merge_id = gtk_ui_manager_add_ui_from_string
- (priv->manager, popup_menu_string->str,
- popup_menu_string->len, 0);
+ priv->merge_id = gtk_ui_manager_add_ui_from_string
+ (priv->manager, popup_menu_string->str,
+ popup_menu_string->len, 0);
- g_string_free (popup_menu_string, TRUE);
- }
+ g_string_free (popup_menu_string, TRUE);
+ }
- return gtk_ui_manager_get_widget (priv->manager, path);
+ return gtk_ui_manager_get_widget (priv->manager, path);
}
static void
erase_popup (EphyTopicAction *action)
{
- EphyTopicActionPrivate *priv = action->priv;
+ EphyTopicActionPrivate *priv = action->priv;
- if (priv->merge_id != 0)
- {
- gtk_ui_manager_remove_ui (priv->manager, priv->merge_id);
- priv->merge_id = 0;
- }
+ if (priv->merge_id != 0) {
+ gtk_ui_manager_remove_ui (priv->manager, priv->merge_id);
+ priv->merge_id = 0;
+ }
}
static void
child_added_cb (EphyNode *node, EphyNode *child, GObject *object)
{
- EphyTopicAction *action = EPHY_TOPIC_ACTION (object);
- erase_popup (action);
+ EphyTopicAction *action = EPHY_TOPIC_ACTION (object);
+ erase_popup (action);
}
static void
child_changed_cb (EphyNode *node,
- EphyNode *child,
- guint property,
- GObject *object)
+ EphyNode *child,
+ guint property,
+ GObject *object)
{
- EphyTopicAction *action = EPHY_TOPIC_ACTION (object);
+ EphyTopicAction *action = EPHY_TOPIC_ACTION (object);
- erase_popup (action);
+ erase_popup (action);
}
static void
child_removed_cb (EphyNode *node,
- EphyNode *child,
- guint index,
- GObject *object)
+ EphyNode *child,
+ guint index,
+ GObject *object)
{
- EphyTopicAction *action = EPHY_TOPIC_ACTION (object);
+ EphyTopicAction *action = EPHY_TOPIC_ACTION (object);
- erase_popup (action);
+ erase_popup (action);
}
static void
menu_destroy_cb (GtkWidget *menuitem,
- gpointer user_data)
+ gpointer user_data)
{
- /* Save the submenu from similar destruction,
- * because it doesn't rightly belong to this menuitem. */
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), NULL);
+ /* Save the submenu from similar destruction,
+ * because it doesn't rightly belong to this menuitem. */
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), NULL);
}
static void
-menu_init_cb (GtkWidget *menuitem,
- EphyTopicAction *action)
+menu_init_cb (GtkWidget *menuitem,
+ EphyTopicAction *action)
{
- if (gtk_menu_item_get_submenu (GTK_MENU_ITEM (menuitem)) == NULL)
- {
- GtkWidget *popup;
-
- popup = get_popup (action);
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), popup);
- g_signal_connect (menuitem, "destroy",
- G_CALLBACK (menu_destroy_cb), NULL);
- }
+ if (gtk_menu_item_get_submenu (GTK_MENU_ITEM (menuitem)) == NULL) {
+ GtkWidget *popup;
+
+ popup = get_popup (action);
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), popup);
+ g_signal_connect (menuitem, "destroy",
+ G_CALLBACK (menu_destroy_cb), NULL);
+ }
}
static void
connect_proxy (GtkAction *action,
- GtkWidget *proxy)
+ GtkWidget *proxy)
{
- GTK_ACTION_CLASS (ephy_topic_action_parent_class)->connect_proxy (action, proxy);
-
- ephy_topic_action_sync_label (action, NULL, proxy);
- g_signal_connect_object (action, "notify::label",
- G_CALLBACK (ephy_topic_action_sync_label), proxy, 0);
-
- if (GTK_IS_MENU_ITEM (proxy))
- {
- g_signal_connect (proxy, "map",
- G_CALLBACK (menu_init_cb), action);
- }
+ GTK_ACTION_CLASS (ephy_topic_action_parent_class)->connect_proxy (action, proxy);
+
+ ephy_topic_action_sync_label (action, NULL, proxy);
+ g_signal_connect_object (action, "notify::label",
+ G_CALLBACK (ephy_topic_action_sync_label), proxy, 0);
+
+ if (GTK_IS_MENU_ITEM (proxy)) {
+ g_signal_connect (proxy, "map",
+ G_CALLBACK (menu_init_cb), action);
+ }
}
void
ephy_topic_action_updated (EphyTopicAction *action)
{
- EphyTopicActionPrivate *priv = action->priv;
- GValue value = { 0, };
- const char *title;
- int priority;
-
- g_return_if_fail (priv->node != NULL);
-
- priority = ephy_node_get_property_int
- (priv->node, EPHY_NODE_KEYWORD_PROP_PRIORITY);
-
- if (priority == EPHY_NODE_ALL_PRIORITY)
- {
- title = _("Bookmarks");
- }
- else
- {
- title = ephy_node_get_property_string
- (priv->node, EPHY_NODE_KEYWORD_PROP_NAME);
- }
-
- g_value_init(&value, G_TYPE_STRING);
- g_value_set_static_string (&value, title);
- g_object_set_property (G_OBJECT (action), "label", &value);
- g_object_set_property (G_OBJECT (action), "tooltip", &value);
- g_value_unset (&value);
+ EphyTopicActionPrivate *priv = action->priv;
+ GValue value = { 0, };
+ const char *title;
+ int priority;
+
+ g_return_if_fail (priv->node != NULL);
+
+ priority = ephy_node_get_property_int
+ (priv->node, EPHY_NODE_KEYWORD_PROP_PRIORITY);
+
+ if (priority == EPHY_NODE_ALL_PRIORITY) {
+ title = _("Bookmarks");
+ } else {
+ title = ephy_node_get_property_string
+ (priv->node, EPHY_NODE_KEYWORD_PROP_NAME);
+ }
+
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_set_static_string (&value, title);
+ g_object_set_property (G_OBJECT (action), "label", &value);
+ g_object_set_property (G_OBJECT (action), "tooltip", &value);
+ g_value_unset (&value);
}
EphyNode *
ephy_topic_action_get_topic (EphyTopicAction *action)
{
- EphyTopicActionPrivate *priv = action->priv;
+ EphyTopicActionPrivate *priv = action->priv;
- return priv->node;
+ return priv->node;
}
void
ephy_topic_action_set_topic (EphyTopicAction *action,
- EphyNode *node)
+ EphyNode *node)
{
- EphyTopicActionPrivate *priv = action->priv;
- GObject *object = G_OBJECT (action);
-
- g_return_if_fail (node != NULL);
-
- if (priv->node == node) return;
-
- if (priv->node != NULL)
- {
- ephy_node_signal_disconnect_object
- (priv->node, EPHY_NODE_CHILD_ADDED,
- (EphyNodeCallback) child_added_cb, object);
- ephy_node_signal_disconnect_object
- (priv->node, EPHY_NODE_CHILD_CHANGED,
- (EphyNodeCallback)child_changed_cb, object);
- ephy_node_signal_disconnect_object
- (priv->node, EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback)child_removed_cb, object);
- }
-
- ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_ADDED,
- (EphyNodeCallback) child_added_cb,
- object);
- ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_CHANGED,
- (EphyNodeCallback) child_changed_cb,
- object);
- ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback) child_removed_cb,
- object);
-
- priv->node = node;
-
- erase_popup (action);
-
- g_object_freeze_notify (object);
- g_object_notify_by_pspec (object, obj_properties[PROP_TOPIC]);
- ephy_topic_action_updated (action);
- g_object_thaw_notify (object);
+ EphyTopicActionPrivate *priv = action->priv;
+ GObject *object = G_OBJECT (action);
+
+ g_return_if_fail (node != NULL);
+
+ if (priv->node == node) return;
+
+ if (priv->node != NULL) {
+ ephy_node_signal_disconnect_object
+ (priv->node, EPHY_NODE_CHILD_ADDED,
+ (EphyNodeCallback)child_added_cb, object);
+ ephy_node_signal_disconnect_object
+ (priv->node, EPHY_NODE_CHILD_CHANGED,
+ (EphyNodeCallback)child_changed_cb, object);
+ ephy_node_signal_disconnect_object
+ (priv->node, EPHY_NODE_CHILD_REMOVED,
+ (EphyNodeCallback)child_removed_cb, object);
+ }
+
+ ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_ADDED,
+ (EphyNodeCallback)child_added_cb,
+ object);
+ ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_CHANGED,
+ (EphyNodeCallback)child_changed_cb,
+ object);
+ ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_REMOVED,
+ (EphyNodeCallback)child_removed_cb,
+ object);
+
+ priv->node = node;
+
+ erase_popup (action);
+
+ g_object_freeze_notify (object);
+ g_object_notify_by_pspec (object, obj_properties[PROP_TOPIC]);
+ ephy_topic_action_updated (action);
+ g_object_thaw_notify (object);
}
static void
-ephy_topic_action_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ephy_topic_action_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- EphyTopicAction *action = EPHY_TOPIC_ACTION (object);
- EphyTopicActionPrivate *priv = action->priv;
-
- switch (prop_id)
- {
- case PROP_TOPIC:
- ephy_topic_action_set_topic (action, g_value_get_pointer (value));
- break;
- case PROP_MANAGER:
- priv->manager = g_value_get_object (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
+ EphyTopicAction *action = EPHY_TOPIC_ACTION (object);
+ EphyTopicActionPrivate *priv = action->priv;
+
+ switch (prop_id) {
+ case PROP_TOPIC:
+ ephy_topic_action_set_topic (action, g_value_get_pointer (value));
+ break;
+ case PROP_MANAGER:
+ priv->manager = g_value_get_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
-ephy_topic_action_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ephy_topic_action_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- EphyTopicAction *action = EPHY_TOPIC_ACTION (object);
- EphyTopicActionPrivate *priv = action->priv;
-
- switch (prop_id)
- {
- case PROP_TOPIC:
- g_value_set_pointer (value, priv->node);
- break;
- case PROP_MANAGER:
- g_value_set_object (value, priv->manager);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
+ EphyTopicAction *action = EPHY_TOPIC_ACTION (object);
+ EphyTopicActionPrivate *priv = action->priv;
+
+ switch (prop_id) {
+ case PROP_TOPIC:
+ g_value_set_pointer (value, priv->node);
+ break;
+ case PROP_MANAGER:
+ g_value_set_object (value, priv->manager);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
ephy_topic_action_init (EphyTopicAction *action)
{
- action->priv = EPHY_TOPIC_ACTION_GET_PRIVATE (action);
+ action->priv = EPHY_TOPIC_ACTION_GET_PRIVATE (action);
}
static void
ephy_topic_action_class_init (EphyTopicActionClass *class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
- GtkActionClass *action_class = GTK_ACTION_CLASS (class);
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GtkActionClass *action_class = GTK_ACTION_CLASS (class);
- action_class->connect_proxy = connect_proxy;
+ action_class->connect_proxy = connect_proxy;
- object_class->set_property = ephy_topic_action_set_property;
- object_class->get_property = ephy_topic_action_get_property;
+ object_class->set_property = ephy_topic_action_set_property;
+ object_class->get_property = ephy_topic_action_get_property;
- obj_properties[PROP_TOPIC] =
- g_param_spec_pointer ("topic",
- "Topic",
- "Topic",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+ obj_properties[PROP_TOPIC] =
+ g_param_spec_pointer ("topic",
+ "Topic",
+ "Topic",
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
- obj_properties[PROP_MANAGER] =
- g_param_spec_object ("manager",
- "Manager",
- "UI Manager",
- GTK_TYPE_UI_MANAGER,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+ obj_properties[PROP_MANAGER] =
+ g_param_spec_object ("manager",
+ "Manager",
+ "UI Manager",
+ GTK_TYPE_UI_MANAGER,
+ G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
- g_type_class_add_private (object_class, sizeof(EphyTopicActionPrivate));
+ g_type_class_add_private (object_class, sizeof (EphyTopicActionPrivate));
}
GtkAction *
-ephy_topic_action_new (EphyNode *node,
- GtkUIManager *manager,
- const char *name)
+ephy_topic_action_new (EphyNode *node,
+ GtkUIManager *manager,
+ const char *name)
{
- g_assert (name != NULL);
+ g_assert (name != NULL);
- return GTK_ACTION (g_object_new (EPHY_TYPE_TOPIC_ACTION,
- "name", name,
- "topic", node,
- "manager", manager,
- NULL));
+ return GTK_ACTION (g_object_new (EPHY_TYPE_TOPIC_ACTION,
+ "name", name,
+ "topic", node,
+ "manager", manager,
+ NULL));
}
diff --git a/src/bookmarks/ephy-topics-entry.c b/src/bookmarks/ephy-topics-entry.c
index f872c8d..ae43a26 100644
--- a/src/bookmarks/ephy-topics-entry.c
+++ b/src/bookmarks/ephy-topics-entry.c
@@ -28,544 +28,511 @@
#include <gtk/gtk.h>
#include <string.h>
-struct _EphyTopicsEntry
-{
- GtkEntry parent_instance;
-
- EphyBookmarks *bookmarks;
- EphyNode *bookmark;
- GtkListStore *store;
- GtkEntryCompletion *completion;
- gboolean lock;
- char *create;
- char *key;
+struct _EphyTopicsEntry {
+ GtkEntry parent_instance;
+
+ EphyBookmarks *bookmarks;
+ EphyNode *bookmark;
+ GtkListStore *store;
+ GtkEntryCompletion *completion;
+ gboolean lock;
+ char *create;
+ char *key;
};
-enum
-{
- PROP_0,
- PROP_BOOKMARKS,
- PROP_BOOKMARK,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_BOOKMARKS,
+ PROP_BOOKMARK,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
-enum
-{
- COLUMN_NODE,
- COLUMN_KEY,
- COLUMN_TITLE,
- COLUMNS
+enum {
+ COLUMN_NODE,
+ COLUMN_KEY,
+ COLUMN_TITLE,
+ COLUMNS
};
G_DEFINE_TYPE (EphyTopicsEntry, ephy_topics_entry, GTK_TYPE_ENTRY)
static EphyNode *
-find_topic (EphyTopicsEntry *entry,
- const char *key)
+find_topic (EphyTopicsEntry * entry,
+ const char *key)
{
- EphyNode *node = NULL;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GValue value = { 0, };
- gboolean valid;
-
- /* Loop through our table and set/unset topics appropriately */
- model = GTK_TREE_MODEL (entry->store);
- valid = gtk_tree_model_get_iter_first (model, &iter);
- while (valid && node == NULL)
- {
- gtk_tree_model_get_value (model, &iter, COLUMN_KEY, &value);
- if (strcmp(g_value_get_string (&value), key) == 0)
- {
- g_value_unset (&value);
- gtk_tree_model_get_value (model, &iter, COLUMN_NODE, &value);
- node = g_value_get_pointer (&value);
- }
- g_value_unset (&value);
- valid = gtk_tree_model_iter_next (model, &iter);
- }
-
- return node;
+ EphyNode *node = NULL;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GValue value = { 0, };
+ gboolean valid;
+
+ /* Loop through our table and set/unset topics appropriately */
+ model = GTK_TREE_MODEL (entry->store);
+ valid = gtk_tree_model_get_iter_first (model, &iter);
+ while (valid && node == NULL) {
+ gtk_tree_model_get_value (model, &iter, COLUMN_KEY, &value);
+ if (strcmp (g_value_get_string (&value), key) == 0) {
+ g_value_unset (&value);
+ gtk_tree_model_get_value (model, &iter, COLUMN_NODE, &value);
+ node = g_value_get_pointer (&value);
+ }
+ g_value_unset (&value);
+ valid = gtk_tree_model_iter_next (model, &iter);
+ }
+
+ return node;
}
static void
insert_text (EphyTopicsEntry *entry,
- const char *title)
+ const char *title)
{
- GtkEditable *editable = GTK_EDITABLE (entry);
-
- const gchar *text = gtk_entry_get_text (GTK_ENTRY (entry));
- const gchar *midpoint = g_utf8_offset_to_pointer (text, gtk_editable_get_position (editable));
- const gchar *start = g_utf8_strrchr (text, (gssize)(midpoint-text), ',');
- const gchar *end = g_utf8_strchr (midpoint, -1, ',');
- int startpos, endpos;
-
- if (start == NULL)
- startpos = 0;
- else if (g_unichar_isspace (g_utf8_get_char (g_utf8_next_char (start))))
- startpos = g_utf8_pointer_to_offset (text, start)+2;
- else
- startpos = g_utf8_pointer_to_offset (text, start)+1;
-
- if (end == NULL)
- endpos = -1;
- else if (g_unichar_isspace (g_utf8_get_char (g_utf8_next_char (end))))
- endpos = g_utf8_pointer_to_offset (text, end)+2;
- else
- endpos = g_utf8_pointer_to_offset (text, end)+1;
-
- /* Replace the text in the current position with the title */
- gtk_editable_delete_text (editable, startpos, endpos);
- gtk_editable_insert_text (editable, title, strlen(title), &startpos);
- gtk_editable_insert_text (editable, ", ", 2, &startpos);
- gtk_editable_set_position (editable, startpos);
+ GtkEditable *editable = GTK_EDITABLE (entry);
+
+ const gchar *text = gtk_entry_get_text (GTK_ENTRY (entry));
+ const gchar *midpoint = g_utf8_offset_to_pointer (text, gtk_editable_get_position (editable));
+ const gchar *start = g_utf8_strrchr (text, (gssize)(midpoint - text), ',');
+ const gchar *end = g_utf8_strchr (midpoint, -1, ',');
+ int startpos, endpos;
+
+ if (start == NULL)
+ startpos = 0;
+ else if (g_unichar_isspace (g_utf8_get_char (g_utf8_next_char (start))))
+ startpos = g_utf8_pointer_to_offset (text, start) + 2;
+ else
+ startpos = g_utf8_pointer_to_offset (text, start) + 1;
+
+ if (end == NULL)
+ endpos = -1;
+ else if (g_unichar_isspace (g_utf8_get_char (g_utf8_next_char (end))))
+ endpos = g_utf8_pointer_to_offset (text, end) + 2;
+ else
+ endpos = g_utf8_pointer_to_offset (text, end) + 1;
+
+ /* Replace the text in the current position with the title */
+ gtk_editable_delete_text (editable, startpos, endpos);
+ gtk_editable_insert_text (editable, title, strlen (title), &startpos);
+ gtk_editable_insert_text (editable, ", ", 2, &startpos);
+ gtk_editable_set_position (editable, startpos);
}
/* Updates the text entry and the completion model to match the database */
static void
update_widget (EphyTopicsEntry *entry)
{
- GtkEditable *editable = GTK_EDITABLE (entry);
-
- EphyNode *node;
- GPtrArray *children, *topics;
- GtkTreeIter iter;
- guint i;
- gint priority, pos;
- const char *title;
- char *tmp1, *tmp2;
- gboolean is_focus;
-
- /* Prevent any changes to the database */
- if (entry->lock) return;
- entry->lock = TRUE;
-
- node = ephy_bookmarks_get_keywords (entry->bookmarks);
- children = ephy_node_get_children (node);
- topics = g_ptr_array_sized_new (children->len);
-
- for (i = 0; i < children->len; i++)
- {
- node = g_ptr_array_index (children, i);
-
- priority = ephy_node_get_property_int
- (node, EPHY_NODE_KEYWORD_PROP_PRIORITY);
- if (priority != EPHY_NODE_NORMAL_PRIORITY)
- continue;
-
- g_ptr_array_add (topics, node);
- }
-
- g_ptr_array_sort (topics, ephy_bookmarks_compare_topic_pointers);
- gtk_list_store_clear (entry->store);
-
- g_object_get (entry, "is-focus", &is_focus, NULL);
- if (!is_focus)
- {
- gtk_editable_delete_text (editable, 0, -1);
- }
-
- for (pos = 0, i = 0; i < topics->len; i++)
- {
- node = g_ptr_array_index (topics, i);
- title = ephy_node_get_property_string (node, EPHY_NODE_KEYWORD_PROP_NAME);
-
- if (!is_focus && ephy_node_has_child (node, entry->bookmark))
- {
- if (pos > 0)
- gtk_editable_insert_text (editable, ", ", -1, &pos);
- gtk_editable_insert_text (editable, title, -1, &pos);
- }
-
- tmp1 = g_utf8_casefold (title, -1);
- tmp2 = g_utf8_normalize (tmp1, -1, G_NORMALIZE_DEFAULT);
- gtk_list_store_append (entry->store, &iter);
- gtk_list_store_set (entry->store, &iter,
- COLUMN_NODE, node,
- COLUMN_TITLE, title,
- COLUMN_KEY, tmp2,
- -1);
- g_free (tmp2);
- g_free (tmp1);
- }
-
- if (!is_focus)
- {
- gtk_editable_set_position (editable, -1);
- }
-
- g_ptr_array_free (topics, TRUE);
-
- entry->lock = FALSE;
+ GtkEditable *editable = GTK_EDITABLE (entry);
+
+ EphyNode *node;
+ GPtrArray *children, *topics;
+ GtkTreeIter iter;
+ guint i;
+ gint priority, pos;
+ const char *title;
+ char *tmp1, *tmp2;
+ gboolean is_focus;
+
+ /* Prevent any changes to the database */
+ if (entry->lock) return;
+ entry->lock = TRUE;
+
+ node = ephy_bookmarks_get_keywords (entry->bookmarks);
+ children = ephy_node_get_children (node);
+ topics = g_ptr_array_sized_new (children->len);
+
+ for (i = 0; i < children->len; i++) {
+ node = g_ptr_array_index (children, i);
+
+ priority = ephy_node_get_property_int
+ (node, EPHY_NODE_KEYWORD_PROP_PRIORITY);
+ if (priority != EPHY_NODE_NORMAL_PRIORITY)
+ continue;
+
+ g_ptr_array_add (topics, node);
+ }
+
+ g_ptr_array_sort (topics, ephy_bookmarks_compare_topic_pointers);
+ gtk_list_store_clear (entry->store);
+
+ g_object_get (entry, "is-focus", &is_focus, NULL);
+ if (!is_focus) {
+ gtk_editable_delete_text (editable, 0, -1);
+ }
+
+ for (pos = 0, i = 0; i < topics->len; i++) {
+ node = g_ptr_array_index (topics, i);
+ title = ephy_node_get_property_string (node, EPHY_NODE_KEYWORD_PROP_NAME);
+
+ if (!is_focus && ephy_node_has_child (node, entry->bookmark)) {
+ if (pos > 0)
+ gtk_editable_insert_text (editable, ", ", -1, &pos);
+ gtk_editable_insert_text (editable, title, -1, &pos);
+ }
+
+ tmp1 = g_utf8_casefold (title, -1);
+ tmp2 = g_utf8_normalize (tmp1, -1, G_NORMALIZE_DEFAULT);
+ gtk_list_store_append (entry->store, &iter);
+ gtk_list_store_set (entry->store, &iter,
+ COLUMN_NODE, node,
+ COLUMN_TITLE, title,
+ COLUMN_KEY, tmp2,
+ -1);
+ g_free (tmp2);
+ g_free (tmp1);
+ }
+
+ if (!is_focus) {
+ gtk_editable_set_position (editable, -1);
+ }
+
+ g_ptr_array_free (topics, TRUE);
+
+ entry->lock = FALSE;
}
/* Updates the bookmarks database to match what is in the text entry */
static void
update_database (EphyTopicsEntry *entry)
{
- EphyNode *node;
- const char *text;
- char **split;
- char *tmp;
- gint i;
-
- GtkTreeModel *model;
- GtkTreeIter iter;
- GValue value = { 0, };
- gboolean valid;
-
- /* Prevent any changes to the text entry or completion model */
- if (entry->lock) return;
- entry->lock = TRUE;
-
- /* Get the list of strings input by the user */
- text = gtk_entry_get_text (GTK_ENTRY (entry));
- split = g_strsplit (text, ",", 0);
- for (i=0; split[i]; i++)
- {
- g_strstrip (split[i]);
-
- tmp = g_utf8_casefold (split[i], -1);
- g_free (split[i]);
-
- split[i] = g_utf8_normalize (tmp, -1, G_NORMALIZE_DEFAULT);
- g_free (tmp);
- }
-
- /* Loop through the completion model and set/unset topics appropriately */
- model = GTK_TREE_MODEL (entry->store);
- valid = gtk_tree_model_get_iter_first (model, &iter);
- while (valid)
- {
- gtk_tree_model_get_value (model, &iter, COLUMN_NODE, &value);
- node = g_value_get_pointer (&value);
- g_value_unset (&value);
-
- gtk_tree_model_get_value (model, &iter, COLUMN_KEY, &value);
- text = g_value_get_string (&value);
-
- for (i=0; split[i]; i++)
- if (strcmp (text, split[i]) == 0)
- break;
-
- if (split[i])
- {
- split[i][0] = 0;
- ephy_bookmarks_set_keyword (entry->bookmarks, node, entry->bookmark);
- }
- else
- {
- ephy_bookmarks_unset_keyword (entry->bookmarks, node, entry->bookmark);
- }
-
- g_value_unset (&value);
- valid = gtk_tree_model_iter_next (model, &iter);
- }
-
- g_strfreev (split);
-
- entry->lock = FALSE;
+ EphyNode *node;
+ const char *text;
+ char **split;
+ char *tmp;
+ gint i;
+
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GValue value = { 0, };
+ gboolean valid;
+
+ /* Prevent any changes to the text entry or completion model */
+ if (entry->lock) return;
+ entry->lock = TRUE;
+
+ /* Get the list of strings input by the user */
+ text = gtk_entry_get_text (GTK_ENTRY (entry));
+ split = g_strsplit (text, ",", 0);
+ for (i = 0; split[i]; i++) {
+ g_strstrip (split[i]);
+
+ tmp = g_utf8_casefold (split[i], -1);
+ g_free (split[i]);
+
+ split[i] = g_utf8_normalize (tmp, -1, G_NORMALIZE_DEFAULT);
+ g_free (tmp);
+ }
+
+ /* Loop through the completion model and set/unset topics appropriately */
+ model = GTK_TREE_MODEL (entry->store);
+ valid = gtk_tree_model_get_iter_first (model, &iter);
+ while (valid) {
+ gtk_tree_model_get_value (model, &iter, COLUMN_NODE, &value);
+ node = g_value_get_pointer (&value);
+ g_value_unset (&value);
+
+ gtk_tree_model_get_value (model, &iter, COLUMN_KEY, &value);
+ text = g_value_get_string (&value);
+
+ for (i = 0; split[i]; i++)
+ if (strcmp (text, split[i]) == 0)
+ break;
+
+ if (split[i]) {
+ split[i][0] = 0;
+ ephy_bookmarks_set_keyword (entry->bookmarks, node, entry->bookmark);
+ } else {
+ ephy_bookmarks_unset_keyword (entry->bookmarks, node, entry->bookmark);
+ }
+
+ g_value_unset (&value);
+ valid = gtk_tree_model_iter_next (model, &iter);
+ }
+
+ g_strfreev (split);
+
+ entry->lock = FALSE;
}
/* Updates the search key and topic creation action */
static void
update_key (EphyTopicsEntry *entry)
{
- GtkEditable *editable = GTK_EDITABLE (entry);
- char *input;
-
- const gchar *text = gtk_entry_get_text (GTK_ENTRY (entry));
- const gchar *midpoint = g_utf8_offset_to_pointer (text, gtk_editable_get_position (editable));
- const gchar *start = g_utf8_strrchr (text, (gssize)(midpoint-text), ',');
- const gchar *end = g_utf8_strchr (midpoint, -1, ',');
-
- if (start == NULL)
- start = text;
- else if (g_unichar_isspace (g_utf8_get_char (g_utf8_next_char (start))))
- start = g_utf8_next_char (g_utf8_next_char (start));
- else
- start = g_utf8_next_char (start);
-
- if (end == NULL)
- end = text+strlen(text);
-
- /* If there was something we could create, then delete the action. */
- if (entry->create)
- gtk_entry_completion_delete_action (entry->completion, 0);
-
- g_free (entry->create);
- g_free (entry->key);
- entry->create = 0;
- entry->key = 0;
-
- /* Set the entry->create and entry->key appropriately. */
- if (start != end)
- {
- input = g_strndup (start, end-start);
- g_strstrip (input);
- entry->create = input;
-
- input = g_utf8_casefold (input, -1);
- entry->key = g_utf8_normalize (input, -1, G_NORMALIZE_DEFAULT);
- g_free (input);
-
- if (entry->create[0] == '\0' ||
- find_topic (entry, entry->key) != NULL)
- {
- g_free (entry->create);
- entry->create = 0;
- }
-
- /* If there is something we can create, then setup the action. */
- else
- {
- input = g_strdup_printf (_("Create topic “%s”"), entry->create);
- gtk_entry_completion_insert_action_text (entry->completion, 0, input);
- g_free (input);
- }
- }
+ GtkEditable *editable = GTK_EDITABLE (entry);
+ char *input;
+
+ const gchar *text = gtk_entry_get_text (GTK_ENTRY (entry));
+ const gchar *midpoint = g_utf8_offset_to_pointer (text, gtk_editable_get_position (editable));
+ const gchar *start = g_utf8_strrchr (text, (gssize)(midpoint - text), ',');
+ const gchar *end = g_utf8_strchr (midpoint, -1, ',');
+
+ if (start == NULL)
+ start = text;
+ else if (g_unichar_isspace (g_utf8_get_char (g_utf8_next_char (start))))
+ start = g_utf8_next_char (g_utf8_next_char (start));
+ else
+ start = g_utf8_next_char (start);
+
+ if (end == NULL)
+ end = text + strlen (text);
+
+ /* If there was something we could create, then delete the action. */
+ if (entry->create)
+ gtk_entry_completion_delete_action (entry->completion, 0);
+
+ g_free (entry->create);
+ g_free (entry->key);
+ entry->create = 0;
+ entry->key = 0;
+
+ /* Set the entry->create and entry->key appropriately. */
+ if (start != end) {
+ input = g_strndup (start, end - start);
+ g_strstrip (input);
+ entry->create = input;
+
+ input = g_utf8_casefold (input, -1);
+ entry->key = g_utf8_normalize (input, -1, G_NORMALIZE_DEFAULT);
+ g_free (input);
+
+ if (entry->create[0] == '\0' ||
+ find_topic (entry, entry->key) != NULL) {
+ g_free (entry->create);
+ entry->create = 0;
+ }
+ /* If there is something we can create, then setup the action. */
+ else {
+ input = g_strdup_printf (_("Create topic “%s”"), entry->create);
+ gtk_entry_completion_insert_action_text (entry->completion, 0, input);
+ g_free (input);
+ }
+ }
}
static gboolean
match_func (GtkEntryCompletion *completion,
- const gchar *key,
- GtkTreeIter *iter,
- gpointer user_data)
+ const gchar *key,
+ GtkTreeIter *iter,
+ gpointer user_data)
{
- EphyTopicsEntry *entry = EPHY_TOPICS_ENTRY (gtk_entry_completion_get_entry (completion));
- GtkTreeModel *model = gtk_entry_completion_get_model (completion);
-
- gboolean result;
- GValue value = { 0, };
- EphyNode *node;
-
- if (entry->key == NULL)
- {
- return FALSE;
- }
-
- /* If no node at all (this happens for unknown reasons) then don't show. */
- gtk_tree_model_get_value (model, iter, COLUMN_NODE, &value);
- node = g_value_get_pointer (&value);
- g_value_unset (&value);
- if (node == NULL)
- {
- result = FALSE;
- }
-
- /* If it's already selected, don't show it unless we're editing it. */
- else if (ephy_node_has_child (node, entry->bookmark))
- {
- gtk_tree_model_get_value (model, iter, COLUMN_KEY, &value);
- result = (strcmp (g_value_get_string (&value), entry->key) == 0);
- g_value_unset (&value);
- }
-
- /* If it's not selected, show it if it matches. */
- else
- {
- gtk_tree_model_get_value (model, iter, COLUMN_KEY, &value);
- result = (g_str_has_prefix (g_value_get_string (&value), entry->key));
- g_value_unset (&value);
- }
-
- return result;
+ EphyTopicsEntry *entry = EPHY_TOPICS_ENTRY (gtk_entry_completion_get_entry (completion));
+ GtkTreeModel *model = gtk_entry_completion_get_model (completion);
+
+ gboolean result;
+ GValue value = { 0, };
+ EphyNode *node;
+
+ if (entry->key == NULL) {
+ return FALSE;
+ }
+
+ /* If no node at all (this happens for unknown reasons) then don't show. */
+ gtk_tree_model_get_value (model, iter, COLUMN_NODE, &value);
+ node = g_value_get_pointer (&value);
+ g_value_unset (&value);
+ if (node == NULL) {
+ result = FALSE;
+ }
+ /* If it's already selected, don't show it unless we're editing it. */
+ else if (ephy_node_has_child (node, entry->bookmark)) {
+ gtk_tree_model_get_value (model, iter, COLUMN_KEY, &value);
+ result = (strcmp (g_value_get_string (&value), entry->key) == 0);
+ g_value_unset (&value);
+ }
+ /* If it's not selected, show it if it matches. */
+ else {
+ gtk_tree_model_get_value (model, iter, COLUMN_KEY, &value);
+ result = (g_str_has_prefix (g_value_get_string (&value), entry->key));
+ g_value_unset (&value);
+ }
+
+ return result;
}
static void
action_cb (GtkEntryCompletion *completion,
- gint index,
- gpointer user_data)
+ gint index,
+ gpointer user_data)
{
- EphyTopicsEntry *entry = EPHY_TOPICS_ENTRY (gtk_entry_completion_get_entry (completion));
- char *title;
+ EphyTopicsEntry *entry = EPHY_TOPICS_ENTRY (gtk_entry_completion_get_entry (completion));
+ char *title;
- title = g_strdup (entry->create);
+ title = g_strdup (entry->create);
- ephy_bookmarks_add_keyword (entry->bookmarks, title);
- update_widget (entry);
+ ephy_bookmarks_add_keyword (entry->bookmarks, title);
+ update_widget (entry);
- insert_text (entry, title);
- g_free (title);
+ insert_text (entry, title);
+ g_free (title);
}
static gboolean
match_selected_cb (GtkEntryCompletion *completion,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- gpointer user_data)
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer user_data)
{
- EphyTopicsEntry *entry = EPHY_TOPICS_ENTRY (gtk_entry_completion_get_entry (completion));
- GValue value = { 0, };
+ EphyTopicsEntry *entry = EPHY_TOPICS_ENTRY (gtk_entry_completion_get_entry (completion));
+ GValue value = { 0, };
- gtk_tree_model_get_value (model, iter, COLUMN_TITLE, &value);
- insert_text (entry, g_value_get_string (&value));
- g_value_unset (&value);
+ gtk_tree_model_get_value (model, iter, COLUMN_TITLE, &value);
+ insert_text (entry, g_value_get_string (&value));
+ g_value_unset (&value);
- return TRUE;
+ return TRUE;
}
static void
activate_cb (GtkEditable *editable,
- gpointer user_data)
+ gpointer user_data)
{
- EphyTopicsEntry *entry = EPHY_TOPICS_ENTRY (editable);
- GtkEntryCompletion *completion = gtk_entry_get_completion (GTK_ENTRY (entry));
-
- GValue value = { 0, };
- GtkTreeModel *model;
- GtkTreeIter iter;
- gboolean valid;
-
- if (entry->key == NULL || entry->key[0] == '\0')
- {
- gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
- return;
- }
- else
- {
- gtk_entry_set_activates_default (GTK_ENTRY (entry), FALSE);
- }
-
- /* Loop through the completion model and find the first item to use, if any. */
- model = GTK_TREE_MODEL (entry->store);
- valid = gtk_tree_model_get_iter_first (model, &iter);
- while (valid && !match_func (completion, NULL, &iter, NULL))
- {
- valid = gtk_tree_model_iter_next (model, &iter);
- }
-
- if (valid)
- {
- gtk_tree_model_get_value (model, &iter, COLUMN_TITLE, &value);
-
- /* See if there were any others. */
- valid = gtk_tree_model_iter_next (model, &iter);
- while (valid && !match_func (completion, NULL, &iter, NULL))
- {
- valid = gtk_tree_model_iter_next (model, &iter);
- }
-
- if (!valid)
- {
- insert_text (EPHY_TOPICS_ENTRY (editable), g_value_get_string (&value));
- g_value_unset (&value);
- }
- }
+ EphyTopicsEntry *entry = EPHY_TOPICS_ENTRY (editable);
+ GtkEntryCompletion *completion = gtk_entry_get_completion (GTK_ENTRY (entry));
+
+ GValue value = { 0, };
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gboolean valid;
+
+ if (entry->key == NULL || entry->key[0] == '\0') {
+ gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
+ return;
+ } else {
+ gtk_entry_set_activates_default (GTK_ENTRY (entry), FALSE);
+ }
+
+ /* Loop through the completion model and find the first item to use, if any. */
+ model = GTK_TREE_MODEL (entry->store);
+ valid = gtk_tree_model_get_iter_first (model, &iter);
+ while (valid && !match_func (completion, NULL, &iter, NULL)) {
+ valid = gtk_tree_model_iter_next (model, &iter);
+ }
+
+ if (valid) {
+ gtk_tree_model_get_value (model, &iter, COLUMN_TITLE, &value);
+
+ /* See if there were any others. */
+ valid = gtk_tree_model_iter_next (model, &iter);
+ while (valid && !match_func (completion, NULL, &iter, NULL)) {
+ valid = gtk_tree_model_iter_next (model, &iter);
+ }
+
+ if (!valid) {
+ insert_text (EPHY_TOPICS_ENTRY (editable), g_value_get_string (&value));
+ g_value_unset (&value);
+ }
+ }
}
static void
-tree_changed_cb (EphyBookmarks *bookmarks,
- EphyTopicsEntry *entry)
+tree_changed_cb (EphyBookmarks *bookmarks,
+ EphyTopicsEntry *entry)
{
- update_widget (entry);
+ update_widget (entry);
}
static void
node_added_cb (EphyNode *parent,
- EphyNode *child,
- GObject *object)
+ EphyNode *child,
+ GObject *object)
{
- update_widget (EPHY_TOPICS_ENTRY (object));
+ update_widget (EPHY_TOPICS_ENTRY (object));
}
static void
node_changed_cb (EphyNode *parent,
- EphyNode *child,
- guint property_id,
- GObject *object)
+ EphyNode *child,
+ guint property_id,
+ GObject *object)
{
- update_widget (EPHY_TOPICS_ENTRY (object));
+ update_widget (EPHY_TOPICS_ENTRY (object));
}
static void
node_removed_cb (EphyNode *parent,
- EphyNode *child,
- guint index,
- GObject *object)
+ EphyNode *child,
+ guint index,
+ GObject *object)
{
- update_widget (EPHY_TOPICS_ENTRY (object));
+ update_widget (EPHY_TOPICS_ENTRY (object));
}
static void
-ephy_topics_entry_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ephy_topics_entry_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- EphyTopicsEntry *entry = EPHY_TOPICS_ENTRY (object);
- EphyNode *node;
-
- switch (prop_id)
- {
- case PROP_BOOKMARKS:
- entry->bookmarks = g_value_get_object (value);
- node = ephy_bookmarks_get_keywords (entry->bookmarks);
- ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_ADDED,
- (EphyNodeCallback) node_added_cb, object);
- ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_CHANGED,
- (EphyNodeCallback) node_changed_cb, object);
- ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback) node_removed_cb, object);
- g_signal_connect_object (entry->bookmarks, "tree-changed",
- G_CALLBACK (tree_changed_cb), entry,
- G_CONNECT_AFTER);
- break;
- case PROP_BOOKMARK:
- entry->bookmark = g_value_get_pointer (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ EphyTopicsEntry *entry = EPHY_TOPICS_ENTRY (object);
+ EphyNode *node;
+
+ switch (prop_id) {
+ case PROP_BOOKMARKS:
+ entry->bookmarks = g_value_get_object (value);
+ node = ephy_bookmarks_get_keywords (entry->bookmarks);
+ ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_ADDED,
+ (EphyNodeCallback)node_added_cb, object);
+ ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_CHANGED,
+ (EphyNodeCallback)node_changed_cb, object);
+ ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_REMOVED,
+ (EphyNodeCallback)node_removed_cb, object);
+ g_signal_connect_object (entry->bookmarks, "tree-changed",
+ G_CALLBACK (tree_changed_cb), entry,
+ G_CONNECT_AFTER);
+ break;
+ case PROP_BOOKMARK:
+ entry->bookmark = g_value_get_pointer (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static GObject *
-ephy_topics_entry_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_params)
+ephy_topics_entry_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_params)
{
- GObject *object;
- EphyTopicsEntry *entry;
-
- object = G_OBJECT_CLASS (ephy_topics_entry_parent_class)->constructor (type,
- n_construct_properties,
- construct_params);
- entry = EPHY_TOPICS_ENTRY (object);
-
- entry->store = gtk_list_store_new (3, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_STRING);
- entry->completion = gtk_entry_completion_new ();
-
- gtk_entry_completion_set_model (entry->completion, GTK_TREE_MODEL (entry->store));
- gtk_entry_completion_set_text_column (entry->completion, COLUMN_TITLE);
- gtk_entry_completion_set_popup_completion (entry->completion, TRUE);
- gtk_entry_completion_set_popup_single_match (entry->completion, TRUE);
- gtk_entry_completion_set_match_func (entry->completion, match_func, NULL, NULL);
- gtk_entry_set_completion (GTK_ENTRY (entry), entry->completion);
-
- g_signal_connect (entry->completion, "match-selected",
- G_CALLBACK (match_selected_cb), NULL);
- g_signal_connect (entry->completion, "action-activated",
- G_CALLBACK (action_cb), NULL);
-
- g_signal_connect (object, "activate",
- G_CALLBACK (activate_cb), NULL);
-
- g_signal_connect (object, "changed",
- G_CALLBACK (update_database), NULL);
- g_signal_connect (object, "notify::is-focus",
- G_CALLBACK (update_widget), NULL);
- g_signal_connect (object, "notify::cursor-position",
- G_CALLBACK (update_key), NULL);
- g_signal_connect (object, "notify::text",
- G_CALLBACK (update_key), NULL);
-
- update_key (entry);
- update_widget (entry);
-
- return object;
+ GObject *object;
+ EphyTopicsEntry *entry;
+
+ object = G_OBJECT_CLASS (ephy_topics_entry_parent_class)->constructor (type,
+ n_construct_properties,
+ construct_params);
+ entry = EPHY_TOPICS_ENTRY (object);
+
+ entry->store = gtk_list_store_new (3, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_STRING);
+ entry->completion = gtk_entry_completion_new ();
+
+ gtk_entry_completion_set_model (entry->completion, GTK_TREE_MODEL (entry->store));
+ gtk_entry_completion_set_text_column (entry->completion, COLUMN_TITLE);
+ gtk_entry_completion_set_popup_completion (entry->completion, TRUE);
+ gtk_entry_completion_set_popup_single_match (entry->completion, TRUE);
+ gtk_entry_completion_set_match_func (entry->completion, match_func, NULL, NULL);
+ gtk_entry_set_completion (GTK_ENTRY (entry), entry->completion);
+
+ g_signal_connect (entry->completion, "match-selected",
+ G_CALLBACK (match_selected_cb), NULL);
+ g_signal_connect (entry->completion, "action-activated",
+ G_CALLBACK (action_cb), NULL);
+
+ g_signal_connect (object, "activate",
+ G_CALLBACK (activate_cb), NULL);
+
+ g_signal_connect (object, "changed",
+ G_CALLBACK (update_database), NULL);
+ g_signal_connect (object, "notify::is-focus",
+ G_CALLBACK (update_widget), NULL);
+ g_signal_connect (object, "notify::cursor-position",
+ G_CALLBACK (update_key), NULL);
+ g_signal_connect (object, "notify::text",
+ G_CALLBACK (update_key), NULL);
+
+ update_key (entry);
+ update_widget (entry);
+
+ return object;
}
static void
@@ -576,52 +543,52 @@ ephy_topics_entry_init (EphyTopicsEntry *entry)
static void
ephy_topics_entry_finalize (GObject *object)
{
- EphyTopicsEntry *entry = EPHY_TOPICS_ENTRY (object);
+ EphyTopicsEntry *entry = EPHY_TOPICS_ENTRY (object);
- g_free (entry->create);
- g_free (entry->key);
+ g_free (entry->create);
+ g_free (entry->key);
- G_OBJECT_CLASS (ephy_topics_entry_parent_class)->finalize (object);
+ G_OBJECT_CLASS (ephy_topics_entry_parent_class)->finalize (object);
}
GtkWidget *
ephy_topics_entry_new (EphyBookmarks *bookmarks,
- EphyNode *bookmark)
+ EphyNode *bookmark)
{
- EphyTopicsEntry *entry;
+ EphyTopicsEntry *entry;
- g_assert (bookmarks != NULL);
+ g_assert (bookmarks != NULL);
- entry = EPHY_TOPICS_ENTRY (g_object_new
- (EPHY_TYPE_TOPICS_ENTRY,
- "bookmarks", bookmarks,
- "bookmark", bookmark,
- NULL));
+ entry = EPHY_TOPICS_ENTRY (g_object_new
+ (EPHY_TYPE_TOPICS_ENTRY,
+ "bookmarks", bookmarks,
+ "bookmark", bookmark,
+ NULL));
- return GTK_WIDGET (entry);
+ return GTK_WIDGET (entry);
}
static void
ephy_topics_entry_class_init (EphyTopicsEntryClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->set_property = ephy_topics_entry_set_property;
- object_class->constructor = ephy_topics_entry_constructor;
- object_class->finalize = ephy_topics_entry_finalize;
-
- obj_properties[PROP_BOOKMARKS] =
- g_param_spec_object ("bookmarks",
- "Bookmarks set",
- "Bookmarks set",
- EPHY_TYPE_BOOKMARKS,
- G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
-
- obj_properties[PROP_BOOKMARK] =
- g_param_spec_pointer ("bookmark",
- "Bookmark",
- "Bookmark",
- G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->set_property = ephy_topics_entry_set_property;
+ object_class->constructor = ephy_topics_entry_constructor;
+ object_class->finalize = ephy_topics_entry_finalize;
+
+ obj_properties[PROP_BOOKMARKS] =
+ g_param_spec_object ("bookmarks",
+ "Bookmarks set",
+ "Bookmarks set",
+ EPHY_TYPE_BOOKMARKS,
+ G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+
+ obj_properties[PROP_BOOKMARK] =
+ g_param_spec_pointer ("bookmark",
+ "Bookmark",
+ "Bookmark",
+ G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
}
diff --git a/src/bookmarks/ephy-topics-palette.c b/src/bookmarks/ephy-topics-palette.c
index 1ab0844..19a3443 100644
--- a/src/bookmarks/ephy-topics-palette.c
+++ b/src/bookmarks/ephy-topics-palette.c
@@ -28,281 +28,261 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
-struct _EphyTopicsPalette
-{
- GtkListStore parent_instance;
+struct _EphyTopicsPalette {
+ GtkListStore parent_instance;
- /* construct properties */
- EphyBookmarks *bookmarks;
- EphyNode *bookmark;
+ /* construct properties */
+ EphyBookmarks *bookmarks;
+ EphyNode *bookmark;
- /* non-construct property */
- int mode;
+ /* non-construct property */
+ int mode;
};
-enum
-{
- PROP_0,
- PROP_BOOKMARKS,
- PROP_BOOKMARK,
- PROP_MODE,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_BOOKMARKS,
+ PROP_BOOKMARK,
+ PROP_MODE,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
-enum
-{
- MODE_GROUPED,
- MODE_LIST,
- MODES
+enum {
+ MODE_GROUPED,
+ MODE_LIST,
+ MODES
};
G_DEFINE_TYPE (EphyTopicsPalette, ephy_topics_palette, GTK_TYPE_LIST_STORE)
static void
append_topics (EphyTopicsPalette *self,
- GtkTreeIter *iter,
- gboolean *valid,
- gboolean *first,
- GPtrArray *topics)
+ GtkTreeIter *iter,
+ gboolean *valid,
+ gboolean *first,
+ GPtrArray *topics)
{
- EphyNode *node;
- const char *title;
- guint i;
-
- if (topics->len == 0)
- {
- return;
- }
-
- if (!*first)
- {
- if (!*valid) gtk_list_store_append (GTK_LIST_STORE (self), iter);
- gtk_list_store_set (GTK_LIST_STORE (self), iter,
- EPHY_TOPICS_PALETTE_COLUMN_TITLE, NULL,
- EPHY_TOPICS_PALETTE_COLUMN_NODE, NULL,
- -1);
- *valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (self), iter);
- }
-
- for (i = 0; i < topics->len ; i++)
- {
- node = g_ptr_array_index (topics, i);
- title = ephy_node_get_property_string (node, EPHY_NODE_KEYWORD_PROP_NAME);
-
- if (!*valid) gtk_list_store_append (GTK_LIST_STORE (self), iter);
- gtk_list_store_set (GTK_LIST_STORE (self), iter,
- EPHY_TOPICS_PALETTE_COLUMN_TITLE, title,
- EPHY_TOPICS_PALETTE_COLUMN_NODE, node,
- EPHY_TOPICS_PALETTE_COLUMN_SELECTED, ephy_node_has_child (node,
self->bookmark),
- -1);
- *valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (self), iter);
- *first = FALSE;
- }
+ EphyNode *node;
+ const char *title;
+ guint i;
+
+ if (topics->len == 0) {
+ return;
+ }
+
+ if (!*first) {
+ if (!*valid) gtk_list_store_append (GTK_LIST_STORE (self), iter);
+ gtk_list_store_set (GTK_LIST_STORE (self), iter,
+ EPHY_TOPICS_PALETTE_COLUMN_TITLE, NULL,
+ EPHY_TOPICS_PALETTE_COLUMN_NODE, NULL,
+ -1);
+ *valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (self), iter);
+ }
+
+ for (i = 0; i < topics->len; i++) {
+ node = g_ptr_array_index (topics, i);
+ title = ephy_node_get_property_string (node, EPHY_NODE_KEYWORD_PROP_NAME);
+
+ if (!*valid) gtk_list_store_append (GTK_LIST_STORE (self), iter);
+ gtk_list_store_set (GTK_LIST_STORE (self), iter,
+ EPHY_TOPICS_PALETTE_COLUMN_TITLE, title,
+ EPHY_TOPICS_PALETTE_COLUMN_NODE, node,
+ EPHY_TOPICS_PALETTE_COLUMN_SELECTED, ephy_node_has_child (node, self->bookmark),
+ -1);
+ *valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (self), iter);
+ *first = FALSE;
+ }
}
void
ephy_topics_palette_update_list (EphyTopicsPalette *self)
{
- GPtrArray *children, *bookmarks, *topics;
- EphyNode *node;
- GtkTreeIter iter;
- guint i;
- gint priority;
- gboolean valid, first;
-
- valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (self), &iter);
- first = TRUE;
-
- if (self->mode == MODE_LIST)
- {
- /* Allocate and fill the suggestions array. */
- node = ephy_bookmarks_get_keywords (self->bookmarks);
- children = ephy_node_get_children (node);
- topics = g_ptr_array_sized_new (children->len);
- for (i = 0; i < children->len; i++)
- {
- node = g_ptr_array_index (children, i);
-
- priority = ephy_node_get_property_int (node, EPHY_NODE_KEYWORD_PROP_PRIORITY);
- if (priority != EPHY_NODE_NORMAL_PRIORITY)
- continue;
-
- g_ptr_array_add (topics, node);
- }
-
- g_ptr_array_sort (topics, ephy_bookmarks_compare_topic_pointers);
- append_topics (self, &iter, &valid, &first, topics);
- g_ptr_array_free (topics, TRUE);
- }
- else if (self->mode == MODE_GROUPED)
- {
- GPtrArray *suggested, *selected;
-
- /* Allocate and fill the bookmarks array. */
- node = ephy_bookmarks_get_bookmarks (self->bookmarks);
- children = ephy_node_get_children (node);
- bookmarks = g_ptr_array_sized_new (children->len);
- for (i = 0; i < children->len; i++)
- {
- g_ptr_array_add(bookmarks, g_ptr_array_index (children, i));
- }
-
- /* Allocate and fill the topics array. */
- node = ephy_bookmarks_get_keywords (self->bookmarks);
- children = ephy_node_get_children (node);
- topics = g_ptr_array_sized_new (children->len);
- suggested = g_ptr_array_sized_new (children->len);
- selected = g_ptr_array_sized_new (children->len);
- for (i = 0; i < children->len; i++)
- {
- node = g_ptr_array_index (children, i);
-
- priority = ephy_node_get_property_int (node, EPHY_NODE_KEYWORD_PROP_PRIORITY);
- if (priority != EPHY_NODE_NORMAL_PRIORITY)
- continue;
-
- /* We'll consider only bookmarks covered by the same topics as our bookmark. */
- if (ephy_node_has_child (node, self->bookmark))
- {
- ephy_nodes_remove_not_covered (node, bookmarks);
- g_ptr_array_add (selected, node);
- }
-
- /* We'll onsider only topics that are not already selected for our bookmark. */
- else
- {
- g_ptr_array_add (topics, node);
- }
- }
-
- /* Get the minimum cover of topics for the bookmarks. */
- suggested = ephy_nodes_get_covering (topics, bookmarks, suggested, 0, 0);
-
- for (i = 0; i < suggested->len; i++)
- {
- g_ptr_array_remove_fast (topics, g_ptr_array_index (suggested, i));
- }
-
- /* Add any topics which cover the bookmarks completely in their own right, or
- have no bookmarks currently associated with it. */
- for (i = 0; i < topics->len ; i++)
- {
- node = g_ptr_array_index (topics, i);
- if (!ephy_node_has_child (node, self->bookmark) &&
- ephy_nodes_covered (node, bookmarks))
- {
- g_ptr_array_add (suggested, node);
- g_ptr_array_remove_index_fast (topics, i);
- i--;
- }
- }
-
- g_ptr_array_sort (selected, ephy_bookmarks_compare_topic_pointers);
- g_ptr_array_sort (suggested, ephy_bookmarks_compare_topic_pointers);
- g_ptr_array_sort (topics, ephy_bookmarks_compare_topic_pointers);
- append_topics (self, &iter, &valid, &first, selected);
- append_topics (self, &iter, &valid, &first, suggested);
- append_topics (self, &iter, &valid, &first, topics);
- g_ptr_array_free (selected, TRUE);
- g_ptr_array_free (suggested, TRUE);
- g_ptr_array_free (bookmarks, TRUE);
- g_ptr_array_free (topics, TRUE);
- }
-
- while (valid)
- {
- valid = gtk_list_store_remove (GTK_LIST_STORE (self), &iter);
- }
+ GPtrArray *children, *bookmarks, *topics;
+ EphyNode *node;
+ GtkTreeIter iter;
+ guint i;
+ gint priority;
+ gboolean valid, first;
+
+ valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (self), &iter);
+ first = TRUE;
+
+ if (self->mode == MODE_LIST) {
+ /* Allocate and fill the suggestions array. */
+ node = ephy_bookmarks_get_keywords (self->bookmarks);
+ children = ephy_node_get_children (node);
+ topics = g_ptr_array_sized_new (children->len);
+ for (i = 0; i < children->len; i++) {
+ node = g_ptr_array_index (children, i);
+
+ priority = ephy_node_get_property_int (node, EPHY_NODE_KEYWORD_PROP_PRIORITY);
+ if (priority != EPHY_NODE_NORMAL_PRIORITY)
+ continue;
+
+ g_ptr_array_add (topics, node);
+ }
+
+ g_ptr_array_sort (topics, ephy_bookmarks_compare_topic_pointers);
+ append_topics (self, &iter, &valid, &first, topics);
+ g_ptr_array_free (topics, TRUE);
+ } else if (self->mode == MODE_GROUPED) {
+ GPtrArray *suggested, *selected;
+
+ /* Allocate and fill the bookmarks array. */
+ node = ephy_bookmarks_get_bookmarks (self->bookmarks);
+ children = ephy_node_get_children (node);
+ bookmarks = g_ptr_array_sized_new (children->len);
+ for (i = 0; i < children->len; i++) {
+ g_ptr_array_add (bookmarks, g_ptr_array_index (children, i));
+ }
+
+ /* Allocate and fill the topics array. */
+ node = ephy_bookmarks_get_keywords (self->bookmarks);
+ children = ephy_node_get_children (node);
+ topics = g_ptr_array_sized_new (children->len);
+ suggested = g_ptr_array_sized_new (children->len);
+ selected = g_ptr_array_sized_new (children->len);
+ for (i = 0; i < children->len; i++) {
+ node = g_ptr_array_index (children, i);
+
+ priority = ephy_node_get_property_int (node, EPHY_NODE_KEYWORD_PROP_PRIORITY);
+ if (priority != EPHY_NODE_NORMAL_PRIORITY)
+ continue;
+
+ /* We'll consider only bookmarks covered by the same topics as our bookmark. */
+ if (ephy_node_has_child (node, self->bookmark)) {
+ ephy_nodes_remove_not_covered (node, bookmarks);
+ g_ptr_array_add (selected, node);
+ }
+ /* We'll onsider only topics that are not already selected for our bookmark. */
+ else{
+ g_ptr_array_add (topics, node);
+ }
+ }
+
+ /* Get the minimum cover of topics for the bookmarks. */
+ suggested = ephy_nodes_get_covering (topics, bookmarks, suggested, 0, 0);
+
+ for (i = 0; i < suggested->len; i++) {
+ g_ptr_array_remove_fast (topics, g_ptr_array_index (suggested, i));
+ }
+
+ /* Add any topics which cover the bookmarks completely in their own right, or
+ have no bookmarks currently associated with it. */
+ for (i = 0; i < topics->len; i++) {
+ node = g_ptr_array_index (topics, i);
+ if (!ephy_node_has_child (node, self->bookmark) &&
+ ephy_nodes_covered (node, bookmarks)) {
+ g_ptr_array_add (suggested, node);
+ g_ptr_array_remove_index_fast (topics, i);
+ i--;
+ }
+ }
+
+ g_ptr_array_sort (selected, ephy_bookmarks_compare_topic_pointers);
+ g_ptr_array_sort (suggested, ephy_bookmarks_compare_topic_pointers);
+ g_ptr_array_sort (topics, ephy_bookmarks_compare_topic_pointers);
+ append_topics (self, &iter, &valid, &first, selected);
+ append_topics (self, &iter, &valid, &first, suggested);
+ append_topics (self, &iter, &valid, &first, topics);
+ g_ptr_array_free (selected, TRUE);
+ g_ptr_array_free (suggested, TRUE);
+ g_ptr_array_free (bookmarks, TRUE);
+ g_ptr_array_free (topics, TRUE);
+ }
+
+ while (valid) {
+ valid = gtk_list_store_remove (GTK_LIST_STORE (self), &iter);
+ }
}
static void
-tree_changed_cb (EphyBookmarks *bookmarks,
- EphyTopicsPalette *self)
+tree_changed_cb (EphyBookmarks *bookmarks,
+ EphyTopicsPalette *self)
{
- ephy_topics_palette_update_list (self);
+ ephy_topics_palette_update_list (self);
}
static void
-node_added_cb (EphyNode *parent,
- EphyNode *child,
- EphyTopicsPalette *self)
+node_added_cb (EphyNode *parent,
+ EphyNode *child,
+ EphyTopicsPalette *self)
{
- ephy_topics_palette_update_list (self);
+ ephy_topics_palette_update_list (self);
}
static void
-node_changed_cb (EphyNode *parent,
- EphyNode *child,
- guint property_id,
- EphyTopicsPalette *self)
+node_changed_cb (EphyNode *parent,
+ EphyNode *child,
+ guint property_id,
+ EphyTopicsPalette *self)
{
- ephy_topics_palette_update_list (self);
+ ephy_topics_palette_update_list (self);
}
static void
-node_removed_cb (EphyNode *parent,
- EphyNode *child,
- guint index,
- EphyTopicsPalette *self)
+node_removed_cb (EphyNode *parent,
+ EphyNode *child,
+ guint index,
+ EphyTopicsPalette *self)
{
- ephy_topics_palette_update_list (self);
+ ephy_topics_palette_update_list (self);
}
static void
-ephy_topics_palette_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ephy_topics_palette_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- EphyTopicsPalette *self = EPHY_TOPICS_PALETTE (object);
- EphyNode *node;
-
- switch (prop_id)
- {
- case PROP_BOOKMARKS:
- self->bookmarks = g_value_get_object (value);
- node = ephy_bookmarks_get_keywords (self->bookmarks);
- ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_ADDED,
- (EphyNodeCallback) node_added_cb, object);
- ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_CHANGED,
- (EphyNodeCallback) node_changed_cb, object);
- ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback) node_removed_cb, object);
- g_signal_connect_object (self->bookmarks, "tree-changed",
- G_CALLBACK (tree_changed_cb), self,
- G_CONNECT_AFTER);
- break;
- case PROP_BOOKMARK:
- self->bookmark = g_value_get_pointer (value);
- break;
- case PROP_MODE:
- self->mode = g_value_get_int (value);
- ephy_topics_palette_update_list (self);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ EphyTopicsPalette *self = EPHY_TOPICS_PALETTE (object);
+ EphyNode *node;
+
+ switch (prop_id) {
+ case PROP_BOOKMARKS:
+ self->bookmarks = g_value_get_object (value);
+ node = ephy_bookmarks_get_keywords (self->bookmarks);
+ ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_ADDED,
+ (EphyNodeCallback)node_added_cb, object);
+ ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_CHANGED,
+ (EphyNodeCallback)node_changed_cb, object);
+ ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_REMOVED,
+ (EphyNodeCallback)node_removed_cb, object);
+ g_signal_connect_object (self->bookmarks, "tree-changed",
+ G_CALLBACK (tree_changed_cb), self,
+ G_CONNECT_AFTER);
+ break;
+ case PROP_BOOKMARK:
+ self->bookmark = g_value_get_pointer (value);
+ break;
+ case PROP_MODE:
+ self->mode = g_value_get_int (value);
+ ephy_topics_palette_update_list (self);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static GObject *
-ephy_topics_palette_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_params)
+ephy_topics_palette_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_params)
{
- GObject *object;
- GType types[3] = { G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN };
+ GObject *object;
+ GType types[3] = { G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN };
- object = G_OBJECT_CLASS (ephy_topics_palette_parent_class)->constructor (type,
- n_construct_properties,
- construct_params);
- gtk_list_store_set_column_types (GTK_LIST_STORE (object), 3, types);
- ephy_topics_palette_update_list (EPHY_TOPICS_PALETTE (object));
+ object = G_OBJECT_CLASS (ephy_topics_palette_parent_class)->constructor (type,
+ n_construct_properties,
+ construct_params);
+ gtk_list_store_set_column_types (GTK_LIST_STORE (object), 3, types);
+ ephy_topics_palette_update_list (EPHY_TOPICS_PALETTE (object));
- return object;
+ return object;
}
static void
@@ -314,41 +294,41 @@ EphyTopicsPalette *
ephy_topics_palette_new (EphyBookmarks *bookmarks,
EphyNode *bookmark)
{
- g_assert (bookmarks != NULL);
+ g_assert (bookmarks != NULL);
- return g_object_new (EPHY_TYPE_TOPICS_PALETTE,
- "bookmarks", bookmarks,
- "bookmark", bookmark,
- NULL);
+ return g_object_new (EPHY_TYPE_TOPICS_PALETTE,
+ "bookmarks", bookmarks,
+ "bookmark", bookmark,
+ NULL);
}
static void
ephy_topics_palette_class_init (EphyTopicsPaletteClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->set_property = ephy_topics_palette_set_property;
- object_class->constructor = ephy_topics_palette_constructor;
-
- obj_properties[PROP_BOOKMARKS] =
- g_param_spec_object ("bookmarks",
- "Bookmarks set",
- "Bookmarks set",
- EPHY_TYPE_BOOKMARKS,
- G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
-
- obj_properties[PROP_BOOKMARK] =
- g_param_spec_pointer ("bookmark",
- "Bookmark",
- "Bookmark",
- G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
-
- obj_properties[PROP_MODE] =
- g_param_spec_int ("mode",
- "Mode",
- "Mode",
- 0, MODES-1, 0,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->set_property = ephy_topics_palette_set_property;
+ object_class->constructor = ephy_topics_palette_constructor;
+
+ obj_properties[PROP_BOOKMARKS] =
+ g_param_spec_object ("bookmarks",
+ "Bookmarks set",
+ "Bookmarks set",
+ EPHY_TYPE_BOOKMARKS,
+ G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+
+ obj_properties[PROP_BOOKMARK] =
+ g_param_spec_pointer ("bookmark",
+ "Bookmark",
+ "Bookmark",
+ G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+
+ obj_properties[PROP_MODE] =
+ g_param_spec_int ("mode",
+ "Mode",
+ "Mode",
+ 0, MODES - 1, 0,
+ G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
}
diff --git a/src/clear-data-dialog.c b/src/clear-data-dialog.c
index 2b0cc6a..8bba234 100644
--- a/src/clear-data-dialog.c
+++ b/src/clear-data-dialog.c
@@ -32,17 +32,16 @@
#include "clear-data-dialog.h"
-struct _ClearDataDialog
-{
- GtkDialog parent_instance;
+struct _ClearDataDialog {
+ GtkDialog parent_instance;
- GtkWidget *cache_checkbutton;
- GtkWidget *history_checkbutton;
- GtkWidget *passwords_checkbutton;
- GtkWidget *cookies_checkbutton;
- GtkWidget *clear_button;
+ GtkWidget *cache_checkbutton;
+ GtkWidget *history_checkbutton;
+ GtkWidget *passwords_checkbutton;
+ GtkWidget *cookies_checkbutton;
+ GtkWidget *clear_button;
- guint num_checked;
+ guint num_checked;
};
G_DEFINE_TYPE (ClearDataDialog, clear_data_dialog, GTK_TYPE_DIALOG)
@@ -50,114 +49,106 @@ G_DEFINE_TYPE (ClearDataDialog, clear_data_dialog, GTK_TYPE_DIALOG)
static WebKitCookieManager *
get_cookie_manager (void)
{
- WebKitWebContext *web_context;
- EphyEmbedShell *shell = ephy_embed_shell_get_default ();
+ WebKitWebContext *web_context;
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
- web_context = ephy_embed_shell_get_web_context (shell);
- return webkit_web_context_get_cookie_manager (web_context);
+ web_context = ephy_embed_shell_get_web_context (shell);
+ return webkit_web_context_get_cookie_manager (web_context);
}
static void
delete_all_passwords (ClearDataDialog *dialog)
{
- GHashTable *attributes;
-
- attributes = secret_attributes_build (EPHY_FORM_PASSWORD_SCHEMA, NULL);
- secret_service_clear (NULL, EPHY_FORM_PASSWORD_SCHEMA,
- attributes, NULL,
- (GAsyncReadyCallback)secret_service_clear_finish,
- NULL);
- g_hash_table_unref (attributes);
+ GHashTable *attributes;
+
+ attributes = secret_attributes_build (EPHY_FORM_PASSWORD_SCHEMA, NULL);
+ secret_service_clear (NULL, EPHY_FORM_PASSWORD_SCHEMA,
+ attributes, NULL,
+ (GAsyncReadyCallback)secret_service_clear_finish,
+ NULL);
+ g_hash_table_unref (attributes);
}
static void
-clear_data_dialog_response_cb (GtkDialog *widget,
- int response,
- ClearDataDialog *dialog)
+clear_data_dialog_response_cb (GtkDialog *widget,
+ int response,
+ ClearDataDialog *dialog)
{
- if (response == GTK_RESPONSE_OK)
- {
- if (gtk_toggle_button_get_active
- (GTK_TOGGLE_BUTTON (dialog->history_checkbutton)))
- {
- EphyEmbedShell *shell;
- EphyHistoryService *history;
-
- shell = ephy_embed_shell_get_default ();
- history = EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service (shell));
- ephy_history_service_clear (history, NULL, NULL, NULL);
- }
- if (gtk_toggle_button_get_active
- (GTK_TOGGLE_BUTTON (dialog->cookies_checkbutton)))
- {
- WebKitCookieManager *cookie_manager;
-
- cookie_manager = get_cookie_manager ();
- webkit_cookie_manager_delete_all_cookies (cookie_manager);
- }
- if (gtk_toggle_button_get_active
- (GTK_TOGGLE_BUTTON (dialog->passwords_checkbutton)))
- {
- delete_all_passwords (dialog);
- }
- if (gtk_toggle_button_get_active
- (GTK_TOGGLE_BUTTON (dialog->cache_checkbutton)))
- {
- EphyEmbedShell *shell;
- WebKitFaviconDatabase *database;
-
- shell = ephy_embed_shell_get_default ();
-
- ephy_embed_shell_clear_cache (shell);
-
- database = webkit_web_context_get_favicon_database (ephy_embed_shell_get_web_context
(shell));
- webkit_favicon_database_clear (database);
- }
- }
-
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ if (response == GTK_RESPONSE_OK) {
+ if (gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (dialog->history_checkbutton))) {
+ EphyEmbedShell *shell;
+ EphyHistoryService *history;
+
+ shell = ephy_embed_shell_get_default ();
+ history = EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service (shell));
+ ephy_history_service_clear (history, NULL, NULL, NULL);
+ }
+ if (gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (dialog->cookies_checkbutton))) {
+ WebKitCookieManager *cookie_manager;
+
+ cookie_manager = get_cookie_manager ();
+ webkit_cookie_manager_delete_all_cookies (cookie_manager);
+ }
+ if (gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (dialog->passwords_checkbutton))) {
+ delete_all_passwords (dialog);
+ }
+ if (gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (dialog->cache_checkbutton))) {
+ EphyEmbedShell *shell;
+ WebKitFaviconDatabase *database;
+
+ shell = ephy_embed_shell_get_default ();
+
+ ephy_embed_shell_clear_cache (shell);
+
+ database = webkit_web_context_get_favicon_database (ephy_embed_shell_get_web_context (shell));
+ webkit_favicon_database_clear (database);
+ }
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
}
static void
checkbutton_toggled_cb (GtkToggleButton *toggle,
- ClearDataDialog *dialog)
+ ClearDataDialog *dialog)
{
- if (gtk_toggle_button_get_active (toggle) == TRUE)
- {
- dialog->num_checked++;
- }
- else
- {
- dialog->num_checked--;
- }
-
- gtk_widget_set_sensitive (dialog->clear_button,
- dialog->num_checked != 0);
+ if (gtk_toggle_button_get_active (toggle) == TRUE) {
+ dialog->num_checked++;
+ } else {
+ dialog->num_checked--;
+ }
+
+ gtk_widget_set_sensitive (dialog->clear_button,
+ dialog->num_checked != 0);
}
static void
clear_data_dialog_class_init (ClearDataDialogClass *klass)
{
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- gtk_widget_class_set_template_from_resource (widget_class,
- "/org/gnome/epiphany/clear-data-dialog.ui");
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/epiphany/clear-data-dialog.ui");
- gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, cookies_checkbutton);
- gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, cache_checkbutton);
- gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, passwords_checkbutton);
- gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, history_checkbutton);
- gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, clear_button);
+ gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, cookies_checkbutton);
+ gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, cache_checkbutton);
+ gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, passwords_checkbutton);
+ gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, history_checkbutton);
+ gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, clear_button);
- gtk_widget_class_bind_template_callback (widget_class, checkbutton_toggled_cb);
- gtk_widget_class_bind_template_callback (widget_class, clear_data_dialog_response_cb);
+ gtk_widget_class_bind_template_callback (widget_class, checkbutton_toggled_cb);
+ gtk_widget_class_bind_template_callback (widget_class, clear_data_dialog_response_cb);
}
static void
clear_data_dialog_init (ClearDataDialog *dialog)
{
- gtk_widget_init_template (GTK_WIDGET (dialog));
+ gtk_widget_init_template (GTK_WIDGET (dialog));
- dialog->num_checked = 0;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->cache_checkbutton), TRUE);
+ dialog->num_checked = 0;
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->cache_checkbutton), TRUE);
}
diff --git a/src/cookies-dialog.c b/src/cookies-dialog.c
index 629d4bb..7399d84 100644
--- a/src/cookies-dialog.c
+++ b/src/cookies-dialog.c
@@ -30,307 +30,296 @@
#include "cookies-dialog.h"
-enum
-{
- COL_COOKIES_HOST,
- COL_COOKIES_HOST_KEY,
- COL_COOKIES_DATA,
+enum {
+ COL_COOKIES_HOST,
+ COL_COOKIES_HOST_KEY,
+ COL_COOKIES_DATA,
};
-struct _EphyCookiesDialog
-{
- GtkDialog parent_instance;
+struct _EphyCookiesDialog {
+ GtkDialog parent_instance;
- GtkWidget *cookies_treeview;
- GtkTreeSelection *tree_selection;
- GtkWidget *liststore;
- GtkWidget *treemodelfilter;
- GtkWidget *treemodelsort;
+ GtkWidget *cookies_treeview;
+ GtkTreeSelection *tree_selection;
+ GtkWidget *liststore;
+ GtkWidget *treemodelfilter;
+ GtkWidget *treemodelsort;
- GActionGroup *action_group;
+ GActionGroup *action_group;
- WebKitCookieManager *cookie_manager;
- gboolean filled;
+ WebKitCookieManager *cookie_manager;
+ gboolean filled;
- char *search_text;
+ char *search_text;
};
G_DEFINE_TYPE (EphyCookiesDialog, ephy_cookies_dialog, GTK_TYPE_DIALOG)
-static void populate_model (EphyCookiesDialog *dialog);
+static void populate_model (EphyCookiesDialog *dialog);
static void cookie_changed_cb (WebKitCookieManager *cookie_manager,
EphyCookiesDialog *dialog);
static void
reload_model (EphyCookiesDialog *dialog)
{
- g_signal_handlers_disconnect_by_func (dialog->cookie_manager, cookie_changed_cb, dialog);
- gtk_list_store_clear (GTK_LIST_STORE (dialog->liststore));
- dialog->filled = FALSE;
- populate_model (dialog);
+ g_signal_handlers_disconnect_by_func (dialog->cookie_manager, cookie_changed_cb, dialog);
+ gtk_list_store_clear (GTK_LIST_STORE (dialog->liststore));
+ dialog->filled = FALSE;
+ populate_model (dialog);
}
static void
cookie_changed_cb (WebKitCookieManager *cookie_manager,
EphyCookiesDialog *dialog)
{
- reload_model (dialog);
+ reload_model (dialog);
}
static void
ephy_cookies_dialog_dispose (GObject *object)
{
- g_signal_handlers_disconnect_by_func (EPHY_COOKIES_DIALOG (object)->cookie_manager,
cookie_changed_cb, object);
- G_OBJECT_CLASS (ephy_cookies_dialog_parent_class)->dispose (object);
+ g_signal_handlers_disconnect_by_func (EPHY_COOKIES_DIALOG (object)->cookie_manager, cookie_changed_cb,
object);
+ G_OBJECT_CLASS (ephy_cookies_dialog_parent_class)->dispose (object);
}
static void
ephy_cookies_dialog_finalize (GObject *object)
{
- g_free (EPHY_COOKIES_DIALOG (object)->search_text);
- G_OBJECT_CLASS (ephy_cookies_dialog_parent_class)->finalize (object);
+ g_free (EPHY_COOKIES_DIALOG (object)->search_text);
+ G_OBJECT_CLASS (ephy_cookies_dialog_parent_class)->finalize (object);
}
static void
cookie_remove (EphyCookiesDialog *dialog,
- gpointer data)
+ gpointer data)
{
- const char *domain = (const char *) data;
+ const char *domain = (const char *)data;
- webkit_cookie_manager_delete_cookies_for_domain (dialog->cookie_manager, domain);
+ webkit_cookie_manager_delete_cookies_for_domain (dialog->cookie_manager, domain);
}
static void
-forget (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+forget (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
- EphyCookiesDialog *dialog = EPHY_COOKIES_DIALOG (user_data);
- GList *llist, *rlist = NULL, *l, *r;
- GtkTreeModel *model;
- GtkTreePath *path;
- GtkTreeIter iter, iter2;
- GtkTreeRowReference *row_ref = NULL;
-
- llist = gtk_tree_selection_get_selected_rows (dialog->tree_selection, &model);
-
- if (llist == NULL)
- {
- /* nothing to delete, return early */
- return;
- }
-
- for (l = llist; l != NULL; l = l->next)
- {
- rlist = g_list_prepend (rlist, gtk_tree_row_reference_new (model, (GtkTreePath *)l->data));
- }
-
- /* Intelligent selection logic, no actual selection yet */
-
- path = gtk_tree_row_reference_get_path ((GtkTreeRowReference *) g_list_first (rlist)->data);
-
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_path_free (path);
- iter2 = iter;
-
- if (gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter))
- {
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
- row_ref = gtk_tree_row_reference_new (model, path);
- }
- else
- {
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter2);
- if (gtk_tree_path_prev (path))
- {
- row_ref = gtk_tree_row_reference_new (model, path);
- }
- }
- gtk_tree_path_free (path);
-
- /* Removal */
- for (r = rlist; r != NULL; r = r->next)
- {
- GValue val = { 0, };
-
- GtkTreeIter filter_iter;
- GtkTreeIter child_iter;
-
- path = gtk_tree_row_reference_get_path ((GtkTreeRowReference *)r->data);
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_model_get_value (model, &iter, COL_COOKIES_HOST, &val);
- cookie_remove (dialog, (gpointer)g_value_get_string (&val));
- g_value_unset (&val);
-
- gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (dialog->treemodelsort),
- &filter_iter,
- &iter);
-
- gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER
(dialog->treemodelfilter),
- &child_iter,
- &filter_iter);
-
- gtk_list_store_remove (GTK_LIST_STORE (dialog->liststore), &child_iter);
-
- gtk_tree_row_reference_free ((GtkTreeRowReference *)r->data);
- gtk_tree_path_free (path);
- }
-
- g_list_foreach (llist, (GFunc)gtk_tree_path_free, NULL);
- g_list_free (llist);
- g_list_free (rlist);
-
- /* Selection */
- if (row_ref != NULL)
- {
- path = gtk_tree_row_reference_get_path (row_ref);
-
- if (path != NULL)
- {
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (dialog->cookies_treeview), path, NULL,
FALSE);
- gtk_tree_path_free (path);
- }
-
- gtk_tree_row_reference_free (row_ref);
- }
+ EphyCookiesDialog *dialog = EPHY_COOKIES_DIALOG (user_data);
+ GList *llist, *rlist = NULL, *l, *r;
+ GtkTreeModel *model;
+ GtkTreePath *path;
+ GtkTreeIter iter, iter2;
+ GtkTreeRowReference *row_ref = NULL;
+
+ llist = gtk_tree_selection_get_selected_rows (dialog->tree_selection, &model);
+
+ if (llist == NULL) {
+ /* nothing to delete, return early */
+ return;
+ }
+
+ for (l = llist; l != NULL; l = l->next) {
+ rlist = g_list_prepend (rlist, gtk_tree_row_reference_new (model, (GtkTreePath *)l->data));
+ }
+
+ /* Intelligent selection logic, no actual selection yet */
+
+ path = gtk_tree_row_reference_get_path ((GtkTreeRowReference *)g_list_first (rlist)->data);
+
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_path_free (path);
+ iter2 = iter;
+
+ if (gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter)) {
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
+ row_ref = gtk_tree_row_reference_new (model, path);
+ } else {
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter2);
+ if (gtk_tree_path_prev (path)) {
+ row_ref = gtk_tree_row_reference_new (model, path);
+ }
+ }
+ gtk_tree_path_free (path);
+
+ /* Removal */
+ for (r = rlist; r != NULL; r = r->next) {
+ GValue val = { 0, };
+
+ GtkTreeIter filter_iter;
+ GtkTreeIter child_iter;
+
+ path = gtk_tree_row_reference_get_path ((GtkTreeRowReference *)r->data);
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get_value (model, &iter, COL_COOKIES_HOST, &val);
+ cookie_remove (dialog, (gpointer)g_value_get_string (&val));
+ g_value_unset (&val);
+
+ gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (dialog->treemodelsort),
+ &filter_iter,
+ &iter);
+
+ gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (dialog->treemodelfilter),
+ &child_iter,
+ &filter_iter);
+
+ gtk_list_store_remove (GTK_LIST_STORE (dialog->liststore), &child_iter);
+
+ gtk_tree_row_reference_free ((GtkTreeRowReference *)r->data);
+ gtk_tree_path_free (path);
+ }
+
+ g_list_foreach (llist, (GFunc)gtk_tree_path_free, NULL);
+ g_list_free (llist);
+ g_list_free (rlist);
+
+ /* Selection */
+ if (row_ref != NULL) {
+ path = gtk_tree_row_reference_get_path (row_ref);
+
+ if (path != NULL) {
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (dialog->cookies_treeview), path, NULL, FALSE);
+ gtk_tree_path_free (path);
+ }
+
+ gtk_tree_row_reference_free (row_ref);
+ }
}
static void
update_selection_actions (GActionMap *action_map,
gboolean has_selection)
{
- GAction *forget_action;
+ GAction *forget_action;
- forget_action = g_action_map_lookup_action (action_map, "forget");
- g_simple_action_set_enabled (G_SIMPLE_ACTION (forget_action), has_selection);
+ forget_action = g_action_map_lookup_action (action_map, "forget");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (forget_action), has_selection);
}
static void
on_treeview_selection_changed (GtkTreeSelection *selection,
EphyCookiesDialog *dialog)
{
- update_selection_actions (G_ACTION_MAP (dialog->action_group),
- gtk_tree_selection_count_selected_rows (selection) > 0);
+ update_selection_actions (G_ACTION_MAP (dialog->action_group),
+ gtk_tree_selection_count_selected_rows (selection) > 0);
}
static void
on_search_entry_changed (GtkSearchEntry *entry,
EphyCookiesDialog *dialog)
{
- const char *text;
+ const char *text;
- text = gtk_entry_get_text (GTK_ENTRY (entry));
- g_free (dialog->search_text);
- dialog->search_text = g_strdup (text);
- gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (dialog->treemodelfilter));
+ text = gtk_entry_get_text (GTK_ENTRY (entry));
+ g_free (dialog->search_text);
+ dialog->search_text = g_strdup (text);
+ gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (dialog->treemodelfilter));
}
static void
-forget_all (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+forget_all (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
- EphyCookiesDialog *dialog = EPHY_COOKIES_DIALOG (user_data);
+ EphyCookiesDialog *dialog = EPHY_COOKIES_DIALOG (user_data);
- webkit_cookie_manager_delete_all_cookies (dialog->cookie_manager);
- reload_model (dialog);
+ webkit_cookie_manager_delete_all_cookies (dialog->cookie_manager);
+ reload_model (dialog);
}
static void
ephy_cookies_dialog_class_init (EphyCookiesDialogClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->dispose = ephy_cookies_dialog_dispose;
- object_class->finalize = ephy_cookies_dialog_finalize;
+ object_class->dispose = ephy_cookies_dialog_dispose;
+ object_class->finalize = ephy_cookies_dialog_finalize;
- gtk_widget_class_set_template_from_resource (widget_class,
- "/org/gnome/epiphany/cookies-dialog.ui");
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/epiphany/cookies-dialog.ui");
- gtk_widget_class_bind_template_child (widget_class, EphyCookiesDialog, liststore);
- gtk_widget_class_bind_template_child (widget_class, EphyCookiesDialog, treemodelfilter);
- gtk_widget_class_bind_template_child (widget_class, EphyCookiesDialog, treemodelsort);
- gtk_widget_class_bind_template_child (widget_class, EphyCookiesDialog, cookies_treeview);
- gtk_widget_class_bind_template_child (widget_class, EphyCookiesDialog, tree_selection);
+ gtk_widget_class_bind_template_child (widget_class, EphyCookiesDialog, liststore);
+ gtk_widget_class_bind_template_child (widget_class, EphyCookiesDialog, treemodelfilter);
+ gtk_widget_class_bind_template_child (widget_class, EphyCookiesDialog, treemodelsort);
+ gtk_widget_class_bind_template_child (widget_class, EphyCookiesDialog, cookies_treeview);
+ gtk_widget_class_bind_template_child (widget_class, EphyCookiesDialog, tree_selection);
- gtk_widget_class_bind_template_callback (widget_class, on_treeview_selection_changed);
- gtk_widget_class_bind_template_callback (widget_class, on_search_entry_changed);
+ gtk_widget_class_bind_template_callback (widget_class, on_treeview_selection_changed);
+ gtk_widget_class_bind_template_callback (widget_class, on_search_entry_changed);
}
static gboolean
cookie_search_equal (GtkTreeModel *model,
- int column,
- const gchar *key,
- GtkTreeIter *iter,
- gpointer search_data)
+ int column,
+ const gchar *key,
+ GtkTreeIter *iter,
+ gpointer search_data)
{
- GValue value = { 0, };
- gboolean retval;
+ GValue value = { 0, };
+ gboolean retval;
- /* Note that this is function has to return FALSE for a *match* ! */
+ /* Note that this is function has to return FALSE for a *match* ! */
- gtk_tree_model_get_value (model, iter, column, &value);
- retval = strstr (g_value_get_string (&value), key) == NULL;
- g_value_unset (&value);
+ gtk_tree_model_get_value (model, iter, column, &value);
+ retval = strstr (g_value_get_string (&value), key) == NULL;
+ g_value_unset (&value);
- return retval;
+ return retval;
}
static void
cookie_add (EphyCookiesDialog *dialog,
- gpointer data)
+ gpointer data)
{
- char *domain = (char *) data;
- GtkListStore *store;
- GtkTreeIter iter;
- int column[3] = { COL_COOKIES_HOST, COL_COOKIES_HOST_KEY, COL_COOKIES_DATA };
- GValue value[3] = { { 0, }, { 0, }, { 0, } };
-
- store = GTK_LIST_STORE (dialog->liststore);
-
- /* NOTE: We use this strange method to insert the row, because
- * we want to use g_value_take_string but all the row data needs to
- * be inserted in one call as it's needed when the new row is sorted
- * into the model.
- */
-
- g_value_init (&value[0], G_TYPE_STRING);
- g_value_init (&value[1], G_TYPE_STRING);
- g_value_init (&value[2], SOUP_TYPE_COOKIE);
-
- g_value_set_static_string (&value[0], domain);
- g_value_take_string (&value[1], ephy_string_collate_key_for_domain (domain, -1));
-
- gtk_list_store_insert_with_valuesv (store, &iter, -1,
- column, value,
- G_N_ELEMENTS (value));
-
- g_value_unset (&value[0]);
- g_value_unset (&value[1]);
- g_value_unset (&value[2]);
+ char *domain = (char *)data;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ int column[3] = { COL_COOKIES_HOST, COL_COOKIES_HOST_KEY, COL_COOKIES_DATA };
+ GValue value[3] = { { 0, }, { 0, }, { 0, } };
+
+ store = GTK_LIST_STORE (dialog->liststore);
+
+ /* NOTE: We use this strange method to insert the row, because
+ * we want to use g_value_take_string but all the row data needs to
+ * be inserted in one call as it's needed when the new row is sorted
+ * into the model.
+ */
+
+ g_value_init (&value[0], G_TYPE_STRING);
+ g_value_init (&value[1], G_TYPE_STRING);
+ g_value_init (&value[2], SOUP_TYPE_COOKIE);
+
+ g_value_set_static_string (&value[0], domain);
+ g_value_take_string (&value[1], ephy_string_collate_key_for_domain (domain, -1));
+
+ gtk_list_store_insert_with_valuesv (store, &iter, -1,
+ column, value,
+ G_N_ELEMENTS (value));
+
+ g_value_unset (&value[0]);
+ g_value_unset (&value[1]);
+ g_value_unset (&value[2]);
}
static int
compare_cookie_host_keys (GtkTreeModel *model,
- GtkTreeIter *a,
- GtkTreeIter *b,
- gpointer user_data)
+ GtkTreeIter *a,
+ GtkTreeIter *b,
+ gpointer user_data)
{
- GValue a_value = {0, };
- GValue b_value = {0, };
- int retval;
+ GValue a_value = { 0, };
+ GValue b_value = { 0, };
+ int retval;
- gtk_tree_model_get_value (model, a, COL_COOKIES_HOST_KEY, &a_value);
- gtk_tree_model_get_value (model, b, COL_COOKIES_HOST_KEY, &b_value);
+ gtk_tree_model_get_value (model, a, COL_COOKIES_HOST_KEY, &a_value);
+ gtk_tree_model_get_value (model, b, COL_COOKIES_HOST_KEY, &b_value);
- retval = strcmp (g_value_get_string (&a_value),
- g_value_get_string (&b_value));
+ retval = strcmp (g_value_get_string (&a_value),
+ g_value_get_string (&b_value));
- g_value_unset (&a_value);
- g_value_unset (&b_value);
+ g_value_unset (&a_value);
+ g_value_unset (&b_value);
- return retval;
+ return retval;
}
static void
@@ -338,34 +327,34 @@ get_domains_with_cookies_cb (WebKitCookieManager *cookie_manager,
GAsyncResult *result,
EphyCookiesDialog *dialog)
{
- gchar **domains;
- guint i;
-
- domains = webkit_cookie_manager_get_domains_with_cookies_finish (cookie_manager, result, NULL);
- if (!domains)
- return;
-
- for (i = 0; domains[i]; i++)
- cookie_add (dialog, domains[i]);
-
- /* The array items have been consumed, so we need only to free the array. */
- g_free (domains);
-
- /* Now turn on sorting */
- gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (dialog->liststore),
- COL_COOKIES_HOST_KEY,
- (GtkTreeIterCompareFunc) compare_cookie_host_keys,
- NULL, NULL);
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (dialog->liststore),
- COL_COOKIES_HOST_KEY,
- GTK_SORT_ASCENDING);
-
- g_signal_connect (cookie_manager,
- "changed",
- G_CALLBACK (cookie_changed_cb),
- dialog);
-
- dialog->filled = TRUE;
+ gchar **domains;
+ guint i;
+
+ domains = webkit_cookie_manager_get_domains_with_cookies_finish (cookie_manager, result, NULL);
+ if (!domains)
+ return;
+
+ for (i = 0; domains[i]; i++)
+ cookie_add (dialog, domains[i]);
+
+ /* The array items have been consumed, so we need only to free the array. */
+ g_free (domains);
+
+ /* Now turn on sorting */
+ gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (dialog->liststore),
+ COL_COOKIES_HOST_KEY,
+ (GtkTreeIterCompareFunc)compare_cookie_host_keys,
+ NULL, NULL);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (dialog->liststore),
+ COL_COOKIES_HOST_KEY,
+ GTK_SORT_ASCENDING);
+
+ g_signal_connect (cookie_manager,
+ "changed",
+ G_CALLBACK (cookie_changed_cb),
+ dialog);
+
+ dialog->filled = TRUE;
}
static gboolean
@@ -373,88 +362,88 @@ row_visible_func (GtkTreeModel *model,
GtkTreeIter *iter,
EphyCookiesDialog *dialog)
{
- gboolean visible = FALSE;
- gchar *host;
+ gboolean visible = FALSE;
+ gchar *host;
- if (dialog->search_text == NULL)
- return TRUE;
+ if (dialog->search_text == NULL)
+ return TRUE;
- gtk_tree_model_get (model, iter,
- COL_COOKIES_HOST, &host,
- -1);
+ gtk_tree_model_get (model, iter,
+ COL_COOKIES_HOST, &host,
+ -1);
- if (host != NULL && strstr (host, dialog->search_text) != NULL)
- visible = TRUE;
+ if (host != NULL && strstr (host, dialog->search_text) != NULL)
+ visible = TRUE;
- g_free (host);
+ g_free (host);
- return visible;
+ return visible;
}
static void
populate_model (EphyCookiesDialog *dialog)
{
- g_assert (dialog->filled == FALSE);
+ g_assert (dialog->filled == FALSE);
- webkit_cookie_manager_get_domains_with_cookies (dialog->cookie_manager,
- NULL,
- (GAsyncReadyCallback) get_domains_with_cookies_cb,
- dialog);
+ webkit_cookie_manager_get_domains_with_cookies (dialog->cookie_manager,
+ NULL,
+ (GAsyncReadyCallback)get_domains_with_cookies_cb,
+ dialog);
}
static void
setup_page (EphyCookiesDialog *dialog)
{
- gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (dialog->cookies_treeview),
- (GtkTreeViewSearchEqualFunc) cookie_search_equal,
- dialog, NULL);
- populate_model (dialog);
+ gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (dialog->cookies_treeview),
+ (GtkTreeViewSearchEqualFunc)cookie_search_equal,
+ dialog, NULL);
+ populate_model (dialog);
}
static GActionGroup *
create_action_group (EphyCookiesDialog *dialog)
{
- const GActionEntry entries[] = {
- { "forget", forget },
- { "forget-all", forget_all }
- };
+ const GActionEntry entries[] = {
+ { "forget", forget },
+ { "forget-all", forget_all }
+ };
- GSimpleActionGroup *group;
+ GSimpleActionGroup *group;
- group = g_simple_action_group_new ();
- g_action_map_add_action_entries (G_ACTION_MAP (group), entries, G_N_ELEMENTS (entries), dialog);
+ group = g_simple_action_group_new ();
+ g_action_map_add_action_entries (G_ACTION_MAP (group), entries, G_N_ELEMENTS (entries), dialog);
- return G_ACTION_GROUP (group);
+ return G_ACTION_GROUP (group);
}
static void
ephy_cookies_dialog_init (EphyCookiesDialog *dialog)
{
- WebKitWebContext *web_context;
- EphyEmbedShell *shell = ephy_embed_shell_get_default ();
+ WebKitWebContext *web_context;
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
- gtk_widget_init_template (GTK_WIDGET (dialog));
+ gtk_widget_init_template (GTK_WIDGET (dialog));
- gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (dialog->treemodelfilter),
- (GtkTreeModelFilterVisibleFunc)row_visible_func,
- dialog,
- NULL);
+ gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (dialog->treemodelfilter),
+ (GtkTreeModelFilterVisibleFunc)row_visible_func,
+ dialog,
+ NULL);
- web_context = ephy_embed_shell_get_web_context (shell);
- dialog->cookie_manager = webkit_web_context_get_cookie_manager (web_context);
+ web_context = ephy_embed_shell_get_web_context (shell);
+ dialog->cookie_manager = webkit_web_context_get_cookie_manager (web_context);
- setup_page (dialog);
+ setup_page (dialog);
- dialog->action_group = create_action_group (dialog);
- gtk_widget_insert_action_group (GTK_WIDGET (dialog), "cookies", dialog->action_group);
+ dialog->action_group = create_action_group (dialog);
+ gtk_widget_insert_action_group (GTK_WIDGET (dialog), "cookies", dialog->action_group);
- update_selection_actions (G_ACTION_MAP (dialog->action_group), FALSE);
+ update_selection_actions (G_ACTION_MAP (dialog->action_group), FALSE);
}
EphyCookiesDialog *
ephy_cookies_dialog_new (void)
{
- return g_object_new (EPHY_TYPE_COOKIES_DIALOG,
- "use-header-bar", TRUE,
- NULL);
+ return g_object_new (EPHY_TYPE_COOKIES_DIALOG,
+ "use-header-bar", TRUE,
+ NULL);
}
diff --git a/src/ephy-action-helper.c b/src/ephy-action-helper.c
index 83a4e94..a810672 100644
--- a/src/ephy-action-helper.c
+++ b/src/ephy-action-helper.c
@@ -19,7 +19,7 @@
#include "ephy-action-helper.h"
-#define SENSITIVITY_KEY "EphyAction::Sensitivity"
+#define SENSITIVITY_KEY "EphyAction::Sensitivity"
/**
* ephy_action_change_sensitivity_flags:
@@ -35,32 +35,28 @@
* set. This means you can stack @flags for different events or
* conditions at the same time.
*/
-void
+void
ephy_action_change_sensitivity_flags (GtkAction *action,
- guint flags,
- gboolean set)
+ guint flags,
+ gboolean set)
{
- static GQuark sensitivity_quark = 0;
- GObject *object = (GObject *) action;
- guint value;
+ static GQuark sensitivity_quark = 0;
+ GObject *object = (GObject *)action;
+ guint value;
- if (G_UNLIKELY (sensitivity_quark == 0))
- {
- sensitivity_quark = g_quark_from_static_string (SENSITIVITY_KEY);
- }
+ if (G_UNLIKELY (sensitivity_quark == 0)) {
+ sensitivity_quark = g_quark_from_static_string (SENSITIVITY_KEY);
+ }
- value = GPOINTER_TO_UINT (g_object_get_qdata (object, sensitivity_quark));
+ value = GPOINTER_TO_UINT (g_object_get_qdata (object, sensitivity_quark));
- if (set)
- {
- value |= flags;
- }
- else
- {
- value &= ~flags;
- }
+ if (set) {
+ value |= flags;
+ } else {
+ value &= ~flags;
+ }
- g_object_set_qdata (object, sensitivity_quark, GUINT_TO_POINTER (value));
+ g_object_set_qdata (object, sensitivity_quark, GUINT_TO_POINTER (value));
- gtk_action_set_sensitive (GTK_ACTION (action), value == 0);
+ gtk_action_set_sensitive (GTK_ACTION (action), value == 0);
}
diff --git a/src/ephy-combined-stop-reload-action.c b/src/ephy-combined-stop-reload-action.c
index 3184101..012e09e 100644
--- a/src/ephy-combined-stop-reload-action.c
+++ b/src/ephy-combined-stop-reload-action.c
@@ -29,8 +29,7 @@ G_DEFINE_TYPE (EphyCombinedStopReloadAction, ephy_combined_stop_reload_action, E
#define COMBINED_STOP_RELOAD_ACTION_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), EPHY_TYPE_COMBINED_STOP_RELOAD_ACTION,
EphyCombinedStopReloadActionPrivate))
-struct _EphyCombinedStopReloadActionPrivate
-{
+struct _EphyCombinedStopReloadActionPrivate {
gboolean loading;
gulong action_handler_id;
};
@@ -59,7 +58,7 @@ static GParamSpec *obj_properties[LAST_PROP];
void
ephy_combined_stop_reload_action_set_loading (EphyCombinedStopReloadAction *action,
- gboolean loading)
+ gboolean loading)
{
EphyCombinedStopReloadActionEnum action_enum;
EphyCombinedStopReloadActionPrivate *priv;
@@ -72,7 +71,7 @@ ephy_combined_stop_reload_action_set_loading (EphyCombinedStopReloadAction *acti
return;
action_enum = loading ?
- EPHY_COMBINED_STOP_RELOAD_ACTION_STOP : EPHY_COMBINED_STOP_RELOAD_ACTION_REFRESH;
+ EPHY_COMBINED_STOP_RELOAD_ACTION_STOP : EPHY_COMBINED_STOP_RELOAD_ACTION_REFRESH;
g_object_set (action,
"icon-name", combined_stop_reload_action_entries[action_enum].stock_id,
@@ -97,14 +96,13 @@ ephy_combined_stop_reload_action_get_property (GObject *object,
{
EphyCombinedStopReloadAction *action = EPHY_COMBINED_STOP_RELOAD_ACTION (object);
- switch (property_id)
- {
+ switch (property_id) {
case PROP_LOADING:
g_value_set_boolean (value, action->priv->loading);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- }
+ }
}
static void
@@ -115,14 +113,13 @@ ephy_combined_stop_reload_action_set_property (GObject *object,
{
EphyCombinedStopReloadAction *action = EPHY_COMBINED_STOP_RELOAD_ACTION (object);
- switch (property_id)
- {
- case PROP_LOADING:
- ephy_combined_stop_reload_action_set_loading (action,
- g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ switch (property_id) {
+ case PROP_LOADING:
+ ephy_combined_stop_reload_action_set_loading (action,
+ g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
diff --git a/src/ephy-completion-model.c b/src/ephy-completion-model.c
index 6c0ebcd..8c4e69d 100644
--- a/src/ephy-completion-model.c
+++ b/src/ephy-completion-model.c
@@ -1,5 +1,5 @@
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/*
+/*
* Copyright © 2012 Igalia S.L.
*
* This program is free software; you can redistribute it and/or modify
@@ -66,10 +66,10 @@ static void
free_search_terms (GSList *search_terms)
{
GSList *iter;
-
+
for (iter = search_terms; iter != NULL; iter = iter->next)
- g_regex_unref ((GRegex*)iter->data);
-
+ g_regex_unref ((GRegex *)iter->data);
+
g_slist_free (search_terms);
}
@@ -79,19 +79,19 @@ ephy_completion_model_set_property (GObject *object, guint property_id, const GV
EphyCompletionModel *self = EPHY_COMPLETION_MODEL (object);
switch (property_id) {
- case PROP_HISTORY_SERVICE:
- self->history_service = EPHY_HISTORY_SERVICE (g_value_get_pointer (value));
- break;
- case PROP_BOOKMARKS: {
- EphyBookmarks *bookmarks = EPHY_BOOKMARKS (g_value_get_pointer (value));
-
- self->bookmarks = ephy_bookmarks_get_bookmarks (bookmarks);
- self->smart_bookmarks = ephy_bookmarks_get_smart_bookmarks (bookmarks);
+ case PROP_HISTORY_SERVICE:
+ self->history_service = EPHY_HISTORY_SERVICE (g_value_get_pointer (value));
+ break;
+ case PROP_BOOKMARKS: {
+ EphyBookmarks *bookmarks = EPHY_BOOKMARKS (g_value_get_pointer (value));
+
+ self->bookmarks = ephy_bookmarks_get_bookmarks (bookmarks);
+ self->smart_bookmarks = ephy_bookmarks_get_smart_bookmarks (bookmarks);
}
break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (self, property_id, pspec);
- break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (self, property_id, pspec);
+ break;
}
}
@@ -152,7 +152,7 @@ is_base_address (const char *address)
* Neither scheme nor host contain a slash, so we can use slashes
* figure out if it's a base address.
*
- * Note: previous code was using a GRegExp to do the same thing.
+ * Note: previous code was using a GRegExp to do the same thing.
* While regexps are much nicer to read, they're also a lot
* slower.
*/
@@ -172,8 +172,8 @@ is_base_address (const char *address)
static int
get_relevance (const char *location,
- int visit_count,
- gboolean is_bookmark)
+ int visit_count,
+ gboolean is_bookmark)
{
/* FIXME: use frecency. */
int relevance = 0;
@@ -190,7 +190,7 @@ get_relevance (const char *location,
else
relevance = visit_count;
}
-
+
return relevance;
}
@@ -212,7 +212,7 @@ icon_loaded_cb (GObject *source, GAsyncResult *result, gpointer user_data)
{
GtkTreeIter iter;
GtkTreePath *path;
- IconLoadData *data = (IconLoadData *) user_data;
+ IconLoadData *data = (IconLoadData *)user_data;
WebKitFaviconDatabase *database = WEBKIT_FAVICON_DATABASE (source);
GdkPixbuf *favicon = NULL;
cairo_surface_t *icon_surface = webkit_favicon_database_get_favicon_finish (database, result, NULL);
@@ -244,7 +244,7 @@ set_row_in_model (EphyCompletionModel *model, int position, PotentialRow *row)
GtkTreeIter iter;
GtkTreePath *path;
IconLoadData *data;
- WebKitFaviconDatabase* database;
+ WebKitFaviconDatabase *database;
EphyEmbedShell *shell = ephy_embed_shell_get_default ();
database = webkit_web_context_get_favicon_database (ephy_embed_shell_get_web_context (shell));
@@ -259,7 +259,7 @@ set_row_in_model (EphyCompletionModel *model, int position, PotentialRow *row)
-1);
data = g_slice_new (IconLoadData);
- data->model = GTK_LIST_STORE (g_object_ref(model));
+ data->model = GTK_LIST_STORE (g_object_ref (model));
path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
data->row_reference = gtk_tree_row_reference_new (GTK_TREE_MODEL (model), path);
gtk_tree_path_free (path);
@@ -281,7 +281,7 @@ replace_rows_in_model (EphyCompletionModel *model, GSList *new_rows)
return;
for (i = 0; new_rows != NULL; i++) {
- PotentialRow *row = (PotentialRow*)new_rows->data;
+ PotentialRow *row = (PotentialRow *)new_rows->data;
set_row_in_model (model, i, row);
new_rows = new_rows->next;
@@ -290,10 +290,10 @@ replace_rows_in_model (EphyCompletionModel *model, GSList *new_rows)
static gboolean
should_add_bookmark_to_model (EphyCompletionModel *model,
- const char *search_string,
- const char *title,
- const char *location,
- const char *keywords)
+ const char *search_string,
+ const char *title,
+ const char *location,
+ const char *keywords)
{
gboolean ret = TRUE;
@@ -302,7 +302,7 @@ should_add_bookmark_to_model (EphyCompletionModel *model,
GRegex *current = NULL;
for (iter = model->search_terms; iter != NULL; iter = iter->next) {
- current = (GRegex*)iter->data;
+ current = (GRegex *)iter->data;
if ((!g_regex_match (current, title ? title : "", G_REGEX_MATCH_NOTEMPTY, NULL)) &&
(!g_regex_match (current, location ? location : "", G_REGEX_MATCH_NOTEMPTY, NULL)) &&
(!g_regex_match (current, keywords ? keywords : "", G_REGEX_MATCH_NOTEMPTY, NULL))) {
@@ -326,7 +326,7 @@ static int
find_url (gconstpointer a,
gconstpointer b)
{
- return g_strcmp0 (((PotentialRow*)a)->location,
+ return g_strcmp0 (((PotentialRow *)a)->location,
((char *)b));
}
@@ -352,18 +352,18 @@ free_potential_row (PotentialRow *row)
g_free (row->title);
g_free (row->location);
g_free (row->keywords);
-
+
g_slice_free (PotentialRow, row);
}
static GSList *
-add_to_potential_rows (GSList *rows,
+add_to_potential_rows (GSList *rows,
const char *title,
const char *location,
const char *keywords,
- int visit_count,
- gboolean is_bookmark,
- gboolean search_for_duplicates)
+ int visit_count,
+ gboolean is_bookmark,
+ gboolean search_for_duplicates)
{
gboolean found = FALSE;
PotentialRow *row = potential_row_new (title, location, keywords, visit_count, is_bookmark);
@@ -373,10 +373,10 @@ add_to_potential_rows (GSList *rows,
p = g_slist_find_custom (rows, location, find_url);
if (p) {
- PotentialRow *match = (PotentialRow*)p->data;
+ PotentialRow *match = (PotentialRow *)p->data;
if (row->relevance > match->relevance)
match->relevance = row->relevance;
-
+
found = TRUE;
free_potential_row (row);
}
@@ -391,8 +391,8 @@ add_to_potential_rows (GSList *rows,
static int
sort_by_relevance (gconstpointer a, gconstpointer b)
{
- PotentialRow *r1 = (PotentialRow*)a;
- PotentialRow *r2 = (PotentialRow*)b;
+ PotentialRow *r1 = (PotentialRow *)a;
+ PotentialRow *r2 = (PotentialRow *)b;
if (r1->relevance < r2->relevance)
return 1;
@@ -404,9 +404,9 @@ sort_by_relevance (gconstpointer a, gconstpointer b)
static void
query_completed_cb (EphyHistoryService *service,
- gboolean success,
- gpointer result_data,
- FindURLsData *user_data)
+ gboolean success,
+ gpointer result_data,
+ FindURLsData *user_data)
{
EphyCompletionModel *model = user_data->model;
GList *p, *urls;
@@ -438,10 +438,10 @@ query_completed_cb (EphyHistoryService *service,
}
/* History */
- urls = (GList*)result_data;
+ urls = (GList *)result_data;
for (p = urls; p != NULL; p = p->next) {
- EphyHistoryURL *url = (EphyHistoryURL*)p->data;
+ EphyHistoryURL *url = (EphyHistoryURL *)p->data;
list = add_to_potential_rows (list, url->title, url->url, NULL, url->visit_count, FALSE, TRUE);
}
@@ -466,7 +466,7 @@ query_completed_cb (EphyHistoryService *service,
static void
update_search_terms (EphyCompletionModel *model,
- const char *text)
+ const char *text)
{
const char *current;
const char *ptr;
@@ -484,7 +484,7 @@ update_search_terms (EphyCompletionModel *model,
quote_regex = g_regex_new ("\"", G_REGEX_OPTIMIZE,
G_REGEX_MATCH_NOTEMPTY, NULL);
-
+
/*
* This code loops through the string using pointer arythmetics.
* Although the string we are handling may contain UTF-8 chars
@@ -493,7 +493,7 @@ update_search_terms (EphyCompletionModel *model,
*/
for (count = 0, current = ptr = text; ptr[0] != '\0'; ptr++, count++) {
/*
- * If we found a double quote character; we will
+ * If we found a double quote character; we will
* consume bytes up until the next quote, or
* end of line;
*/
@@ -515,7 +515,7 @@ update_search_terms (EphyCompletionModel *model,
*/
if (ptr[1] == '\0')
count++;
-
+
/*
* remove quotes, and quote any regex-sensitive
* characters
@@ -547,10 +547,10 @@ update_search_terms (EphyCompletionModel *model,
#define MAX_COMPLETION_HISTORY_URLS 8
void
-ephy_completion_model_update_for_string (EphyCompletionModel *model,
- const char *search_string,
+ephy_completion_model_update_for_string (EphyCompletionModel *model,
+ const char *search_string,
EphyHistoryJobCallback callback,
- gpointer data)
+ gpointer data)
{
char **strings;
int i;
diff --git a/src/ephy-encoding-dialog.c b/src/ephy-encoding-dialog.c
index aa09285..d614442 100644
--- a/src/ephy-encoding-dialog.c
+++ b/src/ephy-encoding-dialog.c
@@ -34,39 +34,37 @@
#include <gtk/gtk.h>
#include <webkit2/webkit2.h>
-struct _EphyEncodingDialog
-{
- GtkDialog parent_instance;
-
- EphyEncodings *encodings;
- EphyWindow *window;
- EphyEmbed *embed;
- GtkWidget *enc_view;
- gboolean update_embed_tag;
- gboolean update_view_tag;
- const char *selected_encoding;
-
- /* from the UI file */
- GtkStack *type_stack;
- GtkSwitch *default_switch;
- GtkListBox *list_box;
- GtkListBox *recent_list_box;
- GtkListBox *related_list_box;
- GtkGrid *recent_grid;
- GtkGrid *related_grid;
+struct _EphyEncodingDialog {
+ GtkDialog parent_instance;
+
+ EphyEncodings *encodings;
+ EphyWindow *window;
+ EphyEmbed *embed;
+ GtkWidget *enc_view;
+ gboolean update_embed_tag;
+ gboolean update_view_tag;
+ const char *selected_encoding;
+
+ /* from the UI file */
+ GtkStack *type_stack;
+ GtkSwitch *default_switch;
+ GtkListBox *list_box;
+ GtkListBox *recent_list_box;
+ GtkListBox *related_list_box;
+ GtkGrid *recent_grid;
+ GtkGrid *related_grid;
};
enum {
- COL_TITLE_ELIDED,
- COL_ENCODING,
- NUM_COLS
+ COL_TITLE_ELIDED,
+ COL_ENCODING,
+ NUM_COLS
};
-enum
-{
- PROP_0,
- PROP_PARENT_WINDOW,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_PARENT_WINDOW,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
@@ -77,177 +75,171 @@ static void
select_encoding_row (GtkListBox *list_box,
EphyEncoding *encoding)
{
- const char *target_encoding;
- GList *rows, *r;
+ const char *target_encoding;
+ GList *rows, *r;
- target_encoding = ephy_encoding_get_encoding (encoding);
- rows = gtk_container_get_children (GTK_CONTAINER (list_box));
+ target_encoding = ephy_encoding_get_encoding (encoding);
+ rows = gtk_container_get_children (GTK_CONTAINER (list_box));
- for (r = rows; r != NULL; r = r->next)
- {
- EphyEncodingRow *ephy_encoding_row;
- EphyEncoding *ephy_encoding;
- const char *encoding_string = NULL;
+ for (r = rows; r != NULL; r = r->next) {
+ EphyEncodingRow *ephy_encoding_row;
+ EphyEncoding *ephy_encoding;
+ const char *encoding_string = NULL;
- ephy_encoding_row = EPHY_ENCODING_ROW (gtk_bin_get_child (GTK_BIN (r->data)));
- ephy_encoding = ephy_encoding_row_get_encoding (ephy_encoding_row);
- encoding_string = ephy_encoding_get_encoding (ephy_encoding);
+ ephy_encoding_row = EPHY_ENCODING_ROW (gtk_bin_get_child (GTK_BIN (r->data)));
+ ephy_encoding = ephy_encoding_row_get_encoding (ephy_encoding_row);
+ encoding_string = ephy_encoding_get_encoding (ephy_encoding);
- if (g_strcmp0 (encoding_string, target_encoding) == 0)
- {
- ephy_encoding_row_set_selected (ephy_encoding_row, TRUE);
+ if (g_strcmp0 (encoding_string, target_encoding) == 0) {
+ ephy_encoding_row_set_selected (ephy_encoding_row, TRUE);
- gtk_list_box_select_row (list_box, GTK_LIST_BOX_ROW (r->data));
- /* TODO scroll to row */
+ gtk_list_box_select_row (list_box, GTK_LIST_BOX_ROW (r->data));
+ /* TODO scroll to row */
- break;
- }
- }
- g_list_free (rows);
+ break;
+ }
+ }
+ g_list_free (rows);
}
static void
sync_encoding_against_embed (EphyEncodingDialog *dialog)
{
- const char *encoding;
- gboolean is_automatic = FALSE;
- WebKitWebView *view;
+ const char *encoding;
+ gboolean is_automatic = FALSE;
+ WebKitWebView *view;
- dialog->update_embed_tag = TRUE;
+ dialog->update_embed_tag = TRUE;
- g_return_if_fail (EPHY_IS_EMBED (dialog->embed));
- view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (dialog->embed);
+ g_return_if_fail (EPHY_IS_EMBED (dialog->embed));
+ view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (dialog->embed);
- encoding = webkit_web_view_get_custom_charset (view);
- is_automatic = encoding == NULL;
+ encoding = webkit_web_view_get_custom_charset (view);
+ is_automatic = encoding == NULL;
- if (!is_automatic)
- {
- EphyEncoding *node;
+ if (!is_automatic) {
+ EphyEncoding *node;
- node = ephy_encodings_get_encoding (dialog->encodings, encoding, TRUE);
- g_assert (EPHY_IS_ENCODING (node));
+ node = ephy_encodings_get_encoding (dialog->encodings, encoding, TRUE);
+ g_assert (EPHY_IS_ENCODING (node));
- /* Select the current encoding in the lists. */
- select_encoding_row (dialog->list_box, node);
- select_encoding_row (dialog->recent_list_box, node);
- select_encoding_row (dialog->related_list_box, node);
+ /* Select the current encoding in the lists. */
+ select_encoding_row (dialog->list_box, node);
+ select_encoding_row (dialog->recent_list_box, node);
+ select_encoding_row (dialog->related_list_box, node);
- /* TODO scroll the view so the active encoding is visible */
- }
- gtk_switch_set_active (dialog->default_switch, is_automatic);
- gtk_switch_set_state (dialog->default_switch, is_automatic);
- gtk_widget_set_sensitive (GTK_WIDGET (dialog->type_stack), !is_automatic);
+ /* TODO scroll the view so the active encoding is visible */
+ }
+ gtk_switch_set_active (dialog->default_switch, is_automatic);
+ gtk_switch_set_state (dialog->default_switch, is_automatic);
+ gtk_widget_set_sensitive (GTK_WIDGET (dialog->type_stack), !is_automatic);
- dialog->update_embed_tag = FALSE;
+ dialog->update_embed_tag = FALSE;
}
static void
-embed_net_stop_cb (EphyWebView *view,
- WebKitLoadEvent load_event,
- EphyEncodingDialog *dialog)
+embed_net_stop_cb (EphyWebView *view,
+ WebKitLoadEvent load_event,
+ EphyEncodingDialog *dialog)
{
- if (ephy_web_view_is_loading (view) == FALSE)
- sync_encoding_against_embed (dialog);
+ if (ephy_web_view_is_loading (view) == FALSE)
+ sync_encoding_against_embed (dialog);
}
static void
ephy_encoding_dialog_detach_embed (EphyEncodingDialog *dialog)
{
- EphyEmbed **embedptr;
+ EphyEmbed **embedptr;
- g_signal_handlers_disconnect_by_func (ephy_embed_get_web_view (dialog->embed),
- G_CALLBACK (embed_net_stop_cb),
- dialog);
+ g_signal_handlers_disconnect_by_func (ephy_embed_get_web_view (dialog->embed),
+ G_CALLBACK (embed_net_stop_cb),
+ dialog);
- embedptr = &dialog->embed;
- g_object_remove_weak_pointer (G_OBJECT (dialog->embed),
- (gpointer *) embedptr);
- dialog->embed = NULL;
+ embedptr = &dialog->embed;
+ g_object_remove_weak_pointer (G_OBJECT (dialog->embed),
+ (gpointer *)embedptr);
+ dialog->embed = NULL;
}
static void
ephy_encoding_dialog_attach_embed (EphyEncodingDialog *dialog)
{
- EphyEmbed *embed;
- EphyEmbed **embedptr;
+ EphyEmbed *embed;
+ EphyEmbed **embedptr;
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (dialog->window));
- g_return_if_fail (EPHY_IS_EMBED (embed));
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (dialog->window));
+ g_return_if_fail (EPHY_IS_EMBED (embed));
- g_signal_connect (G_OBJECT (ephy_embed_get_web_view (embed)), "load-changed",
- G_CALLBACK (embed_net_stop_cb), dialog);
+ g_signal_connect (G_OBJECT (ephy_embed_get_web_view (embed)), "load-changed",
+ G_CALLBACK (embed_net_stop_cb), dialog);
- dialog->embed = embed;
+ dialog->embed = embed;
- embedptr = &dialog->embed;
- g_object_add_weak_pointer (G_OBJECT (dialog->embed),
- (gpointer *) embedptr);
+ embedptr = &dialog->embed;
+ g_object_add_weak_pointer (G_OBJECT (dialog->embed),
+ (gpointer *)embedptr);
}
static void
ephy_encoding_dialog_sync_embed (EphyWindow *window, GParamSpec *pspec, EphyEncodingDialog *dialog)
{
- ephy_encoding_dialog_detach_embed (dialog);
- ephy_encoding_dialog_attach_embed (dialog);
- sync_encoding_against_embed (dialog);
+ ephy_encoding_dialog_detach_embed (dialog);
+ ephy_encoding_dialog_attach_embed (dialog);
+ sync_encoding_against_embed (dialog);
}
static void
activate_choice (EphyEncodingDialog *dialog)
{
- WebKitWebView *view;
+ WebKitWebView *view;
- g_return_if_fail (EPHY_IS_EMBED (dialog->embed));
- view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (dialog->embed);
+ g_return_if_fail (EPHY_IS_EMBED (dialog->embed));
+ view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (dialog->embed);
- if (gtk_switch_get_active (dialog->default_switch))
- {
- webkit_web_view_set_custom_charset (view, NULL);
- }
- else if (dialog->selected_encoding != NULL)
- {
- const char *code;
+ if (gtk_switch_get_active (dialog->default_switch)) {
+ webkit_web_view_set_custom_charset (view, NULL);
+ } else if (dialog->selected_encoding != NULL) {
+ const char *code;
- code = dialog->selected_encoding;
+ code = dialog->selected_encoding;
- webkit_web_view_set_custom_charset (view, code);
+ webkit_web_view_set_custom_charset (view, code);
- ephy_encodings_add_recent (dialog->encodings, code);
- }
+ ephy_encodings_add_recent (dialog->encodings, code);
+ }
}
static void
-ephy_encoding_dialog_response_cb (GtkWidget *widget,
- int response,
- EphyEncodingDialog *dialog)
+ephy_encoding_dialog_response_cb (GtkWidget *widget,
+ int response,
+ EphyEncodingDialog *dialog)
{
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_widget_destroy (GTK_WIDGET (dialog));
}
static void
clean_selected_row (gpointer row, gpointer null_pointer)
{
- EphyEncodingRow *ephy_encoding_row;
- ephy_encoding_row = EPHY_ENCODING_ROW (gtk_bin_get_child (GTK_BIN (row)));
- ephy_encoding_row_set_selected (ephy_encoding_row, FALSE);
+ EphyEncodingRow *ephy_encoding_row;
+ ephy_encoding_row = EPHY_ENCODING_ROW (gtk_bin_get_child (GTK_BIN (row)));
+ ephy_encoding_row_set_selected (ephy_encoding_row, FALSE);
}
static void
clean_selected_list_box (GtkListBox *list_box)
{
- GList *rows;
- rows = gtk_container_get_children (GTK_CONTAINER (list_box));
- g_list_foreach (rows, (GFunc)clean_selected_row, NULL);
- g_list_free (rows);
+ GList *rows;
+ rows = gtk_container_get_children (GTK_CONTAINER (list_box));
+ g_list_foreach (rows, (GFunc)clean_selected_row, NULL);
+ g_list_free (rows);
}
static void
clean_selected (EphyEncodingDialog *dialog)
{
- clean_selected_list_box (dialog->list_box);
- clean_selected_list_box (dialog->recent_list_box);
- clean_selected_list_box (dialog->related_list_box);
+ clean_selected_list_box (dialog->list_box);
+ clean_selected_list_box (dialog->recent_list_box);
+ clean_selected_list_box (dialog->related_list_box);
}
static void
@@ -255,27 +247,27 @@ row_activated_cb (GtkListBox *box,
GtkListBoxRow *row,
EphyEncodingDialog *dialog)
{
- EphyEncodingRow *ephy_encoding_row;
- EphyEncoding *ephy_encoding;
- const char *selected_encoding;
+ EphyEncodingRow *ephy_encoding_row;
+ EphyEncoding *ephy_encoding;
+ const char *selected_encoding;
- if (dialog->update_embed_tag || dialog->update_view_tag)
- return;
+ if (dialog->update_embed_tag || dialog->update_view_tag)
+ return;
- dialog->update_view_tag = TRUE;
+ dialog->update_view_tag = TRUE;
- ephy_encoding_row = EPHY_ENCODING_ROW (gtk_bin_get_child (GTK_BIN (row)));
- ephy_encoding = ephy_encoding_row_get_encoding (ephy_encoding_row);
- selected_encoding = ephy_encoding_get_encoding (ephy_encoding);
+ ephy_encoding_row = EPHY_ENCODING_ROW (gtk_bin_get_child (GTK_BIN (row)));
+ ephy_encoding = ephy_encoding_row_get_encoding (ephy_encoding_row);
+ selected_encoding = ephy_encoding_get_encoding (ephy_encoding);
- dialog->selected_encoding = selected_encoding;
+ dialog->selected_encoding = selected_encoding;
- clean_selected (dialog);
- ephy_encoding_row_set_selected (ephy_encoding_row, TRUE);
+ clean_selected (dialog);
+ ephy_encoding_row_set_selected (ephy_encoding_row, TRUE);
- activate_choice (dialog);
+ activate_choice (dialog);
- dialog->update_view_tag = FALSE;
+ dialog->update_view_tag = FALSE;
}
static gboolean
@@ -283,180 +275,173 @@ default_switch_toggled_cb (GtkSwitch *default_switch,
gboolean state,
EphyEncodingDialog *dialog)
{
- if (dialog->update_embed_tag || dialog->update_view_tag)
- {
- gtk_switch_set_state (default_switch, !state); // cancel switch change
- return TRUE;
- }
+ if (dialog->update_embed_tag || dialog->update_view_tag) {
+ gtk_switch_set_state (default_switch, !state); /* cancel switch change */
+ return TRUE;
+ }
- dialog->update_view_tag = TRUE;
+ dialog->update_view_tag = TRUE;
- gtk_switch_set_active (default_switch, state);
- gtk_switch_set_state (default_switch, state);
+ gtk_switch_set_active (default_switch, state);
+ gtk_switch_set_state (default_switch, state);
- // TODO if state == false && selected_encoding == NULL, select safe default in list, or find another
solution
- if (state)
- clean_selected (dialog);
- activate_choice (dialog);
+ /* TODO if state == false && selected_encoding == NULL, select safe default in list, or find another
solution */
+ if (state)
+ clean_selected (dialog);
+ activate_choice (dialog);
- dialog->update_view_tag = FALSE;
+ dialog->update_view_tag = FALSE;
- return TRUE;
+ return TRUE;
}
static void
show_all_button_clicked_cb (GtkButton *show_all_button,
EphyEncodingDialog *dialog)
{
- gtk_stack_set_visible_child_name (dialog->type_stack, "scrolled-window");
+ gtk_stack_set_visible_child_name (dialog->type_stack, "scrolled-window");
}
static gint
sort_list_store (gconstpointer a,
gconstpointer b,
- gpointer user_data)
+ gpointer user_data)
{
- const char *encoding1 = ephy_encoding_get_title_elided ((EphyEncoding *)a);
- const char *encoding2 = ephy_encoding_get_title_elided ((EphyEncoding *)b);
+ const char *encoding1 = ephy_encoding_get_title_elided ((EphyEncoding *)a);
+ const char *encoding2 = ephy_encoding_get_title_elided ((EphyEncoding *)b);
- return g_strcmp0 (encoding1, encoding2);
+ return g_strcmp0 (encoding1, encoding2);
}
static GtkWidget *
create_list_box_row (gpointer object,
gpointer user_data)
{
- return GTK_WIDGET (ephy_encoding_row_new (EPHY_ENCODING (object)));
+ return GTK_WIDGET (ephy_encoding_row_new (EPHY_ENCODING (object)));
}
static void
-add_list_item (EphyEncoding *encoding, GtkListBox* list_box)
+add_list_item (EphyEncoding *encoding, GtkListBox *list_box)
{
- gtk_container_add (GTK_CONTAINER (list_box), GTK_WIDGET (ephy_encoding_row_new (encoding)));
+ gtk_container_add (GTK_CONTAINER (list_box), GTK_WIDGET (ephy_encoding_row_new (encoding)));
}
static int
sort_encodings (gconstpointer a, gconstpointer b)
{
- EphyEncoding *enc1 = (EphyEncoding *)a;
- EphyEncoding *enc2 = (EphyEncoding *)b;
- const char *key1, *key2;
+ EphyEncoding *enc1 = (EphyEncoding *)a;
+ EphyEncoding *enc2 = (EphyEncoding *)b;
+ const char *key1, *key2;
- key1 = ephy_encoding_get_collation_key (enc1);
- key2 = ephy_encoding_get_collation_key (enc2);
+ key1 = ephy_encoding_get_collation_key (enc1);
+ key2 = ephy_encoding_get_collation_key (enc2);
- return strcmp (key1, key2);
+ return strcmp (key1, key2);
}
static void
ephy_encoding_dialog_init (EphyEncodingDialog *dialog)
{
- GList *encodings, *p;
- GListStore *store;
+ GList *encodings, *p;
+ GListStore *store;
- gtk_widget_init_template (GTK_WIDGET (dialog));
+ gtk_widget_init_template (GTK_WIDGET (dialog));
- dialog->update_embed_tag = FALSE;
- dialog->update_view_tag = FALSE;
+ dialog->update_embed_tag = FALSE;
+ dialog->update_view_tag = FALSE;
- dialog->encodings =
- EPHY_ENCODINGS (ephy_embed_shell_get_encodings
- (EPHY_EMBED_SHELL (ephy_shell_get_default ())));
+ dialog->encodings =
+ EPHY_ENCODINGS (ephy_embed_shell_get_encodings
+ (EPHY_EMBED_SHELL (ephy_shell_get_default ())));
- encodings = ephy_encodings_get_all (dialog->encodings);
+ encodings = ephy_encodings_get_all (dialog->encodings);
- store = g_list_store_new (EPHY_TYPE_ENCODING);
- for (p = encodings; p; p = p->next)
- {
- EphyEncoding *encoding = EPHY_ENCODING (p->data);
- g_list_store_insert_sorted (store, encoding, sort_list_store, NULL);
- }
- g_list_free (encodings);
+ store = g_list_store_new (EPHY_TYPE_ENCODING);
+ for (p = encodings; p; p = p->next) {
+ EphyEncoding *encoding = EPHY_ENCODING (p->data);
+ g_list_store_insert_sorted (store, encoding, sort_list_store, NULL);
+ }
+ g_list_free (encodings);
- gtk_list_box_bind_model (dialog->list_box, G_LIST_MODEL (store),
- create_list_box_row,
- NULL, NULL);
+ gtk_list_box_bind_model (dialog->list_box, G_LIST_MODEL (store),
+ create_list_box_row,
+ NULL, NULL);
}
static void
ephy_encoding_dialog_constructed (GObject *object)
{
- EphyEncodingDialog *dialog;
- WebKitWebView *view;
- EphyEncoding *enc_node;
- EphyLanguageGroup groups;
- GList *recent;
- GList *related = NULL;
-
- /* selected encoding */
- dialog = EPHY_ENCODING_DIALOG (object);
-
- g_return_if_fail (EPHY_IS_EMBED (dialog->embed));
- view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (dialog->embed);
-
- dialog->selected_encoding = webkit_web_view_get_custom_charset (view);
-
- /* recent */
- recent = ephy_encodings_get_recent (dialog->encodings);
- if (recent != NULL)
- {
- recent = g_list_sort (recent, (GCompareFunc)sort_encodings);
- g_list_foreach (recent, (GFunc)add_list_item, dialog->recent_list_box);
- }
- else
- gtk_widget_hide (GTK_WIDGET (dialog->recent_grid));
-
- /* related */
- if (dialog->selected_encoding != NULL)
- {
- enc_node = ephy_encodings_get_encoding (dialog->encodings, dialog->selected_encoding, TRUE);
- g_assert (EPHY_IS_ENCODING (enc_node));
- groups = ephy_encoding_get_language_groups (enc_node);
-
- related = ephy_encodings_get_encodings (dialog->encodings, groups);
- }
- if (related != NULL)
- {
- related = g_list_sort (related, (GCompareFunc)sort_encodings);
- g_list_foreach (related, (GFunc)add_list_item, dialog->related_list_box);
- }
- else
- gtk_widget_hide (GTK_WIDGET (dialog->related_grid));
-
- /* update list_boxes */
- sync_encoding_against_embed (dialog);
-
- /* chaining */
- G_OBJECT_CLASS (ephy_encoding_dialog_parent_class)->constructed (object);
+ EphyEncodingDialog *dialog;
+ WebKitWebView *view;
+ EphyEncoding *enc_node;
+ EphyLanguageGroup groups;
+ GList *recent;
+ GList *related = NULL;
+
+ /* selected encoding */
+ dialog = EPHY_ENCODING_DIALOG (object);
+
+ g_return_if_fail (EPHY_IS_EMBED (dialog->embed));
+ view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (dialog->embed);
+
+ dialog->selected_encoding = webkit_web_view_get_custom_charset (view);
+
+ /* recent */
+ recent = ephy_encodings_get_recent (dialog->encodings);
+ if (recent != NULL) {
+ recent = g_list_sort (recent, (GCompareFunc)sort_encodings);
+ g_list_foreach (recent, (GFunc)add_list_item, dialog->recent_list_box);
+ } else
+ gtk_widget_hide (GTK_WIDGET (dialog->recent_grid));
+
+ /* related */
+ if (dialog->selected_encoding != NULL) {
+ enc_node = ephy_encodings_get_encoding (dialog->encodings, dialog->selected_encoding, TRUE);
+ g_assert (EPHY_IS_ENCODING (enc_node));
+ groups = ephy_encoding_get_language_groups (enc_node);
+
+ related = ephy_encodings_get_encodings (dialog->encodings, groups);
+ }
+ if (related != NULL) {
+ related = g_list_sort (related, (GCompareFunc)sort_encodings);
+ g_list_foreach (related, (GFunc)add_list_item, dialog->related_list_box);
+ } else
+ gtk_widget_hide (GTK_WIDGET (dialog->related_grid));
+
+ /* update list_boxes */
+ sync_encoding_against_embed (dialog);
+
+ /* chaining */
+ G_OBJECT_CLASS (ephy_encoding_dialog_parent_class)->constructed (object);
}
static void
ephy_encoding_dialog_dispose (GObject *object)
{
- EphyEncodingDialog *dialog = EPHY_ENCODING_DIALOG (object);
+ EphyEncodingDialog *dialog = EPHY_ENCODING_DIALOG (object);
- g_signal_handlers_disconnect_by_func (dialog->window,
- G_CALLBACK (ephy_encoding_dialog_sync_embed),
- dialog);
+ g_signal_handlers_disconnect_by_func (dialog->window,
+ G_CALLBACK (ephy_encoding_dialog_sync_embed),
+ dialog);
- if (dialog->embed != NULL)
- ephy_encoding_dialog_detach_embed (dialog);
+ if (dialog->embed != NULL)
+ ephy_encoding_dialog_detach_embed (dialog);
- G_OBJECT_CLASS (ephy_encoding_dialog_parent_class)->dispose (object);
+ G_OBJECT_CLASS (ephy_encoding_dialog_parent_class)->dispose (object);
}
static void
ephy_encoding_dialog_set_parent_window (EphyEncodingDialog *dialog,
- EphyWindow *window)
+ EphyWindow *window)
{
- g_return_if_fail (EPHY_IS_WINDOW (window));
+ g_return_if_fail (EPHY_IS_WINDOW (window));
- g_signal_connect (G_OBJECT (window), "notify::active-child",
- G_CALLBACK (ephy_encoding_dialog_sync_embed), dialog);
+ g_signal_connect (G_OBJECT (window), "notify::active-child",
+ G_CALLBACK (ephy_encoding_dialog_sync_embed), dialog);
- dialog->window = window;
+ dialog->window = window;
- ephy_encoding_dialog_attach_embed (dialog);
+ ephy_encoding_dialog_attach_embed (dialog);
}
static void
@@ -465,16 +450,15 @@ ephy_encoding_dialog_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- switch (prop_id)
- {
- case PROP_PARENT_WINDOW:
- ephy_encoding_dialog_set_parent_window (EPHY_ENCODING_DIALOG (object),
- g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ case PROP_PARENT_WINDOW:
+ ephy_encoding_dialog_set_parent_window (EPHY_ENCODING_DIALOG (object),
+ g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
@@ -483,60 +467,59 @@ ephy_encoding_dialog_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- switch (prop_id)
- {
- case PROP_PARENT_WINDOW:
- g_value_set_object (value, EPHY_ENCODING_DIALOG (object)->window);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ case PROP_PARENT_WINDOW:
+ g_value_set_object (value, EPHY_ENCODING_DIALOG (object)->window);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
ephy_encoding_dialog_class_init (EphyEncodingDialogClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
- /* class creation */
- object_class->constructed = ephy_encoding_dialog_constructed;
- object_class->set_property = ephy_encoding_dialog_set_property;
- object_class->get_property = ephy_encoding_dialog_get_property;
- object_class->dispose = ephy_encoding_dialog_dispose;
-
- obj_properties[PROP_PARENT_WINDOW] =
- g_param_spec_object ("parent-window",
- "Parent window",
- "Parent window",
- EPHY_TYPE_WINDOW,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
-
- /* load from UI file */
- gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/epiphany/encoding-dialog.ui");
-
- gtk_widget_class_bind_template_child (widget_class, EphyEncodingDialog, type_stack);
- gtk_widget_class_bind_template_child (widget_class, EphyEncodingDialog, default_switch);
- gtk_widget_class_bind_template_child (widget_class, EphyEncodingDialog, list_box);
- gtk_widget_class_bind_template_child (widget_class, EphyEncodingDialog, recent_list_box);
- gtk_widget_class_bind_template_child (widget_class, EphyEncodingDialog, related_list_box);
- gtk_widget_class_bind_template_child (widget_class, EphyEncodingDialog, recent_grid);
- gtk_widget_class_bind_template_child (widget_class, EphyEncodingDialog, related_grid);
-
- gtk_widget_class_bind_template_callback (widget_class, default_switch_toggled_cb);
- gtk_widget_class_bind_template_callback (widget_class, ephy_encoding_dialog_response_cb);
- gtk_widget_class_bind_template_callback (widget_class, row_activated_cb);
- gtk_widget_class_bind_template_callback (widget_class, show_all_button_clicked_cb);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ /* class creation */
+ object_class->constructed = ephy_encoding_dialog_constructed;
+ object_class->set_property = ephy_encoding_dialog_set_property;
+ object_class->get_property = ephy_encoding_dialog_get_property;
+ object_class->dispose = ephy_encoding_dialog_dispose;
+
+ obj_properties[PROP_PARENT_WINDOW] =
+ g_param_spec_object ("parent-window",
+ "Parent window",
+ "Parent window",
+ EPHY_TYPE_WINDOW,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+
+ /* load from UI file */
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/epiphany/encoding-dialog.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, EphyEncodingDialog, type_stack);
+ gtk_widget_class_bind_template_child (widget_class, EphyEncodingDialog, default_switch);
+ gtk_widget_class_bind_template_child (widget_class, EphyEncodingDialog, list_box);
+ gtk_widget_class_bind_template_child (widget_class, EphyEncodingDialog, recent_list_box);
+ gtk_widget_class_bind_template_child (widget_class, EphyEncodingDialog, related_list_box);
+ gtk_widget_class_bind_template_child (widget_class, EphyEncodingDialog, recent_grid);
+ gtk_widget_class_bind_template_child (widget_class, EphyEncodingDialog, related_grid);
+
+ gtk_widget_class_bind_template_callback (widget_class, default_switch_toggled_cb);
+ gtk_widget_class_bind_template_callback (widget_class, ephy_encoding_dialog_response_cb);
+ gtk_widget_class_bind_template_callback (widget_class, row_activated_cb);
+ gtk_widget_class_bind_template_callback (widget_class, show_all_button_clicked_cb);
}
EphyEncodingDialog *
ephy_encoding_dialog_new (EphyWindow *parent)
{
- return g_object_new (EPHY_TYPE_ENCODING_DIALOG,
- "use-header-bar" , TRUE,
- "parent-window", parent,
- NULL);
+ return g_object_new (EPHY_TYPE_ENCODING_DIALOG,
+ "use-header-bar", TRUE,
+ "parent-window", parent,
+ NULL);
}
diff --git a/src/ephy-encoding-row.c b/src/ephy-encoding-row.c
index 72edf8d..d82f780 100644
--- a/src/ephy-encoding-row.c
+++ b/src/ephy-encoding-row.c
@@ -26,22 +26,20 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-struct _EphyEncodingRow
-{
- GtkGrid parent_instance;
+struct _EphyEncodingRow {
+ GtkGrid parent_instance;
- EphyEncoding *encoding;
+ EphyEncoding *encoding;
- /* from the UI file */
- GtkLabel *encoding_label;
- GtkImage *selected_image;
+ /* from the UI file */
+ GtkLabel *encoding_label;
+ GtkImage *selected_image;
};
-enum
-{
- PROP_0,
- PROP_ENCODING,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_ENCODING,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
@@ -52,35 +50,35 @@ void
ephy_encoding_row_set_selected (EphyEncodingRow *row,
gboolean selected)
{
- g_return_if_fail (EPHY_IS_ENCODING_ROW (row));
+ g_return_if_fail (EPHY_IS_ENCODING_ROW (row));
- if (selected)
- gtk_widget_show (GTK_WIDGET (row->selected_image));
- else
- gtk_widget_hide (GTK_WIDGET (row->selected_image));
+ if (selected)
+ gtk_widget_show (GTK_WIDGET (row->selected_image));
+ else
+ gtk_widget_hide (GTK_WIDGET (row->selected_image));
}
static void
ephy_encoding_row_init (EphyEncodingRow *self)
{
- gtk_widget_init_template (GTK_WIDGET (self));
+ gtk_widget_init_template (GTK_WIDGET (self));
}
static void
ephy_encoding_row_set_encoding (EphyEncodingRow *self,
EphyEncoding *encoding)
{
- g_return_if_fail (EPHY_IS_ENCODING (encoding));
+ g_return_if_fail (EPHY_IS_ENCODING (encoding));
- self->encoding = encoding;
- gtk_label_set_text (self->encoding_label,
- ephy_encoding_get_title_elided (encoding));
+ self->encoding = encoding;
+ gtk_label_set_text (self->encoding_label,
+ ephy_encoding_get_title_elided (encoding));
}
EphyEncoding *
ephy_encoding_row_get_encoding (EphyEncodingRow *row)
{
- return row->encoding;
+ return row->encoding;
}
static void
@@ -89,16 +87,15 @@ ephy_encoding_row_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- switch (prop_id)
- {
- case PROP_ENCODING:
- ephy_encoding_row_set_encoding (EPHY_ENCODING_ROW (object),
- g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ case PROP_ENCODING:
+ ephy_encoding_row_set_encoding (EPHY_ENCODING_ROW (object),
+ g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
@@ -107,47 +104,46 @@ ephy_encoding_row_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- switch (prop_id)
- {
- case PROP_ENCODING:
- g_value_set_object (value, EPHY_ENCODING_ROW (object)->encoding);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ case PROP_ENCODING:
+ g_value_set_object (value, EPHY_ENCODING_ROW (object)->encoding);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
ephy_encoding_row_class_init (EphyEncodingRowClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- /* class creation */
- object_class->set_property = ephy_encoding_row_set_property;
- object_class->get_property = ephy_encoding_row_get_property;
+ /* class creation */
+ object_class->set_property = ephy_encoding_row_set_property;
+ object_class->get_property = ephy_encoding_row_get_property;
- obj_properties[PROP_ENCODING] =
- g_param_spec_object ("encoding",
- "encoding",
- "encoding",
- EPHY_TYPE_ENCODING,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+ obj_properties[PROP_ENCODING] =
+ g_param_spec_object ("encoding",
+ "encoding",
+ "encoding",
+ EPHY_TYPE_ENCODING,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
- /* load from UI file */
- gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/epiphany/encoding-row.ui");
+ /* load from UI file */
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/epiphany/encoding-row.ui");
- gtk_widget_class_bind_template_child (widget_class, EphyEncodingRow, encoding_label);
- gtk_widget_class_bind_template_child (widget_class, EphyEncodingRow, selected_image);
+ gtk_widget_class_bind_template_child (widget_class, EphyEncodingRow, encoding_label);
+ gtk_widget_class_bind_template_child (widget_class, EphyEncodingRow, selected_image);
}
EphyEncodingRow *
ephy_encoding_row_new (EphyEncoding *encoding)
{
- return g_object_new (EPHY_TYPE_ENCODING_ROW,
- "encoding", encoding,
- NULL);
+ return g_object_new (EPHY_TYPE_ENCODING_ROW,
+ "encoding", encoding,
+ NULL);
}
diff --git a/src/ephy-history-window.c b/src/ephy-history-window.c
index 9d13691..544e666 100644
--- a/src/ephy-history-window.c
+++ b/src/ephy-history-window.c
@@ -40,817 +40,795 @@
/* 3/5 of gdkframeclockidle.c's FRAME_INTERVAL (16667 microsecs) */
#define GTK_TREE_VIEW_TIME_MS_PER_IDLE 10
-struct _EphyHistoryWindow
-{
- GtkDialog parent_instance;
+struct _EphyHistoryWindow {
+ GtkDialog parent_instance;
- EphyHistoryService *history_service;
- GCancellable *cancellable;
+ EphyHistoryService *history_service;
+ GCancellable *cancellable;
- GtkWidget *treeview;
- GtkTreeSelection *tree_selection;
- GtkWidget *liststore;
- GtkTreeViewColumn *date_column;
- GtkTreeViewColumn *name_column;
- GtkTreeViewColumn *location_column;
- GtkWidget *date_renderer;
- GtkWidget *location_renderer;
- GMenuModel *treeview_popup_menu_model;
+ GtkWidget *treeview;
+ GtkTreeSelection *tree_selection;
+ GtkWidget *liststore;
+ GtkTreeViewColumn *date_column;
+ GtkTreeViewColumn *name_column;
+ GtkTreeViewColumn *location_column;
+ GtkWidget *date_renderer;
+ GtkWidget *location_renderer;
+ GMenuModel *treeview_popup_menu_model;
- GActionGroup *action_group;
+ GActionGroup *action_group;
- GList *urls;
- guint sorter_source;
+ GList *urls;
+ guint sorter_source;
- char *search_text;
+ char *search_text;
- gboolean sort_ascending;
- gint sort_column;
+ gboolean sort_ascending;
+ gint sort_column;
- GtkWidget *window;
+ GtkWidget *window;
- GtkWidget *confirmation_dialog;
+ GtkWidget *confirmation_dialog;
};
G_DEFINE_TYPE (EphyHistoryWindow, ephy_history_window, GTK_TYPE_DIALOG)
-enum
-{
- PROP_0,
- PROP_HISTORY_SERVICE,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_HISTORY_SERVICE,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
-typedef enum
-{
- COLUMN_DATE,
- COLUMN_NAME,
- COLUMN_LOCATION
+typedef enum {
+ COLUMN_DATE,
+ COLUMN_NAME,
+ COLUMN_LOCATION
} EphyHistoryWindowColumns;
static gboolean
add_urls_source (EphyHistoryWindow *self)
{
- EphyHistoryURL *url;
- GTimer *timer;
- GList *element;
-
- if (self->urls == NULL)
- {
- self->sorter_source = 0;
- return G_SOURCE_REMOVE;
- }
+ EphyHistoryURL *url;
+ GTimer *timer;
+ GList *element;
- timer = g_timer_new ();
- g_timer_start (timer);
+ if (self->urls == NULL) {
+ self->sorter_source = 0;
+ return G_SOURCE_REMOVE;
+ }
- do {
- element = self->urls;
- url = element->data;
- gtk_list_store_insert_with_values (GTK_LIST_STORE (self->liststore),
- NULL, G_MAXINT,
- COLUMN_DATE, url->last_visit_time,
- COLUMN_NAME, url->title,
- COLUMN_LOCATION, url->url,
- -1);
- self->urls = g_list_remove_link (self->urls, element);
- ephy_history_url_free (url);
- g_list_free_1 (element);
+ timer = g_timer_new ();
+ g_timer_start (timer);
- } while (self->urls &&
- g_timer_elapsed (timer, NULL) < GTK_TREE_VIEW_TIME_MS_PER_IDLE / 1000.);
+ do {
+ element = self->urls;
+ url = element->data;
+ gtk_list_store_insert_with_values (GTK_LIST_STORE (self->liststore),
+ NULL, G_MAXINT,
+ COLUMN_DATE, url->last_visit_time,
+ COLUMN_NAME, url->title,
+ COLUMN_LOCATION, url->url,
+ -1);
+ self->urls = g_list_remove_link (self->urls, element);
+ ephy_history_url_free (url);
+ g_list_free_1 (element);
+ } while (self->urls &&
+ g_timer_elapsed (timer, NULL) < GTK_TREE_VIEW_TIME_MS_PER_IDLE / 1000.);
- g_timer_destroy (timer);
+ g_timer_destroy (timer);
- return G_SOURCE_CONTINUE;
+ return G_SOURCE_CONTINUE;
}
static void
on_find_urls_cb (gpointer service,
- gboolean success,
- gpointer result_data,
- gpointer user_data)
+ gboolean success,
+ gpointer result_data,
+ gpointer user_data)
{
- EphyHistoryWindow *self = EPHY_HISTORY_WINDOW (user_data);
- GtkTreeViewColumn *column;
+ EphyHistoryWindow *self = EPHY_HISTORY_WINDOW (user_data);
+ GtkTreeViewColumn *column;
- if (success != TRUE)
- return;
+ if (success != TRUE)
+ return;
- self->urls = (GList *)result_data;
+ self->urls = (GList *)result_data;
- gtk_tree_view_set_model (GTK_TREE_VIEW (self->treeview), NULL);
- gtk_list_store_clear (GTK_LIST_STORE (self->liststore));
- gtk_tree_view_set_model (GTK_TREE_VIEW (self->treeview), GTK_TREE_MODEL (self->liststore));
+ gtk_tree_view_set_model (GTK_TREE_VIEW (self->treeview), NULL);
+ gtk_list_store_clear (GTK_LIST_STORE (self->liststore));
+ gtk_tree_view_set_model (GTK_TREE_VIEW (self->treeview), GTK_TREE_MODEL (self->liststore));
- column = gtk_tree_view_get_column (GTK_TREE_VIEW (self->treeview), self->sort_column);
- gtk_tree_view_column_set_sort_order (column, self->sort_ascending ? GTK_SORT_ASCENDING :
GTK_SORT_DESCENDING);
- gtk_tree_view_column_set_sort_indicator (column, TRUE);
-
- self->sorter_source = g_idle_add ((GSourceFunc)add_urls_source, self);
+ column = gtk_tree_view_get_column (GTK_TREE_VIEW (self->treeview), self->sort_column);
+ gtk_tree_view_column_set_sort_order (column, self->sort_ascending ? GTK_SORT_ASCENDING :
GTK_SORT_DESCENDING);
+ gtk_tree_view_column_set_sort_indicator (column, TRUE);
+ self->sorter_source = g_idle_add ((GSourceFunc)add_urls_source, self);
}
static GList *
substrings_filter (EphyHistoryWindow *self)
{
- char **tokens, **p;
- GList *substrings = NULL;
+ char **tokens, **p;
+ GList *substrings = NULL;
- if (self->search_text == NULL)
- return NULL;
+ if (self->search_text == NULL)
+ return NULL;
- tokens = p = g_strsplit (self->search_text, " ", -1);
+ tokens = p = g_strsplit (self->search_text, " ", -1);
- while (*p) {
- substrings = g_list_prepend (substrings, *p++);
- };
- g_free (tokens);
+ while (*p) {
+ substrings = g_list_prepend (substrings, *p++);
+ }
+ ;
+ g_free (tokens);
- return substrings;
+ return substrings;
}
static void
-remove_pending_sorter_source (EphyHistoryWindow *self) {
-
- if (self->sorter_source != 0)
- {
- g_source_remove (self->sorter_source);
- self->sorter_source = 0;
- }
+remove_pending_sorter_source (EphyHistoryWindow *self)
+{
+ if (self->sorter_source != 0) {
+ g_source_remove (self->sorter_source);
+ self->sorter_source = 0;
+ }
- if (self->urls != NULL)
- {
- g_list_free_full (self->urls, (GDestroyNotify)ephy_history_url_free);
- self->urls = NULL;
- }
+ if (self->urls != NULL) {
+ g_list_free_full (self->urls, (GDestroyNotify)ephy_history_url_free);
+ self->urls = NULL;
+ }
}
static void
filter_now (EphyHistoryWindow *self)
{
- gint64 from, to;
- GList *substrings;
- EphyHistorySortType type;
+ gint64 from, to;
+ GList *substrings;
+ EphyHistorySortType type;
- substrings = substrings_filter (self);
+ substrings = substrings_filter (self);
- from = to = -1; /* all */
+ from = to = -1; /* all */
- switch (self->sort_column)
- {
- case COLUMN_DATE:
- type = self->sort_ascending ? EPHY_HISTORY_SORT_LEAST_RECENTLY_VISITED :
EPHY_HISTORY_SORT_MOST_RECENTLY_VISITED;
- break;
- case COLUMN_NAME:
- type = self->sort_ascending ? EPHY_HISTORY_SORT_TITLE_ASCENDING :
EPHY_HISTORY_SORT_TITLE_DESCENDING;
- break;
- case COLUMN_LOCATION:
- type = self->sort_ascending ? EPHY_HISTORY_SORT_URL_ASCENDING :
EPHY_HISTORY_SORT_URL_DESCENDING;
- break;
- default:
- type = EPHY_HISTORY_SORT_MOST_RECENTLY_VISITED;
- }
+ switch (self->sort_column) {
+ case COLUMN_DATE:
+ type = self->sort_ascending ? EPHY_HISTORY_SORT_LEAST_RECENTLY_VISITED :
EPHY_HISTORY_SORT_MOST_RECENTLY_VISITED;
+ break;
+ case COLUMN_NAME:
+ type = self->sort_ascending ? EPHY_HISTORY_SORT_TITLE_ASCENDING : EPHY_HISTORY_SORT_TITLE_DESCENDING;
+ break;
+ case COLUMN_LOCATION:
+ type = self->sort_ascending ? EPHY_HISTORY_SORT_URL_ASCENDING : EPHY_HISTORY_SORT_URL_DESCENDING;
+ break;
+ default:
+ type = EPHY_HISTORY_SORT_MOST_RECENTLY_VISITED;
+ }
- remove_pending_sorter_source (self);
+ remove_pending_sorter_source (self);
- ephy_history_service_find_urls (self->history_service,
- from, to,
- NUM_RESULTS_LIMIT, 0,
- substrings,
- type,
- self->cancellable,
- (EphyHistoryJobCallback)on_find_urls_cb, self);
+ ephy_history_service_find_urls (self->history_service,
+ from, to,
+ NUM_RESULTS_LIMIT, 0,
+ substrings,
+ type,
+ self->cancellable,
+ (EphyHistoryJobCallback)on_find_urls_cb, self);
}
static void
-confirmation_dialog_response_cb (GtkWidget *dialog,
- int response,
- EphyHistoryWindow *self)
+confirmation_dialog_response_cb (GtkWidget *dialog,
+ int response,
+ EphyHistoryWindow *self)
{
- gtk_widget_destroy (dialog);
+ gtk_widget_destroy (dialog);
- if (response == GTK_RESPONSE_ACCEPT)
- {
- ephy_history_service_clear (self->history_service,
- NULL, NULL, NULL);
- filter_now (self);
- }
+ if (response == GTK_RESPONSE_ACCEPT) {
+ ephy_history_service_clear (self->history_service,
+ NULL, NULL, NULL);
+ filter_now (self);
+ }
}
static GtkWidget *
confirmation_dialog_construct (EphyHistoryWindow *self)
{
- GtkWidget *dialog, *button;
+ GtkWidget *dialog, *button;
- dialog = gtk_message_dialog_new
- (GTK_WINDOW (self),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_CANCEL,
- _("Clear browsing history?"));
+ dialog = gtk_message_dialog_new
+ (GTK_WINDOW (self),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_CANCEL,
+ _("Clear browsing history?"));
- gtk_message_dialog_format_secondary_text
- (GTK_MESSAGE_DIALOG (dialog),
- _("Clearing the browsing history will cause all"
- " history links to be permanently deleted."));
+ gtk_message_dialog_format_secondary_text
+ (GTK_MESSAGE_DIALOG (dialog),
+ _("Clearing the browsing history will cause all"
+ " history links to be permanently deleted."));
- gtk_window_group_add_window (ephy_gui_ensure_window_group (GTK_WINDOW (self)),
- GTK_WINDOW (dialog));
+ gtk_window_group_add_window (ephy_gui_ensure_window_group (GTK_WINDOW (self)),
+ GTK_WINDOW (dialog));
- button = gtk_button_new_with_mnemonic (_("Cl_ear"));
- gtk_widget_show (button);
- gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_ACCEPT);
+ button = gtk_button_new_with_mnemonic (_("Cl_ear"));
+ gtk_widget_show (button);
+ gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_ACCEPT);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
- g_signal_connect (dialog, "response",
- G_CALLBACK (confirmation_dialog_response_cb),
- self);
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (confirmation_dialog_response_cb),
+ self);
- return dialog;
+ return dialog;
}
static void
-forget_all (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+forget_all (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
- EphyHistoryWindow *self = EPHY_HISTORY_WINDOW (user_data);
+ EphyHistoryWindow *self = EPHY_HISTORY_WINDOW (user_data);
- if (self->confirmation_dialog == NULL)
- {
- GtkWidget **confirmation_dialog;
+ if (self->confirmation_dialog == NULL) {
+ GtkWidget **confirmation_dialog;
- self->confirmation_dialog = confirmation_dialog_construct (self);
- confirmation_dialog = &self->confirmation_dialog;
- g_object_add_weak_pointer (G_OBJECT (self->confirmation_dialog),
- (gpointer *) confirmation_dialog);
- }
+ self->confirmation_dialog = confirmation_dialog_construct (self);
+ confirmation_dialog = &self->confirmation_dialog;
+ g_object_add_weak_pointer (G_OBJECT (self->confirmation_dialog),
+ (gpointer *)confirmation_dialog);
+ }
- gtk_widget_show (self->confirmation_dialog);
+ gtk_widget_show (self->confirmation_dialog);
}
static GtkWidget *
get_target_window (EphyHistoryWindow *self)
{
- if (self->window)
- {
- return self->window;
- }
- else
- {
- return GTK_WIDGET (gtk_application_get_active_window (GTK_APPLICATION (ephy_shell_get_default
())));
- }
+ if (self->window) {
+ return self->window;
+ } else {
+ return GTK_WIDGET (gtk_application_get_active_window (GTK_APPLICATION (ephy_shell_get_default ())));
+ }
}
static void
on_browse_history_deleted_cb (gpointer service,
- gboolean success,
- gpointer result_data,
- gpointer user_data)
+ gboolean success,
+ gpointer result_data,
+ gpointer user_data)
{
- EphyHistoryWindow *self = EPHY_HISTORY_WINDOW (user_data);
+ EphyHistoryWindow *self = EPHY_HISTORY_WINDOW (user_data);
- if (success != TRUE)
- return;
+ if (success != TRUE)
+ return;
- filter_now (self);
+ filter_now (self);
}
static EphyHistoryURL *
get_url_from_path (GtkTreeModel *model,
- GtkTreePath *path)
+ GtkTreePath *path)
{
- GtkTreeIter iter;
+ GtkTreeIter iter;
- EphyHistoryURL *url = ephy_history_url_new (NULL, NULL, 0, 0, 0);
+ EphyHistoryURL *url = ephy_history_url_new (NULL, NULL, 0, 0, 0);
- gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_model_get (model, &iter,
- COLUMN_NAME, &url->title,
- COLUMN_LOCATION, &url->url,
- -1);
- return url;
+ gtk_tree_model_get (model, &iter,
+ COLUMN_NAME, &url->title,
+ COLUMN_LOCATION, &url->url,
+ -1);
+ return url;
}
static void
get_selection_foreach (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer *data)
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer *data)
{
- EphyHistoryURL *url;
+ EphyHistoryURL *url;
- url = get_url_from_path (model, path);
- *data = g_list_prepend (*data, url);
+ url = get_url_from_path (model, path);
+ *data = g_list_prepend (*data, url);
}
static GList *
get_selection (EphyHistoryWindow *self)
{
- GList *list = NULL;
+ GList *list = NULL;
- gtk_tree_selection_selected_foreach (self->tree_selection,
- (GtkTreeSelectionForeachFunc) get_selection_foreach,
- &list);
+ gtk_tree_selection_selected_foreach (self->tree_selection,
+ (GtkTreeSelectionForeachFunc)get_selection_foreach,
+ &list);
- return g_list_reverse (list);
+ return g_list_reverse (list);
}
static void
delete_selected (EphyHistoryWindow *self)
{
- GList *selected;
+ GList *selected;
- selected = get_selection (self);
- ephy_history_service_delete_urls (self->history_service, selected, self->cancellable,
- (EphyHistoryJobCallback)on_browse_history_deleted_cb, self);
+ selected = get_selection (self);
+ ephy_history_service_delete_urls (self->history_service, selected, self->cancellable,
+ (EphyHistoryJobCallback)on_browse_history_deleted_cb, self);
}
static void
-open_selection (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+open_selection (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
- EphyHistoryWindow *self = EPHY_HISTORY_WINDOW (user_data);
- EphyWindow *window;
- GList *selection;
- GList *l;
+ EphyHistoryWindow *self = EPHY_HISTORY_WINDOW (user_data);
+ EphyWindow *window;
+ GList *selection;
+ GList *l;
- selection = get_selection (self);
+ selection = get_selection (self);
- window = EPHY_WINDOW (get_target_window (self));
- for (l = selection; l; l = l->next) {
- EphyHistoryURL *url = l->data;
- EphyEmbed *embed;
+ window = EPHY_WINDOW (get_target_window (self));
+ for (l = selection; l; l = l->next) {
+ EphyHistoryURL *url = l->data;
+ EphyEmbed *embed;
- embed = ephy_shell_new_tab (ephy_shell_get_default (),
- window, NULL, EPHY_NEW_TAB_JUMP);
- ephy_web_view_load_url (ephy_embed_get_web_view (embed), url->url);
- }
+ embed = ephy_shell_new_tab (ephy_shell_get_default (),
+ window, NULL, EPHY_NEW_TAB_JUMP);
+ ephy_web_view_load_url (ephy_embed_get_web_view (embed), url->url);
+ }
- g_list_free_full (selection, (GDestroyNotify) ephy_history_url_free);
+ g_list_free_full (selection, (GDestroyNotify)ephy_history_url_free);
}
static void
-copy_url (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+copy_url (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
- EphyHistoryWindow *self = EPHY_HISTORY_WINDOW (user_data);
- GList *selection;
+ EphyHistoryWindow *self = EPHY_HISTORY_WINDOW (user_data);
+ GList *selection;
- selection = get_selection (self);
+ selection = get_selection (self);
- if (g_list_length (selection) == 1) {
- EphyHistoryURL *url = selection->data;
- g_message ("URL %s", url->url);
- gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD), url->url, -1);
- }
+ if (g_list_length (selection) == 1) {
+ EphyHistoryURL *url = selection->data;
+ g_message ("URL %s", url->url);
+ gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD), url->url, -1);
+ }
- g_list_free_full (selection, (GDestroyNotify) ephy_history_url_free);
+ g_list_free_full (selection, (GDestroyNotify)ephy_history_url_free);
}
static void
-bookmark (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+bookmark (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
- EphyHistoryWindow *self = EPHY_HISTORY_WINDOW (user_data);
- GList *selection;
+ EphyHistoryWindow *self = EPHY_HISTORY_WINDOW (user_data);
+ GList *selection;
- selection = get_selection (self);
+ selection = get_selection (self);
- if (g_list_length (selection) == 1)
- {
- EphyHistoryURL *url;
+ if (g_list_length (selection) == 1) {
+ EphyHistoryURL *url;
- url = selection->data;
+ url = selection->data;
- ephy_bookmarks_ui_add_bookmark (GTK_WINDOW (self), url->url, url->title);
- }
+ ephy_bookmarks_ui_add_bookmark (GTK_WINDOW (self), url->url, url->title);
+ }
- g_list_free_full (selection, (GDestroyNotify) ephy_history_url_free);
+ g_list_free_full (selection, (GDestroyNotify)ephy_history_url_free);
}
static void
-forget (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+forget (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
- EphyHistoryWindow *self = EPHY_HISTORY_WINDOW (user_data);
+ EphyHistoryWindow *self = EPHY_HISTORY_WINDOW (user_data);
- delete_selected (self);
+ delete_selected (self);
}
static gboolean
on_treeview_key_press_event (GtkWidget *widget,
- GdkEventKey *event,
- EphyHistoryWindow *self)
+ GdkEventKey *event,
+ EphyHistoryWindow *self)
{
- if (event->keyval == GDK_KEY_Delete || event->keyval == GDK_KEY_KP_Delete)
- {
- delete_selected (self);
+ if (event->keyval == GDK_KEY_Delete || event->keyval == GDK_KEY_KP_Delete) {
+ delete_selected (self);
- return TRUE;
- }
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
static void
update_popup_menu_actions (GActionGroup *action_group,
gboolean only_one_selected_item)
{
- GAction *copy_url_action;
- GAction *bookmark_action;
- gboolean bookmarks_locked;
+ GAction *copy_url_action;
+ GAction *bookmark_action;
+ gboolean bookmarks_locked;
- copy_url_action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "copy-url");
- bookmark_action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "bookmark");
- bookmarks_locked = g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
- EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING);
+ copy_url_action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "copy-url");
+ bookmark_action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "bookmark");
+ bookmarks_locked = g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING);
- g_simple_action_set_enabled (G_SIMPLE_ACTION (copy_url_action), only_one_selected_item);
- g_simple_action_set_enabled (G_SIMPLE_ACTION (bookmark_action), (only_one_selected_item &&
!bookmarks_locked));
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (copy_url_action), only_one_selected_item);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (bookmark_action), (only_one_selected_item &&
!bookmarks_locked));
}
static gboolean
on_treeview_button_press_event (GtkWidget *widget,
- GdkEventButton *event,
- EphyHistoryWindow *self)
+ GdkEventButton *event,
+ EphyHistoryWindow *self)
{
- if (event->button == 3) {
- int n;
- GtkWidget *menu;
+ if (event->button == 3) {
+ int n;
+ GtkWidget *menu;
- n = gtk_tree_selection_count_selected_rows (self->tree_selection);
- if (n <= 0)
- return FALSE;
+ n = gtk_tree_selection_count_selected_rows (self->tree_selection);
+ if (n <= 0)
+ return FALSE;
- update_popup_menu_actions (self->action_group, (n == 1));
+ update_popup_menu_actions (self->action_group, (n == 1));
- menu = gtk_menu_new_from_model (self->treeview_popup_menu_model);
- gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (self), NULL);
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time);
- return TRUE;
- }
+ menu = gtk_menu_new_from_model (self->treeview_popup_menu_model);
+ gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (self), NULL);
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time);
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
static void
-on_treeview_row_activated (GtkTreeView *view,
- GtkTreePath *path,
- GtkTreeViewColumn *col,
- EphyHistoryWindow *self)
+on_treeview_row_activated (GtkTreeView *view,
+ GtkTreePath *path,
+ GtkTreeViewColumn *col,
+ EphyHistoryWindow *self)
{
- EphyWindow *window;
- EphyHistoryURL *url;
- EphyEmbed *embed;
+ EphyWindow *window;
+ EphyHistoryURL *url;
+ EphyEmbed *embed;
- window = EPHY_WINDOW (get_target_window (self));
- url = get_url_from_path (gtk_tree_view_get_model (view),
- path);
- g_return_if_fail (url != NULL);
+ window = EPHY_WINDOW (get_target_window (self));
+ url = get_url_from_path (gtk_tree_view_get_model (view),
+ path);
+ g_return_if_fail (url != NULL);
- embed = ephy_shell_new_tab (ephy_shell_get_default (),
- window, NULL, EPHY_NEW_TAB_JUMP);
- ephy_web_view_load_url (ephy_embed_get_web_view (embed), url->url);
- ephy_history_url_free (url);
+ embed = ephy_shell_new_tab (ephy_shell_get_default (),
+ window, NULL, EPHY_NEW_TAB_JUMP);
+ ephy_web_view_load_url (ephy_embed_get_web_view (embed), url->url);
+ ephy_history_url_free (url);
}
static void
-on_search_entry_changed (GtkSearchEntry *entry,
- EphyHistoryWindow *self)
+on_search_entry_changed (GtkSearchEntry *entry,
+ EphyHistoryWindow *self)
{
- const char *text;
+ const char *text;
- text = gtk_entry_get_text (GTK_ENTRY (entry));
- g_free (self->search_text);
- self->search_text = g_strdup (text);
+ text = gtk_entry_get_text (GTK_ENTRY (entry));
+ g_free (self->search_text);
+ self->search_text = g_strdup (text);
- filter_now (self);
+ filter_now (self);
}
static void
update_selection_actions (GActionGroup *action_group,
gboolean has_selection)
{
- GAction *forget_action;
- GAction *open_selection_action;
+ GAction *forget_action;
+ GAction *open_selection_action;
- forget_action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "forget");
- open_selection_action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "open-selection");
+ forget_action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "forget");
+ open_selection_action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "open-selection");
- g_simple_action_set_enabled (G_SIMPLE_ACTION (forget_action), has_selection);
- g_simple_action_set_enabled (G_SIMPLE_ACTION (open_selection_action), has_selection);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (forget_action), has_selection);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (open_selection_action), has_selection);
}
static void
-on_treeview_selection_changed (GtkTreeSelection *selection,
- EphyHistoryWindow *self)
+on_treeview_selection_changed (GtkTreeSelection *selection,
+ EphyHistoryWindow *self)
{
- update_selection_actions (self->action_group,
- gtk_tree_selection_count_selected_rows (selection) > 0);
+ update_selection_actions (self->action_group,
+ gtk_tree_selection_count_selected_rows (selection) > 0);
}
static void
on_treeview_column_clicked_event (GtkTreeViewColumn *column,
- EphyHistoryWindow *self)
+ EphyHistoryWindow *self)
{
- GtkTreeViewColumn *previous_sortby;
- gint new_sort_column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (column), "column"));
+ GtkTreeViewColumn *previous_sortby;
+ gint new_sort_column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (column), "column"));
- if (new_sort_column == self->sort_column)
- {
- self->sort_ascending = !(self->sort_ascending);
- }
- else
- {
- previous_sortby = gtk_tree_view_get_column (GTK_TREE_VIEW (self->treeview),
self->sort_column);
- gtk_tree_view_column_set_sort_indicator (previous_sortby, FALSE);
+ if (new_sort_column == self->sort_column) {
+ self->sort_ascending = !(self->sort_ascending);
+ } else {
+ previous_sortby = gtk_tree_view_get_column (GTK_TREE_VIEW (self->treeview), self->sort_column);
+ gtk_tree_view_column_set_sort_indicator (previous_sortby, FALSE);
- self->sort_column = new_sort_column;
- self->sort_ascending = self->sort_column == COLUMN_DATE ? FALSE : TRUE;
- }
+ self->sort_column = new_sort_column;
+ self->sort_ascending = self->sort_column == COLUMN_DATE ? FALSE : TRUE;
+ }
- gtk_tree_view_column_set_sort_order (column, self->sort_ascending ? GTK_SORT_ASCENDING :
GTK_SORT_DESCENDING);
- gtk_tree_view_column_set_sort_indicator (column, TRUE);
- filter_now (self);
+ gtk_tree_view_column_set_sort_order (column, self->sort_ascending ? GTK_SORT_ASCENDING :
GTK_SORT_DESCENDING);
+ gtk_tree_view_column_set_sort_indicator (column, TRUE);
+ filter_now (self);
}
static gboolean
on_urls_visited_cb (EphyHistoryService *service,
- EphyHistoryWindow *self)
+ EphyHistoryWindow *self)
{
- filter_now (self);
+ filter_now (self);
- return FALSE;
+ return FALSE;
}
static void
-set_history_service (EphyHistoryWindow *self,
- EphyHistoryService *history_service)
+set_history_service (EphyHistoryWindow *self,
+ EphyHistoryService *history_service)
{
- if (history_service == self->history_service)
- return;
+ if (history_service == self->history_service)
+ return;
- if (self->history_service != NULL) {
- g_signal_handlers_disconnect_by_func (self->history_service,
- on_urls_visited_cb,
- self);
- g_clear_object (&self->history_service);
- }
+ if (self->history_service != NULL) {
+ g_signal_handlers_disconnect_by_func (self->history_service,
+ on_urls_visited_cb,
+ self);
+ g_clear_object (&self->history_service);
+ }
- if (history_service != NULL) {
- self->history_service = g_object_ref (history_service);
- g_signal_connect_after (self->history_service,
- "urls-visited", G_CALLBACK (on_urls_visited_cb),
- self);
- }
+ if (history_service != NULL) {
+ self->history_service = g_object_ref (history_service);
+ g_signal_connect_after (self->history_service,
+ "urls-visited", G_CALLBACK (on_urls_visited_cb),
+ self);
+ }
- filter_now (self);
+ filter_now (self);
}
static void
-ephy_history_window_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ephy_history_window_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- EphyHistoryWindow *self = EPHY_HISTORY_WINDOW (object);
+ EphyHistoryWindow *self = EPHY_HISTORY_WINDOW (object);
- switch (prop_id)
- {
- case PROP_HISTORY_SERVICE:
- set_history_service (self, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ case PROP_HISTORY_SERVICE:
+ set_history_service (self, g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-ephy_history_window_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ephy_history_window_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- EphyHistoryWindow *self = EPHY_HISTORY_WINDOW (object);
+ EphyHistoryWindow *self = EPHY_HISTORY_WINDOW (object);
- switch (prop_id)
- {
- case PROP_HISTORY_SERVICE:
- g_value_set_object (value, self->history_service);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ case PROP_HISTORY_SERVICE:
+ g_value_set_object (value, self->history_service);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
ephy_history_window_dispose (GObject *object)
{
- EphyHistoryWindow *self = EPHY_HISTORY_WINDOW (object);
+ EphyHistoryWindow *self = EPHY_HISTORY_WINDOW (object);
- g_free (self->search_text);
- self->search_text = NULL;
+ g_free (self->search_text);
+ self->search_text = NULL;
- if (self->cancellable)
- {
- g_cancellable_cancel (self->cancellable);
- g_clear_object (&self->cancellable);
- }
+ if (self->cancellable) {
+ g_cancellable_cancel (self->cancellable);
+ g_clear_object (&self->cancellable);
+ }
- if (self->history_service != NULL)
- g_signal_handlers_disconnect_by_func (self->history_service,
- on_urls_visited_cb,
- self);
- g_clear_object (&self->history_service);
+ if (self->history_service != NULL)
+ g_signal_handlers_disconnect_by_func (self->history_service,
+ on_urls_visited_cb,
+ self);
+ g_clear_object (&self->history_service);
- remove_pending_sorter_source (self);
+ remove_pending_sorter_source (self);
- G_OBJECT_CLASS (ephy_history_window_parent_class)->dispose (object);
+ G_OBJECT_CLASS (ephy_history_window_parent_class)->dispose (object);
}
static void
ephy_history_window_finalize (GObject *object)
{
- EphyHistoryWindow *self = EPHY_HISTORY_WINDOW (object);
+ EphyHistoryWindow *self = EPHY_HISTORY_WINDOW (object);
- if (self->window)
- {
- GtkWidget **window = &self->window;
- g_object_remove_weak_pointer
- (G_OBJECT(self->window),
- (gpointer *)window);
- }
+ if (self->window) {
+ GtkWidget **window = &self->window;
+ g_object_remove_weak_pointer
+ (G_OBJECT (self->window),
+ (gpointer *)window);
+ }
- G_OBJECT_CLASS (ephy_history_window_parent_class)->finalize (object);
+ G_OBJECT_CLASS (ephy_history_window_parent_class)->finalize (object);
}
static void
ephy_history_window_class_init (EphyHistoryWindowClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = ephy_history_window_finalize;
+ object_class->finalize = ephy_history_window_finalize;
- object_class->set_property = ephy_history_window_set_property;
- object_class->get_property = ephy_history_window_get_property;
- object_class->dispose = ephy_history_window_dispose;
+ object_class->set_property = ephy_history_window_set_property;
+ object_class->get_property = ephy_history_window_get_property;
+ object_class->dispose = ephy_history_window_dispose;
- obj_properties[PROP_HISTORY_SERVICE] =
- g_param_spec_object ("history-service",
- "History service",
- "History Service",
- EPHY_TYPE_HISTORY_SERVICE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+ obj_properties[PROP_HISTORY_SERVICE] =
+ g_param_spec_object ("history-service",
+ "History service",
+ "History Service",
+ EPHY_TYPE_HISTORY_SERVICE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
- gtk_widget_class_set_template_from_resource (widget_class,
- "/org/gnome/epiphany/history-dialog.ui");
- gtk_widget_class_bind_template_child (widget_class, EphyHistoryWindow, liststore);
- gtk_widget_class_bind_template_child (widget_class, EphyHistoryWindow, treeview);
- gtk_widget_class_bind_template_child (widget_class, EphyHistoryWindow, tree_selection);
- gtk_widget_class_bind_template_child (widget_class, EphyHistoryWindow, date_column);
- gtk_widget_class_bind_template_child (widget_class, EphyHistoryWindow, name_column);
- gtk_widget_class_bind_template_child (widget_class, EphyHistoryWindow, location_column);
- gtk_widget_class_bind_template_child (widget_class, EphyHistoryWindow, date_renderer);
- gtk_widget_class_bind_template_child (widget_class, EphyHistoryWindow, location_renderer);
- gtk_widget_class_bind_template_child (widget_class, EphyHistoryWindow, treeview_popup_menu_model);
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/epiphany/history-dialog.ui");
+ gtk_widget_class_bind_template_child (widget_class, EphyHistoryWindow, liststore);
+ gtk_widget_class_bind_template_child (widget_class, EphyHistoryWindow, treeview);
+ gtk_widget_class_bind_template_child (widget_class, EphyHistoryWindow, tree_selection);
+ gtk_widget_class_bind_template_child (widget_class, EphyHistoryWindow, date_column);
+ gtk_widget_class_bind_template_child (widget_class, EphyHistoryWindow, name_column);
+ gtk_widget_class_bind_template_child (widget_class, EphyHistoryWindow, location_column);
+ gtk_widget_class_bind_template_child (widget_class, EphyHistoryWindow, date_renderer);
+ gtk_widget_class_bind_template_child (widget_class, EphyHistoryWindow, location_renderer);
+ gtk_widget_class_bind_template_child (widget_class, EphyHistoryWindow, treeview_popup_menu_model);
- gtk_widget_class_bind_template_callback (widget_class, on_treeview_row_activated);
- gtk_widget_class_bind_template_callback (widget_class, on_treeview_key_press_event);
- gtk_widget_class_bind_template_callback (widget_class, on_treeview_button_press_event);
- gtk_widget_class_bind_template_callback (widget_class, on_treeview_selection_changed);
- gtk_widget_class_bind_template_callback (widget_class, on_treeview_column_clicked_event);
- gtk_widget_class_bind_template_callback (widget_class, on_search_entry_changed);
+ gtk_widget_class_bind_template_callback (widget_class, on_treeview_row_activated);
+ gtk_widget_class_bind_template_callback (widget_class, on_treeview_key_press_event);
+ gtk_widget_class_bind_template_callback (widget_class, on_treeview_button_press_event);
+ gtk_widget_class_bind_template_callback (widget_class, on_treeview_selection_changed);
+ gtk_widget_class_bind_template_callback (widget_class, on_treeview_column_clicked_event);
+ gtk_widget_class_bind_template_callback (widget_class, on_search_entry_changed);
}
static void
convert_date_data_func (GtkTreeViewColumn *column,
- GtkCellRenderer *renderer,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- gpointer user_data)
+ GtkCellRenderer *renderer,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer user_data)
{
- int col_id = GPOINTER_TO_INT (user_data);
- int value;
- time_t time;
- char *friendly;
+ int col_id = GPOINTER_TO_INT (user_data);
+ int value;
+ time_t time;
+ char *friendly;
- gtk_tree_model_get (model, iter,
- col_id,
- &value,
- -1);
- time = (time_t) value;
+ gtk_tree_model_get (model, iter,
+ col_id,
+ &value,
+ -1);
+ time = (time_t)value;
- friendly = ephy_time_helpers_utf_friendly_time (time);
- g_object_set (renderer, "text", friendly, NULL);
- g_free (friendly);
+ friendly = ephy_time_helpers_utf_friendly_time (time);
+ g_object_set (renderer, "text", friendly, NULL);
+ g_free (friendly);
}
static void
convert_location_data_func (GtkTreeViewColumn *column,
- GtkCellRenderer *renderer,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- gpointer user_data)
+ GtkCellRenderer *renderer,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer user_data)
{
- int col_id = GPOINTER_TO_INT (user_data);
- char *url;
- char *decoded_url;
+ int col_id = GPOINTER_TO_INT (user_data);
+ char *url;
+ char *decoded_url;
- gtk_tree_model_get (model, iter,
- col_id,
- &url,
- -1);
- decoded_url = ephy_uri_decode (url);
+ gtk_tree_model_get (model, iter,
+ col_id,
+ &url,
+ -1);
+ decoded_url = ephy_uri_decode (url);
- g_object_set (renderer, "text", decoded_url, NULL);
+ g_object_set (renderer, "text", decoded_url, NULL);
- g_free (url);
- g_free (decoded_url);
+ g_free (url);
+ g_free (decoded_url);
}
GtkWidget *
ephy_history_window_new (EphyHistoryService *history_service)
{
- EphyHistoryWindow *self;
+ EphyHistoryWindow *self;
- g_return_val_if_fail (history_service != NULL, NULL);
+ g_return_val_if_fail (history_service != NULL, NULL);
- self = g_object_new (EPHY_TYPE_HISTORY_WINDOW,
- "use-header-bar" , TRUE,
- "history-service", history_service,
- NULL);
+ self = g_object_new (EPHY_TYPE_HISTORY_WINDOW,
+ "use-header-bar", TRUE,
+ "history-service", history_service,
+ NULL);
- return GTK_WIDGET (self);
+ return GTK_WIDGET (self);
}
static GActionGroup *
create_action_group (EphyHistoryWindow *self)
{
- const GActionEntry entries[] = {
- { "open-selection", open_selection },
- { "copy-url", copy_url },
- { "bookmark", bookmark },
- { "forget", forget },
- { "forget-all", forget_all }
- };
- GSimpleActionGroup *group;
+ const GActionEntry entries[] = {
+ { "open-selection", open_selection },
+ { "copy-url", copy_url },
+ { "bookmark", bookmark },
+ { "forget", forget },
+ { "forget-all", forget_all }
+ };
+ GSimpleActionGroup *group;
- group = g_simple_action_group_new ();
- g_action_map_add_action_entries (G_ACTION_MAP (group), entries, G_N_ELEMENTS (entries), self);
+ group = g_simple_action_group_new ();
+ g_action_map_add_action_entries (G_ACTION_MAP (group), entries, G_N_ELEMENTS (entries), self);
- return G_ACTION_GROUP (group);
+ return G_ACTION_GROUP (group);
}
static void
ephy_history_window_init (EphyHistoryWindow *self)
{
- gtk_widget_init_template (GTK_WIDGET (self));
+ gtk_widget_init_template (GTK_WIDGET (self));
- self->cancellable = g_cancellable_new ();
+ self->cancellable = g_cancellable_new ();
- self->urls = NULL;
- self->sort_ascending = FALSE;
- self->sort_column = COLUMN_DATE;
- self->sorter_source = 0;
+ self->urls = NULL;
+ self->sort_ascending = FALSE;
+ self->sort_column = COLUMN_DATE;
+ self->sorter_source = 0;
- ephy_gui_ensure_window_group (GTK_WINDOW (self));
+ ephy_gui_ensure_window_group (GTK_WINDOW (self));
- g_object_set_data (G_OBJECT (self->date_column),
- "column", GINT_TO_POINTER (COLUMN_DATE));
- g_object_set_data (G_OBJECT (self->name_column),
- "column", GINT_TO_POINTER (COLUMN_NAME));
- g_object_set_data (G_OBJECT (self->location_column),
- "column", GINT_TO_POINTER (COLUMN_LOCATION));
+ g_object_set_data (G_OBJECT (self->date_column),
+ "column", GINT_TO_POINTER (COLUMN_DATE));
+ g_object_set_data (G_OBJECT (self->name_column),
+ "column", GINT_TO_POINTER (COLUMN_NAME));
+ g_object_set_data (G_OBJECT (self->location_column),
+ "column", GINT_TO_POINTER (COLUMN_LOCATION));
- gtk_tree_view_column_set_cell_data_func (GTK_TREE_VIEW_COLUMN (self->date_column),
- GTK_CELL_RENDERER (self->date_renderer),
- (GtkTreeCellDataFunc) convert_date_data_func,
- GINT_TO_POINTER (COLUMN_DATE),
- NULL);
+ gtk_tree_view_column_set_cell_data_func (GTK_TREE_VIEW_COLUMN (self->date_column),
+ GTK_CELL_RENDERER (self->date_renderer),
+ (GtkTreeCellDataFunc)convert_date_data_func,
+ GINT_TO_POINTER (COLUMN_DATE),
+ NULL);
- gtk_tree_view_column_set_cell_data_func (GTK_TREE_VIEW_COLUMN (self->location_column),
- GTK_CELL_RENDERER (self->location_renderer),
- (GtkTreeCellDataFunc) convert_location_data_func,
- GINT_TO_POINTER (COLUMN_LOCATION),
- NULL);
+ gtk_tree_view_column_set_cell_data_func (GTK_TREE_VIEW_COLUMN (self->location_column),
+ GTK_CELL_RENDERER (self->location_renderer),
+ (GtkTreeCellDataFunc)convert_location_data_func,
+ GINT_TO_POINTER (COLUMN_LOCATION),
+ NULL);
- self->action_group = create_action_group (self);
- gtk_widget_insert_action_group (GTK_WIDGET (self), "history", self->action_group);
+ self->action_group = create_action_group (self);
+ gtk_widget_insert_action_group (GTK_WIDGET (self), "history", self->action_group);
- update_selection_actions (self->action_group, FALSE);
+ update_selection_actions (self->action_group, FALSE);
}
diff --git a/src/ephy-home-action.c b/src/ephy-home-action.c
index b45f286..7de40d2 100644
--- a/src/ephy-home-action.c
+++ b/src/ephy-home-action.c
@@ -1,20 +1,20 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
-* Copyright © 2004 Christian Persch
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, or (at your option)
-* any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
+ * Copyright © 2004 Christian Persch
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
#include "config.h"
#include "ephy-home-action.h"
@@ -24,51 +24,51 @@
G_DEFINE_TYPE (EphyHomeAction, ephy_home_action, EPHY_TYPE_LINK_ACTION)
static void
-ephy_home_action_open (GtkAction *action,
- const char *address,
- EphyLinkFlags flags)
+ephy_home_action_open (GtkAction *action,
+ const char *address,
+ EphyLinkFlags flags)
{
- ephy_link_open (EPHY_LINK (action),
- address != NULL && address[0] != '\0' ? address : "about:blank",
- NULL,
- flags);
+ ephy_link_open (EPHY_LINK (action),
+ address != NULL && address[0] != '\0' ? address : "about:blank",
+ NULL,
+ flags);
}
static void
-action_name_association (GtkAction *action,
- char *action_name,
- const char *address)
+action_name_association (GtkAction *action,
+ char *action_name,
+ const char *address)
{
- EphyLinkFlags flags = EPHY_LINK_HOME_PAGE;
+ EphyLinkFlags flags = EPHY_LINK_HOME_PAGE;
- if (g_str_equal (action_name, "FileNewTab"))
- flags |= EPHY_LINK_NEW_TAB | EPHY_LINK_JUMP_TO;
+ if (g_str_equal (action_name, "FileNewTab"))
+ flags |= EPHY_LINK_NEW_TAB | EPHY_LINK_JUMP_TO;
- ephy_home_action_open (action, address, flags);
-}
+ ephy_home_action_open (action, address, flags);
+}
static void
ephy_home_action_activate (GtkAction *action)
{
- char *action_name;
+ char *action_name;
+
+ g_object_get (G_OBJECT (action), "name", &action_name, NULL);
- g_object_get (G_OBJECT (action), "name", &action_name, NULL);
-
- action_name_association (action, action_name, "about:overview");
+ action_name_association (action, action_name, "about:overview");
- g_free (action_name);
+ g_free (action_name);
}
static void
ephy_home_action_class_init (EphyHomeActionClass *class)
{
- GtkActionClass *action_class = GTK_ACTION_CLASS (class);
-
- action_class->activate = ephy_home_action_activate;
+ GtkActionClass *action_class = GTK_ACTION_CLASS (class);
+
+ action_class->activate = ephy_home_action_activate;
}
static void
ephy_home_action_init (EphyHomeAction *action)
{
- /* Empty, needed for G_DEFINE_TYPE macro */
+ /* Empty, needed for G_DEFINE_TYPE macro */
}
diff --git a/src/ephy-link-action.c b/src/ephy-link-action.c
index 9c48ad7..980e1b1 100644
--- a/src/ephy-link-action.c
+++ b/src/ephy-link-action.c
@@ -28,116 +28,106 @@
#include <gtk/gtk.h>
G_DEFINE_TYPE_WITH_CODE (EphyLinkAction, ephy_link_action, EPHY_TYPE_WINDOW_ACTION,
- G_IMPLEMENT_INTERFACE (EPHY_TYPE_LINK,
- NULL))
+ G_IMPLEMENT_INTERFACE (EPHY_TYPE_LINK,
+ NULL))
#define EPHY_LINK_ACTION_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_LINK_ACTION,
EphyLinkActionPrivate))
-struct _EphyLinkActionPrivate
-{
- guint button;
+struct _EphyLinkActionPrivate {
+ guint button;
};
static gboolean
-proxy_button_press_event_cb (GtkButton *button,
- GdkEventButton *event,
- EphyLinkAction *action)
+proxy_button_press_event_cb (GtkButton *button,
+ GdkEventButton *event,
+ EphyLinkAction *action)
{
- action->priv->button = event->button;
+ action->priv->button = event->button;
- return FALSE;
+ return FALSE;
}
static GtkWidget *
get_event_widget (GtkWidget *proxy)
{
- GtkWidget *widget;
-
- /*
- * Finding the interesting widget requires internal knowledge of
- * the widgets in question. This can't be helped, but by keeping
- * the sneaky code in one place, it can easily be updated.
- */
- if (GTK_IS_MENU_ITEM (proxy))
- {
- /* Menu items already forward middle clicks */
- widget = NULL;
- }
- else if (GTK_IS_TOOL_BUTTON (proxy))
- {
- /* The tool button's button is the direct child */
- widget = gtk_bin_get_child (GTK_BIN (proxy));
- }
- else if (GTK_IS_BUTTON (proxy))
- {
- widget = proxy;
- }
- else
- {
- /* Don't touch anything we don't know about */
- widget = NULL;
- }
-
- return widget;
+ GtkWidget *widget;
+
+ /*
+ * Finding the interesting widget requires internal knowledge of
+ * the widgets in question. This can't be helped, but by keeping
+ * the sneaky code in one place, it can easily be updated.
+ */
+ if (GTK_IS_MENU_ITEM (proxy)) {
+ /* Menu items already forward middle clicks */
+ widget = NULL;
+ } else if (GTK_IS_TOOL_BUTTON (proxy)) {
+ /* The tool button's button is the direct child */
+ widget = gtk_bin_get_child (GTK_BIN (proxy));
+ } else if (GTK_IS_BUTTON (proxy)) {
+ widget = proxy;
+ } else {
+ /* Don't touch anything we don't know about */
+ widget = NULL;
+ }
+
+ return widget;
}
static void
ephy_link_action_connect_proxy (GtkAction *action, GtkWidget *proxy)
{
- GtkWidget *widget;
+ GtkWidget *widget;
- LOG ("Connect link action proxy");
+ LOG ("Connect link action proxy");
- widget = get_event_widget (proxy);
- if (widget)
- {
- g_signal_connect (widget, "button-press-event",
- G_CALLBACK (proxy_button_press_event_cb),
- action);
- }
+ widget = get_event_widget (proxy);
+ if (widget) {
+ g_signal_connect (widget, "button-press-event",
+ G_CALLBACK (proxy_button_press_event_cb),
+ action);
+ }
- GTK_ACTION_CLASS (ephy_link_action_parent_class)->connect_proxy (action, proxy);
+ GTK_ACTION_CLASS (ephy_link_action_parent_class)->connect_proxy (action, proxy);
}
static void
ephy_link_action_disconnect_proxy (GtkAction *action, GtkWidget *proxy)
{
- GtkWidget *widget;
+ GtkWidget *widget;
- LOG ("Disconnect link action proxy");
+ LOG ("Disconnect link action proxy");
- widget = get_event_widget (proxy);
- if (widget)
- {
- g_signal_handlers_disconnect_by_func (widget,
- G_CALLBACK (proxy_button_press_event_cb),
- action);
- }
+ widget = get_event_widget (proxy);
+ if (widget) {
+ g_signal_handlers_disconnect_by_func (widget,
+ G_CALLBACK (proxy_button_press_event_cb),
+ action);
+ }
- GTK_ACTION_CLASS (ephy_link_action_parent_class)->disconnect_proxy (action, proxy);
+ GTK_ACTION_CLASS (ephy_link_action_parent_class)->disconnect_proxy (action, proxy);
}
static void
ephy_link_action_init (EphyLinkAction *action)
{
- action->priv = EPHY_LINK_ACTION_GET_PRIVATE (action);
+ action->priv = EPHY_LINK_ACTION_GET_PRIVATE (action);
}
static void
ephy_link_action_class_init (EphyLinkActionClass *class)
{
- GtkActionClass *action_class = GTK_ACTION_CLASS (class);
+ GtkActionClass *action_class = GTK_ACTION_CLASS (class);
- action_class->connect_proxy = ephy_link_action_connect_proxy;
- action_class->disconnect_proxy = ephy_link_action_disconnect_proxy;
+ action_class->connect_proxy = ephy_link_action_connect_proxy;
+ action_class->disconnect_proxy = ephy_link_action_disconnect_proxy;
- g_type_class_add_private (G_OBJECT_CLASS (class), sizeof (EphyLinkActionPrivate));
+ g_type_class_add_private (G_OBJECT_CLASS (class), sizeof (EphyLinkActionPrivate));
}
/**
* ephy_link_action_get_button:
* @action: an #EphyLinkAction
- *
+ *
* This method stores the mouse button number that last activated, or
* is activating, the @action. This is useful because #GtkButton's
* cannot be clicked with a middle click by default, so inside
@@ -146,37 +136,37 @@ ephy_link_action_class_init (EphyLinkActionClass *class)
* EphyGUI methods like ephy_gui_is_middle_click not work here, so we
* need to ask the @action directly about the button that activated
* it.
- *
+ *
* Returns: the button number that last activated (or is activating) the @action
**/
guint
ephy_link_action_get_button (EphyLinkAction *action)
{
- g_return_val_if_fail (EPHY_IS_LINK_ACTION (action), 0);
+ g_return_val_if_fail (EPHY_IS_LINK_ACTION (action), 0);
- return action->priv->button;
+ return action->priv->button;
}
G_DEFINE_TYPE_WITH_CODE (EphyLinkActionGroup, ephy_link_action_group, GTK_TYPE_ACTION_GROUP,
- G_IMPLEMENT_INTERFACE (EPHY_TYPE_LINK,
- NULL))
+ G_IMPLEMENT_INTERFACE (EPHY_TYPE_LINK,
+ NULL))
static void
ephy_link_action_group_class_init (EphyLinkActionGroupClass *klass)
{
- /* Empty, needed for G_DEFINE_TYPE macro */
+ /* Empty, needed for G_DEFINE_TYPE macro */
}
static void
ephy_link_action_group_init (EphyLinkActionGroup *action_group)
{
- /* Empty, needed for G_DEFINE_TYPE macro */
+ /* Empty, needed for G_DEFINE_TYPE macro */
}
EphyLinkActionGroup *
-ephy_link_action_group_new (const char * name)
+ephy_link_action_group_new (const char *name)
{
- return g_object_new (EPHY_TYPE_LINK_ACTION_GROUP,
- "name", name,
- NULL);
+ return g_object_new (EPHY_TYPE_LINK_ACTION_GROUP,
+ "name", name,
+ NULL);
}
diff --git a/src/ephy-link.c b/src/ephy-link.c
index aa0fd05..262bdb4 100644
--- a/src/ephy-link.c
+++ b/src/ephy-link.c
@@ -25,10 +25,9 @@
#include "ephy-gui.h"
#include "ephy-debug.h"
-enum
-{
- OPEN_LINK,
- LAST_SIGNAL
+enum {
+ OPEN_LINK,
+ LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
@@ -38,30 +37,30 @@ G_DEFINE_INTERFACE (EphyLink, ephy_link, G_TYPE_OBJECT)
static void
ephy_link_default_init (EphyLinkInterface *iface)
{
- /**
- * EphyLink::open-link:
- * @address: the address of @link
- * @embed: #EphyEmbed associated with @link
- * @flags: flags for @link
- *
- * The ::open-link signal is emitted when @link is requested to
- * open it's associated @address.
- *
- * Returns: (transfer none): the #EphyEmbed where @address has
- * been handled.
- **/
- signals[OPEN_LINK] = g_signal_new
- ("open-link",
- EPHY_TYPE_LINK,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EphyLinkInterface, open_link),
- ephy_signal_accumulator_object, ephy_embed_get_type,
- NULL,
- GTK_TYPE_WIDGET /* Can't use an interface type here */,
- 3,
- G_TYPE_STRING,
- GTK_TYPE_WIDGET /* Can't use an interface type here */,
- EPHY_TYPE_LINK_FLAGS);
+ /**
+ * EphyLink::open-link:
+ * @address: the address of @link
+ * @embed: #EphyEmbed associated with @link
+ * @flags: flags for @link
+ *
+ * The ::open-link signal is emitted when @link is requested to
+ * open it's associated @address.
+ *
+ * Returns: (transfer none): the #EphyEmbed where @address has
+ * been handled.
+ **/
+ signals[OPEN_LINK] = g_signal_new
+ ("open-link",
+ EPHY_TYPE_LINK,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EphyLinkInterface, open_link),
+ ephy_signal_accumulator_object, ephy_embed_get_type,
+ NULL,
+ GTK_TYPE_WIDGET /* Can't use an interface type here */,
+ 3,
+ G_TYPE_STRING,
+ GTK_TYPE_WIDGET /* Can't use an interface type here */,
+ EPHY_TYPE_LINK_FLAGS);
}
/**
@@ -76,53 +75,44 @@ ephy_link_default_init (EphyLinkInterface *iface)
* Returns: (transfer none): the #EphyEmbed where @link opened.
*/
EphyEmbed *
-ephy_link_open (EphyLink *link,
- const char *address,
- EphyEmbed *embed,
- EphyLinkFlags flags)
+ephy_link_open (EphyLink *link,
+ const char *address,
+ EphyEmbed *embed,
+ EphyLinkFlags flags)
{
- EphyEmbed *new_embed = NULL;
+ EphyEmbed *new_embed = NULL;
- LOG ("ephy_link_open address \"%s\" parent-embed %p flags %u", address, embed, flags);
+ LOG ("ephy_link_open address \"%s\" parent-embed %p flags %u", address, embed, flags);
- g_signal_emit (link, signals[OPEN_LINK], 0,
- address, embed, flags,
- &new_embed);
+ g_signal_emit (link, signals[OPEN_LINK], 0,
+ address, embed, flags,
+ &new_embed);
- return new_embed;
+ return new_embed;
}
EphyLinkFlags
ephy_link_flags_from_current_event (void)
{
- GdkEventType type = GDK_NOTHING;
- guint state = 0, button = (guint) -1;
- EphyLinkFlags flags = 0;
+ GdkEventType type = GDK_NOTHING;
+ guint state = 0, button = (guint) - 1;
+ EphyLinkFlags flags = 0;
- ephy_gui_get_current_event (&type, &state, &button);
+ ephy_gui_get_current_event (&type, &state, &button);
- if (button == 2 && (type == GDK_BUTTON_PRESS || type == GDK_BUTTON_RELEASE))
- {
- if (state == GDK_SHIFT_MASK)
- {
- flags = EPHY_LINK_NEW_WINDOW;
- }
- else if (state == 0 || state == GDK_CONTROL_MASK)
- {
- flags = EPHY_LINK_NEW_TAB | EPHY_LINK_NEW_TAB_APPEND_AFTER;
- }
- }
- else
- {
- if (state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK))
- {
- flags = EPHY_LINK_NEW_WINDOW;
- }
- else if (state == GDK_CONTROL_MASK)
- {
- flags = EPHY_LINK_NEW_TAB | EPHY_LINK_NEW_TAB_APPEND_AFTER;
- }
- }
+ if (button == 2 && (type == GDK_BUTTON_PRESS || type == GDK_BUTTON_RELEASE)) {
+ if (state == GDK_SHIFT_MASK) {
+ flags = EPHY_LINK_NEW_WINDOW;
+ } else if (state == 0 || state == GDK_CONTROL_MASK) {
+ flags = EPHY_LINK_NEW_TAB | EPHY_LINK_NEW_TAB_APPEND_AFTER;
+ }
+ } else {
+ if (state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) {
+ flags = EPHY_LINK_NEW_WINDOW;
+ } else if (state == GDK_CONTROL_MASK) {
+ flags = EPHY_LINK_NEW_TAB | EPHY_LINK_NEW_TAB_APPEND_AFTER;
+ }
+ }
- return flags;
+ return flags;
}
diff --git a/src/ephy-location-controller.c b/src/ephy-location-controller.c
index 44b9fbc..cef9802 100644
--- a/src/ephy-location-controller.c
+++ b/src/ephy-location-controller.c
@@ -42,783 +42,760 @@
* #EphyLocationController handles navigation together with #EphyLocationEntry
*/
-struct _EphyLocationController
-{
- GObject parent_instance;
-
- EphyWindow *window;
- EphyLocationEntry *location_entry;
- EphyTitleBox *title_box;
- GList *actions;
- char *address;
- EphyNode *smart_bmks;
- EphyBookmarks *bookmarks;
- GdkPixbuf *icon;
- guint editable : 1;
- guint show_icon : 1;
- gboolean sync_address_is_blocked;
+struct _EphyLocationController {
+ GObject parent_instance;
+
+ EphyWindow *window;
+ EphyLocationEntry *location_entry;
+ EphyTitleBox *title_box;
+ GList *actions;
+ char *address;
+ EphyNode *smart_bmks;
+ EphyBookmarks *bookmarks;
+ GdkPixbuf *icon;
+ guint editable : 1;
+ guint show_icon : 1;
+ gboolean sync_address_is_blocked;
};
-static void ephy_location_controller_finalize (GObject *object);
-static void user_changed_cb (GtkWidget *widget,
- EphyLocationController *controller);
-static void sync_address (EphyLocationController *controller,
- GParamSpec *pspec,
- GtkWidget *widget);
-
-enum
-{
- PROP_0,
- PROP_ADDRESS,
- PROP_EDITABLE,
- PROP_ICON,
- PROP_SHOW_ICON,
- PROP_WINDOW,
- PROP_LOCATION_ENTRY,
- PROP_TITLE_BOX,
- LAST_PROP
+static void ephy_location_controller_finalize (GObject *object);
+static void user_changed_cb (GtkWidget *widget,
+ EphyLocationController *controller);
+static void sync_address (EphyLocationController *controller,
+ GParamSpec *pspec,
+ GtkWidget *widget);
+
+enum {
+ PROP_0,
+ PROP_ADDRESS,
+ PROP_EDITABLE,
+ PROP_ICON,
+ PROP_SHOW_ICON,
+ PROP_WINDOW,
+ PROP_LOCATION_ENTRY,
+ PROP_TITLE_BOX,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
-enum
-{
- LOCK_CLICKED,
- LAST_SIGNAL
+enum {
+ LOCK_CLICKED,
+ LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
G_DEFINE_TYPE_WITH_CODE (EphyLocationController, ephy_location_controller, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (EPHY_TYPE_LINK,
- NULL))
+ G_IMPLEMENT_INTERFACE (EPHY_TYPE_LINK,
+ NULL))
static gboolean
match_func (GtkEntryCompletion *completion,
- const char *key,
- GtkTreeIter *iter,
- gpointer data)
+ const char *key,
+ GtkTreeIter *iter,
+ gpointer data)
{
- /* We want every row in the model to show up. */
- return TRUE;
+ /* We want every row in the model to show up. */
+ return TRUE;
}
static void
-action_activated_cb (GtkEntryCompletion *completion,
- gint index,
- EphyLocationController *controller)
-{
- GtkWidget *entry;
- char *content;
-
- entry = gtk_entry_completion_get_entry (completion);
- content = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
- if (content)
- {
- EphyNode *node;
- const char *smart_url;
- char *url;
-
- node = (EphyNode *)g_list_nth_data (controller->actions, index);
- smart_url = ephy_node_get_property_string
- (node, EPHY_NODE_BMK_PROP_LOCATION);
- g_return_if_fail (smart_url != NULL);
-
- url = ephy_bookmarks_resolve_address
- (controller->bookmarks, smart_url, content);
- g_free (content);
- if (url == NULL) return;
-
- ephy_link_open (EPHY_LINK (controller), url, NULL,
- ephy_link_flags_from_current_event () | EPHY_LINK_TYPED);
-
- g_free (url);
- }
+action_activated_cb (GtkEntryCompletion *completion,
+ gint index,
+ EphyLocationController *controller)
+{
+ GtkWidget *entry;
+ char *content;
+
+ entry = gtk_entry_completion_get_entry (completion);
+ content = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
+ if (content) {
+ EphyNode *node;
+ const char *smart_url;
+ char *url;
+
+ node = (EphyNode *)g_list_nth_data (controller->actions, index);
+ smart_url = ephy_node_get_property_string
+ (node, EPHY_NODE_BMK_PROP_LOCATION);
+ g_return_if_fail (smart_url != NULL);
+
+ url = ephy_bookmarks_resolve_address
+ (controller->bookmarks, smart_url, content);
+ g_free (content);
+ if (url == NULL) return;
+
+ ephy_link_open (EPHY_LINK (controller), url, NULL,
+ ephy_link_flags_from_current_event () | EPHY_LINK_TYPED);
+
+ g_free (url);
+ }
}
static void
entry_drag_data_received_cb (GtkWidget *widget,
- GdkDragContext *context,
- gint x, gint y,
- GtkSelectionData *selection_data,
- guint info,
- guint time,
- EphyLocationController *controller)
-{
- GtkEntry *entry;
- GdkAtom url_type;
- GdkAtom text_type;
- const guchar *sel_data;
-
- sel_data = gtk_selection_data_get_data (selection_data);
-
- url_type = gdk_atom_intern (EPHY_DND_URL_TYPE, FALSE);
- text_type = gdk_atom_intern (EPHY_DND_TEXT_TYPE, FALSE);
-
- if (gtk_selection_data_get_length (selection_data) <= 0 || sel_data == NULL)
- return;
-
- entry = GTK_ENTRY (widget);
-
- if (gtk_selection_data_get_target (selection_data) == url_type)
- {
- char **uris;
-
- uris = g_uri_list_extract_uris ((char *)sel_data);
- if (uris != NULL && uris[0] != NULL && *uris[0] != '\0')
- {
- gtk_entry_set_text (entry, (char *)uris[0]);
- ephy_link_open (EPHY_LINK (controller),
- uris[0],
- NULL,
- ephy_link_flags_from_current_event ());
- }
- g_strfreev (uris);
- } else if (gtk_selection_data_get_target (selection_data) == text_type) {
- char *address;
-
- gtk_entry_set_text (entry, (const gchar *)sel_data);
- address = ephy_embed_utils_normalize_or_autosearch_address ((const gchar *)sel_data);
- ephy_link_open (EPHY_LINK (controller),
- address,
- NULL,
- ephy_link_flags_from_current_event ());
- g_free (address);
- }
+ GdkDragContext *context,
+ gint x, gint y,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint time,
+ EphyLocationController *controller)
+{
+ GtkEntry *entry;
+ GdkAtom url_type;
+ GdkAtom text_type;
+ const guchar *sel_data;
+
+ sel_data = gtk_selection_data_get_data (selection_data);
+
+ url_type = gdk_atom_intern (EPHY_DND_URL_TYPE, FALSE);
+ text_type = gdk_atom_intern (EPHY_DND_TEXT_TYPE, FALSE);
+
+ if (gtk_selection_data_get_length (selection_data) <= 0 || sel_data == NULL)
+ return;
+
+ entry = GTK_ENTRY (widget);
+
+ if (gtk_selection_data_get_target (selection_data) == url_type) {
+ char **uris;
+
+ uris = g_uri_list_extract_uris ((char *)sel_data);
+ if (uris != NULL && uris[0] != NULL && *uris[0] != '\0') {
+ gtk_entry_set_text (entry, (char *)uris[0]);
+ ephy_link_open (EPHY_LINK (controller),
+ uris[0],
+ NULL,
+ ephy_link_flags_from_current_event ());
+ }
+ g_strfreev (uris);
+ } else if (gtk_selection_data_get_target (selection_data) == text_type) {
+ char *address;
+
+ gtk_entry_set_text (entry, (const gchar *)sel_data);
+ address = ephy_embed_utils_normalize_or_autosearch_address ((const gchar *)sel_data);
+ ephy_link_open (EPHY_LINK (controller),
+ address,
+ NULL,
+ ephy_link_flags_from_current_event ());
+ g_free (address);
+ }
}
static void
-entry_activate_cb (GtkEntry *entry,
- EphyLocationController *controller)
+entry_activate_cb (GtkEntry *entry,
+ EphyLocationController *controller)
{
- EphyBookmarks *bookmarks;
- const char *content;
- char *address;
- char *effective_address;
+ EphyBookmarks *bookmarks;
+ const char *content;
+ char *address;
+ char *effective_address;
- if (controller->sync_address_is_blocked)
- {
- controller->sync_address_is_blocked = FALSE;
- g_signal_handlers_unblock_by_func (controller, G_CALLBACK (sync_address), entry);
- }
+ if (controller->sync_address_is_blocked) {
+ controller->sync_address_is_blocked = FALSE;
+ g_signal_handlers_unblock_by_func (controller, G_CALLBACK (sync_address), entry);
+ }
- content = gtk_entry_get_text (entry);
- if (content == NULL || content[0] == '\0') return;
+ content = gtk_entry_get_text (entry);
+ if (content == NULL || content[0] == '\0') return;
- bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
+ bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
- address = ephy_bookmarks_resolve_address (bookmarks, content, NULL);
- g_return_if_fail (address != NULL);
+ address = ephy_bookmarks_resolve_address (bookmarks, content, NULL);
+ g_return_if_fail (address != NULL);
- effective_address = ephy_embed_utils_normalize_or_autosearch_address (g_strstrip (address));
- g_free (address);
+ effective_address = ephy_embed_utils_normalize_or_autosearch_address (g_strstrip (address));
+ g_free (address);
#if 0
- if (!ephy_embed_utils_address_has_web_scheme (effective_address))
- {
- /* After normalization there are still some cases that are
- * impossible to tell apart. One example is <URI>:<PORT> and <NON
- * WEB SCHEME>:<DATA>. To fix this, let's do a HEAD request to the
- * effective URI prefxed with http://; if we get OK Status the URI
- * exists, and we'll go ahead, otherwise we'll try to launch a
- * proper handler through gtk_show_uri. We only do this in
- * ephy_web_view_load_url, since this case is only relevant for URIs
- * typed in the location entry, which uses this method to do the
- * load. */
- /* TODO: however, this is not really possible, because normalize_or_autosearch_address
- * prepends http:// for anything that doesn't look like a URL.
- */
- }
+ if (!ephy_embed_utils_address_has_web_scheme (effective_address)) {
+ /* After normalization there are still some cases that are
+ * impossible to tell apart. One example is <URI>:<PORT> and <NON
+ * WEB SCHEME>:<DATA>. To fix this, let's do a HEAD request to the
+ * effective URI prefxed with http://; if we get OK Status the URI
+ * exists, and we'll go ahead, otherwise we'll try to launch a
+ * proper handler through gtk_show_uri. We only do this in
+ * ephy_web_view_load_url, since this case is only relevant for URIs
+ * typed in the location entry, which uses this method to do the
+ * load. */
+ /* TODO: however, this is not really possible, because normalize_or_autosearch_address
+ * prepends http:// for anything that doesn't look like a URL.
+ */
+ }
#endif
- ephy_link_open (EPHY_LINK (controller), effective_address, NULL,
- ephy_link_flags_from_current_event () | EPHY_LINK_TYPED);
+ ephy_link_open (EPHY_LINK (controller), effective_address, NULL,
+ ephy_link_flags_from_current_event () | EPHY_LINK_TYPED);
- g_free (effective_address);
+ g_free (effective_address);
}
static void
update_done_cb (EphyHistoryService *service,
- gboolean success,
- gpointer result_data,
- gpointer user_data)
-{
- /* FIXME: this hack is needed for the completion entry popup
- * to resize smoothly. See:
- * https://bugzilla.gnome.org/show_bug.cgi?id=671074 */
- gtk_entry_completion_complete (GTK_ENTRY_COMPLETION (user_data));
+ gboolean success,
+ gpointer result_data,
+ gpointer user_data)
+{
+ /* FIXME: this hack is needed for the completion entry popup
+ * to resize smoothly. See:
+ * https://bugzilla.gnome.org/show_bug.cgi?id=671074 */
+ gtk_entry_completion_complete (GTK_ENTRY_COMPLETION (user_data));
}
static void
user_changed_cb (GtkWidget *widget, EphyLocationController *controller)
{
- const char *address;
- GtkTreeModel *model;
- GtkEntryCompletion *completion;
+ const char *address;
+ GtkTreeModel *model;
+ GtkEntryCompletion *completion;
- address = ephy_location_entry_get_location (EPHY_LOCATION_ENTRY (widget));
+ address = ephy_location_entry_get_location (EPHY_LOCATION_ENTRY (widget));
- LOG ("user_changed_cb, address %s", address);
+ LOG ("user_changed_cb, address %s", address);
- completion = gtk_entry_get_completion (GTK_ENTRY (widget));
- model = gtk_entry_completion_get_model (completion);
+ completion = gtk_entry_get_completion (GTK_ENTRY (widget));
+ model = gtk_entry_completion_get_model (completion);
- ephy_completion_model_update_for_string (EPHY_COMPLETION_MODEL (model), address,
- update_done_cb, completion);
+ ephy_completion_model_update_for_string (EPHY_COMPLETION_MODEL (model), address,
+ update_done_cb, completion);
}
static void
-lock_clicked_cb (GtkWidget *widget,
- EphyLocationController *controller)
+lock_clicked_cb (GtkWidget *widget,
+ EphyLocationController *controller)
{
- g_signal_emit (controller, signals[LOCK_CLICKED], 0);
+ g_signal_emit (controller, signals[LOCK_CLICKED], 0);
}
static void
sync_address (EphyLocationController *controller,
- GParamSpec *pspec,
- GtkWidget *widget)
+ GParamSpec *pspec,
+ GtkWidget *widget)
{
- EphyLocationEntry *lentry = EPHY_LOCATION_ENTRY (widget);
+ EphyLocationEntry *lentry = EPHY_LOCATION_ENTRY (widget);
- LOG ("sync_address %s", controller->address);
+ LOG ("sync_address %s", controller->address);
- g_signal_handlers_block_by_func (widget, G_CALLBACK (user_changed_cb), controller);
- ephy_location_entry_set_location (lentry, controller->address);
- ephy_title_box_set_address (controller->title_box, controller->address);
- g_signal_handlers_unblock_by_func (widget, G_CALLBACK (user_changed_cb), controller);
+ g_signal_handlers_block_by_func (widget, G_CALLBACK (user_changed_cb), controller);
+ ephy_location_entry_set_location (lentry, controller->address);
+ ephy_title_box_set_address (controller->title_box, controller->address);
+ g_signal_handlers_unblock_by_func (widget, G_CALLBACK (user_changed_cb), controller);
}
static void
title_box_mode_changed_cb (EphyTitleBox *title_box,
- GParamSpec *psec,
- gpointer user_data)
+ GParamSpec *psec,
+ gpointer user_data)
{
- EphyLocationController *controller = EPHY_LOCATION_CONTROLLER (user_data);
+ EphyLocationController *controller = EPHY_LOCATION_CONTROLLER (user_data);
- sync_address (controller, NULL, GTK_WIDGET (controller->location_entry));
+ sync_address (controller, NULL, GTK_WIDGET (controller->location_entry));
}
static char *
-get_location_cb (EphyLocationEntry *entry,
- EphyLocationController *controller)
+get_location_cb (EphyLocationEntry *entry,
+ EphyLocationController *controller)
{
- EphyEmbed *embed;
+ EphyEmbed *embed;
- embed = ephy_embed_container_get_active_child
- (EPHY_EMBED_CONTAINER (controller->window));
+ embed = ephy_embed_container_get_active_child
+ (EPHY_EMBED_CONTAINER (controller->window));
- return g_strdup (ephy_web_view_get_address (ephy_embed_get_web_view (embed)));
+ return g_strdup (ephy_web_view_get_address (ephy_embed_get_web_view (embed)));
}
static char *
-get_title_cb (EphyLocationEntry *entry,
- EphyLocationController *controller)
+get_title_cb (EphyLocationEntry *entry,
+ EphyLocationController *controller)
{
- EphyEmbed *embed;
+ EphyEmbed *embed;
- embed = ephy_embed_container_get_active_child
- (EPHY_EMBED_CONTAINER (controller->window));
+ embed = ephy_embed_container_get_active_child
+ (EPHY_EMBED_CONTAINER (controller->window));
- return g_strdup (ephy_embed_get_title (embed));
+ return g_strdup (ephy_embed_get_title (embed));
}
static void
remove_completion_actions (EphyLocationController *controller,
- EphyLocationEntry *lentry)
+ EphyLocationEntry *lentry)
{
- GtkEntryCompletion *completion;
- GList *l;
+ GtkEntryCompletion *completion;
+ GList *l;
- completion = gtk_entry_get_completion (GTK_ENTRY (lentry));
+ completion = gtk_entry_get_completion (GTK_ENTRY (lentry));
- for (l = controller->actions; l != NULL; l = l->next)
- {
- gtk_entry_completion_delete_action (completion, 0);
- }
+ for (l = controller->actions; l != NULL; l = l->next) {
+ gtk_entry_completion_delete_action (completion, 0);
+ }
- g_signal_handlers_disconnect_by_func
- (completion, G_CALLBACK (action_activated_cb), controller);
+ g_signal_handlers_disconnect_by_func
+ (completion, G_CALLBACK (action_activated_cb), controller);
}
static void
add_completion_actions (EphyLocationController *controller,
- EphyLocationEntry *lentry)
+ EphyLocationEntry *lentry)
{
- GtkEntryCompletion *completion;
- GList *l;
+ GtkEntryCompletion *completion;
+ GList *l;
- completion = gtk_entry_get_completion (GTK_ENTRY (lentry));
+ completion = gtk_entry_get_completion (GTK_ENTRY (lentry));
- for (l = controller->actions; l != NULL; l = l->next)
- {
- EphyNode *bmk = l->data;
- const char *title;
- int index;
+ for (l = controller->actions; l != NULL; l = l->next) {
+ EphyNode *bmk = l->data;
+ const char *title;
+ int index;
- index = g_list_position (controller->actions, l);
- title = ephy_node_get_property_string
- (bmk, EPHY_NODE_BMK_PROP_TITLE);
- gtk_entry_completion_insert_action_text (completion, index, (char*)title);
- }
+ index = g_list_position (controller->actions, l);
+ title = ephy_node_get_property_string
+ (bmk, EPHY_NODE_BMK_PROP_TITLE);
+ gtk_entry_completion_insert_action_text (completion, index, (char *)title);
+ }
- g_signal_connect (completion, "action_activated",
- G_CALLBACK (action_activated_cb), controller);
+ g_signal_connect (completion, "action_activated",
+ G_CALLBACK (action_activated_cb), controller);
}
static gboolean
-focus_in_event_cb (GtkWidget *entry,
- GdkEventFocus *event,
- EphyLocationController *controller)
+focus_in_event_cb (GtkWidget *entry,
+ GdkEventFocus *event,
+ EphyLocationController *controller)
{
- if (!controller->sync_address_is_blocked)
- {
- controller->sync_address_is_blocked = TRUE;
- g_signal_handlers_block_by_func (controller, G_CALLBACK (sync_address), entry);
- }
+ if (!controller->sync_address_is_blocked) {
+ controller->sync_address_is_blocked = TRUE;
+ g_signal_handlers_block_by_func (controller, G_CALLBACK (sync_address), entry);
+ }
- return FALSE;
+ return FALSE;
}
static gboolean
-focus_out_event_cb (GtkWidget *entry,
- GdkEventFocus *event,
- EphyLocationController *controller)
+focus_out_event_cb (GtkWidget *entry,
+ GdkEventFocus *event,
+ EphyLocationController *controller)
{
- if (controller->sync_address_is_blocked)
- {
- controller->sync_address_is_blocked = FALSE;
- g_signal_handlers_unblock_by_func (controller, G_CALLBACK (sync_address), entry);
- }
+ if (controller->sync_address_is_blocked) {
+ controller->sync_address_is_blocked = FALSE;
+ g_signal_handlers_unblock_by_func (controller, G_CALLBACK (sync_address), entry);
+ }
- return FALSE;
+ return FALSE;
}
static void
-switch_page_cb (GtkNotebook *notebook,
- GtkWidget *page,
- guint page_num,
- EphyLocationController *controller)
-{
- if (controller->sync_address_is_blocked == TRUE)
- {
- controller->sync_address_is_blocked = FALSE;
- g_signal_handlers_unblock_by_func (controller, G_CALLBACK (sync_address),
controller->location_entry);
- }
+switch_page_cb (GtkNotebook *notebook,
+ GtkWidget *page,
+ guint page_num,
+ EphyLocationController *controller)
+{
+ if (controller->sync_address_is_blocked == TRUE) {
+ controller->sync_address_is_blocked = FALSE;
+ g_signal_handlers_unblock_by_func (controller, G_CALLBACK (sync_address), controller->location_entry);
+ }
}
static void
ephy_location_controller_constructed (GObject *object)
{
- EphyLocationController *controller = EPHY_LOCATION_CONTROLLER (object);
- EphyHistoryService *history_service;
- EphyBookmarks *bookmarks;
- EphyCompletionModel *model;
- GtkWidget *notebook, *widget;
-
- G_OBJECT_CLASS (ephy_location_controller_parent_class)->constructed (object);
-
- notebook = ephy_window_get_notebook (controller->window);
- widget = GTK_WIDGET (controller->location_entry);
-
- g_signal_connect (notebook, "switch-page",
- G_CALLBACK (switch_page_cb), controller);
-
- history_service = EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service
(ephy_embed_shell_get_default ()));
- bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
- model = ephy_completion_model_new (history_service, bookmarks);
- ephy_location_entry_set_completion (controller->location_entry,
- GTK_TREE_MODEL (model),
- EPHY_COMPLETION_TEXT_COL,
- EPHY_COMPLETION_ACTION_COL,
- EPHY_COMPLETION_KEYWORDS_COL,
- EPHY_COMPLETION_RELEVANCE_COL,
- EPHY_COMPLETION_URL_COL,
- EPHY_COMPLETION_EXTRA_COL,
- EPHY_COMPLETION_FAVICON_COL);
- g_object_unref (model);
-
- ephy_location_entry_set_match_func (controller->location_entry,
- match_func,
- controller->location_entry,
- NULL);
-
- add_completion_actions (controller, controller->location_entry);
-
- g_signal_connect_object (controller->title_box, "notify::mode",
- G_CALLBACK (title_box_mode_changed_cb), controller, 0);
-
- sync_address (controller, NULL, widget);
- g_signal_connect_object (controller, "notify::address",
- G_CALLBACK (sync_address), widget, 0);
- g_object_bind_property (controller, "editable",
- controller->location_entry, "editable",
- G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (controller, "icon",
- controller->location_entry, "favicon",
- G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (controller, "show-icon",
- controller->location_entry, "show-favicon",
- G_BINDING_SYNC_CREATE);
-
- g_signal_connect_object (widget, "drag-data-received",
- G_CALLBACK (entry_drag_data_received_cb),
- controller, 0);
- g_signal_connect_object (widget, "activate",
- G_CALLBACK (entry_activate_cb),
- controller, 0);
- g_signal_connect_object (widget, "user-changed",
- G_CALLBACK (user_changed_cb), controller, 0);
- g_signal_connect_object (widget, "lock-clicked",
- G_CALLBACK (lock_clicked_cb), controller, 0);
- g_signal_connect_object (widget, "get-location",
- G_CALLBACK (get_location_cb), controller, 0);
- g_signal_connect_object (widget, "get-title",
- G_CALLBACK (get_title_cb), controller, 0);
- g_signal_connect_object (widget, "focus-in-event",
- G_CALLBACK (focus_in_event_cb), controller, 0);
- g_signal_connect_object (widget, "focus-out-event",
- G_CALLBACK (focus_out_event_cb), controller, 0);
+ EphyLocationController *controller = EPHY_LOCATION_CONTROLLER (object);
+ EphyHistoryService *history_service;
+ EphyBookmarks *bookmarks;
+ EphyCompletionModel *model;
+ GtkWidget *notebook, *widget;
+
+ G_OBJECT_CLASS (ephy_location_controller_parent_class)->constructed (object);
+
+ notebook = ephy_window_get_notebook (controller->window);
+ widget = GTK_WIDGET (controller->location_entry);
+
+ g_signal_connect (notebook, "switch-page",
+ G_CALLBACK (switch_page_cb), controller);
+
+ history_service = EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service
(ephy_embed_shell_get_default ()));
+ bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
+ model = ephy_completion_model_new (history_service, bookmarks);
+ ephy_location_entry_set_completion (controller->location_entry,
+ GTK_TREE_MODEL (model),
+ EPHY_COMPLETION_TEXT_COL,
+ EPHY_COMPLETION_ACTION_COL,
+ EPHY_COMPLETION_KEYWORDS_COL,
+ EPHY_COMPLETION_RELEVANCE_COL,
+ EPHY_COMPLETION_URL_COL,
+ EPHY_COMPLETION_EXTRA_COL,
+ EPHY_COMPLETION_FAVICON_COL);
+ g_object_unref (model);
+
+ ephy_location_entry_set_match_func (controller->location_entry,
+ match_func,
+ controller->location_entry,
+ NULL);
+
+ add_completion_actions (controller, controller->location_entry);
+
+ g_signal_connect_object (controller->title_box, "notify::mode",
+ G_CALLBACK (title_box_mode_changed_cb), controller, 0);
+
+ sync_address (controller, NULL, widget);
+ g_signal_connect_object (controller, "notify::address",
+ G_CALLBACK (sync_address), widget, 0);
+ g_object_bind_property (controller, "editable",
+ controller->location_entry, "editable",
+ G_BINDING_SYNC_CREATE);
+
+ g_object_bind_property (controller, "icon",
+ controller->location_entry, "favicon",
+ G_BINDING_SYNC_CREATE);
+
+ g_object_bind_property (controller, "show-icon",
+ controller->location_entry, "show-favicon",
+ G_BINDING_SYNC_CREATE);
+
+ g_signal_connect_object (widget, "drag-data-received",
+ G_CALLBACK (entry_drag_data_received_cb),
+ controller, 0);
+ g_signal_connect_object (widget, "activate",
+ G_CALLBACK (entry_activate_cb),
+ controller, 0);
+ g_signal_connect_object (widget, "user-changed",
+ G_CALLBACK (user_changed_cb), controller, 0);
+ g_signal_connect_object (widget, "lock-clicked",
+ G_CALLBACK (lock_clicked_cb), controller, 0);
+ g_signal_connect_object (widget, "get-location",
+ G_CALLBACK (get_location_cb), controller, 0);
+ g_signal_connect_object (widget, "get-title",
+ G_CALLBACK (get_title_cb), controller, 0);
+ g_signal_connect_object (widget, "focus-in-event",
+ G_CALLBACK (focus_in_event_cb), controller, 0);
+ g_signal_connect_object (widget, "focus-out-event",
+ G_CALLBACK (focus_out_event_cb), controller, 0);
}
static void
-ephy_location_controller_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EphyLocationController *controller = EPHY_LOCATION_CONTROLLER (object);
-
- switch (prop_id)
- {
- case PROP_ADDRESS:
- ephy_location_controller_set_address (controller, g_value_get_string (value));
- break;
- case PROP_EDITABLE:
- controller->editable = g_value_get_boolean (value);
- break;
- case PROP_ICON:
- if (controller->icon != NULL)
- {
- g_object_unref (controller->icon);
- }
- controller->icon = GDK_PIXBUF (g_value_dup_object (value));
- break;
- case PROP_SHOW_ICON:
- controller->show_icon = g_value_get_boolean (value);
- break;
- case PROP_WINDOW:
- controller->window = EPHY_WINDOW (g_value_get_object (value));
- break;
- case PROP_LOCATION_ENTRY:
- controller->location_entry = EPHY_LOCATION_ENTRY (g_value_get_object (value));
- break;
- case PROP_TITLE_BOX:
- controller->title_box = EPHY_TITLE_BOX (g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- }
+ephy_location_controller_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EphyLocationController *controller = EPHY_LOCATION_CONTROLLER (object);
+
+ switch (prop_id) {
+ case PROP_ADDRESS:
+ ephy_location_controller_set_address (controller, g_value_get_string (value));
+ break;
+ case PROP_EDITABLE:
+ controller->editable = g_value_get_boolean (value);
+ break;
+ case PROP_ICON:
+ if (controller->icon != NULL) {
+ g_object_unref (controller->icon);
+ }
+ controller->icon = GDK_PIXBUF (g_value_dup_object (value));
+ break;
+ case PROP_SHOW_ICON:
+ controller->show_icon = g_value_get_boolean (value);
+ break;
+ case PROP_WINDOW:
+ controller->window = EPHY_WINDOW (g_value_get_object (value));
+ break;
+ case PROP_LOCATION_ENTRY:
+ controller->location_entry = EPHY_LOCATION_ENTRY (g_value_get_object (value));
+ break;
+ case PROP_TITLE_BOX:
+ controller->title_box = EPHY_TITLE_BOX (g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
-ephy_location_controller_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EphyLocationController *controller = EPHY_LOCATION_CONTROLLER (object);
-
- switch (prop_id)
- {
- case PROP_ADDRESS:
- g_value_set_string (value, ephy_location_controller_get_address (controller));
- break;
- case PROP_EDITABLE:
- g_value_set_boolean (value, controller->editable);
- break;
- case PROP_ICON:
- g_value_set_object (value, controller->icon);
- break;
- case PROP_SHOW_ICON:
- g_value_set_boolean (value, controller->show_icon);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- }
+ephy_location_controller_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EphyLocationController *controller = EPHY_LOCATION_CONTROLLER (object);
+
+ switch (prop_id) {
+ case PROP_ADDRESS:
+ g_value_set_string (value, ephy_location_controller_get_address (controller));
+ break;
+ case PROP_EDITABLE:
+ g_value_set_boolean (value, controller->editable);
+ break;
+ case PROP_ICON:
+ g_value_set_object (value, controller->icon);
+ break;
+ case PROP_SHOW_ICON:
+ g_value_set_boolean (value, controller->show_icon);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
ephy_location_controller_dispose (GObject *object)
{
- EphyLocationController *controller = EPHY_LOCATION_CONTROLLER (object);
- GtkWidget *notebook;
-
- notebook = ephy_window_get_notebook (controller->window);
-
- if (notebook == NULL ||
- controller->location_entry == NULL) {
- return;
- }
-
- g_signal_handlers_disconnect_matched (controller, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, controller->location_entry);
- g_signal_handlers_disconnect_matched (controller->location_entry, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, controller);
- g_signal_handlers_disconnect_matched (controller->title_box, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, controller);
- g_signal_handlers_disconnect_matched (notebook, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, controller);
- controller->location_entry = NULL;
-
- G_OBJECT_CLASS (ephy_location_controller_parent_class)->dispose (object);
+ EphyLocationController *controller = EPHY_LOCATION_CONTROLLER (object);
+ GtkWidget *notebook;
+
+ notebook = ephy_window_get_notebook (controller->window);
+
+ if (notebook == NULL ||
+ controller->location_entry == NULL) {
+ return;
+ }
+
+ g_signal_handlers_disconnect_matched (controller, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, controller->location_entry);
+ g_signal_handlers_disconnect_matched (controller->location_entry, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, controller);
+ g_signal_handlers_disconnect_matched (controller->title_box, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, controller);
+ g_signal_handlers_disconnect_matched (notebook, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, controller);
+ controller->location_entry = NULL;
+
+ G_OBJECT_CLASS (ephy_location_controller_parent_class)->dispose (object);
}
static void
ephy_location_controller_class_init (EphyLocationControllerClass *class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
-
- object_class->finalize = ephy_location_controller_finalize;
- object_class->dispose = ephy_location_controller_dispose;
- object_class->constructed = ephy_location_controller_constructed;
- object_class->get_property = ephy_location_controller_get_property;
- object_class->set_property = ephy_location_controller_set_property;
-
- /**
- * EphyLocationController::lock-clicked:
- * @controller: the object which received the signal.
- *
- * Emitted when the user clicks on the security icon of the internal
- * #EphyLocationEntry.
- */
- signals[LOCK_CLICKED] = g_signal_new (
- "lock-clicked",
- EPHY_TYPE_LOCATION_CONTROLLER,
- G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 0);
-
- /**
- * EphyLocationController:address:
- *
- * The address of the current location.
- */
- obj_properties[PROP_ADDRESS] =
- g_param_spec_string ("address",
- "Address",
- "The address of the current location",
- "",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- /**
- * EphyLocationController:editable:
- *
- * Whether the location bar entry can be edited.
- */
- obj_properties[PROP_EDITABLE] =
- g_param_spec_boolean ("editable",
- "Editable",
- "Whether the location bar entry can be edited",
- TRUE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- /**
- * EphyLocationController:icon:
- *
- * The icon corresponding to the current location.
- */
- obj_properties[PROP_ICON] =
- g_param_spec_object ("icon",
- "Icon",
- "The icon corresponding to the current location",
- GDK_TYPE_PIXBUF,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- /**
- * EphyLocationController:show-icon:
- *
- * If we should show the page icon.
- */
- obj_properties[PROP_SHOW_ICON] =
- g_param_spec_boolean ("show-icon",
- "Show Icon",
- "Whether to show the favicon",
- TRUE,
- G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- /**
- * EphyLocationController:window:
- *
- * The parent window.
- */
- obj_properties[PROP_WINDOW] =
- g_param_spec_object ("window",
- "Window",
- "The parent window",
- G_TYPE_OBJECT,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
-
- /**
- * EphyLocationController:location-entry:
- *
- * The controlled location entry.
- */
- obj_properties[PROP_LOCATION_ENTRY] =
- g_param_spec_object ("location-entry",
- "Location entry",
- "The controlled location entry",
- G_TYPE_OBJECT,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
-
- /**
- * EphyLocationController:title-box:
- *
- * The #EphyLocationController sets the address of this title box.
- */
- obj_properties[PROP_TITLE_BOX] =
- g_param_spec_object ("title-box",
- "Title box",
- "The title box whose address will be managed",
- G_TYPE_OBJECT,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
-
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+ object_class->finalize = ephy_location_controller_finalize;
+ object_class->dispose = ephy_location_controller_dispose;
+ object_class->constructed = ephy_location_controller_constructed;
+ object_class->get_property = ephy_location_controller_get_property;
+ object_class->set_property = ephy_location_controller_set_property;
+
+ /**
+ * EphyLocationController::lock-clicked:
+ * @controller: the object which received the signal.
+ *
+ * Emitted when the user clicks on the security icon of the internal
+ * #EphyLocationEntry.
+ */
+ signals[LOCK_CLICKED] = g_signal_new (
+ "lock-clicked",
+ EPHY_TYPE_LOCATION_CONTROLLER,
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 0);
+
+ /**
+ * EphyLocationController:address:
+ *
+ * The address of the current location.
+ */
+ obj_properties[PROP_ADDRESS] =
+ g_param_spec_string ("address",
+ "Address",
+ "The address of the current location",
+ "",
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ /**
+ * EphyLocationController:editable:
+ *
+ * Whether the location bar entry can be edited.
+ */
+ obj_properties[PROP_EDITABLE] =
+ g_param_spec_boolean ("editable",
+ "Editable",
+ "Whether the location bar entry can be edited",
+ TRUE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ /**
+ * EphyLocationController:icon:
+ *
+ * The icon corresponding to the current location.
+ */
+ obj_properties[PROP_ICON] =
+ g_param_spec_object ("icon",
+ "Icon",
+ "The icon corresponding to the current location",
+ GDK_TYPE_PIXBUF,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ /**
+ * EphyLocationController:show-icon:
+ *
+ * If we should show the page icon.
+ */
+ obj_properties[PROP_SHOW_ICON] =
+ g_param_spec_boolean ("show-icon",
+ "Show Icon",
+ "Whether to show the favicon",
+ TRUE,
+ G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ /**
+ * EphyLocationController:window:
+ *
+ * The parent window.
+ */
+ obj_properties[PROP_WINDOW] =
+ g_param_spec_object ("window",
+ "Window",
+ "The parent window",
+ G_TYPE_OBJECT,
+ G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+
+ /**
+ * EphyLocationController:location-entry:
+ *
+ * The controlled location entry.
+ */
+ obj_properties[PROP_LOCATION_ENTRY] =
+ g_param_spec_object ("location-entry",
+ "Location entry",
+ "The controlled location entry",
+ G_TYPE_OBJECT,
+ G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+
+ /**
+ * EphyLocationController:title-box:
+ *
+ * The #EphyLocationController sets the address of this title box.
+ */
+ obj_properties[PROP_TITLE_BOX] =
+ g_param_spec_object ("title-box",
+ "Title box",
+ "The title box whose address will be managed",
+ G_TYPE_OBJECT,
+ G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
}
static int
compare_actions (gconstpointer a,
- gconstpointer b)
-{
- EphyNode *node_a = (EphyNode *)a;
- EphyNode *node_b = (EphyNode *)b;
- const char *title1, *title2;
- int retval;
-
- title1 = ephy_node_get_property_string (node_a, EPHY_NODE_BMK_PROP_TITLE);
- title2 = ephy_node_get_property_string (node_b, EPHY_NODE_BMK_PROP_TITLE);
-
- if (title1 == NULL)
- {
- retval = -1;
- }
- else if (title2 == NULL)
- {
- retval = 1;
- }
- else
- {
- char *str_a, *str_b;
-
- str_a = g_utf8_casefold (title1, -1);
- str_b = g_utf8_casefold (title2, -1);
- retval = g_utf8_collate (str_a, str_b);
- g_free (str_a);
- g_free (str_b);
- }
-
- return retval;
+ gconstpointer b)
+{
+ EphyNode *node_a = (EphyNode *)a;
+ EphyNode *node_b = (EphyNode *)b;
+ const char *title1, *title2;
+ int retval;
+
+ title1 = ephy_node_get_property_string (node_a, EPHY_NODE_BMK_PROP_TITLE);
+ title2 = ephy_node_get_property_string (node_b, EPHY_NODE_BMK_PROP_TITLE);
+
+ if (title1 == NULL) {
+ retval = -1;
+ } else if (title2 == NULL) {
+ retval = 1;
+ } else {
+ char *str_a, *str_b;
+
+ str_a = g_utf8_casefold (title1, -1);
+ str_b = g_utf8_casefold (title2, -1);
+ retval = g_utf8_collate (str_a, str_b);
+ g_free (str_a);
+ g_free (str_b);
+ }
+
+ return retval;
}
static void
init_actions_list (EphyLocationController *controller)
{
- GPtrArray *children;
- guint i;
+ GPtrArray *children;
+ guint i;
- children = ephy_node_get_children (controller->smart_bmks);
- for (i = 0; i < children->len; i++)
- {
- EphyNode *kid;
+ children = ephy_node_get_children (controller->smart_bmks);
+ for (i = 0; i < children->len; i++) {
+ EphyNode *kid;
- kid = g_ptr_array_index (children, i);
+ kid = g_ptr_array_index (children, i);
- controller->actions = g_list_prepend
- (controller->actions, kid);
- }
+ controller->actions = g_list_prepend
+ (controller->actions, kid);
+ }
- controller->actions =
- g_list_sort (controller->actions, (GCompareFunc) compare_actions);
+ controller->actions =
+ g_list_sort (controller->actions, (GCompareFunc)compare_actions);
}
static void
update_actions_list (EphyLocationController *controller)
{
- remove_completion_actions (controller, controller->location_entry);
+ remove_completion_actions (controller, controller->location_entry);
- g_list_free (controller->actions);
- controller->actions = NULL;
- init_actions_list (controller);
+ g_list_free (controller->actions);
+ controller->actions = NULL;
+ init_actions_list (controller);
- add_completion_actions (controller, controller->location_entry);
+ add_completion_actions (controller, controller->location_entry);
}
static void
-actions_child_removed_cb (EphyNode *node,
- EphyNode *child,
- guint old_index,
- EphyLocationController *controller)
+actions_child_removed_cb (EphyNode *node,
+ EphyNode *child,
+ guint old_index,
+ EphyLocationController *controller)
{
- update_actions_list (controller);
+ update_actions_list (controller);
}
static void
-actions_child_added_cb (EphyNode *node,
- EphyNode *child,
- EphyLocationController *controller)
+actions_child_added_cb (EphyNode *node,
+ EphyNode *child,
+ EphyLocationController *controller)
{
- update_actions_list (controller);
+ update_actions_list (controller);
}
static void
-actions_child_changed_cb (EphyNode *node,
- EphyNode *child,
- guint property_id,
- EphyLocationController *controller)
+actions_child_changed_cb (EphyNode *node,
+ EphyNode *child,
+ guint property_id,
+ EphyLocationController *controller)
{
- update_actions_list (controller);
+ update_actions_list (controller);
}
static void
ephy_location_controller_init (EphyLocationController *controller)
{
- controller->address = g_strdup ("");
- controller->editable = TRUE;
- controller->bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
- controller->smart_bmks = ephy_bookmarks_get_smart_bookmarks
- (controller->bookmarks);
- controller->sync_address_is_blocked = FALSE;
-
- init_actions_list (controller);
-
- ephy_node_signal_connect_object (controller->smart_bmks,
- EPHY_NODE_CHILD_ADDED,
- (EphyNodeCallback)actions_child_added_cb,
- G_OBJECT (controller));
- ephy_node_signal_connect_object (controller->smart_bmks,
- EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback)actions_child_removed_cb,
- G_OBJECT (controller));
- ephy_node_signal_connect_object (controller->smart_bmks,
- EPHY_NODE_CHILD_CHANGED,
- (EphyNodeCallback)actions_child_changed_cb,
- G_OBJECT (controller));
+ controller->address = g_strdup ("");
+ controller->editable = TRUE;
+ controller->bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
+ controller->smart_bmks = ephy_bookmarks_get_smart_bookmarks
+ (controller->bookmarks);
+ controller->sync_address_is_blocked = FALSE;
+
+ init_actions_list (controller);
+
+ ephy_node_signal_connect_object (controller->smart_bmks,
+ EPHY_NODE_CHILD_ADDED,
+ (EphyNodeCallback)actions_child_added_cb,
+ G_OBJECT (controller));
+ ephy_node_signal_connect_object (controller->smart_bmks,
+ EPHY_NODE_CHILD_REMOVED,
+ (EphyNodeCallback)actions_child_removed_cb,
+ G_OBJECT (controller));
+ ephy_node_signal_connect_object (controller->smart_bmks,
+ EPHY_NODE_CHILD_CHANGED,
+ (EphyNodeCallback)actions_child_changed_cb,
+ G_OBJECT (controller));
}
static void
ephy_location_controller_finalize (GObject *object)
{
- EphyLocationController *controller = EPHY_LOCATION_CONTROLLER (object);
+ EphyLocationController *controller = EPHY_LOCATION_CONTROLLER (object);
- if (controller->icon != NULL)
- {
- g_object_unref (controller->icon);
- }
+ if (controller->icon != NULL) {
+ g_object_unref (controller->icon);
+ }
- g_list_free (controller->actions);
- g_free (controller->address);
+ g_list_free (controller->actions);
+ g_free (controller->address);
- G_OBJECT_CLASS (ephy_location_controller_parent_class)->finalize (object);
+ G_OBJECT_CLASS (ephy_location_controller_parent_class)->finalize (object);
}
/**
@@ -832,9 +809,9 @@ ephy_location_controller_finalize (GObject *object)
const char *
ephy_location_controller_get_address (EphyLocationController *controller)
{
- g_return_val_if_fail (EPHY_IS_LOCATION_CONTROLLER (controller), "");
+ g_return_val_if_fail (EPHY_IS_LOCATION_CONTROLLER (controller), "");
- return controller->address;
+ return controller->address;
}
/**
@@ -846,14 +823,14 @@ ephy_location_controller_get_address (EphyLocationController *controller)
**/
void
ephy_location_controller_set_address (EphyLocationController *controller,
- const char *address)
+ const char *address)
{
- g_return_if_fail (EPHY_IS_LOCATION_CONTROLLER (controller));
+ g_return_if_fail (EPHY_IS_LOCATION_CONTROLLER (controller));
- LOG ("set_address %s", address);
+ LOG ("set_address %s", address);
- g_free (controller->address);
- controller->address = g_strdup (address);
+ g_free (controller->address);
+ controller->address = g_strdup (address);
- g_object_notify_by_pspec (G_OBJECT (controller), obj_properties[PROP_ADDRESS]);
+ g_object_notify_by_pspec (G_OBJECT (controller), obj_properties[PROP_ADDRESS]);
}
diff --git a/src/ephy-lockdown.c b/src/ephy-lockdown.c
index 22eaea3..3589385 100644
--- a/src/ephy-lockdown.c
+++ b/src/ephy-lockdown.c
@@ -34,8 +34,7 @@
#define LOCKDOWN_FLAG 1 << 8
-struct _EphyLockdown
-{
+struct _EphyLockdown {
GObject parent_instance;
};
@@ -43,26 +42,26 @@ G_DEFINE_TYPE (EphyLockdown, ephy_lockdown, G_TYPE_OBJECT)
static int
find_name (GtkActionGroup *action_group,
- const char *name)
+ const char *name)
{
return g_strcmp0 (gtk_action_group_get_name (action_group), name);
}
static GtkActionGroup *
find_action_group (GtkUIManager *manager,
- const char *name)
+ const char *name)
{
GList *list, *element;
list = gtk_ui_manager_get_action_groups (manager);
- element = g_list_find_custom (list, name, (GCompareFunc) find_name);
+ element = g_list_find_custom (list, name, (GCompareFunc)find_name);
g_return_val_if_fail (element != NULL, NULL);
return GTK_ACTION_GROUP (element->data);
}
static void
-arbitrary_url_cb (GSettings *settings,
+arbitrary_url_cb (GSettings *settings,
const char *key,
EphyWindow *window)
{
@@ -83,7 +82,7 @@ arbitrary_url_cb (GSettings *settings,
}
static void
-fullscreen_cb (GSettings *settings,
+fullscreen_cb (GSettings *settings,
const char *key,
EphyWindow *window)
{
@@ -129,9 +128,9 @@ static const BindAction special_toolbar_actions[] = {
};
static gboolean
-sensitive_get_mapping (GValue *value,
+sensitive_get_mapping (GValue *value,
GVariant *variant,
- gpointer data)
+ gpointer data)
{
GtkAction *action;
gboolean active, before, after;
@@ -151,10 +150,10 @@ sensitive_get_mapping (GValue *value,
}
static void
-bind_settings_and_actions (GSettings *settings,
- GtkActionGroup *action_group,
+bind_settings_and_actions (GSettings *settings,
+ GtkActionGroup *action_group,
const BindAction *actions,
- int actions_n)
+ int actions_n)
{
int i;
@@ -162,7 +161,7 @@ bind_settings_and_actions (GSettings *settings,
GtkAction *action;
action = gtk_action_group_get_action (action_group,
- actions[i].action);
+ actions[i].action);
if (g_strcmp0 (actions[i].prop, "visible") == 0) {
g_settings_bind (settings, actions[i].key,
@@ -185,7 +184,7 @@ bind_settings_and_actions (GSettings *settings,
}
static void
-bind_location_controller (GSettings *settings,
+bind_location_controller (GSettings *settings,
EphyLocationController *controller)
{
g_settings_bind (settings, EPHY_PREFS_LOCKDOWN_ARBITRARY_URL,
@@ -196,8 +195,8 @@ bind_location_controller (GSettings *settings,
static void
window_added_cb (GtkApplication *application,
- GtkWindow *window,
- EphyLockdown *lockdown)
+ GtkWindow *window,
+ EphyLockdown *lockdown)
{
GtkUIManager *manager;
GtkActionGroup *action_group;
diff --git a/src/ephy-main.c b/src/ephy-main.c
index 7f9d55c..ae0dd1b 100644
--- a/src/ephy-main.c
+++ b/src/ephy-main.c
@@ -67,7 +67,7 @@ option_version_cb (const gchar *option_name,
exit (EXIT_SUCCESS);
return FALSE;
}
-
+
static const GOptionEntry option_entries[] =
{
{ "new-tab", 'n', 0, G_OPTION_ARG_NONE, &open_in_new_tab,
@@ -91,8 +91,8 @@ static const GOptionEntry option_entries[] =
{ "profile", 0, 0, G_OPTION_ARG_STRING, &profile_directory,
N_("Profile directory to use in the private instance"), N_("DIR") },
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &arguments,
- "", N_("URL …")},
- { "version", 0, G_OPTION_FLAG_NO_ARG | G_OPTION_FLAG_HIDDEN,
+ "", N_("URL …") },
+ { "version", 0, G_OPTION_FLAG_NO_ARG | G_OPTION_FLAG_HIDDEN,
G_OPTION_ARG_CALLBACK, option_version_cb, NULL, NULL },
{ "delete-application", 0, 0, G_OPTION_ARG_STRING | G_OPTION_FLAG_HIDDEN,
&application_to_delete, NULL, NULL },
@@ -117,13 +117,13 @@ get_startup_id (void)
gulong value;
gchar *end;
errno = 0;
-
+
/* Skip past the "_TIME" part */
time_str += 5;
-
+
value = strtoul (time_str, &end, 0);
if (end != time_str && errno == 0)
- retval = (guint32) value;
+ retval = (guint32)value;
}
return retval;
@@ -142,16 +142,16 @@ slowly_and_stupidly_obtain_timestamp (Display *xdisplay)
{
Window xwindow;
XEvent event;
-
+
{
XSetWindowAttributes attrs;
Atom atom_name;
Atom atom_type;
- const char* name;
-
+ const char *name;
+
attrs.override_redirect = True;
attrs.event_mask = PropertyChangeMask | StructureNotifyMask;
-
+
xwindow =
XCreateWindow (xdisplay,
RootWindow (xdisplay, 0),
@@ -162,26 +162,26 @@ slowly_and_stupidly_obtain_timestamp (Display *xdisplay)
CopyFromParent,
CWOverrideRedirect | CWEventMask,
&attrs);
-
+
atom_name = XInternAtom (xdisplay, "WM_NAME", TRUE);
g_assert (atom_name != None);
atom_type = XInternAtom (xdisplay, "STRING", TRUE);
g_assert (atom_type != None);
-
+
name = "Fake Window";
- XChangeProperty (xdisplay,
+ XChangeProperty (xdisplay,
xwindow, atom_name,
atom_type,
8, PropModeReplace, (unsigned char *)name, strlen (name));
}
-
+
XWindowEvent (xdisplay,
xwindow,
PropertyChangeMask,
&event);
-
- XDestroyWindow(xdisplay, xwindow);
-
+
+ XDestroyWindow (xdisplay, xwindow);
+
return event.xproperty.time;
}
#endif
@@ -199,8 +199,8 @@ show_error_message (GError **error)
_("Could not start Web"));
gtk_message_dialog_format_secondary_text
(GTK_MESSAGE_DIALOG (dialog),
- _("Startup failed because of the following error:\n%s"),
- (*error)->message);
+ _("Startup failed because of the following error:\n%s"),
+ (*error)->message);
g_clear_error (error);
@@ -221,7 +221,7 @@ get_startup_flags (void)
}
int
-main (int argc,
+main (int argc,
char *argv[])
{
GOptionContext *option_context;
@@ -254,15 +254,15 @@ main (int argc,
const char *opening, *closing;
char *command, *argument;
char **arg_list;
-
+
if (argc != 3) {
g_print ("-remote allows exactly one argument\n");
exit (1);
}
-
+
opening = strchr (argv[2], '(');
closing = strchr (argv[2], ')');
-
+
if (opening == NULL ||
closing == NULL ||
opening == argv[2] ||
@@ -270,9 +270,9 @@ main (int argc,
g_print ("Invalid argument for -remote\n");
exit (1);
}
-
+
command = g_strstrip (g_strndup (argv[2], opening - argv[2]));
-
+
/* See http://lxr.mozilla.org/seamonkey/source/xpfe/components/xremote/src/XRemoteService.cpp
* for the commands that mozilla supports; we'll just support openURL here.
*/
@@ -281,28 +281,28 @@ main (int argc,
g_free (command);
exit (1);
}
-
+
g_free (command);
-
+
argument = g_strstrip (g_strndup (opening + 1, closing - opening - 1));
arg_list = g_strsplit (argument, ",", -1);
g_free (argument);
if (arg_list == NULL) {
g_print ("Invalid argument for -remote\n");
-
+
exit (1);
}
-
+
/* replace arguments */
argv[1] = g_strstrip (g_strdup (arg_list[0]));
argc = 2;
-
+
g_strfreev (arg_list);
}
-
+
/* Initialise our debug helpers */
ephy_debug_init ();
-
+
/* get this early, since gdk will unset the env var */
user_time = get_startup_id ();
@@ -326,7 +326,7 @@ main (int argc,
g_option_context_free (option_context);
exit (1);
}
-
+
g_option_context_free (option_context);
/* Some argument sanity checks*/
@@ -341,8 +341,8 @@ main (int argc,
}
if (application_mode && profile_directory && !g_file_test (profile_directory, G_FILE_TEST_IS_DIR)) {
- g_print ("--profile must be an existing directory when --application-mode is requested\n");
- exit (1);
+ g_print ("--profile must be an existing directory when --application-mode is requested\n");
+ exit (1);
}
if (application_mode && !profile_directory) {
@@ -416,7 +416,7 @@ main (int argc,
#ifdef GDK_WINDOWING_X11
/* Get a timestamp manually if need be */
if (user_time == 0) {
- GdkDisplay* display =
+ GdkDisplay *display =
gdk_display_manager_get_default_display (gdk_display_manager_get ());
if (GDK_IS_X11_DISPLAY (display))
user_time =
diff --git a/src/ephy-navigation-history-action.c b/src/ephy-navigation-history-action.c
index 69cc2d7..6cc1b02 100644
--- a/src/ephy-navigation-history-action.c
+++ b/src/ephy-navigation-history-action.c
@@ -40,10 +40,10 @@
#include <gtk/gtk.h>
#include <webkit2/webkit2.h>
-#define EPHY_NAVIGATION_HISTORY_ACTION_GET_PRIVATE(object) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((object), \
- EPHY_TYPE_NAVIGATION_HISTORY_ACTION, \
- EphyNavigationHistoryActionPrivate))
+#define EPHY_NAVIGATION_HISTORY_ACTION_GET_PRIVATE(object) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((object), \
+ EPHY_TYPE_NAVIGATION_HISTORY_ACTION, \
+ EphyNavigationHistoryActionPrivate))
struct _EphyNavigationHistoryActionPrivate {
EphyNavigationHistoryDirection direction;
@@ -70,7 +70,7 @@ typedef enum {
G_DEFINE_TYPE (EphyNavigationHistoryAction, ephy_navigation_history_action, EPHY_TYPE_LINK_ACTION)
static void
-ephy_history_cleared_cb (EphyHistoryService *history,
+ephy_history_cleared_cb (EphyHistoryService *history,
EphyNavigationHistoryAction *action)
{
ephy_action_change_sensitivity_flags (GTK_ACTION (action), SENS_FLAG, TRUE);
@@ -180,44 +180,44 @@ ephy_navigation_history_action_finalize (GObject *object)
}
static void
-ephy_navigation_history_action_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ephy_navigation_history_action_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
EphyNavigationHistoryAction *nav = EPHY_NAVIGATION_HISTORY_ACTION (object);
switch (prop_id) {
- case PROP_DIRECTION:
- nav->priv->direction = g_value_get_int (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case PROP_DIRECTION:
+ nav->priv->direction = g_value_get_int (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static void
-ephy_navigation_history_action_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ephy_navigation_history_action_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
EphyNavigationHistoryAction *nav = EPHY_NAVIGATION_HISTORY_ACTION (object);
switch (prop_id) {
- case PROP_DIRECTION:
- g_value_set_int (value, nav->priv->direction);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case PROP_DIRECTION:
+ g_value_set_int (value, nav->priv->direction);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static gboolean
-item_enter_notify_event_cb (GtkWidget *widget,
- GdkEvent *event,
+item_enter_notify_event_cb (GtkWidget *widget,
+ GdkEvent *event,
EphyWebView *view)
{
char *text;
@@ -229,8 +229,8 @@ item_enter_notify_event_cb (GtkWidget *widget,
}
static gboolean
-item_leave_notify_event_cb (GtkWidget *widget,
- GdkEvent *event,
+item_leave_notify_event_cb (GtkWidget *widget,
+ GdkEvent *event,
EphyWebView *view)
{
ephy_web_view_set_link_message (view, NULL);
@@ -238,8 +238,8 @@ item_leave_notify_event_cb (GtkWidget *widget,
}
static void
-icon_loaded_cb (GObject *source,
- GAsyncResult *result,
+icon_loaded_cb (GObject *source,
+ GAsyncResult *result,
GtkImageMenuItem *item)
{
WebKitFaviconDatabase *database = WEBKIT_FAVICON_DATABASE (source);
@@ -266,12 +266,12 @@ icon_loaded_cb (GObject *source,
static GtkWidget *
new_history_menu_item (EphyWebView *view,
- const char *origtext,
- const char *address)
+ const char *origtext,
+ const char *address)
{
GtkWidget *item;
GtkLabel *label;
- WebKitFaviconDatabase* database;
+ WebKitFaviconDatabase *database;
EphyEmbedShell *shell = ephy_embed_shell_get_default ();
g_return_val_if_fail (address != NULL && origtext != NULL, NULL);
@@ -288,7 +288,7 @@ new_history_menu_item (EphyWebView *view,
(GAsyncReadyCallback)icon_loaded_cb,
g_object_ref (item));
- g_object_set_data_full (G_OBJECT (item), "link-message", g_strdup (address), (GDestroyNotify) g_free);
+ g_object_set_data_full (G_OBJECT (item), "link-message", g_strdup (address), (GDestroyNotify)g_free);
g_signal_connect (item, "enter-notify-event",
G_CALLBACK (item_enter_notify_event_cb), view);
@@ -303,15 +303,15 @@ new_history_menu_item (EphyWebView *view,
static void
set_new_back_history (EphyEmbed *source,
EphyEmbed *dest,
- gint offset)
+ gint offset)
{
/* TODO: WebKitBackForwardList: In WebKit2 WebKitBackForwardList can't be modified */
}
static void
middle_click_handle_on_history_menu_item (EphyNavigationHistoryAction *action,
- EphyEmbed *embed,
- WebKitBackForwardListItem *item)
+ EphyEmbed *embed,
+ WebKitBackForwardListItem *item)
{
EphyEmbed *new_embed = NULL;
const gchar *url;
@@ -337,7 +337,7 @@ middle_click_handle_on_history_menu_item (EphyNavigationHistoryAction *action,
}
static void
-activate_menu_item_cb (GtkWidget *menuitem,
+activate_menu_item_cb (GtkWidget *menuitem,
EphyNavigationHistoryAction *action)
{
WebKitBackForwardListItem *item;
@@ -348,7 +348,7 @@ activate_menu_item_cb (GtkWidget *menuitem,
embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
g_return_if_fail (embed != NULL);
- item = (WebKitBackForwardListItem *) g_object_get_data (G_OBJECT (menuitem), HISTORY_ITEM_DATA_KEY);
+ item = (WebKitBackForwardListItem *)g_object_get_data (G_OBJECT (menuitem), HISTORY_ITEM_DATA_KEY);
g_return_if_fail (item != NULL);
if (ephy_gui_is_middle_click ())
@@ -362,16 +362,16 @@ activate_menu_item_cb (GtkWidget *menuitem,
}
static GList *
-construct_webkit_history_list (WebKitWebView *web_view,
+construct_webkit_history_list (WebKitWebView *web_view,
WebKitHistoryType hist_type,
- int limit)
+ int limit)
{
WebKitBackForwardList *back_forward_list;
back_forward_list = webkit_web_view_get_back_forward_list (web_view);
return hist_type == WEBKIT_HISTORY_FORWARD ?
- g_list_reverse (webkit_back_forward_list_get_forward_list_with_limit (back_forward_list, limit)) :
- webkit_back_forward_list_get_back_list_with_limit (back_forward_list, limit);
+ g_list_reverse (webkit_back_forward_list_get_forward_list_with_limit (back_forward_list, limit)) :
+ webkit_back_forward_list_get_back_list_with_limit (back_forward_list, limit);
}
static GtkWidget *
@@ -404,7 +404,7 @@ build_dropdown_menu (EphyNavigationHistoryAction *action)
const char *uri;
char *title;
- hitem = (WebKitBackForwardListItem *) l->data;
+ hitem = (WebKitBackForwardListItem *)l->data;
uri = webkit_back_forward_list_item_get_uri (hitem);
title = g_strdup (webkit_back_forward_list_item_get_title (hitem));
@@ -438,18 +438,18 @@ typedef struct {
static GtkWidget *
popup_history_menu (EphyNavigationHistoryAction *action,
- GtkWidget *widget,
- GdkEventButton *event)
+ GtkWidget *widget,
+ GdkEventButton *event)
{
- GtkWidget *menu;
+ GtkWidget *menu;
- menu = build_dropdown_menu (action);
- gtk_menu_popup (GTK_MENU (menu),
- NULL, NULL,
- ephy_gui_menu_position_under_widget, widget,
- event->button, event->time);
+ menu = build_dropdown_menu (action);
+ gtk_menu_popup (GTK_MENU (menu),
+ NULL, NULL,
+ ephy_gui_menu_position_under_widget, widget,
+ event->button, event->time);
- return menu;
+ return menu;
}
static gboolean
@@ -462,8 +462,8 @@ menu_timeout_cb (PopupData *data)
}
static gboolean
-tool_button_press_event_cb (GtkButton *button,
- GdkEventButton *event,
+tool_button_press_event_cb (GtkButton *button,
+ GdkEventButton *event,
EphyNavigationHistoryAction *action)
{
if (event->button == 1) {
@@ -475,9 +475,9 @@ tool_button_press_event_cb (GtkButton *button,
data->widget = GTK_WIDGET (button);
action->priv->menu_timeout = g_timeout_add_full (G_PRIORITY_DEFAULT, 500,
- (GSourceFunc) menu_timeout_cb,
+ (GSourceFunc)menu_timeout_cb,
data,
- (GDestroyNotify) g_free);
+ (GDestroyNotify)g_free);
g_source_set_name_by_id (action->priv->menu_timeout, "[epiphany] menu_timeout_cb");
} else if (event->button == 3) {
popup_history_menu (action, GTK_WIDGET (button), event);
@@ -487,8 +487,8 @@ tool_button_press_event_cb (GtkButton *button,
}
static gboolean
-tool_leave_notify_event_cb (GtkButton *button,
- GdkEvent *event,
+tool_leave_notify_event_cb (GtkButton *button,
+ GdkEvent *event,
EphyNavigationHistoryAction *action)
{
if (action->priv->menu_timeout > 0)
@@ -517,9 +517,9 @@ disconnect_proxy (GtkAction *gaction,
GtkWidget *proxy)
{
g_signal_handlers_disconnect_by_func (proxy,
- G_CALLBACK (tool_button_press_event_cb), gaction);
+ G_CALLBACK (tool_button_press_event_cb), gaction);
g_signal_handlers_disconnect_by_func (proxy,
- G_CALLBACK (tool_leave_notify_event_cb), gaction);
+ G_CALLBACK (tool_leave_notify_event_cb), gaction);
GTK_ACTION_CLASS (ephy_navigation_history_action_parent_class)->disconnect_proxy (gaction, proxy);
}
diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c
index 153eb59..ff859ac 100644
--- a/src/ephy-notebook.c
+++ b/src/ephy-notebook.c
@@ -44,121 +44,116 @@
#define EPHY_NOTEBOOK_TAB_GROUP_ID "0x42"
-struct _EphyNotebook
-{
- GtkNotebook parent_instance;
+struct _EphyNotebook {
+ GtkNotebook parent_instance;
- GList *focused_pages;
- guint tabs_vis_notifier_id;
+ GList *focused_pages;
+ guint tabs_vis_notifier_id;
- guint tabs_allowed : 1;
+ guint tabs_allowed : 1;
};
-static void ephy_notebook_finalize (GObject *object);
-static int ephy_notebook_insert_page (GtkNotebook *notebook,
- GtkWidget *child,
- GtkWidget *tab_label,
- GtkWidget *menu_label,
- int position);
-static void ephy_notebook_remove (GtkContainer *container,
- GtkWidget *tab_widget);
+static void ephy_notebook_finalize (GObject *object);
+static int ephy_notebook_insert_page (GtkNotebook *notebook,
+ GtkWidget *child,
+ GtkWidget *tab_label,
+ GtkWidget *menu_label,
+ int position);
+static void ephy_notebook_remove (GtkContainer *container,
+ GtkWidget *tab_widget);
-static const GtkTargetEntry url_drag_types [] =
+static const GtkTargetEntry url_drag_types [] =
{
- { (char *)"GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, 0 },
- { (char *)EPHY_DND_URI_LIST_TYPE, 0, 0 },
- { (char *)EPHY_DND_URL_TYPE, 0, 1 },
+ { (char *)"GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, 0 },
+ { (char *)EPHY_DND_URI_LIST_TYPE, 0, 0 },
+ { (char *)EPHY_DND_URL_TYPE, 0, 1 },
};
-enum
-{
- PROP_0,
- PROP_TABS_ALLOWED,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_TABS_ALLOWED,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
-enum
-{
- TAB_CLOSE_REQUEST,
- LAST_SIGNAL
+enum {
+ TAB_CLOSE_REQUEST,
+ LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
G_DEFINE_TYPE_WITH_CODE (EphyNotebook, ephy_notebook, GTK_TYPE_NOTEBOOK,
- G_IMPLEMENT_INTERFACE (EPHY_TYPE_LINK,
- NULL))
+ G_IMPLEMENT_INTERFACE (EPHY_TYPE_LINK,
+ NULL))
static void
-ephy_notebook_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EphyNotebook *notebook = EPHY_NOTEBOOK (object);
-
- switch (prop_id)
- {
- case PROP_TABS_ALLOWED:
- g_value_set_boolean (value, notebook->tabs_allowed);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
+ephy_notebook_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EphyNotebook *notebook = EPHY_NOTEBOOK (object);
+
+ switch (prop_id) {
+ case PROP_TABS_ALLOWED:
+ g_value_set_boolean (value, notebook->tabs_allowed);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
-ephy_notebook_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EphyNotebook *notebook = EPHY_NOTEBOOK (object);
-
- switch (prop_id)
- {
- case PROP_TABS_ALLOWED:
- ephy_notebook_set_tabs_allowed (notebook, g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
+ephy_notebook_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EphyNotebook *notebook = EPHY_NOTEBOOK (object);
+
+ switch (prop_id) {
+ case PROP_TABS_ALLOWED:
+ ephy_notebook_set_tabs_allowed (notebook, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
ephy_notebook_class_init (EphyNotebookClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
- GtkNotebookClass *notebook_class = GTK_NOTEBOOK_CLASS (klass);
-
- object_class->finalize = ephy_notebook_finalize;
- object_class->get_property = ephy_notebook_get_property;
- object_class->set_property = ephy_notebook_set_property;
-
- container_class->remove = ephy_notebook_remove;
-
- notebook_class->insert_page = ephy_notebook_insert_page;
-
- signals[TAB_CLOSE_REQUEST] =
- g_signal_new ("tab-close-request",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- GTK_TYPE_WIDGET /* Can't use an interface type here */);
-
- obj_properties[PROP_TABS_ALLOWED] =
- g_param_spec_boolean ("tabs-allowed",
- NULL,
- NULL,
- TRUE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
+ GtkNotebookClass *notebook_class = GTK_NOTEBOOK_CLASS (klass);
+
+ object_class->finalize = ephy_notebook_finalize;
+ object_class->get_property = ephy_notebook_get_property;
+ object_class->set_property = ephy_notebook_set_property;
+
+ container_class->remove = ephy_notebook_remove;
+
+ notebook_class->insert_page = ephy_notebook_insert_page;
+
+ signals[TAB_CLOSE_REQUEST] =
+ g_signal_new ("tab-close-request",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ GTK_TYPE_WIDGET /* Can't use an interface type here */);
+
+ obj_properties[PROP_TABS_ALLOWED] =
+ g_param_spec_boolean ("tabs-allowed",
+ NULL,
+ NULL,
+ TRUE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
}
@@ -166,219 +161,203 @@ ephy_notebook_class_init (EphyNotebookClass *klass)
static EphyNotebook *
find_notebook_at_pointer (GdkDisplay *display, gint abs_x, gint abs_y)
{
- GdkWindow *win_at_pointer, *toplevel_win;
- gpointer toplevel = NULL;
- gint x, y;
-
- win_at_pointer = gdk_device_get_window_at_position (
- gdk_device_manager_get_client_pointer (
- gdk_display_get_device_manager (display)),
- &x, &y);
- if (win_at_pointer == NULL)
- {
- /* We are outside all windows containing a notebook */
- return NULL;
- }
-
- toplevel_win = gdk_window_get_toplevel (win_at_pointer);
-
- /* get the GtkWidget which owns the toplevel GdkWindow */
- gdk_window_get_user_data (toplevel_win, &toplevel);
-
- /* toplevel should be an EphyWindow */
- if (toplevel != NULL && EPHY_IS_WINDOW (toplevel))
- {
- return EPHY_NOTEBOOK (ephy_window_get_notebook
- (EPHY_WINDOW (toplevel)));
- }
-
- return NULL;
+ GdkWindow *win_at_pointer, *toplevel_win;
+ gpointer toplevel = NULL;
+ gint x, y;
+
+ win_at_pointer = gdk_device_get_window_at_position (
+ gdk_device_manager_get_client_pointer (
+ gdk_display_get_device_manager (display)),
+ &x, &y);
+ if (win_at_pointer == NULL) {
+ /* We are outside all windows containing a notebook */
+ return NULL;
+ }
+
+ toplevel_win = gdk_window_get_toplevel (win_at_pointer);
+
+ /* get the GtkWidget which owns the toplevel GdkWindow */
+ gdk_window_get_user_data (toplevel_win, &toplevel);
+
+ /* toplevel should be an EphyWindow */
+ if (toplevel != NULL && EPHY_IS_WINDOW (toplevel)) {
+ return EPHY_NOTEBOOK (ephy_window_get_notebook
+ (EPHY_WINDOW (toplevel)));
+ }
+
+ return NULL;
}
static gboolean
is_in_notebook_window (EphyNotebook *notebook,
- gint abs_x, gint abs_y)
+ gint abs_x, gint abs_y)
{
- EphyNotebook *nb_at_pointer;
+ EphyNotebook *nb_at_pointer;
- nb_at_pointer = find_notebook_at_pointer (gtk_widget_get_display (GTK_WIDGET (notebook)),
- abs_x, abs_y);
+ nb_at_pointer = find_notebook_at_pointer (gtk_widget_get_display (GTK_WIDGET (notebook)),
+ abs_x, abs_y);
- return nb_at_pointer == notebook;
+ return nb_at_pointer == notebook;
}
static gint
find_tab_num_at_pos (EphyNotebook *notebook, gint abs_x, gint abs_y)
{
- int page_num = 0;
- GtkNotebook *nb = GTK_NOTEBOOK (notebook);
- GtkWidget *page;
-
- /* For some reason unfullscreen + quick click can
- cause a wrong click event to be reported to the tab */
- if (!is_in_notebook_window (notebook, abs_x, abs_y))
- {
- return NOT_IN_APP_WINDOWS;
- }
-
- while ((page = gtk_notebook_get_nth_page (nb, page_num)))
- {
- GtkWidget *tab;
- GtkAllocation allocation;
- gint max_x, max_y;
- gint x_root, y_root;
-
- tab = gtk_notebook_get_tab_label (nb, page);
- g_return_val_if_fail (tab != NULL, -1);
-
- if (!gtk_widget_get_mapped (GTK_WIDGET (tab)))
- {
- page_num++;
- continue;
- }
-
- gdk_window_get_origin (gtk_widget_get_window (tab),
- &x_root, &y_root);
-
- gtk_widget_get_allocation (tab, &allocation);
- max_x = x_root + allocation.x + allocation.width;
- max_y = y_root + allocation.y + allocation.height;
-
- if (abs_y <= max_y && abs_x <= max_x)
- {
- return page_num;
- }
-
- page_num++;
- }
- return AFTER_ALL_TABS;
+ int page_num = 0;
+ GtkNotebook *nb = GTK_NOTEBOOK (notebook);
+ GtkWidget *page;
+
+ /* For some reason unfullscreen + quick click can
+ cause a wrong click event to be reported to the tab */
+ if (!is_in_notebook_window (notebook, abs_x, abs_y)) {
+ return NOT_IN_APP_WINDOWS;
+ }
+
+ while ((page = gtk_notebook_get_nth_page (nb, page_num))) {
+ GtkWidget *tab;
+ GtkAllocation allocation;
+ gint max_x, max_y;
+ gint x_root, y_root;
+
+ tab = gtk_notebook_get_tab_label (nb, page);
+ g_return_val_if_fail (tab != NULL, -1);
+
+ if (!gtk_widget_get_mapped (GTK_WIDGET (tab))) {
+ page_num++;
+ continue;
+ }
+
+ gdk_window_get_origin (gtk_widget_get_window (tab),
+ &x_root, &y_root);
+
+ gtk_widget_get_allocation (tab, &allocation);
+ max_x = x_root + allocation.x + allocation.width;
+ max_y = y_root + allocation.y + allocation.height;
+
+ if (abs_y <= max_y && abs_x <= max_x) {
+ return page_num;
+ }
+
+ page_num++;
+ }
+ return AFTER_ALL_TABS;
}
static gboolean
-button_press_cb (EphyNotebook *notebook,
- GdkEventButton *event,
- gpointer data)
-{
- int tab_clicked;
-
- tab_clicked = find_tab_num_at_pos (notebook, event->x_root, event->y_root);
-
- if (event->type == GDK_BUTTON_PRESS &&
- event->button == 3 &&
- (event->state & gtk_accelerator_get_default_mod_mask ()) == 0)
- {
- if (tab_clicked == -1)
- {
- /* Consume event so that we don't pop up the context
- * menu when the mouse is not over a tab label.
- */
- return TRUE;
- }
-
- /* Switch to the page where the mouse is over, but don't consume the
- * event. */
- gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), tab_clicked);
- }
-
- return FALSE;
+button_press_cb (EphyNotebook *notebook,
+ GdkEventButton *event,
+ gpointer data)
+{
+ int tab_clicked;
+
+ tab_clicked = find_tab_num_at_pos (notebook, event->x_root, event->y_root);
+
+ if (event->type == GDK_BUTTON_PRESS &&
+ event->button == 3 &&
+ (event->state & gtk_accelerator_get_default_mod_mask ()) == 0) {
+ if (tab_clicked == -1) {
+ /* Consume event so that we don't pop up the context
+ * menu when the mouse is not over a tab label.
+ */
+ return TRUE;
+ }
+
+ /* Switch to the page where the mouse is over, but don't consume the
+ * event. */
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), tab_clicked);
+ }
+
+ return FALSE;
}
static void
ephy_notebook_switch_page_cb (GtkNotebook *notebook,
- GtkWidget *page,
- guint page_num,
- gpointer data)
+ GtkWidget *page,
+ guint page_num,
+ gpointer data)
{
- EphyNotebook *nb = EPHY_NOTEBOOK (notebook);
- GtkWidget *child;
+ EphyNotebook *nb = EPHY_NOTEBOOK (notebook);
+ GtkWidget *child;
- child = gtk_notebook_get_nth_page (notebook, page_num);
+ child = gtk_notebook_get_nth_page (notebook, page_num);
- /* Remove the old page, we dont want to grow unnecessarily
- * the list */
- if (nb->focused_pages)
- {
- nb->focused_pages =
- g_list_remove (nb->focused_pages, child);
- }
+ /* Remove the old page, we dont want to grow unnecessarily
+ * the list */
+ if (nb->focused_pages) {
+ nb->focused_pages =
+ g_list_remove (nb->focused_pages, child);
+ }
- nb->focused_pages = g_list_append (nb->focused_pages, child);
+ nb->focused_pages = g_list_append (nb->focused_pages, child);
}
static void
-notebook_drag_data_received_cb (GtkWidget* widget,
- GdkDragContext *context,
- int x,
- int y,
+notebook_drag_data_received_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ int x,
+ int y,
GtkSelectionData *selection_data,
- guint info,
- guint time,
- EphyEmbed *embed)
-{
- EphyWindow *window;
- GtkWidget *notebook;
- GdkAtom target;
- const guchar *data;
-
- target = gtk_selection_data_get_target (selection_data);
- if (target == gdk_atom_intern_static_string ("GTK_NOTEBOOK_TAB"))
- return;
-
- g_signal_stop_emission_by_name (widget, "drag_data_received");
-
- if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
- EPHY_PREFS_LOCKDOWN_ARBITRARY_URL)) return;
-
- data = gtk_selection_data_get_data (selection_data);
- if (gtk_selection_data_get_length (selection_data) <= 0 || data == NULL) return;
-
- window = EPHY_WINDOW (gtk_widget_get_toplevel (widget));
- notebook = ephy_window_get_notebook (window);
-
- if (target == gdk_atom_intern (EPHY_DND_URL_TYPE, FALSE))
- {
- char **split;
-
- /* URL_TYPE has format: url \n title */
- split = g_strsplit ((const gchar *) data, "\n", 2);
- if (split != NULL && split[0] != NULL && split[0][0] != '\0')
- {
- ephy_link_open (EPHY_LINK (notebook), split[0], embed,
- embed ? 0 : EPHY_LINK_NEW_TAB);
- }
- g_strfreev (split);
- }
- else if (target == gdk_atom_intern (EPHY_DND_URI_LIST_TYPE, FALSE))
- {
- char **uris;
- int i;
-
- uris = gtk_selection_data_get_uris (selection_data);
- if (uris == NULL) return;
-
- for (i = 0; uris[i] != NULL && i < INSANE_NUMBER_OF_URLS; i++)
- {
- embed = ephy_link_open (EPHY_LINK (notebook), uris[i], embed,
- (embed && i == 0) ? 0 : EPHY_LINK_NEW_TAB);
- }
-
- g_strfreev (uris);
- }
- else
- {
- char *text;
-
- text = (char *) gtk_selection_data_get_text (selection_data);
- if (text != NULL) {
- char *address;
-
- address = ephy_embed_utils_normalize_or_autosearch_address (text);
- ephy_link_open (EPHY_LINK (notebook), address, embed,
- embed ? 0 : EPHY_LINK_NEW_TAB);
- g_free (address);
- g_free (text);
- }
- }
+ guint info,
+ guint time,
+ EphyEmbed *embed)
+{
+ EphyWindow *window;
+ GtkWidget *notebook;
+ GdkAtom target;
+ const guchar *data;
+
+ target = gtk_selection_data_get_target (selection_data);
+ if (target == gdk_atom_intern_static_string ("GTK_NOTEBOOK_TAB"))
+ return;
+
+ g_signal_stop_emission_by_name (widget, "drag_data_received");
+
+ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_ARBITRARY_URL)) return;
+
+ data = gtk_selection_data_get_data (selection_data);
+ if (gtk_selection_data_get_length (selection_data) <= 0 || data == NULL) return;
+
+ window = EPHY_WINDOW (gtk_widget_get_toplevel (widget));
+ notebook = ephy_window_get_notebook (window);
+
+ if (target == gdk_atom_intern (EPHY_DND_URL_TYPE, FALSE)) {
+ char **split;
+
+ /* URL_TYPE has format: url \n title */
+ split = g_strsplit ((const gchar *)data, "\n", 2);
+ if (split != NULL && split[0] != NULL && split[0][0] != '\0') {
+ ephy_link_open (EPHY_LINK (notebook), split[0], embed,
+ embed ? 0 : EPHY_LINK_NEW_TAB);
+ }
+ g_strfreev (split);
+ } else if (target == gdk_atom_intern (EPHY_DND_URI_LIST_TYPE, FALSE)) {
+ char **uris;
+ int i;
+
+ uris = gtk_selection_data_get_uris (selection_data);
+ if (uris == NULL) return;
+
+ for (i = 0; uris[i] != NULL && i < INSANE_NUMBER_OF_URLS; i++) {
+ embed = ephy_link_open (EPHY_LINK (notebook), uris[i], embed,
+ (embed && i == 0) ? 0 : EPHY_LINK_NEW_TAB);
+ }
+
+ g_strfreev (uris);
+ } else {
+ char *text;
+
+ text = (char *)gtk_selection_data_get_text (selection_data);
+ if (text != NULL) {
+ char *address;
+
+ address = ephy_embed_utils_normalize_or_autosearch_address (text);
+ ephy_link_open (EPHY_LINK (notebook), address, embed,
+ embed ? 0 : EPHY_LINK_NEW_TAB);
+ g_free (address);
+ g_free (text);
+ }
+ }
}
/*
@@ -387,437 +366,428 @@ notebook_drag_data_received_cb (GtkWidget* widget,
*/
static void
update_tabs_visibility (EphyNotebook *nb,
- gboolean before_inserting)
+ gboolean before_inserting)
{
- EphyEmbedShellMode mode;
- gboolean show_tabs = FALSE;
- guint num;
- EphyPrefsUITabsBarVisibilityPolicy policy;
+ EphyEmbedShellMode mode;
+ gboolean show_tabs = FALSE;
+ guint num;
+ EphyPrefsUITabsBarVisibilityPolicy policy;
- mode = ephy_embed_shell_get_mode (EPHY_EMBED_SHELL (ephy_shell_get_default ()));
- num = gtk_notebook_get_n_pages (GTK_NOTEBOOK (nb));
+ mode = ephy_embed_shell_get_mode (EPHY_EMBED_SHELL (ephy_shell_get_default ()));
+ num = gtk_notebook_get_n_pages (GTK_NOTEBOOK (nb));
- if (before_inserting) num++;
+ if (before_inserting) num++;
- policy = g_settings_get_enum (EPHY_SETTINGS_UI,
- EPHY_PREFS_UI_TABS_BAR_VISIBILITY_POLICY);
+ policy = g_settings_get_enum (EPHY_SETTINGS_UI,
+ EPHY_PREFS_UI_TABS_BAR_VISIBILITY_POLICY);
- if (mode != EPHY_EMBED_SHELL_MODE_APPLICATION &&
- ((policy == EPHY_PREFS_UI_TABS_BAR_VISIBILITY_POLICY_MORE_THAN_ONE && num > 1) ||
- policy == EPHY_PREFS_UI_TABS_BAR_VISIBILITY_POLICY_ALWAYS))
- show_tabs = TRUE;
+ if (mode != EPHY_EMBED_SHELL_MODE_APPLICATION &&
+ ((policy == EPHY_PREFS_UI_TABS_BAR_VISIBILITY_POLICY_MORE_THAN_ONE && num > 1) ||
+ policy == EPHY_PREFS_UI_TABS_BAR_VISIBILITY_POLICY_ALWAYS))
+ show_tabs = TRUE;
- /* Only show the tabs when the "tabs-allowed" property is TRUE. */
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nb), nb->tabs_allowed && show_tabs);
+ /* Only show the tabs when the "tabs-allowed" property is TRUE. */
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nb), nb->tabs_allowed && show_tabs);
}
static void
-show_tabs_changed_cb (GSettings *settings,
- char *key,
- EphyNotebook *nb)
+show_tabs_changed_cb (GSettings *settings,
+ char *key,
+ EphyNotebook *nb)
{
- update_tabs_visibility (nb, FALSE);
+ update_tabs_visibility (nb, FALSE);
}
static void
ephy_notebook_init (EphyNotebook *notebook)
{
- GtkWidget *widget = GTK_WIDGET (notebook);
- GtkNotebook *gnotebook = GTK_NOTEBOOK (notebook);
-
- gtk_notebook_set_scrollable (gnotebook, TRUE);
- gtk_notebook_set_show_border (gnotebook, FALSE);
- gtk_notebook_set_show_tabs (gnotebook, FALSE);
- gtk_notebook_set_group_name (gnotebook, EPHY_NOTEBOOK_TAB_GROUP_ID);
-
- notebook->tabs_allowed = TRUE;
-
- g_signal_connect (notebook, "button-press-event",
- (GCallback)button_press_cb, NULL);
- g_signal_connect_after (notebook, "switch-page",
- G_CALLBACK (ephy_notebook_switch_page_cb),
- NULL);
-
- /* Set up drag-and-drop target */
- g_signal_connect (notebook, "drag-data-received",
- G_CALLBACK (notebook_drag_data_received_cb),
- NULL);
- gtk_drag_dest_set (widget, 0,
- url_drag_types, G_N_ELEMENTS (url_drag_types),
- GDK_ACTION_MOVE | GDK_ACTION_COPY);
- gtk_drag_dest_add_text_targets (widget);
-
- g_signal_connect (EPHY_SETTINGS_UI,
- "changed::" EPHY_PREFS_UI_TABS_BAR_VISIBILITY_POLICY,
- G_CALLBACK (show_tabs_changed_cb), notebook);
+ GtkWidget *widget = GTK_WIDGET (notebook);
+ GtkNotebook *gnotebook = GTK_NOTEBOOK (notebook);
+
+ gtk_notebook_set_scrollable (gnotebook, TRUE);
+ gtk_notebook_set_show_border (gnotebook, FALSE);
+ gtk_notebook_set_show_tabs (gnotebook, FALSE);
+ gtk_notebook_set_group_name (gnotebook, EPHY_NOTEBOOK_TAB_GROUP_ID);
+
+ notebook->tabs_allowed = TRUE;
+
+ g_signal_connect (notebook, "button-press-event",
+ (GCallback)button_press_cb, NULL);
+ g_signal_connect_after (notebook, "switch-page",
+ G_CALLBACK (ephy_notebook_switch_page_cb),
+ NULL);
+
+ /* Set up drag-and-drop target */
+ g_signal_connect (notebook, "drag-data-received",
+ G_CALLBACK (notebook_drag_data_received_cb),
+ NULL);
+ gtk_drag_dest_set (widget, 0,
+ url_drag_types, G_N_ELEMENTS (url_drag_types),
+ GDK_ACTION_MOVE | GDK_ACTION_COPY);
+ gtk_drag_dest_add_text_targets (widget);
+
+ g_signal_connect (EPHY_SETTINGS_UI,
+ "changed::" EPHY_PREFS_UI_TABS_BAR_VISIBILITY_POLICY,
+ G_CALLBACK (show_tabs_changed_cb), notebook);
}
static void
ephy_notebook_finalize (GObject *object)
{
- EphyNotebook *notebook = EPHY_NOTEBOOK (object);
+ EphyNotebook *notebook = EPHY_NOTEBOOK (object);
- g_signal_handlers_disconnect_by_func (EPHY_SETTINGS_UI,
- show_tabs_changed_cb,
- notebook);
- g_list_free (notebook->focused_pages);
+ g_signal_handlers_disconnect_by_func (EPHY_SETTINGS_UI,
+ show_tabs_changed_cb,
+ notebook);
+ g_list_free (notebook->focused_pages);
- G_OBJECT_CLASS (ephy_notebook_parent_class)->finalize (object);
+ G_OBJECT_CLASS (ephy_notebook_parent_class)->finalize (object);
}
static void
sync_load_status (EphyWebView *view, GParamSpec *pspec, GtkWidget *proxy)
{
- GtkWidget *spinner, *icon;
- EphyEmbed *embed;
-
- spinner = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "spinner"));
- icon = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "icon"));
- g_return_if_fail (spinner != NULL && icon != NULL);
-
- embed = EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (view);
- if (ephy_web_view_is_loading (view) && !ephy_embed_has_load_pending (embed))
- {
- gtk_widget_hide (icon);
- gtk_widget_show (spinner);
- gtk_spinner_start (GTK_SPINNER (spinner));
- }
- else
- {
- gtk_spinner_stop (GTK_SPINNER (spinner));
- gtk_widget_hide (spinner);
- gtk_widget_show (icon);
- }
+ GtkWidget *spinner, *icon;
+ EphyEmbed *embed;
+
+ spinner = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "spinner"));
+ icon = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "icon"));
+ g_return_if_fail (spinner != NULL && icon != NULL);
+
+ embed = EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (view);
+ if (ephy_web_view_is_loading (view) && !ephy_embed_has_load_pending (embed)) {
+ gtk_widget_hide (icon);
+ gtk_widget_show (spinner);
+ gtk_spinner_start (GTK_SPINNER (spinner));
+ } else {
+ gtk_spinner_stop (GTK_SPINNER (spinner));
+ gtk_widget_hide (spinner);
+ gtk_widget_show (icon);
+ }
}
static void
load_changed_cb (EphyWebView *view, WebKitLoadEvent load_event, GtkWidget *proxy)
{
- sync_load_status (view, NULL, proxy);
+ sync_load_status (view, NULL, proxy);
}
static void
sync_icon (EphyWebView *view,
- GParamSpec *pspec,
- GtkImage *icon)
+ GParamSpec *pspec,
+ GtkImage *icon)
{
- gtk_image_set_from_pixbuf (icon, ephy_web_view_get_icon (view));
+ gtk_image_set_from_pixbuf (icon, ephy_web_view_get_icon (view));
}
static void
sync_label (EphyEmbed *embed, GParamSpec *pspec, GtkWidget *label)
{
- const char *title;
+ const char *title;
- title = ephy_embed_get_title (embed);
- gtk_label_set_text (GTK_LABEL (label), title);
- gtk_widget_set_tooltip_text (label, title);
+ title = ephy_embed_get_title (embed);
+ gtk_label_set_text (GTK_LABEL (label), title);
+ gtk_widget_set_tooltip_text (label, title);
}
static void
sync_is_playing_audio (WebKitWebView *view,
- GParamSpec *pspec,
- GtkWidget *speaker_icon)
+ GParamSpec *pspec,
+ GtkWidget *speaker_icon)
{
- gtk_widget_set_visible (speaker_icon, webkit_web_view_is_playing_audio (view));
+ gtk_widget_set_visible (speaker_icon, webkit_web_view_is_playing_audio (view));
}
static void
close_button_clicked_cb (GtkWidget *widget, GtkWidget *tab)
{
- GtkWidget *notebook;
+ GtkWidget *notebook;
- notebook = gtk_widget_get_parent (tab);
- g_signal_emit (notebook, signals[TAB_CLOSE_REQUEST], 0, tab);
+ notebook = gtk_widget_get_parent (tab);
+ g_signal_emit (notebook, signals[TAB_CLOSE_REQUEST], 0, tab);
}
static void
tab_label_style_set_cb (GtkWidget *hbox,
- GtkStyle *previous_style,
- gpointer user_data)
-{
- PangoFontMetrics *metrics;
- PangoContext *context;
- GtkStyleContext *style;
- PangoFontDescription *font_desc;
- GtkWidget *button;
- int char_width, h, w;
-
- context = gtk_widget_get_pango_context (hbox);
- style = gtk_widget_get_style_context (hbox);
- gtk_style_context_get (style, gtk_style_context_get_state (style),
- "font", &font_desc, NULL);
- metrics = pango_context_get_metrics (context,
- font_desc,
- pango_context_get_language (context));
- pango_font_description_free (font_desc);
- char_width = pango_font_metrics_get_approximate_digit_width (metrics);
- pango_font_metrics_unref (metrics);
-
- gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (hbox),
- GTK_ICON_SIZE_MENU, &w, &h);
-
- gtk_widget_set_size_request
- (hbox, TAB_WIDTH_N_CHARS * PANGO_PIXELS(char_width) + 2 * w, -1);
-
- button = g_object_get_data (G_OBJECT (hbox), "close-button");
- gtk_widget_set_size_request (button, w + 2, h + 2);
+ GtkStyle *previous_style,
+ gpointer user_data)
+{
+ PangoFontMetrics *metrics;
+ PangoContext *context;
+ GtkStyleContext *style;
+ PangoFontDescription *font_desc;
+ GtkWidget *button;
+ int char_width, h, w;
+
+ context = gtk_widget_get_pango_context (hbox);
+ style = gtk_widget_get_style_context (hbox);
+ gtk_style_context_get (style, gtk_style_context_get_state (style),
+ "font", &font_desc, NULL);
+ metrics = pango_context_get_metrics (context,
+ font_desc,
+ pango_context_get_language (context));
+ pango_font_description_free (font_desc);
+ char_width = pango_font_metrics_get_approximate_digit_width (metrics);
+ pango_font_metrics_unref (metrics);
+
+ gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (hbox),
+ GTK_ICON_SIZE_MENU, &w, &h);
+
+ gtk_widget_set_size_request
+ (hbox, TAB_WIDTH_N_CHARS * PANGO_PIXELS (char_width) + 2 * w, -1);
+
+ button = g_object_get_data (G_OBJECT (hbox), "close-button");
+ gtk_widget_set_size_request (button, w + 2, h + 2);
}
static GtkWidget *
build_tab_label (EphyNotebook *nb, EphyEmbed *embed)
{
- GtkWidget *hbox, *label, *close_button, *image, *spinner, *icon, *speaker_icon;
- GtkWidget *box;
- EphyWebView *view;
-
- box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
- gtk_widget_show (box);
-
- /* set hbox spacing and label padding (see below) so that there's an
- * equal amount of space around the label */
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_widget_show (hbox);
- gtk_widget_set_halign (hbox, GTK_ALIGN_CENTER);
- gtk_box_pack_start (GTK_BOX (box), hbox, TRUE, TRUE, 0);
-
- /* setup load feedback */
- spinner = gtk_spinner_new ();
- gtk_box_pack_start (GTK_BOX (hbox), spinner, FALSE, FALSE, 0);
-
- /* setup site icon, empty by default */
- icon = gtk_image_new ();
- gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
- /* don't show the icon */
-
- /* setup label */
- label = gtk_label_new (NULL);
- gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
- gtk_label_set_single_line_mode (GTK_LABEL (label), TRUE);
- gtk_misc_set_padding (GTK_MISC (label), 0, 0);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- gtk_widget_show (label);
-
- /* setup speaker icon */
- speaker_icon = gtk_image_new_from_icon_name ("audio-volume-high-symbolic",
- GTK_ICON_SIZE_MENU);
- gtk_box_pack_start (GTK_BOX (hbox), speaker_icon, FALSE, FALSE, 0);
-
- /* setup close button */
- close_button = gtk_button_new ();
- gtk_button_set_relief (GTK_BUTTON (close_button),
- GTK_RELIEF_NONE);
- /* don't allow focus on the close button */
- gtk_button_set_focus_on_click (GTK_BUTTON (close_button), FALSE);
-
- gtk_widget_set_name (close_button, "ephy-tab-close-button");
-
- image = gtk_image_new_from_icon_name ("window-close-symbolic",
- GTK_ICON_SIZE_MENU);
- gtk_widget_set_tooltip_text (close_button, _("Close tab"));
- g_signal_connect (close_button, "clicked",
- G_CALLBACK (close_button_clicked_cb), embed);
-
- gtk_container_add (GTK_CONTAINER (close_button), image);
- gtk_widget_show (image);
-
- gtk_box_pack_start (GTK_BOX (box), close_button, FALSE, FALSE, 0);
- gtk_widget_show (close_button);
-
- /* Set minimal size */
- g_signal_connect (box, "style-set",
- G_CALLBACK (tab_label_style_set_cb), NULL);
-
- /* Set up drag-and-drop target */
- g_signal_connect (box, "drag-data-received",
- G_CALLBACK (notebook_drag_data_received_cb), embed);
- gtk_drag_dest_set (box, GTK_DEST_DEFAULT_ALL,
- url_drag_types, G_N_ELEMENTS (url_drag_types),
- GDK_ACTION_MOVE | GDK_ACTION_COPY);
- gtk_drag_dest_add_text_targets (box);
-
- g_object_set_data (G_OBJECT (box), "label", label);
- g_object_set_data (G_OBJECT (box), "spinner", spinner);
- g_object_set_data (G_OBJECT (box), "icon", icon);
- g_object_set_data (G_OBJECT (box), "close-button", close_button);
- g_object_set_data (G_OBJECT (box), "speaker-icon", speaker_icon);
-
- /* Hook the label up to the tab properties */
- view = ephy_embed_get_web_view (embed);
- sync_icon (view, NULL, GTK_IMAGE (icon));
- sync_label (embed, NULL, label);
- sync_load_status (view, NULL, box);
- sync_is_playing_audio (WEBKIT_WEB_VIEW (view), NULL, speaker_icon);
-
- g_signal_connect_object (view, "notify::icon",
- G_CALLBACK (sync_icon), icon, 0);
- g_signal_connect_object (embed, "notify::title",
- G_CALLBACK (sync_label), label, 0);
- g_signal_connect_object (view, "load-changed",
- G_CALLBACK (load_changed_cb), box, 0);
- g_signal_connect_object (view, "notify::is-playing-audio",
- G_CALLBACK (sync_is_playing_audio), speaker_icon, 0);
- return box;
+ GtkWidget *hbox, *label, *close_button, *image, *spinner, *icon, *speaker_icon;
+ GtkWidget *box;
+ EphyWebView *view;
+
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
+ gtk_widget_show (box);
+
+ /* set hbox spacing and label padding (see below) so that there's an
+ * equal amount of space around the label */
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ gtk_widget_show (hbox);
+ gtk_widget_set_halign (hbox, GTK_ALIGN_CENTER);
+ gtk_box_pack_start (GTK_BOX (box), hbox, TRUE, TRUE, 0);
+
+ /* setup load feedback */
+ spinner = gtk_spinner_new ();
+ gtk_box_pack_start (GTK_BOX (hbox), spinner, FALSE, FALSE, 0);
+
+ /* setup site icon, empty by default */
+ icon = gtk_image_new ();
+ gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
+ /* don't show the icon */
+
+ /* setup label */
+ label = gtk_label_new (NULL);
+ gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
+ gtk_label_set_single_line_mode (GTK_LABEL (label), TRUE);
+ gtk_misc_set_padding (GTK_MISC (label), 0, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_widget_show (label);
+
+ /* setup speaker icon */
+ speaker_icon = gtk_image_new_from_icon_name ("audio-volume-high-symbolic",
+ GTK_ICON_SIZE_MENU);
+ gtk_box_pack_start (GTK_BOX (hbox), speaker_icon, FALSE, FALSE, 0);
+
+ /* setup close button */
+ close_button = gtk_button_new ();
+ gtk_button_set_relief (GTK_BUTTON (close_button),
+ GTK_RELIEF_NONE);
+ /* don't allow focus on the close button */
+ gtk_button_set_focus_on_click (GTK_BUTTON (close_button), FALSE);
+
+ gtk_widget_set_name (close_button, "ephy-tab-close-button");
+
+ image = gtk_image_new_from_icon_name ("window-close-symbolic",
+ GTK_ICON_SIZE_MENU);
+ gtk_widget_set_tooltip_text (close_button, _("Close tab"));
+ g_signal_connect (close_button, "clicked",
+ G_CALLBACK (close_button_clicked_cb), embed);
+
+ gtk_container_add (GTK_CONTAINER (close_button), image);
+ gtk_widget_show (image);
+
+ gtk_box_pack_start (GTK_BOX (box), close_button, FALSE, FALSE, 0);
+ gtk_widget_show (close_button);
+
+ /* Set minimal size */
+ g_signal_connect (box, "style-set",
+ G_CALLBACK (tab_label_style_set_cb), NULL);
+
+ /* Set up drag-and-drop target */
+ g_signal_connect (box, "drag-data-received",
+ G_CALLBACK (notebook_drag_data_received_cb), embed);
+ gtk_drag_dest_set (box, GTK_DEST_DEFAULT_ALL,
+ url_drag_types, G_N_ELEMENTS (url_drag_types),
+ GDK_ACTION_MOVE | GDK_ACTION_COPY);
+ gtk_drag_dest_add_text_targets (box);
+
+ g_object_set_data (G_OBJECT (box), "label", label);
+ g_object_set_data (G_OBJECT (box), "spinner", spinner);
+ g_object_set_data (G_OBJECT (box), "icon", icon);
+ g_object_set_data (G_OBJECT (box), "close-button", close_button);
+ g_object_set_data (G_OBJECT (box), "speaker-icon", speaker_icon);
+
+ /* Hook the label up to the tab properties */
+ view = ephy_embed_get_web_view (embed);
+ sync_icon (view, NULL, GTK_IMAGE (icon));
+ sync_label (embed, NULL, label);
+ sync_load_status (view, NULL, box);
+ sync_is_playing_audio (WEBKIT_WEB_VIEW (view), NULL, speaker_icon);
+
+ g_signal_connect_object (view, "notify::icon",
+ G_CALLBACK (sync_icon), icon, 0);
+ g_signal_connect_object (embed, "notify::title",
+ G_CALLBACK (sync_label), label, 0);
+ g_signal_connect_object (view, "load-changed",
+ G_CALLBACK (load_changed_cb), box, 0);
+ g_signal_connect_object (view, "notify::is-playing-audio",
+ G_CALLBACK (sync_is_playing_audio), speaker_icon, 0);
+ return box;
}
void
ephy_notebook_set_tabs_allowed (EphyNotebook *nb,
- gboolean tabs_allowed)
+ gboolean tabs_allowed)
{
- nb->tabs_allowed = tabs_allowed != FALSE;
+ nb->tabs_allowed = tabs_allowed != FALSE;
- update_tabs_visibility (nb, FALSE);
+ update_tabs_visibility (nb, FALSE);
- g_object_notify_by_pspec (G_OBJECT (nb), obj_properties[PROP_TABS_ALLOWED]);
+ g_object_notify_by_pspec (G_OBJECT (nb), obj_properties[PROP_TABS_ALLOWED]);
}
static int
ephy_notebook_insert_page (GtkNotebook *gnotebook,
- GtkWidget *tab_widget,
- GtkWidget *tab_label,
- GtkWidget *menu_label,
- int position)
+ GtkWidget *tab_widget,
+ GtkWidget *tab_label,
+ GtkWidget *menu_label,
+ int position)
{
- EphyNotebook *notebook = EPHY_NOTEBOOK (gnotebook);
+ EphyNotebook *notebook = EPHY_NOTEBOOK (gnotebook);
- /* Destroy passed-in tab label */
- if (tab_label != NULL)
- {
- g_object_ref_sink (tab_label);
- g_object_unref (tab_label);
- }
+ /* Destroy passed-in tab label */
+ if (tab_label != NULL) {
+ g_object_ref_sink (tab_label);
+ g_object_unref (tab_label);
+ }
- g_assert (EPHY_IS_EMBED (tab_widget));
+ g_assert (EPHY_IS_EMBED (tab_widget));
- tab_label = build_tab_label (notebook, EPHY_EMBED (tab_widget));
+ tab_label = build_tab_label (notebook, EPHY_EMBED (tab_widget));
- update_tabs_visibility (notebook, TRUE);
+ update_tabs_visibility (notebook, TRUE);
- position = GTK_NOTEBOOK_CLASS (ephy_notebook_parent_class)->insert_page (gnotebook,
- tab_widget,
- tab_label,
- menu_label,
- position);
+ position = GTK_NOTEBOOK_CLASS (ephy_notebook_parent_class)->insert_page (gnotebook,
+ tab_widget,
+ tab_label,
+ menu_label,
+ position);
- gtk_notebook_set_tab_reorderable (gnotebook, tab_widget, TRUE);
- gtk_notebook_set_tab_detachable (gnotebook, tab_widget, TRUE);
- gtk_container_child_set (GTK_CONTAINER (gnotebook),
- GTK_WIDGET (tab_widget),
- "tab-expand", TRUE,
- NULL);
+ gtk_notebook_set_tab_reorderable (gnotebook, tab_widget, TRUE);
+ gtk_notebook_set_tab_detachable (gnotebook, tab_widget, TRUE);
+ gtk_container_child_set (GTK_CONTAINER (gnotebook),
+ GTK_WIDGET (tab_widget),
+ "tab-expand", TRUE,
+ NULL);
- return position;
+ return position;
}
int
ephy_notebook_add_tab (EphyNotebook *notebook,
- EphyEmbed *embed,
- int position,
- gboolean jump_to)
+ EphyEmbed *embed,
+ int position,
+ gboolean jump_to)
{
- GtkNotebook *gnotebook = GTK_NOTEBOOK (notebook);
+ GtkNotebook *gnotebook = GTK_NOTEBOOK (notebook);
- g_return_val_if_fail (EPHY_IS_NOTEBOOK (notebook), -1);
+ g_return_val_if_fail (EPHY_IS_NOTEBOOK (notebook), -1);
- position = gtk_notebook_insert_page (GTK_NOTEBOOK (notebook),
- GTK_WIDGET (embed),
- NULL,
- position);
+ position = gtk_notebook_insert_page (GTK_NOTEBOOK (notebook),
+ GTK_WIDGET (embed),
+ NULL,
+ position);
- gtk_container_child_set (GTK_CONTAINER (notebook),
- GTK_WIDGET (embed),
- "tab-expand", TRUE,
- NULL);
+ gtk_container_child_set (GTK_CONTAINER (notebook),
+ GTK_WIDGET (embed),
+ "tab-expand", TRUE,
+ NULL);
- if (jump_to)
- {
- gtk_notebook_set_current_page (gnotebook, position);
- g_object_set_data (G_OBJECT (embed), "jump_to",
- GINT_TO_POINTER (jump_to));
- }
+ if (jump_to) {
+ gtk_notebook_set_current_page (gnotebook, position);
+ g_object_set_data (G_OBJECT (embed), "jump_to",
+ GINT_TO_POINTER (jump_to));
+ }
- return position;
+ return position;
}
static void
smart_tab_switching_on_closure (EphyNotebook *notebook,
- GtkWidget *tab)
-{
- gboolean jump_to;
-
- jump_to = GPOINTER_TO_INT (g_object_get_data
- (G_OBJECT (tab), "jump_to"));
-
- if (!jump_to || !notebook->focused_pages)
- {
- gtk_notebook_next_page (GTK_NOTEBOOK (notebook));
- }
- else
- {
- GList *l;
- GtkWidget *child;
- int page_num;
-
- /* activate the last focused tab */
- l = g_list_last (notebook->focused_pages);
- child = GTK_WIDGET (l->data);
- page_num = gtk_notebook_page_num (GTK_NOTEBOOK (notebook),
- child);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook),
- page_num);
- }
+ GtkWidget *tab)
+{
+ gboolean jump_to;
+
+ jump_to = GPOINTER_TO_INT (g_object_get_data
+ (G_OBJECT (tab), "jump_to"));
+
+ if (!jump_to || !notebook->focused_pages) {
+ gtk_notebook_next_page (GTK_NOTEBOOK (notebook));
+ } else {
+ GList *l;
+ GtkWidget *child;
+ int page_num;
+
+ /* activate the last focused tab */
+ l = g_list_last (notebook->focused_pages);
+ child = GTK_WIDGET (l->data);
+ page_num = gtk_notebook_page_num (GTK_NOTEBOOK (notebook),
+ child);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook),
+ page_num);
+ }
}
static void
ephy_notebook_remove (GtkContainer *container,
- GtkWidget *tab_widget)
+ GtkWidget *tab_widget)
{
- GtkNotebook *gnotebook = GTK_NOTEBOOK (container);
- EphyNotebook *notebook = EPHY_NOTEBOOK (container);
- GtkWidget *tab_label, *tab_label_label, *tab_label_icon, *tab_label_speaker_icon;
- int position, curr;
- EphyWebView *view;
-
- if (!EPHY_IS_EMBED (tab_widget))
- return;
-
- /* Remove the page from the focused pages list */
- notebook->focused_pages = g_list_remove (notebook->focused_pages, tab_widget);
-
- position = gtk_notebook_page_num (gnotebook, tab_widget);
- curr = gtk_notebook_get_current_page (gnotebook);
-
- if (position == curr)
- {
- smart_tab_switching_on_closure (notebook, tab_widget);
- }
-
- /* Prepare tab label for destruction */
- tab_label = gtk_notebook_get_tab_label (gnotebook, tab_widget);
- tab_label_icon = g_object_get_data (G_OBJECT (tab_label), "icon");
- tab_label_label = g_object_get_data (G_OBJECT (tab_label), "label");
- tab_label_speaker_icon = g_object_get_data (G_OBJECT (tab_label), "speaker-icon");
-
- view = ephy_embed_get_web_view (EPHY_EMBED (tab_widget));
-
- g_signal_handlers_disconnect_by_func
- (view, G_CALLBACK (sync_icon), tab_label_icon);
- g_signal_handlers_disconnect_by_func
- (tab_widget, G_CALLBACK (sync_label), tab_label_label);
- g_signal_handlers_disconnect_by_func
- (view, G_CALLBACK (sync_load_status), tab_label);
- g_signal_handlers_disconnect_by_func
- (view, G_CALLBACK (sync_is_playing_audio), tab_label_speaker_icon);
-
- GTK_CONTAINER_CLASS (ephy_notebook_parent_class)->remove (container, tab_widget);
-
- update_tabs_visibility (notebook, FALSE);
+ GtkNotebook *gnotebook = GTK_NOTEBOOK (container);
+ EphyNotebook *notebook = EPHY_NOTEBOOK (container);
+ GtkWidget *tab_label, *tab_label_label, *tab_label_icon, *tab_label_speaker_icon;
+ int position, curr;
+ EphyWebView *view;
+
+ if (!EPHY_IS_EMBED (tab_widget))
+ return;
+
+ /* Remove the page from the focused pages list */
+ notebook->focused_pages = g_list_remove (notebook->focused_pages, tab_widget);
+
+ position = gtk_notebook_page_num (gnotebook, tab_widget);
+ curr = gtk_notebook_get_current_page (gnotebook);
+
+ if (position == curr) {
+ smart_tab_switching_on_closure (notebook, tab_widget);
+ }
+
+ /* Prepare tab label for destruction */
+ tab_label = gtk_notebook_get_tab_label (gnotebook, tab_widget);
+ tab_label_icon = g_object_get_data (G_OBJECT (tab_label), "icon");
+ tab_label_label = g_object_get_data (G_OBJECT (tab_label), "label");
+ tab_label_speaker_icon = g_object_get_data (G_OBJECT (tab_label), "speaker-icon");
+
+ view = ephy_embed_get_web_view (EPHY_EMBED (tab_widget));
+
+ g_signal_handlers_disconnect_by_func
+ (view, G_CALLBACK (sync_icon), tab_label_icon);
+ g_signal_handlers_disconnect_by_func
+ (tab_widget, G_CALLBACK (sync_label), tab_label_label);
+ g_signal_handlers_disconnect_by_func
+ (view, G_CALLBACK (sync_load_status), tab_label);
+ g_signal_handlers_disconnect_by_func
+ (view, G_CALLBACK (sync_is_playing_audio), tab_label_speaker_icon);
+
+ GTK_CONTAINER_CLASS (ephy_notebook_parent_class)->remove (container, tab_widget);
+
+ update_tabs_visibility (notebook, FALSE);
}
/**
* ephy_notebook_next_page:
* @notebook: an #EphyNotebook
- *
+ *
* Advances to the next page in the @notebook. Note that unlike
* gtk_notebook_next_page() this method will wrap around if
* #GtkSettings:gtk-keynav-wrap-around is set.
@@ -825,25 +795,25 @@ ephy_notebook_remove (GtkContainer *container,
void
ephy_notebook_next_page (EphyNotebook *notebook)
{
- gint current_page, n_pages;
-
- g_return_if_fail (EPHY_IS_NOTEBOOK (notebook));
-
- current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
- n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook));
-
- if (current_page < n_pages - 1)
- gtk_notebook_next_page (GTK_NOTEBOOK (notebook));
- else {
- gboolean wrap_around;
-
- g_object_get (gtk_widget_get_settings (GTK_WIDGET (notebook)),
- "gtk-keynav-wrap-around", &wrap_around,
- NULL);
-
- if (wrap_around)
- gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), 0);
- }
+ gint current_page, n_pages;
+
+ g_return_if_fail (EPHY_IS_NOTEBOOK (notebook));
+
+ current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
+ n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook));
+
+ if (current_page < n_pages - 1)
+ gtk_notebook_next_page (GTK_NOTEBOOK (notebook));
+ else {
+ gboolean wrap_around;
+
+ g_object_get (gtk_widget_get_settings (GTK_WIDGET (notebook)),
+ "gtk-keynav-wrap-around", &wrap_around,
+ NULL);
+
+ if (wrap_around)
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), 0);
+ }
}
/**
@@ -857,22 +827,22 @@ ephy_notebook_next_page (EphyNotebook *notebook)
void
ephy_notebook_prev_page (EphyNotebook *notebook)
{
- gint current_page;
-
- g_return_if_fail (EPHY_IS_NOTEBOOK (notebook));
-
- current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
-
- if (current_page > 0)
- gtk_notebook_prev_page (GTK_NOTEBOOK (notebook));
- else {
- gboolean wrap_around;
-
- g_object_get (gtk_widget_get_settings (GTK_WIDGET (notebook)),
- "gtk-keynav-wrap-around", &wrap_around,
- NULL);
-
- if (wrap_around)
- gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), -1);
- }
+ gint current_page;
+
+ g_return_if_fail (EPHY_IS_NOTEBOOK (notebook));
+
+ current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
+
+ if (current_page > 0)
+ gtk_notebook_prev_page (GTK_NOTEBOOK (notebook));
+ else {
+ gboolean wrap_around;
+
+ g_object_get (gtk_widget_get_settings (GTK_WIDGET (notebook)),
+ "gtk-keynav-wrap-around", &wrap_around,
+ NULL);
+
+ if (wrap_around)
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), -1);
+ }
}
diff --git a/src/ephy-search-provider-main.c b/src/ephy-search-provider-main.c
index adab134..a2b2d40 100644
--- a/src/ephy-search-provider-main.c
+++ b/src/ephy-search-provider-main.c
@@ -25,7 +25,7 @@
#include <glib/gi18n.h>
#include <locale.h>
-gint main (gint argc, gchar** argv)
+gint main (gint argc, gchar **argv)
{
EphySearchProvider *search_provider;
int status;
diff --git a/src/ephy-search-provider.c b/src/ephy-search-provider.c
index 3db9817..e1231dc 100644
--- a/src/ephy-search-provider.c
+++ b/src/ephy-search-provider.c
@@ -30,8 +30,7 @@
#include <gio/gdesktopappinfo.h>
#include <libsoup/soup.h>
-struct _EphySearchProvider
-{
+struct _EphySearchProvider {
GApplication parent_instance;
EphyShellSearchProvider2 *skeleton;
@@ -43,8 +42,7 @@ struct _EphySearchProvider
EphyCompletionModel *model;
};
-struct _EphySearchProviderClass
-{
+struct _EphySearchProviderClass {
GApplicationClass parent_class;
};
@@ -54,9 +52,9 @@ G_DEFINE_TYPE (EphySearchProvider, ephy_search_provider, G_TYPE_APPLICATION)
static void
on_model_updated (EphyHistoryService *service,
- gboolean success,
- gpointer result_data,
- gpointer user_data)
+ gboolean success,
+ gpointer result_data,
+ gpointer user_data)
{
GTask *task = user_data;
EphySearchProvider *self = g_task_get_source_object (task);
@@ -84,7 +82,7 @@ on_model_updated (EphyHistoryService *service,
g_task_return_pointer (task,
g_ptr_array_free (results, FALSE),
- (GDestroyNotify) g_strfreev);
+ (GDestroyNotify)g_strfreev);
}
static char **
@@ -96,11 +94,11 @@ gather_results_finish (EphySearchProvider *self,
}
static void
-gather_results_async (EphySearchProvider *self,
- char **terms,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+gather_results_async (EphySearchProvider *self,
+ char **terms,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GTask *task;
char *search_string;
@@ -139,10 +137,10 @@ complete_request (GObject *object,
}
static gboolean
-handle_get_initial_result_set (EphyShellSearchProvider2 *skeleton,
- GDBusMethodInvocation *invocation,
- char **terms,
- EphySearchProvider *self)
+handle_get_initial_result_set (EphyShellSearchProvider2 *skeleton,
+ GDBusMethodInvocation *invocation,
+ char **terms,
+ EphySearchProvider *self)
{
g_application_hold (G_APPLICATION (self));
g_cancellable_reset (self->cancellable);
@@ -154,11 +152,11 @@ handle_get_initial_result_set (EphyShellSearchProvider2 *skeleton,
}
static gboolean
-handle_get_subsearch_result_set (EphyShellSearchProvider2 *skeleton,
- GDBusMethodInvocation *invocation,
- char **previous_results,
- char **terms,
- EphySearchProvider *self)
+handle_get_subsearch_result_set (EphyShellSearchProvider2 *skeleton,
+ GDBusMethodInvocation *invocation,
+ char **previous_results,
+ char **terms,
+ EphySearchProvider *self)
{
g_application_hold (G_APPLICATION (self));
g_cancellable_reset (self->cancellable);
@@ -170,10 +168,10 @@ handle_get_subsearch_result_set (EphyShellSearchProvider2 *skeleton,
}
static gboolean
-handle_get_result_metas (EphyShellSearchProvider2 *skeleton,
- GDBusMethodInvocation *invocation,
- char **results,
- EphySearchProvider *self)
+handle_get_result_metas (EphyShellSearchProvider2 *skeleton,
+ GDBusMethodInvocation *invocation,
+ char **results,
+ EphySearchProvider *self)
{
GtkTreeModel *model = GTK_TREE_MODEL (self->model);
GtkTreeIter iter;
@@ -188,68 +186,67 @@ handle_get_result_metas (EphyShellSearchProvider2 *skeleton,
g_variant_builder_init (&builder, G_VARIANT_TYPE ("aa{sv}"));
- for (i = 0; results[i]; i++)
- {
- if (g_str_has_prefix (results[i], "special:search:")) {
- g_variant_builder_open (&builder, G_VARIANT_TYPE ("a{sv}"));
- g_variant_builder_add (&builder, "{sv}",
- "id", g_variant_new_string ("special:search"));
- g_variant_builder_add (&builder, "{sv}",
- "name", g_variant_new_take_string (g_strdup_printf(_("Search the Web for %s"),
- results[i] +
strlen("special:search:"))));
- g_variant_builder_add (&builder, "{sv}",
- "gicon", g_variant_new_string ("web-browser"));
- g_variant_builder_close (&builder);
- continue;
- }
-
- if (!gtk_tree_model_get_iter_from_string (model, &iter, results[i]))
- continue;
-
- gtk_tree_model_get (model, &iter,
- EPHY_COMPLETION_TEXT_COL, &name,
- EPHY_COMPLETION_URL_COL, &url,
- EPHY_COMPLETION_FAVICON_COL, &favicon,
- EPHY_COMPLETION_EXTRA_COL, &is_bookmark,
- -1);
-
+ for (i = 0; results[i]; i++) {
+ if (g_str_has_prefix (results[i], "special:search:")) {
g_variant_builder_open (&builder, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_add (&builder, "{sv}",
- "id", g_variant_new_string (url));
+ "id", g_variant_new_string ("special:search"));
+ g_variant_builder_add (&builder, "{sv}",
+ "name", g_variant_new_take_string (g_strdup_printf (_("Search the Web for %s"),
+ results[i] + strlen
("special:search:"))));
g_variant_builder_add (&builder, "{sv}",
- "name", g_variant_new_string (name));
+ "gicon", g_variant_new_string ("web-browser"));
+ g_variant_builder_close (&builder);
+ continue;
+ }
- if (favicon == NULL) {
- char *type;
+ if (!gtk_tree_model_get_iter_from_string (model, &iter, results[i]))
+ continue;
- type = g_content_type_from_mime_type ("text/html");
- favicon = g_content_type_get_icon (type);
+ gtk_tree_model_get (model, &iter,
+ EPHY_COMPLETION_TEXT_COL, &name,
+ EPHY_COMPLETION_URL_COL, &url,
+ EPHY_COMPLETION_FAVICON_COL, &favicon,
+ EPHY_COMPLETION_EXTRA_COL, &is_bookmark,
+ -1);
- if (is_bookmark) {
- GEmblem *emblem;
- GIcon *emblem_icon, *emblemed;
+ g_variant_builder_open (&builder, G_VARIANT_TYPE ("a{sv}"));
+ g_variant_builder_add (&builder, "{sv}",
+ "id", g_variant_new_string (url));
+ g_variant_builder_add (&builder, "{sv}",
+ "name", g_variant_new_string (name));
- emblem_icon = g_themed_icon_new ("emblem-favorite");
- emblem = g_emblem_new (emblem_icon);
+ if (favicon == NULL) {
+ char *type;
- emblemed = g_emblemed_icon_new (favicon, emblem);
+ type = g_content_type_from_mime_type ("text/html");
+ favicon = g_content_type_get_icon (type);
- g_object_unref (emblem);
- g_object_unref (emblem_icon);
- g_object_unref (favicon);
- favicon = emblemed;
- }
- }
+ if (is_bookmark) {
+ GEmblem *emblem;
+ GIcon *emblem_icon, *emblemed;
- g_variant_builder_add (&builder, "{sv}",
- "icon", g_icon_serialize (favicon));
- g_variant_builder_close (&builder);
+ emblem_icon = g_themed_icon_new ("emblem-favorite");
+ emblem = g_emblem_new (emblem_icon);
+
+ emblemed = g_emblemed_icon_new (favicon, emblem);
- g_object_unref (favicon);
- g_free (name);
- g_free (url);
+ g_object_unref (emblem);
+ g_object_unref (emblem_icon);
+ g_object_unref (favicon);
+ favicon = emblemed;
+ }
}
+ g_variant_builder_add (&builder, "{sv}",
+ "icon", g_icon_serialize (favicon));
+ g_variant_builder_close (&builder);
+
+ g_object_unref (favicon);
+ g_free (name);
+ g_free (url);
+ }
+
ephy_shell_search_provider2_complete_get_result_metas (skeleton,
invocation,
g_variant_builder_end (&builder));
@@ -260,8 +257,8 @@ handle_get_result_metas (EphyShellSearchProvider2 *skeleton,
}
static void
-launch_uri (const char *uri,
- guint timestamp)
+launch_uri (const char *uri,
+ guint timestamp)
{
char *str;
@@ -272,9 +269,9 @@ launch_uri (const char *uri,
}
static void
-launch_search (EphySearchProvider *self,
- char **terms,
- guint timestamp)
+launch_search (EphySearchProvider *self,
+ char **terms,
+ guint timestamp)
{
char *search_string, *url_search, *query_param, *effective_url;
@@ -305,12 +302,12 @@ launch_search (EphySearchProvider *self,
}
static gboolean
-handle_activate_result (EphyShellSearchProvider2 *skeleton,
- GDBusMethodInvocation *invocation,
- char *identifier,
- char **terms,
- guint timestamp,
- EphySearchProvider *self)
+handle_activate_result (EphyShellSearchProvider2 *skeleton,
+ GDBusMethodInvocation *invocation,
+ char *identifier,
+ char **terms,
+ guint timestamp,
+ EphySearchProvider *self)
{
g_application_hold (G_APPLICATION (self));
g_cancellable_cancel (self->cancellable);
@@ -327,11 +324,11 @@ handle_activate_result (EphyShellSearchProvider2 *skeleton,
}
static gboolean
-handle_launch_search (EphyShellSearchProvider2 *skeleton,
- GDBusMethodInvocation *invocation,
- char **terms,
- guint timestamp,
- EphySearchProvider *self)
+handle_launch_search (EphyShellSearchProvider2 *skeleton,
+ GDBusMethodInvocation *invocation,
+ char **terms,
+ guint timestamp,
+ EphySearchProvider *self)
{
g_application_hold (G_APPLICATION (self));
g_cancellable_cancel (self->cancellable);
diff --git a/src/ephy-session.c b/src/ephy-session.c
index 6622080..f836053 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -42,39 +42,35 @@
#include <libxml/tree.h>
#include <libxml/xmlwriter.h>
-typedef struct
-{
- EphyNotebook *notebook;
- gint ref_count;
+typedef struct {
+ EphyNotebook *notebook;
+ gint ref_count;
} NotebookTracker;
-typedef struct
-{
- NotebookTracker *notebook_tracker;
- int position;
- char *url;
- WebKitWebViewSessionState *state;
+typedef struct {
+ NotebookTracker *notebook_tracker;
+ int position;
+ char *url;
+ WebKitWebViewSessionState *state;
} ClosedTab;
-struct _EphySession
-{
- GObject parent_instance;
+struct _EphySession {
+ GObject parent_instance;
- GQueue *closed_tabs;
- guint save_source_id;
- GCancellable *save_cancellable;
- guint closing : 1;
- guint dont_save : 1;
+ GQueue *closed_tabs;
+ guint save_source_id;
+ GCancellable *save_cancellable;
+ guint closing : 1;
+ guint dont_save : 1;
};
-#define SESSION_STATE "type:session_state"
-#define MAX_CLOSED_TABS 10
+#define SESSION_STATE "type:session_state"
+#define MAX_CLOSED_TABS 10
-enum
-{
- PROP_0,
- PROP_CAN_UNDO_TAB_CLOSED,
- LAST_PROP
+enum {
+ PROP_0,
+ PROP_CAN_UNDO_TAB_CLOSED,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
@@ -88,378 +84,358 @@ G_DEFINE_TYPE (EphySession, ephy_session, G_TYPE_OBJECT)
static GFile *
get_session_file (const char *filename)
{
- GFile *file;
- char *path;
+ GFile *file;
+ char *path;
- if (filename == NULL)
- {
- return NULL;
- }
+ if (filename == NULL) {
+ return NULL;
+ }
- if (strcmp (filename, SESSION_STATE) == 0)
- {
- path = g_build_filename (ephy_dot_dir (),
- "session_state.xml",
- NULL);
- }
- else
- {
- path = g_strdup (filename);
- }
+ if (strcmp (filename, SESSION_STATE) == 0) {
+ path = g_build_filename (ephy_dot_dir (),
+ "session_state.xml",
+ NULL);
+ } else {
+ path = g_strdup (filename);
+ }
- file = g_file_new_for_path (path);
- g_free (path);
+ file = g_file_new_for_path (path);
+ g_free (path);
- return file;
+ return file;
}
static void
session_delete (EphySession *session)
{
- GFile *file;
+ GFile *file;
- file = get_session_file (SESSION_STATE);
- g_file_delete (file, NULL, NULL);
- g_object_unref (file);
+ file = get_session_file (SESSION_STATE);
+ g_file_delete (file, NULL, NULL);
+ g_object_unref (file);
}
static void
-load_changed_cb (WebKitWebView *view,
- WebKitLoadEvent load_event,
- EphySession *session)
+load_changed_cb (WebKitWebView *view,
+ WebKitLoadEvent load_event,
+ EphySession *session)
{
- if (!ephy_web_view_load_failed (EPHY_WEB_VIEW (view)))
- ephy_session_save (session);
+ if (!ephy_web_view_load_failed (EPHY_WEB_VIEW (view)))
+ ephy_session_save (session);
}
static void
notebook_tracker_set_notebook (NotebookTracker *tracker,
- EphyNotebook *notebook)
+ EphyNotebook *notebook)
{
- if (tracker->notebook == notebook)
- {
- return;
- }
+ if (tracker->notebook == notebook) {
+ return;
+ }
- if (tracker->notebook)
- {
- g_object_remove_weak_pointer (G_OBJECT (tracker->notebook), (gpointer *)&tracker->notebook);
- }
- tracker->notebook = notebook;
- if (tracker->notebook)
- {
- g_object_add_weak_pointer (G_OBJECT (tracker->notebook), (gpointer *)&tracker->notebook);
- }
+ if (tracker->notebook) {
+ g_object_remove_weak_pointer (G_OBJECT (tracker->notebook), (gpointer *)&tracker->notebook);
+ }
+ tracker->notebook = notebook;
+ if (tracker->notebook) {
+ g_object_add_weak_pointer (G_OBJECT (tracker->notebook), (gpointer *)&tracker->notebook);
+ }
}
static NotebookTracker *
notebook_tracker_new (EphyNotebook *notebook)
{
- NotebookTracker *tracker = g_slice_new0 (NotebookTracker);
+ NotebookTracker *tracker = g_slice_new0 (NotebookTracker);
- tracker->ref_count = 1;
- notebook_tracker_set_notebook (tracker, notebook);
+ tracker->ref_count = 1;
+ notebook_tracker_set_notebook (tracker, notebook);
- return tracker;
+ return tracker;
}
static NotebookTracker *
notebook_tracker_ref (NotebookTracker *tracker)
{
- g_atomic_int_inc (&tracker->ref_count);
+ g_atomic_int_inc (&tracker->ref_count);
- return tracker;
+ return tracker;
}
static void
notebook_tracker_unref (NotebookTracker *tracker)
{
- if (!g_atomic_int_dec_and_test (&tracker->ref_count))
- return;
+ if (!g_atomic_int_dec_and_test (&tracker->ref_count))
+ return;
- notebook_tracker_set_notebook (tracker, NULL);
- g_slice_free (NotebookTracker, tracker);
+ notebook_tracker_set_notebook (tracker, NULL);
+ g_slice_free (NotebookTracker, tracker);
}
static EphyNotebook *
closed_tab_get_notebook (ClosedTab *tab)
{
- return tab->notebook_tracker->notebook;
+ return tab->notebook_tracker->notebook;
}
static int
compare_func (ClosedTab *iter, EphyNotebook *notebook)
{
- return GTK_NOTEBOOK (closed_tab_get_notebook (iter)) - GTK_NOTEBOOK (notebook);
+ return GTK_NOTEBOOK (closed_tab_get_notebook (iter)) - GTK_NOTEBOOK (notebook);
}
static NotebookTracker *
-ephy_session_ref_or_create_notebook_tracker (EphySession *session,
- EphyNotebook *notebook)
+ephy_session_ref_or_create_notebook_tracker (EphySession *session,
+ EphyNotebook *notebook)
{
- GList *item = g_queue_find_custom (session->closed_tabs, notebook, (GCompareFunc)compare_func);
- return item ? notebook_tracker_ref (((ClosedTab *)item->data)->notebook_tracker) :
notebook_tracker_new (notebook);
+ GList *item = g_queue_find_custom (session->closed_tabs, notebook, (GCompareFunc)compare_func);
+ return item ? notebook_tracker_ref (((ClosedTab *)item->data)->notebook_tracker) : notebook_tracker_new
(notebook);
}
static void
closed_tab_free (ClosedTab *tab)
{
- g_free (tab->url);
- notebook_tracker_unref (tab->notebook_tracker);
- webkit_web_view_session_state_unref (tab->state);
+ g_free (tab->url);
+ notebook_tracker_unref (tab->notebook_tracker);
+ webkit_web_view_session_state_unref (tab->state);
- g_slice_free (ClosedTab, tab);
+ g_slice_free (ClosedTab, tab);
}
static ClosedTab *
-closed_tab_new (EphyWebView *web_view,
- int position,
- NotebookTracker *notebook_tracker)
+closed_tab_new (EphyWebView *web_view,
+ int position,
+ NotebookTracker *notebook_tracker)
{
- ClosedTab *tab = g_slice_new0 (ClosedTab);
+ ClosedTab *tab = g_slice_new0 (ClosedTab);
- tab->url = g_strdup (ephy_web_view_get_address (web_view));
- tab->position = position;
- /* Takes the ownership of the tracker */
- tab->notebook_tracker = notebook_tracker;
- tab->state = webkit_web_view_get_session_state (WEBKIT_WEB_VIEW (web_view));
+ tab->url = g_strdup (ephy_web_view_get_address (web_view));
+ tab->position = position;
+ /* Takes the ownership of the tracker */
+ tab->notebook_tracker = notebook_tracker;
+ tab->state = webkit_web_view_get_session_state (WEBKIT_WEB_VIEW (web_view));
- return tab;
+ return tab;
}
void
ephy_session_undo_close_tab (EphySession *session)
{
- EphyEmbed *embed, *new_tab;
- WebKitWebView *web_view;
- WebKitBackForwardList *bf_list;
- WebKitBackForwardListItem *item;
- ClosedTab *tab;
- EphyWindow *window;
- EphyNotebook *notebook;
- EphyNewTabFlags flags = EPHY_NEW_TAB_JUMP;
-
- g_return_if_fail (EPHY_IS_SESSION (session));
-
- tab = g_queue_pop_head (session->closed_tabs);
- if (tab == NULL)
- return;
-
- LOG ("UNDO CLOSE TAB: %s", tab->url);
- notebook = closed_tab_get_notebook (tab);
- if (notebook)
- {
- if (tab->position > 0)
- {
- /* Append in the n-th position. */
- embed = EPHY_EMBED (gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook),
- tab->position - 1));
- flags |= EPHY_NEW_TAB_APPEND_AFTER;
- }
- else
- {
- /* Just prepend in the first position. */
- embed = NULL;
- flags |= EPHY_NEW_TAB_FIRST;
- }
-
- window = EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (notebook)));
- new_tab = ephy_shell_new_tab (ephy_shell_get_default (),
- window, embed,
- flags);
- }
- else
- {
- window = ephy_window_new ();
- new_tab = ephy_shell_new_tab (ephy_shell_get_default (),
- window, NULL, flags);
- notebook_tracker_set_notebook (tab->notebook_tracker,
- EPHY_NOTEBOOK (ephy_window_get_notebook (window)));
- }
-
- web_view = WEBKIT_WEB_VIEW (ephy_embed_get_web_view (new_tab));
- webkit_web_view_restore_session_state (web_view, tab->state);
- bf_list = webkit_web_view_get_back_forward_list (web_view);
- item = webkit_back_forward_list_get_current_item (bf_list);
- if (item)
- {
- webkit_web_view_go_to_back_forward_list_item (web_view, item);
- }
- else
- {
- ephy_web_view_load_url (ephy_embed_get_web_view (new_tab), tab->url);
- }
-
- gtk_widget_grab_focus (GTK_WIDGET (new_tab));
- gtk_window_present (GTK_WINDOW (window));
-
- closed_tab_free (tab);
-
- if (g_queue_is_empty (session->closed_tabs))
- g_object_notify_by_pspec (G_OBJECT (session), obj_properties[PROP_CAN_UNDO_TAB_CLOSED]);
+ EphyEmbed *embed, *new_tab;
+ WebKitWebView *web_view;
+ WebKitBackForwardList *bf_list;
+ WebKitBackForwardListItem *item;
+ ClosedTab *tab;
+ EphyWindow *window;
+ EphyNotebook *notebook;
+ EphyNewTabFlags flags = EPHY_NEW_TAB_JUMP;
+
+ g_return_if_fail (EPHY_IS_SESSION (session));
+
+ tab = g_queue_pop_head (session->closed_tabs);
+ if (tab == NULL)
+ return;
+
+ LOG ("UNDO CLOSE TAB: %s", tab->url);
+ notebook = closed_tab_get_notebook (tab);
+ if (notebook) {
+ if (tab->position > 0) {
+ /* Append in the n-th position. */
+ embed = EPHY_EMBED (gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook),
+ tab->position - 1));
+ flags |= EPHY_NEW_TAB_APPEND_AFTER;
+ } else {
+ /* Just prepend in the first position. */
+ embed = NULL;
+ flags |= EPHY_NEW_TAB_FIRST;
+ }
+
+ window = EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (notebook)));
+ new_tab = ephy_shell_new_tab (ephy_shell_get_default (),
+ window, embed,
+ flags);
+ } else {
+ window = ephy_window_new ();
+ new_tab = ephy_shell_new_tab (ephy_shell_get_default (),
+ window, NULL, flags);
+ notebook_tracker_set_notebook (tab->notebook_tracker,
+ EPHY_NOTEBOOK (ephy_window_get_notebook (window)));
+ }
+
+ web_view = WEBKIT_WEB_VIEW (ephy_embed_get_web_view (new_tab));
+ webkit_web_view_restore_session_state (web_view, tab->state);
+ bf_list = webkit_web_view_get_back_forward_list (web_view);
+ item = webkit_back_forward_list_get_current_item (bf_list);
+ if (item) {
+ webkit_web_view_go_to_back_forward_list_item (web_view, item);
+ } else {
+ ephy_web_view_load_url (ephy_embed_get_web_view (new_tab), tab->url);
+ }
+
+ gtk_widget_grab_focus (GTK_WIDGET (new_tab));
+ gtk_window_present (GTK_WINDOW (window));
+
+ closed_tab_free (tab);
+
+ if (g_queue_is_empty (session->closed_tabs))
+ g_object_notify_by_pspec (G_OBJECT (session), obj_properties[PROP_CAN_UNDO_TAB_CLOSED]);
}
static void
-ephy_session_tab_closed (EphySession *session,
- EphyNotebook *notebook,
- EphyEmbed *embed,
- gint position)
+ephy_session_tab_closed (EphySession *session,
+ EphyNotebook *notebook,
+ EphyEmbed *embed,
+ gint position)
{
- EphyWebView *view;
- WebKitWebView *wk_view;
- ClosedTab *tab;
+ EphyWebView *view;
+ WebKitWebView *wk_view;
+ ClosedTab *tab;
- view = ephy_embed_get_web_view (embed);
- wk_view = WEBKIT_WEB_VIEW (view);
+ view = ephy_embed_get_web_view (embed);
+ wk_view = WEBKIT_WEB_VIEW (view);
- if (!webkit_web_view_can_go_back (wk_view) && !webkit_web_view_can_go_forward (wk_view) &&
- (ephy_web_view_get_is_blank (view) || ephy_web_view_is_overview (view)))
- {
- return;
- }
+ if (!webkit_web_view_can_go_back (wk_view) && !webkit_web_view_can_go_forward (wk_view) &&
+ (ephy_web_view_get_is_blank (view) || ephy_web_view_is_overview (view))) {
+ return;
+ }
- if (g_queue_get_length (session->closed_tabs) == MAX_CLOSED_TABS)
- {
- closed_tab_free (g_queue_pop_tail (session->closed_tabs));
- }
+ if (g_queue_get_length (session->closed_tabs) == MAX_CLOSED_TABS) {
+ closed_tab_free (g_queue_pop_tail (session->closed_tabs));
+ }
- tab = closed_tab_new (view, position,
- ephy_session_ref_or_create_notebook_tracker (session, notebook));
- g_queue_push_head (session->closed_tabs, tab);
+ tab = closed_tab_new (view, position,
+ ephy_session_ref_or_create_notebook_tracker (session, notebook));
+ g_queue_push_head (session->closed_tabs, tab);
- if (g_queue_get_length (session->closed_tabs) == 1)
- g_object_notify_by_pspec (G_OBJECT (session), obj_properties[PROP_CAN_UNDO_TAB_CLOSED]);
+ if (g_queue_get_length (session->closed_tabs) == 1)
+ g_object_notify_by_pspec (G_OBJECT (session), obj_properties[PROP_CAN_UNDO_TAB_CLOSED]);
- LOG ("Added: %s to the list (%d elements)",
- ephy_web_view_get_address (view), g_queue_get_length (session->closed_tabs));
+ LOG ("Added: %s to the list (%d elements)",
+ ephy_web_view_get_address (view), g_queue_get_length (session->closed_tabs));
}
gboolean
ephy_session_get_can_undo_tab_closed (EphySession *session)
{
- g_return_val_if_fail (EPHY_IS_SESSION (session), FALSE);
+ g_return_val_if_fail (EPHY_IS_SESSION (session), FALSE);
- return g_queue_is_empty (session->closed_tabs) == FALSE;
+ return g_queue_is_empty (session->closed_tabs) == FALSE;
}
static void
-notebook_page_added_cb (GtkWidget *notebook,
- EphyEmbed *embed,
- guint position,
- EphySession *session)
+notebook_page_added_cb (GtkWidget *notebook,
+ EphyEmbed *embed,
+ guint position,
+ EphySession *session)
{
- g_signal_connect (ephy_embed_get_web_view (embed), "load-changed",
- G_CALLBACK (load_changed_cb), session);
+ g_signal_connect (ephy_embed_get_web_view (embed), "load-changed",
+ G_CALLBACK (load_changed_cb), session);
}
static void
-notebook_page_removed_cb (GtkWidget *notebook,
- EphyEmbed *embed,
- guint position,
- EphySession *session)
+notebook_page_removed_cb (GtkWidget *notebook,
+ EphyEmbed *embed,
+ guint position,
+ EphySession *session)
{
- ephy_session_save (session);
+ ephy_session_save (session);
- g_signal_handlers_disconnect_by_func
- (ephy_embed_get_web_view (embed), G_CALLBACK (load_changed_cb),
- session);
+ g_signal_handlers_disconnect_by_func
+ (ephy_embed_get_web_view (embed), G_CALLBACK (load_changed_cb),
+ session);
- ephy_session_tab_closed (session, EPHY_NOTEBOOK (notebook), embed, position);
+ ephy_session_tab_closed (session, EPHY_NOTEBOOK (notebook), embed, position);
}
static void
-notebook_page_reordered_cb (GtkWidget *notebook,
- GtkWidget *tab,
- guint position,
- EphySession *session)
+notebook_page_reordered_cb (GtkWidget *notebook,
+ GtkWidget *tab,
+ guint position,
+ EphySession *session)
{
- ephy_session_save (session);
+ ephy_session_save (session);
}
static void
notebook_switch_page_cb (GtkNotebook *notebook,
- GtkWidget *page,
- guint page_num,
- EphySession *session)
+ GtkWidget *page,
+ guint page_num,
+ EphySession *session)
{
- ephy_session_save (session);
+ ephy_session_save (session);
}
static void
session_maybe_open_window (EphySession *session,
- guint32 user_time)
+ guint32 user_time)
{
- EphyShell *shell = ephy_shell_get_default ();
+ EphyShell *shell = ephy_shell_get_default ();
- /* FIXME: maybe just check for normal windows? */
- if (ephy_shell_get_n_windows (shell) == 0)
- {
- EphyWindow *window = ephy_window_new ();
- EphyEmbed *embed;
+ /* FIXME: maybe just check for normal windows? */
+ if (ephy_shell_get_n_windows (shell) == 0) {
+ EphyWindow *window = ephy_window_new ();
+ EphyEmbed *embed;
- embed = ephy_shell_new_tab_full (shell,
- NULL /* title */,
- NULL /* related view */,
- window, NULL /* tab */,
- 0,
- user_time);
- ephy_web_view_load_homepage (ephy_embed_get_web_view (embed));
- ephy_window_activate_location (window);
- }
+ embed = ephy_shell_new_tab_full (shell,
+ NULL /* title */,
+ NULL /* related view */,
+ window, NULL /* tab */,
+ 0,
+ user_time);
+ ephy_web_view_load_homepage (ephy_embed_get_web_view (embed));
+ ephy_window_activate_location (window);
+ }
}
static void
window_added_cb (GtkApplication *application,
- GtkWindow *window,
- EphySession *session)
+ GtkWindow *window,
+ EphySession *session)
{
- GtkWidget *notebook;
- EphyWindow *ephy_window;
+ GtkWidget *notebook;
+ EphyWindow *ephy_window;
- ephy_session_save (session);
+ ephy_session_save (session);
- if (!EPHY_IS_WINDOW (window))
- return;
+ if (!EPHY_IS_WINDOW (window))
+ return;
- ephy_window = EPHY_WINDOW (window);
+ ephy_window = EPHY_WINDOW (window);
- notebook = ephy_window_get_notebook (ephy_window);
- g_signal_connect (notebook, "page-added",
- G_CALLBACK (notebook_page_added_cb), session);
- g_signal_connect (notebook, "page-removed",
- G_CALLBACK (notebook_page_removed_cb), session);
- g_signal_connect (notebook, "page-reordered",
- G_CALLBACK (notebook_page_reordered_cb), session);
- g_signal_connect_after (notebook, "switch-page",
- G_CALLBACK (notebook_switch_page_cb), session);
+ notebook = ephy_window_get_notebook (ephy_window);
+ g_signal_connect (notebook, "page-added",
+ G_CALLBACK (notebook_page_added_cb), session);
+ g_signal_connect (notebook, "page-removed",
+ G_CALLBACK (notebook_page_removed_cb), session);
+ g_signal_connect (notebook, "page-reordered",
+ G_CALLBACK (notebook_page_reordered_cb), session);
+ g_signal_connect_after (notebook, "switch-page",
+ G_CALLBACK (notebook_switch_page_cb), session);
- /* Set unique identifier as role, so that on restore, the WM can
- * place the window on the right workspace
- */
+ /* Set unique identifier as role, so that on restore, the WM can
+ * place the window on the right workspace
+ */
- if (gtk_window_get_role (window) == NULL)
- {
- /* I guess rand() is unique enough, otherwise we could use
- * time + pid or something
- */
- char *role;
+ if (gtk_window_get_role (window) == NULL) {
+ /* I guess rand() is unique enough, otherwise we could use
+ * time + pid or something
+ */
+ char *role;
- role = g_strdup_printf ("epiphany-window-%x", rand());
- gtk_window_set_role (window, role);
- g_free (role);
- }
+ role = g_strdup_printf ("epiphany-window-%x", rand ());
+ gtk_window_set_role (window, role);
+ g_free (role);
+ }
}
static void
window_removed_cb (GtkApplication *application,
- GtkWindow *window,
- EphySession *session)
+ GtkWindow *window,
+ EphySession *session)
{
- ephy_session_save (session);
+ ephy_session_save (session);
- /* NOTE: since the window will be destroyed anyway, we don't need to
- * disconnect our signal handlers from its components.
- */
+ /* NOTE: since the window will be destroyed anyway, we don't need to
+ * disconnect our signal handlers from its components.
+ */
}
/* Class implementation */
@@ -467,66 +443,65 @@ window_removed_cb (GtkApplication *application,
static void
ephy_session_init (EphySession *session)
{
- EphyShell *shell;
+ EphyShell *shell;
- LOG ("EphySession initialising");
+ LOG ("EphySession initialising");
- session->closed_tabs = g_queue_new ();
- shell = ephy_shell_get_default ();
- g_signal_connect (shell, "window-added",
- G_CALLBACK (window_added_cb), session);
- g_signal_connect (shell, "window-removed",
- G_CALLBACK (window_removed_cb), session);
+ session->closed_tabs = g_queue_new ();
+ shell = ephy_shell_get_default ();
+ g_signal_connect (shell, "window-added",
+ G_CALLBACK (window_added_cb), session);
+ g_signal_connect (shell, "window-removed",
+ G_CALLBACK (window_removed_cb), session);
}
static void
ephy_session_dispose (GObject *object)
{
- EphySession *session = EPHY_SESSION (object);
+ EphySession *session = EPHY_SESSION (object);
- LOG ("EphySession disposing");
+ LOG ("EphySession disposing");
- g_queue_free_full (session->closed_tabs,
- (GDestroyNotify)closed_tab_free);
+ g_queue_free_full (session->closed_tabs,
+ (GDestroyNotify)closed_tab_free);
- G_OBJECT_CLASS (ephy_session_parent_class)->dispose (object);
+ G_OBJECT_CLASS (ephy_session_parent_class)->dispose (object);
}
static void
-ephy_session_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+ephy_session_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- EphySession *session = EPHY_SESSION (object);
+ EphySession *session = EPHY_SESSION (object);
- switch (property_id)
- {
- case PROP_CAN_UNDO_TAB_CLOSED:
- g_value_set_boolean (value,
- ephy_session_get_can_undo_tab_closed (session));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- }
+ switch (property_id) {
+ case PROP_CAN_UNDO_TAB_CLOSED:
+ g_value_set_boolean (value,
+ ephy_session_get_can_undo_tab_closed (session));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
}
static void
ephy_session_class_init (EphySessionClass *class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
- object_class->dispose = ephy_session_dispose;
- object_class->get_property = ephy_session_get_property;
+ object_class->dispose = ephy_session_dispose;
+ object_class->get_property = ephy_session_get_property;
- obj_properties[PROP_CAN_UNDO_TAB_CLOSED] =
- g_param_spec_boolean ("can-undo-tab-closed",
- "Can undo tab close",
- "Session can undo a tab closure",
- FALSE,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ obj_properties[PROP_CAN_UNDO_TAB_CLOSED] =
+ g_param_spec_boolean ("can-undo-tab-closed",
+ "Can undo tab close",
+ "Session can undo a tab closure",
+ FALSE,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
}
/* Implementation */
@@ -534,891 +509,816 @@ ephy_session_class_init (EphySessionClass *class)
void
ephy_session_close (EphySession *session)
{
- EphyPrefsRestoreSessionPolicy policy;
+ EphyPrefsRestoreSessionPolicy policy;
- g_return_if_fail (EPHY_IS_SESSION (session));
+ g_return_if_fail (EPHY_IS_SESSION (session));
- LOG ("ephy_session_close");
+ LOG ("ephy_session_close");
- if (session->save_source_id)
- {
- /* There's a save pending, cancel it and save the session now since
- * after closing the session the saving is no longer allowed.
- */
- g_source_remove (session->save_source_id);
- session->save_source_id = 0;
- }
+ if (session->save_source_id) {
+ /* There's a save pending, cancel it and save the session now since
+ * after closing the session the saving is no longer allowed.
+ */
+ g_source_remove (session->save_source_id);
+ session->save_source_id = 0;
+ }
- session->closing = TRUE;
+ session->closing = TRUE;
- policy = g_settings_get_enum (EPHY_SETTINGS_MAIN, EPHY_PREFS_RESTORE_SESSION_POLICY);
- if (policy == EPHY_PREFS_RESTORE_SESSION_POLICY_ALWAYS)
- {
- ephy_session_save_idle_cb (session);
- }
- else
- {
- session_delete (session);
- }
+ policy = g_settings_get_enum (EPHY_SETTINGS_MAIN, EPHY_PREFS_RESTORE_SESSION_POLICY);
+ if (policy == EPHY_PREFS_RESTORE_SESSION_POLICY_ALWAYS) {
+ ephy_session_save_idle_cb (session);
+ } else {
+ session_delete (session);
+ }
- session->dont_save = TRUE;
+ session->dont_save = TRUE;
}
static void
-get_window_geometry (GtkWindow *window,
- GdkRectangle *rectangle)
+get_window_geometry (GtkWindow *window,
+ GdkRectangle *rectangle)
{
- gtk_window_get_size (window, &rectangle->width, &rectangle->height);
- gtk_window_get_position (window, &rectangle->x, &rectangle->y);
+ gtk_window_get_size (window, &rectangle->width, &rectangle->height);
+ gtk_window_get_position (window, &rectangle->x, &rectangle->y);
}
typedef struct {
- char *url;
- char *title;
- gboolean loading;
- gboolean crashed;
- WebKitWebViewSessionState *state;
+ char *url;
+ char *title;
+ gboolean loading;
+ gboolean crashed;
+ WebKitWebViewSessionState *state;
} SessionTab;
static SessionTab *
-session_tab_new (EphyEmbed *embed,
- EphySession *session)
-{
- SessionTab *session_tab;
- const char *address;
- EphyWebView *web_view = ephy_embed_get_web_view (embed);
- EphyWebViewErrorPage error_page = ephy_web_view_get_error_page (web_view);
-
- session_tab = g_slice_new (SessionTab);
-
- address = ephy_web_view_get_address (web_view);
- /* Do not store ephy-about: URIs, they are not valid for loading. */
- if (g_str_has_prefix (address, EPHY_ABOUT_SCHEME))
- {
- session_tab->url = g_strconcat ("about", address + EPHY_ABOUT_SCHEME_LEN, NULL);
- }
- else if (g_str_equal (address, "about:blank"))
- {
- /* EphyWebView address is NULL between load_uri() and WEBKIT_LOAD_STARTED,
- * but WebKitWebView knows the pending API request URL, so use that instead of about:blank.
- */
- session_tab->url = g_strdup (webkit_web_view_get_uri (WEBKIT_WEB_VIEW (web_view)));
- }
- else
- {
- session_tab->url = g_strdup (address);
- }
-
- session_tab->title = g_strdup (ephy_embed_get_title (embed));
- session_tab->loading = (ephy_web_view_is_loading (web_view) &&
- !ephy_embed_has_load_pending (embed) &&
- !session->closing);
- session_tab->crashed = (error_page == EPHY_WEB_VIEW_ERROR_PAGE_CRASH ||
- error_page == EPHY_WEB_VIEW_ERROR_PROCESS_CRASH);
- session_tab->state = webkit_web_view_get_session_state (WEBKIT_WEB_VIEW (web_view));
-
- return session_tab;
+session_tab_new (EphyEmbed *embed,
+ EphySession *session)
+{
+ SessionTab *session_tab;
+ const char *address;
+ EphyWebView *web_view = ephy_embed_get_web_view (embed);
+ EphyWebViewErrorPage error_page = ephy_web_view_get_error_page (web_view);
+
+ session_tab = g_slice_new (SessionTab);
+
+ address = ephy_web_view_get_address (web_view);
+ /* Do not store ephy-about: URIs, they are not valid for loading. */
+ if (g_str_has_prefix (address, EPHY_ABOUT_SCHEME)) {
+ session_tab->url = g_strconcat ("about", address + EPHY_ABOUT_SCHEME_LEN, NULL);
+ } else if (g_str_equal (address, "about:blank")) {
+ /* EphyWebView address is NULL between load_uri() and WEBKIT_LOAD_STARTED,
+ * but WebKitWebView knows the pending API request URL, so use that instead of about:blank.
+ */
+ session_tab->url = g_strdup (webkit_web_view_get_uri (WEBKIT_WEB_VIEW (web_view)));
+ } else {
+ session_tab->url = g_strdup (address);
+ }
+
+ session_tab->title = g_strdup (ephy_embed_get_title (embed));
+ session_tab->loading = (ephy_web_view_is_loading (web_view) &&
+ !ephy_embed_has_load_pending (embed) &&
+ !session->closing);
+ session_tab->crashed = (error_page == EPHY_WEB_VIEW_ERROR_PAGE_CRASH ||
+ error_page == EPHY_WEB_VIEW_ERROR_PROCESS_CRASH);
+ session_tab->state = webkit_web_view_get_session_state (WEBKIT_WEB_VIEW (web_view));
+
+ return session_tab;
}
static void
session_tab_free (SessionTab *tab)
{
- g_free (tab->url);
- g_free (tab->title);
- g_clear_pointer (&tab->state, webkit_web_view_session_state_unref);
+ g_free (tab->url);
+ g_free (tab->title);
+ g_clear_pointer (&tab->state, webkit_web_view_session_state_unref);
- g_slice_free (SessionTab, tab);
+ g_slice_free (SessionTab, tab);
}
typedef struct {
- GdkRectangle geometry;
- char *role;
+ GdkRectangle geometry;
+ char *role;
- GList *tabs;
- gint active_tab;
+ GList *tabs;
+ gint active_tab;
} SessionWindow;
static SessionWindow *
-session_window_new (EphyWindow *window,
- EphySession *session)
+session_window_new (EphyWindow *window,
+ EphySession *session)
{
- SessionWindow *session_window;
- GList *tabs, *l;
- GtkNotebook *notebook;
+ SessionWindow *session_window;
+ GList *tabs, *l;
+ GtkNotebook *notebook;
- tabs = ephy_embed_container_get_children (EPHY_EMBED_CONTAINER (window));
- /* Do not save an empty EphyWindow.
- * This only happens when the window was newly opened.
- */
- if (!tabs)
- {
- return NULL;
- }
+ tabs = ephy_embed_container_get_children (EPHY_EMBED_CONTAINER (window));
+ /* Do not save an empty EphyWindow.
+ * This only happens when the window was newly opened.
+ */
+ if (!tabs) {
+ return NULL;
+ }
- session_window = g_slice_new0 (SessionWindow);
- get_window_geometry (GTK_WINDOW (window), &session_window->geometry);
- session_window->role = g_strdup (gtk_window_get_role (GTK_WINDOW (window)));
+ session_window = g_slice_new0 (SessionWindow);
+ get_window_geometry (GTK_WINDOW (window), &session_window->geometry);
+ session_window->role = g_strdup (gtk_window_get_role (GTK_WINDOW (window)));
- for (l = tabs; l != NULL; l = l->next)
- {
- SessionTab *tab;
+ for (l = tabs; l != NULL; l = l->next) {
+ SessionTab *tab;
- tab = session_tab_new (EPHY_EMBED (l->data), session);
- session_window->tabs = g_list_prepend (session_window->tabs, tab);
- }
- g_list_free (tabs);
- session_window->tabs = g_list_reverse (session_window->tabs);
+ tab = session_tab_new (EPHY_EMBED (l->data), session);
+ session_window->tabs = g_list_prepend (session_window->tabs, tab);
+ }
+ g_list_free (tabs);
+ session_window->tabs = g_list_reverse (session_window->tabs);
- notebook = GTK_NOTEBOOK (ephy_window_get_notebook (window));
- session_window->active_tab = gtk_notebook_get_current_page (notebook);
+ notebook = GTK_NOTEBOOK (ephy_window_get_notebook (window));
+ session_window->active_tab = gtk_notebook_get_current_page (notebook);
- return session_window;
+ return session_window;
}
static void
session_window_free (SessionWindow *session_window)
{
- g_free (session_window->role);
- g_list_free_full (session_window->tabs, (GDestroyNotify)session_tab_free);
+ g_free (session_window->role);
+ g_list_free_full (session_window->tabs, (GDestroyNotify)session_tab_free);
- g_slice_free (SessionWindow, session_window);
+ g_slice_free (SessionWindow, session_window);
}
typedef struct {
- EphySession *session;
+ EphySession *session;
- GList *windows;
+ GList *windows;
} SaveData;
static SaveData *
save_data_new (EphySession *session)
{
- SaveData *data;
- EphyShell *shell = ephy_shell_get_default ();
- GList *windows, *w;
+ SaveData *data;
+ EphyShell *shell = ephy_shell_get_default ();
+ GList *windows, *w;
- data = g_slice_new0 (SaveData);
- data->session = g_object_ref (session);
+ data = g_slice_new0 (SaveData);
+ data->session = g_object_ref (session);
- windows = gtk_application_get_windows (GTK_APPLICATION (shell));
- for (w = windows; w != NULL ; w = w->next)
- {
- SessionWindow *session_window;
+ windows = gtk_application_get_windows (GTK_APPLICATION (shell));
+ for (w = windows; w != NULL; w = w->next) {
+ SessionWindow *session_window;
- session_window = session_window_new (EPHY_WINDOW (w->data), session);
- if (session_window)
- data->windows = g_list_prepend (data->windows, session_window);
- }
- data->windows = g_list_reverse (data->windows);
+ session_window = session_window_new (EPHY_WINDOW (w->data), session);
+ if (session_window)
+ data->windows = g_list_prepend (data->windows, session_window);
+ }
+ data->windows = g_list_reverse (data->windows);
- return data;
+ return data;
}
static void
save_data_free (SaveData *data)
{
- g_list_free_full (data->windows, (GDestroyNotify)session_window_free);
+ g_list_free_full (data->windows, (GDestroyNotify)session_window_free);
- g_object_unref (data->session);
+ g_object_unref (data->session);
- g_slice_free (SaveData, data);
+ g_slice_free (SaveData, data);
}
static int
write_tab (xmlTextWriterPtr writer,
- SessionTab *tab)
-{
- int ret;
-
- ret = xmlTextWriterStartElement (writer, (xmlChar *) "embed");
- if (ret < 0) return ret;
-
- ret = xmlTextWriterWriteAttribute (writer, (xmlChar *) "url",
- (const xmlChar *) tab->url);
- if (ret < 0) return ret;
-
- ret = xmlTextWriterWriteAttribute (writer, (xmlChar *) "title",
- (const xmlChar *) tab->title);
- if (ret < 0) return ret;
-
- if (tab->loading)
- {
- ret = xmlTextWriterWriteAttribute (writer,
- (const xmlChar *) "loading",
- (const xmlChar *) "true");
- if (ret < 0) return ret;
- }
-
- if (tab->crashed)
- {
- ret = xmlTextWriterWriteAttribute (writer,
- (const xmlChar *) "crashed",
- (const xmlChar *) "true");
- if (ret < 0) return ret;
- }
-
- if (tab->state)
- {
- GBytes *bytes;
-
- bytes = webkit_web_view_session_state_serialize (tab->state);
- if (bytes)
- {
- gchar *base64;
- gconstpointer data;
- gsize data_length;
-
- data = g_bytes_get_data (bytes, &data_length);
- base64 = g_base64_encode (data, data_length);
- ret = xmlTextWriterWriteAttribute (writer,
- (const xmlChar *) "history",
- (const xmlChar *) base64);
- g_free (base64);
- g_bytes_unref (bytes);
- }
- }
-
- ret = xmlTextWriterEndElement (writer); /* embed */
- return ret;
+ SessionTab *tab)
+{
+ int ret;
+
+ ret = xmlTextWriterStartElement (writer, (xmlChar *)"embed");
+ if (ret < 0) return ret;
+
+ ret = xmlTextWriterWriteAttribute (writer, (xmlChar *)"url",
+ (const xmlChar *)tab->url);
+ if (ret < 0) return ret;
+
+ ret = xmlTextWriterWriteAttribute (writer, (xmlChar *)"title",
+ (const xmlChar *)tab->title);
+ if (ret < 0) return ret;
+
+ if (tab->loading) {
+ ret = xmlTextWriterWriteAttribute (writer,
+ (const xmlChar *)"loading",
+ (const xmlChar *)"true");
+ if (ret < 0) return ret;
+ }
+
+ if (tab->crashed) {
+ ret = xmlTextWriterWriteAttribute (writer,
+ (const xmlChar *)"crashed",
+ (const xmlChar *)"true");
+ if (ret < 0) return ret;
+ }
+
+ if (tab->state) {
+ GBytes *bytes;
+
+ bytes = webkit_web_view_session_state_serialize (tab->state);
+ if (bytes) {
+ gchar *base64;
+ gconstpointer data;
+ gsize data_length;
+
+ data = g_bytes_get_data (bytes, &data_length);
+ base64 = g_base64_encode (data, data_length);
+ ret = xmlTextWriterWriteAttribute (writer,
+ (const xmlChar *)"history",
+ (const xmlChar *)base64);
+ g_free (base64);
+ g_bytes_unref (bytes);
+ }
+ }
+
+ ret = xmlTextWriterEndElement (writer); /* embed */
+ return ret;
}
static int
write_window_geometry (xmlTextWriterPtr writer,
- GdkRectangle *geometry)
+ GdkRectangle *geometry)
{
- int ret;
+ int ret;
- /* set window properties */
- ret = xmlTextWriterWriteFormatAttribute (writer, (const xmlChar *) "x", "%d",
- geometry->x);
- if (ret < 0) return ret;
+ /* set window properties */
+ ret = xmlTextWriterWriteFormatAttribute (writer, (const xmlChar *)"x", "%d",
+ geometry->x);
+ if (ret < 0) return ret;
- ret = xmlTextWriterWriteFormatAttribute (writer, (const xmlChar *) "y", "%d",
- geometry->y);
- if (ret < 0) return ret;
+ ret = xmlTextWriterWriteFormatAttribute (writer, (const xmlChar *)"y", "%d",
+ geometry->y);
+ if (ret < 0) return ret;
- ret = xmlTextWriterWriteFormatAttribute (writer, (const xmlChar *) "width", "%d",
- geometry->width);
- if (ret < 0) return ret;
+ ret = xmlTextWriterWriteFormatAttribute (writer, (const xmlChar *)"width", "%d",
+ geometry->width);
+ if (ret < 0) return ret;
- ret = xmlTextWriterWriteFormatAttribute (writer, (const xmlChar *) "height", "%d",
- geometry->height);
- return ret;
+ ret = xmlTextWriterWriteFormatAttribute (writer, (const xmlChar *)"height", "%d",
+ geometry->height);
+ return ret;
}
static int
write_ephy_window (xmlTextWriterPtr writer,
- SessionWindow *window)
+ SessionWindow *window)
{
- GList *l;
- int ret;
+ GList *l;
+ int ret;
- ret = xmlTextWriterStartElement (writer, (xmlChar *) "window");
- if (ret < 0) return ret;
+ ret = xmlTextWriterStartElement (writer, (xmlChar *)"window");
+ if (ret < 0) return ret;
- ret = write_window_geometry (writer, &window->geometry);
- if (ret < 0) return ret;
+ ret = write_window_geometry (writer, &window->geometry);
+ if (ret < 0) return ret;
- ret = xmlTextWriterWriteFormatAttribute (writer, (const xmlChar *) "active-tab", "%d",
- window->active_tab);
- if (ret < 0) return ret;
+ ret = xmlTextWriterWriteFormatAttribute (writer, (const xmlChar *)"active-tab", "%d",
+ window->active_tab);
+ if (ret < 0) return ret;
- if (window->role != NULL)
- {
- ret = xmlTextWriterWriteAttribute (writer,
- (const xmlChar *) "role",
- (const xmlChar *) window->role);
- if (ret < 0) return ret;
- }
+ if (window->role != NULL) {
+ ret = xmlTextWriterWriteAttribute (writer,
+ (const xmlChar *)"role",
+ (const xmlChar *)window->role);
+ if (ret < 0) return ret;
+ }
- for (l = window->tabs; l != NULL; l = l->next)
- {
- SessionTab *tab = (SessionTab *) l->data;
- ret = write_tab (writer, tab);
- if (ret < 0) break;
- }
- if (ret < 0) return ret;
+ for (l = window->tabs; l != NULL; l = l->next) {
+ SessionTab *tab = (SessionTab *)l->data;
+ ret = write_tab (writer, tab);
+ if (ret < 0) break;
+ }
+ if (ret < 0) return ret;
- ret = xmlTextWriterEndElement (writer); /* window */
- return ret;
+ ret = xmlTextWriterEndElement (writer); /* window */
+ return ret;
}
static void
-save_session_in_thread_finished_cb (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
+save_session_in_thread_finished_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
- g_application_release (G_APPLICATION (ephy_shell_get_default ()));
+ g_application_release (G_APPLICATION (ephy_shell_get_default ()));
}
static void
-save_session_sync (GTask *task,
- gpointer source_object,
- gpointer task_data,
- GCancellable *cancellable)
+save_session_sync (GTask *task,
+ gpointer source_object,
+ gpointer task_data,
+ GCancellable *cancellable)
{
- SaveData *data = (SaveData *)g_task_get_task_data (task);
- xmlBufferPtr buffer;
- xmlTextWriterPtr writer;
- GList *w;
- int ret = -1;
+ SaveData *data = (SaveData *)g_task_get_task_data (task);
+ xmlBufferPtr buffer;
+ xmlTextWriterPtr writer;
+ GList *w;
+ int ret = -1;
- buffer = xmlBufferCreate ();
- writer = xmlNewTextWriterMemory (buffer, 0);
- if (writer == NULL) goto out;
+ buffer = xmlBufferCreate ();
+ writer = xmlNewTextWriterMemory (buffer, 0);
+ if (writer == NULL) goto out;
- ret = xmlTextWriterSetIndent (writer, 1);
- if (ret < 0) goto out;
+ ret = xmlTextWriterSetIndent (writer, 1);
+ if (ret < 0) goto out;
- ret = xmlTextWriterSetIndentString (writer, (const xmlChar *) " ");
- if (ret < 0) goto out;
+ ret = xmlTextWriterSetIndentString (writer, (const xmlChar *)" ");
+ if (ret < 0) goto out;
- START_PROFILER ("Saving session")
+ START_PROFILER ("Saving session")
- ret = xmlTextWriterStartDocument (writer, "1.0", NULL, NULL);
- if (ret < 0) goto out;
+ ret = xmlTextWriterStartDocument (writer, "1.0", NULL, NULL);
+ if (ret < 0) goto out;
- /* create and set the root node for the session */
- ret = xmlTextWriterStartElement (writer, (const xmlChar *) "session");
- if (ret < 0) goto out;
+ /* create and set the root node for the session */
+ ret = xmlTextWriterStartElement (writer, (const xmlChar *)"session");
+ if (ret < 0) goto out;
- /* iterate through all the windows */
- for (w = data->windows; w != NULL && ret >= 0; w = w->next)
- {
- ret = write_ephy_window (writer, (SessionWindow *) w->data);
- }
- if (ret < 0) goto out;
+ /* iterate through all the windows */
+ for (w = data->windows; w != NULL && ret >= 0; w = w->next) {
+ ret = write_ephy_window (writer, (SessionWindow *)w->data);
+ }
+ if (ret < 0) goto out;
- ret = xmlTextWriterEndElement (writer); /* session */
- if (ret < 0) goto out;
+ ret = xmlTextWriterEndElement (writer); /* session */
+ if (ret < 0) goto out;
- ret = xmlTextWriterEndDocument (writer);
+ ret = xmlTextWriterEndDocument (writer);
-out:
- if (writer)
- xmlFreeTextWriter (writer);
+ out:
+ if (writer)
+ xmlFreeTextWriter (writer);
- if (ret >= 0 && !g_cancellable_is_cancelled (cancellable))
- {
- GError *error = NULL;
- GFile *session_file;
+ if (ret >= 0 && !g_cancellable_is_cancelled (cancellable)) {
+ GError *error = NULL;
+ GFile *session_file;
- session_file = get_session_file (SESSION_STATE);
+ session_file = get_session_file (SESSION_STATE);
- if (!g_file_replace_contents (session_file,
- (const char *)buffer->content,
- buffer->use,
- NULL, TRUE, 0, NULL,
- cancellable, &error))
- {
- if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- {
- g_warning ("Error saving session: %s", error->message);
- }
- g_error_free (error);
- }
+ if (!g_file_replace_contents (session_file,
+ (const char *)buffer->content,
+ buffer->use,
+ NULL, TRUE, 0, NULL,
+ cancellable, &error)) {
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ g_warning ("Error saving session: %s", error->message);
+ }
+ g_error_free (error);
+ }
- g_object_unref (session_file);
- }
+ g_object_unref (session_file);
+ }
- xmlBufferFree (buffer);
+ xmlBufferFree (buffer);
- g_task_return_boolean (task, TRUE);
+ g_task_return_boolean (task, TRUE);
- STOP_PROFILER ("Saving session")
+ STOP_PROFILER ("Saving session")
}
static EphySession *
ephy_session_save_idle_started (EphySession *session)
{
- g_application_hold (G_APPLICATION (ephy_shell_get_default ()));
- return g_object_ref (session);
+ g_application_hold (G_APPLICATION (ephy_shell_get_default ()));
+ return g_object_ref (session);
}
static void
ephy_session_save_idle_finished (EphySession *session)
{
- g_application_release (G_APPLICATION (ephy_shell_get_default ()));
- g_object_unref (session);
+ g_application_release (G_APPLICATION (ephy_shell_get_default ()));
+ g_object_unref (session);
}
static gboolean
ephy_session_save_idle_cb (EphySession *session)
{
- EphyShell *shell = ephy_shell_get_default ();
- SaveData *data;
- GTask *task;
+ EphyShell *shell = ephy_shell_get_default ();
+ SaveData *data;
+ GTask *task;
- session->save_source_id = 0;
+ session->save_source_id = 0;
- if (session->save_cancellable)
- {
- g_cancellable_cancel (session->save_cancellable);
- g_object_unref (session->save_cancellable);
- session->save_cancellable = NULL;
- }
+ if (session->save_cancellable) {
+ g_cancellable_cancel (session->save_cancellable);
+ g_object_unref (session->save_cancellable);
+ session->save_cancellable = NULL;
+ }
- LOG ("ephy_sesion_save");
+ LOG ("ephy_sesion_save");
- if (ephy_shell_get_n_windows (shell) == 0)
- {
- session_delete (session);
- return G_SOURCE_REMOVE;
- }
+ if (ephy_shell_get_n_windows (shell) == 0) {
+ session_delete (session);
+ return G_SOURCE_REMOVE;
+ }
- g_application_hold (G_APPLICATION (ephy_shell_get_default ()));
- session->save_cancellable = g_cancellable_new ();
- data = save_data_new (session);
- task = g_task_new (session, session->save_cancellable,
- save_session_in_thread_finished_cb, NULL);
- g_task_set_task_data (task, data, (GDestroyNotify)save_data_free);
- g_task_run_in_thread (task, save_session_sync);
- g_object_unref (task);
+ g_application_hold (G_APPLICATION (ephy_shell_get_default ()));
+ session->save_cancellable = g_cancellable_new ();
+ data = save_data_new (session);
+ task = g_task_new (session, session->save_cancellable,
+ save_session_in_thread_finished_cb, NULL);
+ g_task_set_task_data (task, data, (GDestroyNotify)save_data_free);
+ g_task_run_in_thread (task, save_session_sync);
+ g_object_unref (task);
- return G_SOURCE_REMOVE;
+ return G_SOURCE_REMOVE;
}
void
ephy_session_save (EphySession *session)
{
- EphyPrefsRestoreSessionPolicy policy;
+ EphyPrefsRestoreSessionPolicy policy;
- g_return_if_fail (EPHY_IS_SESSION (session));
+ g_return_if_fail (EPHY_IS_SESSION (session));
- if (session->save_source_id)
- {
- return;
- }
+ if (session->save_source_id) {
+ return;
+ }
- if (session->dont_save)
- {
- return;
- }
+ if (session->dont_save) {
+ return;
+ }
- policy = g_settings_get_enum (EPHY_SETTINGS_MAIN, EPHY_PREFS_RESTORE_SESSION_POLICY);
- if (policy == EPHY_PREFS_RESTORE_SESSION_POLICY_NEVER)
- {
- return;
- }
+ policy = g_settings_get_enum (EPHY_SETTINGS_MAIN, EPHY_PREFS_RESTORE_SESSION_POLICY);
+ if (policy == EPHY_PREFS_RESTORE_SESSION_POLICY_NEVER) {
+ return;
+ }
- session->save_source_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT_IDLE, 1,
- (GSourceFunc)ephy_session_save_idle_cb,
- ephy_session_save_idle_started (session),
-
(GDestroyNotify)ephy_session_save_idle_finished);
+ session->save_source_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT_IDLE, 1,
+ (GSourceFunc)ephy_session_save_idle_cb,
+ ephy_session_save_idle_started (session),
+ (GDestroyNotify)ephy_session_save_idle_finished);
}
static void
confirm_before_recover (EphyWindow *window, const char *url, const char *title)
{
- EphyEmbed *embed;
+ EphyEmbed *embed;
- embed = ephy_shell_new_tab_full (ephy_shell_get_default (),
- title, NULL,
- window, NULL,
- EPHY_NEW_TAB_APPEND_LAST,
- 0);
+ embed = ephy_shell_new_tab_full (ephy_shell_get_default (),
+ title, NULL,
+ window, NULL,
+ EPHY_NEW_TAB_APPEND_LAST,
+ 0);
- ephy_web_view_load_error_page (ephy_embed_get_web_view (embed), url,
- EPHY_WEB_VIEW_ERROR_PAGE_CRASH, NULL);
+ ephy_web_view_load_error_page (ephy_embed_get_web_view (embed), url,
+ EPHY_WEB_VIEW_ERROR_PAGE_CRASH, NULL);
}
static void
-restore_geometry (GtkWindow *window,
- GdkRectangle *geometry)
+restore_geometry (GtkWindow *window,
+ GdkRectangle *geometry)
{
- if (geometry->x >= 0 && geometry->y >= 0)
- {
- gtk_window_move (window, geometry->x, geometry->y);
- }
+ if (geometry->x >= 0 && geometry->y >= 0) {
+ gtk_window_move (window, geometry->x, geometry->y);
+ }
- if (geometry->width > 0 && geometry->height > 0)
- {
- gtk_window_set_default_size (window, geometry->width, geometry->height);
- }
+ if (geometry->width > 0 && geometry->height > 0) {
+ gtk_window_set_default_size (window, geometry->width, geometry->height);
+ }
}
typedef struct {
- EphySession *session;
- guint32 user_time;
+ EphySession *session;
+ guint32 user_time;
- EphyWindow *window;
- gboolean is_first_window;
- gint active_tab;
+ EphyWindow *window;
+ gboolean is_first_window;
+ gint active_tab;
- gboolean is_first_tab;
+ gboolean is_first_tab;
} SessionParserContext;
static SessionParserContext *
session_parser_context_new (EphySession *session,
- guint32 user_time)
+ guint32 user_time)
{
- SessionParserContext *context;
+ SessionParserContext *context;
- context = g_slice_new0 (SessionParserContext);
- context->session = g_object_ref (session);
- context->user_time = user_time;
- context->is_first_window = TRUE;
+ context = g_slice_new0 (SessionParserContext);
+ context->session = g_object_ref (session);
+ context->user_time = user_time;
+ context->is_first_window = TRUE;
- return context;
+ return context;
}
static void
session_parser_context_free (SessionParserContext *context)
{
- g_object_unref (context->session);
+ g_object_unref (context->session);
- g_slice_free (SessionParserContext, context);
+ g_slice_free (SessionParserContext, context);
}
static void
session_parse_window (SessionParserContext *context,
- const gchar **names,
- const gchar **values)
-{
- GdkRectangle geometry = { -1, -1, 0, 0 };
- guint i;
-
- context->window = ephy_window_new ();
-
- for (i = 0; names[i]; i++)
- {
- gulong int_value;
-
- if (strcmp (names[i], "x") == 0)
- {
- ephy_string_to_int (values[i], &int_value);
- geometry.x = int_value;
- }
- else if (strcmp (names[i], "y") == 0)
- {
- ephy_string_to_int (values[i], &int_value);
- geometry.y = int_value;
- }
- else if (strcmp (names[i], "width") == 0)
- {
- ephy_string_to_int (values[i], &int_value);
- geometry.width = int_value;
- }
- else if (strcmp (names[i], "height") == 0)
- {
- ephy_string_to_int (values[i], &int_value);
- geometry.height = int_value;
- }
- else if (strcmp (names[i], "role") == 0)
- {
- gtk_window_set_role (GTK_WINDOW (context->window), values[i]);
- }
- else if (strcmp (names[i], "active-tab") == 0)
- {
- ephy_string_to_int (values[i], &int_value);
- context->active_tab = int_value;
- }
- }
-
- restore_geometry (GTK_WINDOW (context->window), &geometry);
- ephy_gui_window_update_user_time (GTK_WIDGET (context->window), context->user_time);
+ const gchar **names,
+ const gchar **values)
+{
+ GdkRectangle geometry = { -1, -1, 0, 0 };
+ guint i;
+
+ context->window = ephy_window_new ();
+
+ for (i = 0; names[i]; i++) {
+ gulong int_value;
+
+ if (strcmp (names[i], "x") == 0) {
+ ephy_string_to_int (values[i], &int_value);
+ geometry.x = int_value;
+ } else if (strcmp (names[i], "y") == 0) {
+ ephy_string_to_int (values[i], &int_value);
+ geometry.y = int_value;
+ } else if (strcmp (names[i], "width") == 0) {
+ ephy_string_to_int (values[i], &int_value);
+ geometry.width = int_value;
+ } else if (strcmp (names[i], "height") == 0) {
+ ephy_string_to_int (values[i], &int_value);
+ geometry.height = int_value;
+ } else if (strcmp (names[i], "role") == 0) {
+ gtk_window_set_role (GTK_WINDOW (context->window), values[i]);
+ } else if (strcmp (names[i], "active-tab") == 0) {
+ ephy_string_to_int (values[i], &int_value);
+ context->active_tab = int_value;
+ }
+ }
+
+ restore_geometry (GTK_WINDOW (context->window), &geometry);
+ ephy_gui_window_update_user_time (GTK_WIDGET (context->window), context->user_time);
}
static void
session_parse_embed (SessionParserContext *context,
- const gchar **names,
- const gchar **values)
-{
- const char *url = NULL;
- const char *title = NULL;
- const char *history = NULL;
- gboolean was_loading = FALSE;
- gboolean crashed = FALSE;
- gboolean is_blank_page = FALSE;
- guint i;
-
- for (i = 0; names[i]; i++)
- {
- if (strcmp (names[i], "url") == 0)
- {
- url = values[i];
- is_blank_page = (strcmp (url, "about:blank") == 0 ||
- strcmp (url, "about:overview") == 0);
- }
- else if (strcmp (names[i], "title") == 0)
- {
- title = values[i];
- }
- else if (strcmp (names[i], "loading") == 0)
- {
- was_loading = strcmp (values[i], "true") == 0;
- }
- else if (strcmp (names[i], "crashed") == 0)
- {
- crashed = strcmp (values[i], "true") == 0;
- }
- else if (strcmp (names[i], "history") == 0)
- {
- history = values[i];
- }
- }
-
- /* In the case that crash happens before we receive the URL from the server,
- * this will open an about:blank tab.
- * See http://bugzilla.gnome.org/show_bug.cgi?id=591294
- * Otherwise, if the web was fully loaded, it is reloaded again.
- */
- if ((!was_loading || is_blank_page) && !crashed)
- {
- EphyNewTabFlags flags;
- EphyEmbed *embed;
- EphyWebView *web_view;
- gboolean delay_loading;
- WebKitWebViewSessionState* state = NULL;
-
- delay_loading = g_settings_get_boolean (EPHY_SETTINGS_MAIN,
- EPHY_PREFS_RESTORE_SESSION_DELAYING_LOADS);
-
- flags = EPHY_NEW_TAB_APPEND_LAST;
-
- embed = ephy_shell_new_tab_full (ephy_shell_get_default (),
- title, NULL,
- context->window, NULL, flags,
- 0);
-
- web_view = ephy_embed_get_web_view (embed);
- if (history) {
- guchar *data;
- gsize data_length;
- GBytes *history_data;
-
- data = g_base64_decode (history, &data_length);
- history_data = g_bytes_new_take (data, data_length);
- state = webkit_web_view_session_state_new (history_data);
- g_bytes_unref (history_data);
- }
-
- if (delay_loading)
- {
- WebKitURIRequest *request = webkit_uri_request_new (url);
-
- ephy_embed_set_delayed_load_request (embed, request, state);
- ephy_web_view_set_placeholder (web_view, url, title);
- g_object_unref (request);
- }
- else
- {
- WebKitBackForwardList *bf_list;
- WebKitBackForwardListItem *item;
-
- if (state)
- {
- webkit_web_view_restore_session_state (WEBKIT_WEB_VIEW (web_view), state);
- }
-
- bf_list = webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (web_view));
- item = webkit_back_forward_list_get_current_item (bf_list);
- if (item)
- {
- webkit_web_view_go_to_back_forward_list_item (WEBKIT_WEB_VIEW (web_view),
item);
- }
- else
- {
- ephy_web_view_load_url (web_view, url);
- }
- }
-
- if (state)
- {
- webkit_web_view_session_state_unref (state);
- }
- }
- else if (url && (was_loading || crashed))
- {
- /* This page was loading during a UI process crash
- * (was_loading == TRUE) or a web process crash
- * (crashed == TRUE) and might make Epiphany crash again.
- */
- confirm_before_recover (context->window, url, title);
- }
+ const gchar **names,
+ const gchar **values)
+{
+ const char *url = NULL;
+ const char *title = NULL;
+ const char *history = NULL;
+ gboolean was_loading = FALSE;
+ gboolean crashed = FALSE;
+ gboolean is_blank_page = FALSE;
+ guint i;
+
+ for (i = 0; names[i]; i++) {
+ if (strcmp (names[i], "url") == 0) {
+ url = values[i];
+ is_blank_page = (strcmp (url, "about:blank") == 0 ||
+ strcmp (url, "about:overview") == 0);
+ } else if (strcmp (names[i], "title") == 0) {
+ title = values[i];
+ } else if (strcmp (names[i], "loading") == 0) {
+ was_loading = strcmp (values[i], "true") == 0;
+ } else if (strcmp (names[i], "crashed") == 0) {
+ crashed = strcmp (values[i], "true") == 0;
+ } else if (strcmp (names[i], "history") == 0) {
+ history = values[i];
+ }
+ }
+
+ /* In the case that crash happens before we receive the URL from the server,
+ * this will open an about:blank tab.
+ * See http://bugzilla.gnome.org/show_bug.cgi?id=591294
+ * Otherwise, if the web was fully loaded, it is reloaded again.
+ */
+ if ((!was_loading || is_blank_page) && !crashed) {
+ EphyNewTabFlags flags;
+ EphyEmbed *embed;
+ EphyWebView *web_view;
+ gboolean delay_loading;
+ WebKitWebViewSessionState *state = NULL;
+
+ delay_loading = g_settings_get_boolean (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_RESTORE_SESSION_DELAYING_LOADS);
+
+ flags = EPHY_NEW_TAB_APPEND_LAST;
+
+ embed = ephy_shell_new_tab_full (ephy_shell_get_default (),
+ title, NULL,
+ context->window, NULL, flags,
+ 0);
+
+ web_view = ephy_embed_get_web_view (embed);
+ if (history) {
+ guchar *data;
+ gsize data_length;
+ GBytes *history_data;
+
+ data = g_base64_decode (history, &data_length);
+ history_data = g_bytes_new_take (data, data_length);
+ state = webkit_web_view_session_state_new (history_data);
+ g_bytes_unref (history_data);
+ }
+
+ if (delay_loading) {
+ WebKitURIRequest *request = webkit_uri_request_new (url);
+
+ ephy_embed_set_delayed_load_request (embed, request, state);
+ ephy_web_view_set_placeholder (web_view, url, title);
+ g_object_unref (request);
+ } else {
+ WebKitBackForwardList *bf_list;
+ WebKitBackForwardListItem *item;
+
+ if (state) {
+ webkit_web_view_restore_session_state (WEBKIT_WEB_VIEW (web_view), state);
+ }
+
+ bf_list = webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (web_view));
+ item = webkit_back_forward_list_get_current_item (bf_list);
+ if (item) {
+ webkit_web_view_go_to_back_forward_list_item (WEBKIT_WEB_VIEW (web_view), item);
+ } else {
+ ephy_web_view_load_url (web_view, url);
+ }
+ }
+
+ if (state) {
+ webkit_web_view_session_state_unref (state);
+ }
+ } else if (url && (was_loading || crashed)) {
+ /* This page was loading during a UI process crash
+ * (was_loading == TRUE) or a web process crash
+ * (crashed == TRUE) and might make Epiphany crash again.
+ */
+ confirm_before_recover (context->window, url, title);
+ }
}
static void
-session_start_element (GMarkupParseContext *ctx,
- const gchar *element_name,
- const gchar **names,
- const gchar **values,
- gpointer user_data,
- GError **error)
-{
- SessionParserContext *context = (SessionParserContext *)user_data;
-
- if (strcmp (element_name, "window") == 0)
- {
- session_parse_window (context, names, values);
- context->is_first_tab = TRUE;
- }
- else if (strcmp (element_name, "embed") == 0)
- {
- session_parse_embed (context, names, values);
- }
+session_start_element (GMarkupParseContext *ctx,
+ const gchar *element_name,
+ const gchar **names,
+ const gchar **values,
+ gpointer user_data,
+ GError **error)
+{
+ SessionParserContext *context = (SessionParserContext *)user_data;
+
+ if (strcmp (element_name, "window") == 0) {
+ session_parse_window (context, names, values);
+ context->is_first_tab = TRUE;
+ } else if (strcmp (element_name, "embed") == 0) {
+ session_parse_embed (context, names, values);
+ }
}
static void
-session_end_element (GMarkupParseContext *ctx,
- const gchar *element_name,
- gpointer user_data,
- GError **error)
+session_end_element (GMarkupParseContext *ctx,
+ const gchar *element_name,
+ gpointer user_data,
+ GError **error)
{
- SessionParserContext *context = (SessionParserContext *)user_data;
+ SessionParserContext *context = (SessionParserContext *)user_data;
- if (strcmp (element_name, "window") == 0)
- {
- GtkWidget *notebook;
- EphyEmbedShell *shell = ephy_embed_shell_get_default ();
+ if (strcmp (element_name, "window") == 0) {
+ GtkWidget *notebook;
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
- notebook = ephy_window_get_notebook (context->window);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), context->active_tab);
+ notebook = ephy_window_get_notebook (context->window);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), context->active_tab);
- if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) != EPHY_EMBED_SHELL_MODE_TEST)
- {
- EphyEmbed *active_child;
+ if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) != EPHY_EMBED_SHELL_MODE_TEST) {
+ EphyEmbed *active_child;
- active_child = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER
(context->window));
- gtk_widget_grab_focus (GTK_WIDGET (active_child));
- gtk_widget_show (GTK_WIDGET (context->window));
- }
+ active_child = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (context->window));
+ gtk_widget_grab_focus (GTK_WIDGET (active_child));
+ gtk_widget_show (GTK_WIDGET (context->window));
+ }
- ephy_embed_shell_restored_window (shell);
+ ephy_embed_shell_restored_window (shell);
- context->window = NULL;
- context->active_tab = 0;
- context->is_first_window = FALSE;
- }
- else if (strcmp (element_name, "embed") == 0)
- {
- context->is_first_tab = FALSE;
- }
+ context->window = NULL;
+ context->active_tab = 0;
+ context->is_first_window = FALSE;
+ } else if (strcmp (element_name, "embed") == 0) {
+ context->is_first_tab = FALSE;
+ }
}
static const GMarkupParser session_parser = {
- session_start_element,
- session_end_element,
- NULL,
- NULL,
- NULL
+ session_start_element,
+ session_end_element,
+ NULL,
+ NULL,
+ NULL
};
typedef struct {
- EphyShell *shell;
- GMarkupParseContext *parser;
- char buffer[1024];
+ EphyShell *shell;
+ GMarkupParseContext *parser;
+ char buffer[1024];
} LoadFromStreamAsyncData;
static LoadFromStreamAsyncData *
load_from_stream_async_data_new (GMarkupParseContext *parser)
{
- LoadFromStreamAsyncData *data;
+ LoadFromStreamAsyncData *data;
- data = g_slice_new (LoadFromStreamAsyncData);
- data->shell = g_object_ref (ephy_shell_get_default ());
- data->parser = parser;
+ data = g_slice_new (LoadFromStreamAsyncData);
+ data->shell = g_object_ref (ephy_shell_get_default ());
+ data->parser = parser;
- return data;
+ return data;
}
static void
load_from_stream_async_data_free (LoadFromStreamAsyncData *data)
{
- g_object_unref (data->shell);
- g_markup_parse_context_free (data->parser);
+ g_object_unref (data->shell);
+ g_markup_parse_context_free (data->parser);
- g_slice_free (LoadFromStreamAsyncData, data);
+ g_slice_free (LoadFromStreamAsyncData, data);
}
static void
load_stream_complete (GTask *task)
{
- EphySession *session;
+ EphySession *session;
- g_task_return_boolean (task, TRUE);
+ g_task_return_boolean (task, TRUE);
- session = EPHY_SESSION (g_task_get_source_object (task));
- session->dont_save = FALSE;
+ session = EPHY_SESSION (g_task_get_source_object (task));
+ session->dont_save = FALSE;
- ephy_session_save (session);
+ ephy_session_save (session);
- g_object_unref (task);
+ g_object_unref (task);
- g_application_release (G_APPLICATION (ephy_shell_get_default ()));
+ g_application_release (G_APPLICATION (ephy_shell_get_default ()));
}
static void
-load_stream_complete_error (GTask *task,
- GError *error)
+load_stream_complete_error (GTask *task,
+ GError *error)
{
- EphySession *session;
- LoadFromStreamAsyncData *data;
- SessionParserContext *context;
+ EphySession *session;
+ LoadFromStreamAsyncData *data;
+ SessionParserContext *context;
- g_task_return_error (task, error);
+ g_task_return_error (task, error);
- session = EPHY_SESSION (g_task_get_source_object (task));
- session->dont_save = FALSE;
- /* If the session fails to load for whatever reason,
- * delete the file and open an empty window.
- */
- session_delete (session);
+ session = EPHY_SESSION (g_task_get_source_object (task));
+ session->dont_save = FALSE;
+ /* If the session fails to load for whatever reason,
+ * delete the file and open an empty window.
+ */
+ session_delete (session);
- data = g_task_get_task_data (task);
- context = (SessionParserContext *)g_markup_parse_context_get_user_data (data->parser);
- session_maybe_open_window (session, context->user_time);
+ data = g_task_get_task_data (task);
+ context = (SessionParserContext *)g_markup_parse_context_get_user_data (data->parser);
+ session_maybe_open_window (session, context->user_time);
- g_object_unref (task);
+ g_object_unref (task);
- g_application_release (G_APPLICATION (ephy_shell_get_default ()));
+ g_application_release (G_APPLICATION (ephy_shell_get_default ()));
}
static void
-load_stream_read_cb (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
-{
- GInputStream *stream = G_INPUT_STREAM (object);
- GTask *task = G_TASK (user_data);
- LoadFromStreamAsyncData *data;
- gssize bytes_read;
- GError *error = NULL;
-
- bytes_read = g_input_stream_read_finish (stream, result, &error);
- if (bytes_read < 0)
- {
- load_stream_complete_error (task, error);
-
- return;
- }
-
- data = g_task_get_task_data (task);
- if (bytes_read == 0)
- {
- if (!g_markup_parse_context_end_parse (data->parser, &error))
- {
- load_stream_complete_error (task, error);
- }
- else
- {
- load_stream_complete (task);
- }
-
- return;
- }
-
- if (!g_markup_parse_context_parse (data->parser, data->buffer, bytes_read, &error))
- {
- load_stream_complete_error (task, error);
-
- return;
- }
-
- g_input_stream_read_async (stream, data->buffer, sizeof (data->buffer),
- g_task_get_priority (task),
- g_task_get_cancellable (task),
- load_stream_read_cb, task);
+load_stream_read_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GInputStream *stream = G_INPUT_STREAM (object);
+ GTask *task = G_TASK (user_data);
+ LoadFromStreamAsyncData *data;
+ gssize bytes_read;
+ GError *error = NULL;
+
+ bytes_read = g_input_stream_read_finish (stream, result, &error);
+ if (bytes_read < 0) {
+ load_stream_complete_error (task, error);
+
+ return;
+ }
+
+ data = g_task_get_task_data (task);
+ if (bytes_read == 0) {
+ if (!g_markup_parse_context_end_parse (data->parser, &error)) {
+ load_stream_complete_error (task, error);
+ } else {
+ load_stream_complete (task);
+ }
+
+ return;
+ }
+
+ if (!g_markup_parse_context_parse (data->parser, data->buffer, bytes_read, &error)) {
+ load_stream_complete_error (task, error);
+
+ return;
+ }
+
+ g_input_stream_read_async (stream, data->buffer, sizeof (data->buffer),
+ g_task_get_priority (task),
+ g_task_get_cancellable (task),
+ load_stream_read_cb, task);
}
/**
@@ -1439,39 +1339,39 @@ load_stream_read_cb (GObject *object,
* the operation.
**/
void
-ephy_session_load_from_stream (EphySession *session,
- GInputStream *stream,
- guint32 user_time,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+ephy_session_load_from_stream (EphySession *session,
+ GInputStream *stream,
+ guint32 user_time,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
- GTask *task;
- SessionParserContext *context;
- GMarkupParseContext *parser;
- LoadFromStreamAsyncData *data;
+ GTask *task;
+ SessionParserContext *context;
+ GMarkupParseContext *parser;
+ LoadFromStreamAsyncData *data;
- g_return_if_fail (EPHY_IS_SESSION (session));
- g_return_if_fail (G_IS_INPUT_STREAM (stream));
+ g_return_if_fail (EPHY_IS_SESSION (session));
+ g_return_if_fail (G_IS_INPUT_STREAM (stream));
- g_application_hold (G_APPLICATION (ephy_shell_get_default ()));
+ g_application_hold (G_APPLICATION (ephy_shell_get_default ()));
- session->dont_save = TRUE;
+ session->dont_save = TRUE;
- task = g_task_new (session, cancellable, callback, user_data);
- /* Use a priority lower than drawing events (HIGH_IDLE + 20) to make sure
- * the main window is shown as soon as possible at startup
- */
- g_task_set_priority (task, G_PRIORITY_HIGH_IDLE + 30);
+ task = g_task_new (session, cancellable, callback, user_data);
+ /* Use a priority lower than drawing events (HIGH_IDLE + 20) to make sure
+ * the main window is shown as soon as possible at startup
+ */
+ g_task_set_priority (task, G_PRIORITY_HIGH_IDLE + 30);
- context = session_parser_context_new (session, user_time);
- parser = g_markup_parse_context_new (&session_parser, 0, context,
(GDestroyNotify)session_parser_context_free);
- data = load_from_stream_async_data_new (parser);
- g_task_set_task_data (task, data, (GDestroyNotify)load_from_stream_async_data_free);
+ context = session_parser_context_new (session, user_time);
+ parser = g_markup_parse_context_new (&session_parser, 0, context,
(GDestroyNotify)session_parser_context_free);
+ data = load_from_stream_async_data_new (parser);
+ g_task_set_task_data (task, data, (GDestroyNotify)load_from_stream_async_data_free);
- g_input_stream_read_async (stream, data->buffer, sizeof (data->buffer),
- g_task_get_priority (task), cancellable,
- load_stream_read_cb, task);
+ g_input_stream_read_async (stream, data->buffer, sizeof (data->buffer),
+ g_task_get_priority (task), cancellable,
+ load_stream_read_cb, task);
}
/**
@@ -1486,85 +1386,79 @@ ephy_session_load_from_stream (EphySession *session,
* Returns: %TRUE if at least a window has been opened
**/
gboolean
-ephy_session_load_from_stream_finish (EphySession *session,
- GAsyncResult *result,
- GError **error)
+ephy_session_load_from_stream_finish (EphySession *session,
+ GAsyncResult *result,
+ GError **error)
{
- g_return_val_if_fail (g_task_is_valid (result, session), FALSE);
+ g_return_val_if_fail (g_task_is_valid (result, session), FALSE);
- return g_task_propagate_boolean (G_TASK (result), error);
+ return g_task_propagate_boolean (G_TASK (result), error);
}
typedef struct {
- guint32 user_time;
+ guint32 user_time;
} LoadAsyncData;
static LoadAsyncData *
load_async_data_new (guint32 user_time)
{
- LoadAsyncData *data;
+ LoadAsyncData *data;
- data = g_slice_new (LoadAsyncData);
- data->user_time = user_time;
+ data = g_slice_new (LoadAsyncData);
+ data->user_time = user_time;
- return data;
+ return data;
}
static void
load_async_data_free (LoadAsyncData *data)
{
- g_slice_free (LoadAsyncData, data);
+ g_slice_free (LoadAsyncData, data);
}
static void
-load_from_stream_cb (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
+load_from_stream_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- EphySession *session = EPHY_SESSION (object);
- GTask *task = G_TASK (user_data);
- GError *error = NULL;
+ EphySession *session = EPHY_SESSION (object);
+ GTask *task = G_TASK (user_data);
+ GError *error = NULL;
- if (!ephy_session_load_from_stream_finish (session, result, &error))
- {
- g_task_return_error (task, error);
- }
- else
- {
- g_task_return_boolean (task, TRUE);
- }
+ if (!ephy_session_load_from_stream_finish (session, result, &error)) {
+ g_task_return_error (task, error);
+ } else {
+ g_task_return_boolean (task, TRUE);
+ }
- g_object_unref (task);
+ g_object_unref (task);
}
static void
-session_read_cb (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
-{
- GFileInputStream *stream;
- GTask *task = G_TASK (user_data);
- GError *error = NULL;
-
- stream = g_file_read_finish (G_FILE (object), result, &error);
- if (stream)
- {
- EphySession *session;
- LoadAsyncData *data;
-
- session = EPHY_SESSION (g_task_get_source_object (task));
- data = g_task_get_task_data (task);
- ephy_session_load_from_stream (session, G_INPUT_STREAM (stream), data->user_time,
- g_task_get_cancellable (task), load_from_stream_cb, task);
- g_object_unref (stream);
- }
- else
- {
- g_task_return_error (task, error);
- g_object_unref (task);
- }
-
- g_application_release (G_APPLICATION (ephy_shell_get_default ()));
+session_read_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GFileInputStream *stream;
+ GTask *task = G_TASK (user_data);
+ GError *error = NULL;
+
+ stream = g_file_read_finish (G_FILE (object), result, &error);
+ if (stream) {
+ EphySession *session;
+ LoadAsyncData *data;
+
+ session = EPHY_SESSION (g_task_get_source_object (task));
+ data = g_task_get_task_data (task);
+ ephy_session_load_from_stream (session, G_INPUT_STREAM (stream), data->user_time,
+ g_task_get_cancellable (task), load_from_stream_cb, task);
+ g_object_unref (stream);
+ } else {
+ g_task_return_error (task, error);
+ g_object_unref (task);
+ }
+
+ g_application_release (G_APPLICATION (ephy_shell_get_default ()));
}
/**
@@ -1585,35 +1479,35 @@ session_read_cb (GObject *object,
* the operation.
**/
void
-ephy_session_load (EphySession *session,
- const char *filename,
- guint32 user_time,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+ephy_session_load (EphySession *session,
+ const char *filename,
+ guint32 user_time,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
- GFile *save_to_file;
- GTask *task;
- LoadAsyncData *data;
+ GFile *save_to_file;
+ GTask *task;
+ LoadAsyncData *data;
- g_return_if_fail (EPHY_IS_SESSION (session));
- g_return_if_fail (filename);
+ g_return_if_fail (EPHY_IS_SESSION (session));
+ g_return_if_fail (filename);
- LOG ("ephy_sesion_load %s", filename);
+ LOG ("ephy_sesion_load %s", filename);
- g_application_hold (G_APPLICATION (ephy_shell_get_default ()));
+ g_application_hold (G_APPLICATION (ephy_shell_get_default ()));
- task = g_task_new (session, cancellable, callback, user_data);
- /* Use a priority lower than drawing events (HIGH_IDLE + 20) to make sure
- * the main window is shown as soon as possible at startup
- */
- g_task_set_priority (task, G_PRIORITY_HIGH_IDLE + 30);
+ task = g_task_new (session, cancellable, callback, user_data);
+ /* Use a priority lower than drawing events (HIGH_IDLE + 20) to make sure
+ * the main window is shown as soon as possible at startup
+ */
+ g_task_set_priority (task, G_PRIORITY_HIGH_IDLE + 30);
- save_to_file = get_session_file (filename);
- data = load_async_data_new (user_time);
- g_task_set_task_data (task, data, (GDestroyNotify)load_async_data_free);
- g_file_read_async (save_to_file, g_task_get_priority (task), cancellable, session_read_cb, task);
- g_object_unref (save_to_file);
+ save_to_file = get_session_file (filename);
+ data = load_async_data_new (user_time);
+ g_task_set_task_data (task, data, (GDestroyNotify)load_async_data_free);
+ g_file_read_async (save_to_file, g_task_get_priority (task), cancellable, session_read_cb, task);
+ g_object_unref (save_to_file);
}
/**
@@ -1628,124 +1522,118 @@ ephy_session_load (EphySession *session,
* Returns: %TRUE if at least a window has been opened
**/
gboolean
-ephy_session_load_finish (EphySession *session,
- GAsyncResult *result,
- GError **error)
+ephy_session_load_finish (EphySession *session,
+ GAsyncResult *result,
+ GError **error)
{
- g_return_val_if_fail (g_task_is_valid (result, session), FALSE);
+ g_return_val_if_fail (g_task_is_valid (result, session), FALSE);
- return g_task_propagate_boolean (G_TASK (result), error);
+ return g_task_propagate_boolean (G_TASK (result), error);
}
static gboolean
session_state_file_exists (EphySession *session)
{
- GFile *saved_session_file;
- char *saved_session_file_path;
- gboolean retval;
+ GFile *saved_session_file;
+ char *saved_session_file_path;
+ gboolean retval;
- saved_session_file = get_session_file (SESSION_STATE);
- saved_session_file_path = g_file_get_path (saved_session_file);
- g_object_unref (saved_session_file);
- retval = g_file_test (saved_session_file_path, G_FILE_TEST_EXISTS);
- g_free (saved_session_file_path);
+ saved_session_file = get_session_file (SESSION_STATE);
+ saved_session_file_path = g_file_get_path (saved_session_file);
+ g_object_unref (saved_session_file);
+ retval = g_file_test (saved_session_file_path, G_FILE_TEST_EXISTS);
+ g_free (saved_session_file_path);
- return retval;
+ return retval;
}
static void
-session_resumed_cb (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
+session_resumed_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- EphySession *session = EPHY_SESSION (object);
- GTask *task = G_TASK (user_data);
- GError *error = NULL;
+ EphySession *session = EPHY_SESSION (object);
+ GTask *task = G_TASK (user_data);
+ GError *error = NULL;
- if (!ephy_session_load_finish (session, result, &error))
- {
- g_task_return_error (task, error);
- }
- else
- {
- g_task_return_boolean (task, TRUE);
- }
+ if (!ephy_session_load_finish (session, result, &error)) {
+ g_task_return_error (task, error);
+ } else {
+ g_task_return_boolean (task, TRUE);
+ }
- g_object_unref (task);
+ g_object_unref (task);
}
void
-ephy_session_resume (EphySession *session,
- guint32 user_time,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+ephy_session_resume (EphySession *session,
+ guint32 user_time,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
- GTask *task;
- gboolean has_session_state;
- EphyPrefsRestoreSessionPolicy policy;
- EphyShell *shell;
+ GTask *task;
+ gboolean has_session_state;
+ EphyPrefsRestoreSessionPolicy policy;
+ EphyShell *shell;
- LOG ("ephy_session_resume");
+ LOG ("ephy_session_resume");
- task = g_task_new (session, cancellable, callback, user_data);
+ task = g_task_new (session, cancellable, callback, user_data);
- has_session_state = session_state_file_exists (session);
+ has_session_state = session_state_file_exists (session);
- policy = g_settings_get_enum (EPHY_SETTINGS_MAIN,
- EPHY_PREFS_RESTORE_SESSION_POLICY);
+ policy = g_settings_get_enum (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_RESTORE_SESSION_POLICY);
- shell = ephy_shell_get_default ();
+ shell = ephy_shell_get_default ();
- if (has_session_state == FALSE ||
- policy == EPHY_PREFS_RESTORE_SESSION_POLICY_NEVER)
- {
- /* If we are auto-resuming, and we never want to
- * restore the session, clobber the session state
- * file. */
- if (policy == EPHY_PREFS_RESTORE_SESSION_POLICY_NEVER)
- session_delete (session);
+ if (has_session_state == FALSE ||
+ policy == EPHY_PREFS_RESTORE_SESSION_POLICY_NEVER) {
+ /* If we are auto-resuming, and we never want to
+ * restore the session, clobber the session state
+ * file. */
+ if (policy == EPHY_PREFS_RESTORE_SESSION_POLICY_NEVER)
+ session_delete (session);
- session_maybe_open_window (session, user_time);
- }
- else if (ephy_shell_get_n_windows (shell) == 0)
- {
- ephy_session_load (session, SESSION_STATE, user_time, cancellable,
- session_resumed_cb, task);
- return;
- }
+ session_maybe_open_window (session, user_time);
+ } else if (ephy_shell_get_n_windows (shell) == 0) {
+ ephy_session_load (session, SESSION_STATE, user_time, cancellable,
+ session_resumed_cb, task);
+ return;
+ }
- g_task_return_boolean (task, TRUE);
- g_object_unref (task);
+ g_task_return_boolean (task, TRUE);
+ g_object_unref (task);
}
gboolean
-ephy_session_resume_finish (EphySession *session,
- GAsyncResult *result,
- GError **error)
+ephy_session_resume_finish (EphySession *session,
+ GAsyncResult *result,
+ GError **error)
{
- g_return_val_if_fail (g_task_is_valid (result, session), FALSE);
+ g_return_val_if_fail (g_task_is_valid (result, session), FALSE);
- return g_task_propagate_boolean (G_TASK (result), error);
+ return g_task_propagate_boolean (G_TASK (result), error);
}
void
ephy_session_clear (EphySession *session)
{
- EphyShell *shell;
- GList *windows, *p;
+ EphyShell *shell;
+ GList *windows, *p;
- g_return_if_fail (EPHY_IS_SESSION (session));
+ g_return_if_fail (EPHY_IS_SESSION (session));
- shell = ephy_shell_get_default ();
- windows = g_list_copy (gtk_application_get_windows (GTK_APPLICATION (shell)));
- for (p = windows; p; p = p->next)
- gtk_widget_destroy (GTK_WIDGET (p->data));
- g_list_free (windows);
- g_queue_foreach (session->closed_tabs,
- (GFunc)closed_tab_free, NULL);
- g_queue_clear (session->closed_tabs);
+ shell = ephy_shell_get_default ();
+ windows = g_list_copy (gtk_application_get_windows (GTK_APPLICATION (shell)));
+ for (p = windows; p; p = p->next)
+ gtk_widget_destroy (GTK_WIDGET (p->data));
+ g_list_free (windows);
+ g_queue_foreach (session->closed_tabs,
+ (GFunc)closed_tab_free, NULL);
+ g_queue_clear (session->closed_tabs);
- ephy_session_save (session);
+ ephy_session_save (session);
}
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 88560e8..4543ca4 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -67,8 +67,8 @@ struct _EphyShell {
static EphyShell *ephy_shell = NULL;
-static void ephy_shell_dispose (GObject *object);
-static void ephy_shell_finalize (GObject *object);
+static void ephy_shell_dispose (GObject *object);
+static void ephy_shell_finalize (GObject *object);
G_DEFINE_TYPE (EphyShell, ephy_shell, EPHY_TYPE_EMBED_SHELL)
@@ -150,40 +150,40 @@ ephy_shell_startup_continue (EphyShell *shell, EphyShellStartupContext *ctx)
static void
new_window (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+ GVariant *parameter,
+ gpointer user_data)
{
window_cmd_file_new_window (NULL, NULL);
}
static void
new_incognito_window (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+ GVariant *parameter,
+ gpointer user_data)
{
window_cmd_file_new_incognito_window (NULL, NULL);
}
static void
reopen_closed_tab (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+ GVariant *parameter,
+ gpointer user_data)
{
window_cmd_undo_close_tab (NULL, NULL);
}
static void
show_bookmarks (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+ GVariant *parameter,
+ gpointer user_data)
{
window_cmd_edit_bookmarks (NULL, NULL);
}
static void
show_history (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+ GVariant *parameter,
+ gpointer user_data)
{
GtkWindow *window;
@@ -194,8 +194,8 @@ show_history (GSimpleAction *action,
static void
show_preferences (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+ GVariant *parameter,
+ gpointer user_data)
{
GtkWindow *window;
@@ -206,8 +206,8 @@ show_preferences (GSimpleAction *action,
static void
show_help (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+ GVariant *parameter,
+ gpointer user_data)
{
GtkWindow *window;
@@ -218,8 +218,8 @@ show_help (GSimpleAction *action,
static void
show_about (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+ GVariant *parameter,
+ gpointer user_data)
{
GtkWindow *window;
@@ -230,8 +230,8 @@ show_about (GSimpleAction *action,
static void
quit_application (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+ GVariant *parameter,
+ gpointer user_data)
{
window_cmd_file_quit (NULL, NULL);
}
@@ -253,8 +253,8 @@ static GActionEntry app_normal_mode_entries[] = {
static void
download_started_cb (WebKitWebContext *web_context,
- WebKitDownload *download,
- EphyShell *shell)
+ WebKitDownload *download,
+ EphyShell *shell)
{
EphyDownload *ephy_download;
gboolean ephy_download_set;
@@ -282,7 +282,7 @@ download_started_cb (WebKitWebContext *web_context,
}
static void
-ephy_shell_startup (GApplication* application)
+ephy_shell_startup (GApplication *application)
{
EphyEmbedShell *embed_shell = EPHY_EMBED_SHELL (application);
EphyEmbedShellMode mode;
@@ -327,9 +327,9 @@ ephy_shell_startup (GApplication* application)
}
static void
-session_load_cb (GObject *object,
+session_load_cb (GObject *object,
GAsyncResult *result,
- gpointer user_data)
+ gpointer user_data)
{
EphySession *session = EPHY_SESSION (object);
EphyShellStartupContext *ctx = (EphyShellStartupContext *)user_data;
@@ -377,14 +377,14 @@ typedef enum {
} CtxEnum;
static void
-ephy_shell_add_platform_data (GApplication *application,
+ephy_shell_add_platform_data (GApplication *application,
GVariantBuilder *builder)
{
EphyShell *app;
EphyShellStartupContext *ctx;
GVariantBuilder *ctx_builder;
static const char *empty_arguments[] = { "", NULL };
- const char* const * arguments;
+ const char * const *arguments;
app = EPHY_SHELL (application);
@@ -446,7 +446,7 @@ ephy_shell_add_platform_data (GApplication *application,
static void
ephy_shell_before_emit (GApplication *application,
- GVariant *platform_data)
+ GVariant *platform_data)
{
GVariantIter iter, ctx_iter;
const char *key;
@@ -468,27 +468,27 @@ ephy_shell_before_emit (GApplication *application,
g_variant_iter_init (&ctx_iter, value);
while (g_variant_iter_loop (&ctx_iter, "{iv}", &ctx_key, &ctx_value)) {
switch (ctx_key) {
- case CTX_STARTUP_FLAGS:
- ctx->startup_flags = g_variant_get_byte (ctx_value);
- break;
- case CTX_BOOKMARKS_FILENAME:
- ctx->bookmarks_filename = g_variant_dup_string (ctx_value, NULL);
- break;
- case CTX_SESSION_FILENAME:
- ctx->session_filename = g_variant_dup_string (ctx_value, NULL);
- break;
- case CTX_BOOKMARK_URL:
- ctx->bookmark_url = g_variant_dup_string (ctx_value, NULL);
- break;
- case CTX_ARGUMENTS:
- ctx->arguments = g_variant_dup_strv (ctx_value, NULL);
- break;
- case CTX_USER_TIME:
- ctx->user_time = g_variant_get_uint32 (ctx_value);
- break;
- default:
- g_assert_not_reached ();
- break;
+ case CTX_STARTUP_FLAGS:
+ ctx->startup_flags = g_variant_get_byte (ctx_value);
+ break;
+ case CTX_BOOKMARKS_FILENAME:
+ ctx->bookmarks_filename = g_variant_dup_string (ctx_value, NULL);
+ break;
+ case CTX_SESSION_FILENAME:
+ ctx->session_filename = g_variant_dup_string (ctx_value, NULL);
+ break;
+ case CTX_BOOKMARK_URL:
+ ctx->bookmark_url = g_variant_dup_string (ctx_value, NULL);
+ break;
+ case CTX_ARGUMENTS:
+ ctx->arguments = g_variant_dup_strv (ctx_value, NULL);
+ break;
+ case CTX_USER_TIME:
+ ctx->user_time = g_variant_get_uint32 (ctx_value);
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
}
}
}
@@ -625,13 +625,13 @@ ephy_shell_get_default (void)
* Return value: (transfer none): the created #EphyEmbed
**/
EphyEmbed *
-ephy_shell_new_tab_full (EphyShell *shell,
- const char *title,
- WebKitWebView *related_view,
- EphyWindow *window,
- EphyEmbed *previous_embed,
+ephy_shell_new_tab_full (EphyShell *shell,
+ const char *title,
+ WebKitWebView *related_view,
+ EphyWindow *window,
+ EphyEmbed *previous_embed,
EphyNewTabFlags flags,
- guint32 user_time)
+ guint32 user_time)
{
EphyEmbedShell *embed_shell;
GtkWidget *web_view;
@@ -697,9 +697,9 @@ ephy_shell_new_tab_full (EphyShell *shell,
* Return value: (transfer none): the created #EphyEmbed
**/
EphyEmbed *
-ephy_shell_new_tab (EphyShell *shell,
- EphyWindow *parent_window,
- EphyEmbed *previous_embed,
+ephy_shell_new_tab (EphyShell *shell,
+ EphyWindow *parent_window,
+ EphyEmbed *previous_embed,
EphyNewTabFlags flags)
{
return ephy_shell_new_tab_full (shell, NULL, NULL, parent_window,
@@ -789,7 +789,7 @@ ephy_shell_get_history_window (EphyShell *shell)
if (shell->history_window == NULL) {
service = EPHY_HISTORY_SERVICE
- (ephy_embed_shell_get_global_history_service (embed_shell));
+ (ephy_embed_shell_get_global_history_service (embed_shell));
shell->history_window = ephy_history_window_new (service);
g_signal_connect (shell->history_window,
"destroy",
@@ -843,7 +843,7 @@ _ephy_shell_create_instance (EphyEmbedShellMode mode)
* See ephy_shell_set_startup_new().
**/
void
-ephy_shell_set_startup_context (EphyShell *shell,
+ephy_shell_set_startup_context (EphyShell *shell,
EphyShellStartupContext *ctx)
{
g_return_if_fail (EPHY_IS_SHELL (shell));
@@ -903,10 +903,10 @@ typedef struct {
} OpenURIsData;
static OpenURIsData *
-open_uris_data_new (EphyShell *shell,
- const char **uris,
+open_uris_data_new (EphyShell *shell,
+ const char **uris,
EphyStartupFlags startup_flags,
- guint32 user_time)
+ guint32 user_time)
{
OpenURIsData *data;
gboolean new_windows_in_tabs;
@@ -924,7 +924,7 @@ open_uris_data_new (EphyShell *shell,
fullscreen_lockdown = g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
EPHY_PREFS_LOCKDOWN_FULLSCREEN);
- have_uris = ! (g_strv_length ((char **)uris) == 1 && g_str_equal (uris[0], ""));
+ have_uris = !(g_strv_length ((char **)uris) == 1 && g_str_equal (uris[0], ""));
if (startup_flags & EPHY_STARTUP_NEW_WINDOW && !fullscreen_lockdown) {
data->window = ephy_window_new ();
@@ -1009,10 +1009,10 @@ ephy_shell_open_uris_idle_done (OpenURIsData *data)
}
void
-ephy_shell_open_uris (EphyShell *shell,
- const char **uris,
+ephy_shell_open_uris (EphyShell *shell,
+ const char **uris,
EphyStartupFlags startup_flags,
- guint32 user_time)
+ guint32 user_time)
{
OpenURIsData *data;
guint id;
diff --git a/src/ephy-title-box.c b/src/ephy-title-box.c
index 0223eea..70af11b 100644
--- a/src/ephy-title-box.c
+++ b/src/ephy-title-box.c
@@ -42,16 +42,14 @@ enum {
static GParamSpec *object_properties[N_PROPERTIES] = { NULL, };
-enum
-{
+enum {
LOCK_CLICKED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
-struct _EphyTitleBox
-{
+struct _EphyTitleBox {
GtkStack parent_instance;
EphyWindow *window;
@@ -83,8 +81,7 @@ ephy_title_box_get_property (GObject *object,
{
EphyTitleBox *title_box = EPHY_TITLE_BOX (object);
- switch (prop_id)
- {
+ switch (prop_id) {
case PROP_MODE:
g_value_set_enum (value, ephy_title_box_get_mode (title_box));
break;
@@ -101,8 +98,7 @@ ephy_title_box_set_property (GObject *object,
{
EphyTitleBox *title_box = EPHY_TITLE_BOX (object);
- switch (prop_id)
- {
+ switch (prop_id) {
case PROP_WINDOW:
title_box->window = EPHY_WINDOW (g_value_get_object (value));
break;
@@ -120,7 +116,7 @@ ephy_title_box_entry_key_press_cb (GtkWidget *widget,
gpointer user_data)
{
EphyTitleBox *title_box = EPHY_TITLE_BOX (user_data);
- guint state = event->state & gtk_accelerator_get_default_mod_mask ();
+ guint state = event->state & gtk_accelerator_get_default_mod_mask ();
LOG ("key-press-event entry %p event %p title-box %p", widget, event, title_box);
@@ -199,7 +195,7 @@ ephy_title_box_add_title_bar (EphyTitleBox *title_box)
static void
sync_chromes_visibility (EphyTitleBox *title_box)
{
- EphyWindowChrome chrome;
+ EphyWindowChrome chrome;
chrome = ephy_window_get_chrome (title_box->window);
title_box->location_disabled = !(chrome & EPHY_WINDOW_CHROME_LOCATION);
@@ -213,7 +209,7 @@ static void
ephy_title_box_constructed (GObject *object)
{
EphyTitleBox *title_box = EPHY_TITLE_BOX (object);
- EphyWindowChrome chrome;
+ EphyWindowChrome chrome;
LOG ("EphyTitleBox constructed");
@@ -248,7 +244,7 @@ ephy_title_box_switch_to_entry_timeout_cb (gpointer user_data)
EphyTitleBox *title_box = EPHY_TITLE_BOX (user_data);
LOG ("switch_to_entry_timeout_cb title-box %p switch_to_entry_timeout_id %u",
- title_box, title_box->switch_to_entry_timeout_id);
+ title_box, title_box->switch_to_entry_timeout_id);
title_box->switch_to_entry_timeout_id = 0;
ephy_title_box_set_mode (title_box, EPHY_TITLE_BOX_MODE_LOCATION_ENTRY);
@@ -260,13 +256,13 @@ ephy_title_box_switch_to_entry_timeout_cb (gpointer user_data)
static void
ephy_title_box_switch_to_entry_after_double_click_time (EphyTitleBox *title_box)
{
- gint double_click_time;
+ gint double_click_time;
if (title_box->switch_to_entry_timeout_id > 0)
return;
LOG ("switch_to_entry_after_double_click_time title-box %p switch_to_entry_timeout_id %u",
- title_box, title_box->switch_to_entry_timeout_id);
+ title_box, title_box->switch_to_entry_timeout_id);
g_object_get (gtk_widget_get_settings (GTK_WIDGET (title_box)),
"gtk-double-click-time", &double_click_time,
@@ -287,7 +283,7 @@ ephy_title_box_cancel_switch_to_entry_after_double_click_time (EphyTitleBox *tit
return;
LOG ("cancel_switch_to_entry_after_double_click_time title-box %p switch_to_entry_timeout_id %u",
- title_box, title_box->switch_to_entry_timeout_id);
+ title_box, title_box->switch_to_entry_timeout_id);
g_source_remove (title_box->switch_to_entry_timeout_id);
title_box->switch_to_entry_timeout_id = 0;
@@ -317,7 +313,7 @@ ephy_title_box_button_press_event (GtkWidget *widget,
GdkEventButton *event)
{
EphyTitleBox *title_box = EPHY_TITLE_BOX (widget);
- GtkAllocation lock_allocation;
+ GtkAllocation lock_allocation;
if (title_box->mode != EPHY_TITLE_BOX_MODE_TITLE)
return GDK_EVENT_PROPAGATE;
@@ -527,7 +523,7 @@ ephy_title_box_set_web_view (EphyTitleBox *title_box,
title = webkit_web_view_get_title (web_view);
ephy_title_box_set_mode (title_box, title && *title != '\0' ?
- EPHY_TITLE_BOX_MODE_TITLE : EPHY_TITLE_BOX_MODE_LOCATION_ENTRY);
+ EPHY_TITLE_BOX_MODE_TITLE : EPHY_TITLE_BOX_MODE_LOCATION_ENTRY);
title_box->title_binding = g_object_bind_property (title_box->web_view, "title",
title_box->title, "label",
@@ -614,8 +610,8 @@ ephy_title_box_set_mode (EphyTitleBox *title_box,
* Sets the lock icon to be displayed by the title box and location entry
**/
void
-ephy_title_box_set_security_level (EphyTitleBox *title_box,
- EphySecurityLevel security_level)
+ephy_title_box_set_security_level (EphyTitleBox *title_box,
+ EphySecurityLevel security_level)
{
const char *icon_name;
@@ -657,7 +653,7 @@ ephy_title_box_get_location_entry (EphyTitleBox *title_box)
*/
void
ephy_title_box_set_address (EphyTitleBox *title_box,
- const char *address)
+ const char *address)
{
EphyEmbedShellMode mode;
diff --git a/src/ephy-toolbar.c b/src/ephy-toolbar.c
index aeec113..7b21dd1 100644
--- a/src/ephy-toolbar.c
+++ b/src/ephy-toolbar.c
@@ -52,8 +52,8 @@ G_DEFINE_TYPE (EphyToolbar, ephy_toolbar, GTK_TYPE_HEADER_BAR)
static void
download_added_cb (EphyDownloadsManager *manager,
- EphyDownload *download,
- EphyToolbar *toolbar)
+ EphyDownload *download,
+ EphyToolbar *toolbar)
{
if (!toolbar->downloads_popover) {
toolbar->downloads_popover = ephy_downloads_popover_new (toolbar->downloads_button);
@@ -67,16 +67,16 @@ download_added_cb (EphyDownloadsManager *manager,
static void
download_completed_cb (EphyDownloadsManager *manager,
- EphyDownload *download,
- EphyToolbar *toolbar)
+ EphyDownload *download,
+ EphyToolbar *toolbar)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toolbar->downloads_button), TRUE);
}
static void
download_removed_cb (EphyDownloadsManager *manager,
- EphyDownload *download,
- EphyToolbar *toolbar)
+ EphyDownload *download,
+ EphyToolbar *toolbar)
{
if (!ephy_downloads_manager_get_downloads (manager))
gtk_revealer_set_reveal_child (GTK_REVEALER (toolbar->downloads_revealer), FALSE);
@@ -84,43 +84,43 @@ download_removed_cb (EphyDownloadsManager *manager,
static void
downloads_estimated_progress_cb (EphyDownloadsManager *manager,
- EphyToolbar *toolbar)
+ EphyToolbar *toolbar)
{
gtk_widget_queue_draw (gtk_button_get_image (GTK_BUTTON (toolbar->downloads_button)));
}
static void
-ephy_toolbar_set_property (GObject *object,
- guint property_id,
+ephy_toolbar_set_property (GObject *object,
+ guint property_id,
const GValue *value,
- GParamSpec *pspec)
+ GParamSpec *pspec)
{
EphyToolbar *toolbar = EPHY_TOOLBAR (object);
switch (property_id) {
- case PROP_WINDOW:
- toolbar->window = EPHY_WINDOW (g_value_get_object (value));
- g_object_notify_by_pspec (object, object_properties[PROP_WINDOW]);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ case PROP_WINDOW:
+ toolbar->window = EPHY_WINDOW (g_value_get_object (value));
+ g_object_notify_by_pspec (object, object_properties[PROP_WINDOW]);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
-ephy_toolbar_get_property (GObject *object,
- guint property_id,
- GValue *value,
+ephy_toolbar_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
GParamSpec *pspec)
{
EphyToolbar *toolbar = EPHY_TOOLBAR (object);
switch (property_id) {
- case PROP_WINDOW:
- g_value_set_object (value, toolbar->window);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ case PROP_WINDOW:
+ g_value_set_object (value, toolbar->window);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
@@ -271,22 +271,22 @@ ephy_toolbar_constructed (GObject *object)
static void
ephy_toolbar_class_init (EphyToolbarClass *klass)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->set_property = ephy_toolbar_set_property;
- gobject_class->get_property = ephy_toolbar_get_property;
- gobject_class->constructed = ephy_toolbar_constructed;
-
- object_properties[PROP_WINDOW] =
- g_param_spec_object ("window",
- "Window",
- "The toolbar's EphyWindow",
- EPHY_TYPE_WINDOW,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties (gobject_class,
- N_PROPERTIES,
- object_properties);
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->set_property = ephy_toolbar_set_property;
+ gobject_class->get_property = ephy_toolbar_get_property;
+ gobject_class->constructed = ephy_toolbar_constructed;
+
+ object_properties[PROP_WINDOW] =
+ g_param_spec_object ("window",
+ "Window",
+ "The toolbar's EphyWindow",
+ EPHY_TYPE_WINDOW,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (gobject_class,
+ N_PROPERTIES,
+ object_properties);
}
static void
@@ -294,15 +294,15 @@ ephy_toolbar_init (EphyToolbar *toolbar)
{
}
-GtkWidget*
+GtkWidget *
ephy_toolbar_new (EphyWindow *window)
{
- g_return_val_if_fail (EPHY_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (EPHY_IS_WINDOW (window), NULL);
- return GTK_WIDGET (g_object_new (EPHY_TYPE_TOOLBAR,
- "show-close-button", TRUE,
- "window", window,
- NULL));
+ return GTK_WIDGET (g_object_new (EPHY_TYPE_TOOLBAR,
+ "show-close-button", TRUE,
+ "window", window,
+ NULL));
}
GtkWidget *
diff --git a/src/ephy-window-action.c b/src/ephy-window-action.c
index 4f91f93..875d8e3 100644
--- a/src/ephy-window-action.c
+++ b/src/ephy-window-action.c
@@ -24,13 +24,13 @@
#define EPHY_WINDOW_ACTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EPHY_TYPE_WINDOW_ACTION,
EphyWindowActionPrivate))
struct _EphyWindowActionPrivate {
- EphyWindow *window;
+ EphyWindow *window;
};
enum {
- PROP_0,
- PROP_WINDOW,
- LAST_PROP
+ PROP_0,
+ PROP_WINDOW,
+ LAST_PROP
};
static GParamSpec *obj_properties[LAST_PROP];
@@ -40,67 +40,67 @@ G_DEFINE_TYPE (EphyWindowAction, ephy_window_action, GTK_TYPE_ACTION)
static void
ephy_window_action_init (EphyWindowAction *action)
{
- action->priv = EPHY_WINDOW_ACTION_GET_PRIVATE (action);
+ action->priv = EPHY_WINDOW_ACTION_GET_PRIVATE (action);
}
static void
-ephy_window_action_set_property (GObject *object,
- guint property_id,
+ephy_window_action_set_property (GObject *object,
+ guint property_id,
const GValue *value,
- GParamSpec *pspec)
+ GParamSpec *pspec)
{
- EphyWindowAction *action = EPHY_WINDOW_ACTION (object);
+ EphyWindowAction *action = EPHY_WINDOW_ACTION (object);
- switch (property_id) {
+ switch (property_id) {
case PROP_WINDOW:
- action->priv->window = EPHY_WINDOW (g_value_get_object (value));
- break;
+ action->priv->window = EPHY_WINDOW (g_value_get_object (value));
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- }
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
}
static void
-ephy_window_action_get_property (GObject *object,
- guint property_id,
- GValue *value,
+ephy_window_action_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
GParamSpec *pspec)
{
- EphyWindowAction *action = EPHY_WINDOW_ACTION (object);
+ EphyWindowAction *action = EPHY_WINDOW_ACTION (object);
- switch (property_id) {
+ switch (property_id) {
case PROP_WINDOW:
- g_value_set_object (value, action->priv->window);
- break;
+ g_value_set_object (value, action->priv->window);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- }
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
}
static void
ephy_window_action_class_init (EphyWindowActionClass *class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
- object_class->set_property = ephy_window_action_set_property;
- object_class->get_property = ephy_window_action_get_property;
+ object_class->set_property = ephy_window_action_set_property;
+ object_class->get_property = ephy_window_action_get_property;
- obj_properties[PROP_WINDOW] =
- g_param_spec_object ("window",
- NULL,
- NULL,
- G_TYPE_OBJECT,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT);
+ obj_properties[PROP_WINDOW] =
+ g_param_spec_object ("window",
+ NULL,
+ NULL,
+ G_TYPE_OBJECT,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT);
- g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+ g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
- g_type_class_add_private (object_class, sizeof (EphyWindowActionPrivate));
+ g_type_class_add_private (object_class, sizeof (EphyWindowActionPrivate));
}
EphyWindow *
ephy_window_action_get_window (EphyWindowAction *action)
{
- g_return_val_if_fail (EPHY_IS_WINDOW_ACTION (action), NULL);
+ g_return_val_if_fail (EPHY_IS_WINDOW_ACTION (action), NULL);
- return action->priv->window;
+ return action->priv->window;
}
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 9fc746c..4c42a5d 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -77,2469 +77,2352 @@
* #EphyWindow is Epiphany's main widget.
*/
-static void ephy_window_view_popup_windows_cb (GtkAction *action,
- EphyWindow *window);
+static void ephy_window_view_popup_windows_cb (GtkAction *action,
+ EphyWindow *window);
static const GtkActionEntry ephy_menu_entries [] = {
-
- /* Toplevel */
-
- { "Bookmarks", NULL, N_("_Bookmarks") },
- { "PopupAction", NULL, "" },
- { "PagePopupAction", NULL, "" },
- { "NotebookPopupAction", NULL, "" },
-
- /* File actions. */
-
- { "FileNewWindow", NULL, N_("_New Window"), "<control>N", NULL,
- G_CALLBACK (window_cmd_file_new_window) },
- { "FileNewWindowIncognito", NULL, N_("New _Incognito Window"), "<control><shift>N", NULL,
- G_CALLBACK (window_cmd_file_new_incognito_window) },
- { "FileOpen", NULL, N_("_Open…"), "<control>O", NULL,
- G_CALLBACK (window_cmd_file_open) },
- { "FileSaveAs", NULL, N_("Save _As…"), "<shift><control>S", NULL,
- G_CALLBACK (window_cmd_file_save_as) },
- { "FileSaveAsApplication", NULL, N_("Save As _Web Application…"), "<shift><control>A", NULL,
- G_CALLBACK (window_cmd_file_save_as_application) },
- { "FilePrint", NULL, N_("_Print…"), "<control>P", NULL,
- G_CALLBACK (window_cmd_file_print) },
- { "FileSendTo", NULL, N_("S_end Link by Email…"), NULL, NULL,
- G_CALLBACK (window_cmd_file_send_to) },
- { "FileCloseTab", NULL, N_("_Close"), "<control>W", NULL,
- G_CALLBACK (window_cmd_file_close_window) },
- { "FileQuit", NULL, N_("_Quit"), "<control>Q", NULL,
- G_CALLBACK (window_cmd_file_quit) },
-
- /* Edit actions. */
-
- { "EditUndo", NULL, N_("_Undo"), "<control>Z", NULL,
- G_CALLBACK (window_cmd_edit_undo) },
- { "EditRedo", NULL, N_("Re_do"), "<shift><control>Z", NULL,
- G_CALLBACK (window_cmd_edit_redo) },
- { "EditCut", NULL, N_("Cu_t"), "<control>X", NULL,
- G_CALLBACK (window_cmd_edit_cut) },
- { "EditCopy", NULL, N_("_Copy"), "<control>C", NULL,
- G_CALLBACK (window_cmd_edit_copy) },
- { "EditPaste", NULL, N_("_Paste"), "<control>V", NULL,
- G_CALLBACK (window_cmd_edit_paste) },
- { "EditDelete", NULL, NULL, NULL, NULL,
- G_CALLBACK (window_cmd_edit_delete) },
- { "EditSelectAll", NULL, N_("Select _All"), "<control>A", NULL,
- G_CALLBACK (window_cmd_edit_select_all) },
- { "EditFind", NULL, N_("_Find…"), "<control>F", NULL,
- G_CALLBACK (window_cmd_edit_find) },
- { "EditFindNext", NULL, N_("Find Ne_xt"), "<control>G", NULL,
- G_CALLBACK (window_cmd_edit_find_next) },
- { "EditFindPrev", NULL, N_("Find Pre_vious"), "<shift><control>G", NULL,
- G_CALLBACK (window_cmd_edit_find_prev) },
- { "EditBookmarks", NULL, N_("Edit _Bookmarks"), "<control>B", NULL,
- G_CALLBACK (window_cmd_edit_bookmarks) },
- { "EditHistory", NULL, N_("_History"), "<control>H", NULL,
- G_CALLBACK (window_cmd_edit_history) },
- { "EditPreferences", NULL, N_("Pr_eferences"), "<control>e", NULL,
- G_CALLBACK (window_cmd_edit_preferences) },
-
- /* View actions. */
-
- { "ViewStop", NULL, N_("_Stop"), "Escape", NULL,
- G_CALLBACK (window_cmd_view_stop) },
- { "ViewAlwaysStop", NULL, N_("_Stop"), "Escape",
- NULL, G_CALLBACK (window_cmd_view_stop) },
- { "ViewReload", NULL, N_("_Reload"), "<control>R", NULL,
- G_CALLBACK (window_cmd_view_reload) },
- { "ViewZoomIn", NULL, N_("Zoom _In"), "<control>plus", NULL,
- G_CALLBACK (window_cmd_view_zoom_in) },
- { "ViewZoomOut", NULL, N_("Zoom O_ut"), "<control>minus", NULL,
- G_CALLBACK (window_cmd_view_zoom_out) },
- { "ViewZoomNormal", NULL, N_("_Normal Size"), "<control>0", NULL,
- G_CALLBACK (window_cmd_view_zoom_normal) },
- { "ViewEncoding", NULL, N_("Text _Encoding"), NULL, NULL,
- G_CALLBACK (window_cmd_view_encoding) },
- { "ViewPageSource", NULL, N_("_Page Source"), "<control>U", NULL,
- G_CALLBACK (window_cmd_view_page_source) },
-
- /* Bookmarks actions. */
-
- { "FileBookmarkPage", NULL, N_("_Add Bookmark…"), "<control>D", NULL,
- G_CALLBACK (window_cmd_file_bookmark_page) },
-
- /* Go actions. */
-
- { "GoLocation", NULL, N_("_Location…"), "<control>L", NULL,
- G_CALLBACK (window_cmd_go_location) },
-
- /* Tabs actions. */
-
- { "TabsPrevious", NULL, N_("_Previous Tab"), "<control>Page_Up", NULL,
- G_CALLBACK (window_cmd_tabs_previous) },
- { "TabsNext", NULL, N_("_Next Tab"), "<control>Page_Down", NULL,
- G_CALLBACK (window_cmd_tabs_next) },
- { "TabsMoveLeft", NULL, N_("Move Tab _Left"), "<shift><control>Page_Up", NULL,
- G_CALLBACK (window_cmd_tabs_move_left) },
- { "TabsMoveRight", NULL, N_("Move Tab _Right"), "<shift><control>Page_Down", NULL,
- G_CALLBACK (window_cmd_tabs_move_right) },
- { "TabsDetach", NULL, N_("_Detach Tab"), NULL, NULL,
- G_CALLBACK (window_cmd_tabs_detach) },
-
- /* Help. */
-
- { "HelpContents", NULL, N_("_Help"), "F1", NULL,
- G_CALLBACK (window_cmd_help_contents) },
- { "HelpAbout", NULL, N_("_About"), NULL, NULL,
- G_CALLBACK (window_cmd_help_about) }
+ /* Toplevel */
+
+ { "Bookmarks", NULL, N_("_Bookmarks") },
+ { "PopupAction", NULL, "" },
+ { "PagePopupAction", NULL, "" },
+ { "NotebookPopupAction", NULL, "" },
+
+ /* File actions. */
+
+ { "FileNewWindow", NULL, N_("_New Window"), "<control>N", NULL,
+ G_CALLBACK (window_cmd_file_new_window) },
+ { "FileNewWindowIncognito", NULL, N_("New _Incognito Window"), "<control><shift>N", NULL,
+ G_CALLBACK (window_cmd_file_new_incognito_window) },
+ { "FileOpen", NULL, N_("_Open…"), "<control>O", NULL,
+ G_CALLBACK (window_cmd_file_open) },
+ { "FileSaveAs", NULL, N_("Save _As…"), "<shift><control>S", NULL,
+ G_CALLBACK (window_cmd_file_save_as) },
+ { "FileSaveAsApplication", NULL, N_("Save As _Web Application…"), "<shift><control>A", NULL,
+ G_CALLBACK (window_cmd_file_save_as_application) },
+ { "FilePrint", NULL, N_("_Print…"), "<control>P", NULL,
+ G_CALLBACK (window_cmd_file_print) },
+ { "FileSendTo", NULL, N_("S_end Link by Email…"), NULL, NULL,
+ G_CALLBACK (window_cmd_file_send_to) },
+ { "FileCloseTab", NULL, N_("_Close"), "<control>W", NULL,
+ G_CALLBACK (window_cmd_file_close_window) },
+ { "FileQuit", NULL, N_("_Quit"), "<control>Q", NULL,
+ G_CALLBACK (window_cmd_file_quit) },
+
+ /* Edit actions. */
+
+ { "EditUndo", NULL, N_("_Undo"), "<control>Z", NULL,
+ G_CALLBACK (window_cmd_edit_undo) },
+ { "EditRedo", NULL, N_("Re_do"), "<shift><control>Z", NULL,
+ G_CALLBACK (window_cmd_edit_redo) },
+ { "EditCut", NULL, N_("Cu_t"), "<control>X", NULL,
+ G_CALLBACK (window_cmd_edit_cut) },
+ { "EditCopy", NULL, N_("_Copy"), "<control>C", NULL,
+ G_CALLBACK (window_cmd_edit_copy) },
+ { "EditPaste", NULL, N_("_Paste"), "<control>V", NULL,
+ G_CALLBACK (window_cmd_edit_paste) },
+ { "EditDelete", NULL, NULL, NULL, NULL,
+ G_CALLBACK (window_cmd_edit_delete) },
+ { "EditSelectAll", NULL, N_("Select _All"), "<control>A", NULL,
+ G_CALLBACK (window_cmd_edit_select_all) },
+ { "EditFind", NULL, N_("_Find…"), "<control>F", NULL,
+ G_CALLBACK (window_cmd_edit_find) },
+ { "EditFindNext", NULL, N_("Find Ne_xt"), "<control>G", NULL,
+ G_CALLBACK (window_cmd_edit_find_next) },
+ { "EditFindPrev", NULL, N_("Find Pre_vious"), "<shift><control>G", NULL,
+ G_CALLBACK (window_cmd_edit_find_prev) },
+ { "EditBookmarks", NULL, N_("Edit _Bookmarks"), "<control>B", NULL,
+ G_CALLBACK (window_cmd_edit_bookmarks) },
+ { "EditHistory", NULL, N_("_History"), "<control>H", NULL,
+ G_CALLBACK (window_cmd_edit_history) },
+ { "EditPreferences", NULL, N_("Pr_eferences"), "<control>e", NULL,
+ G_CALLBACK (window_cmd_edit_preferences) },
+
+ /* View actions. */
+
+ { "ViewStop", NULL, N_("_Stop"), "Escape", NULL,
+ G_CALLBACK (window_cmd_view_stop) },
+ { "ViewAlwaysStop", NULL, N_("_Stop"), "Escape",
+ NULL, G_CALLBACK (window_cmd_view_stop) },
+ { "ViewReload", NULL, N_("_Reload"), "<control>R", NULL,
+ G_CALLBACK (window_cmd_view_reload) },
+ { "ViewZoomIn", NULL, N_("Zoom _In"), "<control>plus", NULL,
+ G_CALLBACK (window_cmd_view_zoom_in) },
+ { "ViewZoomOut", NULL, N_("Zoom O_ut"), "<control>minus", NULL,
+ G_CALLBACK (window_cmd_view_zoom_out) },
+ { "ViewZoomNormal", NULL, N_("_Normal Size"), "<control>0", NULL,
+ G_CALLBACK (window_cmd_view_zoom_normal) },
+ { "ViewEncoding", NULL, N_("Text _Encoding"), NULL, NULL,
+ G_CALLBACK (window_cmd_view_encoding) },
+ { "ViewPageSource", NULL, N_("_Page Source"), "<control>U", NULL,
+ G_CALLBACK (window_cmd_view_page_source) },
+
+ /* Bookmarks actions. */
+
+ { "FileBookmarkPage", NULL, N_("_Add Bookmark…"), "<control>D", NULL,
+ G_CALLBACK (window_cmd_file_bookmark_page) },
+
+ /* Go actions. */
+
+ { "GoLocation", NULL, N_("_Location…"), "<control>L", NULL,
+ G_CALLBACK (window_cmd_go_location) },
+
+ /* Tabs actions. */
+
+ { "TabsPrevious", NULL, N_("_Previous Tab"), "<control>Page_Up", NULL,
+ G_CALLBACK (window_cmd_tabs_previous) },
+ { "TabsNext", NULL, N_("_Next Tab"), "<control>Page_Down", NULL,
+ G_CALLBACK (window_cmd_tabs_next) },
+ { "TabsMoveLeft", NULL, N_("Move Tab _Left"), "<shift><control>Page_Up", NULL,
+ G_CALLBACK (window_cmd_tabs_move_left) },
+ { "TabsMoveRight", NULL, N_("Move Tab _Right"), "<shift><control>Page_Down", NULL,
+ G_CALLBACK (window_cmd_tabs_move_right) },
+ { "TabsDetach", NULL, N_("_Detach Tab"), NULL, NULL,
+ G_CALLBACK (window_cmd_tabs_detach) },
+
+ /* Help. */
+
+ { "HelpContents", NULL, N_("_Help"), "F1", NULL,
+ G_CALLBACK (window_cmd_help_contents) },
+ { "HelpAbout", NULL, N_("_About"), NULL, NULL,
+ G_CALLBACK (window_cmd_help_about) }
};
static const GtkToggleActionEntry ephy_menu_toggle_entries [] =
{
- /* View actions. */
+ /* View actions. */
- { "ViewFullscreen", NULL, N_("_Fullscreen"), "F11", NULL,
- G_CALLBACK (window_cmd_view_fullscreen), FALSE },
- { "ViewPopupWindows", NULL, N_("Popup _Windows"), NULL, NULL,
- G_CALLBACK (ephy_window_view_popup_windows_cb), FALSE },
- { "BrowseWithCaret", NULL, N_("Selection Caret"), "F7", NULL,
- G_CALLBACK (window_cmd_browse_with_caret), FALSE }
+ { "ViewFullscreen", NULL, N_("_Fullscreen"), "F11", NULL,
+ G_CALLBACK (window_cmd_view_fullscreen), FALSE },
+ { "ViewPopupWindows", NULL, N_("Popup _Windows"), NULL, NULL,
+ G_CALLBACK (ephy_window_view_popup_windows_cb), FALSE },
+ { "BrowseWithCaret", NULL, N_("Selection Caret"), "F7", NULL,
+ G_CALLBACK (window_cmd_browse_with_caret), FALSE }
};
static const GtkActionEntry ephy_popups_entries [] = {
- /* Document. */
-
- { "ContextBookmarkPage", NULL, N_("Add Boo_kmark…"), "<control>D", NULL,
- G_CALLBACK (window_cmd_file_bookmark_page) },
-
- /* Links. */
-
- { "OpenLinkInNewWindow", NULL, N_("Open Link in New _Window"), NULL, NULL,
- G_CALLBACK (popup_cmd_link_in_new_window) },
- { "OpenLinkInNewTab", NULL, N_("Open Link in New _Tab"), NULL, NULL,
- G_CALLBACK (popup_cmd_link_in_new_tab) },
- { "OpenLinkInIncognitoWindow", NULL, N_("Open Link in I_ncognito Window"), NULL, NULL,
- G_CALLBACK (popup_cmd_link_in_incognito_window) },
- { "DownloadLinkAs", NULL, N_("_Save Link As…"), NULL, NULL,
- G_CALLBACK (popup_cmd_download_link_as) },
- { "CopyLinkAddress", NULL, N_("_Copy Link Address"), NULL,
- NULL, G_CALLBACK (popup_cmd_copy_link_address) },
- { "CopyEmailAddress", NULL, N_("_Copy E-mail Address"), NULL,
- NULL, G_CALLBACK (popup_cmd_copy_link_address) },
-
- /* Images. */
-
- { "ViewImage", NULL, N_("View _Image in New Tab"), NULL,
- NULL, G_CALLBACK (popup_cmd_view_image_in_new_tab) },
- { "CopyImageLocation", NULL, N_("Copy I_mage Address"), NULL,
- NULL, G_CALLBACK (popup_cmd_copy_image_location) },
- { "SaveImageAs", NULL, N_("_Save Image As…"), NULL,
- NULL, G_CALLBACK (popup_cmd_save_image_as) },
- { "SetImageAsBackground", NULL, N_("Set as _Wallpaper"), NULL,
- NULL, G_CALLBACK (popup_cmd_set_image_as_background) },
-
- /* Video. */
-
- { "OpenVideoInNewWindow", NULL, N_("Open Video in New _Window"), NULL, NULL,
- G_CALLBACK (popup_cmd_media_in_new_window) },
- { "OpenVideoInNewTab", NULL, N_("Open Video in New _Tab"), NULL, NULL,
- G_CALLBACK (popup_cmd_media_in_new_tab) },
- { "SaveVideoAs", NULL, N_("_Save Video As…"), NULL,
- NULL, G_CALLBACK (popup_cmd_save_media_as) },
- { "CopyVideoLocation", NULL, N_("_Copy Video Address"), NULL,
- NULL, G_CALLBACK (popup_cmd_copy_media_location) },
-
- /* Audio. */
-
- { "OpenAudioInNewWindow", NULL, N_("Open Audio in New _Window"), NULL, NULL,
- G_CALLBACK (popup_cmd_media_in_new_window) },
- { "OpenAudioInNewTab", NULL, N_("Open Audio in New _Tab"), NULL, NULL,
- G_CALLBACK (popup_cmd_media_in_new_tab) },
- { "SaveAudioAs", NULL, N_("_Save Audio As…"), NULL,
- NULL, G_CALLBACK (popup_cmd_save_media_as) },
- { "CopyAudioLocation", NULL, N_("_Copy Audio Address"), NULL,
- NULL, G_CALLBACK (popup_cmd_copy_media_location) },
-
- /* Selection */
- { "SearchSelection", NULL, "_Search Selection", NULL, NULL,
- G_CALLBACK (popup_cmd_search_selection) },
+ /* Document. */
+
+ { "ContextBookmarkPage", NULL, N_("Add Boo_kmark…"), "<control>D", NULL,
+ G_CALLBACK (window_cmd_file_bookmark_page) },
+
+ /* Links. */
+
+ { "OpenLinkInNewWindow", NULL, N_("Open Link in New _Window"), NULL, NULL,
+ G_CALLBACK (popup_cmd_link_in_new_window) },
+ { "OpenLinkInNewTab", NULL, N_("Open Link in New _Tab"), NULL, NULL,
+ G_CALLBACK (popup_cmd_link_in_new_tab) },
+ { "OpenLinkInIncognitoWindow", NULL, N_("Open Link in I_ncognito Window"), NULL, NULL,
+ G_CALLBACK (popup_cmd_link_in_incognito_window) },
+ { "DownloadLinkAs", NULL, N_("_Save Link As…"), NULL, NULL,
+ G_CALLBACK (popup_cmd_download_link_as) },
+ { "CopyLinkAddress", NULL, N_("_Copy Link Address"), NULL,
+ NULL, G_CALLBACK (popup_cmd_copy_link_address) },
+ { "CopyEmailAddress", NULL, N_("_Copy E-mail Address"), NULL,
+ NULL, G_CALLBACK (popup_cmd_copy_link_address) },
+
+ /* Images. */
+
+ { "ViewImage", NULL, N_("View _Image in New Tab"), NULL,
+ NULL, G_CALLBACK (popup_cmd_view_image_in_new_tab) },
+ { "CopyImageLocation", NULL, N_("Copy I_mage Address"), NULL,
+ NULL, G_CALLBACK (popup_cmd_copy_image_location) },
+ { "SaveImageAs", NULL, N_("_Save Image As…"), NULL,
+ NULL, G_CALLBACK (popup_cmd_save_image_as) },
+ { "SetImageAsBackground", NULL, N_("Set as _Wallpaper"), NULL,
+ NULL, G_CALLBACK (popup_cmd_set_image_as_background) },
+
+ /* Video. */
+
+ { "OpenVideoInNewWindow", NULL, N_("Open Video in New _Window"), NULL, NULL,
+ G_CALLBACK (popup_cmd_media_in_new_window) },
+ { "OpenVideoInNewTab", NULL, N_("Open Video in New _Tab"), NULL, NULL,
+ G_CALLBACK (popup_cmd_media_in_new_tab) },
+ { "SaveVideoAs", NULL, N_("_Save Video As…"), NULL,
+ NULL, G_CALLBACK (popup_cmd_save_media_as) },
+ { "CopyVideoLocation", NULL, N_("_Copy Video Address"), NULL,
+ NULL, G_CALLBACK (popup_cmd_copy_media_location) },
+
+ /* Audio. */
+
+ { "OpenAudioInNewWindow", NULL, N_("Open Audio in New _Window"), NULL, NULL,
+ G_CALLBACK (popup_cmd_media_in_new_window) },
+ { "OpenAudioInNewTab", NULL, N_("Open Audio in New _Tab"), NULL, NULL,
+ G_CALLBACK (popup_cmd_media_in_new_tab) },
+ { "SaveAudioAs", NULL, N_("_Save Audio As…"), NULL,
+ NULL, G_CALLBACK (popup_cmd_save_media_as) },
+ { "CopyAudioLocation", NULL, N_("_Copy Audio Address"), NULL,
+ NULL, G_CALLBACK (popup_cmd_copy_media_location) },
+
+ /* Selection */
+ { "SearchSelection", NULL, "_Search Selection", NULL, NULL,
+ G_CALLBACK (popup_cmd_search_selection) },
};
-static const struct
-{
- guint keyval;
- GdkModifierType modifier;
- const gchar *action;
- gboolean fromToolbar;
+static const struct {
+ guint keyval;
+ GdkModifierType modifier;
+ const gchar *action;
+ gboolean fromToolbar;
} extra_keybindings [] = {
- /* FIXME: PageMenu should have its accel without being in the
- * extra keybindings, but does not seem to work for some
- * reason. */
- { GDK_KEY_F10, 0, "PageMenu", TRUE },
- { GDK_KEY_Home, GDK_MOD1_MASK, "FileHome", TRUE },
- /* FIXME: these are not in any menu for now, so add them here. */
- { GDK_KEY_F11, 0, "ViewFullscreen", FALSE },
- { GDK_KEY_plus, GDK_CONTROL_MASK, "ViewZoomIn", FALSE },
- { GDK_KEY_minus, GDK_CONTROL_MASK, "ViewZoomOut", FALSE },
- { GDK_KEY_0, GDK_CONTROL_MASK, "ViewZoomNormal", FALSE },
- { GDK_KEY_g, GDK_CONTROL_MASK, "EditFindNext", FALSE },
- { GDK_KEY_G, GDK_CONTROL_MASK |
- GDK_SHIFT_MASK, "EditFindPrev", FALSE },
-
- { GDK_KEY_s, GDK_CONTROL_MASK, "FileSaveAs", FALSE },
- { GDK_KEY_r, GDK_CONTROL_MASK, "ViewReload", FALSE },
- { GDK_KEY_R, GDK_CONTROL_MASK, "ViewReload", FALSE },
- { GDK_KEY_R, GDK_CONTROL_MASK |
- GDK_SHIFT_MASK, "ViewReload", FALSE },
- /* Tab navigation */
- { GDK_KEY_Page_Up, GDK_CONTROL_MASK, "TabsPrevious", FALSE },
- { GDK_KEY_Page_Down, GDK_CONTROL_MASK, "TabsNext", FALSE },
- { GDK_KEY_Page_Up, GDK_CONTROL_MASK |
- GDK_SHIFT_MASK, "TabsMoveLeft", FALSE },
- { GDK_KEY_Page_Down, GDK_CONTROL_MASK |
- GDK_SHIFT_MASK, "TabsMoveRight", FALSE },
- /* Go */
- { GDK_KEY_l, GDK_CONTROL_MASK, "GoLocation", FALSE },
- { GDK_KEY_F6, 0, "GoLocation", FALSE },
- /* Support all the MSIE tricks as well ;) */
- { GDK_KEY_F5, 0, "ViewReload", FALSE },
- { GDK_KEY_F5, GDK_CONTROL_MASK, "ViewReload", FALSE },
- { GDK_KEY_F5, GDK_SHIFT_MASK, "ViewReload", FALSE },
- { GDK_KEY_F5, GDK_CONTROL_MASK |
- GDK_SHIFT_MASK, "ViewReload", FALSE },
- { GDK_KEY_KP_Add, GDK_CONTROL_MASK, "ViewZoomIn", FALSE },
- { GDK_KEY_KP_Subtract, GDK_CONTROL_MASK, "ViewZoomOut", FALSE },
- { GDK_KEY_equal, GDK_CONTROL_MASK, "ViewZoomIn", FALSE },
- { GDK_KEY_KP_0, GDK_CONTROL_MASK, "ViewZoomNormal", FALSE },
- /* These keys are a bit strange: when pressed with no modifiers, they emit
- * KP_PageUp/Down Control; when pressed with Control+Shift they are KP_9/3,
- * when NumLock is on they are KP_9/3 and with NumLock and Control+Shift
- * They're KP_PageUp/Down again!
- */
- { GDK_KEY_KP_4, GDK_MOD1_MASK /*Alt*/, "NavigationBack", TRUE },
- { GDK_KEY_KP_6, GDK_MOD1_MASK /*Alt*/, "NavigationForward", TRUE },
- { GDK_KEY_KP_Page_Up, GDK_CONTROL_MASK, "TabsPrevious", FALSE },
- { GDK_KEY_KP_9, GDK_CONTROL_MASK, "TabsPrevious", FALSE },
- { GDK_KEY_KP_Page_Down, GDK_CONTROL_MASK, "TabsNext", FALSE },
- { GDK_KEY_KP_3, GDK_CONTROL_MASK, "TabsNext", FALSE },
- { GDK_KEY_KP_Page_Up, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "TabsMoveLeft", FALSE },
- { GDK_KEY_KP_9, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "TabsMoveLeft", FALSE },
- { GDK_KEY_KP_Page_Down, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "TabsMoveRight", FALSE },
- { GDK_KEY_KP_3, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "TabsMoveRight", FALSE },
+ /* FIXME: PageMenu should have its accel without being in the
+ * extra keybindings, but does not seem to work for some
+ * reason. */
+ { GDK_KEY_F10, 0, "PageMenu", TRUE },
+ { GDK_KEY_Home, GDK_MOD1_MASK, "FileHome", TRUE },
+ /* FIXME: these are not in any menu for now, so add them here. */
+ { GDK_KEY_F11, 0, "ViewFullscreen", FALSE },
+ { GDK_KEY_plus, GDK_CONTROL_MASK, "ViewZoomIn", FALSE },
+ { GDK_KEY_minus, GDK_CONTROL_MASK, "ViewZoomOut", FALSE },
+ { GDK_KEY_0, GDK_CONTROL_MASK, "ViewZoomNormal", FALSE },
+ { GDK_KEY_g, GDK_CONTROL_MASK, "EditFindNext", FALSE },
+ { GDK_KEY_G, GDK_CONTROL_MASK |
+ GDK_SHIFT_MASK, "EditFindPrev", FALSE },
+
+ { GDK_KEY_s, GDK_CONTROL_MASK, "FileSaveAs", FALSE },
+ { GDK_KEY_r, GDK_CONTROL_MASK, "ViewReload", FALSE },
+ { GDK_KEY_R, GDK_CONTROL_MASK, "ViewReload", FALSE },
+ { GDK_KEY_R, GDK_CONTROL_MASK |
+ GDK_SHIFT_MASK, "ViewReload", FALSE },
+ /* Tab navigation */
+ { GDK_KEY_Page_Up, GDK_CONTROL_MASK, "TabsPrevious", FALSE },
+ { GDK_KEY_Page_Down, GDK_CONTROL_MASK, "TabsNext", FALSE },
+ { GDK_KEY_Page_Up, GDK_CONTROL_MASK |
+ GDK_SHIFT_MASK, "TabsMoveLeft", FALSE },
+ { GDK_KEY_Page_Down, GDK_CONTROL_MASK |
+ GDK_SHIFT_MASK, "TabsMoveRight", FALSE },
+ /* Go */
+ { GDK_KEY_l, GDK_CONTROL_MASK, "GoLocation", FALSE },
+ { GDK_KEY_F6, 0, "GoLocation", FALSE },
+ /* Support all the MSIE tricks as well ;) */
+ { GDK_KEY_F5, 0, "ViewReload", FALSE },
+ { GDK_KEY_F5, GDK_CONTROL_MASK, "ViewReload", FALSE },
+ { GDK_KEY_F5, GDK_SHIFT_MASK, "ViewReload", FALSE },
+ { GDK_KEY_F5, GDK_CONTROL_MASK |
+ GDK_SHIFT_MASK, "ViewReload", FALSE },
+ { GDK_KEY_KP_Add, GDK_CONTROL_MASK, "ViewZoomIn", FALSE },
+ { GDK_KEY_KP_Subtract, GDK_CONTROL_MASK, "ViewZoomOut", FALSE },
+ { GDK_KEY_equal, GDK_CONTROL_MASK, "ViewZoomIn", FALSE },
+ { GDK_KEY_KP_0, GDK_CONTROL_MASK, "ViewZoomNormal", FALSE },
+ /* These keys are a bit strange: when pressed with no modifiers, they emit
+ * KP_PageUp/Down Control; when pressed with Control+Shift they are KP_9/3,
+ * when NumLock is on they are KP_9/3 and with NumLock and Control+Shift
+ * They're KP_PageUp/Down again!
+ */
+ { GDK_KEY_KP_4, GDK_MOD1_MASK /*Alt*/, "NavigationBack", TRUE },
+ { GDK_KEY_KP_6, GDK_MOD1_MASK /*Alt*/, "NavigationForward", TRUE },
+ { GDK_KEY_KP_Page_Up, GDK_CONTROL_MASK, "TabsPrevious", FALSE },
+ { GDK_KEY_KP_9, GDK_CONTROL_MASK, "TabsPrevious", FALSE },
+ { GDK_KEY_KP_Page_Down, GDK_CONTROL_MASK, "TabsNext", FALSE },
+ { GDK_KEY_KP_3, GDK_CONTROL_MASK, "TabsNext", FALSE },
+ { GDK_KEY_KP_Page_Up, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "TabsMoveLeft", FALSE },
+ { GDK_KEY_KP_9, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "TabsMoveLeft", FALSE },
+ { GDK_KEY_KP_Page_Down, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "TabsMoveRight", FALSE },
+ { GDK_KEY_KP_3, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "TabsMoveRight", FALSE },
#ifdef HAVE_X11_XF86KEYSYM_H
- { XF86XK_Back, 0, "NavigationBack", TRUE },
- { XF86XK_Forward, 0, "NavigationForward", TRUE },
- { XF86XK_Go, 0, "GoLocation", FALSE },
- { XF86XK_OpenURL, 0, "GoLocation", FALSE },
- { XF86XK_AddFavorite, 0, "FileBookmarkPage", FALSE },
- { XF86XK_Refresh, 0, "ViewReload", FALSE },
- { XF86XK_Reload, 0, "ViewReload", FALSE },
- { XF86XK_Search, 0, "EditFind", FALSE },
- { XF86XK_Send, 0, "FileSendTo", FALSE },
- { XF86XK_Stop, 0, "ViewStop", FALSE },
- { XF86XK_ZoomIn, 0, "ViewZoomIn", FALSE },
- { XF86XK_ZoomOut, 0, "ViewZoomOut", FALSE }
- /* FIXME: what about ScrollUp, ScrollDown, Menu*, Option, LogOff, Save,.. any others? */
+ { XF86XK_Back, 0, "NavigationBack", TRUE },
+ { XF86XK_Forward, 0, "NavigationForward", TRUE },
+ { XF86XK_Go, 0, "GoLocation", FALSE },
+ { XF86XK_OpenURL, 0, "GoLocation", FALSE },
+ { XF86XK_AddFavorite, 0, "FileBookmarkPage", FALSE },
+ { XF86XK_Refresh, 0, "ViewReload", FALSE },
+ { XF86XK_Reload, 0, "ViewReload", FALSE },
+ { XF86XK_Search, 0, "EditFind", FALSE },
+ { XF86XK_Send, 0, "FileSendTo", FALSE },
+ { XF86XK_Stop, 0, "ViewStop", FALSE },
+ { XF86XK_ZoomIn, 0, "ViewZoomIn", FALSE },
+ { XF86XK_ZoomOut, 0, "ViewZoomOut", FALSE }
+ /* FIXME: what about ScrollUp, ScrollDown, Menu*, Option, LogOff, Save,.. any others? */
#endif /* HAVE_X11_XF86KEYSYM_H */
}, navigation_keybindings_ltr [] = {
- { GDK_KEY_Left, GDK_MOD1_MASK /*Alt*/, "NavigationBack", TRUE },
- { GDK_KEY_KP_Left, GDK_MOD1_MASK /*Alt*/, "NavigationBack", TRUE },
- { GDK_KEY_Right, GDK_MOD1_MASK /*Alt*/, "NavigationForward", TRUE },
- { GDK_KEY_KP_Right, GDK_MOD1_MASK /*Alt*/, "NavigationForward", TRUE }
+ { GDK_KEY_Left, GDK_MOD1_MASK /*Alt*/, "NavigationBack", TRUE },
+ { GDK_KEY_KP_Left, GDK_MOD1_MASK /*Alt*/, "NavigationBack", TRUE },
+ { GDK_KEY_Right, GDK_MOD1_MASK /*Alt*/, "NavigationForward", TRUE },
+ { GDK_KEY_KP_Right, GDK_MOD1_MASK /*Alt*/, "NavigationForward", TRUE }
}, navigation_keybindings_rtl [] = {
- { GDK_KEY_Left, GDK_MOD1_MASK /*Alt*/, "NavigationForward", TRUE },
- { GDK_KEY_KP_Left, GDK_MOD1_MASK /*Alt*/, "NavigationForward", TRUE },
- { GDK_KEY_Right, GDK_MOD1_MASK /*Alt*/, "NavigationBack", TRUE },
- { GDK_KEY_KP_Right, GDK_MOD1_MASK /*Alt*/, "NavigationBack", TRUE }
+ { GDK_KEY_Left, GDK_MOD1_MASK /*Alt*/, "NavigationForward", TRUE },
+ { GDK_KEY_KP_Left, GDK_MOD1_MASK /*Alt*/, "NavigationForward", TRUE },
+ { GDK_KEY_Right, GDK_MOD1_MASK /*Alt*/, "NavigationBack", TRUE },
+ { GDK_KEY_KP_Right, GDK_MOD1_MASK /*Alt*/, "NavigationBack", TRUE }
}, *navigation_keybindings_rtl_ltr;
-#define SETTINGS_CONNECTION_DATA_KEY "EphyWindowSettings"
-
-struct _EphyWindow
-{
- GtkApplicationWindow parent_instance;
-
- GtkWidget *toolbar;
- GtkUIManager *manager;
- GtkActionGroup *action_group;
- GtkActionGroup *popups_action_group;
- GtkActionGroup *toolbar_action_group;
- GtkActionGroup *tab_accels_action_group;
- GtkNotebook *notebook;
- EphyEmbed *active_embed;
- EphyWindowChrome chrome;
- EphyEmbedEvent *context_event;
- WebKitHitTestResult *hit_test_result;
- guint idle_worker;
-
- EphyLocationController *location_controller;
-
- gulong app_menu_visibility_handler;
-
- guint closing : 1;
- guint has_size : 1;
- guint fullscreen_mode : 1;
- guint is_popup : 1;
- guint present_on_insert : 1;
- guint key_theme_is_emacs : 1;
- guint updating_address : 1;
- guint force_close : 1;
- guint checking_modified_forms : 1;
+#define SETTINGS_CONNECTION_DATA_KEY "EphyWindowSettings"
+
+struct _EphyWindow {
+ GtkApplicationWindow parent_instance;
+
+ GtkWidget *toolbar;
+ GtkUIManager *manager;
+ GtkActionGroup *action_group;
+ GtkActionGroup *popups_action_group;
+ GtkActionGroup *toolbar_action_group;
+ GtkActionGroup *tab_accels_action_group;
+ GtkNotebook *notebook;
+ EphyEmbed *active_embed;
+ EphyWindowChrome chrome;
+ EphyEmbedEvent *context_event;
+ WebKitHitTestResult *hit_test_result;
+ guint idle_worker;
+
+ EphyLocationController *location_controller;
+
+ gulong app_menu_visibility_handler;
+
+ guint closing : 1;
+ guint has_size : 1;
+ guint fullscreen_mode : 1;
+ guint is_popup : 1;
+ guint present_on_insert : 1;
+ guint key_theme_is_emacs : 1;
+ guint updating_address : 1;
+ guint force_close : 1;
+ guint checking_modified_forms : 1;
};
-enum
-{
- PROP_0,
- PROP_ACTIVE_CHILD,
- PROP_CHROME,
- PROP_SINGLE_TAB_MODE
+enum {
+ PROP_0,
+ PROP_ACTIVE_CHILD,
+ PROP_CHROME,
+ PROP_SINGLE_TAB_MODE
};
/* Make sure not to overlap with those in ephy-lockdown.c */
-enum
-{
- SENS_FLAG_CHROME = 1 << 0,
- SENS_FLAG_CONTEXT = 1 << 1,
- SENS_FLAG_DOCUMENT = 1 << 2,
- SENS_FLAG_LOADING = 1 << 3,
- SENS_FLAG_NAVIGATION = 1 << 4,
- SENS_FLAG_IS_BLANK = 1 << 5
+enum {
+ SENS_FLAG_CHROME = 1 << 0,
+ SENS_FLAG_CONTEXT = 1 << 1,
+ SENS_FLAG_DOCUMENT = 1 << 2,
+ SENS_FLAG_LOADING = 1 << 3,
+ SENS_FLAG_NAVIGATION = 1 << 4,
+ SENS_FLAG_IS_BLANK = 1 << 5
};
static gint
impl_add_child (EphyEmbedContainer *container,
- EphyEmbed *child,
- gint position,
- gboolean jump_to)
+ EphyEmbed *child,
+ gint position,
+ gboolean jump_to)
{
- EphyWindow *window = EPHY_WINDOW (container);
+ EphyWindow *window = EPHY_WINDOW (container);
- g_return_val_if_fail (!window->is_popup ||
- gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook)) < 1, -1);
+ g_return_val_if_fail (!window->is_popup ||
+ gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook)) < 1, -1);
- return ephy_notebook_add_tab (EPHY_NOTEBOOK (window->notebook),
- child, position, jump_to);
+ return ephy_notebook_add_tab (EPHY_NOTEBOOK (window->notebook),
+ child, position, jump_to);
}
static void
impl_set_active_child (EphyEmbedContainer *container,
- EphyEmbed *child)
+ EphyEmbed *child)
{
- int page;
- EphyWindow *window;
+ int page;
+ EphyWindow *window;
- window = EPHY_WINDOW (container);
+ window = EPHY_WINDOW (container);
- page = gtk_notebook_page_num
- (window->notebook, GTK_WIDGET (child));
- gtk_notebook_set_current_page
- (window->notebook, page);
+ page = gtk_notebook_page_num
+ (window->notebook, GTK_WIDGET (child));
+ gtk_notebook_set_current_page
+ (window->notebook, page);
}
static GtkWidget *
construct_confirm_close_dialog (EphyWindow *window,
- const char *title,
- const char *info,
- const char *action)
+ const char *title,
+ const char *info,
+ const char *action)
{
- GtkWidget *dialog;
+ GtkWidget *dialog;
- dialog = gtk_message_dialog_new (GTK_WINDOW (window),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_CANCEL,
- "%s", title);
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_CANCEL,
+ "%s", title);
- gtk_message_dialog_format_secondary_text
- (GTK_MESSAGE_DIALOG (dialog), "%s", info);
+ gtk_message_dialog_format_secondary_text
+ (GTK_MESSAGE_DIALOG (dialog), "%s", info);
- gtk_dialog_add_button (GTK_DIALOG (dialog),
- action, GTK_RESPONSE_ACCEPT);
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ action, GTK_RESPONSE_ACCEPT);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
- /* FIXME gtk_window_set_title (GTK_WINDOW (dialog), _("Close Document?")); */
- gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (window)),
- GTK_WINDOW (dialog));
+ /* FIXME gtk_window_set_title (GTK_WINDOW (dialog), _("Close Document?")); */
+ gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (window)),
+ GTK_WINDOW (dialog));
- return dialog;
+ return dialog;
}
static gboolean
confirm_close_with_modified_forms (EphyWindow *window)
{
- GtkWidget *dialog;
- int response;
+ GtkWidget *dialog;
+ int response;
- dialog = construct_confirm_close_dialog (window,
- _("There are unsubmitted changes to form elements"),
- _("If you close the document anyway, "
- "you will lose that information."),
- _("Close _Document"));
- response = gtk_dialog_run (GTK_DIALOG (dialog));
+ dialog = construct_confirm_close_dialog (window,
+ _("There are unsubmitted changes to form elements"),
+ _("If you close the document anyway, "
+ "you will lose that information."),
+ _("Close _Document"));
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_widget_destroy (dialog);
- return response == GTK_RESPONSE_ACCEPT;
+ return response == GTK_RESPONSE_ACCEPT;
}
static gboolean
confirm_close_with_downloads (EphyWindow *window)
{
- GtkWidget *dialog;
- int response;
+ GtkWidget *dialog;
+ int response;
- dialog = construct_confirm_close_dialog (window,
- _("There are ongoing downloads"),
- _("If you quit, the downloads will be cancelled"),
- _("Quit and cancel downloads"));
- response = gtk_dialog_run (GTK_DIALOG (dialog));
+ dialog = construct_confirm_close_dialog (window,
+ _("There are ongoing downloads"),
+ _("If you quit, the downloads will be cancelled"),
+ _("Quit and cancel downloads"));
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_widget_destroy (dialog);
- return response == GTK_RESPONSE_ACCEPT;
+ return response == GTK_RESPONSE_ACCEPT;
}
static void
impl_remove_child (EphyEmbedContainer *container,
- EphyEmbed *child)
+ EphyEmbed *child)
{
- EphyWindow *window;
+ EphyWindow *window;
- window = EPHY_WINDOW (container);
- g_signal_emit_by_name (window->notebook,
- "tab-close-request",
- child, window);
+ window = EPHY_WINDOW (container);
+ g_signal_emit_by_name (window->notebook,
+ "tab-close-request",
+ child, window);
}
static EphyEmbed *
impl_get_active_child (EphyEmbedContainer *container)
{
- return EPHY_WINDOW (container)->active_embed;
+ return EPHY_WINDOW (container)->active_embed;
}
static GList *
impl_get_children (EphyEmbedContainer *container)
{
- EphyWindow *window = EPHY_WINDOW (container);
+ EphyWindow *window = EPHY_WINDOW (container);
- return gtk_container_get_children (GTK_CONTAINER (window->notebook));
+ return gtk_container_get_children (GTK_CONTAINER (window->notebook));
}
static gboolean
impl_get_is_popup (EphyEmbedContainer *container)
{
- return EPHY_WINDOW (container)->is_popup;
+ return EPHY_WINDOW (container)->is_popup;
}
static void
ephy_window_embed_container_iface_init (EphyEmbedContainerInterface *iface)
{
- iface->add_child = impl_add_child;
- iface->set_active_child = impl_set_active_child;
- iface->remove_child = impl_remove_child;
- iface->get_active_child = impl_get_active_child;
- iface->get_children = impl_get_children;
- iface->get_is_popup = impl_get_is_popup;
+ iface->add_child = impl_add_child;
+ iface->set_active_child = impl_set_active_child;
+ iface->remove_child = impl_remove_child;
+ iface->get_active_child = impl_get_active_child;
+ iface->get_children = impl_get_children;
+ iface->get_is_popup = impl_get_is_popup;
}
static EphyEmbed *
-ephy_window_open_link (EphyLink *link,
- const char *address,
- EphyEmbed *embed,
- EphyLinkFlags flags)
-{
- EphyWindow *window = EPHY_WINDOW (link);
- EphyEmbed *new_embed;
-
- g_return_val_if_fail (address != NULL, NULL);
-
- if (embed == NULL)
- {
- embed = window->active_embed;
- }
-
- if (flags & EPHY_LINK_BOOKMARK)
- ephy_web_view_set_visit_type (ephy_embed_get_web_view (embed),
- EPHY_PAGE_VISIT_BOOKMARK);
- else if (flags & EPHY_LINK_TYPED)
- ephy_web_view_set_visit_type (ephy_embed_get_web_view (embed),
- EPHY_PAGE_VISIT_TYPED);
-
- if (flags & (EPHY_LINK_JUMP_TO |
- EPHY_LINK_NEW_TAB |
- EPHY_LINK_NEW_WINDOW))
- {
- EphyNewTabFlags ntflags = 0;
- EphyWindow *target_window = EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed)));
-
- if (flags & EPHY_LINK_JUMP_TO)
- {
- ntflags |= EPHY_NEW_TAB_JUMP;
- }
-
- if (flags & EPHY_LINK_NEW_WINDOW ||
- (flags & EPHY_LINK_NEW_TAB && window->is_popup))
- {
- target_window = ephy_window_new ();
- }
-
- if (flags & EPHY_LINK_NEW_TAB_APPEND_AFTER)
- ntflags |= EPHY_NEW_TAB_APPEND_AFTER;
-
- new_embed = ephy_shell_new_tab
- (ephy_shell_get_default (),
- target_window,
- embed, ntflags);
- if (flags & EPHY_LINK_HOME_PAGE)
- {
- ephy_web_view_load_homepage (ephy_embed_get_web_view (new_embed));
- ephy_window_activate_location (window);
- }
- else
- {
- ephy_web_view_load_url (ephy_embed_get_web_view (new_embed), address);
- if (flags & EPHY_LINK_JUMP_TO)
- {
- gtk_widget_grab_focus (GTK_WIDGET (new_embed));
- }
- }
- }
- else
- {
- ephy_web_view_load_url (ephy_embed_get_web_view (embed), address);
-
- if (address == NULL || address[0] == '\0' || g_str_equal (address, "about:blank"))
- {
- ephy_window_activate_location (window);
- }
- else
- {
- gtk_widget_grab_focus (GTK_WIDGET (embed));
- }
-
- new_embed = embed;
- }
-
- return new_embed;
+ephy_window_open_link (EphyLink *link,
+ const char *address,
+ EphyEmbed *embed,
+ EphyLinkFlags flags)
+{
+ EphyWindow *window = EPHY_WINDOW (link);
+ EphyEmbed *new_embed;
+
+ g_return_val_if_fail (address != NULL, NULL);
+
+ if (embed == NULL) {
+ embed = window->active_embed;
+ }
+
+ if (flags & EPHY_LINK_BOOKMARK)
+ ephy_web_view_set_visit_type (ephy_embed_get_web_view (embed),
+ EPHY_PAGE_VISIT_BOOKMARK);
+ else if (flags & EPHY_LINK_TYPED)
+ ephy_web_view_set_visit_type (ephy_embed_get_web_view (embed),
+ EPHY_PAGE_VISIT_TYPED);
+
+ if (flags & (EPHY_LINK_JUMP_TO |
+ EPHY_LINK_NEW_TAB |
+ EPHY_LINK_NEW_WINDOW)) {
+ EphyNewTabFlags ntflags = 0;
+ EphyWindow *target_window = EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed)));
+
+ if (flags & EPHY_LINK_JUMP_TO) {
+ ntflags |= EPHY_NEW_TAB_JUMP;
+ }
+
+ if (flags & EPHY_LINK_NEW_WINDOW ||
+ (flags & EPHY_LINK_NEW_TAB && window->is_popup)) {
+ target_window = ephy_window_new ();
+ }
+
+ if (flags & EPHY_LINK_NEW_TAB_APPEND_AFTER)
+ ntflags |= EPHY_NEW_TAB_APPEND_AFTER;
+
+ new_embed = ephy_shell_new_tab
+ (ephy_shell_get_default (),
+ target_window,
+ embed, ntflags);
+ if (flags & EPHY_LINK_HOME_PAGE) {
+ ephy_web_view_load_homepage (ephy_embed_get_web_view (new_embed));
+ ephy_window_activate_location (window);
+ } else {
+ ephy_web_view_load_url (ephy_embed_get_web_view (new_embed), address);
+ if (flags & EPHY_LINK_JUMP_TO) {
+ gtk_widget_grab_focus (GTK_WIDGET (new_embed));
+ }
+ }
+ } else {
+ ephy_web_view_load_url (ephy_embed_get_web_view (embed), address);
+
+ if (address == NULL || address[0] == '\0' || g_str_equal (address, "about:blank")) {
+ ephy_window_activate_location (window);
+ } else {
+ gtk_widget_grab_focus (GTK_WIDGET (embed));
+ }
+
+ new_embed = embed;
+ }
+
+ return new_embed;
}
static void
ephy_window_link_iface_init (EphyLinkInterface *iface)
{
- iface->open_link = ephy_window_open_link;
+ iface->open_link = ephy_window_open_link;
}
G_DEFINE_TYPE_WITH_CODE (EphyWindow, ephy_window, GTK_TYPE_APPLICATION_WINDOW,
- G_IMPLEMENT_INTERFACE (EPHY_TYPE_LINK,
- ephy_window_link_iface_init)
- G_IMPLEMENT_INTERFACE (EPHY_TYPE_EMBED_CONTAINER,
- ephy_window_embed_container_iface_init))
+ G_IMPLEMENT_INTERFACE (EPHY_TYPE_LINK,
+ ephy_window_link_iface_init)
+ G_IMPLEMENT_INTERFACE (EPHY_TYPE_EMBED_CONTAINER,
+ ephy_window_embed_container_iface_init))
static void
settings_change_notify (GtkSettings *settings,
- EphyWindow *window)
+ EphyWindow *window)
{
- char *key_theme_name;
+ char *key_theme_name;
- g_object_get (settings,
- "gtk-key-theme-name", &key_theme_name,
- NULL);
+ g_object_get (settings,
+ "gtk-key-theme-name", &key_theme_name,
+ NULL);
- window->key_theme_is_emacs =
- key_theme_name &&
- g_ascii_strcasecmp (key_theme_name, "Emacs") == 0;
+ window->key_theme_is_emacs =
+ key_theme_name &&
+ g_ascii_strcasecmp (key_theme_name, "Emacs") == 0;
- g_free (key_theme_name);
+ g_free (key_theme_name);
}
static void
settings_changed_cb (GtkSettings *settings)
{
- GList *list, *l;
+ GList *list, *l;
- /* FIXME: multi-head */
- list = gtk_window_list_toplevels ();
+ /* FIXME: multi-head */
+ list = gtk_window_list_toplevels ();
- for (l = list; l != NULL; l = l->next)
- {
- if (EPHY_IS_WINDOW (l->data))
- {
- settings_change_notify (settings, l->data);
- }
- }
+ for (l = list; l != NULL; l = l->next) {
+ if (EPHY_IS_WINDOW (l->data)) {
+ settings_change_notify (settings, l->data);
+ }
+ }
- g_list_free (list);
+ g_list_free (list);
}
static void
sync_chromes_visibility (EphyWindow *window)
{
- gboolean show_tabsbar;
+ gboolean show_tabsbar;
- if (window->closing)
- return;
+ if (window->closing)
+ return;
- show_tabsbar = (window->chrome & EPHY_WINDOW_CHROME_TABSBAR);
+ show_tabsbar = (window->chrome & EPHY_WINDOW_CHROME_TABSBAR);
- ephy_notebook_set_tabs_allowed (EPHY_NOTEBOOK (window->notebook),
- show_tabsbar && !(window->is_popup || window->fullscreen_mode));
+ ephy_notebook_set_tabs_allowed (EPHY_NOTEBOOK (window->notebook),
+ show_tabsbar && !(window->is_popup || window->fullscreen_mode));
}
static void
-ephy_window_set_chrome (EphyWindow *window,
- EphyWindowChrome chrome)
+ephy_window_set_chrome (EphyWindow *window,
+ EphyWindowChrome chrome)
{
- if (window->chrome == chrome)
- return;
+ if (window->chrome == chrome)
+ return;
- window->chrome = chrome;
- if (window->closing)
- return;
+ window->chrome = chrome;
+ if (window->closing)
+ return;
- g_object_notify (G_OBJECT (window), "chrome");
- sync_chromes_visibility (window);
+ g_object_notify (G_OBJECT (window), "chrome");
+ sync_chromes_visibility (window);
}
static void
-sync_tab_load_status (EphyWebView *view,
- WebKitLoadEvent load_event,
- EphyWindow *window)
+sync_tab_load_status (EphyWebView *view,
+ WebKitLoadEvent load_event,
+ EphyWindow *window)
{
- GtkActionGroup *action_group = window->action_group;
- GtkAction *action;
- gboolean loading;
+ GtkActionGroup *action_group = window->action_group;
+ GtkAction *action;
+ gboolean loading;
- if (window->closing) return;
+ if (window->closing) return;
- loading = ephy_web_view_is_loading (view);
+ loading = ephy_web_view_is_loading (view);
- action = gtk_action_group_get_action (action_group, "ViewStop");
- gtk_action_set_sensitive (action, loading);
+ action = gtk_action_group_get_action (action_group, "ViewStop");
+ gtk_action_set_sensitive (action, loading);
- /* disable print while loading, see bug #116344 */
- action = gtk_action_group_get_action (action_group, "FilePrint");
- ephy_action_change_sensitivity_flags (action, SENS_FLAG_LOADING, loading);
+ /* disable print while loading, see bug #116344 */
+ action = gtk_action_group_get_action (action_group, "FilePrint");
+ ephy_action_change_sensitivity_flags (action, SENS_FLAG_LOADING, loading);
- action = gtk_action_group_get_action (window->toolbar_action_group,
- "ViewCombinedStopReload");
- ephy_combined_stop_reload_action_set_loading (EPHY_COMBINED_STOP_RELOAD_ACTION (action),
- loading);
+ action = gtk_action_group_get_action (window->toolbar_action_group,
+ "ViewCombinedStopReload");
+ ephy_combined_stop_reload_action_set_loading (EPHY_COMBINED_STOP_RELOAD_ACTION (action),
+ loading);
}
static void
sync_tab_security (EphyWebView *view,
- GParamSpec *pspec,
- EphyWindow *window)
+ GParamSpec *pspec,
+ EphyWindow *window)
{
- EphyTitleBox *title_box;
- EphySecurityLevel security_level;
+ EphyTitleBox *title_box;
+ EphySecurityLevel security_level;
- if (window->closing) return;
+ if (window->closing) return;
- ephy_web_view_get_security_level (view, &security_level, NULL, NULL);
- title_box = ephy_toolbar_get_title_box (EPHY_TOOLBAR (window->toolbar));
- ephy_title_box_set_security_level (title_box, security_level);
+ ephy_web_view_get_security_level (view, &security_level, NULL, NULL);
+ title_box = ephy_toolbar_get_title_box (EPHY_TOOLBAR (window->toolbar));
+ ephy_title_box_set_security_level (title_box, security_level);
}
static void
ephy_window_fullscreen (EphyWindow *window)
{
- EphyEmbed *embed;
+ EphyEmbed *embed;
- window->fullscreen_mode = TRUE;
+ window->fullscreen_mode = TRUE;
- /* sync status */
- embed = window->active_embed;
- sync_tab_load_status (ephy_embed_get_web_view (embed), WEBKIT_LOAD_STARTED, window);
- sync_tab_security (ephy_embed_get_web_view (embed), NULL, window);
+ /* sync status */
+ embed = window->active_embed;
+ sync_tab_load_status (ephy_embed_get_web_view (embed), WEBKIT_LOAD_STARTED, window);
+ sync_tab_security (ephy_embed_get_web_view (embed), NULL, window);
- sync_chromes_visibility (window);
- gtk_widget_hide (window->toolbar);
- ephy_embed_entering_fullscreen (embed);
+ sync_chromes_visibility (window);
+ gtk_widget_hide (window->toolbar);
+ ephy_embed_entering_fullscreen (embed);
}
static void
ephy_window_unfullscreen (EphyWindow *window)
{
- window->fullscreen_mode = FALSE;
+ window->fullscreen_mode = FALSE;
- gtk_widget_show (window->toolbar);
- sync_chromes_visibility (window);
- ephy_embed_leaving_fullscreen (window->active_embed);
+ gtk_widget_show (window->toolbar);
+ sync_chromes_visibility (window);
+ ephy_embed_leaving_fullscreen (window->active_embed);
}
static gboolean
-ephy_window_bound_accels (GtkWidget *widget,
- GdkEventKey *event)
-{
- EphyWindow *window = EPHY_WINDOW (widget);
- guint modifier = event->state & gtk_accelerator_get_default_mod_mask ();
- guint i;
-
- navigation_keybindings_rtl_ltr = gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL ?
- navigation_keybindings_rtl : navigation_keybindings_ltr;
-
- for (i = 0; i < G_N_ELEMENTS (extra_keybindings); i++)
- {
- if (event->keyval == extra_keybindings[i].keyval &&
- modifier == extra_keybindings[i].modifier)
- {
- GtkAction * action = gtk_action_group_get_action
- (extra_keybindings[i].fromToolbar ?
- window->toolbar_action_group :
- window->action_group,
- extra_keybindings[i].action);
- if (gtk_action_is_sensitive (action))
- {
- gtk_action_activate (action);
- return TRUE;
- }
- break;
- }
- }
-
- for (i = 0; i < G_N_ELEMENTS (navigation_keybindings_rtl); i++)
- {
- if (event->keyval == navigation_keybindings_rtl_ltr[i].keyval &&
- modifier == navigation_keybindings_rtl_ltr[i].modifier)
- {
- GtkAction * action = gtk_action_group_get_action
- (navigation_keybindings_rtl_ltr[i].fromToolbar ?
- window->toolbar_action_group :
- window->action_group,
- navigation_keybindings_rtl_ltr[i].action);
- if (gtk_action_is_sensitive (action))
- {
- gtk_action_activate (action);
- return TRUE;
- }
- break;
- }
- }
-
- return FALSE;
+ephy_window_bound_accels (GtkWidget *widget,
+ GdkEventKey *event)
+{
+ EphyWindow *window = EPHY_WINDOW (widget);
+ guint modifier = event->state & gtk_accelerator_get_default_mod_mask ();
+ guint i;
+
+ navigation_keybindings_rtl_ltr = gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL ?
+ navigation_keybindings_rtl : navigation_keybindings_ltr;
+
+ for (i = 0; i < G_N_ELEMENTS (extra_keybindings); i++) {
+ if (event->keyval == extra_keybindings[i].keyval &&
+ modifier == extra_keybindings[i].modifier) {
+ GtkAction *action = gtk_action_group_get_action
+ (extra_keybindings[i].fromToolbar ?
+ window->toolbar_action_group :
+ window->action_group,
+ extra_keybindings[i].action);
+ if (gtk_action_is_sensitive (action)) {
+ gtk_action_activate (action);
+ return TRUE;
+ }
+ break;
+ }
+ }
+
+ for (i = 0; i < G_N_ELEMENTS (navigation_keybindings_rtl); i++) {
+ if (event->keyval == navigation_keybindings_rtl_ltr[i].keyval &&
+ modifier == navigation_keybindings_rtl_ltr[i].modifier) {
+ GtkAction *action = gtk_action_group_get_action
+ (navigation_keybindings_rtl_ltr[i].fromToolbar ?
+ window->toolbar_action_group :
+ window->action_group,
+ navigation_keybindings_rtl_ltr[i].action);
+ if (gtk_action_is_sensitive (action)) {
+ gtk_action_activate (action);
+ return TRUE;
+ }
+ break;
+ }
+ }
+
+ return FALSE;
}
static gboolean
-ephy_window_key_press_event (GtkWidget *widget,
- GdkEventKey *event)
-{
- EphyWindow *window = EPHY_WINDOW (widget);
- GtkWidget *focus_widget;
- gboolean shortcircuit = FALSE, force_chain = FALSE, handled = FALSE;
- guint modifier = event->state & gtk_accelerator_get_default_mod_mask ();
-
- /* In an attempt to get the mozembed playing nice with things like emacs keybindings
- * we are passing important events to the focused child widget before letting the window's
- * base handler see them. This is *completely against* stated gtk2 policy but the
- * 'correct' behaviour is exceptionally useless. We need to keep an eye out for
- * unexpected consequences of this decision. IME's should be a high concern, but
- * considering that the IME folks complained about the upside-down event propagation
- * rules, we might be doing them a favour.
- *
- * We achieve this by first evaluating the event to see if it's important, and if
- * so, we get the focus widget and attempt to get the widget to handle that event.
- * If the widget does handle it, we're done (unless force_chain is true, in which
- * case the event is handled as normal in addition to being sent to the focus
- * widget), otherwise the event follows the normal handling path.
- */
-
- if ((event->state & GDK_CONTROL_MASK ||
- event->state & GDK_MOD1_MASK ||
- event->state & GDK_SHIFT_MASK) &&
- event->length > 0)
- {
- /* Pass (CTRL|ALT|SHIFT)+letter characters to the widget */
- shortcircuit = TRUE;
- }
- else if (event->keyval == GDK_KEY_Escape && modifier == 0)
- {
- /* Always pass Escape to both the widget, and the parent */
- shortcircuit = TRUE;
- force_chain = TRUE;
- }
- else if (window->key_theme_is_emacs &&
- (modifier == GDK_CONTROL_MASK) &&
- event->length > 0 &&
- /* But don't pass Ctrl+Enter twice */
- event->keyval != GDK_KEY_Return &&
- event->keyval != GDK_KEY_KP_Enter &&
- event->keyval != GDK_KEY_ISO_Enter)
- {
- /* Pass CTRL+letter characters to the widget */
- shortcircuit = TRUE;
- }
-
- if (shortcircuit)
- {
- focus_widget = gtk_window_get_focus (GTK_WINDOW (window));
-
- if (GTK_IS_WIDGET (focus_widget))
- {
- handled = gtk_widget_event (focus_widget,
- (GdkEvent*) event);
- }
-
- if (handled && !force_chain)
- {
- return handled;
- }
- }
-
- /* Handle accelerators that we want bound, but aren't associated with
- * an action */
- if (ephy_window_bound_accels (widget, event))
- {
- return TRUE;
- }
-
- return GTK_WIDGET_CLASS (ephy_window_parent_class)->key_press_event (widget, event);
+ephy_window_key_press_event (GtkWidget *widget,
+ GdkEventKey *event)
+{
+ EphyWindow *window = EPHY_WINDOW (widget);
+ GtkWidget *focus_widget;
+ gboolean shortcircuit = FALSE, force_chain = FALSE, handled = FALSE;
+ guint modifier = event->state & gtk_accelerator_get_default_mod_mask ();
+
+ /* In an attempt to get the mozembed playing nice with things like emacs keybindings
+ * we are passing important events to the focused child widget before letting the window's
+ * base handler see them. This is *completely against* stated gtk2 policy but the
+ * 'correct' behaviour is exceptionally useless. We need to keep an eye out for
+ * unexpected consequences of this decision. IME's should be a high concern, but
+ * considering that the IME folks complained about the upside-down event propagation
+ * rules, we might be doing them a favour.
+ *
+ * We achieve this by first evaluating the event to see if it's important, and if
+ * so, we get the focus widget and attempt to get the widget to handle that event.
+ * If the widget does handle it, we're done (unless force_chain is true, in which
+ * case the event is handled as normal in addition to being sent to the focus
+ * widget), otherwise the event follows the normal handling path.
+ */
+
+ if ((event->state & GDK_CONTROL_MASK ||
+ event->state & GDK_MOD1_MASK ||
+ event->state & GDK_SHIFT_MASK) &&
+ event->length > 0) {
+ /* Pass (CTRL|ALT|SHIFT)+letter characters to the widget */
+ shortcircuit = TRUE;
+ } else if (event->keyval == GDK_KEY_Escape && modifier == 0) {
+ /* Always pass Escape to both the widget, and the parent */
+ shortcircuit = TRUE;
+ force_chain = TRUE;
+ } else if (window->key_theme_is_emacs &&
+ (modifier == GDK_CONTROL_MASK) &&
+ event->length > 0 &&
+ /* But don't pass Ctrl+Enter twice */
+ event->keyval != GDK_KEY_Return &&
+ event->keyval != GDK_KEY_KP_Enter &&
+ event->keyval != GDK_KEY_ISO_Enter) {
+ /* Pass CTRL+letter characters to the widget */
+ shortcircuit = TRUE;
+ }
+
+ if (shortcircuit) {
+ focus_widget = gtk_window_get_focus (GTK_WINDOW (window));
+
+ if (GTK_IS_WIDGET (focus_widget)) {
+ handled = gtk_widget_event (focus_widget,
+ (GdkEvent *)event);
+ }
+
+ if (handled && !force_chain) {
+ return handled;
+ }
+ }
+
+ /* Handle accelerators that we want bound, but aren't associated with
+ * an action */
+ if (ephy_window_bound_accels (widget, event)) {
+ return TRUE;
+ }
+
+ return GTK_WIDGET_CLASS (ephy_window_parent_class)->key_press_event (widget, event);
}
static gboolean
-ephy_window_delete_event (GtkWidget *widget,
- GdkEventAny *event)
+ephy_window_delete_event (GtkWidget *widget,
+ GdkEventAny *event)
{
- if (!ephy_window_close (EPHY_WINDOW (widget)))
- return TRUE;
+ if (!ephy_window_close (EPHY_WINDOW (widget)))
+ return TRUE;
- /* proceed with window close */
- if (GTK_WIDGET_CLASS (ephy_window_parent_class)->delete_event)
- {
- return GTK_WIDGET_CLASS (ephy_window_parent_class)->delete_event (widget, event);
- }
+ /* proceed with window close */
+ if (GTK_WIDGET_CLASS (ephy_window_parent_class)->delete_event) {
+ return GTK_WIDGET_CLASS (ephy_window_parent_class)->delete_event (widget, event);
+ }
- return FALSE;
+ return FALSE;
}
#define MAX_SPELL_CHECK_GUESSES 4
static void
update_link_actions_sensitivity (EphyWindow *window,
- gboolean link_has_web_scheme)
+ gboolean link_has_web_scheme)
{
- GtkAction *action;
- GtkActionGroup *action_group;
+ GtkAction *action;
+ GtkActionGroup *action_group;
- action_group = window->popups_action_group;
+ action_group = window->popups_action_group;
- action = gtk_action_group_get_action (action_group, "OpenLinkInNewWindow");
- gtk_action_set_sensitive (action, link_has_web_scheme);
+ action = gtk_action_group_get_action (action_group, "OpenLinkInNewWindow");
+ gtk_action_set_sensitive (action, link_has_web_scheme);
- action = gtk_action_group_get_action (action_group, "OpenLinkInNewTab");
- ephy_action_change_sensitivity_flags (action, SENS_FLAG_CONTEXT, !link_has_web_scheme);
+ action = gtk_action_group_get_action (action_group, "OpenLinkInNewTab");
+ ephy_action_change_sensitivity_flags (action, SENS_FLAG_CONTEXT, !link_has_web_scheme);
- action = gtk_action_group_get_action (action_group, "OpenLinkInIncognitoWindow");
- gtk_action_set_sensitive (action, link_has_web_scheme);
+ action = gtk_action_group_get_action (action_group, "OpenLinkInIncognitoWindow");
+ gtk_action_set_sensitive (action, link_has_web_scheme);
}
static void
update_edit_action_sensitivity (EphyWindow *window, const gchar *action_name, gboolean sensitive, gboolean
hide)
{
- GtkAction *action;
+ GtkAction *action;
- action = gtk_action_group_get_action (window->action_group, action_name);
- gtk_action_set_sensitive (action, sensitive);
- gtk_action_set_visible (action, !hide || sensitive);
+ action = gtk_action_group_get_action (window->action_group, action_name);
+ gtk_action_set_sensitive (action, sensitive);
+ gtk_action_set_visible (action, !hide || sensitive);
}
-typedef struct
-{
- EphyWindow *window;
- const gchar *action_name;
- gboolean hide;
+typedef struct {
+ EphyWindow *window;
+ const gchar *action_name;
+ gboolean hide;
} CanEditCommandAsyncData;
static CanEditCommandAsyncData *
can_edit_command_async_data_new (EphyWindow *window, const gchar *action_name, gboolean hide)
{
- CanEditCommandAsyncData *data;
+ CanEditCommandAsyncData *data;
- data = g_slice_new (CanEditCommandAsyncData);
- data->window = g_object_ref (window);
- data->action_name = action_name;
- data->hide = hide;
+ data = g_slice_new (CanEditCommandAsyncData);
+ data->window = g_object_ref (window);
+ data->action_name = action_name;
+ data->hide = hide;
- return data;
+ return data;
}
static void
can_edit_command_async_data_free (CanEditCommandAsyncData *data)
{
- if (G_UNLIKELY (!data))
- return;
+ if (G_UNLIKELY (!data))
+ return;
- g_object_unref (data->window);
- g_slice_free (CanEditCommandAsyncData, data);
+ g_object_unref (data->window);
+ g_slice_free (CanEditCommandAsyncData, data);
}
static void
can_edit_command_callback (GObject *object, GAsyncResult *result, CanEditCommandAsyncData *data)
{
- gboolean sensitive;
- GError *error = NULL;
-
- sensitive = webkit_web_view_can_execute_editing_command_finish (WEBKIT_WEB_VIEW (object), result,
&error);
- if (!error)
- {
- update_edit_action_sensitivity (data->window, data->action_name, sensitive, data->hide);
+ gboolean sensitive;
+ GError *error = NULL;
- }
- else
- {
- g_error_free (error);
- }
+ sensitive = webkit_web_view_can_execute_editing_command_finish (WEBKIT_WEB_VIEW (object), result, &error);
+ if (!error) {
+ update_edit_action_sensitivity (data->window, data->action_name, sensitive, data->hide);
+ } else {
+ g_error_free (error);
+ }
- can_edit_command_async_data_free (data);
+ can_edit_command_async_data_free (data);
}
static void
update_edit_actions_sensitivity (EphyWindow *window, gboolean hide)
{
- GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window));
- gboolean can_copy, can_cut, can_undo, can_redo, can_paste;
-
- if (GTK_IS_EDITABLE (widget))
- {
- GtkWidget *entry;
- gboolean has_selection;
-
- entry = ephy_toolbar_get_location_entry (EPHY_TOOLBAR (window->toolbar));
-
- has_selection = gtk_editable_get_selection_bounds
- (GTK_EDITABLE (widget), NULL, NULL);
-
- can_copy = has_selection;
- can_cut = has_selection;
- can_paste = TRUE;
- can_undo = ephy_location_entry_get_can_undo (EPHY_LOCATION_ENTRY (entry));
- can_redo = ephy_location_entry_get_can_redo (EPHY_LOCATION_ENTRY (entry));
- }
- else
- {
- EphyEmbed *embed;
- WebKitWebView *view;
- CanEditCommandAsyncData *data;
-
- embed = window->active_embed;
- g_return_if_fail (embed != NULL);
-
- view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
-
- data = can_edit_command_async_data_new (window, "EditCopy", hide);
- webkit_web_view_can_execute_editing_command (view, WEBKIT_EDITING_COMMAND_COPY, NULL,
- (GAsyncReadyCallback)can_edit_command_callback,
- data);
- data = can_edit_command_async_data_new (window, "EditCut", hide);
- webkit_web_view_can_execute_editing_command (view, WEBKIT_EDITING_COMMAND_CUT, NULL,
- (GAsyncReadyCallback)can_edit_command_callback,
- data);
- data = can_edit_command_async_data_new (window, "EditPaste", hide);
- webkit_web_view_can_execute_editing_command (view, WEBKIT_EDITING_COMMAND_PASTE, NULL,
- (GAsyncReadyCallback)can_edit_command_callback,
- data);
- data = can_edit_command_async_data_new (window, "EditUndo", hide);
- webkit_web_view_can_execute_editing_command (view, "Undo", NULL,
- (GAsyncReadyCallback)can_edit_command_callback,
- data);
- data = can_edit_command_async_data_new (window, "EditRedo", hide);
- webkit_web_view_can_execute_editing_command (view, "Redo", NULL,
- (GAsyncReadyCallback)can_edit_command_callback,
- data);
- return;
- }
-
- update_edit_action_sensitivity (window, "EditCopy", can_copy, hide);
- update_edit_action_sensitivity (window, "EditCut", can_cut, hide);
- update_edit_action_sensitivity (window, "EditPaste", can_paste, hide);
- update_edit_action_sensitivity (window, "EditUndo", can_undo, hide);
- update_edit_action_sensitivity (window, "EditRedo", can_redo, hide);
+ GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window));
+ gboolean can_copy, can_cut, can_undo, can_redo, can_paste;
+
+ if (GTK_IS_EDITABLE (widget)) {
+ GtkWidget *entry;
+ gboolean has_selection;
+
+ entry = ephy_toolbar_get_location_entry (EPHY_TOOLBAR (window->toolbar));
+
+ has_selection = gtk_editable_get_selection_bounds
+ (GTK_EDITABLE (widget), NULL, NULL);
+
+ can_copy = has_selection;
+ can_cut = has_selection;
+ can_paste = TRUE;
+ can_undo = ephy_location_entry_get_can_undo (EPHY_LOCATION_ENTRY (entry));
+ can_redo = ephy_location_entry_get_can_redo (EPHY_LOCATION_ENTRY (entry));
+ } else {
+ EphyEmbed *embed;
+ WebKitWebView *view;
+ CanEditCommandAsyncData *data;
+
+ embed = window->active_embed;
+ g_return_if_fail (embed != NULL);
+
+ view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
+
+ data = can_edit_command_async_data_new (window, "EditCopy", hide);
+ webkit_web_view_can_execute_editing_command (view, WEBKIT_EDITING_COMMAND_COPY, NULL,
+ (GAsyncReadyCallback)can_edit_command_callback,
+ data);
+ data = can_edit_command_async_data_new (window, "EditCut", hide);
+ webkit_web_view_can_execute_editing_command (view, WEBKIT_EDITING_COMMAND_CUT, NULL,
+ (GAsyncReadyCallback)can_edit_command_callback,
+ data);
+ data = can_edit_command_async_data_new (window, "EditPaste", hide);
+ webkit_web_view_can_execute_editing_command (view, WEBKIT_EDITING_COMMAND_PASTE, NULL,
+ (GAsyncReadyCallback)can_edit_command_callback,
+ data);
+ data = can_edit_command_async_data_new (window, "EditUndo", hide);
+ webkit_web_view_can_execute_editing_command (view, "Undo", NULL,
+ (GAsyncReadyCallback)can_edit_command_callback,
+ data);
+ data = can_edit_command_async_data_new (window, "EditRedo", hide);
+ webkit_web_view_can_execute_editing_command (view, "Redo", NULL,
+ (GAsyncReadyCallback)can_edit_command_callback,
+ data);
+ return;
+ }
+
+ update_edit_action_sensitivity (window, "EditCopy", can_copy, hide);
+ update_edit_action_sensitivity (window, "EditCut", can_cut, hide);
+ update_edit_action_sensitivity (window, "EditPaste", can_paste, hide);
+ update_edit_action_sensitivity (window, "EditUndo", can_undo, hide);
+ update_edit_action_sensitivity (window, "EditRedo", can_redo, hide);
}
static void
enable_edit_actions_sensitivity (EphyWindow *window)
{
- GtkActionGroup *action_group;
- GtkAction *action;
+ GtkActionGroup *action_group;
+ GtkAction *action;
- action_group = window->action_group;
+ action_group = window->action_group;
- action = gtk_action_group_get_action (action_group, "EditCopy");
- gtk_action_set_sensitive (action, TRUE);
- gtk_action_set_visible (action, TRUE);
- action = gtk_action_group_get_action (action_group, "EditCut");
- gtk_action_set_sensitive (action, TRUE);
- gtk_action_set_visible (action, TRUE);
- action = gtk_action_group_get_action (action_group, "EditPaste");
- gtk_action_set_sensitive (action, TRUE);
- gtk_action_set_visible (action, TRUE);
- action = gtk_action_group_get_action (action_group, "EditUndo");
- gtk_action_set_sensitive (action, TRUE);
- gtk_action_set_visible (action, TRUE);
- action = gtk_action_group_get_action (action_group, "EditRedo");
- gtk_action_set_sensitive (action, TRUE);
- gtk_action_set_visible (action, TRUE);
+ action = gtk_action_group_get_action (action_group, "EditCopy");
+ gtk_action_set_sensitive (action, TRUE);
+ gtk_action_set_visible (action, TRUE);
+ action = gtk_action_group_get_action (action_group, "EditCut");
+ gtk_action_set_sensitive (action, TRUE);
+ gtk_action_set_visible (action, TRUE);
+ action = gtk_action_group_get_action (action_group, "EditPaste");
+ gtk_action_set_sensitive (action, TRUE);
+ gtk_action_set_visible (action, TRUE);
+ action = gtk_action_group_get_action (action_group, "EditUndo");
+ gtk_action_set_sensitive (action, TRUE);
+ gtk_action_set_visible (action, TRUE);
+ action = gtk_action_group_get_action (action_group, "EditRedo");
+ gtk_action_set_sensitive (action, TRUE);
+ gtk_action_set_visible (action, TRUE);
}
static void
-edit_menu_show_cb (GtkWidget *menu,
- EphyWindow *window)
+edit_menu_show_cb (GtkWidget *menu,
+ EphyWindow *window)
{
- update_edit_actions_sensitivity (window, FALSE);
+ update_edit_actions_sensitivity (window, FALSE);
}
static void
-edit_menu_hide_cb (GtkWidget *menu,
- EphyWindow *window)
+edit_menu_hide_cb (GtkWidget *menu,
+ EphyWindow *window)
{
- enable_edit_actions_sensitivity (window);
+ enable_edit_actions_sensitivity (window);
}
static void
init_menu_updaters (EphyWindow *window)
{
- GtkWidget *edit_menu;
+ GtkWidget *edit_menu;
- edit_menu = gtk_ui_manager_get_widget
- (window->manager, "/ui/PagePopup");
+ edit_menu = gtk_ui_manager_get_widget
+ (window->manager, "/ui/PagePopup");
- g_signal_connect (edit_menu, "show",
- G_CALLBACK (edit_menu_show_cb), window);
- g_signal_connect (edit_menu, "hide",
- G_CALLBACK (edit_menu_hide_cb), window);
+ g_signal_connect (edit_menu, "show",
+ G_CALLBACK (edit_menu_show_cb), window);
+ g_signal_connect (edit_menu, "hide",
+ G_CALLBACK (edit_menu_hide_cb), window);
}
static void
setup_ui_manager (EphyWindow *window)
{
- GtkActionGroup *action_group;
- GtkAccelGroup *accel_group;
- GtkAction *action;
- GtkUIManager *manager;
-
- manager = gtk_ui_manager_new ();
- accel_group = gtk_ui_manager_get_accel_group (manager);
-
- action_group = gtk_action_group_new ("WindowActions");
- gtk_action_group_set_translation_domain (action_group, NULL);
- gtk_action_group_add_actions (action_group, ephy_menu_entries,
- G_N_ELEMENTS (ephy_menu_entries), window);
- gtk_action_group_add_toggle_actions (action_group,
- ephy_menu_toggle_entries,
- G_N_ELEMENTS (ephy_menu_toggle_entries),
- window);
- gtk_action_group_set_accel_group (action_group, accel_group);
- gtk_ui_manager_insert_action_group (manager, action_group, 0);
- window->action_group = action_group;
- g_object_unref (action_group);
-
- action = gtk_action_group_get_action (action_group, "FileOpen");
- g_object_set (action, "short_label", _("Open"), NULL);
- action = gtk_action_group_get_action (action_group, "FileSaveAs");
- g_object_set (action, "short_label", _("Save As"), NULL);
- action = gtk_action_group_get_action (action_group, "FileSaveAsApplication");
- g_object_set (action, "short_label", _("Save As Application"), NULL);
- action = gtk_action_group_get_action (action_group, "FilePrint");
- g_object_set (action, "short_label", _("Print"), NULL);
- action = gtk_action_group_get_action (action_group, "FileBookmarkPage");
- g_object_set (action, "short_label", _("Bookmark"), NULL);
- action = gtk_action_group_get_action (action_group, "EditFind");
- g_object_set (action, "short_label", _("Find"), NULL);
-
- action = gtk_action_group_get_action (action_group, "EditFind");
- g_object_set (action, "is_important", TRUE, NULL);
-
- action = gtk_action_group_get_action (action_group, "ViewEncoding");
- g_object_set (action, "short_label", _("Encodings…"), NULL);
- action = gtk_action_group_get_action (action_group, "ViewZoomIn");
- /* Translators: This refers to text size */
- g_object_set (action, "short-label", _("Larger"), NULL);
- action = gtk_action_group_get_action (action_group, "ViewZoomOut");
- /* Translators: This refers to text size */
- g_object_set (action, "short-label", _("Smaller"), NULL);
-
- action_group = gtk_action_group_new ("PopupsActions");
- gtk_action_group_set_translation_domain (action_group, NULL);
- gtk_action_group_add_actions (action_group, ephy_popups_entries,
- G_N_ELEMENTS (ephy_popups_entries), window);
- gtk_action_group_set_accel_group (action_group, accel_group);
- gtk_ui_manager_insert_action_group (manager, action_group, 0);
- window->popups_action_group = action_group;
- g_object_unref (action_group);
-
- /* Tab accels */
- action_group = gtk_action_group_new ("TabAccelsActions");
- gtk_action_group_set_accel_group (action_group, accel_group);
- gtk_ui_manager_insert_action_group (manager, action_group, 0);
- window->tab_accels_action_group = action_group;
- g_object_unref (action_group);
-
- action_group = gtk_action_group_new ("SpecialToolbarActions");
- action =
- g_object_new (EPHY_TYPE_NAVIGATION_HISTORY_ACTION,
- "name", "NavigationBack",
- "label", _("Back"),
- "icon-name", "go-previous-symbolic",
- "window", window,
- "direction", EPHY_NAVIGATION_HISTORY_DIRECTION_BACK,
- NULL);
- gtk_action_group_add_action_with_accel (action_group, action,
- "<alt>Left");
- g_object_unref (action);
-
- action =
- g_object_new (EPHY_TYPE_NAVIGATION_HISTORY_ACTION,
- "name", "NavigationForward",
- "label", _("Forward"),
- "icon-name", "go-next-symbolic",
- "window", window,
- "direction", EPHY_NAVIGATION_HISTORY_DIRECTION_FORWARD,
- NULL);
- gtk_action_group_add_action_with_accel (action_group, action,
- "<alt>Right");
- g_object_unref (action);
-
- action =
- g_object_new (EPHY_TYPE_ZOOM_ACTION,
- "name", "Zoom",
- "label", _("Zoom"),
- "zoom", 1.0,
- NULL);
- gtk_action_group_add_action (action_group, action);
- g_object_unref (action);
-
- action = g_object_new (EPHY_TYPE_HOME_ACTION,
- "name", "FileNewTab",
- "icon-name", "tab-new-symbolic",
- "label", _("New _Tab"),
- NULL);
- gtk_action_group_add_action_with_accel (action_group, action, "<control>T");
- g_object_unref (action);
-
- action =
- g_object_new (EPHY_TYPE_HOME_ACTION,
- "name", "FileHome",
- "label", _("Go to most visited"),
- NULL);
- gtk_action_group_add_action_with_accel (action_group, action, "<alt>Home");
- g_signal_connect_swapped (action, "open-link",
- G_CALLBACK (ephy_link_open), window);
- g_object_unref (action);
-
- action = g_object_new (EPHY_TYPE_COMBINED_STOP_RELOAD_ACTION,
- "name", "ViewCombinedStopReload",
- "loading", FALSE,
- "window", window,
- NULL);
- gtk_action_group_add_action (action_group, action);
- g_object_unref (action);
-
- gtk_action_group_set_accel_group (action_group, accel_group);
- gtk_ui_manager_insert_action_group (manager, action_group, 0);
- window->toolbar_action_group = action_group;
- g_object_unref (action_group);
-
- window->manager = manager;
- gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
+ GtkActionGroup *action_group;
+ GtkAccelGroup *accel_group;
+ GtkAction *action;
+ GtkUIManager *manager;
+
+ manager = gtk_ui_manager_new ();
+ accel_group = gtk_ui_manager_get_accel_group (manager);
+
+ action_group = gtk_action_group_new ("WindowActions");
+ gtk_action_group_set_translation_domain (action_group, NULL);
+ gtk_action_group_add_actions (action_group, ephy_menu_entries,
+ G_N_ELEMENTS (ephy_menu_entries), window);
+ gtk_action_group_add_toggle_actions (action_group,
+ ephy_menu_toggle_entries,
+ G_N_ELEMENTS (ephy_menu_toggle_entries),
+ window);
+ gtk_action_group_set_accel_group (action_group, accel_group);
+ gtk_ui_manager_insert_action_group (manager, action_group, 0);
+ window->action_group = action_group;
+ g_object_unref (action_group);
+
+ action = gtk_action_group_get_action (action_group, "FileOpen");
+ g_object_set (action, "short_label", _("Open"), NULL);
+ action = gtk_action_group_get_action (action_group, "FileSaveAs");
+ g_object_set (action, "short_label", _("Save As"), NULL);
+ action = gtk_action_group_get_action (action_group, "FileSaveAsApplication");
+ g_object_set (action, "short_label", _("Save As Application"), NULL);
+ action = gtk_action_group_get_action (action_group, "FilePrint");
+ g_object_set (action, "short_label", _("Print"), NULL);
+ action = gtk_action_group_get_action (action_group, "FileBookmarkPage");
+ g_object_set (action, "short_label", _("Bookmark"), NULL);
+ action = gtk_action_group_get_action (action_group, "EditFind");
+ g_object_set (action, "short_label", _("Find"), NULL);
+
+ action = gtk_action_group_get_action (action_group, "EditFind");
+ g_object_set (action, "is_important", TRUE, NULL);
+
+ action = gtk_action_group_get_action (action_group, "ViewEncoding");
+ g_object_set (action, "short_label", _("Encodings…"), NULL);
+ action = gtk_action_group_get_action (action_group, "ViewZoomIn");
+ /* Translators: This refers to text size */
+ g_object_set (action, "short-label", _("Larger"), NULL);
+ action = gtk_action_group_get_action (action_group, "ViewZoomOut");
+ /* Translators: This refers to text size */
+ g_object_set (action, "short-label", _("Smaller"), NULL);
+
+ action_group = gtk_action_group_new ("PopupsActions");
+ gtk_action_group_set_translation_domain (action_group, NULL);
+ gtk_action_group_add_actions (action_group, ephy_popups_entries,
+ G_N_ELEMENTS (ephy_popups_entries), window);
+ gtk_action_group_set_accel_group (action_group, accel_group);
+ gtk_ui_manager_insert_action_group (manager, action_group, 0);
+ window->popups_action_group = action_group;
+ g_object_unref (action_group);
+
+ /* Tab accels */
+ action_group = gtk_action_group_new ("TabAccelsActions");
+ gtk_action_group_set_accel_group (action_group, accel_group);
+ gtk_ui_manager_insert_action_group (manager, action_group, 0);
+ window->tab_accels_action_group = action_group;
+ g_object_unref (action_group);
+
+ action_group = gtk_action_group_new ("SpecialToolbarActions");
+ action =
+ g_object_new (EPHY_TYPE_NAVIGATION_HISTORY_ACTION,
+ "name", "NavigationBack",
+ "label", _("Back"),
+ "icon-name", "go-previous-symbolic",
+ "window", window,
+ "direction", EPHY_NAVIGATION_HISTORY_DIRECTION_BACK,
+ NULL);
+ gtk_action_group_add_action_with_accel (action_group, action,
+ "<alt>Left");
+ g_object_unref (action);
+
+ action =
+ g_object_new (EPHY_TYPE_NAVIGATION_HISTORY_ACTION,
+ "name", "NavigationForward",
+ "label", _("Forward"),
+ "icon-name", "go-next-symbolic",
+ "window", window,
+ "direction", EPHY_NAVIGATION_HISTORY_DIRECTION_FORWARD,
+ NULL);
+ gtk_action_group_add_action_with_accel (action_group, action,
+ "<alt>Right");
+ g_object_unref (action);
+
+ action =
+ g_object_new (EPHY_TYPE_ZOOM_ACTION,
+ "name", "Zoom",
+ "label", _("Zoom"),
+ "zoom", 1.0,
+ NULL);
+ gtk_action_group_add_action (action_group, action);
+ g_object_unref (action);
+
+ action = g_object_new (EPHY_TYPE_HOME_ACTION,
+ "name", "FileNewTab",
+ "icon-name", "tab-new-symbolic",
+ "label", _("New _Tab"),
+ NULL);
+ gtk_action_group_add_action_with_accel (action_group, action, "<control>T");
+ g_object_unref (action);
+
+ action =
+ g_object_new (EPHY_TYPE_HOME_ACTION,
+ "name", "FileHome",
+ "label", _("Go to most visited"),
+ NULL);
+ gtk_action_group_add_action_with_accel (action_group, action, "<alt>Home");
+ g_signal_connect_swapped (action, "open-link",
+ G_CALLBACK (ephy_link_open), window);
+ g_object_unref (action);
+
+ action = g_object_new (EPHY_TYPE_COMBINED_STOP_RELOAD_ACTION,
+ "name", "ViewCombinedStopReload",
+ "loading", FALSE,
+ "window", window,
+ NULL);
+ gtk_action_group_add_action (action_group, action);
+ g_object_unref (action);
+
+ gtk_action_group_set_accel_group (action_group, accel_group);
+ gtk_ui_manager_insert_action_group (manager, action_group, 0);
+ window->toolbar_action_group = action_group;
+ g_object_unref (action_group);
+
+ window->manager = manager;
+ gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
}
static char *
calculate_location (const char *typed_address, const char *address)
{
- const char *location;
+ const char *location;
- /* If there's a typed address, use that over address. Never
- * show URIs in the 'do_not_show_address' array. */
- location = typed_address ? typed_address : address;
- location = ephy_embed_utils_is_no_show_address (location) ? NULL : location;
+ /* If there's a typed address, use that over address. Never
+ * show URIs in the 'do_not_show_address' array. */
+ location = typed_address ? typed_address : address;
+ location = ephy_embed_utils_is_no_show_address (location) ? NULL : location;
- return g_strdup (location);
+ return g_strdup (location);
}
static void
_ephy_window_set_default_actions_sensitive (EphyWindow *window,
- guint flags,
- gboolean set)
-{
- GtkActionGroup *action_group;
- GtkAction *action;
- int i;
- const char *action_group_actions[] = { "FileSaveAs", "FileSaveAsApplication", "FilePrint",
- "FileSendTo", "FileBookmarkPage", "EditFind",
- "EditFindPrev", "EditFindNext", "ViewEncoding",
- "ViewZoomIn", "ViewZoomOut", "ViewPageSource",
- NULL };
-
- action_group = window->action_group;
-
- /* Page menu */
- for (i = 0; action_group_actions[i] != NULL; i++)
- {
- action = gtk_action_group_get_action (action_group,
- action_group_actions[i]);
- ephy_action_change_sensitivity_flags (action,
- flags, set);
- }
-
- /* Page context popup */
- action = gtk_action_group_get_action (window->popups_action_group,
- "ContextBookmarkPage");
- ephy_action_change_sensitivity_flags (action,
- flags, set);
-
- /* Toolbar */
- action = gtk_action_group_get_action (window->toolbar_action_group,
- "ViewCombinedStopReload");
- ephy_action_change_sensitivity_flags (action,
- flags, set);
+ guint flags,
+ gboolean set)
+{
+ GtkActionGroup *action_group;
+ GtkAction *action;
+ int i;
+ const char *action_group_actions[] = { "FileSaveAs", "FileSaveAsApplication", "FilePrint",
+ "FileSendTo", "FileBookmarkPage", "EditFind",
+ "EditFindPrev", "EditFindNext", "ViewEncoding",
+ "ViewZoomIn", "ViewZoomOut", "ViewPageSource",
+ NULL };
+
+ action_group = window->action_group;
+
+ /* Page menu */
+ for (i = 0; action_group_actions[i] != NULL; i++) {
+ action = gtk_action_group_get_action (action_group,
+ action_group_actions[i]);
+ ephy_action_change_sensitivity_flags (action,
+ flags, set);
+ }
+
+ /* Page context popup */
+ action = gtk_action_group_get_action (window->popups_action_group,
+ "ContextBookmarkPage");
+ ephy_action_change_sensitivity_flags (action,
+ flags, set);
+
+ /* Toolbar */
+ action = gtk_action_group_get_action (window->toolbar_action_group,
+ "ViewCombinedStopReload");
+ ephy_action_change_sensitivity_flags (action,
+ flags, set);
}
static void
sync_tab_address (EphyWebView *view,
- GParamSpec *pspec,
- EphyWindow *window)
+ GParamSpec *pspec,
+ EphyWindow *window)
{
- const char *address;
- const char *typed_address;
- char *location;
+ const char *address;
+ const char *typed_address;
+ char *location;
- if (window->closing) return;
+ if (window->closing) return;
- address = ephy_web_view_get_display_address (view);
- typed_address = ephy_web_view_get_typed_address (view);
+ address = ephy_web_view_get_display_address (view);
+ typed_address = ephy_web_view_get_typed_address (view);
- _ephy_window_set_default_actions_sensitive (window,
- SENS_FLAG_IS_BLANK,
- ephy_web_view_is_overview (view));
+ _ephy_window_set_default_actions_sensitive (window,
+ SENS_FLAG_IS_BLANK,
+ ephy_web_view_is_overview (view));
- location = calculate_location (typed_address, address);
- ephy_window_set_location (window, location);
- g_free (location);
+ location = calculate_location (typed_address, address);
+ ephy_window_set_location (window, location);
+ g_free (location);
}
static void
sync_tab_zoom (WebKitWebView *web_view, GParamSpec *pspec, EphyWindow *window)
{
- GtkActionGroup *action_group;
- GtkAction *action;
- gboolean can_zoom_in = TRUE, can_zoom_out = TRUE, can_zoom_normal = FALSE;
- double zoom;
+ GtkActionGroup *action_group;
+ GtkAction *action;
+ gboolean can_zoom_in = TRUE, can_zoom_out = TRUE, can_zoom_normal = FALSE;
+ double zoom;
- if (window->closing) return;
+ if (window->closing) return;
- zoom = webkit_web_view_get_zoom_level (web_view);
+ zoom = webkit_web_view_get_zoom_level (web_view);
- if (zoom >= ZOOM_MAXIMAL)
- {
- can_zoom_in = FALSE;
- }
+ if (zoom >= ZOOM_MAXIMAL) {
+ can_zoom_in = FALSE;
+ }
- if (zoom <= ZOOM_MINIMAL)
- {
- can_zoom_out = FALSE;
- }
+ if (zoom <= ZOOM_MINIMAL) {
+ can_zoom_out = FALSE;
+ }
- if (zoom != 1.0)
- {
- can_zoom_normal = TRUE;
- }
+ if (zoom != 1.0) {
+ can_zoom_normal = TRUE;
+ }
- action_group = window->action_group;
- action = gtk_action_group_get_action (action_group, "ViewZoomIn");
- gtk_action_set_sensitive (action, can_zoom_in);
- action = gtk_action_group_get_action (action_group, "ViewZoomOut");
- gtk_action_set_sensitive (action, can_zoom_out);
- action = gtk_action_group_get_action (action_group, "ViewZoomNormal");
- gtk_action_set_sensitive (action, can_zoom_normal);
+ action_group = window->action_group;
+ action = gtk_action_group_get_action (action_group, "ViewZoomIn");
+ gtk_action_set_sensitive (action, can_zoom_in);
+ action = gtk_action_group_get_action (action_group, "ViewZoomOut");
+ gtk_action_set_sensitive (action, can_zoom_out);
+ action = gtk_action_group_get_action (action_group, "ViewZoomNormal");
+ gtk_action_set_sensitive (action, can_zoom_normal);
}
static void
sync_tab_document_type (EphyWebView *view,
- GParamSpec *pspec,
- EphyWindow *window)
+ GParamSpec *pspec,
+ EphyWindow *window)
{
- GtkActionGroup *action_group = window->action_group;
- GtkAction *action;
- EphyWebViewDocumentType type;
- gboolean can_find, disable, is_image;
+ GtkActionGroup *action_group = window->action_group;
+ GtkAction *action;
+ EphyWebViewDocumentType type;
+ gboolean can_find, disable, is_image;
- if (window->closing) return;
+ if (window->closing) return;
- /* update zoom actions */
- sync_tab_zoom (WEBKIT_WEB_VIEW (view), NULL, window);
+ /* update zoom actions */
+ sync_tab_zoom (WEBKIT_WEB_VIEW (view), NULL, window);
- type = ephy_web_view_get_document_type (view);
- can_find = (type != EPHY_WEB_VIEW_DOCUMENT_IMAGE);
- is_image = type == EPHY_WEB_VIEW_DOCUMENT_IMAGE;
- disable = (type != EPHY_WEB_VIEW_DOCUMENT_HTML);
+ type = ephy_web_view_get_document_type (view);
+ can_find = (type != EPHY_WEB_VIEW_DOCUMENT_IMAGE);
+ is_image = type == EPHY_WEB_VIEW_DOCUMENT_IMAGE;
+ disable = (type != EPHY_WEB_VIEW_DOCUMENT_HTML);
- action = gtk_action_group_get_action (action_group, "ViewEncoding");
- ephy_action_change_sensitivity_flags (action, SENS_FLAG_DOCUMENT, disable);
- action = gtk_action_group_get_action (action_group, "ViewPageSource");
- ephy_action_change_sensitivity_flags (action, SENS_FLAG_DOCUMENT, is_image);
- action = gtk_action_group_get_action (action_group, "EditFind");
- ephy_action_change_sensitivity_flags (action, SENS_FLAG_DOCUMENT, !can_find);
- action = gtk_action_group_get_action (action_group, "EditFindNext");
- ephy_action_change_sensitivity_flags (action, SENS_FLAG_DOCUMENT, !can_find);
- action = gtk_action_group_get_action (action_group, "EditFindPrev");
- ephy_action_change_sensitivity_flags (action, SENS_FLAG_DOCUMENT, !can_find);
+ action = gtk_action_group_get_action (action_group, "ViewEncoding");
+ ephy_action_change_sensitivity_flags (action, SENS_FLAG_DOCUMENT, disable);
+ action = gtk_action_group_get_action (action_group, "ViewPageSource");
+ ephy_action_change_sensitivity_flags (action, SENS_FLAG_DOCUMENT, is_image);
+ action = gtk_action_group_get_action (action_group, "EditFind");
+ ephy_action_change_sensitivity_flags (action, SENS_FLAG_DOCUMENT, !can_find);
+ action = gtk_action_group_get_action (action_group, "EditFindNext");
+ ephy_action_change_sensitivity_flags (action, SENS_FLAG_DOCUMENT, !can_find);
+ action = gtk_action_group_get_action (action_group, "EditFindPrev");
+ ephy_action_change_sensitivity_flags (action, SENS_FLAG_DOCUMENT, !can_find);
- if (!can_find)
- {
- ephy_find_toolbar_request_close (ephy_embed_get_find_toolbar (window->active_embed));
- }
+ if (!can_find) {
+ ephy_find_toolbar_request_close (ephy_embed_get_find_toolbar (window->active_embed));
+ }
}
static void
_ephy_window_action_set_favicon (EphyWindow *window,
- GdkPixbuf *icon)
+ GdkPixbuf *icon)
{
- g_object_set (window->location_controller, "icon", icon, NULL);
+ g_object_set (window->location_controller, "icon", icon, NULL);
}
static void
sync_tab_icon (EphyWebView *view,
- GParamSpec *pspec,
- EphyWindow *window)
+ GParamSpec *pspec,
+ EphyWindow *window)
{
- GdkPixbuf *icon;
+ GdkPixbuf *icon;
- if (window->closing) return;
+ if (window->closing) return;
- icon = ephy_web_view_get_icon (view);
+ icon = ephy_web_view_get_icon (view);
- _ephy_window_action_set_favicon (window, icon);
+ _ephy_window_action_set_favicon (window, icon);
}
static void
-_ephy_window_set_navigation_flags (EphyWindow *window,
- EphyWebViewNavigationFlags flags)
+_ephy_window_set_navigation_flags (EphyWindow *window,
+ EphyWebViewNavigationFlags flags)
{
- GtkAction *action;
+ GtkAction *action;
- action = gtk_action_group_get_action (window->toolbar_action_group, "NavigationBack");
- gtk_action_set_sensitive (action, flags & EPHY_WEB_VIEW_NAV_BACK);
- action = gtk_action_group_get_action (window->toolbar_action_group, "NavigationForward");
- gtk_action_set_sensitive (action, flags & EPHY_WEB_VIEW_NAV_FORWARD);
+ action = gtk_action_group_get_action (window->toolbar_action_group, "NavigationBack");
+ gtk_action_set_sensitive (action, flags & EPHY_WEB_VIEW_NAV_BACK);
+ action = gtk_action_group_get_action (window->toolbar_action_group, "NavigationForward");
+ gtk_action_set_sensitive (action, flags & EPHY_WEB_VIEW_NAV_FORWARD);
}
static void
sync_tab_navigation (EphyWebView *view,
- GParamSpec *pspec,
- EphyWindow *window)
+ GParamSpec *pspec,
+ EphyWindow *window)
{
- if (window->closing) return;
+ if (window->closing) return;
- _ephy_window_set_navigation_flags (window,
- ephy_web_view_get_navigation_flags (view));
+ _ephy_window_set_navigation_flags (window,
+ ephy_web_view_get_navigation_flags (view));
}
static void
sync_tab_is_blank (EphyWebView *view,
- GParamSpec *pspec,
- EphyWindow *window)
+ GParamSpec *pspec,
+ EphyWindow *window)
{
- if (window->closing) return;
+ if (window->closing) return;
- _ephy_window_set_default_actions_sensitive (window,
- SENS_FLAG_IS_BLANK,
- ephy_web_view_get_is_blank (view));
+ _ephy_window_set_default_actions_sensitive (window,
+ SENS_FLAG_IS_BLANK,
+ ephy_web_view_get_is_blank (view));
}
static void
sync_tab_popup_windows (EphyWebView *view,
- GParamSpec *pspec,
- EphyWindow *window)
+ GParamSpec *pspec,
+ EphyWindow *window)
{
- /* FIXME: show popup count somehow */
+ /* FIXME: show popup count somehow */
}
static void
sync_tab_popups_allowed (EphyWebView *view,
- GParamSpec *pspec,
- EphyWindow *window)
+ GParamSpec *pspec,
+ EphyWindow *window)
{
- GtkAction *action;
- gboolean allow;
+ GtkAction *action;
+ gboolean allow;
- g_return_if_fail (EPHY_IS_WEB_VIEW (view));
- g_return_if_fail (EPHY_IS_WINDOW (window));
+ g_return_if_fail (EPHY_IS_WEB_VIEW (view));
+ g_return_if_fail (EPHY_IS_WINDOW (window));
- action = gtk_action_group_get_action (window->action_group,
- "ViewPopupWindows");
- g_return_if_fail (GTK_IS_ACTION (action));
+ action = gtk_action_group_get_action (window->action_group,
+ "ViewPopupWindows");
+ g_return_if_fail (GTK_IS_ACTION (action));
- g_object_get (view, "popups-allowed", &allow, NULL);
+ g_object_get (view, "popups-allowed", &allow, NULL);
- g_signal_handlers_block_by_func
- (G_OBJECT (action),
- G_CALLBACK (ephy_window_view_popup_windows_cb),
- window);
+ g_signal_handlers_block_by_func
+ (G_OBJECT (action),
+ G_CALLBACK (ephy_window_view_popup_windows_cb),
+ window);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), allow);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), allow);
- g_signal_handlers_unblock_by_func
- (G_OBJECT (action),
- G_CALLBACK (ephy_window_view_popup_windows_cb),
- window);
+ g_signal_handlers_unblock_by_func
+ (G_OBJECT (action),
+ G_CALLBACK (ephy_window_view_popup_windows_cb),
+ window);
}
static void
-sync_tab_title (EphyEmbed *embed,
- GParamSpec *pspec,
- EphyWindow *window)
+sync_tab_title (EphyEmbed *embed,
+ GParamSpec *pspec,
+ EphyWindow *window)
{
- if (window->closing) return;
+ if (window->closing) return;
- gtk_window_set_title (GTK_WINDOW(window),
- ephy_embed_get_title (embed));
+ gtk_window_set_title (GTK_WINDOW (window),
+ ephy_embed_get_title (embed));
}
static gboolean
idle_unref_context_event (EphyWindow *window)
{
- LOG ("Idle unreffing context event %p", window->context_event);
+ LOG ("Idle unreffing context event %p", window->context_event);
- if (window->context_event != NULL)
- {
- g_object_unref (window->context_event);
- window->context_event = NULL;
- }
+ if (window->context_event != NULL) {
+ g_object_unref (window->context_event);
+ window->context_event = NULL;
+ }
- window->idle_worker = 0;
- return FALSE;
+ window->idle_worker = 0;
+ return FALSE;
}
static void
-_ephy_window_set_context_event (EphyWindow *window,
- EphyEmbedEvent *event)
+_ephy_window_set_context_event (EphyWindow *window,
+ EphyEmbedEvent *event)
{
- if (window->idle_worker != 0)
- {
- g_source_remove (window->idle_worker);
- window->idle_worker = 0;
- }
+ if (window->idle_worker != 0) {
+ g_source_remove (window->idle_worker);
+ window->idle_worker = 0;
+ }
- if (window->context_event != NULL)
- {
- g_object_unref (window->context_event);
- }
+ if (window->context_event != NULL) {
+ g_object_unref (window->context_event);
+ }
- window->context_event = event != NULL ? g_object_ref (event) : NULL;
+ window->context_event = event != NULL ? g_object_ref (event) : NULL;
}
static void
_ephy_window_unset_context_event (EphyWindow *window)
{
- /* Unref the event from idle since we still need it
- * from the action callbacks which will run before idle.
- */
- if (window->idle_worker == 0 && window->context_event != NULL)
- {
- window->idle_worker =
- g_idle_add ((GSourceFunc) idle_unref_context_event, window);
- }
+ /* Unref the event from idle since we still need it
+ * from the action callbacks which will run before idle.
+ */
+ if (window->idle_worker == 0 && window->context_event != NULL) {
+ window->idle_worker =
+ g_idle_add ((GSourceFunc)idle_unref_context_event, window);
+ }
}
static void
context_menu_dismissed_cb (WebKitWebView *webView,
- EphyWindow *window)
+ EphyWindow *window)
{
- LOG ("Deactivating popup menu");
+ LOG ("Deactivating popup menu");
- enable_edit_actions_sensitivity (window);
+ enable_edit_actions_sensitivity (window);
- g_signal_handlers_disconnect_by_func
- (webView, G_CALLBACK (context_menu_dismissed_cb), window);
+ g_signal_handlers_disconnect_by_func
+ (webView, G_CALLBACK (context_menu_dismissed_cb), window);
- _ephy_window_unset_context_event (window);
+ _ephy_window_unset_context_event (window);
}
static void
add_action_to_context_menu (WebKitContextMenu *context_menu,
- GtkActionGroup *action_group,
- const char *action_name)
+ GtkActionGroup *action_group,
+ const char *action_name)
{
- GtkAction *action;
+ GtkAction *action;
- action = gtk_action_group_get_action (action_group, action_name);
- webkit_context_menu_append (context_menu, webkit_context_menu_item_new (action));
+ action = gtk_action_group_get_action (action_group, action_name);
+ webkit_context_menu_append (context_menu, webkit_context_menu_item_new (action));
}
static void
-add_item_to_context_menu (WebKitContextMenu *context_menu,
- WebKitContextMenuItem *item)
+add_item_to_context_menu (WebKitContextMenu *context_menu,
+ WebKitContextMenuItem *item)
{
- if (!item)
- return;
+ if (!item)
+ return;
- webkit_context_menu_append (context_menu, item);
- g_object_unref (item);
+ webkit_context_menu_append (context_menu, item);
+ g_object_unref (item);
}
/* FIXME: Add webkit_context_menu_find() ? */
static WebKitContextMenuItem *
-find_item_in_context_menu (WebKitContextMenu *context_menu,
- WebKitContextMenuAction action)
+find_item_in_context_menu (WebKitContextMenu *context_menu,
+ WebKitContextMenuAction action)
{
- GList *items, *iter;
+ GList *items, *iter;
- items = webkit_context_menu_get_items (context_menu);
- for (iter = items; iter; iter = g_list_next (iter))
- {
- WebKitContextMenuItem *item = (WebKitContextMenuItem *)iter->data;
+ items = webkit_context_menu_get_items (context_menu);
+ for (iter = items; iter; iter = g_list_next (iter)) {
+ WebKitContextMenuItem *item = (WebKitContextMenuItem *)iter->data;
- if (webkit_context_menu_item_get_stock_action (item) == action)
- return g_object_ref (item);
- }
+ if (webkit_context_menu_item_get_stock_action (item) == action)
+ return g_object_ref (item);
+ }
- return NULL;
+ return NULL;
}
static GList *
find_spelling_guess_context_menu_items (WebKitContextMenu *context_menu)
{
- GList *items, *iter;
- guint i;
- GList *retval = NULL;
+ GList *items, *iter;
+ guint i;
+ GList *retval = NULL;
- items = webkit_context_menu_get_items (context_menu);
- for (iter = items, i = 0; iter && i < MAX_SPELL_CHECK_GUESSES; iter = g_list_next (iter), i++)
- {
- WebKitContextMenuItem *item = (WebKitContextMenuItem *)iter->data;
+ items = webkit_context_menu_get_items (context_menu);
+ for (iter = items, i = 0; iter && i < MAX_SPELL_CHECK_GUESSES; iter = g_list_next (iter), i++) {
+ WebKitContextMenuItem *item = (WebKitContextMenuItem *)iter->data;
- if (webkit_context_menu_item_get_stock_action (item) ==
WEBKIT_CONTEXT_MENU_ACTION_SPELLING_GUESS)
- {
- retval = g_list_prepend (retval, g_object_ref (item));
- }
- else
- {
- /* Spelling guesses are always at the beginning of the context menu, so
- * we can break the loop as soon as we find the first item that is not
- * spelling guess.
- */
- break;
- }
- }
+ if (webkit_context_menu_item_get_stock_action (item) == WEBKIT_CONTEXT_MENU_ACTION_SPELLING_GUESS) {
+ retval = g_list_prepend (retval, g_object_ref (item));
+ } else {
+ /* Spelling guesses are always at the beginning of the context menu, so
+ * we can break the loop as soon as we find the first item that is not
+ * spelling guess.
+ */
+ break;
+ }
+ }
- return g_list_reverse (retval);
+ return g_list_reverse (retval);
}
static char *
ellipsize_string (const char *string,
- glong max_length)
+ glong max_length)
{
- char *ellipsized;
- glong length = g_utf8_strlen (string, -1);
+ char *ellipsized;
+ glong length = g_utf8_strlen (string, -1);
- if (length == 0)
- return NULL;
+ if (length == 0)
+ return NULL;
- if (length < max_length)
- {
- ellipsized = g_strdup (string);
- }
- else
- {
- char *str = g_utf8_substring (string, 0, max_length);
- ellipsized = g_strconcat (str, "…", NULL);
- g_free (str);
- }
- return ellipsized;
+ if (length < max_length) {
+ ellipsized = g_strdup (string);
+ } else {
+ char *str = g_utf8_substring (string, 0, max_length);
+ ellipsized = g_strconcat (str, "…", NULL);
+ g_free (str);
+ }
+ return ellipsized;
}
static void
parse_context_menu_user_data (WebKitContextMenu *context_menu,
- const char** selected_text)
+ const char **selected_text)
{
- GVariantDict dict;
+ GVariantDict dict;
- g_variant_dict_init (&dict, webkit_context_menu_get_user_data (context_menu));
- g_variant_dict_lookup (&dict, "SelectedText", "&s", selected_text);
+ g_variant_dict_init (&dict, webkit_context_menu_get_user_data (context_menu));
+ g_variant_dict_lookup (&dict, "SelectedText", "&s", selected_text);
}
static gboolean
-populate_context_menu (WebKitWebView *web_view,
- WebKitContextMenu *context_menu,
- GdkEvent *event,
- WebKitHitTestResult *hit_test_result,
- EphyWindow *window)
-{
- WebKitContextMenuItem *input_methods_item = NULL;
- WebKitContextMenuItem *unicode_item = NULL;
- WebKitContextMenuItem *play_pause_item = NULL;
- WebKitContextMenuItem *mute_item = NULL;
- WebKitContextMenuItem *toggle_controls_item = NULL;
- WebKitContextMenuItem *toggle_loop_item = NULL;
- WebKitContextMenuItem *fullscreen_item = NULL;
- GList *spelling_guess_items = NULL;
- EphyEmbedEvent *embed_event;
- gboolean is_document = FALSE;
- gboolean app_mode, incognito_mode;
- gboolean is_image;
- gboolean is_media = FALSE;
- gboolean is_video = FALSE;
- gboolean is_audio = FALSE;
- gboolean can_search_selection = FALSE;
- const char *selected_text = NULL;
-
- is_image = webkit_hit_test_result_context_is_image (hit_test_result);
-
- if (webkit_hit_test_result_context_is_editable (hit_test_result)) {
- input_methods_item = find_item_in_context_menu (context_menu,
WEBKIT_CONTEXT_MENU_ACTION_INPUT_METHODS);
- unicode_item = find_item_in_context_menu (context_menu, WEBKIT_CONTEXT_MENU_ACTION_UNICODE);
- spelling_guess_items = find_spelling_guess_context_menu_items (context_menu);
- }
-
- if (webkit_hit_test_result_context_is_media (hit_test_result))
- {
- WebKitContextMenuItem *item;
-
- is_media = TRUE;
- play_pause_item = find_item_in_context_menu (context_menu,
WEBKIT_CONTEXT_MENU_ACTION_MEDIA_PLAY);
- if (!play_pause_item)
- play_pause_item = find_item_in_context_menu (context_menu,
WEBKIT_CONTEXT_MENU_ACTION_MEDIA_PAUSE);
- mute_item = find_item_in_context_menu (context_menu, WEBKIT_CONTEXT_MENU_ACTION_MEDIA_MUTE);
- toggle_controls_item = find_item_in_context_menu (context_menu,
WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_CONTROLS);
- toggle_loop_item = find_item_in_context_menu (context_menu,
WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_LOOP);
- fullscreen_item = find_item_in_context_menu (context_menu,
WEBKIT_CONTEXT_MENU_ACTION_ENTER_VIDEO_FULLSCREEN);
-
- item = find_item_in_context_menu (context_menu,
WEBKIT_CONTEXT_MENU_ACTION_COPY_VIDEO_LINK_TO_CLIPBOARD);
- if (item)
- {
- is_video = TRUE;
- g_object_unref (item);
- }
- else
- {
- item = find_item_in_context_menu (context_menu,
WEBKIT_CONTEXT_MENU_ACTION_COPY_AUDIO_LINK_TO_CLIPBOARD);
- if (item)
- {
- is_audio = TRUE;
- g_object_unref (item);
- }
- }
- }
-
- parse_context_menu_user_data (context_menu, &selected_text);
- if (selected_text)
- {
- char* ellipsized = ellipsize_string (selected_text, 32);
- if (ellipsized)
- {
- char* label;
- GtkAction *action;
-
- can_search_selection = TRUE;
- action = gtk_action_group_get_action (window->popups_action_group,
- "SearchSelection");
- label = g_strdup_printf (_("Search the Web for '%s'"), ellipsized);
- gtk_action_set_label (action, label);
- g_object_set_data_full (G_OBJECT (action), "selection", g_strdup (selected_text),
- (GDestroyNotify)g_free);
- g_free (ellipsized);
- g_free (label);
- can_search_selection = TRUE;
- }
- }
-
- webkit_context_menu_remove_all (context_menu);
-
- embed_event = ephy_embed_event_new ((GdkEventButton *)event, hit_test_result);
- _ephy_window_set_context_event (window, embed_event);
- g_object_unref (embed_event);
-
- app_mode = ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) ==
EPHY_EMBED_SHELL_MODE_APPLICATION;
- incognito_mode = ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) ==
EPHY_EMBED_SHELL_MODE_INCOGNITO;
-
- update_edit_actions_sensitivity (window, FALSE);
-
- if (webkit_hit_test_result_context_is_link (hit_test_result))
- {
- const char *uri;
- gboolean link_has_web_scheme;
-
- uri = webkit_hit_test_result_get_link_uri (hit_test_result);
- link_has_web_scheme = ephy_embed_utils_address_has_web_scheme (uri);
-
- update_edit_actions_sensitivity (window, TRUE);
- update_link_actions_sensitivity (window, link_has_web_scheme);
-
- if (!app_mode)
- {
- add_action_to_context_menu (context_menu,
- window->popups_action_group, "OpenLinkInNewTab");
- add_action_to_context_menu (context_menu,
- window->popups_action_group, "OpenLinkInNewWindow");
- if (!incognito_mode)
- add_action_to_context_menu (context_menu,
- window->popups_action_group,
"OpenLinkInIncognitoWindow");
- webkit_context_menu_append (context_menu,
- webkit_context_menu_item_new_separator ());
- }
- add_action_to_context_menu (context_menu,
- window->action_group, "EditCopy");
- if (can_search_selection)
- add_action_to_context_menu (context_menu,
- window->popups_action_group, "SearchSelection");
- webkit_context_menu_append (context_menu,
- webkit_context_menu_item_new_separator ());
- add_action_to_context_menu (context_menu,
- window->popups_action_group, "DownloadLinkAs");
-
- if (g_str_has_prefix (uri, "mailto:"))
- {
- add_action_to_context_menu (context_menu,
- window->popups_action_group, "CopyEmailAddress");
- }
- else
- {
- add_action_to_context_menu (context_menu,
- window->popups_action_group, "CopyLinkAddress");
- }
- }
- else if (webkit_hit_test_result_context_is_editable (hit_test_result))
- {
- GList *l;
- gboolean has_guesses = FALSE;
-
- for (l = spelling_guess_items; l; l = g_list_next (l))
- {
- WebKitContextMenuItem *item = WEBKIT_CONTEXT_MENU_ITEM (l->data);
-
- webkit_context_menu_append (context_menu, item);
- g_object_unref (item);
- has_guesses = TRUE;
- }
- g_list_free (spelling_guess_items);
-
- if (has_guesses)
- {
- webkit_context_menu_append (context_menu,
- webkit_context_menu_item_new_separator ());
- }
-
- update_edit_actions_sensitivity (window, FALSE);
-
- add_action_to_context_menu (context_menu,
- window->action_group, "EditUndo");
- add_action_to_context_menu (context_menu,
- window->action_group, "EditRedo");
- webkit_context_menu_append (context_menu,
- webkit_context_menu_item_new_separator ());
- add_action_to_context_menu (context_menu,
- window->action_group, "EditCut");
- add_action_to_context_menu (context_menu,
- window->action_group, "EditCopy");
- add_action_to_context_menu (context_menu,
- window->action_group, "EditPaste");
- webkit_context_menu_append (context_menu,
- webkit_context_menu_item_new_separator ());
- add_action_to_context_menu (context_menu,
- window->action_group, "EditSelectAll");
- if (input_methods_item || unicode_item)
- webkit_context_menu_append (context_menu,
- webkit_context_menu_item_new_separator ());
- add_item_to_context_menu (context_menu, input_methods_item);
- add_item_to_context_menu (context_menu, unicode_item);
- }
- else
- {
- is_document = TRUE;
-
- update_edit_actions_sensitivity (window, TRUE);
-
- if (!is_image && !is_media)
- {
- add_action_to_context_menu (context_menu,
- window->toolbar_action_group, "NavigationBack");
- add_action_to_context_menu (context_menu,
- window->toolbar_action_group, "NavigationForward");
- add_action_to_context_menu (context_menu,
- window->action_group, "ViewReload");
- webkit_context_menu_append (context_menu,
- webkit_context_menu_item_new_separator ());
- }
-
- add_action_to_context_menu (context_menu,
- window->action_group, "EditCopy");
- if (can_search_selection)
- add_action_to_context_menu (context_menu,
- window->popups_action_group, "SearchSelection");
-
- if (!app_mode && !is_image && !is_media)
- {
- webkit_context_menu_append (context_menu,
- webkit_context_menu_item_new_separator ());
- add_action_to_context_menu (context_menu,
- window->popups_action_group, "ContextBookmarkPage");
- }
- }
-
- if (is_image)
- {
- webkit_context_menu_append (context_menu,
- webkit_context_menu_item_new_separator ());
- add_action_to_context_menu (context_menu,
- window->popups_action_group, "SaveImageAs");
- add_action_to_context_menu (context_menu,
- window->popups_action_group, "CopyImageLocation");
- add_action_to_context_menu (context_menu,
- window->popups_action_group, "ViewImage");
- add_action_to_context_menu (context_menu,
- window->popups_action_group, "SetImageAsBackground");
- }
-
- if (is_media)
- {
- add_item_to_context_menu (context_menu, play_pause_item);
- add_item_to_context_menu (context_menu, mute_item);
- add_item_to_context_menu (context_menu, toggle_controls_item);
- add_item_to_context_menu (context_menu, toggle_loop_item);
- add_item_to_context_menu (context_menu, fullscreen_item);
- webkit_context_menu_append (context_menu,
- webkit_context_menu_item_new_separator ());
- if (is_video)
- {
- add_action_to_context_menu (context_menu, window->popups_action_group,
- "OpenVideoInNewWindow");
- add_action_to_context_menu (context_menu, window->popups_action_group,
- "OpenVideoInNewTab");
- add_action_to_context_menu (context_menu, window->popups_action_group,
- "SaveVideoAs");
- add_action_to_context_menu (context_menu, window->popups_action_group,
- "CopyVideoLocation");
- }
- else if (is_audio)
- {
- add_action_to_context_menu (context_menu, window->popups_action_group,
- "OpenAudioInNewWindow");
- add_action_to_context_menu (context_menu, window->popups_action_group,
- "OpenAudioInNewTab");
- add_action_to_context_menu (context_menu, window->popups_action_group,
- "SaveAudioAs");
- add_action_to_context_menu (context_menu, window->popups_action_group,
- "CopyAudioLocation");
- }
- }
-
- g_signal_connect (web_view, "context-menu-dismissed",
- G_CALLBACK (context_menu_dismissed_cb),
- window);
-
- if (app_mode)
- return FALSE;
-
- if (is_document && !is_image && !is_media)
- {
- webkit_context_menu_append (context_menu,
- webkit_context_menu_item_new_separator ());
- add_action_to_context_menu (context_menu,
- window->action_group, "FileSendTo");
- }
-
- webkit_context_menu_append (context_menu,
- webkit_context_menu_item_new_separator ());
- webkit_context_menu_append (context_menu,
- webkit_context_menu_item_new_from_stock_action
(WEBKIT_CONTEXT_MENU_ACTION_INSPECT_ELEMENT));
-
- return FALSE;
+populate_context_menu (WebKitWebView *web_view,
+ WebKitContextMenu *context_menu,
+ GdkEvent *event,
+ WebKitHitTestResult *hit_test_result,
+ EphyWindow *window)
+{
+ WebKitContextMenuItem *input_methods_item = NULL;
+ WebKitContextMenuItem *unicode_item = NULL;
+ WebKitContextMenuItem *play_pause_item = NULL;
+ WebKitContextMenuItem *mute_item = NULL;
+ WebKitContextMenuItem *toggle_controls_item = NULL;
+ WebKitContextMenuItem *toggle_loop_item = NULL;
+ WebKitContextMenuItem *fullscreen_item = NULL;
+ GList *spelling_guess_items = NULL;
+ EphyEmbedEvent *embed_event;
+ gboolean is_document = FALSE;
+ gboolean app_mode, incognito_mode;
+ gboolean is_image;
+ gboolean is_media = FALSE;
+ gboolean is_video = FALSE;
+ gboolean is_audio = FALSE;
+ gboolean can_search_selection = FALSE;
+ const char *selected_text = NULL;
+
+ is_image = webkit_hit_test_result_context_is_image (hit_test_result);
+
+ if (webkit_hit_test_result_context_is_editable (hit_test_result)) {
+ input_methods_item = find_item_in_context_menu (context_menu, WEBKIT_CONTEXT_MENU_ACTION_INPUT_METHODS);
+ unicode_item = find_item_in_context_menu (context_menu, WEBKIT_CONTEXT_MENU_ACTION_UNICODE);
+ spelling_guess_items = find_spelling_guess_context_menu_items (context_menu);
+ }
+
+ if (webkit_hit_test_result_context_is_media (hit_test_result)) {
+ WebKitContextMenuItem *item;
+
+ is_media = TRUE;
+ play_pause_item = find_item_in_context_menu (context_menu, WEBKIT_CONTEXT_MENU_ACTION_MEDIA_PLAY);
+ if (!play_pause_item)
+ play_pause_item = find_item_in_context_menu (context_menu, WEBKIT_CONTEXT_MENU_ACTION_MEDIA_PAUSE);
+ mute_item = find_item_in_context_menu (context_menu, WEBKIT_CONTEXT_MENU_ACTION_MEDIA_MUTE);
+ toggle_controls_item = find_item_in_context_menu (context_menu,
WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_CONTROLS);
+ toggle_loop_item = find_item_in_context_menu (context_menu,
WEBKIT_CONTEXT_MENU_ACTION_TOGGLE_MEDIA_LOOP);
+ fullscreen_item = find_item_in_context_menu (context_menu,
WEBKIT_CONTEXT_MENU_ACTION_ENTER_VIDEO_FULLSCREEN);
+
+ item = find_item_in_context_menu (context_menu, WEBKIT_CONTEXT_MENU_ACTION_COPY_VIDEO_LINK_TO_CLIPBOARD);
+ if (item) {
+ is_video = TRUE;
+ g_object_unref (item);
+ } else {
+ item = find_item_in_context_menu (context_menu,
WEBKIT_CONTEXT_MENU_ACTION_COPY_AUDIO_LINK_TO_CLIPBOARD);
+ if (item) {
+ is_audio = TRUE;
+ g_object_unref (item);
+ }
+ }
+ }
+
+ parse_context_menu_user_data (context_menu, &selected_text);
+ if (selected_text) {
+ char *ellipsized = ellipsize_string (selected_text, 32);
+ if (ellipsized) {
+ char *label;
+ GtkAction *action;
+
+ can_search_selection = TRUE;
+ action = gtk_action_group_get_action (window->popups_action_group,
+ "SearchSelection");
+ label = g_strdup_printf (_("Search the Web for '%s'"), ellipsized);
+ gtk_action_set_label (action, label);
+ g_object_set_data_full (G_OBJECT (action), "selection", g_strdup (selected_text),
+ (GDestroyNotify)g_free);
+ g_free (ellipsized);
+ g_free (label);
+ can_search_selection = TRUE;
+ }
+ }
+
+ webkit_context_menu_remove_all (context_menu);
+
+ embed_event = ephy_embed_event_new ((GdkEventButton *)event, hit_test_result);
+ _ephy_window_set_context_event (window, embed_event);
+ g_object_unref (embed_event);
+
+ app_mode = ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) ==
EPHY_EMBED_SHELL_MODE_APPLICATION;
+ incognito_mode = ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) ==
EPHY_EMBED_SHELL_MODE_INCOGNITO;
+
+ update_edit_actions_sensitivity (window, FALSE);
+
+ if (webkit_hit_test_result_context_is_link (hit_test_result)) {
+ const char *uri;
+ gboolean link_has_web_scheme;
+
+ uri = webkit_hit_test_result_get_link_uri (hit_test_result);
+ link_has_web_scheme = ephy_embed_utils_address_has_web_scheme (uri);
+
+ update_edit_actions_sensitivity (window, TRUE);
+ update_link_actions_sensitivity (window, link_has_web_scheme);
+
+ if (!app_mode) {
+ add_action_to_context_menu (context_menu,
+ window->popups_action_group, "OpenLinkInNewTab");
+ add_action_to_context_menu (context_menu,
+ window->popups_action_group, "OpenLinkInNewWindow");
+ if (!incognito_mode)
+ add_action_to_context_menu (context_menu,
+ window->popups_action_group, "OpenLinkInIncognitoWindow");
+ webkit_context_menu_append (context_menu,
+ webkit_context_menu_item_new_separator ());
+ }
+ add_action_to_context_menu (context_menu,
+ window->action_group, "EditCopy");
+ if (can_search_selection)
+ add_action_to_context_menu (context_menu,
+ window->popups_action_group, "SearchSelection");
+ webkit_context_menu_append (context_menu,
+ webkit_context_menu_item_new_separator ());
+ add_action_to_context_menu (context_menu,
+ window->popups_action_group, "DownloadLinkAs");
+
+ if (g_str_has_prefix (uri, "mailto:")) {
+ add_action_to_context_menu (context_menu,
+ window->popups_action_group, "CopyEmailAddress");
+ } else {
+ add_action_to_context_menu (context_menu,
+ window->popups_action_group, "CopyLinkAddress");
+ }
+ } else if (webkit_hit_test_result_context_is_editable (hit_test_result)) {
+ GList *l;
+ gboolean has_guesses = FALSE;
+
+ for (l = spelling_guess_items; l; l = g_list_next (l)) {
+ WebKitContextMenuItem *item = WEBKIT_CONTEXT_MENU_ITEM (l->data);
+
+ webkit_context_menu_append (context_menu, item);
+ g_object_unref (item);
+ has_guesses = TRUE;
+ }
+ g_list_free (spelling_guess_items);
+
+ if (has_guesses) {
+ webkit_context_menu_append (context_menu,
+ webkit_context_menu_item_new_separator ());
+ }
+
+ update_edit_actions_sensitivity (window, FALSE);
+
+ add_action_to_context_menu (context_menu,
+ window->action_group, "EditUndo");
+ add_action_to_context_menu (context_menu,
+ window->action_group, "EditRedo");
+ webkit_context_menu_append (context_menu,
+ webkit_context_menu_item_new_separator ());
+ add_action_to_context_menu (context_menu,
+ window->action_group, "EditCut");
+ add_action_to_context_menu (context_menu,
+ window->action_group, "EditCopy");
+ add_action_to_context_menu (context_menu,
+ window->action_group, "EditPaste");
+ webkit_context_menu_append (context_menu,
+ webkit_context_menu_item_new_separator ());
+ add_action_to_context_menu (context_menu,
+ window->action_group, "EditSelectAll");
+ if (input_methods_item || unicode_item)
+ webkit_context_menu_append (context_menu,
+ webkit_context_menu_item_new_separator ());
+ add_item_to_context_menu (context_menu, input_methods_item);
+ add_item_to_context_menu (context_menu, unicode_item);
+ } else {
+ is_document = TRUE;
+
+ update_edit_actions_sensitivity (window, TRUE);
+
+ if (!is_image && !is_media) {
+ add_action_to_context_menu (context_menu,
+ window->toolbar_action_group, "NavigationBack");
+ add_action_to_context_menu (context_menu,
+ window->toolbar_action_group, "NavigationForward");
+ add_action_to_context_menu (context_menu,
+ window->action_group, "ViewReload");
+ webkit_context_menu_append (context_menu,
+ webkit_context_menu_item_new_separator ());
+ }
+
+ add_action_to_context_menu (context_menu,
+ window->action_group, "EditCopy");
+ if (can_search_selection)
+ add_action_to_context_menu (context_menu,
+ window->popups_action_group, "SearchSelection");
+
+ if (!app_mode && !is_image && !is_media) {
+ webkit_context_menu_append (context_menu,
+ webkit_context_menu_item_new_separator ());
+ add_action_to_context_menu (context_menu,
+ window->popups_action_group, "ContextBookmarkPage");
+ }
+ }
+
+ if (is_image) {
+ webkit_context_menu_append (context_menu,
+ webkit_context_menu_item_new_separator ());
+ add_action_to_context_menu (context_menu,
+ window->popups_action_group, "SaveImageAs");
+ add_action_to_context_menu (context_menu,
+ window->popups_action_group, "CopyImageLocation");
+ add_action_to_context_menu (context_menu,
+ window->popups_action_group, "ViewImage");
+ add_action_to_context_menu (context_menu,
+ window->popups_action_group, "SetImageAsBackground");
+ }
+
+ if (is_media) {
+ add_item_to_context_menu (context_menu, play_pause_item);
+ add_item_to_context_menu (context_menu, mute_item);
+ add_item_to_context_menu (context_menu, toggle_controls_item);
+ add_item_to_context_menu (context_menu, toggle_loop_item);
+ add_item_to_context_menu (context_menu, fullscreen_item);
+ webkit_context_menu_append (context_menu,
+ webkit_context_menu_item_new_separator ());
+ if (is_video) {
+ add_action_to_context_menu (context_menu, window->popups_action_group,
+ "OpenVideoInNewWindow");
+ add_action_to_context_menu (context_menu, window->popups_action_group,
+ "OpenVideoInNewTab");
+ add_action_to_context_menu (context_menu, window->popups_action_group,
+ "SaveVideoAs");
+ add_action_to_context_menu (context_menu, window->popups_action_group,
+ "CopyVideoLocation");
+ } else if (is_audio) {
+ add_action_to_context_menu (context_menu, window->popups_action_group,
+ "OpenAudioInNewWindow");
+ add_action_to_context_menu (context_menu, window->popups_action_group,
+ "OpenAudioInNewTab");
+ add_action_to_context_menu (context_menu, window->popups_action_group,
+ "SaveAudioAs");
+ add_action_to_context_menu (context_menu, window->popups_action_group,
+ "CopyAudioLocation");
+ }
+ }
+
+ g_signal_connect (web_view, "context-menu-dismissed",
+ G_CALLBACK (context_menu_dismissed_cb),
+ window);
+
+ if (app_mode)
+ return FALSE;
+
+ if (is_document && !is_image && !is_media) {
+ webkit_context_menu_append (context_menu,
+ webkit_context_menu_item_new_separator ());
+ add_action_to_context_menu (context_menu,
+ window->action_group, "FileSendTo");
+ }
+
+ webkit_context_menu_append (context_menu,
+ webkit_context_menu_item_new_separator ());
+ webkit_context_menu_append (context_menu,
+ webkit_context_menu_item_new_from_stock_action
(WEBKIT_CONTEXT_MENU_ACTION_INSPECT_ELEMENT));
+
+ return FALSE;
}
static gboolean
-save_target_uri (EphyWindow *window,
- WebKitWebView *view,
- GdkEventButton *event,
- WebKitHitTestResult *hit_test_result)
-{
- guint context;
- char *location = NULL;
- gboolean retval = FALSE;
-
- g_object_get (hit_test_result, "context", &context, NULL);
-
- LOG ("ephy_window_dom_mouse_click_cb: button %d, context %d, modifier %d (%d:%d)",
- event->button, context, event->state, (int)event->x, (int)event->y);
-
- /* shift+click saves the link target */
- if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK)
- {
- g_object_get (G_OBJECT (hit_test_result), "link-uri", &location, NULL);
- }
- /* Note: pressing enter to submit a form synthesizes a mouse
- * click event
- */
- /* shift+click saves the non-link image */
- else if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE &&
- !(context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE))
- {
- g_object_get (G_OBJECT (hit_test_result), "image-uri", &location, NULL);
- }
-
- if (location)
- {
- LOG ("Location: %s", location);
-
- retval = ephy_embed_utils_address_has_web_scheme (location);
- if (retval)
- {
- EphyDownload *download;
-
- download = ephy_download_new_for_uri (location);
- ephy_download_set_action (download, EPHY_DOWNLOAD_ACTION_OPEN);
- ephy_downloads_manager_add_download (ephy_embed_shell_get_downloads_manager
(EPHY_EMBED_SHELL (ephy_shell_get_default ())),
- download);
- g_object_unref (download);
- }
-
- g_free (location);
- }
-
- return retval;
+save_target_uri (EphyWindow *window,
+ WebKitWebView *view,
+ GdkEventButton *event,
+ WebKitHitTestResult *hit_test_result)
+{
+ guint context;
+ char *location = NULL;
+ gboolean retval = FALSE;
+
+ g_object_get (hit_test_result, "context", &context, NULL);
+
+ LOG ("ephy_window_dom_mouse_click_cb: button %d, context %d, modifier %d (%d:%d)",
+ event->button, context, event->state, (int)event->x, (int)event->y);
+
+ /* shift+click saves the link target */
+ if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK) {
+ g_object_get (G_OBJECT (hit_test_result), "link-uri", &location, NULL);
+ }
+ /* Note: pressing enter to submit a form synthesizes a mouse
+ * click event
+ */
+ /* shift+click saves the non-link image */
+ else if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE &&
+ !(context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE)) {
+ g_object_get (G_OBJECT (hit_test_result), "image-uri", &location, NULL);
+ }
+
+ if (location) {
+ LOG ("Location: %s", location);
+
+ retval = ephy_embed_utils_address_has_web_scheme (location);
+ if (retval) {
+ EphyDownload *download;
+
+ download = ephy_download_new_for_uri (location);
+ ephy_download_set_action (download, EPHY_DOWNLOAD_ACTION_OPEN);
+ ephy_downloads_manager_add_download (ephy_embed_shell_get_downloads_manager (EPHY_EMBED_SHELL
(ephy_shell_get_default ())),
+ download);
+ g_object_unref (download);
+ }
+
+ g_free (location);
+ }
+
+ return retval;
}
static gboolean
-ephy_window_dom_mouse_click_cb (WebKitWebView *view,
- GdkEventButton *event,
- EphyWindow *window)
+ephy_window_dom_mouse_click_cb (WebKitWebView *view,
+ GdkEventButton *event,
+ EphyWindow *window)
{
- WebKitHitTestResult *hit_test_result;
- gboolean handled = FALSE;
+ WebKitHitTestResult *hit_test_result;
+ gboolean handled = FALSE;
- /* Since we're only dealing with shift+click, we can do these
- checks early. */
- if (!(event->state & GDK_SHIFT_MASK) || event->button != GDK_BUTTON_PRIMARY)
- {
- return FALSE;
- }
+ /* Since we're only dealing with shift+click, we can do these
+ checks early. */
+ if (!(event->state & GDK_SHIFT_MASK) || event->button != GDK_BUTTON_PRIMARY) {
+ return FALSE;
+ }
- hit_test_result = g_object_ref (window->hit_test_result);
- handled = save_target_uri (window, view, event, hit_test_result);
- g_object_unref (hit_test_result);
+ hit_test_result = g_object_ref (window->hit_test_result);
+ handled = save_target_uri (window, view, event, hit_test_result);
+ g_object_unref (hit_test_result);
- return handled;
+ return handled;
}
static void
-ephy_window_mouse_target_changed_cb (WebKitWebView *web_view,
- WebKitHitTestResult *hit_test_result,
- guint modifiers,
- EphyWindow *window)
+ephy_window_mouse_target_changed_cb (WebKitWebView *web_view,
+ WebKitHitTestResult *hit_test_result,
+ guint modifiers,
+ EphyWindow *window)
{
- if (window->hit_test_result)
- g_object_unref (window->hit_test_result);
- window->hit_test_result = g_object_ref (hit_test_result);
+ if (window->hit_test_result)
+ g_object_unref (window->hit_test_result);
+ window->hit_test_result = g_object_ref (hit_test_result);
}
static void
ephy_window_set_is_popup (EphyWindow *window,
- gboolean is_popup)
+ gboolean is_popup)
{
- window->is_popup = is_popup;
+ window->is_popup = is_popup;
- g_object_notify (G_OBJECT (window), "is-popup");
+ g_object_notify (G_OBJECT (window), "is-popup");
}
static void
window_properties_geometry_changed (WebKitWindowProperties *properties,
- GParamSpec *pspec,
- EphyWindow *window)
+ GParamSpec *pspec,
+ EphyWindow *window)
{
- GdkRectangle geometry;
+ GdkRectangle geometry;
- webkit_window_properties_get_geometry (properties, &geometry);
- if (geometry.x >= 0 && geometry.y >= 0)
- gtk_window_move (GTK_WINDOW (window), geometry.x, geometry.y);
- if (geometry.width > 0 && geometry.height > 0)
- gtk_window_resize (GTK_WINDOW (window), geometry.width, geometry.height);
+ webkit_window_properties_get_geometry (properties, &geometry);
+ if (geometry.x >= 0 && geometry.y >= 0)
+ gtk_window_move (GTK_WINDOW (window), geometry.x, geometry.y);
+ if (geometry.width > 0 && geometry.height > 0)
+ gtk_window_resize (GTK_WINDOW (window), geometry.width, geometry.height);
}
static void
-ephy_window_configure_for_view (EphyWindow *window,
- WebKitWebView *web_view)
+ephy_window_configure_for_view (EphyWindow *window,
+ WebKitWebView *web_view)
{
- WebKitWindowProperties *properties;
- GdkRectangle geometry;
- EphyWindowChrome chrome = 0;
+ WebKitWindowProperties *properties;
+ GdkRectangle geometry;
+ EphyWindowChrome chrome = 0;
- properties = webkit_web_view_get_window_properties (web_view);
+ properties = webkit_web_view_get_window_properties (web_view);
- if (webkit_window_properties_get_toolbar_visible (properties))
- chrome |= EPHY_WINDOW_CHROME_TOOLBAR;
+ if (webkit_window_properties_get_toolbar_visible (properties))
+ chrome |= EPHY_WINDOW_CHROME_TOOLBAR;
- if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) != EPHY_EMBED_SHELL_MODE_APPLICATION)
- {
- GtkWidget *entry;
+ if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) != EPHY_EMBED_SHELL_MODE_APPLICATION) {
+ GtkWidget *entry;
- entry = ephy_toolbar_get_location_entry (EPHY_TOOLBAR (window->toolbar));
- gtk_editable_set_editable (GTK_EDITABLE (entry), FALSE);
+ entry = ephy_toolbar_get_location_entry (EPHY_TOOLBAR (window->toolbar));
+ gtk_editable_set_editable (GTK_EDITABLE (entry), FALSE);
- if (webkit_window_properties_get_menubar_visible (properties))
- chrome |= EPHY_WINDOW_CHROME_MENU;
- if (webkit_window_properties_get_locationbar_visible (properties))
- chrome |= EPHY_WINDOW_CHROME_LOCATION;
- }
+ if (webkit_window_properties_get_menubar_visible (properties))
+ chrome |= EPHY_WINDOW_CHROME_MENU;
+ if (webkit_window_properties_get_locationbar_visible (properties))
+ chrome |= EPHY_WINDOW_CHROME_LOCATION;
+ }
- webkit_window_properties_get_geometry (properties, &geometry);
- if (geometry.width > 0 && geometry.height > 0)
- gtk_window_set_default_size (GTK_WINDOW (window), geometry.width, geometry.height);
+ webkit_window_properties_get_geometry (properties, &geometry);
+ if (geometry.width > 0 && geometry.height > 0)
+ gtk_window_set_default_size (GTK_WINDOW (window), geometry.width, geometry.height);
- if (!webkit_window_properties_get_resizable (properties))
- gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
+ if (!webkit_window_properties_get_resizable (properties))
+ gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
- window->is_popup = TRUE;
- ephy_window_set_chrome (window, chrome);
- g_signal_connect (properties, "notify::geometry",
- G_CALLBACK (window_properties_geometry_changed),
- window);
+ window->is_popup = TRUE;
+ ephy_window_set_chrome (window, chrome);
+ g_signal_connect (properties, "notify::geometry",
+ G_CALLBACK (window_properties_geometry_changed),
+ window);
}
static gboolean
web_view_ready_cb (WebKitWebView *web_view,
- WebKitWebView *parent_web_view)
+ WebKitWebView *parent_web_view)
{
- EphyWindow *window, *parent_view_window;
- gboolean using_new_window;
+ EphyWindow *window, *parent_view_window;
+ gboolean using_new_window;
- window = EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (web_view)));
- parent_view_window = EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (parent_web_view)));
+ window = EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (web_view)));
+ parent_view_window = EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (parent_web_view)));
- using_new_window = window != parent_view_window;
+ using_new_window = window != parent_view_window;
- if (using_new_window)
- {
- ephy_window_configure_for_view (window, web_view);
- g_signal_emit_by_name (parent_web_view, "new-window", web_view);
- }
+ if (using_new_window) {
+ ephy_window_configure_for_view (window, web_view);
+ g_signal_emit_by_name (parent_web_view, "new-window", web_view);
+ }
- if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) == EPHY_EMBED_SHELL_MODE_APPLICATION
&&
- !webkit_web_view_get_uri(web_view))
- {
- /* Wait until we have a valid URL to decide whether to show the window
- * or load the URL in the default web browser
- */
- g_object_set_data_full (G_OBJECT (window), "referrer",
- g_strdup (webkit_web_view_get_uri (parent_web_view)),
- g_free);
- return TRUE;
- }
+ if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) == EPHY_EMBED_SHELL_MODE_APPLICATION &&
+ !webkit_web_view_get_uri (web_view)) {
+ /* Wait until we have a valid URL to decide whether to show the window
+ * or load the URL in the default web browser
+ */
+ g_object_set_data_full (G_OBJECT (window), "referrer",
+ g_strdup (webkit_web_view_get_uri (parent_web_view)),
+ g_free);
+ return TRUE;
+ }
- gtk_widget_show (GTK_WIDGET (window));
+ gtk_widget_show (GTK_WIDGET (window));
- return TRUE;
+ return TRUE;
}
static WebKitWebView *
-create_web_view_cb (WebKitWebView *web_view,
- WebKitNavigationAction *navigation_action,
- EphyWindow *window)
-{
- EphyEmbed *embed;
- WebKitWebView *new_web_view;
- EphyNewTabFlags flags;
- EphyWindow *target_window;
-
- if ((ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) !=
EPHY_EMBED_SHELL_MODE_APPLICATION) &&
- (g_settings_get_boolean (EPHY_SETTINGS_MAIN,
- EPHY_PREFS_NEW_WINDOWS_IN_TABS) ||
- g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
- EPHY_PREFS_LOCKDOWN_FULLSCREEN)))
- {
- target_window = window;
- flags = EPHY_NEW_TAB_JUMP |
- EPHY_NEW_TAB_APPEND_AFTER;
- }
- else
- {
- target_window = ephy_window_new ();
- flags = EPHY_NEW_TAB_DONT_SHOW_WINDOW;
- }
-
- embed = ephy_shell_new_tab_full (ephy_shell_get_default (),
- NULL,
- web_view,
- target_window,
- EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view),
- flags,
- 0);
- if (target_window == window)
- gtk_widget_grab_focus (GTK_WIDGET (embed));
-
- new_web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
- g_signal_connect (new_web_view, "ready-to-show",
- G_CALLBACK (web_view_ready_cb),
- web_view);
-
- return new_web_view;
+create_web_view_cb (WebKitWebView *web_view,
+ WebKitNavigationAction *navigation_action,
+ EphyWindow *window)
+{
+ EphyEmbed *embed;
+ WebKitWebView *new_web_view;
+ EphyNewTabFlags flags;
+ EphyWindow *target_window;
+
+ if ((ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) != EPHY_EMBED_SHELL_MODE_APPLICATION) &&
+ (g_settings_get_boolean (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_NEW_WINDOWS_IN_TABS) ||
+ g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_FULLSCREEN))) {
+ target_window = window;
+ flags = EPHY_NEW_TAB_JUMP |
+ EPHY_NEW_TAB_APPEND_AFTER;
+ } else {
+ target_window = ephy_window_new ();
+ flags = EPHY_NEW_TAB_DONT_SHOW_WINDOW;
+ }
+
+ embed = ephy_shell_new_tab_full (ephy_shell_get_default (),
+ NULL,
+ web_view,
+ target_window,
+ EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view),
+ flags,
+ 0);
+ if (target_window == window)
+ gtk_widget_grab_focus (GTK_WIDGET (embed));
+
+ new_web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
+ g_signal_connect (new_web_view, "ready-to-show",
+ G_CALLBACK (web_view_ready_cb),
+ web_view);
+
+ return new_web_view;
}
static gboolean
-decide_policy_cb (WebKitWebView *web_view,
- WebKitPolicyDecision *decision,
- WebKitPolicyDecisionType decision_type,
- EphyWindow *window)
-{
- WebKitNavigationPolicyDecision *navigation_decision;
- WebKitNavigationAction *navigation_action;
- WebKitNavigationType navigation_type;
- WebKitURIRequest *request;
- const char *uri;
- EphyEmbed *embed;
-
- if (decision_type == WEBKIT_POLICY_DECISION_TYPE_RESPONSE)
- return FALSE;
-
- navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision);
- navigation_action = webkit_navigation_policy_decision_get_navigation_action (navigation_decision);
- request = webkit_navigation_action_get_request (navigation_action);
- uri = webkit_uri_request_get_uri (request);
-
- if (!ephy_embed_utils_address_has_web_scheme (uri))
- {
- GError *error = NULL;
- GdkScreen *screen;
-
- screen = gtk_widget_get_screen (GTK_WIDGET (web_view));
- gtk_show_uri (screen, uri, GDK_CURRENT_TIME, &error);
-
- if (error)
- {
- LOG ("failed to handle non web scheme: %s", error->message);
- g_error_free (error);
-
- return FALSE;
- }
-
- webkit_policy_decision_ignore (decision);
-
- return TRUE;
- }
-
- if (decision_type == WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION)
- {
- const char *frame_name = webkit_navigation_policy_decision_get_frame_name
(navigation_decision);
-
- if (g_strcmp0 (frame_name, "_evince_download") == 0)
- {
- /* The Evince Browser Plugin is requesting us to downlod the document */
- webkit_policy_decision_download (decision);
- return TRUE;
- }
-
- if (!g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_ENABLE_POPUPS) &&
- !webkit_navigation_action_is_user_gesture (navigation_action))
- {
- webkit_policy_decision_ignore (decision);
- return TRUE;
- }
- }
-
- navigation_type = webkit_navigation_action_get_navigation_type (navigation_action);
-
- if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) == EPHY_EMBED_SHELL_MODE_APPLICATION)
- {
- if (!gtk_widget_is_visible (GTK_WIDGET (window)))
- {
- char *referrer;
-
- referrer = (char *)g_object_get_data (G_OBJECT (window), "referrer");
-
- if (ephy_embed_utils_urls_have_same_origin (uri, referrer))
- {
- gtk_widget_show (GTK_WIDGET (window));
- }
- else
- {
- ephy_file_open_uri_in_default_browser (uri, GDK_CURRENT_TIME,
- gtk_window_get_screen (GTK_WINDOW
(window)));
- webkit_policy_decision_ignore (decision);
-
- gtk_widget_destroy (GTK_WIDGET (window));
-
- return TRUE;
- }
- }
-
- if (navigation_type == WEBKIT_NAVIGATION_TYPE_LINK_CLICKED)
- {
- if (ephy_embed_utils_urls_have_same_origin (uri, webkit_web_view_get_uri (web_view)))
- {
- return FALSE;
- }
-
- ephy_file_open_uri_in_default_browser (uri, GDK_CURRENT_TIME,
- gtk_window_get_screen (GTK_WINDOW (window)));
- webkit_policy_decision_ignore (decision);
-
- return TRUE;
- }
- }
-
- if (navigation_type == WEBKIT_NAVIGATION_TYPE_LINK_CLICKED)
- {
- gint button;
- gint state;
- EphyEmbed *new_embed;
- EphyWebView *new_view;
- EphyNewTabFlags flags = 0;
- EphyWindow *target_window = window;
- gboolean inherit_session = FALSE;
-
- button = webkit_navigation_action_get_mouse_button (navigation_action);
- state = webkit_navigation_action_get_modifiers (navigation_action);
-
- ephy_web_view_set_visit_type (EPHY_WEB_VIEW (web_view),
- EPHY_PAGE_VISIT_LINK);
-
- /* New tab in new window for control+shift+click */
- if (button == 1 && state == (GDK_SHIFT_MASK | GDK_CONTROL_MASK) &&
- !g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
- EPHY_PREFS_LOCKDOWN_FULLSCREEN))
- {
- target_window = ephy_window_new ();
- }
- /* New tab in existing window for middle click and
- * control+click */
- else if (button == 2 || (button == 1 && state == GDK_CONTROL_MASK))
- {
- flags |= EPHY_NEW_TAB_APPEND_AFTER;
- inherit_session = TRUE;
- }
- /* Because we connect to button-press-event *after*
- * (G_CONNECT_AFTER) we need to prevent WebKit from browsing to
- * a link when you shift+click it. Otherwise when you
- * shift+click a link to download it you would also be taken to
- * the link destination. */
- else if (button == 1 && state == GDK_SHIFT_MASK)
- {
- webkit_policy_decision_ignore (decision);
-
- return TRUE;
- }
- /* Those were our special cases, we won't handle this */
- else
- {
- return FALSE;
- }
-
- embed = ephy_embed_container_get_active_child
- (EPHY_EMBED_CONTAINER (window));
-
- new_embed = ephy_shell_new_tab_full (ephy_shell_get_default (),
- NULL, NULL,
- target_window,
- embed,
- flags,
- 0);
-
- new_view = ephy_embed_get_web_view (new_embed);
- if (inherit_session)
- {
- WebKitWebViewSessionState *session_state;
-
- session_state = webkit_web_view_get_session_state (web_view);
- webkit_web_view_restore_session_state (WEBKIT_WEB_VIEW (new_view), session_state);
- webkit_web_view_session_state_unref (session_state);
- }
- ephy_web_view_load_request (new_view, request);
-
- webkit_policy_decision_ignore (decision);
-
- return TRUE;
- }
-
- return FALSE;
+decide_policy_cb (WebKitWebView *web_view,
+ WebKitPolicyDecision *decision,
+ WebKitPolicyDecisionType decision_type,
+ EphyWindow *window)
+{
+ WebKitNavigationPolicyDecision *navigation_decision;
+ WebKitNavigationAction *navigation_action;
+ WebKitNavigationType navigation_type;
+ WebKitURIRequest *request;
+ const char *uri;
+ EphyEmbed *embed;
+
+ if (decision_type == WEBKIT_POLICY_DECISION_TYPE_RESPONSE)
+ return FALSE;
+
+ navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision);
+ navigation_action = webkit_navigation_policy_decision_get_navigation_action (navigation_decision);
+ request = webkit_navigation_action_get_request (navigation_action);
+ uri = webkit_uri_request_get_uri (request);
+
+ if (!ephy_embed_utils_address_has_web_scheme (uri)) {
+ GError *error = NULL;
+ GdkScreen *screen;
+
+ screen = gtk_widget_get_screen (GTK_WIDGET (web_view));
+ gtk_show_uri (screen, uri, GDK_CURRENT_TIME, &error);
+
+ if (error) {
+ LOG ("failed to handle non web scheme: %s", error->message);
+ g_error_free (error);
+
+ return FALSE;
+ }
+
+ webkit_policy_decision_ignore (decision);
+
+ return TRUE;
+ }
+
+ if (decision_type == WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION) {
+ const char *frame_name = webkit_navigation_policy_decision_get_frame_name (navigation_decision);
+
+ if (g_strcmp0 (frame_name, "_evince_download") == 0) {
+ /* The Evince Browser Plugin is requesting us to downlod the document */
+ webkit_policy_decision_download (decision);
+ return TRUE;
+ }
+
+ if (!g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_ENABLE_POPUPS) &&
+ !webkit_navigation_action_is_user_gesture (navigation_action)) {
+ webkit_policy_decision_ignore (decision);
+ return TRUE;
+ }
+ }
+
+ navigation_type = webkit_navigation_action_get_navigation_type (navigation_action);
+
+ if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) == EPHY_EMBED_SHELL_MODE_APPLICATION) {
+ if (!gtk_widget_is_visible (GTK_WIDGET (window))) {
+ char *referrer;
+
+ referrer = (char *)g_object_get_data (G_OBJECT (window), "referrer");
+
+ if (ephy_embed_utils_urls_have_same_origin (uri, referrer)) {
+ gtk_widget_show (GTK_WIDGET (window));
+ } else {
+ ephy_file_open_uri_in_default_browser (uri, GDK_CURRENT_TIME,
+ gtk_window_get_screen (GTK_WINDOW (window)));
+ webkit_policy_decision_ignore (decision);
+
+ gtk_widget_destroy (GTK_WIDGET (window));
+
+ return TRUE;
+ }
+ }
+
+ if (navigation_type == WEBKIT_NAVIGATION_TYPE_LINK_CLICKED) {
+ if (ephy_embed_utils_urls_have_same_origin (uri, webkit_web_view_get_uri (web_view))) {
+ return FALSE;
+ }
+
+ ephy_file_open_uri_in_default_browser (uri, GDK_CURRENT_TIME,
+ gtk_window_get_screen (GTK_WINDOW (window)));
+ webkit_policy_decision_ignore (decision);
+
+ return TRUE;
+ }
+ }
+
+ if (navigation_type == WEBKIT_NAVIGATION_TYPE_LINK_CLICKED) {
+ gint button;
+ gint state;
+ EphyEmbed *new_embed;
+ EphyWebView *new_view;
+ EphyNewTabFlags flags = 0;
+ EphyWindow *target_window = window;
+ gboolean inherit_session = FALSE;
+
+ button = webkit_navigation_action_get_mouse_button (navigation_action);
+ state = webkit_navigation_action_get_modifiers (navigation_action);
+
+ ephy_web_view_set_visit_type (EPHY_WEB_VIEW (web_view),
+ EPHY_PAGE_VISIT_LINK);
+
+ /* New tab in new window for control+shift+click */
+ if (button == 1 && state == (GDK_SHIFT_MASK | GDK_CONTROL_MASK) &&
+ !g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_FULLSCREEN)) {
+ target_window = ephy_window_new ();
+ }
+ /* New tab in existing window for middle click and
+ * control+click */
+ else if (button == 2 || (button == 1 && state == GDK_CONTROL_MASK)) {
+ flags |= EPHY_NEW_TAB_APPEND_AFTER;
+ inherit_session = TRUE;
+ }
+ /* Because we connect to button-press-event *after*
+ * (G_CONNECT_AFTER) we need to prevent WebKit from browsing to
+ * a link when you shift+click it. Otherwise when you
+ * shift+click a link to download it you would also be taken to
+ * the link destination. */
+ else if (button == 1 && state == GDK_SHIFT_MASK) {
+ webkit_policy_decision_ignore (decision);
+
+ return TRUE;
+ }
+ /* Those were our special cases, we won't handle this */
+ else {
+ return FALSE;
+ }
+
+ embed = ephy_embed_container_get_active_child
+ (EPHY_EMBED_CONTAINER (window));
+
+ new_embed = ephy_shell_new_tab_full (ephy_shell_get_default (),
+ NULL, NULL,
+ target_window,
+ embed,
+ flags,
+ 0);
+
+ new_view = ephy_embed_get_web_view (new_embed);
+ if (inherit_session) {
+ WebKitWebViewSessionState *session_state;
+
+ session_state = webkit_web_view_get_session_state (web_view);
+ webkit_web_view_restore_session_state (WEBKIT_WEB_VIEW (new_view), session_state);
+ webkit_web_view_session_state_unref (session_state);
+ }
+ ephy_web_view_load_request (new_view, request);
+
+ webkit_policy_decision_ignore (decision);
+
+ return TRUE;
+ }
+
+ return FALSE;
}
static void
ephy_window_connect_active_embed (EphyWindow *window)
{
- EphyEmbed *embed;
- WebKitWebView *web_view;
- EphyWebView *view;
-
- g_return_if_fail (window->active_embed != NULL);
-
- embed = window->active_embed;
- view = ephy_embed_get_web_view (embed);
- web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
-
- sync_tab_security (view, NULL, window);
- sync_tab_document_type (view, NULL, window);
- sync_tab_load_status (view, WEBKIT_LOAD_STARTED, window);
- sync_tab_is_blank (view, NULL, window);
- sync_tab_navigation (view, NULL, window);
- sync_tab_title (embed, NULL, window);
- sync_tab_address (view, NULL, window);
- sync_tab_icon (view, NULL, window);
- sync_tab_popup_windows (view, NULL, window);
- sync_tab_popups_allowed (view, NULL, window);
-
- sync_tab_zoom (web_view, NULL, window);
-
- g_signal_connect_object (web_view, "notify::zoom-level",
- G_CALLBACK (sync_tab_zoom),
- window, 0);
-
- g_signal_connect_object (web_view, "create",
- G_CALLBACK (create_web_view_cb),
- window, 0);
- g_signal_connect_object (web_view, "decide-policy",
- G_CALLBACK (decide_policy_cb),
- window, 0);
- g_signal_connect_object (view, "notify::hidden-popup-count",
- G_CALLBACK (sync_tab_popup_windows),
- window, 0);
- g_signal_connect_object (view, "notify::popups-allowed",
- G_CALLBACK (sync_tab_popups_allowed),
- window, 0);
- g_signal_connect_object (embed, "notify::title",
- G_CALLBACK (sync_tab_title),
- window, 0);
- g_signal_connect_object (view, "notify::address",
- G_CALLBACK (sync_tab_address),
- window, 0);
- g_signal_connect_object (view, "notify::icon",
- G_CALLBACK (sync_tab_icon),
- window, 0);
- g_signal_connect_object (view, "notify::security-level",
- G_CALLBACK (sync_tab_security),
- window, 0);
- g_signal_connect_object (view, "notify::document-type",
- G_CALLBACK (sync_tab_document_type),
- window, 0);
- g_signal_connect_object (view, "load-changed",
- G_CALLBACK (sync_tab_load_status),
- window, 0);
- g_signal_connect_object (view, "notify::navigation",
- G_CALLBACK (sync_tab_navigation),
- window, 0);
- g_signal_connect_object (view, "notify::is-blank",
- G_CALLBACK (sync_tab_is_blank),
- window, 0);
- g_signal_connect_object (view, "button-press-event",
- G_CALLBACK (ephy_window_dom_mouse_click_cb),
- window, 0);
- g_signal_connect_object (view, "context-menu",
- G_CALLBACK (populate_context_menu),
- window, 0);
- g_signal_connect_object (view, "mouse-target-changed",
- G_CALLBACK (ephy_window_mouse_target_changed_cb),
- window, 0);
-
- g_object_notify (G_OBJECT (window), "active-child");
+ EphyEmbed *embed;
+ WebKitWebView *web_view;
+ EphyWebView *view;
+
+ g_return_if_fail (window->active_embed != NULL);
+
+ embed = window->active_embed;
+ view = ephy_embed_get_web_view (embed);
+ web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
+
+ sync_tab_security (view, NULL, window);
+ sync_tab_document_type (view, NULL, window);
+ sync_tab_load_status (view, WEBKIT_LOAD_STARTED, window);
+ sync_tab_is_blank (view, NULL, window);
+ sync_tab_navigation (view, NULL, window);
+ sync_tab_title (embed, NULL, window);
+ sync_tab_address (view, NULL, window);
+ sync_tab_icon (view, NULL, window);
+ sync_tab_popup_windows (view, NULL, window);
+ sync_tab_popups_allowed (view, NULL, window);
+
+ sync_tab_zoom (web_view, NULL, window);
+
+ g_signal_connect_object (web_view, "notify::zoom-level",
+ G_CALLBACK (sync_tab_zoom),
+ window, 0);
+
+ g_signal_connect_object (web_view, "create",
+ G_CALLBACK (create_web_view_cb),
+ window, 0);
+ g_signal_connect_object (web_view, "decide-policy",
+ G_CALLBACK (decide_policy_cb),
+ window, 0);
+ g_signal_connect_object (view, "notify::hidden-popup-count",
+ G_CALLBACK (sync_tab_popup_windows),
+ window, 0);
+ g_signal_connect_object (view, "notify::popups-allowed",
+ G_CALLBACK (sync_tab_popups_allowed),
+ window, 0);
+ g_signal_connect_object (embed, "notify::title",
+ G_CALLBACK (sync_tab_title),
+ window, 0);
+ g_signal_connect_object (view, "notify::address",
+ G_CALLBACK (sync_tab_address),
+ window, 0);
+ g_signal_connect_object (view, "notify::icon",
+ G_CALLBACK (sync_tab_icon),
+ window, 0);
+ g_signal_connect_object (view, "notify::security-level",
+ G_CALLBACK (sync_tab_security),
+ window, 0);
+ g_signal_connect_object (view, "notify::document-type",
+ G_CALLBACK (sync_tab_document_type),
+ window, 0);
+ g_signal_connect_object (view, "load-changed",
+ G_CALLBACK (sync_tab_load_status),
+ window, 0);
+ g_signal_connect_object (view, "notify::navigation",
+ G_CALLBACK (sync_tab_navigation),
+ window, 0);
+ g_signal_connect_object (view, "notify::is-blank",
+ G_CALLBACK (sync_tab_is_blank),
+ window, 0);
+ g_signal_connect_object (view, "button-press-event",
+ G_CALLBACK (ephy_window_dom_mouse_click_cb),
+ window, 0);
+ g_signal_connect_object (view, "context-menu",
+ G_CALLBACK (populate_context_menu),
+ window, 0);
+ g_signal_connect_object (view, "mouse-target-changed",
+ G_CALLBACK (ephy_window_mouse_target_changed_cb),
+ window, 0);
+
+ g_object_notify (G_OBJECT (window), "active-child");
}
static void
ephy_window_disconnect_active_embed (EphyWindow *window)
{
- EphyEmbed *embed;
- WebKitWebView *web_view;
- EphyWebView *view;
-
- g_return_if_fail (window->active_embed != NULL);
-
- embed = window->active_embed;
- web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
- view = EPHY_WEB_VIEW (web_view);
-
- g_signal_handlers_disconnect_by_func (web_view,
- G_CALLBACK (sync_tab_zoom),
- window);
- g_signal_handlers_disconnect_by_func (web_view,
- G_CALLBACK (create_web_view_cb),
- window);
- g_signal_handlers_disconnect_by_func (view,
- G_CALLBACK (decide_policy_cb),
- window);
- g_signal_handlers_disconnect_by_func (view,
- G_CALLBACK (sync_tab_popup_windows),
- window);
- g_signal_handlers_disconnect_by_func (view,
- G_CALLBACK (sync_tab_popups_allowed),
- window);
- g_signal_handlers_disconnect_by_func (view,
- G_CALLBACK (sync_tab_security),
- window);
- g_signal_handlers_disconnect_by_func (view,
- G_CALLBACK (sync_tab_document_type),
- window);
- g_signal_handlers_disconnect_by_func (view,
- G_CALLBACK (sync_tab_load_status),
- window);
- g_signal_handlers_disconnect_by_func (view,
- G_CALLBACK (sync_tab_is_blank),
- window);
- g_signal_handlers_disconnect_by_func (view,
- G_CALLBACK (sync_tab_navigation),
- window);
- g_signal_handlers_disconnect_by_func (embed,
- G_CALLBACK (sync_tab_title),
- window);
- g_signal_handlers_disconnect_by_func (view,
- G_CALLBACK (sync_tab_address),
- window);
- g_signal_handlers_disconnect_by_func (view,
- G_CALLBACK (sync_tab_icon),
- window);
-
- g_signal_handlers_disconnect_by_func
- (view, G_CALLBACK (ephy_window_dom_mouse_click_cb), window);
- g_signal_handlers_disconnect_by_func (view,
- G_CALLBACK (populate_context_menu),
- window);
- g_signal_handlers_disconnect_by_func (view,
- G_CALLBACK (ephy_window_mouse_target_changed_cb),
- window);
+ EphyEmbed *embed;
+ WebKitWebView *web_view;
+ EphyWebView *view;
+
+ g_return_if_fail (window->active_embed != NULL);
+
+ embed = window->active_embed;
+ web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
+ view = EPHY_WEB_VIEW (web_view);
+
+ g_signal_handlers_disconnect_by_func (web_view,
+ G_CALLBACK (sync_tab_zoom),
+ window);
+ g_signal_handlers_disconnect_by_func (web_view,
+ G_CALLBACK (create_web_view_cb),
+ window);
+ g_signal_handlers_disconnect_by_func (view,
+ G_CALLBACK (decide_policy_cb),
+ window);
+ g_signal_handlers_disconnect_by_func (view,
+ G_CALLBACK (sync_tab_popup_windows),
+ window);
+ g_signal_handlers_disconnect_by_func (view,
+ G_CALLBACK (sync_tab_popups_allowed),
+ window);
+ g_signal_handlers_disconnect_by_func (view,
+ G_CALLBACK (sync_tab_security),
+ window);
+ g_signal_handlers_disconnect_by_func (view,
+ G_CALLBACK (sync_tab_document_type),
+ window);
+ g_signal_handlers_disconnect_by_func (view,
+ G_CALLBACK (sync_tab_load_status),
+ window);
+ g_signal_handlers_disconnect_by_func (view,
+ G_CALLBACK (sync_tab_is_blank),
+ window);
+ g_signal_handlers_disconnect_by_func (view,
+ G_CALLBACK (sync_tab_navigation),
+ window);
+ g_signal_handlers_disconnect_by_func (embed,
+ G_CALLBACK (sync_tab_title),
+ window);
+ g_signal_handlers_disconnect_by_func (view,
+ G_CALLBACK (sync_tab_address),
+ window);
+ g_signal_handlers_disconnect_by_func (view,
+ G_CALLBACK (sync_tab_icon),
+ window);
+
+ g_signal_handlers_disconnect_by_func
+ (view, G_CALLBACK (ephy_window_dom_mouse_click_cb), window);
+ g_signal_handlers_disconnect_by_func (view,
+ G_CALLBACK (populate_context_menu),
+ window);
+ g_signal_handlers_disconnect_by_func (view,
+ G_CALLBACK (ephy_window_mouse_target_changed_cb),
+ window);
}
static void
ephy_window_set_active_tab (EphyWindow *window, EphyEmbed *new_embed)
{
- EphyEmbed *old_embed;
+ EphyEmbed *old_embed;
- g_return_if_fail (EPHY_IS_WINDOW (window));
- g_return_if_fail (gtk_widget_get_toplevel (GTK_WIDGET (new_embed)) == GTK_WIDGET (window));
+ g_return_if_fail (EPHY_IS_WINDOW (window));
+ g_return_if_fail (gtk_widget_get_toplevel (GTK_WIDGET (new_embed)) == GTK_WIDGET (window));
- old_embed = window->active_embed;
+ old_embed = window->active_embed;
- if (old_embed == new_embed) return;
+ if (old_embed == new_embed) return;
- if (old_embed != NULL)
- ephy_window_disconnect_active_embed (window);
+ if (old_embed != NULL)
+ ephy_window_disconnect_active_embed (window);
- window->active_embed = new_embed;
+ window->active_embed = new_embed;
- if (new_embed != NULL)
- ephy_window_connect_active_embed (window);
+ if (new_embed != NULL)
+ ephy_window_connect_active_embed (window);
}
static void
-tab_accels_item_activate (GtkAction *action,
- EphyWindow *window)
+tab_accels_item_activate (GtkAction *action,
+ EphyWindow *window)
{
- const char *name;
- int tab_number;
+ const char *name;
+ int tab_number;
- name = gtk_action_get_name (action);
- tab_number = atoi (name + strlen ("TabAccel"));
+ name = gtk_action_get_name (action);
+ tab_number = atoi (name + strlen ("TabAccel"));
- gtk_notebook_set_current_page (window->notebook, tab_number);
+ gtk_notebook_set_current_page (window->notebook, tab_number);
}
static void
tab_accels_update (EphyWindow *window)
{
- int pages, i = 0;
- GList *actions, *l;
+ int pages, i = 0;
+ GList *actions, *l;
- actions = gtk_action_group_list_actions (window->tab_accels_action_group);
- pages = gtk_notebook_get_n_pages (window->notebook);
- for (l = actions; l != NULL; l = l->next)
- {
- GtkAction *action = GTK_ACTION (l->data);
+ actions = gtk_action_group_list_actions (window->tab_accels_action_group);
+ pages = gtk_notebook_get_n_pages (window->notebook);
+ for (l = actions; l != NULL; l = l->next) {
+ GtkAction *action = GTK_ACTION (l->data);
- gtk_action_set_sensitive (action, (i < pages));
+ gtk_action_set_sensitive (action, (i < pages));
- i++;
- }
- g_list_free (actions);
+ i++;
+ }
+ g_list_free (actions);
}
#define TAB_ACCELS_N 10
@@ -2547,268 +2430,253 @@ tab_accels_update (EphyWindow *window)
static void
setup_tab_accels (EphyWindow *window)
{
- guint id;
- int i;
+ guint id;
+ int i;
- id = gtk_ui_manager_new_merge_id (window->manager);
+ id = gtk_ui_manager_new_merge_id (window->manager);
- for (i = 0; i < TAB_ACCELS_N; i++)
- {
- GtkAction *action;
- char *name;
- char *accel;
+ for (i = 0; i < TAB_ACCELS_N; i++) {
+ GtkAction *action;
+ char *name;
+ char *accel;
- name = g_strdup_printf ("TabAccel%d", i);
- accel = g_strdup_printf ("<alt>%d", (i + 1) % TAB_ACCELS_N);
- action = gtk_action_new (name, NULL, NULL, NULL);
+ name = g_strdup_printf ("TabAccel%d", i);
+ accel = g_strdup_printf ("<alt>%d", (i + 1) % TAB_ACCELS_N);
+ action = gtk_action_new (name, NULL, NULL, NULL);
- gtk_action_group_add_action_with_accel (window->tab_accels_action_group,
- action, accel);
+ gtk_action_group_add_action_with_accel (window->tab_accels_action_group,
+ action, accel);
- g_signal_connect (action, "activate",
- G_CALLBACK (tab_accels_item_activate), window);
- gtk_ui_manager_add_ui (window->manager, id, "/",
- name, name,
- GTK_UI_MANAGER_ACCELERATOR,
- FALSE);
+ g_signal_connect (action, "activate",
+ G_CALLBACK (tab_accels_item_activate), window);
+ gtk_ui_manager_add_ui (window->manager, id, "/",
+ name, name,
+ GTK_UI_MANAGER_ACCELERATOR,
+ FALSE);
- g_object_unref (action);
- g_free (accel);
- g_free (name);
- }
+ g_object_unref (action);
+ g_free (accel);
+ g_free (name);
+ }
}
static gboolean
-show_notebook_popup_menu (GtkNotebook *notebook,
- EphyWindow *window,
- GdkEventButton *event)
+show_notebook_popup_menu (GtkNotebook *notebook,
+ EphyWindow *window,
+ GdkEventButton *event)
{
- GtkWidget *menu, *tab, *tab_label;
- GtkAction *action;
+ GtkWidget *menu, *tab, *tab_label;
+ GtkAction *action;
- menu = gtk_ui_manager_get_widget (window->manager, "/EphyNotebookPopup");
- g_return_val_if_fail (menu != NULL, FALSE);
+ menu = gtk_ui_manager_get_widget (window->manager, "/EphyNotebookPopup");
+ g_return_val_if_fail (menu != NULL, FALSE);
- /* allow extensions to sync when showing the popup */
- action = gtk_action_group_get_action (window->action_group,
- "NotebookPopupAction");
- g_return_val_if_fail (action != NULL, FALSE);
- gtk_action_activate (action);
+ /* allow extensions to sync when showing the popup */
+ action = gtk_action_group_get_action (window->action_group,
+ "NotebookPopupAction");
+ g_return_val_if_fail (action != NULL, FALSE);
+ gtk_action_activate (action);
- if (event != NULL)
- {
- gint n_pages, page_num;
+ if (event != NULL) {
+ gint n_pages, page_num;
- tab = GTK_WIDGET (window->active_embed);
- n_pages = gtk_notebook_get_n_pages (notebook);
- page_num = gtk_notebook_page_num (notebook, tab);
+ tab = GTK_WIDGET (window->active_embed);
+ n_pages = gtk_notebook_get_n_pages (notebook);
+ page_num = gtk_notebook_page_num (notebook, tab);
- /* enable/disable move left/right items*/
- action = gtk_action_group_get_action (window->action_group,
- "TabsMoveLeft");
- gtk_action_set_sensitive (action, page_num > 0);
+ /* enable/disable move left/right items*/
+ action = gtk_action_group_get_action (window->action_group,
+ "TabsMoveLeft");
+ gtk_action_set_sensitive (action, page_num > 0);
- action = gtk_action_group_get_action (window->action_group,
- "TabsMoveRight");
- gtk_action_set_sensitive (action, page_num < n_pages - 1);
+ action = gtk_action_group_get_action (window->action_group,
+ "TabsMoveRight");
+ gtk_action_set_sensitive (action, page_num < n_pages - 1);
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
- NULL, NULL,
- event->button, event->time);
- }
- else
- {
- tab = GTK_WIDGET (window->active_embed);
- tab_label = gtk_notebook_get_tab_label (notebook, tab);
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
+ NULL, NULL,
+ event->button, event->time);
+ } else {
+ tab = GTK_WIDGET (window->active_embed);
+ tab_label = gtk_notebook_get_tab_label (notebook, tab);
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
- ephy_gui_menu_position_under_widget, tab_label,
- 0, gtk_get_current_event_time ());
- gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
- }
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
+ ephy_gui_menu_position_under_widget, tab_label,
+ 0, gtk_get_current_event_time ());
+ gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
+ }
- return TRUE;
+ return TRUE;
}
static gboolean
-notebook_button_press_cb (GtkNotebook *notebook,
- GdkEventButton *event,
- EphyWindow *window)
+notebook_button_press_cb (GtkNotebook *notebook,
+ GdkEventButton *event,
+ EphyWindow *window)
{
- if (GDK_BUTTON_PRESS == event->type && 3 == event->button)
- {
- return show_notebook_popup_menu (notebook, window, event);
- }
+ if (GDK_BUTTON_PRESS == event->type && 3 == event->button) {
+ return show_notebook_popup_menu (notebook, window, event);
+ }
- return FALSE;
+ return FALSE;
}
static gboolean
notebook_popup_menu_cb (GtkNotebook *notebook,
- EphyWindow *window)
+ EphyWindow *window)
{
- /* Only respond if the notebook is the actual focus */
- if (EPHY_IS_NOTEBOOK (gtk_window_get_focus (GTK_WINDOW (window))))
- {
- return show_notebook_popup_menu (notebook, window, NULL);
- }
+ /* Only respond if the notebook is the actual focus */
+ if (EPHY_IS_NOTEBOOK (gtk_window_get_focus (GTK_WINDOW (window)))) {
+ return show_notebook_popup_menu (notebook, window, NULL);
+ }
- return FALSE;
+ return FALSE;
}
static gboolean
present_on_idle_cb (GtkWindow *window)
{
- gtk_window_present (window);
- return FALSE;
+ gtk_window_present (window);
+ return FALSE;
}
static gboolean
delayed_remove_child (gpointer data)
{
- GtkWidget *widget = GTK_WIDGET (data);
- EphyEmbedContainer *container = EPHY_EMBED_CONTAINER (gtk_widget_get_toplevel (widget));
+ GtkWidget *widget = GTK_WIDGET (data);
+ EphyEmbedContainer *container = EPHY_EMBED_CONTAINER (gtk_widget_get_toplevel (widget));
- ephy_embed_container_remove_child (container, EPHY_EMBED (widget));
+ ephy_embed_container_remove_child (container, EPHY_EMBED (widget));
- return FALSE;
+ return FALSE;
}
static void
download_only_load_cb (EphyWebView *view,
- EphyWindow *window)
+ EphyWindow *window)
{
- if (gtk_notebook_get_n_pages (window->notebook) == 1) {
- ephy_web_view_load_homepage (view);
- return;
- }
+ if (gtk_notebook_get_n_pages (window->notebook) == 1) {
+ ephy_web_view_load_homepage (view);
+ return;
+ }
- g_idle_add (delayed_remove_child, EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (view));
+ g_idle_add (delayed_remove_child, EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (view));
}
static void
notebook_page_added_cb (EphyNotebook *notebook,
- EphyEmbed *embed,
- guint position,
- EphyWindow *window)
+ EphyEmbed *embed,
+ guint position,
+ EphyWindow *window)
{
- LOG ("page-added notebook %p embed %p position %u\n", notebook, embed, position);
+ LOG ("page-added notebook %p embed %p position %u\n", notebook, embed, position);
- g_return_if_fail (EPHY_IS_EMBED (embed));
+ g_return_if_fail (EPHY_IS_EMBED (embed));
#if 0
- g_signal_connect_object (embed, "open-link",
- G_CALLBACK (ephy_link_open), window,
- G_CONNECT_SWAPPED);
+ g_signal_connect_object (embed, "open-link",
+ G_CALLBACK (ephy_link_open), window,
+ G_CONNECT_SWAPPED);
#endif
- g_signal_connect_object (ephy_embed_get_web_view (embed), "download-only-load",
- G_CALLBACK (download_only_load_cb), window, G_CONNECT_AFTER);
+ g_signal_connect_object (ephy_embed_get_web_view (embed), "download-only-load",
+ G_CALLBACK (download_only_load_cb), window, G_CONNECT_AFTER);
- if (window->present_on_insert)
- {
- window->present_on_insert = FALSE;
- g_idle_add ((GSourceFunc) present_on_idle_cb, g_object_ref (window));
- }
+ if (window->present_on_insert) {
+ window->present_on_insert = FALSE;
+ g_idle_add ((GSourceFunc)present_on_idle_cb, g_object_ref (window));
+ }
- tab_accels_update (window);
+ tab_accels_update (window);
}
static void
notebook_page_removed_cb (EphyNotebook *notebook,
- EphyEmbed *embed,
- guint position,
- EphyWindow *window)
+ EphyEmbed *embed,
+ guint position,
+ EphyWindow *window)
{
- LOG ("page-removed notebook %p embed %p position %u\n", notebook, embed, position);
+ LOG ("page-removed notebook %p embed %p position %u\n", notebook, embed, position);
- if (window->closing) return;
+ if (window->closing) return;
- g_return_if_fail (EPHY_IS_EMBED (embed));
+ g_return_if_fail (EPHY_IS_EMBED (embed));
#if 0
- g_signal_handlers_disconnect_by_func (G_OBJECT (embed),
- G_CALLBACK (ephy_link_open),
- window);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (embed),
+ G_CALLBACK (ephy_link_open),
+ window);
#endif
- g_signal_handlers_disconnect_by_func
- (ephy_embed_get_web_view (embed), G_CALLBACK (download_only_load_cb), window);
+ g_signal_handlers_disconnect_by_func
+ (ephy_embed_get_web_view (embed), G_CALLBACK (download_only_load_cb), window);
- tab_accels_update (window);
+ tab_accels_update (window);
}
static void
ephy_window_close_tab (EphyWindow *window,
- EphyEmbed *tab)
+ EphyEmbed *tab)
{
- gtk_widget_destroy (GTK_WIDGET (tab));
+ gtk_widget_destroy (GTK_WIDGET (tab));
- /* If that was the last tab, destroy the window. */
- if (gtk_notebook_get_n_pages (window->notebook) == 0)
- {
- gtk_widget_destroy (GTK_WIDGET (window));
- }
+ /* If that was the last tab, destroy the window. */
+ if (gtk_notebook_get_n_pages (window->notebook) == 0) {
+ gtk_widget_destroy (GTK_WIDGET (window));
+ }
}
static void
-tab_has_modified_forms_cb (EphyWebView *view,
- GAsyncResult *result,
- EphyWindow *window)
+tab_has_modified_forms_cb (EphyWebView *view,
+ GAsyncResult *result,
+ EphyWindow *window)
{
- gboolean has_modified_forms;
+ gboolean has_modified_forms;
- has_modified_forms = ephy_web_view_has_modified_forms_finish (view, result, NULL);
- if (!has_modified_forms || confirm_close_with_modified_forms (window))
- {
- ephy_window_close_tab (window, EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (view));
- }
+ has_modified_forms = ephy_web_view_has_modified_forms_finish (view, result, NULL);
+ if (!has_modified_forms || confirm_close_with_modified_forms (window)) {
+ ephy_window_close_tab (window, EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (view));
+ }
}
static void
notebook_page_close_request_cb (EphyNotebook *notebook,
- EphyEmbed *embed,
- EphyWindow *window)
-{
- if (gtk_notebook_get_n_pages (window->notebook) == 1)
- {
- if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
- EPHY_PREFS_LOCKDOWN_QUIT))
- {
- return;
- }
-
- /* Last window, check ongoing downloads before closing the tab */
- if (ephy_shell_get_n_windows (ephy_shell_get_default ()) == 1)
- {
- EphyDownloadsManager *manager = ephy_embed_shell_get_downloads_manager
(EPHY_EMBED_SHELL (ephy_shell_get_default ()));
-
- if (ephy_downloads_manager_has_active_downloads (manager) &&
- !confirm_close_with_downloads (window))
- return;
- }
- }
-
- if (g_settings_get_boolean (EPHY_SETTINGS_MAIN,
- EPHY_PREFS_WARN_ON_CLOSE_UNSUBMITTED_DATA))
- {
- ephy_web_view_has_modified_forms (ephy_embed_get_web_view (embed),
- NULL,
- (GAsyncReadyCallback)tab_has_modified_forms_cb,
- window);
- }
- else
- {
- ephy_window_close_tab (window, embed);
- }
+ EphyEmbed *embed,
+ EphyWindow *window)
+{
+ if (gtk_notebook_get_n_pages (window->notebook) == 1) {
+ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_QUIT)) {
+ return;
+ }
+
+ /* Last window, check ongoing downloads before closing the tab */
+ if (ephy_shell_get_n_windows (ephy_shell_get_default ()) == 1) {
+ EphyDownloadsManager *manager = ephy_embed_shell_get_downloads_manager (EPHY_EMBED_SHELL
(ephy_shell_get_default ()));
+
+ if (ephy_downloads_manager_has_active_downloads (manager) &&
+ !confirm_close_with_downloads (window))
+ return;
+ }
+ }
+
+ if (g_settings_get_boolean (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_WARN_ON_CLOSE_UNSUBMITTED_DATA)) {
+ ephy_web_view_has_modified_forms (ephy_embed_get_web_view (embed),
+ NULL,
+ (GAsyncReadyCallback)tab_has_modified_forms_cb,
+ window);
+ } else {
+ ephy_window_close_tab (window, embed);
+ }
}
static GtkWidget *
notebook_create_window_cb (GtkNotebook *notebook,
- GtkWidget *page,
- int x,
- int y,
- EphyWindow *window)
+ GtkWidget *page,
+ int x,
+ int y,
+ EphyWindow *window)
{
EphyWindow *new_window;
@@ -2822,655 +2690,639 @@ notebook_create_window_cb (GtkNotebook *notebook,
static EphyEmbed *
real_get_active_tab (EphyWindow *window, int page_num)
{
- GtkWidget *embed;
+ GtkWidget *embed;
- if (page_num == -1)
- {
- page_num = gtk_notebook_get_current_page (window->notebook);
- }
+ if (page_num == -1) {
+ page_num = gtk_notebook_get_current_page (window->notebook);
+ }
- embed = gtk_notebook_get_nth_page (window->notebook, page_num);
+ embed = gtk_notebook_get_nth_page (window->notebook, page_num);
- g_return_val_if_fail (EPHY_IS_EMBED (embed), NULL);
+ g_return_val_if_fail (EPHY_IS_EMBED (embed), NULL);
- return EPHY_EMBED (embed);
+ return EPHY_EMBED (embed);
}
static void
notebook_switch_page_cb (GtkNotebook *notebook,
- GtkWidget *page,
- guint page_num,
- EphyWindow *window)
+ GtkWidget *page,
+ guint page_num,
+ EphyWindow *window)
{
- EphyEmbed *embed;
+ EphyEmbed *embed;
- LOG ("switch-page notebook %p position %u\n", notebook, page_num);
+ LOG ("switch-page notebook %p position %u\n", notebook, page_num);
- if (window->closing) return;
+ if (window->closing) return;
- /* get the new tab */
- embed = real_get_active_tab (window, page_num);
+ /* get the new tab */
+ embed = real_get_active_tab (window, page_num);
- /* update new tab */
- ephy_window_set_active_tab (window, embed);
+ /* update new tab */
+ ephy_window_set_active_tab (window, embed);
- ephy_title_box_set_web_view (ephy_toolbar_get_title_box (EPHY_TOOLBAR (window->toolbar)),
- EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed));
+ ephy_title_box_set_web_view (ephy_toolbar_get_title_box (EPHY_TOOLBAR (window->toolbar)),
+ EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed));
}
static GtkNotebook *
setup_notebook (EphyWindow *window)
{
- GtkNotebook *notebook;
+ GtkNotebook *notebook;
- notebook = GTK_NOTEBOOK (g_object_new (EPHY_TYPE_NOTEBOOK, NULL));
+ notebook = GTK_NOTEBOOK (g_object_new (EPHY_TYPE_NOTEBOOK, NULL));
- g_signal_connect_after (notebook, "switch-page",
- G_CALLBACK (notebook_switch_page_cb),
- window);
- g_signal_connect (notebook, "create-window",
- G_CALLBACK (notebook_create_window_cb),
+ g_signal_connect_after (notebook, "switch-page",
+ G_CALLBACK (notebook_switch_page_cb),
window);
+ g_signal_connect (notebook, "create-window",
+ G_CALLBACK (notebook_create_window_cb),
+ window);
- g_signal_connect (notebook, "popup-menu",
- G_CALLBACK (notebook_popup_menu_cb), window);
- g_signal_connect (notebook, "button-press-event",
- G_CALLBACK (notebook_button_press_cb), window);
+ g_signal_connect (notebook, "popup-menu",
+ G_CALLBACK (notebook_popup_menu_cb), window);
+ g_signal_connect (notebook, "button-press-event",
+ G_CALLBACK (notebook_button_press_cb), window);
- g_signal_connect (notebook, "page-added",
- G_CALLBACK (notebook_page_added_cb), window);
- g_signal_connect (notebook, "page-removed",
- G_CALLBACK (notebook_page_removed_cb), window);
- g_signal_connect (notebook, "tab-close-request",
- G_CALLBACK (notebook_page_close_request_cb), window);
+ g_signal_connect (notebook, "page-added",
+ G_CALLBACK (notebook_page_added_cb), window);
+ g_signal_connect (notebook, "page-removed",
+ G_CALLBACK (notebook_page_removed_cb), window);
+ g_signal_connect (notebook, "tab-close-request",
+ G_CALLBACK (notebook_page_close_request_cb), window);
- g_signal_connect_swapped (notebook, "open-link",
- G_CALLBACK (ephy_link_open), window);
+ g_signal_connect_swapped (notebook, "open-link",
+ G_CALLBACK (ephy_link_open), window);
- return notebook;
+ return notebook;
}
static void
ephy_window_dispose (GObject *object)
{
- EphyWindow *window = EPHY_WINDOW (object);
- GSList *popups;
+ EphyWindow *window = EPHY_WINDOW (object);
+ GSList *popups;
- LOG ("EphyWindow dispose %p", window);
+ LOG ("EphyWindow dispose %p", window);
- /* Only do these once */
- if (window->closing == FALSE)
- {
- window->closing = TRUE;
+ /* Only do these once */
+ if (window->closing == FALSE) {
+ window->closing = TRUE;
- ephy_bookmarks_ui_detach_window (window);
+ ephy_bookmarks_ui_detach_window (window);
- /* Deactivate menus */
- popups = gtk_ui_manager_get_toplevels (window->manager, GTK_UI_MANAGER_POPUP);
- g_slist_foreach (popups, (GFunc) gtk_menu_shell_deactivate, NULL);
- g_slist_free (popups);
+ /* Deactivate menus */
+ popups = gtk_ui_manager_get_toplevels (window->manager, GTK_UI_MANAGER_POPUP);
+ g_slist_foreach (popups, (GFunc)gtk_menu_shell_deactivate, NULL);
+ g_slist_free (popups);
- window->action_group = NULL;
- window->popups_action_group = NULL;
- window->tab_accels_action_group = NULL;
+ window->action_group = NULL;
+ window->popups_action_group = NULL;
+ window->tab_accels_action_group = NULL;
- g_object_unref (window->manager);
- window->manager = NULL;
+ g_object_unref (window->manager);
+ window->manager = NULL;
- _ephy_window_set_context_event (window, NULL);
+ _ephy_window_set_context_event (window, NULL);
- g_clear_object (&window->hit_test_result);
- }
+ g_clear_object (&window->hit_test_result);
+ }
- G_OBJECT_CLASS (ephy_window_parent_class)->dispose (object);
+ G_OBJECT_CLASS (ephy_window_parent_class)->dispose (object);
}
static void
-ephy_window_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ephy_window_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- EphyWindow *window = EPHY_WINDOW (object);
+ EphyWindow *window = EPHY_WINDOW (object);
- switch (prop_id)
- {
- case PROP_ACTIVE_CHILD:
- impl_set_active_child (EPHY_EMBED_CONTAINER (window),
- g_value_get_object (value));
- break;
- case PROP_CHROME:
- ephy_window_set_chrome (window, g_value_get_flags (value));
- break;
- case PROP_SINGLE_TAB_MODE:
- ephy_window_set_is_popup (window, g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ case PROP_ACTIVE_CHILD:
+ impl_set_active_child (EPHY_EMBED_CONTAINER (window),
+ g_value_get_object (value));
+ break;
+ case PROP_CHROME:
+ ephy_window_set_chrome (window, g_value_get_flags (value));
+ break;
+ case PROP_SINGLE_TAB_MODE:
+ ephy_window_set_is_popup (window, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-ephy_window_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ephy_window_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- EphyWindow *window = EPHY_WINDOW (object);
+ EphyWindow *window = EPHY_WINDOW (object);
- switch (prop_id)
- {
- case PROP_ACTIVE_CHILD:
- g_value_set_object (value, window->active_embed);
- break;
- case PROP_CHROME:
- g_value_set_flags (value, window->chrome);
- break;
- case PROP_SINGLE_TAB_MODE:
- g_value_set_boolean (value, window->is_popup);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id) {
+ case PROP_ACTIVE_CHILD:
+ g_value_set_object (value, window->active_embed);
+ break;
+ case PROP_CHROME:
+ g_value_set_flags (value, window->chrome);
+ break;
+ case PROP_SINGLE_TAB_MODE:
+ g_value_set_boolean (value, window->is_popup);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static gboolean
-ephy_window_state_event (GtkWidget *widget,
- GdkEventWindowState *event)
+ephy_window_state_event (GtkWidget *widget,
+ GdkEventWindowState *event)
{
- EphyWindow *window = EPHY_WINDOW (widget);
+ EphyWindow *window = EPHY_WINDOW (widget);
- if (GTK_WIDGET_CLASS (ephy_window_parent_class)->window_state_event)
- {
- GTK_WIDGET_CLASS (ephy_window_parent_class)->window_state_event (widget, event);
- }
+ if (GTK_WIDGET_CLASS (ephy_window_parent_class)->window_state_event) {
+ GTK_WIDGET_CLASS (ephy_window_parent_class)->window_state_event (widget, event);
+ }
- if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
- {
- GtkActionGroup *action_group;
- GtkAction *action;
- gboolean fullscreen;
+ if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) {
+ GtkActionGroup *action_group;
+ GtkAction *action;
+ gboolean fullscreen;
- fullscreen = event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN;
+ fullscreen = event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN;
- if (fullscreen)
- {
- ephy_window_fullscreen (window);
- }
- else
- {
- ephy_window_unfullscreen (window);
- }
+ if (fullscreen) {
+ ephy_window_fullscreen (window);
+ } else {
+ ephy_window_unfullscreen (window);
+ }
- action_group = window->action_group;
+ action_group = window->action_group;
- action = gtk_action_group_get_action (action_group, "ViewFullscreen");
- g_signal_handlers_block_by_func
- (action, G_CALLBACK (window_cmd_view_fullscreen), window);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), fullscreen);
- g_signal_handlers_unblock_by_func
- (action, G_CALLBACK (window_cmd_view_fullscreen), window);
- }
+ action = gtk_action_group_get_action (action_group, "ViewFullscreen");
+ g_signal_handlers_block_by_func
+ (action, G_CALLBACK (window_cmd_view_fullscreen), window);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), fullscreen);
+ g_signal_handlers_unblock_by_func
+ (action, G_CALLBACK (window_cmd_view_fullscreen), window);
+ }
- return FALSE;
+ return FALSE;
}
static void
ephy_window_finalize (GObject *object)
{
- EphyWindow *window = EPHY_WINDOW (object);
+ EphyWindow *window = EPHY_WINDOW (object);
- if (window->app_menu_visibility_handler != 0)
- g_signal_handler_disconnect (gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET
(window))),
- window->app_menu_visibility_handler);
+ if (window->app_menu_visibility_handler != 0)
+ g_signal_handler_disconnect (gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window))),
+ window->app_menu_visibility_handler);
- G_OBJECT_CLASS (ephy_window_parent_class)->finalize (object);
+ G_OBJECT_CLASS (ephy_window_parent_class)->finalize (object);
- LOG ("EphyWindow finalised %p", object);
+ LOG ("EphyWindow finalised %p", object);
}
static void
-allow_popups_notifier (GSettings *settings,
- char *key,
- EphyWindow *window)
+allow_popups_notifier (GSettings *settings,
+ char *key,
+ EphyWindow *window)
{
- GList *tabs;
- EphyEmbed *embed;
+ GList *tabs;
+ EphyEmbed *embed;
- g_return_if_fail (EPHY_IS_WINDOW (window));
+ g_return_if_fail (EPHY_IS_WINDOW (window));
- tabs = impl_get_children (EPHY_EMBED_CONTAINER (window));
+ tabs = impl_get_children (EPHY_EMBED_CONTAINER (window));
- for (; tabs; tabs = g_list_next (tabs))
- {
- embed = EPHY_EMBED (tabs->data);
- g_return_if_fail (EPHY_IS_EMBED (embed));
+ for (; tabs; tabs = g_list_next (tabs)) {
+ embed = EPHY_EMBED (tabs->data);
+ g_return_if_fail (EPHY_IS_EMBED (embed));
- g_object_notify (G_OBJECT (ephy_embed_get_web_view (embed)), "popups-allowed");
- }
- g_list_free (tabs);
+ g_object_notify (G_OBJECT (ephy_embed_get_web_view (embed)), "popups-allowed");
+ }
+ g_list_free (tabs);
}
static void
sync_user_input_cb (EphyLocationController *action,
- GParamSpec *pspec,
- EphyWindow *window)
+ GParamSpec *pspec,
+ EphyWindow *window)
{
- EphyEmbed *embed;
- const char *address;
+ EphyEmbed *embed;
+ const char *address;
- LOG ("sync_user_input_cb");
+ LOG ("sync_user_input_cb");
- if (window->updating_address) return;
+ if (window->updating_address) return;
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
- g_assert (EPHY_IS_EMBED (embed));
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+ g_assert (EPHY_IS_EMBED (embed));
- address = ephy_location_controller_get_address (action);
+ address = ephy_location_controller_get_address (action);
- window->updating_address = TRUE;
- ephy_web_view_set_typed_address (ephy_embed_get_web_view (embed), address);
- window->updating_address = FALSE;
+ window->updating_address = TRUE;
+ ephy_web_view_set_typed_address (ephy_embed_get_web_view (embed), address);
+ window->updating_address = FALSE;
}
static void
-zoom_to_level_cb (GtkAction *action,
- float zoom,
- EphyWindow *window)
+zoom_to_level_cb (GtkAction *action,
+ float zoom,
+ EphyWindow *window)
{
- ephy_window_set_zoom (window, zoom);
+ ephy_window_set_zoom (window, zoom);
}
static void
-open_security_popover (EphyWindow *window,
- GtkWidget *relative_to,
- GdkRectangle *lock_position)
+open_security_popover (EphyWindow *window,
+ GtkWidget *relative_to,
+ GdkRectangle *lock_position)
{
- EphyWebView *view;
- GTlsCertificate *certificate;
- GTlsCertificateFlags tls_errors;
- EphySecurityLevel security_level;
- GtkWidget *location_entry;
- GtkWidget *security_popover;
+ EphyWebView *view;
+ GTlsCertificate *certificate;
+ GTlsCertificateFlags tls_errors;
+ EphySecurityLevel security_level;
+ GtkWidget *location_entry;
+ GtkWidget *security_popover;
- view = ephy_embed_get_web_view (window->active_embed);
- ephy_web_view_get_security_level (view, &security_level, &certificate, &tls_errors);
- location_entry = ephy_toolbar_get_location_entry (EPHY_TOOLBAR (window->toolbar));
+ view = ephy_embed_get_web_view (window->active_embed);
+ ephy_web_view_get_security_level (view, &security_level, &certificate, &tls_errors);
+ location_entry = ephy_toolbar_get_location_entry (EPHY_TOOLBAR (window->toolbar));
- security_popover = ephy_security_popover_new (relative_to,
- ephy_location_entry_get_location (EPHY_LOCATION_ENTRY
(location_entry)),
- certificate,
- tls_errors,
- security_level);
+ security_popover = ephy_security_popover_new (relative_to,
+ ephy_location_entry_get_location (EPHY_LOCATION_ENTRY
(location_entry)),
+ certificate,
+ tls_errors,
+ security_level);
- g_signal_connect (security_popover, "closed",
- G_CALLBACK (gtk_widget_destroy), NULL);
- gtk_popover_set_pointing_to (GTK_POPOVER (security_popover), lock_position);
- gtk_widget_show (security_popover);
+ g_signal_connect (security_popover, "closed",
+ G_CALLBACK (gtk_widget_destroy), NULL);
+ gtk_popover_set_pointing_to (GTK_POPOVER (security_popover), lock_position);
+ gtk_widget_show (security_popover);
}
static void
location_controller_lock_clicked_cb (EphyLocationController *controller,
- gpointer user_data)
+ gpointer user_data)
{
- EphyWindow *window = EPHY_WINDOW (user_data);
- GtkWidget *location_entry;
- GdkRectangle lock_position;
+ EphyWindow *window = EPHY_WINDOW (user_data);
+ GtkWidget *location_entry;
+ GdkRectangle lock_position;
- location_entry = ephy_toolbar_get_location_entry (EPHY_TOOLBAR (window->toolbar));
- gtk_entry_get_icon_area (GTK_ENTRY (location_entry), GTK_ENTRY_ICON_SECONDARY, &lock_position);
- open_security_popover (window, location_entry, &lock_position);
+ location_entry = ephy_toolbar_get_location_entry (EPHY_TOOLBAR (window->toolbar));
+ gtk_entry_get_icon_area (GTK_ENTRY (location_entry), GTK_ENTRY_ICON_SECONDARY, &lock_position);
+ open_security_popover (window, location_entry, &lock_position);
}
static void
title_box_lock_clicked_cb (EphyTitleBox *title_box,
- GdkRectangle *lock_position,
- gpointer user_data)
+ GdkRectangle *lock_position,
+ gpointer user_data)
{
- EphyWindow *window = EPHY_WINDOW (user_data);
+ EphyWindow *window = EPHY_WINDOW (user_data);
- open_security_popover (window, GTK_WIDGET (title_box), lock_position);
+ open_security_popover (window, GTK_WIDGET (title_box), lock_position);
}
static GtkWidget *
setup_toolbar (EphyWindow *window)
{
- GtkWidget *toolbar;
- GtkAction *action;
- EphyEmbedShellMode app_mode;
- EphyTitleBox *title_box;
+ GtkWidget *toolbar;
+ GtkAction *action;
+ EphyEmbedShellMode app_mode;
+ EphyTitleBox *title_box;
- toolbar = ephy_toolbar_new (window);
- gtk_window_set_titlebar (GTK_WINDOW (window), toolbar);
- gtk_widget_show (toolbar);
+ toolbar = ephy_toolbar_new (window);
+ gtk_window_set_titlebar (GTK_WINDOW (window), toolbar);
+ gtk_widget_show (toolbar);
- app_mode = ephy_embed_shell_get_mode (ephy_embed_shell_get_default ());
- if (app_mode == EPHY_EMBED_SHELL_MODE_INCOGNITO)
- gtk_style_context_add_class (gtk_widget_get_style_context (toolbar), "incognito-mode");
+ app_mode = ephy_embed_shell_get_mode (ephy_embed_shell_get_default ());
+ if (app_mode == EPHY_EMBED_SHELL_MODE_INCOGNITO)
+ gtk_style_context_add_class (gtk_widget_get_style_context (toolbar), "incognito-mode");
- action = gtk_action_group_get_action (window->toolbar_action_group,
- "NavigationBack");
- g_signal_connect_swapped (action, "open-link",
- G_CALLBACK (ephy_link_open), window);
+ action = gtk_action_group_get_action (window->toolbar_action_group,
+ "NavigationBack");
+ g_signal_connect_swapped (action, "open-link",
+ G_CALLBACK (ephy_link_open), window);
- action = gtk_action_group_get_action (window->toolbar_action_group,
- "NavigationForward");
- g_signal_connect_swapped (action, "open-link",
- G_CALLBACK (ephy_link_open), window);
+ action = gtk_action_group_get_action (window->toolbar_action_group,
+ "NavigationForward");
+ g_signal_connect_swapped (action, "open-link",
+ G_CALLBACK (ephy_link_open), window);
- action = gtk_action_group_get_action (window->toolbar_action_group,
- "FileNewTab");
- g_signal_connect_swapped (action, "open-link",
- G_CALLBACK (ephy_link_open), window);
+ action = gtk_action_group_get_action (window->toolbar_action_group,
+ "FileNewTab");
+ g_signal_connect_swapped (action, "open-link",
+ G_CALLBACK (ephy_link_open), window);
- action = gtk_action_group_get_action (window->toolbar_action_group,
- "Zoom");
- g_signal_connect (action, "zoom-to-level",
- G_CALLBACK (zoom_to_level_cb), window);
+ action = gtk_action_group_get_action (window->toolbar_action_group,
+ "Zoom");
+ g_signal_connect (action, "zoom-to-level",
+ G_CALLBACK (zoom_to_level_cb), window);
- title_box = ephy_toolbar_get_title_box (EPHY_TOOLBAR (toolbar));
- g_signal_connect (title_box, "lock-clicked",
- G_CALLBACK (title_box_lock_clicked_cb), window);
+ title_box = ephy_toolbar_get_title_box (EPHY_TOOLBAR (toolbar));
+ g_signal_connect (title_box, "lock-clicked",
+ G_CALLBACK (title_box_lock_clicked_cb), window);
- return toolbar;
+ return toolbar;
}
static EphyLocationController *
-setup_location_controller (EphyWindow *window,
- EphyToolbar *toolbar)
-{
- EphyLocationController *location_controller;
-
- location_controller =
- g_object_new (EPHY_TYPE_LOCATION_CONTROLLER,
- "window", window,
- "location-entry", ephy_toolbar_get_location_entry (toolbar),
- "title-box", ephy_toolbar_get_title_box (toolbar),
- NULL);
- g_signal_connect (location_controller, "notify::address",
- G_CALLBACK (sync_user_input_cb), window);
- g_signal_connect_swapped (location_controller, "open-link",
- G_CALLBACK (ephy_link_open), window);
- g_signal_connect (location_controller, "lock-clicked",
- G_CALLBACK (location_controller_lock_clicked_cb), window);
-
- return location_controller;
-}
-
-static const char* disabled_actions_for_app_mode[] = { "FileOpen",
- "FileNewWindow",
- "FileNewWindowIncognito",
- "FileSaveAs",
- "FileSaveAsApplication",
- "ViewEncoding",
- "ViewPageSource",
- "FileBookmarkPage",
- "EditBookmarks",
- "EditHistory",
- "EditPreferences"};
+setup_location_controller (EphyWindow *window,
+ EphyToolbar *toolbar)
+{
+ EphyLocationController *location_controller;
+
+ location_controller =
+ g_object_new (EPHY_TYPE_LOCATION_CONTROLLER,
+ "window", window,
+ "location-entry", ephy_toolbar_get_location_entry (toolbar),
+ "title-box", ephy_toolbar_get_title_box (toolbar),
+ NULL);
+ g_signal_connect (location_controller, "notify::address",
+ G_CALLBACK (sync_user_input_cb), window);
+ g_signal_connect_swapped (location_controller, "open-link",
+ G_CALLBACK (ephy_link_open), window);
+ g_signal_connect (location_controller, "lock-clicked",
+ G_CALLBACK (location_controller_lock_clicked_cb), window);
+
+ return location_controller;
+}
+
+static const char *disabled_actions_for_app_mode[] = { "FileOpen",
+ "FileNewWindow",
+ "FileNewWindowIncognito",
+ "FileSaveAs",
+ "FileSaveAsApplication",
+ "ViewEncoding",
+ "ViewPageSource",
+ "FileBookmarkPage",
+ "EditBookmarks",
+ "EditHistory",
+ "EditPreferences" };
static void
parse_css_error (GtkCssProvider *provider,
- GtkCssSection *section,
- GError *error,
- gpointer user_data)
-{
- g_warning ("CSS error in section beginning line %u at offset %u:\n %s",
- gtk_css_section_get_start_line (section) + 1,
- gtk_css_section_get_start_position (section),
- error->message);
-}
-
-static const gchar* app_actions[] = {
- "FileNewWindow",
- "FileNewWindowIncognito",
- "EditPreferences",
- "EditBookmarks",
- "EditHistory",
- "FileQuit",
- "HelpContents",
- "HelpAbout"
+ GtkCssSection *section,
+ GError *error,
+ gpointer user_data)
+{
+ g_warning ("CSS error in section beginning line %u at offset %u:\n %s",
+ gtk_css_section_get_start_line (section) + 1,
+ gtk_css_section_get_start_position (section),
+ error->message);
+}
+
+static const gchar *app_actions[] = {
+ "FileNewWindow",
+ "FileNewWindowIncognito",
+ "EditPreferences",
+ "EditBookmarks",
+ "EditHistory",
+ "FileQuit",
+ "HelpContents",
+ "HelpAbout"
};
static void
ephy_window_toggle_visibility_for_app_menu (EphyWindow *window)
{
- const gchar *action_name;
- gboolean shows_app_menu;
- GtkSettings *settings;
- GtkAction *action;
- guint i;
+ const gchar *action_name;
+ gboolean shows_app_menu;
+ GtkSettings *settings;
+ GtkAction *action;
+ guint i;
- settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window)));
- g_object_get (settings,
- "gtk-shell-shows-app-menu", &shows_app_menu,
- NULL);
+ settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window)));
+ g_object_get (settings,
+ "gtk-shell-shows-app-menu", &shows_app_menu,
+ NULL);
- for (i = 0; i < G_N_ELEMENTS (app_actions); i++) {
- action_name = app_actions[i];
- action = gtk_action_group_get_action (window->action_group, action_name);
+ for (i = 0; i < G_N_ELEMENTS (app_actions); i++) {
+ action_name = app_actions[i];
+ action = gtk_action_group_get_action (window->action_group, action_name);
- gtk_action_set_visible (action, !shows_app_menu);
- }
+ gtk_action_set_visible (action, !shows_app_menu);
+ }
}
static GObject *
-ephy_window_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_params)
-{
- GObject *object;
- EphyWindow *window;
- GtkSettings *settings;
- GtkAction *action;
- GtkActionGroup *toolbar_action_group;
- GError *error = NULL;
- guint settings_connection;
- GtkCssProvider *css_provider;
- guint i;
- EphyEmbedShellMode mode;
- EphyWindowChrome chrome = EPHY_WINDOW_CHROME_DEFAULT;
-
- object = G_OBJECT_CLASS (ephy_window_parent_class)->constructor
- (type, n_construct_properties, construct_params);
-
- window = EPHY_WINDOW (object);
-
- ephy_gui_ensure_window_group (GTK_WINDOW (window));
-
- /* initialize the listener for the key theme
- * FIXME: Need to handle multi-head and migration.
- */
- settings = gtk_settings_get_default ();
- settings_connection = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (settings),
- SETTINGS_CONNECTION_DATA_KEY));
- if (settings_connection == 0)
- {
- settings_connection =
- g_signal_connect (settings, "notify::gtk-key-theme-name",
- G_CALLBACK (settings_changed_cb), NULL);
- g_object_set_data (G_OBJECT (settings), SETTINGS_CONNECTION_DATA_KEY,
- GUINT_TO_POINTER (settings_connection));
-
- }
-
- settings_change_notify (settings, window);
-
- /* Setup the UI manager and connect verbs */
- setup_ui_manager (window);
- setup_tab_accels (window);
-
- window->notebook = setup_notebook (window);
-
- /* Now load the UI definition (needed by EphyToolbar). */
- gtk_ui_manager_add_ui_from_resource (window->manager,
- "/org/gnome/epiphany/epiphany-ui.xml",
- &error);
- if (error != NULL)
- {
- g_warning ("Could not merge epiphany-ui.xml: %s", error->message);
- g_error_free (error);
- error = NULL;
- }
-
- /* Setup the toolbar. */
- window->toolbar = setup_toolbar (window);
- window->location_controller = setup_location_controller (window, EPHY_TOOLBAR (window->toolbar));
- gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (window->notebook));
- gtk_widget_show (GTK_WIDGET (window->notebook));
-
- /* Attach the CSS provider to the window. */
- css_provider = gtk_css_provider_new ();
- g_signal_connect (css_provider,
- "parsing-error",
- G_CALLBACK (parse_css_error), window);
- gtk_css_provider_load_from_resource (css_provider, "/org/gnome/epiphany/epiphany.css");
- gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (GTK_WIDGET (window)),
- GTK_STYLE_PROVIDER (css_provider),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
- g_object_unref (css_provider);
-
- /* Initialize the menus */
- ephy_bookmarks_ui_attach_window (window);
-
- /* other notifiers */
- action = gtk_action_group_get_action (window->action_group,
- "BrowseWithCaret");
-
- g_settings_bind (EPHY_SETTINGS_MAIN,
- EPHY_PREFS_ENABLE_CARET_BROWSING,
- action, "active",
- G_SETTINGS_BIND_GET);
-
- g_signal_connect (EPHY_SETTINGS_WEB,
- "changed::" EPHY_PREFS_WEB_ENABLE_POPUPS,
- G_CALLBACK (allow_popups_notifier), window);
-
- /* Disable actions not needed for popup mode. */
- toolbar_action_group = window->toolbar_action_group;
- action = gtk_action_group_get_action (toolbar_action_group, "FileNewTab");
- ephy_action_change_sensitivity_flags (action, SENS_FLAG_CHROME,
- window->is_popup);
-
- action = gtk_action_group_get_action (window->popups_action_group, "OpenLinkInNewTab");
- ephy_action_change_sensitivity_flags (action, SENS_FLAG_CHROME,
- window->is_popup);
-
- /* Disabled actions not needed for application mode. */
- mode = ephy_embed_shell_get_mode (ephy_embed_shell_get_default ());
- if (mode == EPHY_EMBED_SHELL_MODE_APPLICATION)
- {
- g_object_set (window->location_controller, "editable", FALSE, NULL);
-
- /* We don't need to show the page menu in web application mode. */
- action = gtk_action_group_get_action (toolbar_action_group, "PageMenu");
- ephy_action_change_sensitivity_flags (action, SENS_FLAG_CHROME, TRUE);
- gtk_action_set_visible (action, FALSE);
-
- action = gtk_action_group_get_action (toolbar_action_group, "FileNewTab");
- ephy_action_change_sensitivity_flags (action, SENS_FLAG_CHROME,
- TRUE);
- gtk_action_set_visible (action, FALSE);
-
- action = gtk_action_group_get_action (window->popups_action_group, "ContextBookmarkPage");
- ephy_action_change_sensitivity_flags (action, SENS_FLAG_CHROME, TRUE);
- gtk_action_set_visible (action, FALSE);
-
- for (i = 0; i < G_N_ELEMENTS (disabled_actions_for_app_mode); i++)
- {
- action = gtk_action_group_get_action (window->action_group,
- disabled_actions_for_app_mode[i]);
- ephy_action_change_sensitivity_flags (action, SENS_FLAG_CHROME, TRUE);
- gtk_action_set_visible (action, FALSE);
- }
- chrome &= ~(EPHY_WINDOW_CHROME_MENU | EPHY_WINDOW_CHROME_TABSBAR);
- }
-
- /* We never want the menubar shown, we merge the app menu into
- * our super menu manually when running outside the Shell. */
- gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (window), FALSE);
-
- ephy_window_toggle_visibility_for_app_menu (window);
- window->app_menu_visibility_handler = g_signal_connect_swapped (gtk_settings_get_for_screen
(gtk_widget_get_screen (GTK_WIDGET (window))),
- "notify::gtk-shell-shows-app-menu",
- G_CALLBACK
(ephy_window_toggle_visibility_for_app_menu), window);
-
- /* ensure the UI is updated */
- gtk_ui_manager_ensure_update (window->manager);
-
- init_menu_updaters (window);
-
- ephy_window_set_chrome (window, chrome);
-
- return object;
+ephy_window_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_params)
+{
+ GObject *object;
+ EphyWindow *window;
+ GtkSettings *settings;
+ GtkAction *action;
+ GtkActionGroup *toolbar_action_group;
+ GError *error = NULL;
+ guint settings_connection;
+ GtkCssProvider *css_provider;
+ guint i;
+ EphyEmbedShellMode mode;
+ EphyWindowChrome chrome = EPHY_WINDOW_CHROME_DEFAULT;
+
+ object = G_OBJECT_CLASS (ephy_window_parent_class)->constructor
+ (type, n_construct_properties, construct_params);
+
+ window = EPHY_WINDOW (object);
+
+ ephy_gui_ensure_window_group (GTK_WINDOW (window));
+
+ /* initialize the listener for the key theme
+ * FIXME: Need to handle multi-head and migration.
+ */
+ settings = gtk_settings_get_default ();
+ settings_connection = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (settings),
+ SETTINGS_CONNECTION_DATA_KEY));
+ if (settings_connection == 0) {
+ settings_connection =
+ g_signal_connect (settings, "notify::gtk-key-theme-name",
+ G_CALLBACK (settings_changed_cb), NULL);
+ g_object_set_data (G_OBJECT (settings), SETTINGS_CONNECTION_DATA_KEY,
+ GUINT_TO_POINTER (settings_connection));
+ }
+
+ settings_change_notify (settings, window);
+
+ /* Setup the UI manager and connect verbs */
+ setup_ui_manager (window);
+ setup_tab_accels (window);
+
+ window->notebook = setup_notebook (window);
+
+ /* Now load the UI definition (needed by EphyToolbar). */
+ gtk_ui_manager_add_ui_from_resource (window->manager,
+ "/org/gnome/epiphany/epiphany-ui.xml",
+ &error);
+ if (error != NULL) {
+ g_warning ("Could not merge epiphany-ui.xml: %s", error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+
+ /* Setup the toolbar. */
+ window->toolbar = setup_toolbar (window);
+ window->location_controller = setup_location_controller (window, EPHY_TOOLBAR (window->toolbar));
+ gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (window->notebook));
+ gtk_widget_show (GTK_WIDGET (window->notebook));
+
+ /* Attach the CSS provider to the window. */
+ css_provider = gtk_css_provider_new ();
+ g_signal_connect (css_provider,
+ "parsing-error",
+ G_CALLBACK (parse_css_error), window);
+ gtk_css_provider_load_from_resource (css_provider, "/org/gnome/epiphany/epiphany.css");
+ gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (GTK_WIDGET (window)),
+ GTK_STYLE_PROVIDER (css_provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ g_object_unref (css_provider);
+
+ /* Initialize the menus */
+ ephy_bookmarks_ui_attach_window (window);
+
+ /* other notifiers */
+ action = gtk_action_group_get_action (window->action_group,
+ "BrowseWithCaret");
+
+ g_settings_bind (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_ENABLE_CARET_BROWSING,
+ action, "active",
+ G_SETTINGS_BIND_GET);
+
+ g_signal_connect (EPHY_SETTINGS_WEB,
+ "changed::" EPHY_PREFS_WEB_ENABLE_POPUPS,
+ G_CALLBACK (allow_popups_notifier), window);
+
+ /* Disable actions not needed for popup mode. */
+ toolbar_action_group = window->toolbar_action_group;
+ action = gtk_action_group_get_action (toolbar_action_group, "FileNewTab");
+ ephy_action_change_sensitivity_flags (action, SENS_FLAG_CHROME,
+ window->is_popup);
+
+ action = gtk_action_group_get_action (window->popups_action_group, "OpenLinkInNewTab");
+ ephy_action_change_sensitivity_flags (action, SENS_FLAG_CHROME,
+ window->is_popup);
+
+ /* Disabled actions not needed for application mode. */
+ mode = ephy_embed_shell_get_mode (ephy_embed_shell_get_default ());
+ if (mode == EPHY_EMBED_SHELL_MODE_APPLICATION) {
+ g_object_set (window->location_controller, "editable", FALSE, NULL);
+
+ /* We don't need to show the page menu in web application mode. */
+ action = gtk_action_group_get_action (toolbar_action_group, "PageMenu");
+ ephy_action_change_sensitivity_flags (action, SENS_FLAG_CHROME, TRUE);
+ gtk_action_set_visible (action, FALSE);
+
+ action = gtk_action_group_get_action (toolbar_action_group, "FileNewTab");
+ ephy_action_change_sensitivity_flags (action, SENS_FLAG_CHROME,
+ TRUE);
+ gtk_action_set_visible (action, FALSE);
+
+ action = gtk_action_group_get_action (window->popups_action_group, "ContextBookmarkPage");
+ ephy_action_change_sensitivity_flags (action, SENS_FLAG_CHROME, TRUE);
+ gtk_action_set_visible (action, FALSE);
+
+ for (i = 0; i < G_N_ELEMENTS (disabled_actions_for_app_mode); i++) {
+ action = gtk_action_group_get_action (window->action_group,
+ disabled_actions_for_app_mode[i]);
+ ephy_action_change_sensitivity_flags (action, SENS_FLAG_CHROME, TRUE);
+ gtk_action_set_visible (action, FALSE);
+ }
+ chrome &= ~(EPHY_WINDOW_CHROME_MENU | EPHY_WINDOW_CHROME_TABSBAR);
+ }
+
+ /* We never want the menubar shown, we merge the app menu into
+ * our super menu manually when running outside the Shell. */
+ gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (window), FALSE);
+
+ ephy_window_toggle_visibility_for_app_menu (window);
+ window->app_menu_visibility_handler = g_signal_connect_swapped (gtk_settings_get_for_screen
(gtk_widget_get_screen (GTK_WIDGET (window))),
+ "notify::gtk-shell-shows-app-menu",
+ G_CALLBACK
(ephy_window_toggle_visibility_for_app_menu), window);
+
+ /* ensure the UI is updated */
+ gtk_ui_manager_ensure_update (window->manager);
+
+ init_menu_updaters (window);
+
+ ephy_window_set_chrome (window, chrome);
+
+ return object;
}
static void
ephy_window_show (GtkWidget *widget)
{
- EphyWindow *window = EPHY_WINDOW (widget);
+ EphyWindow *window = EPHY_WINDOW (widget);
- if (!window->has_size)
- {
- EphyEmbed *embed;
- int flags = 0;
+ if (!window->has_size) {
+ EphyEmbed *embed;
+ int flags = 0;
- embed = window->active_embed;
- g_return_if_fail (EPHY_IS_EMBED (embed));
+ embed = window->active_embed;
+ g_return_if_fail (EPHY_IS_EMBED (embed));
- if (!window->is_popup)
- flags = EPHY_INITIAL_STATE_WINDOW_SAVE_SIZE;
+ if (!window->is_popup)
+ flags = EPHY_INITIAL_STATE_WINDOW_SAVE_SIZE;
- ephy_initial_state_add_window (widget, "main_window", 600, 500,
- TRUE, flags);
- window->has_size = TRUE;
- }
+ ephy_initial_state_add_window (widget, "main_window", 600, 500,
+ TRUE, flags);
+ window->has_size = TRUE;
+ }
- GTK_WIDGET_CLASS (ephy_window_parent_class)->show (widget);
+ GTK_WIDGET_CLASS (ephy_window_parent_class)->show (widget);
}
static void
ephy_window_class_init (EphyWindowClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->constructor = ephy_window_constructor;
- object_class->dispose = ephy_window_dispose;
- object_class->finalize = ephy_window_finalize;
- object_class->get_property = ephy_window_get_property;
- object_class->set_property = ephy_window_set_property;
+ object_class->constructor = ephy_window_constructor;
+ object_class->dispose = ephy_window_dispose;
+ object_class->finalize = ephy_window_finalize;
+ object_class->get_property = ephy_window_get_property;
+ object_class->set_property = ephy_window_set_property;
- widget_class->show = ephy_window_show;
- widget_class->key_press_event = ephy_window_key_press_event;
- widget_class->window_state_event = ephy_window_state_event;
- widget_class->delete_event = ephy_window_delete_event;
+ widget_class->show = ephy_window_show;
+ widget_class->key_press_event = ephy_window_key_press_event;
+ widget_class->window_state_event = ephy_window_state_event;
+ widget_class->delete_event = ephy_window_delete_event;
- g_object_class_override_property (object_class,
- PROP_ACTIVE_CHILD,
- "active-child");
+ g_object_class_override_property (object_class,
+ PROP_ACTIVE_CHILD,
+ "active-child");
- g_object_class_override_property (object_class,
- PROP_SINGLE_TAB_MODE,
- "is-popup");
+ g_object_class_override_property (object_class,
+ PROP_SINGLE_TAB_MODE,
+ "is-popup");
- g_object_class_install_property (object_class,
- PROP_CHROME,
- g_param_spec_flags ("chrome",
- NULL,
- NULL,
- EPHY_TYPE_WINDOW_CHROME,
- EPHY_WINDOW_CHROME_DEFAULT,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class,
+ PROP_CHROME,
+ g_param_spec_flags ("chrome",
+ NULL,
+ NULL,
+ EPHY_TYPE_WINDOW_CHROME,
+ EPHY_WINDOW_CHROME_DEFAULT,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
}
static void
ephy_window_init (EphyWindow *window)
{
- LOG ("EphyWindow initialising %p", window);
+ LOG ("EphyWindow initialising %p", window);
}
/**
@@ -3484,10 +3336,10 @@ ephy_window_init (EphyWindow *window)
EphyWindow *
ephy_window_new (void)
{
- return g_object_new (EPHY_TYPE_WINDOW,
- "application", GTK_APPLICATION (ephy_shell_get_default ()),
- "icon-name", "web-browser",
- NULL);
+ return g_object_new (EPHY_TYPE_WINDOW,
+ "application", GTK_APPLICATION (ephy_shell_get_default ()),
+ "icon-name", "web-browser",
+ NULL);
}
/**
@@ -3501,9 +3353,9 @@ ephy_window_new (void)
GtkUIManager *
ephy_window_get_ui_manager (EphyWindow *window)
{
- g_return_val_if_fail (EPHY_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (EPHY_IS_WINDOW (window), NULL);
- return window->manager;
+ return window->manager;
}
/**
@@ -3517,9 +3369,9 @@ ephy_window_get_ui_manager (EphyWindow *window)
GtkWidget *
ephy_window_get_notebook (EphyWindow *window)
{
- g_return_val_if_fail (EPHY_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (EPHY_IS_WINDOW (window), NULL);
- return GTK_WIDGET (window->notebook);
+ return GTK_WIDGET (window->notebook);
}
/**
@@ -3533,9 +3385,9 @@ ephy_window_get_notebook (EphyWindow *window)
GtkWidget *
ephy_window_get_current_find_toolbar (EphyWindow *window)
{
- g_return_val_if_fail (EPHY_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (EPHY_IS_WINDOW (window), NULL);
- return GTK_WIDGET (ephy_embed_get_find_toolbar (window->active_embed));
+ return GTK_WIDGET (ephy_embed_get_find_toolbar (window->active_embed));
}
/**
@@ -3550,11 +3402,11 @@ ephy_window_get_current_find_toolbar (EphyWindow *window)
**/
void
ephy_window_load_url (EphyWindow *window,
- const char *url)
+ const char *url)
{
- g_return_if_fail (url != NULL);
+ g_return_if_fail (url != NULL);
- ephy_link_open (EPHY_LINK (window), url, NULL, 0);
+ ephy_link_open (EPHY_LINK (window), url, NULL, 0);
}
/**
@@ -3566,16 +3418,16 @@ ephy_window_load_url (EphyWindow *window,
void
ephy_window_activate_location (EphyWindow *window)
{
- GtkWidget *entry;
+ GtkWidget *entry;
- if (!(window->chrome & EPHY_WINDOW_CHROME_LOCATION))
- return;
+ if (!(window->chrome & EPHY_WINDOW_CHROME_LOCATION))
+ return;
- ephy_title_box_set_mode (ephy_toolbar_get_title_box (EPHY_TOOLBAR (window->toolbar)),
- EPHY_TITLE_BOX_MODE_LOCATION_ENTRY);
+ ephy_title_box_set_mode (ephy_toolbar_get_title_box (EPHY_TOOLBAR (window->toolbar)),
+ EPHY_TITLE_BOX_MODE_LOCATION_ENTRY);
- entry = ephy_toolbar_get_location_entry (EPHY_TOOLBAR (window->toolbar));
- ephy_location_entry_activate (EPHY_LOCATION_ENTRY (entry));
+ entry = ephy_toolbar_get_location_entry (EPHY_TOOLBAR (window->toolbar));
+ ephy_location_entry_activate (EPHY_LOCATION_ENTRY (entry));
}
/**
@@ -3588,58 +3440,51 @@ ephy_window_activate_location (EphyWindow *window)
**/
void
ephy_window_set_zoom (EphyWindow *window,
- float zoom)
+ float zoom)
{
- EphyEmbed *embed;
- double current_zoom = 1.0;
- WebKitWebView *web_view;
+ EphyEmbed *embed;
+ double current_zoom = 1.0;
+ WebKitWebView *web_view;
- g_return_if_fail (EPHY_IS_WINDOW (window));
+ g_return_if_fail (EPHY_IS_WINDOW (window));
- embed = window->active_embed;
- g_return_if_fail (embed != NULL);
+ embed = window->active_embed;
+ g_return_if_fail (embed != NULL);
- web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
+ web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
- current_zoom = webkit_web_view_get_zoom_level (web_view);
+ current_zoom = webkit_web_view_get_zoom_level (web_view);
- if (zoom == ZOOM_IN)
- {
- zoom = ephy_zoom_get_changed_zoom_level (current_zoom, 1);
- }
- else if (zoom == ZOOM_OUT)
- {
- zoom = ephy_zoom_get_changed_zoom_level (current_zoom, -1);
- }
+ if (zoom == ZOOM_IN) {
+ zoom = ephy_zoom_get_changed_zoom_level (current_zoom, 1);
+ } else if (zoom == ZOOM_OUT) {
+ zoom = ephy_zoom_get_changed_zoom_level (current_zoom, -1);
+ }
- if (zoom != current_zoom)
- {
- webkit_web_view_set_zoom_level (web_view, zoom);
- }
+ if (zoom != current_zoom) {
+ webkit_web_view_set_zoom_level (web_view, zoom);
+ }
}
static void
-ephy_window_view_popup_windows_cb (GtkAction *action,
- EphyWindow *window)
+ephy_window_view_popup_windows_cb (GtkAction *action,
+ EphyWindow *window)
{
- EphyEmbed *embed;
- gboolean allow;
+ EphyEmbed *embed;
+ gboolean allow;
- g_return_if_fail (EPHY_IS_WINDOW (window));
+ g_return_if_fail (EPHY_IS_WINDOW (window));
- embed = window->active_embed;
- g_return_if_fail (EPHY_IS_EMBED (embed));
+ embed = window->active_embed;
+ g_return_if_fail (EPHY_IS_EMBED (embed));
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
- {
- allow = TRUE;
- }
- else
- {
- allow = FALSE;
- }
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
+ allow = TRUE;
+ } else {
+ allow = FALSE;
+ }
- g_object_set (G_OBJECT (ephy_embed_get_web_view (embed)), "popups-allowed", allow, NULL);
+ g_object_set (G_OBJECT (ephy_embed_get_web_view (embed)), "popups-allowed", allow, NULL);
}
/**
@@ -3654,9 +3499,9 @@ ephy_window_view_popup_windows_cb (GtkAction *action,
EphyEmbedEvent *
ephy_window_get_context_event (EphyWindow *window)
{
- g_return_val_if_fail (EPHY_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (EPHY_IS_WINDOW (window), NULL);
- return window->context_event;
+ return window->context_event;
}
/**
@@ -3670,7 +3515,7 @@ ephy_window_get_context_event (EphyWindow *window)
const char *
ephy_window_get_location (EphyWindow *window)
{
- return ephy_location_controller_get_address (window->location_controller);
+ return ephy_location_controller_get_address (window->location_controller);
}
/**
@@ -3682,46 +3527,46 @@ ephy_window_get_location (EphyWindow *window)
**/
void
ephy_window_set_location (EphyWindow *window,
- const char *address)
+ const char *address)
{
- if (window->updating_address) return;
+ if (window->updating_address) return;
- window->updating_address = TRUE;
- ephy_location_controller_set_address (window->location_controller, address);
- window->updating_address = FALSE;
+ window->updating_address = TRUE;
+ ephy_location_controller_set_address (window->location_controller, address);
+ window->updating_address = FALSE;
}
/**
* ephy_window_get_toolbar_action_group:
* @window: an #EphyWindow
- *
+ *
* Returns the toolbar #GtkActionGroup for this @window
- *
+ *
* Returns: (transfer none): the #GtkActionGroup for this @window's
* toolbar actions
**/
GtkActionGroup *
ephy_window_get_toolbar_action_group (EphyWindow *window)
{
- g_return_val_if_fail (EPHY_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (EPHY_IS_WINDOW (window), NULL);
- return window->toolbar_action_group;
+ return window->toolbar_action_group;
}
/**
* ephy_window_get_location_controller:
* @window: an #EphyWindow
- *
+ *
* Returns the @window #EphyLocationController
- *
+ *
* Returns: (transfer none): the @window #EphyLocationController
**/
EphyLocationController *
ephy_window_get_location_controller (EphyWindow *window)
{
- g_return_val_if_fail (EPHY_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (EPHY_IS_WINDOW (window), NULL);
- return window->location_controller;
+ return window->location_controller;
}
/**
@@ -3735,119 +3580,116 @@ ephy_window_get_location_controller (EphyWindow *window)
gboolean
ephy_window_is_on_current_workspace (EphyWindow *window)
{
- GdkWindow *gdk_window = NULL;
- WnckWorkspace *workspace = NULL;
- WnckWindow *wnck_window = NULL;
+ GdkWindow *gdk_window = NULL;
+ WnckWorkspace *workspace = NULL;
+ WnckWindow *wnck_window = NULL;
- if (!gtk_widget_get_realized (GTK_WIDGET (window)))
- return TRUE;
+ if (!gtk_widget_get_realized (GTK_WIDGET (window)))
+ return TRUE;
- gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
+ gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
- if(!GDK_IS_X11_WINDOW (gdk_window))
- return TRUE;
+ if (!GDK_IS_X11_WINDOW (gdk_window))
+ return TRUE;
- workspace = wnck_screen_get_active_workspace (wnck_screen_get_default ());
+ workspace = wnck_screen_get_active_workspace (wnck_screen_get_default ());
- /* From WNCK docs:
- * "May return NULL sometimes, if libwnck is in a weird state due to
- * the asynchronous nature of the interaction with the window manager."
- * In such a case we cannot really check, so assume we are.
- */
- if (!workspace)
- return TRUE;
+ /* From WNCK docs:
+ * "May return NULL sometimes, if libwnck is in a weird state due to
+ * the asynchronous nature of the interaction with the window manager."
+ * In such a case we cannot really check, so assume we are.
+ */
+ if (!workspace)
+ return TRUE;
- wnck_window = wnck_window_get (GDK_WINDOW_XID (gdk_window));
+ wnck_window = wnck_window_get (GDK_WINDOW_XID (gdk_window));
- return wnck_window_is_on_workspace (wnck_window, workspace);
+ return wnck_window_is_on_workspace (wnck_window, workspace);
}
typedef struct {
- EphyWindow *window;
- GCancellable *cancellable;
+ EphyWindow *window;
+ GCancellable *cancellable;
- guint embeds_to_check;
- EphyEmbed *modified_embed;
+ guint embeds_to_check;
+ EphyEmbed *modified_embed;
} ModifiedFormsData;
static void
modified_forms_data_free (ModifiedFormsData *data)
{
- g_object_unref (data->cancellable);
+ g_object_unref (data->cancellable);
- g_slice_free (ModifiedFormsData, data);
+ g_slice_free (ModifiedFormsData, data);
}
static void
continue_window_close_after_modified_forms_check (ModifiedFormsData *data)
{
- gboolean should_close;
+ gboolean should_close;
- data->window->checking_modified_forms = FALSE;
+ data->window->checking_modified_forms = FALSE;
- if (data->modified_embed)
- {
- /* jump to the first tab with modified forms */
- impl_set_active_child (EPHY_EMBED_CONTAINER (data->window),
- data->modified_embed);
- if (!confirm_close_with_modified_forms (data->window))
- return;
- }
+ if (data->modified_embed) {
+ /* jump to the first tab with modified forms */
+ impl_set_active_child (EPHY_EMBED_CONTAINER (data->window),
+ data->modified_embed);
+ if (!confirm_close_with_modified_forms (data->window))
+ return;
+ }
- data->window->force_close = TRUE;
- should_close = ephy_window_close (data->window);
- data->window->force_close = FALSE;
- if (should_close)
- gtk_widget_destroy (GTK_WIDGET (data->window));
+ data->window->force_close = TRUE;
+ should_close = ephy_window_close (data->window);
+ data->window->force_close = FALSE;
+ if (should_close)
+ gtk_widget_destroy (GTK_WIDGET (data->window));
}
static void
-has_modified_forms_cb (EphyWebView *view,
- GAsyncResult *result,
- ModifiedFormsData *data)
+has_modified_forms_cb (EphyWebView *view,
+ GAsyncResult *result,
+ ModifiedFormsData *data)
{
- gboolean has_modified_forms;
+ gboolean has_modified_forms;
- data->embeds_to_check--;
- has_modified_forms = ephy_web_view_has_modified_forms_finish (view, result, NULL);
- if (has_modified_forms)
- {
- /* Cancel all others */
- g_cancellable_cancel (data->cancellable);
- data->modified_embed = EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (view);
- }
+ data->embeds_to_check--;
+ has_modified_forms = ephy_web_view_has_modified_forms_finish (view, result, NULL);
+ if (has_modified_forms) {
+ /* Cancel all others */
+ g_cancellable_cancel (data->cancellable);
+ data->modified_embed = EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (view);
+ }
- if (data->embeds_to_check > 0)
- return;
+ if (data->embeds_to_check > 0)
+ return;
- continue_window_close_after_modified_forms_check (data);
- modified_forms_data_free (data);
+ continue_window_close_after_modified_forms_check (data);
+ modified_forms_data_free (data);
}
static void
ephy_window_check_modified_forms (EphyWindow *window)
{
- GList *tabs, *l;
- ModifiedFormsData *data;
+ GList *tabs, *l;
+ ModifiedFormsData *data;
- window->checking_modified_forms = TRUE;
+ window->checking_modified_forms = TRUE;
- data = g_slice_new0 (ModifiedFormsData);
- data->window = window;
- data->cancellable = g_cancellable_new ();
- data->embeds_to_check = gtk_notebook_get_n_pages (window->notebook);
+ data = g_slice_new0 (ModifiedFormsData);
+ data->window = window;
+ data->cancellable = g_cancellable_new ();
+ data->embeds_to_check = gtk_notebook_get_n_pages (window->notebook);
- tabs = impl_get_children (EPHY_EMBED_CONTAINER (window));
- for (l = tabs; l != NULL; l = l->next)
- {
- EphyEmbed *embed = (EphyEmbed *) l->data;
+ tabs = impl_get_children (EPHY_EMBED_CONTAINER (window));
+ for (l = tabs; l != NULL; l = l->next) {
+ EphyEmbed *embed = (EphyEmbed *)l->data;
- ephy_web_view_has_modified_forms (ephy_embed_get_web_view (embed),
- data->cancellable,
- (GAsyncReadyCallback)has_modified_forms_cb,
- data);
- }
- g_list_free (tabs);
+ ephy_web_view_has_modified_forms (ephy_embed_get_web_view (embed),
+ data->cancellable,
+ (GAsyncReadyCallback)has_modified_forms_cb,
+ data);
+ }
+ g_list_free (tabs);
}
/**
@@ -3863,51 +3705,48 @@ ephy_window_check_modified_forms (EphyWindow *window)
gboolean
ephy_window_close (EphyWindow *window)
{
- /* We ignore the delete_event if the disable_quit lockdown has been set
- */
- if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
- EPHY_PREFS_LOCKDOWN_QUIT)) return FALSE;
-
- if (window->checking_modified_forms) {
- /* stop window close */
- return FALSE;
- }
-
- if (!window->force_close &&
- g_settings_get_boolean (EPHY_SETTINGS_MAIN,
- EPHY_PREFS_WARN_ON_CLOSE_UNSUBMITTED_DATA) &&
- gtk_notebook_get_n_pages (window->notebook) > 0)
- {
- ephy_window_check_modified_forms (window);
- /* stop window close */
- return FALSE;
- }
-
- /* If this is the last window, check ongoing downloads and save its state in the session. */
- if (ephy_shell_get_n_windows (ephy_shell_get_default ()) == 1)
- {
- EphyDownloadsManager *manager = ephy_embed_shell_get_downloads_manager (EPHY_EMBED_SHELL
(ephy_shell_get_default ()));
-
- if (ephy_downloads_manager_has_active_downloads (manager) &&
- !confirm_close_with_downloads (window))
- {
- /* stop window close */
- return FALSE;
- }
+ /* We ignore the delete_event if the disable_quit lockdown has been set
+ */
+ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_QUIT)) return FALSE;
+
+ if (window->checking_modified_forms) {
+ /* stop window close */
+ return FALSE;
+ }
+
+ if (!window->force_close &&
+ g_settings_get_boolean (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_WARN_ON_CLOSE_UNSUBMITTED_DATA) &&
+ gtk_notebook_get_n_pages (window->notebook) > 0) {
+ ephy_window_check_modified_forms (window);
+ /* stop window close */
+ return FALSE;
+ }
+
+ /* If this is the last window, check ongoing downloads and save its state in the session. */
+ if (ephy_shell_get_n_windows (ephy_shell_get_default ()) == 1) {
+ EphyDownloadsManager *manager = ephy_embed_shell_get_downloads_manager (EPHY_EMBED_SHELL
(ephy_shell_get_default ()));
+
+ if (ephy_downloads_manager_has_active_downloads (manager) &&
+ !confirm_close_with_downloads (window)) {
+ /* stop window close */
+ return FALSE;
+ }
- ephy_session_close (ephy_shell_get_session (ephy_shell_get_default ()));
- }
+ ephy_session_close (ephy_shell_get_session (ephy_shell_get_default ()));
+ }
- /* See bug #114689 */
- gtk_widget_hide (GTK_WIDGET (window));
+ /* See bug #114689 */
+ gtk_widget_hide (GTK_WIDGET (window));
- return TRUE;
+ return TRUE;
}
EphyWindowChrome
ephy_window_get_chrome (EphyWindow *window)
{
- g_return_val_if_fail (EPHY_IS_WINDOW (window), EPHY_WINDOW_CHROME_DEFAULT);
+ g_return_val_if_fail (EPHY_IS_WINDOW (window), EPHY_WINDOW_CHROME_DEFAULT);
- return window->chrome;
+ return window->chrome;
}
diff --git a/src/passwords-dialog.c b/src/passwords-dialog.c
index ab51b23..649f043 100644
--- a/src/passwords-dialog.c
+++ b/src/passwords-dialog.c
@@ -29,13 +29,12 @@
#include "ephy-string.h"
#include "passwords-dialog.h"
-typedef enum
-{
- COL_PASSWORDS_HOST,
- COL_PASSWORDS_USER,
- COL_PASSWORDS_PASSWORD,
- COL_PASSWORDS_INVISIBLE,
- COL_PASSWORDS_DATA,
+typedef enum {
+ COL_PASSWORDS_HOST,
+ COL_PASSWORDS_USER,
+ COL_PASSWORDS_PASSWORD,
+ COL_PASSWORDS_INVISIBLE,
+ COL_PASSWORDS_DATA,
} PasswordsDialogColumn;
#define URI_KEY "uri"
@@ -43,27 +42,26 @@ typedef enum
#define FORM_PASSWORD_KEY "form_password"
#define USERNAME_KEY "username"
-struct _EphyPasswordsDialog
-{
- GtkDialog parent_instance;
+struct _EphyPasswordsDialog {
+ GtkDialog parent_instance;
- GtkWidget *passwords_treeview;
- GtkTreeSelection *tree_selection;
- GtkWidget *liststore;
- GtkWidget *treemodelfilter;
- GtkWidget *treemodelsort;
- GtkWidget *show_passwords_button;
- GtkWidget *password_column;
- GtkWidget *password_renderer;
- GMenuModel *treeview_popup_menu_model;
+ GtkWidget *passwords_treeview;
+ GtkTreeSelection *tree_selection;
+ GtkWidget *liststore;
+ GtkWidget *treemodelfilter;
+ GtkWidget *treemodelsort;
+ GtkWidget *show_passwords_button;
+ GtkWidget *password_column;
+ GtkWidget *password_renderer;
+ GMenuModel *treeview_popup_menu_model;
- GActionGroup *action_group;
+ GActionGroup *action_group;
- SecretService *ss;
- GCancellable *ss_cancellable;
- gboolean filled;
+ SecretService *ss;
+ GCancellable *ss_cancellable;
+ gboolean filled;
- char *search_text;
+ char *search_text;
};
G_DEFINE_TYPE (EphyPasswordsDialog, ephy_passwords_dialog, GTK_TYPE_DIALOG)
@@ -73,26 +71,26 @@ static void populate_model (EphyPasswordsDialog *dialog);
static void
reload_model (EphyPasswordsDialog *dialog)
{
- gtk_list_store_clear (GTK_LIST_STORE (dialog->liststore));
- dialog->filled = FALSE;
- populate_model (dialog);
+ gtk_list_store_clear (GTK_LIST_STORE (dialog->liststore));
+ dialog->filled = FALSE;
+ populate_model (dialog);
}
static void
ephy_passwords_dialog_dispose (GObject *object)
{
- EphyPasswordsDialog *dialog = EPHY_PASSWORDS_DIALOG (object);
+ EphyPasswordsDialog *dialog = EPHY_PASSWORDS_DIALOG (object);
- if (dialog->ss_cancellable != NULL) {
- g_cancellable_cancel (dialog->ss_cancellable);
- g_clear_object (&(dialog->ss_cancellable));
- }
+ if (dialog->ss_cancellable != NULL) {
+ g_cancellable_cancel (dialog->ss_cancellable);
+ g_clear_object (&(dialog->ss_cancellable));
+ }
- g_clear_object (&(dialog->ss));
- g_free (dialog->search_text);
- dialog->search_text = NULL;
+ g_clear_object (&(dialog->ss));
+ g_free (dialog->search_text);
+ dialog->search_text = NULL;
- G_OBJECT_CLASS (ephy_passwords_dialog_parent_class)->dispose (object);
+ G_OBJECT_CLASS (ephy_passwords_dialog_parent_class)->dispose (object);
}
static void
@@ -100,224 +98,215 @@ secret_remove_ready_cb (GObject *source,
GAsyncResult *res,
EphyPasswordsDialog *dialog)
{
- secret_item_delete_finish (SECRET_ITEM (source), res, NULL);
+ secret_item_delete_finish (SECRET_ITEM (source), res, NULL);
}
static void
secret_remove (EphyPasswordsDialog *dialog,
SecretItem *item)
{
- secret_item_delete (item, NULL, (GAsyncReadyCallback)secret_remove_ready_cb, dialog);
+ secret_item_delete (item, NULL, (GAsyncReadyCallback)secret_remove_ready_cb, dialog);
}
static void
-forget (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+forget (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
- EphyPasswordsDialog *dialog = EPHY_PASSWORDS_DIALOG (user_data);
- GList *llist, *rlist = NULL, *l, *r;
- GtkTreeModel *model;
- GtkTreePath *path;
- GtkTreeIter iter, iter2;
- GtkTreeRowReference *row_ref = NULL;
-
- llist = gtk_tree_selection_get_selected_rows (dialog->tree_selection, &model);
-
- if (llist == NULL)
- {
- /* nothing to delete, return early */
- return;
- }
-
- for (l = llist; l != NULL; l = l->next)
- {
- rlist = g_list_prepend (rlist, gtk_tree_row_reference_new (model, (GtkTreePath *)l->data));
- }
-
- /* Intelligent selection logic, no actual selection yet */
-
- path = gtk_tree_row_reference_get_path ((GtkTreeRowReference *) g_list_first (rlist)->data);
-
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_path_free (path);
- iter2 = iter;
-
- if (gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter))
- {
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
- row_ref = gtk_tree_row_reference_new (model, path);
- }
- else
- {
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter2);
- if (gtk_tree_path_prev (path))
- {
- row_ref = gtk_tree_row_reference_new (model, path);
- }
- }
- gtk_tree_path_free (path);
-
- /* Removal */
- for (r = rlist; r != NULL; r = r->next)
- {
- GValue val = { 0, };
- SecretItem *item;
- GtkTreeIter filter_iter;
- GtkTreeIter child_iter;
-
- path = gtk_tree_row_reference_get_path ((GtkTreeRowReference *)r->data);
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_model_get_value (model, &iter, COL_PASSWORDS_DATA, &val);
- item = g_value_get_object (&val);
- secret_remove (dialog, item);
- g_value_unset (&val);
-
- gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (dialog->treemodelsort),
- &filter_iter,
- &iter);
-
- gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER
(dialog->treemodelfilter),
- &child_iter,
- &filter_iter);
-
- gtk_list_store_remove (GTK_LIST_STORE (dialog->liststore), &child_iter);
-
- gtk_tree_row_reference_free ((GtkTreeRowReference *)r->data);
- gtk_tree_path_free (path);
- }
-
- g_list_foreach (llist, (GFunc)gtk_tree_path_free, NULL);
- g_list_free (llist);
- g_list_free (rlist);
-
- /* Selection */
- if (row_ref != NULL)
- {
- path = gtk_tree_row_reference_get_path (row_ref);
-
- if (path != NULL)
- {
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (dialog->passwords_treeview), path, NULL,
FALSE);
- gtk_tree_path_free (path);
- }
-
- gtk_tree_row_reference_free (row_ref);
- }
+ EphyPasswordsDialog *dialog = EPHY_PASSWORDS_DIALOG (user_data);
+ GList *llist, *rlist = NULL, *l, *r;
+ GtkTreeModel *model;
+ GtkTreePath *path;
+ GtkTreeIter iter, iter2;
+ GtkTreeRowReference *row_ref = NULL;
+
+ llist = gtk_tree_selection_get_selected_rows (dialog->tree_selection, &model);
+
+ if (llist == NULL) {
+ /* nothing to delete, return early */
+ return;
+ }
+
+ for (l = llist; l != NULL; l = l->next) {
+ rlist = g_list_prepend (rlist, gtk_tree_row_reference_new (model, (GtkTreePath *)l->data));
+ }
+
+ /* Intelligent selection logic, no actual selection yet */
+
+ path = gtk_tree_row_reference_get_path ((GtkTreeRowReference *)g_list_first (rlist)->data);
+
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_path_free (path);
+ iter2 = iter;
+
+ if (gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter)) {
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
+ row_ref = gtk_tree_row_reference_new (model, path);
+ } else {
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter2);
+ if (gtk_tree_path_prev (path)) {
+ row_ref = gtk_tree_row_reference_new (model, path);
+ }
+ }
+ gtk_tree_path_free (path);
+
+ /* Removal */
+ for (r = rlist; r != NULL; r = r->next) {
+ GValue val = { 0, };
+ SecretItem *item;
+ GtkTreeIter filter_iter;
+ GtkTreeIter child_iter;
+
+ path = gtk_tree_row_reference_get_path ((GtkTreeRowReference *)r->data);
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get_value (model, &iter, COL_PASSWORDS_DATA, &val);
+ item = g_value_get_object (&val);
+ secret_remove (dialog, item);
+ g_value_unset (&val);
+
+ gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (dialog->treemodelsort),
+ &filter_iter,
+ &iter);
+
+ gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (dialog->treemodelfilter),
+ &child_iter,
+ &filter_iter);
+
+ gtk_list_store_remove (GTK_LIST_STORE (dialog->liststore), &child_iter);
+
+ gtk_tree_row_reference_free ((GtkTreeRowReference *)r->data);
+ gtk_tree_path_free (path);
+ }
+
+ g_list_foreach (llist, (GFunc)gtk_tree_path_free, NULL);
+ g_list_free (llist);
+ g_list_free (rlist);
+
+ /* Selection */
+ if (row_ref != NULL) {
+ path = gtk_tree_row_reference_get_path (row_ref);
+
+ if (path != NULL) {
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (dialog->passwords_treeview), path, NULL, FALSE);
+ gtk_tree_path_free (path);
+ }
+
+ gtk_tree_row_reference_free (row_ref);
+ }
}
static void
-show_passwords (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+show_passwords (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
- EphyPasswordsDialog *dialog = EPHY_PASSWORDS_DIALOG (user_data);
- gboolean active;
+ EphyPasswordsDialog *dialog = EPHY_PASSWORDS_DIALOG (user_data);
+ gboolean active;
- active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->show_passwords_button));
+ active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->show_passwords_button));
- gtk_tree_view_column_set_attributes (GTK_TREE_VIEW_COLUMN (dialog->password_column),
- GTK_CELL_RENDERER (dialog->password_renderer),
- "text", (active ? COL_PASSWORDS_PASSWORD :
COL_PASSWORDS_INVISIBLE),
- NULL);
- gtk_widget_queue_draw (dialog->passwords_treeview);
+ gtk_tree_view_column_set_attributes (GTK_TREE_VIEW_COLUMN (dialog->password_column),
+ GTK_CELL_RENDERER (dialog->password_renderer),
+ "text", (active ? COL_PASSWORDS_PASSWORD : COL_PASSWORDS_INVISIBLE),
+ NULL);
+ gtk_widget_queue_draw (dialog->passwords_treeview);
}
static void
update_selection_actions (GActionMap *action_map,
gboolean has_selection)
{
- GAction *forget_action;
+ GAction *forget_action;
- forget_action = g_action_map_lookup_action (action_map, "forget");
- g_simple_action_set_enabled (G_SIMPLE_ACTION (forget_action), has_selection);
+ forget_action = g_action_map_lookup_action (action_map, "forget");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (forget_action), has_selection);
}
static void
on_treeview_selection_changed (GtkTreeSelection *selection,
EphyPasswordsDialog *dialog)
{
- update_selection_actions (G_ACTION_MAP (dialog->action_group),
- gtk_tree_selection_count_selected_rows (selection) > 0);
+ update_selection_actions (G_ACTION_MAP (dialog->action_group),
+ gtk_tree_selection_count_selected_rows (selection) > 0);
}
static void
on_search_entry_changed (GtkSearchEntry *entry,
EphyPasswordsDialog *dialog)
{
- const char *text;
+ const char *text;
- text = gtk_entry_get_text (GTK_ENTRY (entry));
- g_free (dialog->search_text);
- dialog->search_text = g_strdup (text);
- gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (dialog->treemodelfilter));
+ text = gtk_entry_get_text (GTK_ENTRY (entry));
+ g_free (dialog->search_text);
+ dialog->search_text = g_strdup (text);
+ gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (dialog->treemodelfilter));
}
static char *
-get_selected_item (EphyPasswordsDialog *dialog,
- PasswordsDialogColumn column)
+get_selected_item (EphyPasswordsDialog *dialog,
+ PasswordsDialogColumn column)
{
- GtkTreeModel *model;
- GList *selected;
- GtkTreeIter iter;
- char *value;
-
- selected = gtk_tree_selection_get_selected_rows (dialog->tree_selection, &model);
- gtk_tree_model_get_iter (model, &iter, selected->data);
- gtk_tree_model_get (model, &iter,
- column, &value,
- -1);
- g_list_free_full (selected, (GDestroyNotify) gtk_tree_path_free);
-
- return value;
+ GtkTreeModel *model;
+ GList *selected;
+ GtkTreeIter iter;
+ char *value;
+
+ selected = gtk_tree_selection_get_selected_rows (dialog->tree_selection, &model);
+ gtk_tree_model_get_iter (model, &iter, selected->data);
+ gtk_tree_model_get (model, &iter,
+ column, &value,
+ -1);
+ g_list_free_full (selected, (GDestroyNotify)gtk_tree_path_free);
+
+ return value;
}
static void
-copy_password (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+copy_password (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
- EphyPasswordsDialog *dialog = EPHY_PASSWORDS_DIALOG (user_data);
- char *password;
-
- password = get_selected_item (dialog, COL_PASSWORDS_PASSWORD);
- if (password != NULL) {
- gtk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (dialog),
- GDK_SELECTION_CLIPBOARD),
- password, -1);
- }
- g_free (password);
+ EphyPasswordsDialog *dialog = EPHY_PASSWORDS_DIALOG (user_data);
+ char *password;
+
+ password = get_selected_item (dialog, COL_PASSWORDS_PASSWORD);
+ if (password != NULL) {
+ gtk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (dialog),
+ GDK_SELECTION_CLIPBOARD),
+ password, -1);
+ }
+ g_free (password);
}
static void
-copy_username (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+copy_username (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
- EphyPasswordsDialog *dialog = EPHY_PASSWORDS_DIALOG (user_data);
- char *username;
-
- username = get_selected_item (dialog, COL_PASSWORDS_USER);
- if (username != NULL) {
- gtk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (dialog),
- GDK_SELECTION_CLIPBOARD),
- username, -1);
- }
- g_free (username);
+ EphyPasswordsDialog *dialog = EPHY_PASSWORDS_DIALOG (user_data);
+ char *username;
+
+ username = get_selected_item (dialog, COL_PASSWORDS_USER);
+ if (username != NULL) {
+ gtk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (dialog),
+ GDK_SELECTION_CLIPBOARD),
+ username, -1);
+ }
+ g_free (username);
}
static void
update_popup_menu_actions (GActionGroup *action_group,
gboolean only_one_selected_item)
{
- GAction *copy_password_action;
- GAction *copy_username_action;
+ GAction *copy_password_action;
+ GAction *copy_username_action;
- copy_password_action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "copy-password");
- copy_username_action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "copy-username");
+ copy_password_action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "copy-password");
+ copy_username_action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "copy-username");
- g_simple_action_set_enabled (G_SIMPLE_ACTION (copy_password_action), only_one_selected_item);
- g_simple_action_set_enabled (G_SIMPLE_ACTION (copy_username_action), only_one_selected_item);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (copy_password_action), only_one_selected_item);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (copy_username_action), only_one_selected_item);
}
static gboolean
@@ -325,49 +314,49 @@ on_passwords_treeview_button_press_event (GtkWidget *widget,
GdkEventButton *event,
EphyPasswordsDialog *dialog)
{
- if (event->button == 3) {
- int n;
- GtkWidget *menu;
+ if (event->button == 3) {
+ int n;
+ GtkWidget *menu;
- n = gtk_tree_selection_count_selected_rows (dialog->tree_selection);
- if (n == 0)
- return FALSE;
+ n = gtk_tree_selection_count_selected_rows (dialog->tree_selection);
+ if (n == 0)
+ return FALSE;
- update_popup_menu_actions (dialog->action_group, (n == 1));
+ update_popup_menu_actions (dialog->action_group, (n == 1));
- menu = gtk_menu_new_from_model (dialog->treeview_popup_menu_model);
- gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (dialog), NULL);
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time);
- return TRUE;
- }
+ menu = gtk_menu_new_from_model (dialog->treeview_popup_menu_model);
+ gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (dialog), NULL);
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time);
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
static void
ephy_passwords_dialog_class_init (EphyPasswordsDialogClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
- object_class->dispose = ephy_passwords_dialog_dispose;
-
- gtk_widget_class_set_template_from_resource (widget_class,
- "/org/gnome/epiphany/passwords-dialog.ui");
-
- gtk_widget_class_bind_template_child (widget_class, EphyPasswordsDialog, liststore);
- gtk_widget_class_bind_template_child (widget_class, EphyPasswordsDialog, treemodelfilter);
- gtk_widget_class_bind_template_child (widget_class, EphyPasswordsDialog, treemodelsort);
- gtk_widget_class_bind_template_child (widget_class, EphyPasswordsDialog, passwords_treeview);
- gtk_widget_class_bind_template_child (widget_class, EphyPasswordsDialog, tree_selection);
- gtk_widget_class_bind_template_child (widget_class, EphyPasswordsDialog, show_passwords_button);
- gtk_widget_class_bind_template_child (widget_class, EphyPasswordsDialog, password_column);
- gtk_widget_class_bind_template_child (widget_class, EphyPasswordsDialog, password_renderer);
- gtk_widget_class_bind_template_child (widget_class, EphyPasswordsDialog, treeview_popup_menu_model);
-
- gtk_widget_class_bind_template_callback (widget_class, on_passwords_treeview_button_press_event);
- gtk_widget_class_bind_template_callback (widget_class, on_treeview_selection_changed);
- gtk_widget_class_bind_template_callback (widget_class, on_search_entry_changed);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->dispose = ephy_passwords_dialog_dispose;
+
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/epiphany/passwords-dialog.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, EphyPasswordsDialog, liststore);
+ gtk_widget_class_bind_template_child (widget_class, EphyPasswordsDialog, treemodelfilter);
+ gtk_widget_class_bind_template_child (widget_class, EphyPasswordsDialog, treemodelsort);
+ gtk_widget_class_bind_template_child (widget_class, EphyPasswordsDialog, passwords_treeview);
+ gtk_widget_class_bind_template_child (widget_class, EphyPasswordsDialog, tree_selection);
+ gtk_widget_class_bind_template_child (widget_class, EphyPasswordsDialog, show_passwords_button);
+ gtk_widget_class_bind_template_child (widget_class, EphyPasswordsDialog, password_column);
+ gtk_widget_class_bind_template_child (widget_class, EphyPasswordsDialog, password_renderer);
+ gtk_widget_class_bind_template_child (widget_class, EphyPasswordsDialog, treeview_popup_menu_model);
+
+ gtk_widget_class_bind_template_callback (widget_class, on_passwords_treeview_button_press_event);
+ gtk_widget_class_bind_template_callback (widget_class, on_treeview_selection_changed);
+ gtk_widget_class_bind_template_callback (widget_class, on_search_entry_changed);
}
static void
@@ -375,26 +364,26 @@ delete_all_passwords_ready_cb (GObject *source_object,
GAsyncResult *res,
EphyPasswordsDialog *dialog)
{
- secret_service_clear_finish (dialog->ss, res, NULL);
- reload_model (dialog);
+ secret_service_clear_finish (dialog->ss, res, NULL);
+ reload_model (dialog);
}
static void
-forget_all (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+forget_all (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
- EphyPasswordsDialog *dialog = EPHY_PASSWORDS_DIALOG (user_data);
- GHashTable *attributes;
-
- attributes = secret_attributes_build (EPHY_FORM_PASSWORD_SCHEMA, NULL);
- secret_service_clear (dialog->ss,
- EPHY_FORM_PASSWORD_SCHEMA,
- attributes,
- dialog->ss_cancellable,
- (GAsyncReadyCallback)delete_all_passwords_ready_cb,
- dialog);
- g_hash_table_unref (attributes);
+ EphyPasswordsDialog *dialog = EPHY_PASSWORDS_DIALOG (user_data);
+ GHashTable *attributes;
+
+ attributes = secret_attributes_build (EPHY_FORM_PASSWORD_SCHEMA, NULL);
+ secret_service_clear (dialog->ss,
+ EPHY_FORM_PASSWORD_SCHEMA,
+ attributes,
+ dialog->ss_cancellable,
+ (GAsyncReadyCallback)delete_all_passwords_ready_cb,
+ dialog);
+ g_hash_table_unref (attributes);
}
static void
@@ -402,61 +391,61 @@ secrets_search_ready_cb (GObject *source_object,
GAsyncResult *res,
EphyPasswordsDialog *dialog)
{
- GList *matches;
- GList *l;
-
- matches = secret_service_search_finish (dialog->ss, res, NULL);
-
- for (l = matches; l != NULL; l = l->next) {
- SecretItem *item = l->data;
- SecretValue *value = NULL;
- GHashTable *attributes = NULL;
- const char *username = NULL;
- const char *password = NULL;
- char *host = NULL;
- GtkTreeIter iter;
-
- attributes = secret_item_get_attributes (item);
- username = g_hash_table_lookup (attributes, USERNAME_KEY);
- host = ephy_string_get_host_name (g_hash_table_lookup (attributes, URI_KEY));
- value = secret_item_get_secret (item);
- password = secret_value_get (value, NULL);
-
- gtk_list_store_insert_with_values (GTK_LIST_STORE (dialog->liststore),
- &iter,
- -1,
- COL_PASSWORDS_HOST, host,
- COL_PASSWORDS_USER, username,
- COL_PASSWORDS_PASSWORD, password,
- COL_PASSWORDS_INVISIBLE, "●●●●●●●●",
- COL_PASSWORDS_DATA, item,
- -1);
-
- g_free (host);
- g_hash_table_unref (attributes);
- }
-
- g_list_free_full (matches, g_object_unref);
+ GList *matches;
+ GList *l;
+
+ matches = secret_service_search_finish (dialog->ss, res, NULL);
+
+ for (l = matches; l != NULL; l = l->next) {
+ SecretItem *item = l->data;
+ SecretValue *value = NULL;
+ GHashTable *attributes = NULL;
+ const char *username = NULL;
+ const char *password = NULL;
+ char *host = NULL;
+ GtkTreeIter iter;
+
+ attributes = secret_item_get_attributes (item);
+ username = g_hash_table_lookup (attributes, USERNAME_KEY);
+ host = ephy_string_get_host_name (g_hash_table_lookup (attributes, URI_KEY));
+ value = secret_item_get_secret (item);
+ password = secret_value_get (value, NULL);
+
+ gtk_list_store_insert_with_values (GTK_LIST_STORE (dialog->liststore),
+ &iter,
+ -1,
+ COL_PASSWORDS_HOST, host,
+ COL_PASSWORDS_USER, username,
+ COL_PASSWORDS_PASSWORD, password,
+ COL_PASSWORDS_INVISIBLE, "●●●●●●●●",
+ COL_PASSWORDS_DATA, item,
+ -1);
+
+ g_free (host);
+ g_hash_table_unref (attributes);
+ }
+
+ g_list_free_full (matches, g_object_unref);
}
static void
populate_model (EphyPasswordsDialog *dialog)
{
- GHashTable *attributes;
+ GHashTable *attributes;
- g_assert (dialog->filled == FALSE);
+ g_assert (dialog->filled == FALSE);
- attributes = secret_attributes_build (EPHY_FORM_PASSWORD_SCHEMA, NULL);
+ attributes = secret_attributes_build (EPHY_FORM_PASSWORD_SCHEMA, NULL);
- secret_service_search (dialog->ss,
- EPHY_FORM_PASSWORD_SCHEMA,
- attributes,
- SECRET_SEARCH_ALL | SECRET_SEARCH_UNLOCK | SECRET_SEARCH_LOAD_SECRETS,
- dialog->ss_cancellable,
- (GAsyncReadyCallback)secrets_search_ready_cb,
- dialog);
+ secret_service_search (dialog->ss,
+ EPHY_FORM_PASSWORD_SCHEMA,
+ attributes,
+ SECRET_SEARCH_ALL | SECRET_SEARCH_UNLOCK | SECRET_SEARCH_LOAD_SECRETS,
+ dialog->ss_cancellable,
+ (GAsyncReadyCallback)secrets_search_ready_cb,
+ dialog);
- g_hash_table_unref (attributes);
+ g_hash_table_unref (attributes);
}
static void
@@ -464,8 +453,8 @@ secrets_ready_cb (GObject *source_object,
GAsyncResult *res,
EphyPasswordsDialog *dialog)
{
- dialog->ss = secret_service_get_finish (res, NULL);
- populate_model (dialog);
+ dialog->ss = secret_service_get_finish (res, NULL);
+ populate_model (dialog);
}
static gboolean
@@ -473,74 +462,74 @@ row_visible_func (GtkTreeModel *model,
GtkTreeIter *iter,
EphyPasswordsDialog *dialog)
{
- char *username;
- char *host;
- gboolean visible = FALSE;
+ char *username;
+ char *host;
+ gboolean visible = FALSE;
- if (dialog->search_text == NULL)
- return TRUE;
+ if (dialog->search_text == NULL)
+ return TRUE;
- gtk_tree_model_get (model, iter,
- COL_PASSWORDS_HOST, &host,
- COL_PASSWORDS_USER, &username,
- -1);
+ gtk_tree_model_get (model, iter,
+ COL_PASSWORDS_HOST, &host,
+ COL_PASSWORDS_USER, &username,
+ -1);
- if (host != NULL && g_strrstr (host, dialog->search_text) != NULL)
- visible = TRUE;
- else if (username != NULL && g_strrstr (username, dialog->search_text) != NULL)
- visible = TRUE;
+ if (host != NULL && g_strrstr (host, dialog->search_text) != NULL)
+ visible = TRUE;
+ else if (username != NULL && g_strrstr (username, dialog->search_text) != NULL)
+ visible = TRUE;
- g_free (host);
- g_free (username);
+ g_free (host);
+ g_free (username);
- return visible;
+ return visible;
}
static GActionGroup *
create_action_group (EphyPasswordsDialog *dialog)
{
- const GActionEntry entries[] = {
- { "copy-password", copy_password },
- { "copy-username", copy_username },
- { "forget", forget },
- { "forget-all", forget_all },
- { "show-passwords", show_passwords }
- };
+ const GActionEntry entries[] = {
+ { "copy-password", copy_password },
+ { "copy-username", copy_username },
+ { "forget", forget },
+ { "forget-all", forget_all },
+ { "show-passwords", show_passwords }
+ };
- GSimpleActionGroup *group;
+ GSimpleActionGroup *group;
- group = g_simple_action_group_new ();
- g_action_map_add_action_entries (G_ACTION_MAP (group), entries, G_N_ELEMENTS (entries), dialog);
+ group = g_simple_action_group_new ();
+ g_action_map_add_action_entries (G_ACTION_MAP (group), entries, G_N_ELEMENTS (entries), dialog);
- return G_ACTION_GROUP (group);
+ return G_ACTION_GROUP (group);
}
static void
ephy_passwords_dialog_init (EphyPasswordsDialog *dialog)
{
- gtk_widget_init_template (GTK_WIDGET (dialog));
+ gtk_widget_init_template (GTK_WIDGET (dialog));
- gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (dialog->treemodelfilter),
- (GtkTreeModelFilterVisibleFunc)row_visible_func,
- dialog,
- NULL);
+ gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (dialog->treemodelfilter),
+ (GtkTreeModelFilterVisibleFunc)row_visible_func,
+ dialog,
+ NULL);
- dialog->ss_cancellable = g_cancellable_new ();
- secret_service_get (SECRET_SERVICE_OPEN_SESSION | SECRET_SERVICE_LOAD_COLLECTIONS,
- dialog->ss_cancellable,
- (GAsyncReadyCallback)secrets_ready_cb,
- dialog);
+ dialog->ss_cancellable = g_cancellable_new ();
+ secret_service_get (SECRET_SERVICE_OPEN_SESSION | SECRET_SERVICE_LOAD_COLLECTIONS,
+ dialog->ss_cancellable,
+ (GAsyncReadyCallback)secrets_ready_cb,
+ dialog);
- dialog->action_group = create_action_group (dialog);
- gtk_widget_insert_action_group (GTK_WIDGET (dialog), "passwords", dialog->action_group);
+ dialog->action_group = create_action_group (dialog);
+ gtk_widget_insert_action_group (GTK_WIDGET (dialog), "passwords", dialog->action_group);
- update_selection_actions (G_ACTION_MAP (dialog->action_group), FALSE);
+ update_selection_actions (G_ACTION_MAP (dialog->action_group), FALSE);
}
EphyPasswordsDialog *
ephy_passwords_dialog_new (void)
{
- return g_object_new (EPHY_TYPE_PASSWORDS_DIALOG,
- "use-header-bar", TRUE,
- NULL);
+ return g_object_new (EPHY_TYPE_PASSWORDS_DIALOG,
+ "use-header-bar", TRUE,
+ NULL);
}
diff --git a/src/popup-commands.c b/src/popup-commands.c
index 1ed949c..3dc6e79 100644
--- a/src/popup-commands.c
+++ b/src/popup-commands.c
@@ -37,373 +37,367 @@
#include <webkit2/webkit2.h>
typedef enum {
- NEW_WINDOW,
- NEW_TAB
+ NEW_WINDOW,
+ NEW_TAB
} LinkDestination;
static void
-view_in_destination (EphyWindow *window,
- const char *property_name,
- LinkDestination destination)
+view_in_destination (EphyWindow *window,
+ const char *property_name,
+ LinkDestination destination)
{
- EphyEmbedEvent *event;
- GValue value = { 0, };
- EphyEmbed *embed;
- EphyEmbed *new_embed;
- EphyWebView *new_view;
- WebKitWebViewSessionState *session_state;
- EphyWindow *dest_window = window;
- EphyNewTabFlags flags = 0;
-
- event = ephy_window_get_context_event (window);
- g_return_if_fail (event != NULL);
-
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
- g_return_if_fail (embed != NULL);
-
- ephy_embed_event_get_property (event, property_name, &value);
- switch (destination) {
- case NEW_WINDOW:
- dest_window = ephy_window_new ();
- break;
- case NEW_TAB:
- flags |= EPHY_NEW_TAB_APPEND_AFTER;
- break;
- default:
- g_assert_not_reached();
- }
-
- new_embed = ephy_shell_new_tab (ephy_shell_get_default (),
- dest_window, embed, flags);
-
- new_view = ephy_embed_get_web_view (new_embed);
- session_state = webkit_web_view_get_session_state (WEBKIT_WEB_VIEW (ephy_embed_get_web_view (embed)));
- webkit_web_view_restore_session_state (WEBKIT_WEB_VIEW (new_view), session_state);
- webkit_web_view_session_state_unref (session_state);
- ephy_web_view_load_url (new_view, g_value_get_string (&value));
- g_value_unset (&value);
+ EphyEmbedEvent *event;
+ GValue value = { 0, };
+ EphyEmbed *embed;
+ EphyEmbed *new_embed;
+ EphyWebView *new_view;
+ WebKitWebViewSessionState *session_state;
+ EphyWindow *dest_window = window;
+ EphyNewTabFlags flags = 0;
+
+ event = ephy_window_get_context_event (window);
+ g_return_if_fail (event != NULL);
+
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+ g_return_if_fail (embed != NULL);
+
+ ephy_embed_event_get_property (event, property_name, &value);
+ switch (destination) {
+ case NEW_WINDOW:
+ dest_window = ephy_window_new ();
+ break;
+ case NEW_TAB:
+ flags |= EPHY_NEW_TAB_APPEND_AFTER;
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ new_embed = ephy_shell_new_tab (ephy_shell_get_default (),
+ dest_window, embed, flags);
+
+ new_view = ephy_embed_get_web_view (new_embed);
+ session_state = webkit_web_view_get_session_state (WEBKIT_WEB_VIEW (ephy_embed_get_web_view (embed)));
+ webkit_web_view_restore_session_state (WEBKIT_WEB_VIEW (new_view), session_state);
+ webkit_web_view_session_state_unref (session_state);
+ ephy_web_view_load_url (new_view, g_value_get_string (&value));
+ g_value_unset (&value);
}
void
-popup_cmd_link_in_new_window (GtkAction *action,
- EphyWindow *window)
+popup_cmd_link_in_new_window (GtkAction *action,
+ EphyWindow *window)
{
- view_in_destination (window, "link-uri", NEW_WINDOW);
+ view_in_destination (window, "link-uri", NEW_WINDOW);
}
void
-popup_cmd_media_in_new_window (GtkAction *action,
- EphyWindow *window)
+popup_cmd_media_in_new_window (GtkAction *action,
+ EphyWindow *window)
{
- view_in_destination (window, "media-uri", NEW_WINDOW);
+ view_in_destination (window, "media-uri", NEW_WINDOW);
}
void
-popup_cmd_bookmark_link (GtkAction *action,
- EphyWindow *window)
+popup_cmd_bookmark_link (GtkAction *action,
+ EphyWindow *window)
{
- EphyEmbedEvent *event;
- WebKitHitTestResult *result;
- const char *title;
- const char *location;
-
- event = ephy_window_get_context_event (window);
-
- result = ephy_embed_event_get_hit_test_result (event);
- if (!webkit_hit_test_result_context_is_link (result))
- {
- return;
- }
-
- location = webkit_hit_test_result_get_link_uri (result);
- title = webkit_hit_test_result_get_link_title (result);
- if (!title)
- {
- title = webkit_hit_test_result_get_link_label (result);
- }
-
- ephy_bookmarks_ui_add_bookmark (GTK_WINDOW (window), location, title);
+ EphyEmbedEvent *event;
+ WebKitHitTestResult *result;
+ const char *title;
+ const char *location;
+
+ event = ephy_window_get_context_event (window);
+
+ result = ephy_embed_event_get_hit_test_result (event);
+ if (!webkit_hit_test_result_context_is_link (result)) {
+ return;
+ }
+
+ location = webkit_hit_test_result_get_link_uri (result);
+ title = webkit_hit_test_result_get_link_title (result);
+ if (!title) {
+ title = webkit_hit_test_result_get_link_label (result);
+ }
+
+ ephy_bookmarks_ui_add_bookmark (GTK_WINDOW (window), location, title);
}
static void
popup_cmd_copy_to_clipboard (EphyWindow *window, const char *text)
{
- gtk_clipboard_set_text (gtk_clipboard_get (GDK_NONE),
- text, -1);
- gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_PRIMARY),
- text, -1);
+ gtk_clipboard_set_text (gtk_clipboard_get (GDK_NONE),
+ text, -1);
+ gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_PRIMARY),
+ text, -1);
}
void
-popup_cmd_copy_link_address (GtkAction *action,
- EphyWindow *window)
+popup_cmd_copy_link_address (GtkAction *action,
+ EphyWindow *window)
{
- EphyEmbedEvent *event;
- guint context;
- const char *address;
- GValue value = { 0, };
+ EphyEmbedEvent *event;
+ guint context;
+ const char *address;
+ GValue value = { 0, };
- event = ephy_window_get_context_event (window);
- g_return_if_fail (event != NULL);
+ event = ephy_window_get_context_event (window);
+ g_return_if_fail (event != NULL);
- context = ephy_embed_event_get_context (event);
+ context = ephy_embed_event_get_context (event);
- if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK)
- {
- ephy_embed_event_get_property (event, "link-uri", &value);
- address = g_value_get_string (&value);
+ if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK) {
+ ephy_embed_event_get_property (event, "link-uri", &value);
+ address = g_value_get_string (&value);
- if (g_str_has_prefix (address, "mailto:"))
- address = address + 7;
+ if (g_str_has_prefix (address, "mailto:"))
+ address = address + 7;
- popup_cmd_copy_to_clipboard (window, address);
- g_value_unset (&value);
- }
+ popup_cmd_copy_to_clipboard (window, address);
+ g_value_unset (&value);
+ }
}
static gboolean
cancel_download_idle_cb (EphyDownload *download)
{
- ephy_download_cancel (download);
+ ephy_download_cancel (download);
- return FALSE;
+ return FALSE;
}
typedef struct {
- char *title;
- EphyWindow *window;
+ char *title;
+ EphyWindow *window;
} SavePropertyURLData;
static void
-filename_suggested_cb (EphyDownload *download,
- const char *suggested_filename,
- SavePropertyURLData *data)
+filename_suggested_cb (EphyDownload *download,
+ const char *suggested_filename,
+ SavePropertyURLData *data)
{
- EphyFileChooser *dialog;
- char *sanitized_filename;
-
- dialog = ephy_file_chooser_new (data->title,
- GTK_WIDGET (data->window),
- GTK_FILE_CHOOSER_ACTION_SAVE,
- EPHY_FILE_FILTER_NONE);
- gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
- gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
-
- sanitized_filename = ephy_sanitize_filename (g_strdup (suggested_filename));
- gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), sanitized_filename);
- g_free (sanitized_filename);
-
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
- {
- char *uri;
- WebKitDownload *webkit_download;
-
- uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
- ephy_download_set_destination_uri (download, uri);
- g_free (uri);
-
- webkit_download = ephy_download_get_webkit_download (download);
- webkit_download_set_allow_overwrite (webkit_download, TRUE);
-
- ephy_downloads_manager_add_download (ephy_embed_shell_get_downloads_manager
(ephy_embed_shell_get_default ()),
- download);
- }
- else
- {
- g_idle_add_full (G_PRIORITY_DEFAULT,
- (GSourceFunc)cancel_download_idle_cb,
- g_object_ref (download),
- g_object_unref);
- }
-
- gtk_widget_destroy (GTK_WIDGET (dialog));
- g_free (data->title);
- g_object_unref (data->window);
- g_free (data);
-
- g_object_unref (download);
+ EphyFileChooser *dialog;
+ char *sanitized_filename;
+
+ dialog = ephy_file_chooser_new (data->title,
+ GTK_WIDGET (data->window),
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ EPHY_FILE_FILTER_NONE);
+ gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+ gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
+
+ sanitized_filename = ephy_sanitize_filename (g_strdup (suggested_filename));
+ gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), sanitized_filename);
+ g_free (sanitized_filename);
+
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
+ char *uri;
+ WebKitDownload *webkit_download;
+
+ uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
+ ephy_download_set_destination_uri (download, uri);
+ g_free (uri);
+
+ webkit_download = ephy_download_get_webkit_download (download);
+ webkit_download_set_allow_overwrite (webkit_download, TRUE);
+
+ ephy_downloads_manager_add_download (ephy_embed_shell_get_downloads_manager
(ephy_embed_shell_get_default ()),
+ download);
+ } else {
+ g_idle_add_full (G_PRIORITY_DEFAULT,
+ (GSourceFunc)cancel_download_idle_cb,
+ g_object_ref (download),
+ g_object_unref);
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ g_free (data->title);
+ g_object_unref (data->window);
+ g_free (data);
+
+ g_object_unref (download);
}
static void
save_property_url (const char *title,
- EphyWindow *window,
- const char *property)
+ EphyWindow *window,
+ const char *property)
{
- EphyEmbedEvent *event;
- const char *location;
- EphyDownload *download;
- SavePropertyURLData *data;
- GValue value = { 0, };
-
- event = ephy_window_get_context_event (window);
- g_return_if_fail (event != NULL);
-
- ephy_embed_event_get_property (event, property, &value);
- location = g_value_get_string (&value);
- download = ephy_download_new_for_uri (location);
- data = g_new (SavePropertyURLData, 1);
- data->title = g_strdup (title);
- data->window = g_object_ref (window);
- g_signal_connect (download, "filename-suggested",
- G_CALLBACK (filename_suggested_cb),
- data);
-
- g_value_unset (&value);
+ EphyEmbedEvent *event;
+ const char *location;
+ EphyDownload *download;
+ SavePropertyURLData *data;
+ GValue value = { 0, };
+
+ event = ephy_window_get_context_event (window);
+ g_return_if_fail (event != NULL);
+
+ ephy_embed_event_get_property (event, property, &value);
+ location = g_value_get_string (&value);
+ download = ephy_download_new_for_uri (location);
+ data = g_new (SavePropertyURLData, 1);
+ data->title = g_strdup (title);
+ data->window = g_object_ref (window);
+ g_signal_connect (download, "filename-suggested",
+ G_CALLBACK (filename_suggested_cb),
+ data);
+
+ g_value_unset (&value);
}
void
-popup_cmd_download_link_as (GtkAction *action,
- EphyWindow *window)
+popup_cmd_download_link_as (GtkAction *action,
+ EphyWindow *window)
{
- save_property_url (_("Save Link As"), window, "link-uri");
+ save_property_url (_("Save Link As"), window, "link-uri");
}
void
-popup_cmd_save_image_as (GtkAction *action,
- EphyWindow *window)
+popup_cmd_save_image_as (GtkAction *action,
+ EphyWindow *window)
{
- save_property_url (_("Save Image As"), window, "image-uri");
+ save_property_url (_("Save Image As"), window, "image-uri");
}
void
-popup_cmd_save_media_as (GtkAction *action,
- EphyWindow *window)
+popup_cmd_save_media_as (GtkAction *action,
+ EphyWindow *window)
{
- save_property_url (_("Save Media As"), window, "media-uri");
+ save_property_url (_("Save Media As"), window, "media-uri");
}
static void
background_download_completed (EphyDownload *download,
- GtkWidget *window)
+ GtkWidget *window)
{
- const char *uri;
- GSettings *settings;
+ const char *uri;
+ GSettings *settings;
- uri = ephy_download_get_destination_uri (download);
- settings = ephy_settings_get ("org.gnome.desktop.background");
- g_settings_set_string (settings, "picture-uri", uri);
+ uri = ephy_download_get_destination_uri (download);
+ settings = ephy_settings_get ("org.gnome.desktop.background");
+ g_settings_set_string (settings, "picture-uri", uri);
}
void
-popup_cmd_set_image_as_background (GtkAction *action,
- EphyWindow *window)
+popup_cmd_set_image_as_background (GtkAction *action,
+ EphyWindow *window)
{
- EphyEmbedEvent *event;
- const char *location;
- char *dest_uri, *dest, *base, *base_converted;
- GValue value = { 0, };
- EphyDownload *download;
-
- event = ephy_window_get_context_event (window);
- g_return_if_fail (event != NULL);
-
- ephy_embed_event_get_property (event, "image-uri", &value);
- location = g_value_get_string (&value);
-
- download = ephy_download_new_for_uri (location);
-
- base = g_path_get_basename (location);
- base_converted = g_filename_from_utf8 (base, -1, NULL, NULL, NULL);
- dest = g_build_filename (g_get_user_special_dir (G_USER_DIRECTORY_PICTURES), base_converted, NULL);
- dest_uri = g_filename_to_uri (dest, NULL, NULL);
-
- ephy_download_set_destination_uri (download, dest_uri);
- ephy_download_set_action (download, EPHY_DOWNLOAD_ACTION_DO_NOTHING);
- ephy_downloads_manager_add_download (ephy_embed_shell_get_downloads_manager
(ephy_embed_shell_get_default ()),
- download);
- g_object_unref (download);
-
- g_signal_connect (download, "completed",
- G_CALLBACK (background_download_completed), window);
-
- g_value_unset (&value);
- g_free (base);
- g_free (base_converted);
- g_free (dest);
- g_free (dest_uri);
+ EphyEmbedEvent *event;
+ const char *location;
+ char *dest_uri, *dest, *base, *base_converted;
+ GValue value = { 0, };
+ EphyDownload *download;
+
+ event = ephy_window_get_context_event (window);
+ g_return_if_fail (event != NULL);
+
+ ephy_embed_event_get_property (event, "image-uri", &value);
+ location = g_value_get_string (&value);
+
+ download = ephy_download_new_for_uri (location);
+
+ base = g_path_get_basename (location);
+ base_converted = g_filename_from_utf8 (base, -1, NULL, NULL, NULL);
+ dest = g_build_filename (g_get_user_special_dir (G_USER_DIRECTORY_PICTURES), base_converted, NULL);
+ dest_uri = g_filename_to_uri (dest, NULL, NULL);
+
+ ephy_download_set_destination_uri (download, dest_uri);
+ ephy_download_set_action (download, EPHY_DOWNLOAD_ACTION_DO_NOTHING);
+ ephy_downloads_manager_add_download (ephy_embed_shell_get_downloads_manager (ephy_embed_shell_get_default
()),
+ download);
+ g_object_unref (download);
+
+ g_signal_connect (download, "completed",
+ G_CALLBACK (background_download_completed), window);
+
+ g_value_unset (&value);
+ g_free (base);
+ g_free (base_converted);
+ g_free (dest);
+ g_free (dest_uri);
}
static void
popup_cmd_copy_location (EphyWindow *window,
- const char *property_name)
+ const char *property_name)
{
- EphyEmbedEvent *event;
- const char *location;
- GValue value = { 0, };
-
- event = ephy_window_get_context_event (window);
- ephy_embed_event_get_property (event, property_name, &value);
- location = g_value_get_string (&value);
- popup_cmd_copy_to_clipboard (window, location);
- g_value_unset (&value);
+ EphyEmbedEvent *event;
+ const char *location;
+ GValue value = { 0, };
+
+ event = ephy_window_get_context_event (window);
+ ephy_embed_event_get_property (event, property_name, &value);
+ location = g_value_get_string (&value);
+ popup_cmd_copy_to_clipboard (window, location);
+ g_value_unset (&value);
}
void
-popup_cmd_copy_image_location (GtkAction *action,
- EphyWindow *window)
+popup_cmd_copy_image_location (GtkAction *action,
+ EphyWindow *window)
{
- popup_cmd_copy_location (window, "image-uri");
+ popup_cmd_copy_location (window, "image-uri");
}
void
-popup_cmd_copy_media_location (GtkAction *action,
- EphyWindow *window)
+popup_cmd_copy_media_location (GtkAction *action,
+ EphyWindow *window)
{
- popup_cmd_copy_location (window, "media-uri");
+ popup_cmd_copy_location (window, "media-uri");
}
void
-popup_cmd_link_in_new_tab (GtkAction *action,
- EphyWindow *window)
+popup_cmd_link_in_new_tab (GtkAction *action,
+ EphyWindow *window)
{
- view_in_destination (window, "link-uri", NEW_TAB);
+ view_in_destination (window, "link-uri", NEW_TAB);
}
void
-popup_cmd_view_image_in_new_tab (GtkAction *action,
- EphyWindow *window)
+popup_cmd_view_image_in_new_tab (GtkAction *action,
+ EphyWindow *window)
{
- view_in_destination (window, "image-uri", NEW_TAB);
+ view_in_destination (window, "image-uri", NEW_TAB);
}
void
-popup_cmd_media_in_new_tab (GtkAction *action,
- EphyWindow *window)
+popup_cmd_media_in_new_tab (GtkAction *action,
+ EphyWindow *window)
{
- view_in_destination (window, "media-uri", NEW_TAB);
+ view_in_destination (window, "media-uri", NEW_TAB);
}
void
-popup_cmd_link_in_incognito_window (GtkAction *action,
- EphyWindow *window)
+popup_cmd_link_in_incognito_window (GtkAction *action,
+ EphyWindow *window)
{
- EphyEmbedEvent *event;
- GValue value = { 0, };
+ EphyEmbedEvent *event;
+ GValue value = { 0, };
- event = ephy_window_get_context_event (window);
- g_assert (event != NULL);
+ event = ephy_window_get_context_event (window);
+ g_assert (event != NULL);
- ephy_embed_event_get_property (event, "link-uri", &value);
- ephy_open_incognito_window (g_value_get_string (&value));
- g_value_unset (&value);
+ ephy_embed_event_get_property (event, "link-uri", &value);
+ ephy_open_incognito_window (g_value_get_string (&value));
+ g_value_unset (&value);
}
void
-popup_cmd_search_selection (GtkAction *action,
- EphyWindow *window)
+popup_cmd_search_selection (GtkAction *action,
+ EphyWindow *window)
{
- EphyEmbed *embed, *new_embed;
- const char *text;
- char *search_url;
-
- embed = ephy_embed_container_get_active_child
- (EPHY_EMBED_CONTAINER (window));
- g_assert (EPHY_IS_EMBED (embed));
-
- text = g_object_get_data (G_OBJECT (action), "selection");
- search_url = ephy_embed_utils_autosearch_address (text);
- new_embed = ephy_shell_new_tab (ephy_shell_get_default (),
- window, embed, EPHY_NEW_TAB_APPEND_AFTER);
- ephy_web_view_load_url (ephy_embed_get_web_view (new_embed), search_url);
- g_free (search_url);
+ EphyEmbed *embed, *new_embed;
+ const char *text;
+ char *search_url;
+
+ embed = ephy_embed_container_get_active_child
+ (EPHY_EMBED_CONTAINER (window));
+ g_assert (EPHY_IS_EMBED (embed));
+
+ text = g_object_get_data (G_OBJECT (action), "selection");
+ search_url = ephy_embed_utils_autosearch_address (text);
+ new_embed = ephy_shell_new_tab (ephy_shell_get_default (),
+ window, embed, EPHY_NEW_TAB_APPEND_AFTER);
+ ephy_web_view_load_url (ephy_embed_get_web_view (new_embed), search_url);
+ g_free (search_url);
}
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index ab1f71a..f4ab10e 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -44,67 +44,64 @@
#include <gtk/gtk.h>
#include <string.h>
-#define DOWNLOAD_BUTTON_WIDTH 8
+#define DOWNLOAD_BUTTON_WIDTH 8
-enum
-{
- COL_LANG_NAME,
- COL_LANG_CODE
+enum {
+ COL_LANG_NAME,
+ COL_LANG_CODE
};
-struct _PrefsDialog
-{
- GtkDialog parent_instance;
-
- /* general */
- GtkWidget *download_button_hbox;
- GtkWidget *download_button_label;
- GtkWidget *automatic_downloads_checkbutton;
- GtkWidget *search_engine_combo;
- GtkWidget *restore_session_checkbutton;
- GtkWidget *popups_allow_checkbutton;
- GtkWidget *adblock_allow_checkbutton;
- GtkWidget *enable_plugins_checkbutton;
-
- /* fonts */
- GtkWidget *use_gnome_fonts_checkbutton;
- GtkWidget *custom_fonts_table;
- GtkWidget *sans_fontbutton;
- GtkWidget *serif_fontbutton;
- GtkWidget *mono_fontbutton;
- GtkWidget *css_checkbox;
- GtkWidget *css_edit_button;
-
- /* privacy */
- GtkWidget *always;
- GtkWidget *no_third_party;
- GtkWidget *never;
- GtkWidget *remember_passwords_checkbutton;
- GtkWidget *do_not_track_checkbutton;
- GtkWidget *clear_personal_data_button;
-
- /* language */
- GtkTreeView *lang_treeview;
- GtkWidget *lang_add_button;
- GtkWidget *lang_remove_button;
- GtkWidget *lang_up_button;
- GtkWidget *lang_down_button;
- GtkWidget *enable_spell_checking_checkbutton;
-
- GtkDialog *add_lang_dialog;
- GtkTreeView *add_lang_treeview;
- GtkTreeModel *lang_model;
-
- GHashTable *iso_639_table;
- GHashTable *iso_3166_table;
+struct _PrefsDialog {
+ GtkDialog parent_instance;
+
+ /* general */
+ GtkWidget *download_button_hbox;
+ GtkWidget *download_button_label;
+ GtkWidget *automatic_downloads_checkbutton;
+ GtkWidget *search_engine_combo;
+ GtkWidget *restore_session_checkbutton;
+ GtkWidget *popups_allow_checkbutton;
+ GtkWidget *adblock_allow_checkbutton;
+ GtkWidget *enable_plugins_checkbutton;
+
+ /* fonts */
+ GtkWidget *use_gnome_fonts_checkbutton;
+ GtkWidget *custom_fonts_table;
+ GtkWidget *sans_fontbutton;
+ GtkWidget *serif_fontbutton;
+ GtkWidget *mono_fontbutton;
+ GtkWidget *css_checkbox;
+ GtkWidget *css_edit_button;
+
+ /* privacy */
+ GtkWidget *always;
+ GtkWidget *no_third_party;
+ GtkWidget *never;
+ GtkWidget *remember_passwords_checkbutton;
+ GtkWidget *do_not_track_checkbutton;
+ GtkWidget *clear_personal_data_button;
+
+ /* language */
+ GtkTreeView *lang_treeview;
+ GtkWidget *lang_add_button;
+ GtkWidget *lang_remove_button;
+ GtkWidget *lang_up_button;
+ GtkWidget *lang_down_button;
+ GtkWidget *enable_spell_checking_checkbutton;
+
+ GtkDialog *add_lang_dialog;
+ GtkTreeView *add_lang_treeview;
+ GtkTreeModel *lang_model;
+
+ GHashTable *iso_639_table;
+ GHashTable *iso_3166_table;
};
-enum
-{
- SEARCH_ENGINE_COL_NAME,
- SEARCH_ENGINE_COL_STOCK_URL,
- SEARCH_ENGINE_COL_URL,
- SEARCH_ENGINE_NUM_COLS
+enum {
+ SEARCH_ENGINE_COL_NAME,
+ SEARCH_ENGINE_COL_STOCK_URL,
+ SEARCH_ENGINE_COL_URL,
+ SEARCH_ENGINE_NUM_COLS
};
G_DEFINE_TYPE (PrefsDialog, prefs_dialog, GTK_TYPE_DIALOG)
@@ -112,898 +109,864 @@ G_DEFINE_TYPE (PrefsDialog, prefs_dialog, GTK_TYPE_DIALOG)
static void
prefs_dialog_finalize (GObject *object)
{
- PrefsDialog *dialog = EPHY_PREFS_DIALOG (object);
+ PrefsDialog *dialog = EPHY_PREFS_DIALOG (object);
- if (dialog->add_lang_dialog != NULL)
- {
- GtkDialog **add_lang_dialog = &dialog->add_lang_dialog;
+ if (dialog->add_lang_dialog != NULL) {
+ GtkDialog **add_lang_dialog = &dialog->add_lang_dialog;
- g_object_remove_weak_pointer (G_OBJECT (dialog->add_lang_dialog),
- (gpointer *) add_lang_dialog);
- g_object_unref (dialog->add_lang_dialog);
- }
+ g_object_remove_weak_pointer (G_OBJECT (dialog->add_lang_dialog),
+ (gpointer *)add_lang_dialog);
+ g_object_unref (dialog->add_lang_dialog);
+ }
- g_hash_table_destroy (dialog->iso_639_table);
- g_hash_table_destroy (dialog->iso_3166_table);
+ g_hash_table_destroy (dialog->iso_639_table);
+ g_hash_table_destroy (dialog->iso_3166_table);
- G_OBJECT_CLASS (prefs_dialog_parent_class)->finalize (object);
+ G_OBJECT_CLASS (prefs_dialog_parent_class)->finalize (object);
}
static void
-on_manage_cookies_button_clicked (GtkWidget *button,
- PrefsDialog *dialog)
+on_manage_cookies_button_clicked (GtkWidget *button,
+ PrefsDialog *dialog)
{
- EphyCookiesDialog *cookies_dialog;
+ EphyCookiesDialog *cookies_dialog;
- cookies_dialog = ephy_cookies_dialog_new ();
+ cookies_dialog = ephy_cookies_dialog_new ();
- gtk_window_set_transient_for (GTK_WINDOW (cookies_dialog), GTK_WINDOW (dialog));
- gtk_window_set_modal (GTK_WINDOW (cookies_dialog), TRUE);
- gtk_window_present (GTK_WINDOW (cookies_dialog));
+ gtk_window_set_transient_for (GTK_WINDOW (cookies_dialog), GTK_WINDOW (dialog));
+ gtk_window_set_modal (GTK_WINDOW (cookies_dialog), TRUE);
+ gtk_window_present (GTK_WINDOW (cookies_dialog));
}
static void
-on_manage_passwords_button_clicked (GtkWidget *button,
- PrefsDialog *dialog)
+on_manage_passwords_button_clicked (GtkWidget *button,
+ PrefsDialog *dialog)
{
- EphyPasswordsDialog *passwords_dialog;
+ EphyPasswordsDialog *passwords_dialog;
- passwords_dialog = ephy_passwords_dialog_new ();
+ passwords_dialog = ephy_passwords_dialog_new ();
- gtk_window_set_transient_for (GTK_WINDOW (passwords_dialog), GTK_WINDOW (dialog));
- gtk_window_set_modal (GTK_WINDOW (passwords_dialog), TRUE);
- gtk_window_present (GTK_WINDOW (passwords_dialog));
+ gtk_window_set_transient_for (GTK_WINDOW (passwords_dialog), GTK_WINDOW (dialog));
+ gtk_window_set_modal (GTK_WINDOW (passwords_dialog), TRUE);
+ gtk_window_present (GTK_WINDOW (passwords_dialog));
}
static void
prefs_dialog_class_init (PrefsDialogClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
- object_class->finalize = prefs_dialog_finalize;
-
- gtk_widget_class_set_template_from_resource (widget_class,
- "/org/gnome/epiphany/prefs-dialog.ui");
- /* general */
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, automatic_downloads_checkbutton);
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, search_engine_combo);
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, restore_session_checkbutton);
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, popups_allow_checkbutton);
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, adblock_allow_checkbutton);
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, enable_plugins_checkbutton);
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, download_button_hbox);
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, download_button_label);
-
- /* fonts */
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, use_gnome_fonts_checkbutton);
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, custom_fonts_table);
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, sans_fontbutton);
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, serif_fontbutton);
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, mono_fontbutton);
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, css_checkbox);
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, css_edit_button);
-
- /* privacy */
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, always);
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, no_third_party);
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, never);
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, remember_passwords_checkbutton);
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, do_not_track_checkbutton);
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, clear_personal_data_button);
-
- /* language */
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, lang_treeview);
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, lang_add_button);
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, lang_remove_button);
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, lang_up_button);
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, lang_down_button);
- gtk_widget_class_bind_template_child (widget_class, PrefsDialog, enable_spell_checking_checkbutton);
-
- gtk_widget_class_bind_template_callback (widget_class, on_manage_cookies_button_clicked);
- gtk_widget_class_bind_template_callback (widget_class, on_manage_passwords_button_clicked);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->finalize = prefs_dialog_finalize;
+
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/epiphany/prefs-dialog.ui");
+ /* general */
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, automatic_downloads_checkbutton);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, search_engine_combo);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, restore_session_checkbutton);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, popups_allow_checkbutton);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, adblock_allow_checkbutton);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, enable_plugins_checkbutton);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, download_button_hbox);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, download_button_label);
+
+ /* fonts */
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, use_gnome_fonts_checkbutton);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, custom_fonts_table);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, sans_fontbutton);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, serif_fontbutton);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, mono_fontbutton);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, css_checkbox);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, css_edit_button);
+
+ /* privacy */
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, always);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, no_third_party);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, never);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, remember_passwords_checkbutton);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, do_not_track_checkbutton);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, clear_personal_data_button);
+
+ /* language */
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, lang_treeview);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, lang_add_button);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, lang_remove_button);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, lang_up_button);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, lang_down_button);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, enable_spell_checking_checkbutton);
+
+ gtk_widget_class_bind_template_callback (widget_class, on_manage_cookies_button_clicked);
+ gtk_widget_class_bind_template_callback (widget_class, on_manage_passwords_button_clicked);
}
static void
-css_edit_button_clicked_cb (GtkWidget *button,
- PrefsDialog *pd)
+css_edit_button_clicked_cb (GtkWidget *button,
+ PrefsDialog *pd)
{
- GFile *css_file;
+ GFile *css_file;
- css_file = g_file_new_for_path (g_build_filename (ephy_dot_dir (),
- USER_STYLESHEET_FILENAME,
- NULL));
+ css_file = g_file_new_for_path (g_build_filename (ephy_dot_dir (),
+ USER_STYLESHEET_FILENAME,
+ NULL));
- ephy_file_launch_handler ("text/plain", css_file,
- gtk_get_current_event_time ());
- g_object_unref (css_file);
+ ephy_file_launch_handler ("text/plain", css_file,
+ gtk_get_current_event_time ());
+ g_object_unref (css_file);
}
static gboolean
-combo_get_mapping (GValue *value,
- GVariant *variant,
- gpointer user_data)
+combo_get_mapping (GValue *value,
+ GVariant *variant,
+ gpointer user_data)
{
- GtkTreeModel *model;
- GtkTreeIter iter;
- gboolean valid = FALSE;
- const char *settings_name;
- int i;
-
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (user_data));
- valid = gtk_tree_model_get_iter_first (model, &iter);
- settings_name = g_variant_get_string (variant, NULL);
- i = 0;
-
- while (valid)
- {
- char *item_name;
- gtk_tree_model_get (model, &iter, 1, &item_name, -1);
-
- if (g_strcmp0 (item_name, settings_name) == 0)
- {
- g_value_set_int (value, i);
- g_free (item_name);
- break;
- }
-
- i++;
- valid = gtk_tree_model_iter_next (model, &iter);
- g_free (item_name);
- }
-
- return TRUE;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gboolean valid = FALSE;
+ const char *settings_name;
+ int i;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (user_data));
+ valid = gtk_tree_model_get_iter_first (model, &iter);
+ settings_name = g_variant_get_string (variant, NULL);
+ i = 0;
+
+ while (valid) {
+ char *item_name;
+ gtk_tree_model_get (model, &iter, 1, &item_name, -1);
+
+ if (g_strcmp0 (item_name, settings_name) == 0) {
+ g_value_set_int (value, i);
+ g_free (item_name);
+ break;
+ }
+
+ i++;
+ valid = gtk_tree_model_iter_next (model, &iter);
+ g_free (item_name);
+ }
+
+ return TRUE;
}
static GVariant *
-combo_set_mapping (const GValue *value,
- const GVariantType *expected_type,
- gpointer user_data)
+combo_set_mapping (const GValue *value,
+ const GVariantType *expected_type,
+ gpointer user_data)
{
- GVariant *variant = NULL;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gboolean valid = FALSE;
- int n;
+ GVariant *variant = NULL;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gboolean valid = FALSE;
+ int n;
- n = g_value_get_int (value);
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (user_data));
- valid = gtk_tree_model_iter_nth_child (model, &iter, NULL, n);
+ n = g_value_get_int (value);
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (user_data));
+ valid = gtk_tree_model_iter_nth_child (model, &iter, NULL, n);
- if (valid)
- {
- char *item_name;
- gtk_tree_model_get (model, &iter, 1, &item_name, -1);
+ if (valid) {
+ char *item_name;
+ gtk_tree_model_get (model, &iter, 1, &item_name, -1);
- variant = g_variant_new_string (item_name);
+ variant = g_variant_new_string (item_name);
- g_free (item_name);
- }
+ g_free (item_name);
+ }
- return variant;
+ return variant;
}
static void
language_editor_add (PrefsDialog *pd,
- const char *code,
- const char *desc)
+ const char *code,
+ const char *desc)
{
- GtkTreeIter iter;
-
- g_return_if_fail (code != NULL && desc != NULL);
-
- if (gtk_tree_model_get_iter_first (pd->lang_model, &iter))
- {
- do
- {
- char *c;
-
- gtk_tree_model_get (pd->lang_model, &iter,
- COL_LANG_CODE, &c,
- -1);
-
- if (strcmp (code, c) == 0)
- {
- g_free (c);
-
- /* already in list, don't allow a duplicate */
- return;
- }
- g_free (c);
- }
- while (gtk_tree_model_iter_next (pd->lang_model, &iter));
- }
-
- gtk_list_store_append (GTK_LIST_STORE (pd->lang_model), &iter);
-
- gtk_list_store_set (GTK_LIST_STORE (pd->lang_model), &iter,
- COL_LANG_NAME, desc,
- COL_LANG_CODE, code,
- -1);
+ GtkTreeIter iter;
+
+ g_return_if_fail (code != NULL && desc != NULL);
+
+ if (gtk_tree_model_get_iter_first (pd->lang_model, &iter)) {
+ do {
+ char *c;
+
+ gtk_tree_model_get (pd->lang_model, &iter,
+ COL_LANG_CODE, &c,
+ -1);
+
+ if (strcmp (code, c) == 0) {
+ g_free (c);
+
+ /* already in list, don't allow a duplicate */
+ return;
+ }
+ g_free (c);
+ } while (gtk_tree_model_iter_next (pd->lang_model, &iter));
+ }
+
+ gtk_list_store_append (GTK_LIST_STORE (pd->lang_model), &iter);
+
+ gtk_list_store_set (GTK_LIST_STORE (pd->lang_model), &iter,
+ COL_LANG_NAME, desc,
+ COL_LANG_CODE, code,
+ -1);
}
static void
language_editor_update_pref (PrefsDialog *pd)
{
- GtkTreeIter iter;
- GVariantBuilder builder;
-
- if (gtk_tree_model_get_iter_first (pd->lang_model, &iter))
- {
- g_variant_builder_init (&builder, G_VARIANT_TYPE_STRING_ARRAY);
-
- do
- {
- char *code;
-
- gtk_tree_model_get (pd->lang_model, &iter,
- COL_LANG_CODE, &code,
- -1);
- g_variant_builder_add (&builder, "s", code);
- g_free (code);
- }
- while (gtk_tree_model_iter_next (pd->lang_model, &iter));
-
- g_settings_set (EPHY_SETTINGS_WEB,
- EPHY_PREFS_WEB_LANGUAGE,
- "as", &builder);
- } else {
- g_settings_set (EPHY_SETTINGS_WEB,
- EPHY_PREFS_WEB_LANGUAGE,
- "as", NULL);
- }
+ GtkTreeIter iter;
+ GVariantBuilder builder;
+
+ if (gtk_tree_model_get_iter_first (pd->lang_model, &iter)) {
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_STRING_ARRAY);
+
+ do {
+ char *code;
+
+ gtk_tree_model_get (pd->lang_model, &iter,
+ COL_LANG_CODE, &code,
+ -1);
+ g_variant_builder_add (&builder, "s", code);
+ g_free (code);
+ } while (gtk_tree_model_iter_next (pd->lang_model, &iter));
+
+ g_settings_set (EPHY_SETTINGS_WEB,
+ EPHY_PREFS_WEB_LANGUAGE,
+ "as", &builder);
+ } else {
+ g_settings_set (EPHY_SETTINGS_WEB,
+ EPHY_PREFS_WEB_LANGUAGE,
+ "as", NULL);
+ }
}
static void
language_editor_update_buttons (PrefsDialog *dialog)
{
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreePath *path;
- GtkTreeIter iter;
- gboolean can_remove = FALSE, can_move_up = FALSE, can_move_down = FALSE;
- int selected;
-
- selection = gtk_tree_view_get_selection (dialog->lang_treeview);
-
- if (gtk_tree_selection_get_selected (selection, &model, &iter))
- {
- path = gtk_tree_model_get_path (model, &iter);
-
- selected = gtk_tree_path_get_indices (path)[0];
-
- can_remove = TRUE;
- can_move_up = selected > 0;
- can_move_down =
- selected < gtk_tree_model_iter_n_children (model, NULL) - 1;
-
- gtk_tree_path_free (path);
- }
-
- gtk_widget_set_sensitive (dialog->lang_remove_button, can_remove);
- gtk_widget_set_sensitive (dialog->lang_up_button, can_move_up);
- gtk_widget_set_sensitive (dialog->lang_down_button, can_move_down);
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ gboolean can_remove = FALSE, can_move_up = FALSE, can_move_down = FALSE;
+ int selected;
+
+ selection = gtk_tree_view_get_selection (dialog->lang_treeview);
+
+ if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
+ path = gtk_tree_model_get_path (model, &iter);
+
+ selected = gtk_tree_path_get_indices (path)[0];
+
+ can_remove = TRUE;
+ can_move_up = selected > 0;
+ can_move_down =
+ selected < gtk_tree_model_iter_n_children (model, NULL) - 1;
+
+ gtk_tree_path_free (path);
+ }
+
+ gtk_widget_set_sensitive (dialog->lang_remove_button, can_remove);
+ gtk_widget_set_sensitive (dialog->lang_up_button, can_move_up);
+ gtk_widget_set_sensitive (dialog->lang_down_button, can_move_down);
}
static void
add_lang_dialog_selection_changed (GtkTreeSelection *selection,
- GtkWidget *button)
+ GtkWidget *button)
{
- int n_selected;
+ int n_selected;
- n_selected = gtk_tree_selection_count_selected_rows (selection);
- gtk_widget_set_sensitive (button, n_selected > 0);
+ n_selected = gtk_tree_selection_count_selected_rows (selection);
+ gtk_widget_set_sensitive (button, n_selected > 0);
}
static void
-add_lang_dialog_response_cb (GtkWidget *widget,
- int response,
- PrefsDialog *pd)
+add_lang_dialog_response_cb (GtkWidget *widget,
+ int response,
+ PrefsDialog *pd)
{
- GtkDialog *dialog = pd->add_lang_dialog;
- GtkTreeModel *model;
- GtkTreeSelection *selection;
- GtkTreeIter iter;
- GList *rows, *r;
+ GtkDialog *dialog = pd->add_lang_dialog;
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ GList *rows, *r;
- g_return_if_fail (dialog != NULL);
+ g_return_if_fail (dialog != NULL);
- if (response == GTK_RESPONSE_ACCEPT)
- {
- selection = gtk_tree_view_get_selection (pd->add_lang_treeview);
+ if (response == GTK_RESPONSE_ACCEPT) {
+ selection = gtk_tree_view_get_selection (pd->add_lang_treeview);
- rows = gtk_tree_selection_get_selected_rows (selection, &model);
+ rows = gtk_tree_selection_get_selected_rows (selection, &model);
- for (r = rows; r != NULL; r = r->next)
- {
- GtkTreePath *path = (GtkTreePath *) r->data;
+ for (r = rows; r != NULL; r = r->next) {
+ GtkTreePath *path = (GtkTreePath *)r->data;
- if (gtk_tree_model_get_iter (model, &iter, path))
- {
- char *code, *desc;
+ if (gtk_tree_model_get_iter (model, &iter, path)) {
+ char *code, *desc;
- gtk_tree_model_get (model, &iter,
- COL_LANG_NAME, &desc,
- COL_LANG_CODE, &code,
- -1);
+ gtk_tree_model_get (model, &iter,
+ COL_LANG_NAME, &desc,
+ COL_LANG_CODE, &code,
+ -1);
- language_editor_add (pd, code, desc);
+ language_editor_add (pd, code, desc);
- g_free (desc);
- g_free (code);
- }
- }
+ g_free (desc);
+ g_free (code);
+ }
+ }
- g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL);
- g_list_free (rows);
+ g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
+ g_list_free (rows);
- language_editor_update_pref (pd);
- language_editor_update_buttons (pd);
- }
+ language_editor_update_pref (pd);
+ language_editor_update_buttons (pd);
+ }
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_widget_destroy (GTK_WIDGET (dialog));
}
static char *
get_name_for_lang_code (PrefsDialog *pd,
- const char *code)
+ const char *code)
{
- char **str;
- char *name;
- const char *langname, *localename;
- int len;
-
- str = g_strsplit (code, "-", -1);
- len = g_strv_length (str);
- g_return_val_if_fail (len != 0, NULL);
-
- langname = (const char *) g_hash_table_lookup (pd->iso_639_table, str[0]);
-
- if (len == 1 && langname != NULL)
- {
- name = g_strdup (dgettext (ISO_639_DOMAIN, langname));
- }
- else if (len == 2 && langname != NULL)
- {
- localename = (const char *) g_hash_table_lookup (pd->iso_3166_table, str[1]);
-
- if (localename != NULL)
- {
- /* Translators: the first %s is the language name, and the
- * second %s is the locale name. Example:
- * "French (France)"
- */
- name = g_strdup_printf (C_("language", "%s (%s)"),
- dgettext (ISO_639_DOMAIN, langname),
- dgettext (ISO_3166_DOMAIN, localename));
- }
- else
- {
- name = g_strdup_printf (C_("language", "%s (%s)"),
- dgettext (ISO_639_DOMAIN, langname), str[1]);
- }
- }
- else
- {
- /* Translators: this refers to a user-define language code
- * (one which isn't in our built-in list).
- */
- name = g_strdup_printf (C_("language", "User defined (%s)"), code);
- }
-
- g_strfreev (str);
-
- return name;
+ char **str;
+ char *name;
+ const char *langname, *localename;
+ int len;
+
+ str = g_strsplit (code, "-", -1);
+ len = g_strv_length (str);
+ g_return_val_if_fail (len != 0, NULL);
+
+ langname = (const char *)g_hash_table_lookup (pd->iso_639_table, str[0]);
+
+ if (len == 1 && langname != NULL) {
+ name = g_strdup (dgettext (ISO_639_DOMAIN, langname));
+ } else if (len == 2 && langname != NULL) {
+ localename = (const char *)g_hash_table_lookup (pd->iso_3166_table, str[1]);
+
+ if (localename != NULL) {
+ /* Translators: the first %s is the language name, and the
+ * second %s is the locale name. Example:
+ * "French (France)"
+ */
+ name = g_strdup_printf (C_("language", "%s (%s)"),
+ dgettext (ISO_639_DOMAIN, langname),
+ dgettext (ISO_3166_DOMAIN, localename));
+ } else {
+ name = g_strdup_printf (C_("language", "%s (%s)"),
+ dgettext (ISO_639_DOMAIN, langname), str[1]);
+ }
+ } else {
+ /* Translators: this refers to a user-define language code
+ * (one which isn't in our built-in list).
+ */
+ name = g_strdup_printf (C_("language", "User defined (%s)"), code);
+ }
+
+ g_strfreev (str);
+
+ return name;
}
static void
add_system_language_entry (GtkListStore *store)
{
- GtkTreeIter iter;
- char **sys_langs;
- char *system, *text;
- int n_sys_langs;
+ GtkTreeIter iter;
+ char **sys_langs;
+ char *system, *text;
+ int n_sys_langs;
- sys_langs = ephy_langs_get_languages ();
- n_sys_langs = g_strv_length (sys_langs);
+ sys_langs = ephy_langs_get_languages ();
+ n_sys_langs = g_strv_length (sys_langs);
- system = g_strjoinv (", ", sys_langs);
+ system = g_strjoinv (", ", sys_langs);
- text = g_strdup_printf
- (ngettext ("System language (%s)",
- "System languages (%s)", n_sys_langs), system);
+ text = g_strdup_printf
+ (ngettext ("System language (%s)",
+ "System languages (%s)", n_sys_langs), system);
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter,
- COL_LANG_NAME, text,
- COL_LANG_CODE, "system",
- -1);
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter,
+ COL_LANG_NAME, text,
+ COL_LANG_CODE, "system",
+ -1);
- g_strfreev (sys_langs);
- g_free (system);
- g_free (text);
+ g_strfreev (sys_langs);
+ g_free (system);
+ g_free (text);
}
static GtkDialog *
setup_add_language_dialog (PrefsDialog *dialog)
{
- GtkWidget *ad;
- GtkWidget *add_button;
- GtkListStore *store;
- GtkTreeModel *sortmodel;
- GtkTreeView *treeview;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
- GtkTreeSelection *selection;
- GtkTreeIter iter;
- guint i;
- GtkBuilder *builder;
-
- builder = gtk_builder_new_from_resource ("/org/gnome/epiphany/prefs-lang-dialog.ui");
- ad = GTK_WIDGET (gtk_builder_get_object (builder, "add_language_dialog"));
- add_button = GTK_WIDGET (gtk_builder_get_object (builder, "add_button"));
- treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder, "languages_treeview"));
- dialog->add_lang_treeview = treeview;
-
- store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
-
- for (i = 0; i < G_N_ELEMENTS (languages); i++)
- {
- const char *code = languages[i];
- char *name;
-
- name = get_name_for_lang_code (dialog, code);
-
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter,
- COL_LANG_NAME, name,
- COL_LANG_CODE, code,
- -1);
- g_free (name);
- }
-
- add_system_language_entry (store);
-
- sortmodel = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (store));
- gtk_tree_sortable_set_sort_column_id
- (GTK_TREE_SORTABLE (sortmodel), COL_LANG_NAME, GTK_SORT_ASCENDING);
-
- gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (dialog)),
- GTK_WINDOW (ad));
- gtk_window_set_modal (GTK_WINDOW (ad), TRUE);
-
- gtk_tree_view_set_reorderable (GTK_TREE_VIEW (treeview), FALSE);
-
- gtk_tree_view_set_model (treeview, sortmodel);
-
- gtk_tree_view_set_headers_visible (treeview, FALSE);
-
- renderer = gtk_cell_renderer_text_new ();
-
- gtk_tree_view_insert_column_with_attributes (treeview,
- 0, "Language",
- renderer,
- "text", 0,
- NULL);
- column = gtk_tree_view_get_column (treeview, 0);
- gtk_tree_view_column_set_resizable (column, TRUE);
- gtk_tree_view_column_set_sort_column_id (column, COL_LANG_NAME);
-
- selection = gtk_tree_view_get_selection (treeview);
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
-
- add_lang_dialog_selection_changed (GTK_TREE_SELECTION (selection), add_button);
- g_signal_connect (selection, "changed",
- G_CALLBACK (add_lang_dialog_selection_changed), add_button);
-
- g_signal_connect (ad, "response",
- G_CALLBACK (add_lang_dialog_response_cb), dialog);
-
- g_object_unref (store);
- g_object_unref (sortmodel);
-
- return GTK_DIALOG (ad);
+ GtkWidget *ad;
+ GtkWidget *add_button;
+ GtkListStore *store;
+ GtkTreeModel *sortmodel;
+ GtkTreeView *treeview;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ guint i;
+ GtkBuilder *builder;
+
+ builder = gtk_builder_new_from_resource ("/org/gnome/epiphany/prefs-lang-dialog.ui");
+ ad = GTK_WIDGET (gtk_builder_get_object (builder, "add_language_dialog"));
+ add_button = GTK_WIDGET (gtk_builder_get_object (builder, "add_button"));
+ treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder, "languages_treeview"));
+ dialog->add_lang_treeview = treeview;
+
+ store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
+
+ for (i = 0; i < G_N_ELEMENTS (languages); i++) {
+ const char *code = languages[i];
+ char *name;
+
+ name = get_name_for_lang_code (dialog, code);
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter,
+ COL_LANG_NAME, name,
+ COL_LANG_CODE, code,
+ -1);
+ g_free (name);
+ }
+
+ add_system_language_entry (store);
+
+ sortmodel = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (store));
+ gtk_tree_sortable_set_sort_column_id
+ (GTK_TREE_SORTABLE (sortmodel), COL_LANG_NAME, GTK_SORT_ASCENDING);
+
+ gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (dialog)),
+ GTK_WINDOW (ad));
+ gtk_window_set_modal (GTK_WINDOW (ad), TRUE);
+
+ gtk_tree_view_set_reorderable (GTK_TREE_VIEW (treeview), FALSE);
+
+ gtk_tree_view_set_model (treeview, sortmodel);
+
+ gtk_tree_view_set_headers_visible (treeview, FALSE);
+
+ renderer = gtk_cell_renderer_text_new ();
+
+ gtk_tree_view_insert_column_with_attributes (treeview,
+ 0, "Language",
+ renderer,
+ "text", 0,
+ NULL);
+ column = gtk_tree_view_get_column (treeview, 0);
+ gtk_tree_view_column_set_resizable (column, TRUE);
+ gtk_tree_view_column_set_sort_column_id (column, COL_LANG_NAME);
+
+ selection = gtk_tree_view_get_selection (treeview);
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+
+ add_lang_dialog_selection_changed (GTK_TREE_SELECTION (selection), add_button);
+ g_signal_connect (selection, "changed",
+ G_CALLBACK (add_lang_dialog_selection_changed), add_button);
+
+ g_signal_connect (ad, "response",
+ G_CALLBACK (add_lang_dialog_response_cb), dialog);
+
+ g_object_unref (store);
+ g_object_unref (sortmodel);
+
+ return GTK_DIALOG (ad);
}
static void
-language_editor_add_button_clicked_cb (GtkWidget *button,
- PrefsDialog *pd)
+language_editor_add_button_clicked_cb (GtkWidget *button,
+ PrefsDialog *pd)
{
- if (pd->add_lang_dialog == NULL)
- {
- GtkDialog **add_lang_dialog;
+ if (pd->add_lang_dialog == NULL) {
+ GtkDialog **add_lang_dialog;
- pd->add_lang_dialog = setup_add_language_dialog (pd);
- gtk_window_set_transient_for (GTK_WINDOW (pd->add_lang_dialog), GTK_WINDOW (pd));
+ pd->add_lang_dialog = setup_add_language_dialog (pd);
+ gtk_window_set_transient_for (GTK_WINDOW (pd->add_lang_dialog), GTK_WINDOW (pd));
- add_lang_dialog = &pd->add_lang_dialog;
+ add_lang_dialog = &pd->add_lang_dialog;
- g_object_add_weak_pointer
- (G_OBJECT (pd->add_lang_dialog),
- (gpointer *) add_lang_dialog);
- }
+ g_object_add_weak_pointer
+ (G_OBJECT (pd->add_lang_dialog),
+ (gpointer *)add_lang_dialog);
+ }
- gtk_window_present (GTK_WINDOW (pd->add_lang_dialog));
+ gtk_window_present (GTK_WINDOW (pd->add_lang_dialog));
}
static void
-language_editor_remove_button_clicked_cb (GtkWidget *button,
- PrefsDialog *pd)
+language_editor_remove_button_clicked_cb (GtkWidget *button,
+ PrefsDialog *pd)
{
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeIter iter;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
- selection = gtk_tree_view_get_selection (pd->lang_treeview);
+ selection = gtk_tree_view_get_selection (pd->lang_treeview);
- if (gtk_tree_selection_get_selected (selection, &model, &iter))
- {
- gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
- }
+ if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
+ gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+ }
- language_editor_update_pref (pd);
- language_editor_update_buttons (pd);
+ language_editor_update_pref (pd);
+ language_editor_update_buttons (pd);
}
static void
-language_editor_up_button_clicked_cb (GtkWidget *button,
- PrefsDialog *pd)
+language_editor_up_button_clicked_cb (GtkWidget *button,
+ PrefsDialog *pd)
{
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeIter iter, iter_prev;
- GtkTreePath *path;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter, iter_prev;
+ GtkTreePath *path;
- selection = gtk_tree_view_get_selection (pd->lang_treeview);
+ selection = gtk_tree_view_get_selection (pd->lang_treeview);
- if (gtk_tree_selection_get_selected (selection, &model, &iter))
- {
- path = gtk_tree_model_get_path (model, &iter);
+ if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
+ path = gtk_tree_model_get_path (model, &iter);
- if (!gtk_tree_path_prev (path))
- {
- gtk_tree_path_free (path);
- return;
- }
+ if (!gtk_tree_path_prev (path)) {
+ gtk_tree_path_free (path);
+ return;
+ }
- gtk_tree_model_get_iter (model, &iter_prev, path);
+ gtk_tree_model_get_iter (model, &iter_prev, path);
- gtk_list_store_swap (GTK_LIST_STORE (model), &iter_prev, &iter);
+ gtk_list_store_swap (GTK_LIST_STORE (model), &iter_prev, &iter);
- gtk_tree_path_free (path);
- }
+ gtk_tree_path_free (path);
+ }
- language_editor_update_pref (pd);
- language_editor_update_buttons (pd);
+ language_editor_update_pref (pd);
+ language_editor_update_buttons (pd);
}
static void
-language_editor_down_button_clicked_cb (GtkWidget *button,
- PrefsDialog *pd)
+language_editor_down_button_clicked_cb (GtkWidget *button,
+ PrefsDialog *pd)
{
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeIter iter, iter_next;
- GtkTreePath *path;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter, iter_next;
+ GtkTreePath *path;
- selection = gtk_tree_view_get_selection (pd->lang_treeview);
+ selection = gtk_tree_view_get_selection (pd->lang_treeview);
- if (gtk_tree_selection_get_selected (selection, &model, &iter))
- {
- path = gtk_tree_model_get_path (model, &iter);
+ if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
+ path = gtk_tree_model_get_path (model, &iter);
- gtk_tree_path_next (path);
+ gtk_tree_path_next (path);
- gtk_tree_model_get_iter (model, &iter_next, path);
+ gtk_tree_model_get_iter (model, &iter_next, path);
- gtk_list_store_swap (GTK_LIST_STORE (model), &iter, &iter_next);
+ gtk_list_store_swap (GTK_LIST_STORE (model), &iter, &iter_next);
- gtk_tree_path_free (path);
- }
+ gtk_tree_path_free (path);
+ }
- language_editor_update_pref (pd);
- language_editor_update_buttons (pd);
+ language_editor_update_pref (pd);
+ language_editor_update_buttons (pd);
}
static void
-language_editor_treeview_drag_end_cb (GtkWidget *widget,
- GdkDragContext *context,
- PrefsDialog *dialog)
+language_editor_treeview_drag_end_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ PrefsDialog *dialog)
{
- language_editor_update_pref (dialog);
- language_editor_update_buttons (dialog);
+ language_editor_update_pref (dialog);
+ language_editor_update_buttons (dialog);
}
static void
language_editor_selection_changed_cb (GtkTreeSelection *selection,
- PrefsDialog *dialog)
+ PrefsDialog *dialog)
{
- language_editor_update_buttons (dialog);
+ language_editor_update_buttons (dialog);
}
static void
create_language_section (PrefsDialog *dialog)
{
- GtkListStore *store;
- GtkTreeView *treeview;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
- GtkTreeSelection *selection;
- char **list = NULL;
- int i;
-
- dialog->iso_639_table = ephy_langs_iso_639_table ();
- dialog->iso_3166_table = ephy_langs_iso_3166_table ();
-
- g_signal_connect (dialog->lang_add_button, "clicked",
- G_CALLBACK (language_editor_add_button_clicked_cb), dialog);
- g_signal_connect (dialog->lang_remove_button, "clicked",
- G_CALLBACK (language_editor_remove_button_clicked_cb), dialog);
- g_signal_connect (dialog->lang_up_button, "clicked",
- G_CALLBACK (language_editor_up_button_clicked_cb), dialog);
- g_signal_connect (dialog->lang_down_button, "clicked",
- G_CALLBACK (language_editor_down_button_clicked_cb), dialog);
-
- /* setup the languages treeview */
- treeview = dialog->lang_treeview;
-
- gtk_tree_view_set_reorderable (treeview, TRUE);
- gtk_tree_view_set_headers_visible (treeview, FALSE);
-
- store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
-
- dialog->lang_model = GTK_TREE_MODEL (store);
- gtk_tree_view_set_model (treeview, dialog->lang_model);
-
- renderer = gtk_cell_renderer_text_new ();
-
- gtk_tree_view_insert_column_with_attributes (treeview,
- 0, _("Language"),
- renderer,
- "text", 0,
- NULL);
- column = gtk_tree_view_get_column (treeview, 0);
- gtk_tree_view_column_set_resizable (column, TRUE);
- gtk_tree_view_column_set_sort_column_id (column, COL_LANG_NAME);
-
- selection = gtk_tree_view_get_selection (treeview);
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
-
- /* Connect treeview signals */
- g_signal_connect (G_OBJECT (treeview), "drag_end",
- G_CALLBACK (language_editor_treeview_drag_end_cb), dialog);
- g_signal_connect (G_OBJECT (selection), "changed",
- G_CALLBACK (language_editor_selection_changed_cb), dialog);
-
- list = g_settings_get_strv (EPHY_SETTINGS_WEB,
- EPHY_PREFS_WEB_LANGUAGE);
-
- /* Fill languages editor */
- for (i = 0; list[i]; i++)
- {
- const char *code = (const char *) list[i];
-
- if (strcmp (code, "system") == 0)
- {
- add_system_language_entry (store);
- }
- else if (code[0] != '\0')
- {
- char *text;
-
- text = get_name_for_lang_code (dialog, code);
- language_editor_add (dialog, code, text);
- g_free (text);
- }
- }
- g_object_unref (store);
-
- language_editor_update_buttons (dialog);
- g_strfreev (list);
-
- /* Lockdown if key is not writable */
- g_settings_bind_writable (EPHY_SETTINGS_WEB,
- EPHY_PREFS_WEB_LANGUAGE,
- dialog->lang_add_button, "sensitive", FALSE);
- g_settings_bind_writable (EPHY_SETTINGS_WEB,
- EPHY_PREFS_WEB_LANGUAGE,
- dialog->lang_remove_button, "sensitive", FALSE);
- g_settings_bind_writable (EPHY_SETTINGS_WEB,
- EPHY_PREFS_WEB_LANGUAGE,
- dialog->lang_up_button, "sensitive", FALSE);
- g_settings_bind_writable (EPHY_SETTINGS_WEB,
- EPHY_PREFS_WEB_LANGUAGE,
- dialog->lang_down_button, "sensitive", FALSE);
- g_settings_bind_writable (EPHY_SETTINGS_WEB,
- EPHY_PREFS_WEB_LANGUAGE,
- dialog->lang_treeview, "sensitive", FALSE);
+ GtkListStore *store;
+ GtkTreeView *treeview;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ GtkTreeSelection *selection;
+ char **list = NULL;
+ int i;
+
+ dialog->iso_639_table = ephy_langs_iso_639_table ();
+ dialog->iso_3166_table = ephy_langs_iso_3166_table ();
+
+ g_signal_connect (dialog->lang_add_button, "clicked",
+ G_CALLBACK (language_editor_add_button_clicked_cb), dialog);
+ g_signal_connect (dialog->lang_remove_button, "clicked",
+ G_CALLBACK (language_editor_remove_button_clicked_cb), dialog);
+ g_signal_connect (dialog->lang_up_button, "clicked",
+ G_CALLBACK (language_editor_up_button_clicked_cb), dialog);
+ g_signal_connect (dialog->lang_down_button, "clicked",
+ G_CALLBACK (language_editor_down_button_clicked_cb), dialog);
+
+ /* setup the languages treeview */
+ treeview = dialog->lang_treeview;
+
+ gtk_tree_view_set_reorderable (treeview, TRUE);
+ gtk_tree_view_set_headers_visible (treeview, FALSE);
+
+ store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
+
+ dialog->lang_model = GTK_TREE_MODEL (store);
+ gtk_tree_view_set_model (treeview, dialog->lang_model);
+
+ renderer = gtk_cell_renderer_text_new ();
+
+ gtk_tree_view_insert_column_with_attributes (treeview,
+ 0, _("Language"),
+ renderer,
+ "text", 0,
+ NULL);
+ column = gtk_tree_view_get_column (treeview, 0);
+ gtk_tree_view_column_set_resizable (column, TRUE);
+ gtk_tree_view_column_set_sort_column_id (column, COL_LANG_NAME);
+
+ selection = gtk_tree_view_get_selection (treeview);
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
+
+ /* Connect treeview signals */
+ g_signal_connect (G_OBJECT (treeview), "drag_end",
+ G_CALLBACK (language_editor_treeview_drag_end_cb), dialog);
+ g_signal_connect (G_OBJECT (selection), "changed",
+ G_CALLBACK (language_editor_selection_changed_cb), dialog);
+
+ list = g_settings_get_strv (EPHY_SETTINGS_WEB,
+ EPHY_PREFS_WEB_LANGUAGE);
+
+ /* Fill languages editor */
+ for (i = 0; list[i]; i++) {
+ const char *code = (const char *)list[i];
+
+ if (strcmp (code, "system") == 0) {
+ add_system_language_entry (store);
+ } else if (code[0] != '\0') {
+ char *text;
+
+ text = get_name_for_lang_code (dialog, code);
+ language_editor_add (dialog, code, text);
+ g_free (text);
+ }
+ }
+ g_object_unref (store);
+
+ language_editor_update_buttons (dialog);
+ g_strfreev (list);
+
+ /* Lockdown if key is not writable */
+ g_settings_bind_writable (EPHY_SETTINGS_WEB,
+ EPHY_PREFS_WEB_LANGUAGE,
+ dialog->lang_add_button, "sensitive", FALSE);
+ g_settings_bind_writable (EPHY_SETTINGS_WEB,
+ EPHY_PREFS_WEB_LANGUAGE,
+ dialog->lang_remove_button, "sensitive", FALSE);
+ g_settings_bind_writable (EPHY_SETTINGS_WEB,
+ EPHY_PREFS_WEB_LANGUAGE,
+ dialog->lang_up_button, "sensitive", FALSE);
+ g_settings_bind_writable (EPHY_SETTINGS_WEB,
+ EPHY_PREFS_WEB_LANGUAGE,
+ dialog->lang_down_button, "sensitive", FALSE);
+ g_settings_bind_writable (EPHY_SETTINGS_WEB,
+ EPHY_PREFS_WEB_LANGUAGE,
+ dialog->lang_treeview, "sensitive", FALSE);
}
static void
download_path_changed_cb (GtkFileChooser *button)
{
- char *dir;
+ char *dir;
- dir = gtk_file_chooser_get_filename (button);
- if (dir == NULL) return;
+ dir = gtk_file_chooser_get_filename (button);
+ if (dir == NULL) return;
- g_settings_set_string (EPHY_SETTINGS_STATE,
- EPHY_PREFS_STATE_DOWNLOAD_DIR, dir);
- g_free (dir);
+ g_settings_set_string (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_DOWNLOAD_DIR, dir);
+ g_free (dir);
}
static void
create_download_path_button (PrefsDialog *dialog)
{
- GtkWidget *button;
- EphyFileChooser *fc;
- char *dir;
-
- dir = ephy_file_get_downloads_dir ();
-
- fc = ephy_file_chooser_new (_("Select a Directory"),
- GTK_WIDGET (dialog),
- GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
- EPHY_FILE_FILTER_NONE);
-
- /* Unset the destroy-with-parent, since gtkfilechooserbutton doesn't
- * expect this */
- gtk_window_set_destroy_with_parent (GTK_WINDOW (fc), FALSE);
-
- button = gtk_file_chooser_button_new_with_dialog (GTK_WIDGET (fc));
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (button), dir);
- gtk_file_chooser_button_set_width_chars (GTK_FILE_CHOOSER_BUTTON (button),
- DOWNLOAD_BUTTON_WIDTH);
- g_signal_connect (button, "selection-changed",
- G_CALLBACK (download_path_changed_cb), dialog);
- gtk_label_set_mnemonic_widget (GTK_LABEL (dialog->download_button_label), button);
- gtk_box_pack_start (GTK_BOX (dialog->download_button_hbox), button, TRUE, TRUE, 0);
- gtk_widget_show (button);
-
- g_settings_bind_writable (EPHY_SETTINGS_STATE,
- EPHY_PREFS_STATE_DOWNLOAD_DIR,
- button, "sensitive", FALSE);
- g_free (dir);
+ GtkWidget *button;
+ EphyFileChooser *fc;
+ char *dir;
+
+ dir = ephy_file_get_downloads_dir ();
+
+ fc = ephy_file_chooser_new (_("Select a Directory"),
+ GTK_WIDGET (dialog),
+ GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+ EPHY_FILE_FILTER_NONE);
+
+ /* Unset the destroy-with-parent, since gtkfilechooserbutton doesn't
+ * expect this */
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (fc), FALSE);
+
+ button = gtk_file_chooser_button_new_with_dialog (GTK_WIDGET (fc));
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (button), dir);
+ gtk_file_chooser_button_set_width_chars (GTK_FILE_CHOOSER_BUTTON (button),
+ DOWNLOAD_BUTTON_WIDTH);
+ g_signal_connect (button, "selection-changed",
+ G_CALLBACK (download_path_changed_cb), dialog);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (dialog->download_button_label), button);
+ gtk_box_pack_start (GTK_BOX (dialog->download_button_hbox), button, TRUE, TRUE, 0);
+ gtk_widget_show (button);
+
+ g_settings_bind_writable (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_DOWNLOAD_DIR,
+ button, "sensitive", FALSE);
+ g_free (dir);
}
static void
prefs_dialog_response_cb (GtkDialog *widget,
- int response,
- GtkDialog *dialog)
+ int response,
+ GtkDialog *dialog)
{
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_widget_destroy (GTK_WIDGET (dialog));
}
static void
-clear_personal_data_button_clicked_cb (GtkWidget *button,
- PrefsDialog *dialog)
+clear_personal_data_button_clicked_cb (GtkWidget *button,
+ PrefsDialog *dialog)
{
- ClearDataDialog *clear_dialog;
-
- clear_dialog = g_object_new (EPHY_TYPE_CLEAR_DATA_DIALOG,
- "use-header-bar", TRUE,
- NULL);
- gtk_window_set_transient_for (GTK_WINDOW (clear_dialog), GTK_WINDOW (dialog));
- gtk_window_set_modal (GTK_WINDOW (clear_dialog), TRUE);
- gtk_window_present (GTK_WINDOW (clear_dialog));
+ ClearDataDialog *clear_dialog;
+
+ clear_dialog = g_object_new (EPHY_TYPE_CLEAR_DATA_DIALOG,
+ "use-header-bar", TRUE,
+ NULL);
+ gtk_window_set_transient_for (GTK_WINDOW (clear_dialog), GTK_WINDOW (dialog));
+ gtk_window_set_modal (GTK_WINDOW (clear_dialog), TRUE);
+ gtk_window_present (GTK_WINDOW (clear_dialog));
}
static gboolean
-cookies_get_mapping (GValue *value,
- GVariant *variant,
- gpointer user_data)
+cookies_get_mapping (GValue *value,
+ GVariant *variant,
+ gpointer user_data)
{
- const char *setting;
- const char *name;
+ const char *setting;
+ const char *name;
- setting = g_variant_get_string (variant, NULL);
- name = gtk_buildable_get_name (GTK_BUILDABLE (user_data));
+ setting = g_variant_get_string (variant, NULL);
+ name = gtk_buildable_get_name (GTK_BUILDABLE (user_data));
- if (g_strcmp0 (name, "no_third_party") == 0)
- name = "no-third-party";
+ if (g_strcmp0 (name, "no_third_party") == 0)
+ name = "no-third-party";
- /* If the button name matches the setting, it should be active. */
- if (g_strcmp0 (name, setting) == 0)
- g_value_set_boolean (value, TRUE);
+ /* If the button name matches the setting, it should be active. */
+ if (g_strcmp0 (name, setting) == 0)
+ g_value_set_boolean (value, TRUE);
- return TRUE;
+ return TRUE;
}
static GVariant *
-cookies_set_mapping (const GValue *value,
- const GVariantType *expected_type,
- gpointer user_data)
+cookies_set_mapping (const GValue *value,
+ const GVariantType *expected_type,
+ gpointer user_data)
{
- GVariant *variant = NULL;
- const char *name;
+ GVariant *variant = NULL;
+ const char *name;
- /* Don't act unless the button has been activated (turned ON). */
- if (!g_value_get_boolean (value))
- return NULL;
+ /* Don't act unless the button has been activated (turned ON). */
+ if (!g_value_get_boolean (value))
+ return NULL;
- name = gtk_buildable_get_name (GTK_BUILDABLE (user_data));
- if (g_strcmp0 (name, "no_third_party") == 0)
- variant = g_variant_new_string ("no-third-party");
- else
- variant = g_variant_new_string (name);
+ name = gtk_buildable_get_name (GTK_BUILDABLE (user_data));
+ if (g_strcmp0 (name, "no_third_party") == 0)
+ variant = g_variant_new_string ("no-third-party");
+ else
+ variant = g_variant_new_string (name);
- return variant;
+ return variant;
}
static void
search_engine_combo_add_default_engines (GtkListStore *store)
{
- guint i;
- const char *default_engines[][3] = { /* Search engine option in the preferences dialog */
- { N_("DuckDuckGo"),
- "https://duckduckgo.com/?q=%s&t=epiphany",
- /* For the preferences dialog. Must exactly match the URL
- * you chose in the gschema, but with & instead of &
- * If the match is not exact, there will be a spurious, ugly
- * entry in the preferences combo, so please test this. */
- N_("https://duckduckgo.com/?q=%s&t=epiphany")},
- /* Search engine option in the preferences dialog */
- { N_("Google"),
- "https://google.com/search?q=%s",
- /* For the preferences dialog. Consider a regional variant,
like google.co.uk */
- N_("https://google.com/search?q=%s")},
- /* Search engine option in the preferences dialog */
- { N_("Bing"),
- "https://www.bing.com/search?q=%s",
- /* For the preferences dialog. Consider a regional variant,
like uk.bing.com */
- N_("https://www.bing.com/search?q=%s")} };
-
- for (i = 0; i < G_N_ELEMENTS (default_engines); ++i)
- {
- gtk_list_store_insert_with_values (store, NULL, -1,
- SEARCH_ENGINE_COL_NAME,
- _(default_engines[i][0]),
- SEARCH_ENGINE_COL_STOCK_URL,
- default_engines[i][1],
- SEARCH_ENGINE_COL_URL,
- _(default_engines[i][2]),
- -1);
- }
+ guint i;
+ const char *default_engines[][3] = { /* Search engine option in the preferences dialog */
+ { N_("DuckDuckGo"),
+ "https://duckduckgo.com/?q=%s&t=epiphany",
+ /* For the preferences dialog. Must exactly match the URL
+ * you chose in the gschema, but with & instead of &
+ * If the match is not exact, there will be a spurious, ugly
+ * entry in the preferences combo, so please test this. */
+ N_("https://duckduckgo.com/?q=%s&t=epiphany") },
+ /* Search engine option in the preferences dialog */
+ { N_("Google"),
+ "https://google.com/search?q=%s",
+ /* For the preferences dialog. Consider a regional variant, like google.co.uk */
+ N_("https://google.com/search?q=%s") },
+ /* Search engine option in the preferences dialog */
+ { N_("Bing"),
+ "https://www.bing.com/search?q=%s",
+ /* For the preferences dialog. Consider a regional variant, like uk.bing.com */
+ N_("https://www.bing.com/search?q=%s") }
+ };
+
+ for (i = 0; i < G_N_ELEMENTS (default_engines); ++i) {
+ gtk_list_store_insert_with_values (store, NULL, -1,
+ SEARCH_ENGINE_COL_NAME,
+ _(default_engines[i][0]),
+ SEARCH_ENGINE_COL_STOCK_URL,
+ default_engines[i][1],
+ SEARCH_ENGINE_COL_URL,
+ _(default_engines[i][2]),
+ -1);
+ }
}
static void
search_engine_combo_add_smart_bookmarks (GtkListStore *store)
{
- guint i;
- EphyBookmarks *bookmarks;
- EphyNode *smart_bookmarks_parent_node;
- GPtrArray *smart_bookmarks;
-
- bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
- smart_bookmarks_parent_node = ephy_bookmarks_get_smart_bookmarks (bookmarks);
- smart_bookmarks = ephy_node_get_children (smart_bookmarks_parent_node);
-
- if (!smart_bookmarks)
- return;
-
- for (i = 0; i < smart_bookmarks->len; ++i)
- {
- EphyNode *bookmark;
- const char *bookmark_name;
- const char *bookmark_url;
-
- bookmark = g_ptr_array_index (smart_bookmarks, i);
- bookmark_name = ephy_node_get_property_string (bookmark, EPHY_NODE_BMK_PROP_TITLE);
- bookmark_url = ephy_node_get_property_string (bookmark, EPHY_NODE_BMK_PROP_LOCATION);
-
- if (!bookmark_name || !bookmark_url)
- continue;
-
- if (strcmp (bookmark_name, DEFAULT_SMART_BOOKMARK_TEXT) == 0)
- continue;
-
- gtk_list_store_insert_with_values (store, NULL, -1,
- SEARCH_ENGINE_COL_NAME, bookmark_name,
- SEARCH_ENGINE_COL_STOCK_URL, bookmark_url,
- SEARCH_ENGINE_COL_URL, bookmark_url,
- -1);
- }
+ guint i;
+ EphyBookmarks *bookmarks;
+ EphyNode *smart_bookmarks_parent_node;
+ GPtrArray *smart_bookmarks;
+
+ bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
+ smart_bookmarks_parent_node = ephy_bookmarks_get_smart_bookmarks (bookmarks);
+ smart_bookmarks = ephy_node_get_children (smart_bookmarks_parent_node);
+
+ if (!smart_bookmarks)
+ return;
+
+ for (i = 0; i < smart_bookmarks->len; ++i) {
+ EphyNode *bookmark;
+ const char *bookmark_name;
+ const char *bookmark_url;
+
+ bookmark = g_ptr_array_index (smart_bookmarks, i);
+ bookmark_name = ephy_node_get_property_string (bookmark, EPHY_NODE_BMK_PROP_TITLE);
+ bookmark_url = ephy_node_get_property_string (bookmark, EPHY_NODE_BMK_PROP_LOCATION);
+
+ if (!bookmark_name || !bookmark_url)
+ continue;
+
+ if (strcmp (bookmark_name, DEFAULT_SMART_BOOKMARK_TEXT) == 0)
+ continue;
+
+ gtk_list_store_insert_with_values (store, NULL, -1,
+ SEARCH_ENGINE_COL_NAME, bookmark_name,
+ SEARCH_ENGINE_COL_STOCK_URL, bookmark_url,
+ SEARCH_ENGINE_COL_URL, bookmark_url,
+ -1);
+ }
}
/* Has the user manually set the engine to something not in the combo?
@@ -1011,270 +974,269 @@ search_engine_combo_add_smart_bookmarks (GtkListStore *store)
static void
search_engine_combo_add_current_engine (GtkListStore *store)
{
- GtkTreeIter iter;
- char *original_url;
- gboolean in_combo = FALSE;
- gboolean has_next = FALSE;
-
- original_url = g_settings_get_string (EPHY_SETTINGS_MAIN,
- EPHY_PREFS_KEYWORD_SEARCH_URL);
- if (!original_url)
- return;
-
- has_next = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
-
- while (!in_combo && has_next)
- {
- char *stock_url, *url;
-
- gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
- SEARCH_ENGINE_COL_STOCK_URL, &stock_url,
- SEARCH_ENGINE_COL_URL, &url, -1);
-
- if (strcmp (original_url, stock_url) == 0 ||
- strcmp (original_url, url) == 0)
- in_combo = TRUE;
-
- g_free (stock_url);
- g_free (url);
- has_next = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter);
- }
-
- if (!in_combo)
- gtk_list_store_insert_with_values (store, NULL, -1,
- SEARCH_ENGINE_COL_NAME, original_url,
- SEARCH_ENGINE_COL_STOCK_URL, original_url,
- SEARCH_ENGINE_COL_URL, original_url,
- -1);
-
- g_free (original_url);
+ GtkTreeIter iter;
+ char *original_url;
+ gboolean in_combo = FALSE;
+ gboolean has_next = FALSE;
+
+ original_url = g_settings_get_string (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_KEYWORD_SEARCH_URL);
+ if (!original_url)
+ return;
+
+ has_next = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
+
+ while (!in_combo && has_next) {
+ char *stock_url, *url;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
+ SEARCH_ENGINE_COL_STOCK_URL, &stock_url,
+ SEARCH_ENGINE_COL_URL, &url, -1);
+
+ if (strcmp (original_url, stock_url) == 0 ||
+ strcmp (original_url, url) == 0)
+ in_combo = TRUE;
+
+ g_free (stock_url);
+ g_free (url);
+ has_next = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter);
+ }
+
+ if (!in_combo)
+ gtk_list_store_insert_with_values (store, NULL, -1,
+ SEARCH_ENGINE_COL_NAME, original_url,
+ SEARCH_ENGINE_COL_STOCK_URL, original_url,
+ SEARCH_ENGINE_COL_URL, original_url,
+ -1);
+
+ g_free (original_url);
}
static void
create_search_engine_combo (GtkComboBox *combo)
{
- GtkCellRenderer *renderer;
- GtkListStore *store;
-
- store = GTK_LIST_STORE (gtk_combo_box_get_model (combo));
-
- search_engine_combo_add_default_engines (store);
- search_engine_combo_add_smart_bookmarks (store);
- search_engine_combo_add_current_engine (store);
-
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), SEARCH_ENGINE_COL_NAME,
- GTK_SORT_ASCENDING);
- gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store));
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,
- "text", SEARCH_ENGINE_COL_NAME,
- NULL);
-
- g_settings_bind_with_mapping (EPHY_SETTINGS_MAIN,
- EPHY_PREFS_KEYWORD_SEARCH_URL,
- combo, "active",
- G_SETTINGS_BIND_DEFAULT,
- combo_get_mapping,
- combo_set_mapping,
- combo,
- NULL);
+ GtkCellRenderer *renderer;
+ GtkListStore *store;
+
+ store = GTK_LIST_STORE (gtk_combo_box_get_model (combo));
+
+ search_engine_combo_add_default_engines (store);
+ search_engine_combo_add_smart_bookmarks (store);
+ search_engine_combo_add_current_engine (store);
+
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), SEARCH_ENGINE_COL_NAME,
+ GTK_SORT_ASCENDING);
+ gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store));
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,
+ "text", SEARCH_ENGINE_COL_NAME,
+ NULL);
+
+ g_settings_bind_with_mapping (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_KEYWORD_SEARCH_URL,
+ combo, "active",
+ G_SETTINGS_BIND_DEFAULT,
+ combo_get_mapping,
+ combo_set_mapping,
+ combo,
+ NULL);
}
static gboolean
-restore_session_get_mapping (GValue *value,
- GVariant *variant,
- gpointer user_data)
+restore_session_get_mapping (GValue *value,
+ GVariant *variant,
+ gpointer user_data)
{
- const char *policy = g_variant_get_string (variant, NULL);
- /* FIXME: Is it possible to somehow use EPHY_PREFS_RESTORE_SESSION_POLICY_ALWAYS here? */
- g_value_set_boolean (value, !strcmp (policy, "always"));
- return TRUE;
+ const char *policy = g_variant_get_string (variant, NULL);
+ /* FIXME: Is it possible to somehow use EPHY_PREFS_RESTORE_SESSION_POLICY_ALWAYS here? */
+ g_value_set_boolean (value, !strcmp (policy, "always"));
+ return TRUE;
}
static GVariant *
-restore_session_set_mapping (const GValue *value,
- const GVariantType *expected_type,
- gpointer user_data)
+restore_session_set_mapping (const GValue *value,
+ const GVariantType *expected_type,
+ gpointer user_data)
{
- /* FIXME: Is it possible to somehow use EphyPrefsRestoreSessionPolicy here? */
- if (g_value_get_boolean (value))
- return g_variant_new_string ("always");
- return g_variant_new_string ("crashed");
+ /* FIXME: Is it possible to somehow use EphyPrefsRestoreSessionPolicy here? */
+ if (g_value_get_boolean (value))
+ return g_variant_new_string ("always");
+ return g_variant_new_string ("crashed");
}
static void
setup_general_page (PrefsDialog *dialog)
{
- GSettings *settings;
- GSettings *web_settings;
-
- settings = ephy_settings_get (EPHY_PREFS_SCHEMA);
- web_settings = ephy_settings_get (EPHY_PREFS_WEB_SCHEMA);
-
- g_settings_bind (settings,
- EPHY_PREFS_AUTO_DOWNLOADS,
- dialog->automatic_downloads_checkbutton,
- "active",
- G_SETTINGS_BIND_DEFAULT);
- g_settings_bind_with_mapping (settings,
- EPHY_PREFS_RESTORE_SESSION_POLICY,
- dialog->restore_session_checkbutton,
- "active",
- G_SETTINGS_BIND_DEFAULT,
- restore_session_get_mapping,
- restore_session_set_mapping,
- NULL, NULL);
- g_settings_bind (web_settings,
- EPHY_PREFS_WEB_ENABLE_POPUPS,
- dialog->popups_allow_checkbutton,
- "active",
- G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (web_settings,
- EPHY_PREFS_WEB_ENABLE_ADBLOCK,
- dialog->adblock_allow_checkbutton,
- "active",
- G_SETTINGS_BIND_INVERT_BOOLEAN);
- g_settings_bind (web_settings,
- EPHY_PREFS_WEB_ENABLE_PLUGINS,
- dialog->enable_plugins_checkbutton,
- "active",
- G_SETTINGS_BIND_DEFAULT);
-
- create_download_path_button (dialog);
- create_search_engine_combo (GTK_COMBO_BOX (dialog->search_engine_combo));
+ GSettings *settings;
+ GSettings *web_settings;
+
+ settings = ephy_settings_get (EPHY_PREFS_SCHEMA);
+ web_settings = ephy_settings_get (EPHY_PREFS_WEB_SCHEMA);
+
+ g_settings_bind (settings,
+ EPHY_PREFS_AUTO_DOWNLOADS,
+ dialog->automatic_downloads_checkbutton,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind_with_mapping (settings,
+ EPHY_PREFS_RESTORE_SESSION_POLICY,
+ dialog->restore_session_checkbutton,
+ "active",
+ G_SETTINGS_BIND_DEFAULT,
+ restore_session_get_mapping,
+ restore_session_set_mapping,
+ NULL, NULL);
+ g_settings_bind (web_settings,
+ EPHY_PREFS_WEB_ENABLE_POPUPS,
+ dialog->popups_allow_checkbutton,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (web_settings,
+ EPHY_PREFS_WEB_ENABLE_ADBLOCK,
+ dialog->adblock_allow_checkbutton,
+ "active",
+ G_SETTINGS_BIND_INVERT_BOOLEAN);
+ g_settings_bind (web_settings,
+ EPHY_PREFS_WEB_ENABLE_PLUGINS,
+ dialog->enable_plugins_checkbutton,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+
+ create_download_path_button (dialog);
+ create_search_engine_combo (GTK_COMBO_BOX (dialog->search_engine_combo));
}
static void
setup_fonts_page (PrefsDialog *dialog)
{
- GSettings *web_settings;
-
- web_settings = ephy_settings_get (EPHY_PREFS_WEB_SCHEMA);
-
- g_settings_bind (web_settings,
- EPHY_PREFS_WEB_USE_GNOME_FONTS,
- dialog->use_gnome_fonts_checkbutton,
- "active",
- G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (web_settings,
- EPHY_PREFS_WEB_USE_GNOME_FONTS,
- dialog->custom_fonts_table,
- "sensitive",
- G_SETTINGS_BIND_GET | G_SETTINGS_BIND_INVERT_BOOLEAN);
- g_settings_bind (web_settings,
- EPHY_PREFS_WEB_SANS_SERIF_FONT,
- dialog->sans_fontbutton,
- "font-name",
- G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (web_settings,
- EPHY_PREFS_WEB_SERIF_FONT,
- dialog->serif_fontbutton,
- "font-name",
- G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (web_settings,
- EPHY_PREFS_WEB_MONOSPACE_FONT,
- dialog->mono_fontbutton,
- "font-name",
- G_SETTINGS_BIND_DEFAULT);
-
- g_settings_bind (web_settings,
- EPHY_PREFS_WEB_ENABLE_USER_CSS,
- dialog->css_checkbox,
- "active",
- G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (web_settings,
- EPHY_PREFS_WEB_ENABLE_USER_CSS,
- dialog->css_edit_button,
- "sensitive",
- G_SETTINGS_BIND_GET);
- g_signal_connect (dialog->css_edit_button,
- "clicked",
- G_CALLBACK (css_edit_button_clicked_cb),
- dialog);
+ GSettings *web_settings;
+
+ web_settings = ephy_settings_get (EPHY_PREFS_WEB_SCHEMA);
+
+ g_settings_bind (web_settings,
+ EPHY_PREFS_WEB_USE_GNOME_FONTS,
+ dialog->use_gnome_fonts_checkbutton,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (web_settings,
+ EPHY_PREFS_WEB_USE_GNOME_FONTS,
+ dialog->custom_fonts_table,
+ "sensitive",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_INVERT_BOOLEAN);
+ g_settings_bind (web_settings,
+ EPHY_PREFS_WEB_SANS_SERIF_FONT,
+ dialog->sans_fontbutton,
+ "font-name",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (web_settings,
+ EPHY_PREFS_WEB_SERIF_FONT,
+ dialog->serif_fontbutton,
+ "font-name",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (web_settings,
+ EPHY_PREFS_WEB_MONOSPACE_FONT,
+ dialog->mono_fontbutton,
+ "font-name",
+ G_SETTINGS_BIND_DEFAULT);
+
+ g_settings_bind (web_settings,
+ EPHY_PREFS_WEB_ENABLE_USER_CSS,
+ dialog->css_checkbox,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (web_settings,
+ EPHY_PREFS_WEB_ENABLE_USER_CSS,
+ dialog->css_edit_button,
+ "sensitive",
+ G_SETTINGS_BIND_GET);
+ g_signal_connect (dialog->css_edit_button,
+ "clicked",
+ G_CALLBACK (css_edit_button_clicked_cb),
+ dialog);
}
static void
setup_privacy_page (PrefsDialog *dialog)
{
- GSettings *settings;
- GSettings *web_settings;
-
- settings = ephy_settings_get (EPHY_PREFS_SCHEMA);
- web_settings = ephy_settings_get (EPHY_PREFS_WEB_SCHEMA);
-
- g_settings_bind_with_mapping (web_settings,
- EPHY_PREFS_WEB_COOKIES_POLICY,
- dialog->always,
- "active",
- G_SETTINGS_BIND_DEFAULT,
- cookies_get_mapping,
- cookies_set_mapping,
- dialog->always,
- NULL);
- g_settings_bind_with_mapping (web_settings,
- EPHY_PREFS_WEB_COOKIES_POLICY,
- dialog->no_third_party,
- "active",
- G_SETTINGS_BIND_DEFAULT,
- cookies_get_mapping,
- cookies_set_mapping,
- dialog->no_third_party,
- NULL);
- g_settings_bind_with_mapping (web_settings,
- EPHY_PREFS_WEB_COOKIES_POLICY,
- dialog->never,
- "active",
- G_SETTINGS_BIND_DEFAULT,
- cookies_get_mapping,
- cookies_set_mapping,
- dialog->never,
- NULL);
- g_settings_bind (settings,
- EPHY_PREFS_REMEMBER_PASSWORDS,
- dialog->remember_passwords_checkbutton,
- "active",
- G_SETTINGS_BIND_DEFAULT);
- g_settings_bind (web_settings,
- EPHY_PREFS_WEB_DO_NOT_TRACK,
- dialog->do_not_track_checkbutton,
- "active",
- G_SETTINGS_BIND_DEFAULT);
-
- g_signal_connect (dialog->clear_personal_data_button,
- "clicked",
- G_CALLBACK (clear_personal_data_button_clicked_cb),
- dialog);
+ GSettings *settings;
+ GSettings *web_settings;
+
+ settings = ephy_settings_get (EPHY_PREFS_SCHEMA);
+ web_settings = ephy_settings_get (EPHY_PREFS_WEB_SCHEMA);
+
+ g_settings_bind_with_mapping (web_settings,
+ EPHY_PREFS_WEB_COOKIES_POLICY,
+ dialog->always,
+ "active",
+ G_SETTINGS_BIND_DEFAULT,
+ cookies_get_mapping,
+ cookies_set_mapping,
+ dialog->always,
+ NULL);
+ g_settings_bind_with_mapping (web_settings,
+ EPHY_PREFS_WEB_COOKIES_POLICY,
+ dialog->no_third_party,
+ "active",
+ G_SETTINGS_BIND_DEFAULT,
+ cookies_get_mapping,
+ cookies_set_mapping,
+ dialog->no_third_party,
+ NULL);
+ g_settings_bind_with_mapping (web_settings,
+ EPHY_PREFS_WEB_COOKIES_POLICY,
+ dialog->never,
+ "active",
+ G_SETTINGS_BIND_DEFAULT,
+ cookies_get_mapping,
+ cookies_set_mapping,
+ dialog->never,
+ NULL);
+ g_settings_bind (settings,
+ EPHY_PREFS_REMEMBER_PASSWORDS,
+ dialog->remember_passwords_checkbutton,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (web_settings,
+ EPHY_PREFS_WEB_DO_NOT_TRACK,
+ dialog->do_not_track_checkbutton,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+
+ g_signal_connect (dialog->clear_personal_data_button,
+ "clicked",
+ G_CALLBACK (clear_personal_data_button_clicked_cb),
+ dialog);
}
static void
setup_language_page (PrefsDialog *dialog)
{
- GSettings *web_settings;
+ GSettings *web_settings;
- web_settings = ephy_settings_get (EPHY_PREFS_WEB_SCHEMA);
+ web_settings = ephy_settings_get (EPHY_PREFS_WEB_SCHEMA);
- g_settings_bind (web_settings,
- EPHY_PREFS_WEB_ENABLE_SPELL_CHECKING,
- dialog->enable_spell_checking_checkbutton,
- "active",
- G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (web_settings,
+ EPHY_PREFS_WEB_ENABLE_SPELL_CHECKING,
+ dialog->enable_spell_checking_checkbutton,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
- create_language_section (dialog);
+ create_language_section (dialog);
}
static void
prefs_dialog_init (PrefsDialog *dialog)
{
- gtk_widget_init_template (GTK_WIDGET (dialog));
+ gtk_widget_init_template (GTK_WIDGET (dialog));
- setup_general_page (dialog);
- setup_fonts_page (dialog);
- setup_privacy_page (dialog);
- setup_language_page (dialog);
+ setup_general_page (dialog);
+ setup_fonts_page (dialog);
+ setup_privacy_page (dialog);
+ setup_language_page (dialog);
- ephy_gui_ensure_window_group (GTK_WINDOW (dialog));
- g_signal_connect (dialog, "response",
- G_CALLBACK (prefs_dialog_response_cb), dialog);
+ ephy_gui_ensure_window_group (GTK_WINDOW (dialog));
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (prefs_dialog_response_cb), dialog);
}
diff --git a/src/window-commands.c b/src/window-commands.c
index c899e4e..c83fdd5 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -62,302 +62,284 @@
#define FAVICON_SIZE 16
void
-window_cmd_file_print (GtkAction *action,
- EphyWindow *window)
+window_cmd_file_print (GtkAction *action,
+ EphyWindow *window)
{
- EphyEmbed *embed;
- EphyWebView *view;
+ EphyEmbed *embed;
+ EphyWebView *view;
- embed = ephy_embed_container_get_active_child
- (EPHY_EMBED_CONTAINER (window));
- g_return_if_fail (EPHY_IS_EMBED (embed));
- view = ephy_embed_get_web_view (embed);
+ embed = ephy_embed_container_get_active_child
+ (EPHY_EMBED_CONTAINER (window));
+ g_return_if_fail (EPHY_IS_EMBED (embed));
+ view = ephy_embed_get_web_view (embed);
- ephy_web_view_print (view);
+ ephy_web_view_print (view);
}
void
-window_cmd_undo_close_tab (GtkAction *action,
- EphyWindow *window)
+window_cmd_undo_close_tab (GtkAction *action,
+ EphyWindow *window)
{
- ephy_session_undo_close_tab (ephy_shell_get_session (ephy_shell_get_default ()));
+ ephy_session_undo_close_tab (ephy_shell_get_session (ephy_shell_get_default ()));
}
void
-window_cmd_file_send_to (GtkAction *action,
- EphyWindow *window)
-{
- EphyEmbed *embed;
- char *command, *subject, *body;
- const char *location, *title;
- GdkScreen *screen;
- GError *error = NULL;
-
- embed = ephy_embed_container_get_active_child
- (EPHY_EMBED_CONTAINER (window));
- g_return_if_fail (embed != NULL);
-
- location = ephy_web_view_get_address (ephy_embed_get_web_view (embed));
- title = ephy_embed_get_title (embed);
-
- subject = g_uri_escape_string (title, NULL, TRUE);
- body = g_uri_escape_string (location, NULL, TRUE);
-
- command = g_strconcat ("mailto:",
- "?Subject=", subject,
- "&Body=", body, NULL);
-
- g_free (subject);
- g_free (body);
-
- if (window)
- {
- screen = gtk_widget_get_screen (GTK_WIDGET (window));
- }
- else
- {
- screen = gdk_screen_get_default ();
- }
-
- if (!gtk_show_uri (screen, command, gtk_get_current_event_time(), &error))
- {
- g_warning ("Unable to send link by email: %s\n", error->message);
- g_error_free (error);
- }
-
- g_free (command);
+window_cmd_file_send_to (GtkAction *action,
+ EphyWindow *window)
+{
+ EphyEmbed *embed;
+ char *command, *subject, *body;
+ const char *location, *title;
+ GdkScreen *screen;
+ GError *error = NULL;
+
+ embed = ephy_embed_container_get_active_child
+ (EPHY_EMBED_CONTAINER (window));
+ g_return_if_fail (embed != NULL);
+
+ location = ephy_web_view_get_address (ephy_embed_get_web_view (embed));
+ title = ephy_embed_get_title (embed);
+
+ subject = g_uri_escape_string (title, NULL, TRUE);
+ body = g_uri_escape_string (location, NULL, TRUE);
+
+ command = g_strconcat ("mailto:",
+ "?Subject=", subject,
+ "&Body=", body, NULL);
+
+ g_free (subject);
+ g_free (body);
+
+ if (window) {
+ screen = gtk_widget_get_screen (GTK_WIDGET (window));
+ } else {
+ screen = gdk_screen_get_default ();
+ }
+
+ if (!gtk_show_uri (screen, command, gtk_get_current_event_time (), &error)) {
+ g_warning ("Unable to send link by email: %s\n", error->message);
+ g_error_free (error);
+ }
+
+ g_free (command);
}
static gboolean
event_with_shift (void)
{
- GdkEvent *event;
- GdkEventType type = 0;
- guint state = 0;
+ GdkEvent *event;
+ GdkEventType type = 0;
+ guint state = 0;
- event = gtk_get_current_event ();
- if (event)
- {
- type = event->type;
+ event = gtk_get_current_event ();
+ if (event) {
+ type = event->type;
- if (type == GDK_BUTTON_RELEASE)
- {
- state = event->button.state;
- }
- else if (type == GDK_KEY_PRESS || type == GDK_KEY_RELEASE)
- {
- state = event->key.state;
- }
+ if (type == GDK_BUTTON_RELEASE) {
+ state = event->button.state;
+ } else if (type == GDK_KEY_PRESS || type == GDK_KEY_RELEASE) {
+ state = event->key.state;
+ }
- gdk_event_free (event);
- }
+ gdk_event_free (event);
+ }
- return (state & GDK_SHIFT_MASK) != 0;
+ return (state & GDK_SHIFT_MASK) != 0;
}
void
-window_cmd_go_location (GtkAction *action,
- EphyWindow *window)
+window_cmd_go_location (GtkAction *action,
+ EphyWindow *window)
{
- ephy_window_activate_location (window);
+ ephy_window_activate_location (window);
}
void
-window_cmd_view_stop (GtkAction *action,
- EphyWindow *window)
+window_cmd_view_stop (GtkAction *action,
+ EphyWindow *window)
{
- EphyEmbed *embed;
-
- embed = ephy_embed_container_get_active_child
- (EPHY_EMBED_CONTAINER (window));
- g_return_if_fail (embed != NULL);
+ EphyEmbed *embed;
+
+ embed = ephy_embed_container_get_active_child
+ (EPHY_EMBED_CONTAINER (window));
+ g_return_if_fail (embed != NULL);
- gtk_widget_grab_focus (GTK_WIDGET (embed));
+ gtk_widget_grab_focus (GTK_WIDGET (embed));
- webkit_web_view_stop_loading (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed));
+ webkit_web_view_stop_loading (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed));
}
void
-window_cmd_view_reload (GtkAction *action,
- EphyWindow *window)
+window_cmd_view_reload (GtkAction *action,
+ EphyWindow *window)
{
- EphyEmbed *embed;
- WebKitWebView *view;
+ EphyEmbed *embed;
+ WebKitWebView *view;
- embed = ephy_embed_container_get_active_child
- (EPHY_EMBED_CONTAINER (window));
- g_return_if_fail (embed != NULL);
+ embed = ephy_embed_container_get_active_child
+ (EPHY_EMBED_CONTAINER (window));
+ g_return_if_fail (embed != NULL);
- gtk_widget_grab_focus (GTK_WIDGET (embed));
+ gtk_widget_grab_focus (GTK_WIDGET (embed));
- view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
- if (event_with_shift ())
- webkit_web_view_reload_bypass_cache (view);
- else
- webkit_web_view_reload (view);
+ view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
+ if (event_with_shift ())
+ webkit_web_view_reload_bypass_cache (view);
+ else
+ webkit_web_view_reload (view);
}
void
-window_cmd_file_bookmark_page (GtkAction *action,
- EphyWindow *window)
+window_cmd_file_bookmark_page (GtkAction *action,
+ EphyWindow *window)
{
- EphyEmbed *embed;
+ EphyEmbed *embed;
- embed = ephy_embed_container_get_active_child
- (EPHY_EMBED_CONTAINER (window));
- g_return_if_fail (embed != NULL);
+ embed = ephy_embed_container_get_active_child
+ (EPHY_EMBED_CONTAINER (window));
+ g_return_if_fail (embed != NULL);
- ephy_bookmarks_ui_add_bookmark (GTK_WINDOW (window),
- ephy_web_view_get_address (ephy_embed_get_web_view (embed)),
- ephy_embed_get_title (embed));
+ ephy_bookmarks_ui_add_bookmark (GTK_WINDOW (window),
+ ephy_web_view_get_address (ephy_embed_get_web_view (embed)),
+ ephy_embed_get_title (embed));
}
static void
open_response_cb (GtkDialog *dialog, int response, EphyWindow *window)
{
- if (response == GTK_RESPONSE_ACCEPT)
- {
- char *uri, *converted;
+ if (response == GTK_RESPONSE_ACCEPT) {
+ char *uri, *converted;
- uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
- if (uri != NULL)
- {
- converted = g_filename_to_utf8 (uri, -1, NULL, NULL, NULL);
-
- if (converted != NULL)
- {
- ephy_window_load_url (window, converted);
- }
-
- g_free (converted);
- g_free (uri);
- }
- }
+ uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
+ if (uri != NULL) {
+ converted = g_filename_to_utf8 (uri, -1, NULL, NULL, NULL);
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ if (converted != NULL) {
+ ephy_window_load_url (window, converted);
+ }
+
+ g_free (converted);
+ g_free (uri);
+ }
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
}
static void
save_response_cb (GtkDialog *dialog, int response, EphyEmbed *embed)
{
- if (response == GTK_RESPONSE_ACCEPT)
- {
- char *uri, *converted;
+ if (response == GTK_RESPONSE_ACCEPT) {
+ char *uri, *converted;
- uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
- if (uri != NULL)
- {
- converted = g_filename_to_utf8 (uri, -1, NULL, NULL, NULL);
+ uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
+ if (uri != NULL) {
+ converted = g_filename_to_utf8 (uri, -1, NULL, NULL, NULL);
- if (converted != NULL)
- {
- EphyWebView *web_view = ephy_embed_get_web_view (embed);
- ephy_web_view_save (web_view, converted);
- }
+ if (converted != NULL) {
+ EphyWebView *web_view = ephy_embed_get_web_view (embed);
+ ephy_web_view_save (web_view, converted);
+ }
- g_free (converted);
- g_free (uri);
- }
- }
+ g_free (converted);
+ g_free (uri);
+ }
+ }
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_widget_destroy (GTK_WIDGET (dialog));
}
void
-window_cmd_file_open (GtkAction *action,
- EphyWindow *window)
+window_cmd_file_open (GtkAction *action,
+ EphyWindow *window)
{
- EphyFileChooser *dialog;
+ EphyFileChooser *dialog;
- dialog = ephy_file_chooser_new (_("Open"),
- GTK_WIDGET (window),
- GTK_FILE_CHOOSER_ACTION_OPEN,
- EPHY_FILE_FILTER_ALL_SUPPORTED);
+ dialog = ephy_file_chooser_new (_("Open"),
+ GTK_WIDGET (window),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ EPHY_FILE_FILTER_ALL_SUPPORTED);
- g_signal_connect (dialog, "response",
- G_CALLBACK (open_response_cb), window);
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (open_response_cb), window);
- gtk_widget_show (GTK_WIDGET (dialog));
+ gtk_widget_show (GTK_WIDGET (dialog));
}
static char *
get_suggested_filename (EphyEmbed *embed)
{
- EphyWebView *view;
- char *suggested_filename = NULL;
- const char *mimetype;
- WebKitURIResponse *response;
- WebKitWebResource *web_resource;
-
- view = ephy_embed_get_web_view (embed);
- web_resource = webkit_web_view_get_main_resource (WEBKIT_WEB_VIEW (view));
- response = webkit_web_resource_get_response (web_resource);
- mimetype = webkit_uri_response_get_mime_type (response);
-
- if ((g_ascii_strncasecmp (mimetype, "text/html", 9)) == 0)
- {
- /* Web Title will be used as suggested filename */
- suggested_filename = g_strconcat (ephy_embed_get_title (embed), ".mhtml", NULL);
- }
- else
- {
- suggested_filename = g_strdup (webkit_uri_response_get_suggested_filename (response));
- if (!suggested_filename)
- {
- SoupURI *soup_uri = soup_uri_new (webkit_web_resource_get_uri (web_resource));
- suggested_filename = g_path_get_basename (soup_uri->path);
- soup_uri_free (soup_uri);
- }
- }
-
- return suggested_filename;
+ EphyWebView *view;
+ char *suggested_filename = NULL;
+ const char *mimetype;
+ WebKitURIResponse *response;
+ WebKitWebResource *web_resource;
+
+ view = ephy_embed_get_web_view (embed);
+ web_resource = webkit_web_view_get_main_resource (WEBKIT_WEB_VIEW (view));
+ response = webkit_web_resource_get_response (web_resource);
+ mimetype = webkit_uri_response_get_mime_type (response);
+
+ if ((g_ascii_strncasecmp (mimetype, "text/html", 9)) == 0) {
+ /* Web Title will be used as suggested filename */
+ suggested_filename = g_strconcat (ephy_embed_get_title (embed), ".mhtml", NULL);
+ } else {
+ suggested_filename = g_strdup (webkit_uri_response_get_suggested_filename (response));
+ if (!suggested_filename) {
+ SoupURI *soup_uri = soup_uri_new (webkit_web_resource_get_uri (web_resource));
+ suggested_filename = g_path_get_basename (soup_uri->path);
+ soup_uri_free (soup_uri);
+ }
+ }
+
+ return suggested_filename;
}
void
-window_cmd_file_save_as (GtkAction *action,
- EphyWindow *window)
+window_cmd_file_save_as (GtkAction *action,
+ EphyWindow *window)
{
- EphyEmbed *embed;
- EphyFileChooser *dialog;
- char *suggested_filename;
+ EphyEmbed *embed;
+ EphyFileChooser *dialog;
+ char *suggested_filename;
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
- g_return_if_fail (embed != NULL);
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+ g_return_if_fail (embed != NULL);
- dialog = ephy_file_chooser_new (_("Save"),
- GTK_WIDGET (window),
- GTK_FILE_CHOOSER_ACTION_SAVE,
- EPHY_FILE_FILTER_NONE);
+ dialog = ephy_file_chooser_new (_("Save"),
+ GTK_WIDGET (window),
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ EPHY_FILE_FILTER_NONE);
- gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
+ gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
- suggested_filename = ephy_sanitize_filename (get_suggested_filename (embed));
+ suggested_filename = ephy_sanitize_filename (get_suggested_filename (embed));
- gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), suggested_filename);
- g_free (suggested_filename);
+ gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), suggested_filename);
+ g_free (suggested_filename);
- g_signal_connect (dialog, "response",
- G_CALLBACK (save_response_cb), embed);
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (save_response_cb), embed);
- gtk_widget_show (GTK_WIDGET (dialog));
+ gtk_widget_show (GTK_WIDGET (dialog));
}
typedef struct {
- EphyWebView *view;
- GtkWidget *image;
- GtkWidget *entry;
- GtkWidget *spinner;
- GtkWidget *spinner_box;
- GtkWidget *box;
- char *icon_href;
- GdkRGBA icon_rgba;
+ EphyWebView *view;
+ GtkWidget *image;
+ GtkWidget *entry;
+ GtkWidget *spinner;
+ GtkWidget *spinner_box;
+ GtkWidget *box;
+ char *icon_href;
+ GdkRGBA icon_rgba;
} EphyApplicationDialogData;
static void
ephy_application_dialog_data_free (EphyApplicationDialogData *data)
{
- g_free (data->icon_href);
- g_slice_free (EphyApplicationDialogData, data);
+ g_free (data->icon_href);
+ g_slice_free (EphyApplicationDialogData, data);
}
static void
@@ -369,329 +351,321 @@ rounded_rectangle (cairo_t *cr,
gdouble width,
gdouble height)
{
- gdouble radius;
- gdouble degrees;
-
- radius = corner_radius / aspect;
- degrees = G_PI / 180.0;
-
- cairo_new_sub_path (cr);
- cairo_arc (cr,
- x + width - radius,
- y + radius,
- radius,
- -90 * degrees,
- 0 * degrees);
- cairo_arc (cr,
- x + width - radius,
- y + height - radius,
- radius,
- 0 * degrees,
- 90 * degrees);
- cairo_arc (cr,
- x + radius,
- y + height - radius,
- radius,
- 90 * degrees,
- 180 * degrees);
- cairo_arc (cr,
- x + radius,
- y + radius,
- radius,
- 180 * degrees,
- 270 * degrees);
- cairo_close_path (cr);
+ gdouble radius;
+ gdouble degrees;
+
+ radius = corner_radius / aspect;
+ degrees = G_PI / 180.0;
+
+ cairo_new_sub_path (cr);
+ cairo_arc (cr,
+ x + width - radius,
+ y + radius,
+ radius,
+ -90 * degrees,
+ 0 * degrees);
+ cairo_arc (cr,
+ x + width - radius,
+ y + height - radius,
+ radius,
+ 0 * degrees,
+ 90 * degrees);
+ cairo_arc (cr,
+ x + radius,
+ y + height - radius,
+ radius,
+ 90 * degrees,
+ 180 * degrees);
+ cairo_arc (cr,
+ x + radius,
+ y + radius,
+ radius,
+ 180 * degrees,
+ 270 * degrees);
+ cairo_close_path (cr);
}
static GdkPixbuf *
-frame_pixbuf (GdkPixbuf *pixbuf,
- GdkRGBA *rgba,
- int width,
- int height)
-{
- GdkPixbuf *framed;
- cairo_surface_t *surface;
- cairo_t *cr;
- int frame_width;
- int radius;
-
- surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
- width, height);
- cr = cairo_create (surface);
-
- frame_width = 0;
- radius = 20;
-
- rounded_rectangle (cr,
- 1.0,
- frame_width + 0.5,
- frame_width + 0.5,
- radius,
- width - frame_width * 2 - 1,
- height - frame_width * 2 - 1);
- if (rgba != NULL)
- cairo_set_source_rgba (cr,
- rgba->red,
- rgba->green,
- rgba->blue,
- rgba->alpha);
- else
- cairo_set_source_rgba (cr, 0.5, 0.5, 0.5, 0.3);
- cairo_fill_preserve (cr);
-
- if (pixbuf != NULL) {
- GdkPixbuf *scaled;
- int w;
- int h;
-
- w = gdk_pixbuf_get_width (pixbuf);
- h = gdk_pixbuf_get_height (pixbuf);
-
- if (w < 48 || h < 48) {
- scaled = gdk_pixbuf_scale_simple (pixbuf, w * 3, h * 3, GDK_INTERP_NEAREST);
- } else if (w > width || h > height) {
- double ws, hs, s;
-
- ws = (double) width / w;
- hs = (double) height / h;
- s = MIN (ws, hs);
- scaled = gdk_pixbuf_scale_simple (pixbuf, w * s, h * s, GDK_INTERP_BILINEAR);
- } else {
- scaled = g_object_ref (pixbuf);
- }
-
- w = gdk_pixbuf_get_width (scaled);
- h = gdk_pixbuf_get_height (scaled);
-
- gdk_cairo_set_source_pixbuf (cr, scaled,
- (width - w) / 2,
- (height - h) / 2);
- g_object_unref (scaled);
- cairo_fill (cr);
- }
-
- framed = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height);
- cairo_destroy (cr);
- cairo_surface_destroy (surface);
-
- return framed;
+frame_pixbuf (GdkPixbuf *pixbuf,
+ GdkRGBA *rgba,
+ int width,
+ int height)
+{
+ GdkPixbuf *framed;
+ cairo_surface_t *surface;
+ cairo_t *cr;
+ int frame_width;
+ int radius;
+
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+ width, height);
+ cr = cairo_create (surface);
+
+ frame_width = 0;
+ radius = 20;
+
+ rounded_rectangle (cr,
+ 1.0,
+ frame_width + 0.5,
+ frame_width + 0.5,
+ radius,
+ width - frame_width * 2 - 1,
+ height - frame_width * 2 - 1);
+ if (rgba != NULL)
+ cairo_set_source_rgba (cr,
+ rgba->red,
+ rgba->green,
+ rgba->blue,
+ rgba->alpha);
+ else
+ cairo_set_source_rgba (cr, 0.5, 0.5, 0.5, 0.3);
+ cairo_fill_preserve (cr);
+
+ if (pixbuf != NULL) {
+ GdkPixbuf *scaled;
+ int w;
+ int h;
+
+ w = gdk_pixbuf_get_width (pixbuf);
+ h = gdk_pixbuf_get_height (pixbuf);
+
+ if (w < 48 || h < 48) {
+ scaled = gdk_pixbuf_scale_simple (pixbuf, w * 3, h * 3, GDK_INTERP_NEAREST);
+ } else if (w > width || h > height) {
+ double ws, hs, s;
+
+ ws = (double)width / w;
+ hs = (double)height / h;
+ s = MIN (ws, hs);
+ scaled = gdk_pixbuf_scale_simple (pixbuf, w * s, h * s, GDK_INTERP_BILINEAR);
+ } else {
+ scaled = g_object_ref (pixbuf);
+ }
+
+ w = gdk_pixbuf_get_width (scaled);
+ h = gdk_pixbuf_get_height (scaled);
+
+ gdk_cairo_set_source_pixbuf (cr, scaled,
+ (width - w) / 2,
+ (height - h) / 2);
+ g_object_unref (scaled);
+ cairo_fill (cr);
+ }
+
+ framed = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height);
+ cairo_destroy (cr);
+ cairo_surface_destroy (surface);
+
+ return framed;
}
static void
set_image_from_favicon (EphyApplicationDialogData *data)
{
- GdkPixbuf *icon = NULL;
- cairo_surface_t *icon_surface = webkit_web_view_get_favicon (WEBKIT_WEB_VIEW (data->view));
+ GdkPixbuf *icon = NULL;
+ cairo_surface_t *icon_surface = webkit_web_view_get_favicon (WEBKIT_WEB_VIEW (data->view));
- if (icon_surface)
- icon = ephy_pixbuf_get_from_surface_scaled (icon_surface, 0, 0);
+ if (icon_surface)
+ icon = ephy_pixbuf_get_from_surface_scaled (icon_surface, 0, 0);
- if (icon != NULL) {
- GdkPixbuf *framed;
+ if (icon != NULL) {
+ GdkPixbuf *framed;
- framed = frame_pixbuf (icon, NULL, DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE);
- g_object_unref (icon);
- gtk_image_set_from_pixbuf (GTK_IMAGE (data->image), framed);
- g_object_unref (framed);
- }
+ framed = frame_pixbuf (icon, NULL, DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE);
+ g_object_unref (icon);
+ gtk_image_set_from_pixbuf (GTK_IMAGE (data->image), framed);
+ g_object_unref (framed);
+ }
}
static void
set_app_icon_from_filename (EphyApplicationDialogData *data,
- const char *filename)
+ const char *filename)
{
- GdkPixbuf *pixbuf;
- GdkPixbuf *framed;
+ GdkPixbuf *pixbuf;
+ GdkPixbuf *framed;
- pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
- if (pixbuf == NULL)
- return;
+ pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
+ if (pixbuf == NULL)
+ return;
- framed = frame_pixbuf (pixbuf, &data->icon_rgba, DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE);
- g_object_unref (pixbuf);
- gtk_image_set_from_pixbuf (GTK_IMAGE (data->image), framed);
- g_object_unref (framed);
+ framed = frame_pixbuf (pixbuf, &data->icon_rgba, DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE);
+ g_object_unref (pixbuf);
+ gtk_image_set_from_pixbuf (GTK_IMAGE (data->image), framed);
+ g_object_unref (framed);
}
static void
-download_finished_cb (WebKitDownload *download,
- EphyApplicationDialogData *data)
+download_finished_cb (WebKitDownload *download,
+ EphyApplicationDialogData *data)
{
- char *filename;
+ char *filename;
- gtk_widget_show (data->image);
+ gtk_widget_show (data->image);
- filename = g_filename_from_uri (webkit_download_get_destination (download), NULL, NULL);
- set_app_icon_from_filename (data, filename);
- g_free (filename);
+ filename = g_filename_from_uri (webkit_download_get_destination (download), NULL, NULL);
+ set_app_icon_from_filename (data, filename);
+ g_free (filename);
}
static void
-download_failed_cb (WebKitDownload *download,
- GError *error,
- EphyApplicationDialogData *data)
+download_failed_cb (WebKitDownload *download,
+ GError *error,
+ EphyApplicationDialogData *data)
{
- gtk_widget_show (data->image);
+ gtk_widget_show (data->image);
- g_signal_handlers_disconnect_by_func (download, download_finished_cb, data);
- /* Something happened, default to a page snapshot. */
- set_image_from_favicon (data);
+ g_signal_handlers_disconnect_by_func (download, download_finished_cb, data);
+ /* Something happened, default to a page snapshot. */
+ set_image_from_favicon (data);
}
static void
download_icon_and_set_image (EphyApplicationDialogData *data)
{
- WebKitDownload *download;
- char *destination, *destination_uri, *tmp_filename;
- EphyEmbedShell *shell = ephy_embed_shell_get_default ();
-
- download = webkit_web_context_download_uri (ephy_embed_shell_get_web_context (shell),
- data->icon_href);
- /* We do not want this download to show up in the UI, so let's
- * set 'ephy-download-set' to make Epiphany think this is
- * already there. */
- /* FIXME: it's probably better to just do this in a clean way
- * instead of using this workaround. */
- g_object_set_data (G_OBJECT (download), "ephy-download-set", GINT_TO_POINTER (TRUE));
-
- tmp_filename = ephy_file_tmp_filename (".ephy-download-XXXXXX", NULL);
- destination = g_build_filename (ephy_file_tmp_dir (), tmp_filename, NULL);
- destination_uri = g_filename_to_uri (destination, NULL, NULL);
- webkit_download_set_destination (download, destination_uri);
- g_free (destination);
- g_free (destination_uri);
- g_free (tmp_filename);
-
- g_signal_connect (download, "finished",
- G_CALLBACK (download_finished_cb), data);
- g_signal_connect (download, "failed",
- G_CALLBACK (download_failed_cb), data);
+ WebKitDownload *download;
+ char *destination, *destination_uri, *tmp_filename;
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
+
+ download = webkit_web_context_download_uri (ephy_embed_shell_get_web_context (shell),
+ data->icon_href);
+ /* We do not want this download to show up in the UI, so let's
+ * set 'ephy-download-set' to make Epiphany think this is
+ * already there. */
+ /* FIXME: it's probably better to just do this in a clean way
+ * instead of using this workaround. */
+ g_object_set_data (G_OBJECT (download), "ephy-download-set", GINT_TO_POINTER (TRUE));
+
+ tmp_filename = ephy_file_tmp_filename (".ephy-download-XXXXXX", NULL);
+ destination = g_build_filename (ephy_file_tmp_dir (), tmp_filename, NULL);
+ destination_uri = g_filename_to_uri (destination, NULL, NULL);
+ webkit_download_set_destination (download, destination_uri);
+ g_free (destination);
+ g_free (destination_uri);
+ g_free (tmp_filename);
+
+ g_signal_connect (download, "finished",
+ G_CALLBACK (download_finished_cb), data);
+ g_signal_connect (download, "failed",
+ G_CALLBACK (download_failed_cb), data);
}
static void
-fill_default_application_image_cb (GObject *source,
- GAsyncResult *async_result,
- gpointer user_data)
-{
- EphyApplicationDialogData *data = user_data;
- char *uri = NULL;
- GdkRGBA color = { 0.5, 0.5, 0.5, 0.3 };
- gboolean res = FALSE;
-
- ephy_web_view_get_best_web_app_icon_finish (EPHY_WEB_VIEW (source), async_result, &res, &uri, &color,
NULL);
-
- data->icon_href = uri;
- data->icon_rgba = color;
- if (res)
- {
- download_icon_and_set_image (data);
- }
- else
- {
- gtk_widget_show (data->image);
- set_image_from_favicon (data);
- }
+fill_default_application_image_cb (GObject *source,
+ GAsyncResult *async_result,
+ gpointer user_data)
+{
+ EphyApplicationDialogData *data = user_data;
+ char *uri = NULL;
+ GdkRGBA color = { 0.5, 0.5, 0.5, 0.3 };
+ gboolean res = FALSE;
+
+ ephy_web_view_get_best_web_app_icon_finish (EPHY_WEB_VIEW (source), async_result, &res, &uri, &color,
NULL);
+
+ data->icon_href = uri;
+ data->icon_rgba = color;
+ if (res) {
+ download_icon_and_set_image (data);
+ } else {
+ gtk_widget_show (data->image);
+ set_image_from_favicon (data);
+ }
}
static void
fill_default_application_image (EphyApplicationDialogData *data)
{
- ephy_web_view_get_best_web_app_icon (data->view, NULL, fill_default_application_image_cb, data);
+ ephy_web_view_get_best_web_app_icon (data->view, NULL, fill_default_application_image_cb, data);
}
typedef struct {
- const char *host;
- const char *name;
+ const char *host;
+ const char *name;
} SiteInfo;
static SiteInfo sites[] = {
- { "www.facebook.com", "Facebook" },
- { "twitter.com", "Twitter" },
- { "gmail.com", "GMail" },
- { "plus.google.com", "Google+" },
- { "youtube.com", "YouTube" },
+ { "www.facebook.com", "Facebook" },
+ { "twitter.com", "Twitter" },
+ { "gmail.com", "GMail" },
+ { "plus.google.com", "Google+" },
+ { "youtube.com", "YouTube" },
};
static char *
get_special_case_application_title_for_host (const char *host)
{
- char *title = NULL;
- guint i;
+ char *title = NULL;
+ guint i;
- for (i = 0; i < G_N_ELEMENTS (sites) && title == NULL; i++)
- {
- SiteInfo *info = &sites[i];
- if (strcmp (host, info->host) == 0)
- {
- title = g_strdup (info->name);
- }
- }
+ for (i = 0; i < G_N_ELEMENTS (sites) && title == NULL; i++) {
+ SiteInfo *info = &sites[i];
+ if (strcmp (host, info->host) == 0) {
+ title = g_strdup (info->name);
+ }
+ }
- return title;
+ return title;
}
static void
set_default_application_title (EphyApplicationDialogData *data,
- char *title)
+ char *title)
{
- if (title == NULL || title[0] == '\0')
- {
- SoupURI *uri;
- const char *host;
+ if (title == NULL || title[0] == '\0') {
+ SoupURI *uri;
+ const char *host;
- uri = soup_uri_new (webkit_web_view_get_uri (WEBKIT_WEB_VIEW (data->view)));
- host = soup_uri_get_host (uri);
+ uri = soup_uri_new (webkit_web_view_get_uri (WEBKIT_WEB_VIEW (data->view)));
+ host = soup_uri_get_host (uri);
- if (host != NULL && host[0] != '\0')
- title = get_special_case_application_title_for_host (host);
+ if (host != NULL && host[0] != '\0')
+ title = get_special_case_application_title_for_host (host);
- if (title == NULL || title[0] == '\0')
- {
- if (g_str_has_prefix (host, "www."))
- title = g_strdup (host + strlen ("www."));
- else
- title = g_strdup (host);
- }
+ if (title == NULL || title[0] == '\0') {
+ if (g_str_has_prefix (host, "www."))
+ title = g_strdup (host + strlen ("www."));
+ else
+ title = g_strdup (host);
+ }
- soup_uri_free (uri);
- }
+ soup_uri_free (uri);
+ }
- if (title == NULL || title[0] == '\0')
- {
- title = g_strdup (webkit_web_view_get_title (WEBKIT_WEB_VIEW (data->view)));
- }
+ if (title == NULL || title[0] == '\0') {
+ title = g_strdup (webkit_web_view_get_title (WEBKIT_WEB_VIEW (data->view)));
+ }
- gtk_entry_set_text (GTK_ENTRY (data->entry), title);
- g_free (title);
+ gtk_entry_set_text (GTK_ENTRY (data->entry), title);
+ g_free (title);
}
static void
-fill_default_application_title_cb (GObject *source,
- GAsyncResult *async_result,
- gpointer user_data)
+fill_default_application_title_cb (GObject *source,
+ GAsyncResult *async_result,
+ gpointer user_data)
{
- EphyApplicationDialogData *data = user_data;
- char *title;
+ EphyApplicationDialogData *data = user_data;
+ char *title;
- title = ephy_web_view_get_web_app_title_finish (EPHY_WEB_VIEW (source), async_result, NULL);
- set_default_application_title (data, title);
+ title = ephy_web_view_get_web_app_title_finish (EPHY_WEB_VIEW (source), async_result, NULL);
+ set_default_application_title (data, title);
}
static void
fill_default_application_title (EphyApplicationDialogData *data)
{
- ephy_web_view_get_web_app_title (data->view, NULL, fill_default_application_title_cb, data);
+ ephy_web_view_get_web_app_title (data->view, NULL, fill_default_application_title_cb, data);
}
static void
notify_launch_cb (NotifyNotification *notification,
- char *action,
- gpointer user_data)
+ char *action,
+ gpointer user_data)
{
- char * desktop_file = user_data;
+ char *desktop_file = user_data;
- ephy_file_launch_desktop_file (desktop_file, NULL, 0, NULL);
- g_free (desktop_file);
+ ephy_file_launch_desktop_file (desktop_file, NULL, 0, NULL);
+ g_free (desktop_file);
}
static gboolean
@@ -701,20 +675,20 @@ confirm_web_application_overwrite (GtkWindow *parent, const char *title)
GtkWidget *dialog;
dialog = gtk_message_dialog_new (parent,
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE,
- _("A web application named '%s' already exists. Do you want to replace
it?"),
- title);
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ _("A web application named '%s' already exists. Do you want to replace
it?"),
+ title);
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- _("Cancel"),
- GTK_RESPONSE_CANCEL,
- _("Replace"),
- GTK_RESPONSE_OK,
- NULL);
+ _("Cancel"),
+ GTK_RESPONSE_CANCEL,
+ _("Replace"),
+ GTK_RESPONSE_OK,
+ NULL);
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
_("An application with the same name already exists. Replacing
it will "
- "overwrite it."));
+ "overwrite it."));
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
response = gtk_dialog_run (GTK_DIALOG (dialog));
@@ -724,981 +698,941 @@ confirm_web_application_overwrite (GtkWindow *parent, const char *title)
}
static void
-dialog_save_as_application_response_cb (GtkDialog *dialog,
- gint response,
- EphyApplicationDialogData *data)
-{
- const char *app_name;
- char *desktop_file;
- char *message;
- NotifyNotification *notification;
-
- if (response == GTK_RESPONSE_OK) {
- app_name = gtk_entry_get_text (GTK_ENTRY (data->entry));
-
- if (ephy_web_application_exists (app_name))
- {
- if (confirm_web_application_overwrite (GTK_WINDOW (dialog), app_name))
- ephy_web_application_delete (app_name);
- else
- return;
- }
-
- /* Create Web Application, including a new profile and .desktop file. */
- desktop_file = ephy_web_application_create (webkit_web_view_get_uri (WEBKIT_WEB_VIEW
(data->view)),
- app_name,
- gtk_image_get_pixbuf (GTK_IMAGE (data->image)));
- if (desktop_file)
- message = g_strdup_printf (_("The application '%s' is ready to be used"),
- app_name);
- else
- message = g_strdup_printf (_("The application '%s' could not be created"),
- app_name);
-
- notification = notify_notification_new (message,
- NULL, NULL);
- g_free (message);
-
- if (desktop_file) {
- notify_notification_add_action (notification, "launch", _("Launch"),
- (NotifyActionCallback)notify_launch_cb,
- g_path_get_basename (desktop_file),
- NULL);
- notify_notification_set_icon_from_pixbuf (notification, gtk_image_get_pixbuf
(GTK_IMAGE (data->image)));
- g_free (desktop_file);
- }
-
- notify_notification_set_timeout (notification, NOTIFY_EXPIRES_DEFAULT);
- notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
- notify_notification_set_hint (notification, "desktop-entry", g_variant_new_string
("epiphany"));
- notify_notification_set_hint (notification, "transient", g_variant_new_boolean (TRUE));
- notify_notification_show (notification, NULL);
- }
-
- ephy_application_dialog_data_free (data);
- gtk_widget_destroy (GTK_WIDGET (dialog));
+dialog_save_as_application_response_cb (GtkDialog *dialog,
+ gint response,
+ EphyApplicationDialogData *data)
+{
+ const char *app_name;
+ char *desktop_file;
+ char *message;
+ NotifyNotification *notification;
+
+ if (response == GTK_RESPONSE_OK) {
+ app_name = gtk_entry_get_text (GTK_ENTRY (data->entry));
+
+ if (ephy_web_application_exists (app_name)) {
+ if (confirm_web_application_overwrite (GTK_WINDOW (dialog), app_name))
+ ephy_web_application_delete (app_name);
+ else
+ return;
+ }
+
+ /* Create Web Application, including a new profile and .desktop file. */
+ desktop_file = ephy_web_application_create (webkit_web_view_get_uri (WEBKIT_WEB_VIEW (data->view)),
+ app_name,
+ gtk_image_get_pixbuf (GTK_IMAGE (data->image)));
+ if (desktop_file)
+ message = g_strdup_printf (_("The application '%s' is ready to be used"),
+ app_name);
+ else
+ message = g_strdup_printf (_("The application '%s' could not be created"),
+ app_name);
+
+ notification = notify_notification_new (message,
+ NULL, NULL);
+ g_free (message);
+
+ if (desktop_file) {
+ notify_notification_add_action (notification, "launch", _("Launch"),
+ (NotifyActionCallback)notify_launch_cb,
+ g_path_get_basename (desktop_file),
+ NULL);
+ notify_notification_set_icon_from_pixbuf (notification, gtk_image_get_pixbuf (GTK_IMAGE
(data->image)));
+ g_free (desktop_file);
+ }
+
+ notify_notification_set_timeout (notification, NOTIFY_EXPIRES_DEFAULT);
+ notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
+ notify_notification_set_hint (notification, "desktop-entry", g_variant_new_string ("epiphany"));
+ notify_notification_set_hint (notification, "transient", g_variant_new_boolean (TRUE));
+ notify_notification_show (notification, NULL);
+ }
+
+ ephy_application_dialog_data_free (data);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
}
void
-window_cmd_file_save_as_application (GtkAction *action,
- EphyWindow *window)
-{
- EphyEmbed *embed;
- GtkWidget *dialog, *box, *image, *entry, *content_area;
- GtkWidget *label;
- GtkWidget *spinner;
- GtkWidget *alignment;
- EphyWebView *view;
- EphyApplicationDialogData *data;
- GdkPixbuf *pixbuf;
- GtkStyleContext *context;
- char *markup;
-
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
- g_return_if_fail (embed != NULL);
-
- view = EPHY_WEB_VIEW (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed));
-
- /* Show dialog with icon, title. */
- dialog = gtk_dialog_new_with_buttons (_("Create Web Application"),
- GTK_WINDOW (window),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT |
GTK_DIALOG_USE_HEADER_BAR,
- _("_Cancel"),
- GTK_RESPONSE_CANCEL,
- _("C_reate"),
- GTK_RESPONSE_OK,
- NULL);
-
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 10);
-
- box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
- gtk_container_add (GTK_CONTAINER (content_area), box);
- gtk_container_set_border_width (GTK_CONTAINER (box), 5);
-
- image = gtk_image_new ();
- gtk_widget_set_no_show_all (image, TRUE);
- gtk_widget_set_size_request (image, DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE);
- gtk_widget_set_margin_bottom (image, 10);
- gtk_container_add (GTK_CONTAINER (box), image);
- pixbuf = frame_pixbuf (NULL, NULL, DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE);
- gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
- g_object_unref (pixbuf);
-
- alignment = gtk_alignment_new (0.5, 0.5, 0, 0);
- gtk_widget_set_no_show_all (alignment, TRUE);
- gtk_widget_set_size_request (alignment, DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE);
- gtk_container_add (GTK_CONTAINER (box), alignment);
- gtk_widget_show (alignment);
-
- spinner = gtk_spinner_new ();
- gtk_widget_set_size_request (spinner, 22, 22);
- gtk_spinner_start (GTK_SPINNER (spinner));
- gtk_container_add (GTK_CONTAINER (alignment), spinner);
- gtk_widget_show (spinner);
-
- entry = gtk_entry_new ();
- gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
- gtk_box_pack_start (GTK_BOX (box), entry, FALSE, FALSE, 0);
-
- markup = g_strdup_printf ("<small>%s</small>", ephy_web_view_get_display_address (view));
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label), markup);
- g_free (markup);
- gtk_box_pack_end (GTK_BOX (box), label, FALSE, FALSE, 0);
- context = gtk_widget_get_style_context (label);
- gtk_style_context_add_class (context, "dim-label");
-
- data = g_slice_new0 (EphyApplicationDialogData);
- data->view = view;
- data->image = image;
- data->entry = entry;
- data->spinner = spinner;
- data->spinner_box = alignment;
-
- g_object_bind_property (image, "visible", data->spinner_box, "visible", G_BINDING_INVERT_BOOLEAN);
-
- fill_default_application_image (data);
- fill_default_application_title (data);
-
- gtk_widget_show_all (dialog);
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
- g_signal_connect (dialog, "response",
- G_CALLBACK (dialog_save_as_application_response_cb),
- data);
- gtk_widget_show_all (dialog);
+window_cmd_file_save_as_application (GtkAction *action,
+ EphyWindow *window)
+{
+ EphyEmbed *embed;
+ GtkWidget *dialog, *box, *image, *entry, *content_area;
+ GtkWidget *label;
+ GtkWidget *spinner;
+ GtkWidget *alignment;
+ EphyWebView *view;
+ EphyApplicationDialogData *data;
+ GdkPixbuf *pixbuf;
+ GtkStyleContext *context;
+ char *markup;
+
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+ g_return_if_fail (embed != NULL);
+
+ view = EPHY_WEB_VIEW (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed));
+
+ /* Show dialog with icon, title. */
+ dialog = gtk_dialog_new_with_buttons (_("Create Web Application"),
+ GTK_WINDOW (window),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT |
GTK_DIALOG_USE_HEADER_BAR,
+ _("_Cancel"),
+ GTK_RESPONSE_CANCEL,
+ _("C_reate"),
+ GTK_RESPONSE_OK,
+ NULL);
+
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 10);
+
+ box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
+ gtk_container_add (GTK_CONTAINER (content_area), box);
+ gtk_container_set_border_width (GTK_CONTAINER (box), 5);
+
+ image = gtk_image_new ();
+ gtk_widget_set_no_show_all (image, TRUE);
+ gtk_widget_set_size_request (image, DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE);
+ gtk_widget_set_margin_bottom (image, 10);
+ gtk_container_add (GTK_CONTAINER (box), image);
+ pixbuf = frame_pixbuf (NULL, NULL, DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE);
+ gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
+ g_object_unref (pixbuf);
+
+ alignment = gtk_alignment_new (0.5, 0.5, 0, 0);
+ gtk_widget_set_no_show_all (alignment, TRUE);
+ gtk_widget_set_size_request (alignment, DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE);
+ gtk_container_add (GTK_CONTAINER (box), alignment);
+ gtk_widget_show (alignment);
+
+ spinner = gtk_spinner_new ();
+ gtk_widget_set_size_request (spinner, 22, 22);
+ gtk_spinner_start (GTK_SPINNER (spinner));
+ gtk_container_add (GTK_CONTAINER (alignment), spinner);
+ gtk_widget_show (spinner);
+
+ entry = gtk_entry_new ();
+ gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
+ gtk_box_pack_start (GTK_BOX (box), entry, FALSE, FALSE, 0);
+
+ markup = g_strdup_printf ("<small>%s</small>", ephy_web_view_get_display_address (view));
+ label = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (label), markup);
+ g_free (markup);
+ gtk_box_pack_end (GTK_BOX (box), label, FALSE, FALSE, 0);
+ context = gtk_widget_get_style_context (label);
+ gtk_style_context_add_class (context, "dim-label");
+
+ data = g_slice_new0 (EphyApplicationDialogData);
+ data->view = view;
+ data->image = image;
+ data->entry = entry;
+ data->spinner = spinner;
+ data->spinner_box = alignment;
+
+ g_object_bind_property (image, "visible", data->spinner_box, "visible", G_BINDING_INVERT_BOOLEAN);
+
+ fill_default_application_image (data);
+ fill_default_application_title (data);
+
+ gtk_widget_show_all (dialog);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (dialog_save_as_application_response_cb),
+ data);
+ gtk_widget_show_all (dialog);
}
void
-window_cmd_file_close_window (GtkAction *action,
- EphyWindow *window)
+window_cmd_file_close_window (GtkAction *action,
+ EphyWindow *window)
{
- GtkWidget *notebook;
- EphyEmbed *embed;
+ GtkWidget *notebook;
+ EphyEmbed *embed;
- notebook = ephy_window_get_notebook (window);
+ notebook = ephy_window_get_notebook (window);
- if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
- EPHY_PREFS_LOCKDOWN_QUIT) &&
- gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)) == 1)
- {
- return;
- }
+ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_QUIT) &&
+ gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)) == 1) {
+ return;
+ }
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
- g_return_if_fail (embed != NULL);
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+ g_return_if_fail (embed != NULL);
- g_signal_emit_by_name (notebook, "tab-close-request", embed);
+ g_signal_emit_by_name (notebook, "tab-close-request", embed);
}
void
-window_cmd_file_quit (GtkAction *action,
- EphyWindow *window)
+window_cmd_file_quit (GtkAction *action,
+ EphyWindow *window)
{
- if (ephy_shell_close_all_windows (ephy_shell_get_default ()))
- g_application_quit (g_application_get_default ());
+ if (ephy_shell_close_all_windows (ephy_shell_get_default ()))
+ g_application_quit (g_application_get_default ());
}
void
-window_cmd_file_new_window (GtkAction *action,
- EphyWindow *window)
+window_cmd_file_new_window (GtkAction *action,
+ EphyWindow *window)
{
- EphyEmbed *embed;
- EphyWindow *new_window = ephy_window_new ();
+ EphyEmbed *embed;
+ EphyWindow *new_window = ephy_window_new ();
- embed = ephy_shell_new_tab (ephy_shell_get_default (),
- new_window, NULL, 0);
- ephy_web_view_load_homepage (ephy_embed_get_web_view (embed));
- ephy_window_activate_location (new_window);
+ embed = ephy_shell_new_tab (ephy_shell_get_default (),
+ new_window, NULL, 0);
+ ephy_web_view_load_homepage (ephy_embed_get_web_view (embed));
+ ephy_window_activate_location (new_window);
}
void
-window_cmd_file_new_incognito_window (GtkAction *action,
- EphyWindow *window)
+window_cmd_file_new_incognito_window (GtkAction *action,
+ EphyWindow *window)
{
- ephy_open_incognito_window (NULL);
+ ephy_open_incognito_window (NULL);
}
void
-window_cmd_edit_undo (GtkAction *action,
- EphyWindow *window)
-{
- GtkWidget *widget;
- GtkWidget *embed;
- GtkWidget *location_entry;
-
- widget = gtk_window_get_focus (GTK_WINDOW (window));
- location_entry = gtk_widget_get_ancestor (widget, EPHY_TYPE_LOCATION_ENTRY);
-
- if (location_entry)
- {
- ephy_location_entry_reset (EPHY_LOCATION_ENTRY (location_entry));
- }
- else
- {
- embed = gtk_widget_get_ancestor (widget, EPHY_TYPE_EMBED);
-
- if (embed)
- {
- webkit_web_view_execute_editing_command (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED
(EPHY_EMBED (embed)), "Undo");
- }
- }
+window_cmd_edit_undo (GtkAction *action,
+ EphyWindow *window)
+{
+ GtkWidget *widget;
+ GtkWidget *embed;
+ GtkWidget *location_entry;
+
+ widget = gtk_window_get_focus (GTK_WINDOW (window));
+ location_entry = gtk_widget_get_ancestor (widget, EPHY_TYPE_LOCATION_ENTRY);
+
+ if (location_entry) {
+ ephy_location_entry_reset (EPHY_LOCATION_ENTRY (location_entry));
+ } else {
+ embed = gtk_widget_get_ancestor (widget, EPHY_TYPE_EMBED);
+
+ if (embed) {
+ webkit_web_view_execute_editing_command (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (EPHY_EMBED (embed)),
"Undo");
+ }
+ }
}
void
-window_cmd_edit_redo (GtkAction *action,
- EphyWindow *window)
-{
- GtkWidget *widget;
- GtkWidget *embed;
- GtkWidget *location_entry;
-
- widget = gtk_window_get_focus (GTK_WINDOW (window));
- location_entry = gtk_widget_get_ancestor (widget, EPHY_TYPE_LOCATION_ENTRY);
-
- if (location_entry)
- {
- ephy_location_entry_undo_reset (EPHY_LOCATION_ENTRY (location_entry));
- }
- else
- {
- embed = gtk_widget_get_ancestor (widget, EPHY_TYPE_EMBED);
- if (embed)
- {
- webkit_web_view_execute_editing_command (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED
(EPHY_EMBED (embed)), "Redo");
- }
- }
+window_cmd_edit_redo (GtkAction *action,
+ EphyWindow *window)
+{
+ GtkWidget *widget;
+ GtkWidget *embed;
+ GtkWidget *location_entry;
+
+ widget = gtk_window_get_focus (GTK_WINDOW (window));
+ location_entry = gtk_widget_get_ancestor (widget, EPHY_TYPE_LOCATION_ENTRY);
+
+ if (location_entry) {
+ ephy_location_entry_undo_reset (EPHY_LOCATION_ENTRY (location_entry));
+ } else {
+ embed = gtk_widget_get_ancestor (widget, EPHY_TYPE_EMBED);
+ if (embed) {
+ webkit_web_view_execute_editing_command (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (EPHY_EMBED (embed)),
"Redo");
+ }
+ }
}
void
-window_cmd_edit_cut (GtkAction *action,
- EphyWindow *window)
+window_cmd_edit_cut (GtkAction *action,
+ EphyWindow *window)
{
- GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window));
+ GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window));
- if (GTK_IS_EDITABLE (widget))
- {
- gtk_editable_cut_clipboard (GTK_EDITABLE (widget));
- }
- else
- {
- EphyEmbed *embed;
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
- g_return_if_fail (embed != NULL);
+ if (GTK_IS_EDITABLE (widget)) {
+ gtk_editable_cut_clipboard (GTK_EDITABLE (widget));
+ } else {
+ EphyEmbed *embed;
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+ g_return_if_fail (embed != NULL);
- webkit_web_view_execute_editing_command (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed),
WEBKIT_EDITING_COMMAND_CUT);
- }
+ webkit_web_view_execute_editing_command (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed),
WEBKIT_EDITING_COMMAND_CUT);
+ }
}
void
-window_cmd_edit_copy (GtkAction *action,
- EphyWindow *window)
+window_cmd_edit_copy (GtkAction *action,
+ EphyWindow *window)
{
- GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window));
+ GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window));
- if (GTK_IS_EDITABLE (widget))
- {
- gtk_editable_copy_clipboard (GTK_EDITABLE (widget));
- }
- else
- {
- EphyEmbed *embed;
+ if (GTK_IS_EDITABLE (widget)) {
+ gtk_editable_copy_clipboard (GTK_EDITABLE (widget));
+ } else {
+ EphyEmbed *embed;
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
- g_return_if_fail (embed != NULL);
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+ g_return_if_fail (embed != NULL);
- webkit_web_view_execute_editing_command (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed),
WEBKIT_EDITING_COMMAND_COPY);
- }
+ webkit_web_view_execute_editing_command (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed),
WEBKIT_EDITING_COMMAND_COPY);
+ }
}
void
-window_cmd_edit_paste (GtkAction *action,
- EphyWindow *window)
+window_cmd_edit_paste (GtkAction *action,
+ EphyWindow *window)
{
- GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window));
+ GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window));
- if (GTK_IS_EDITABLE (widget))
- {
- gtk_editable_paste_clipboard (GTK_EDITABLE (widget));
- }
- else
- {
- EphyEmbed *embed;
+ if (GTK_IS_EDITABLE (widget)) {
+ gtk_editable_paste_clipboard (GTK_EDITABLE (widget));
+ } else {
+ EphyEmbed *embed;
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
- g_return_if_fail (embed != NULL);
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+ g_return_if_fail (embed != NULL);
- webkit_web_view_execute_editing_command (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed),
WEBKIT_EDITING_COMMAND_PASTE);
- }
+ webkit_web_view_execute_editing_command (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed),
WEBKIT_EDITING_COMMAND_PASTE);
+ }
}
void
-window_cmd_edit_delete (GtkAction *action,
- EphyWindow *window)
+window_cmd_edit_delete (GtkAction *action,
+ EphyWindow *window)
{
- GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window));
+ GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window));
- if (GTK_IS_EDITABLE (widget))
- {
- gtk_editable_delete_text (GTK_EDITABLE (widget), 0, -1);
- }
- else
- {
- EphyEmbed *embed;
+ if (GTK_IS_EDITABLE (widget)) {
+ gtk_editable_delete_text (GTK_EDITABLE (widget), 0, -1);
+ } else {
+ EphyEmbed *embed;
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
- g_return_if_fail (embed != NULL);
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+ g_return_if_fail (embed != NULL);
- /* FIXME: TODO */
+ /* FIXME: TODO */
#if 0
- ephy_command_manager_do_command (EPHY_COMMAND_MANAGER (embed),
- "cmd_delete");
+ ephy_command_manager_do_command (EPHY_COMMAND_MANAGER (embed),
+ "cmd_delete");
#endif
- }
+ }
}
void
-window_cmd_edit_select_all (GtkAction *action,
- EphyWindow *window)
+window_cmd_edit_select_all (GtkAction *action,
+ EphyWindow *window)
{
- GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window));
+ GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window));
- if (GTK_IS_EDITABLE (widget))
- {
- gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1);
- }
- else
- {
- EphyEmbed *embed;
+ if (GTK_IS_EDITABLE (widget)) {
+ gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1);
+ } else {
+ EphyEmbed *embed;
- embed = ephy_embed_container_get_active_child
- (EPHY_EMBED_CONTAINER (window));
- g_return_if_fail (embed != NULL);
+ embed = ephy_embed_container_get_active_child
+ (EPHY_EMBED_CONTAINER (window));
+ g_return_if_fail (embed != NULL);
- webkit_web_view_execute_editing_command (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed),
"SelectAll");
- }
+ webkit_web_view_execute_editing_command (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed), "SelectAll");
+ }
}
void
-window_cmd_edit_find (GtkAction *action,
- EphyWindow *window)
+window_cmd_edit_find (GtkAction *action,
+ EphyWindow *window)
{
- EphyFindToolbar *toolbar;
-
- toolbar = EPHY_FIND_TOOLBAR (ephy_window_get_current_find_toolbar (window));
- ephy_find_toolbar_toggle_state (toolbar);
+ EphyFindToolbar *toolbar;
+
+ toolbar = EPHY_FIND_TOOLBAR (ephy_window_get_current_find_toolbar (window));
+ ephy_find_toolbar_toggle_state (toolbar);
}
void
-window_cmd_edit_find_next (GtkAction *action,
- EphyWindow *window)
+window_cmd_edit_find_next (GtkAction *action,
+ EphyWindow *window)
{
- EphyFindToolbar *toolbar;
+ EphyFindToolbar *toolbar;
- toolbar = EPHY_FIND_TOOLBAR (ephy_window_get_current_find_toolbar (window));
- ephy_find_toolbar_find_next (toolbar);
+ toolbar = EPHY_FIND_TOOLBAR (ephy_window_get_current_find_toolbar (window));
+ ephy_find_toolbar_find_next (toolbar);
}
void
-window_cmd_edit_find_prev (GtkAction *action,
- EphyWindow *window)
+window_cmd_edit_find_prev (GtkAction *action,
+ EphyWindow *window)
{
- EphyFindToolbar *toolbar;
+ EphyFindToolbar *toolbar;
- toolbar = EPHY_FIND_TOOLBAR (ephy_window_get_current_find_toolbar (window));
- ephy_find_toolbar_find_previous (toolbar);
+ toolbar = EPHY_FIND_TOOLBAR (ephy_window_get_current_find_toolbar (window));
+ ephy_find_toolbar_find_previous (toolbar);
}
void
-window_cmd_edit_bookmarks (GtkAction *action,
- EphyWindow *window)
+window_cmd_edit_bookmarks (GtkAction *action,
+ EphyWindow *window)
{
- GtkWidget *bwindow;
-
- bwindow = ephy_shell_get_bookmarks_editor (ephy_shell_get_default ());
- gtk_window_present (GTK_WINDOW (bwindow));
+ GtkWidget *bwindow;
+
+ bwindow = ephy_shell_get_bookmarks_editor (ephy_shell_get_default ());
+ gtk_window_present (GTK_WINDOW (bwindow));
}
void
-window_cmd_edit_history (GtkAction *action,
- EphyWindow *window)
+window_cmd_edit_history (GtkAction *action,
+ EphyWindow *window)
{
- GtkWidget *hwindow;
-
- hwindow = ephy_shell_get_history_window (ephy_shell_get_default ());
+ GtkWidget *hwindow;
+
+ hwindow = ephy_shell_get_history_window (ephy_shell_get_default ());
- if (GTK_WINDOW (window) != gtk_window_get_transient_for (GTK_WINDOW (hwindow)))
- gtk_window_set_transient_for (GTK_WINDOW (hwindow),
- GTK_WINDOW (window));
- gtk_window_present (GTK_WINDOW (hwindow));
+ if (GTK_WINDOW (window) != gtk_window_get_transient_for (GTK_WINDOW (hwindow)))
+ gtk_window_set_transient_for (GTK_WINDOW (hwindow),
+ GTK_WINDOW (window));
+ gtk_window_present (GTK_WINDOW (hwindow));
}
void
-window_cmd_edit_preferences (GtkAction *action,
- EphyWindow *window)
+window_cmd_edit_preferences (GtkAction *action,
+ EphyWindow *window)
{
- GtkWindow *dialog;
-
- dialog = GTK_WINDOW (ephy_shell_get_prefs_dialog (ephy_shell_get_default ()));
+ GtkWindow *dialog;
- if (GTK_WINDOW (window) != gtk_window_get_transient_for (dialog))
- gtk_window_set_transient_for (dialog,
- GTK_WINDOW (window));
+ dialog = GTK_WINDOW (ephy_shell_get_prefs_dialog (ephy_shell_get_default ()));
- gtk_window_present (dialog);
+ if (GTK_WINDOW (window) != gtk_window_get_transient_for (dialog))
+ gtk_window_set_transient_for (dialog,
+ GTK_WINDOW (window));
+
+ gtk_window_present (dialog);
}
void
-window_cmd_view_fullscreen (GtkAction *action,
- EphyWindow *window)
+window_cmd_view_fullscreen (GtkAction *action,
+ EphyWindow *window)
{
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
- gtk_window_fullscreen (GTK_WINDOW (window));
- else
- gtk_window_unfullscreen (GTK_WINDOW (window));
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
+ gtk_window_fullscreen (GTK_WINDOW (window));
+ else
+ gtk_window_unfullscreen (GTK_WINDOW (window));
}
void
-window_cmd_view_zoom_in (GtkAction *action,
- EphyWindow *window)
+window_cmd_view_zoom_in (GtkAction *action,
+ EphyWindow *window)
{
- ephy_window_set_zoom (window, ZOOM_IN);
+ ephy_window_set_zoom (window, ZOOM_IN);
}
void
-window_cmd_view_zoom_out (GtkAction *action,
- EphyWindow *window)
+window_cmd_view_zoom_out (GtkAction *action,
+ EphyWindow *window)
{
- ephy_window_set_zoom (window, ZOOM_OUT);
+ ephy_window_set_zoom (window, ZOOM_OUT);
}
void
-window_cmd_view_zoom_normal (GtkAction *action,
- EphyWindow *window)
+window_cmd_view_zoom_normal (GtkAction *action,
+ EphyWindow *window)
{
- ephy_window_set_zoom (window, 1.0);
+ ephy_window_set_zoom (window, 1.0);
}
static void
view_source_embedded (const char *uri, EphyEmbed *embed)
{
- EphyEmbed *new_embed;
+ EphyEmbed *new_embed;
- new_embed = ephy_shell_new_tab
- (ephy_shell_get_default (),
- EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed))),
- embed,
- EPHY_NEW_TAB_JUMP | EPHY_NEW_TAB_APPEND_AFTER);
+ new_embed = ephy_shell_new_tab
+ (ephy_shell_get_default (),
+ EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed))),
+ embed,
+ EPHY_NEW_TAB_JUMP | EPHY_NEW_TAB_APPEND_AFTER);
- /* FIXME: Implement embedded view source mode using a custom URI handler and a
- * javascript library for the syntax highlighting.
- * https://bugzilla.gnome.org/show_bug.cgi?id=731558
- */
- webkit_web_view_load_uri
- (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (new_embed), uri);
- gtk_widget_grab_focus (GTK_WIDGET (new_embed));
+ /* FIXME: Implement embedded view source mode using a custom URI handler and a
+ * javascript library for the syntax highlighting.
+ * https://bugzilla.gnome.org/show_bug.cgi?id=731558
+ */
+ webkit_web_view_load_uri
+ (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (new_embed), uri);
+ gtk_widget_grab_focus (GTK_WIDGET (new_embed));
}
static void
save_temp_source_close_cb (GOutputStream *ostream, GAsyncResult *result, gpointer data)
{
- const char *uri;
- GFile *file;
- GError *error = NULL;
+ const char *uri;
+ GFile *file;
+ GError *error = NULL;
- g_output_stream_close_finish (ostream, result, &error);
- if (error)
- {
- g_warning ("Unable to close file: %s", error->message);
- g_error_free (error);
- return;
- }
+ g_output_stream_close_finish (ostream, result, &error);
+ if (error) {
+ g_warning ("Unable to close file: %s", error->message);
+ g_error_free (error);
+ return;
+ }
- uri = (const char*)g_object_get_data (G_OBJECT (ostream), "ephy-save-temp-source-uri");
+ uri = (const char *)g_object_get_data (G_OBJECT (ostream), "ephy-save-temp-source-uri");
- file = g_file_new_for_uri (uri);
+ file = g_file_new_for_uri (uri);
- if (!ephy_file_launch_handler ("text/plain", file, gtk_get_current_event_time ()))
- {
- /* Fallback to view the source inside the browser */
- EphyEmbed *embed;
+ if (!ephy_file_launch_handler ("text/plain", file, gtk_get_current_event_time ())) {
+ /* Fallback to view the source inside the browser */
+ EphyEmbed *embed;
- uri = (const char*) g_object_get_data (G_OBJECT (ostream),
- "ephy-original-source-uri");
- embed = (EphyEmbed*)g_object_get_data (G_OBJECT (ostream),
- "ephy-save-temp-source-embed");
- view_source_embedded (uri, embed);
- }
- g_object_unref (ostream);
+ uri = (const char *)g_object_get_data (G_OBJECT (ostream),
+ "ephy-original-source-uri");
+ embed = (EphyEmbed *)g_object_get_data (G_OBJECT (ostream),
+ "ephy-save-temp-source-embed");
+ view_source_embedded (uri, embed);
+ }
+ g_object_unref (ostream);
- g_object_unref (file);
+ g_object_unref (file);
}
static void
save_temp_source_write_cb (GOutputStream *ostream, GAsyncResult *result, GString *data)
{
- GError *error = NULL;
- gssize written;
+ GError *error = NULL;
+ gssize written;
- written = g_output_stream_write_finish (ostream, result, &error);
- if (error)
- {
- g_string_free (data, TRUE);
- g_warning ("Unable to write to file: %s", error->message);
- g_error_free (error);
+ written = g_output_stream_write_finish (ostream, result, &error);
+ if (error) {
+ g_string_free (data, TRUE);
+ g_warning ("Unable to write to file: %s", error->message);
+ g_error_free (error);
- g_output_stream_close_async (ostream, G_PRIORITY_DEFAULT, NULL,
- (GAsyncReadyCallback)save_temp_source_close_cb,
- NULL);
+ g_output_stream_close_async (ostream, G_PRIORITY_DEFAULT, NULL,
+ (GAsyncReadyCallback)save_temp_source_close_cb,
+ NULL);
- return;
- }
+ return;
+ }
- if (written == (gint)data->len)
- {
- g_string_free (data, TRUE);
+ if (written == (gint)data->len) {
+ g_string_free (data, TRUE);
- g_output_stream_close_async (ostream, G_PRIORITY_DEFAULT, NULL,
- (GAsyncReadyCallback)save_temp_source_close_cb,
- NULL);
+ g_output_stream_close_async (ostream, G_PRIORITY_DEFAULT, NULL,
+ (GAsyncReadyCallback)save_temp_source_close_cb,
+ NULL);
- return;
- }
+ return;
+ }
- data->len -= written;
- data->str += written;
+ data->len -= written;
+ data->str += written;
- g_output_stream_write_async (ostream,
- data->str, data->len,
- G_PRIORITY_DEFAULT, NULL,
- (GAsyncReadyCallback)save_temp_source_write_cb,
- data);
+ g_output_stream_write_async (ostream,
+ data->str, data->len,
+ G_PRIORITY_DEFAULT, NULL,
+ (GAsyncReadyCallback)save_temp_source_write_cb,
+ data);
}
static void
get_main_resource_data_cb (WebKitWebResource *resource, GAsyncResult *result, GOutputStream *ostream)
{
- guchar *data;
- gsize data_length;
- GString *data_str;
- GError *error = NULL;
+ guchar *data;
+ gsize data_length;
+ GString *data_str;
+ GError *error = NULL;
- data = webkit_web_resource_get_data_finish (resource, result, &data_length, &error);
- if (error) {
- g_warning ("Unable to get main resource data: %s", error->message);
- g_error_free (error);
- return;
- }
+ data = webkit_web_resource_get_data_finish (resource, result, &data_length, &error);
+ if (error) {
+ g_warning ("Unable to get main resource data: %s", error->message);
+ g_error_free (error);
+ return;
+ }
- /* We create a new GString here because we need to make sure
- * we keep writing in case of partial writes */
- data_str = g_string_new_len ((gchar *)data, data_length);
- g_free (data);
+ /* We create a new GString here because we need to make sure
+ * we keep writing in case of partial writes */
+ data_str = g_string_new_len ((gchar *)data, data_length);
+ g_free (data);
- g_output_stream_write_async (ostream,
- data_str->str, data_str->len,
- G_PRIORITY_DEFAULT, NULL,
- (GAsyncReadyCallback)save_temp_source_write_cb,
- data_str);
+ g_output_stream_write_async (ostream,
+ data_str->str, data_str->len,
+ G_PRIORITY_DEFAULT, NULL,
+ (GAsyncReadyCallback)save_temp_source_write_cb,
+ data_str);
}
static void
save_temp_source_replace_cb (GFile *file, GAsyncResult *result, EphyEmbed *embed)
{
- EphyWebView *view;
- WebKitWebResource *resource;
- GFileOutputStream *ostream;
- GError *error = NULL;
+ EphyWebView *view;
+ WebKitWebResource *resource;
+ GFileOutputStream *ostream;
+ GError *error = NULL;
- ostream = g_file_replace_finish (file, result, &error);
- if (error)
- {
- g_warning ("Unable to replace file: %s", error->message);
- g_error_free (error);
- return;
- }
+ ostream = g_file_replace_finish (file, result, &error);
+ if (error) {
+ g_warning ("Unable to replace file: %s", error->message);
+ g_error_free (error);
+ return;
+ }
- g_object_set_data_full (G_OBJECT (ostream),
- "ephy-save-temp-source-uri",
- g_file_get_uri (file),
- g_free);
+ g_object_set_data_full (G_OBJECT (ostream),
+ "ephy-save-temp-source-uri",
+ g_file_get_uri (file),
+ g_free);
- view = ephy_embed_get_web_view (embed);
+ view = ephy_embed_get_web_view (embed);
- g_object_set_data_full (G_OBJECT (ostream),
- "ephy-original-source-uri",
- g_strdup (webkit_web_view_get_uri (WEBKIT_WEB_VIEW (view))),
- g_free),
+ g_object_set_data_full (G_OBJECT (ostream),
+ "ephy-original-source-uri",
+ g_strdup (webkit_web_view_get_uri (WEBKIT_WEB_VIEW (view))),
+ g_free),
- g_object_set_data_full (G_OBJECT (ostream),
- "ephy-save-temp-source-embed",
- g_object_ref (embed),
- g_object_unref);
+ g_object_set_data_full (G_OBJECT (ostream),
+ "ephy-save-temp-source-embed",
+ g_object_ref (embed),
+ g_object_unref);
- resource = webkit_web_view_get_main_resource (WEBKIT_WEB_VIEW (view));
- webkit_web_resource_get_data (resource, NULL,
- (GAsyncReadyCallback)get_main_resource_data_cb,
- ostream);
+ resource = webkit_web_view_get_main_resource (WEBKIT_WEB_VIEW (view));
+ webkit_web_resource_get_data (resource, NULL,
+ (GAsyncReadyCallback)get_main_resource_data_cb,
+ ostream);
}
static void
save_temp_source (EphyEmbed *embed,
- guint32 user_time)
+ guint32 user_time)
{
- GFile *file;
- char *tmp, *base;
- const char *static_temp_dir;
+ GFile *file;
+ char *tmp, *base;
+ const char *static_temp_dir;
- static_temp_dir = ephy_file_tmp_dir ();
- if (static_temp_dir == NULL)
- {
- return;
- }
+ static_temp_dir = ephy_file_tmp_dir ();
+ if (static_temp_dir == NULL) {
+ return;
+ }
- base = g_build_filename (static_temp_dir, "viewsourceXXXXXX", NULL);
- tmp = ephy_file_tmp_filename (base, "html");
- g_free (base);
- if (tmp == NULL)
- {
- return;
- }
+ base = g_build_filename (static_temp_dir, "viewsourceXXXXXX", NULL);
+ tmp = ephy_file_tmp_filename (base, "html");
+ g_free (base);
+ if (tmp == NULL) {
+ return;
+ }
- file = g_file_new_for_path (tmp);
- g_file_replace_async (file, NULL, FALSE,
- G_FILE_CREATE_REPLACE_DESTINATION|G_FILE_CREATE_PRIVATE,
- G_PRIORITY_DEFAULT, NULL,
- (GAsyncReadyCallback)save_temp_source_replace_cb,
- embed);
+ file = g_file_new_for_path (tmp);
+ g_file_replace_async (file, NULL, FALSE,
+ G_FILE_CREATE_REPLACE_DESTINATION | G_FILE_CREATE_PRIVATE,
+ G_PRIORITY_DEFAULT, NULL,
+ (GAsyncReadyCallback)save_temp_source_replace_cb,
+ embed);
- g_object_unref (file);
- g_free (tmp);
+ g_object_unref (file);
+ g_free (tmp);
}
void
-window_cmd_view_page_source (GtkAction *action,
- EphyWindow *window)
+window_cmd_view_page_source (GtkAction *action,
+ EphyWindow *window)
{
- EphyEmbed *embed;
- const char *address;
- guint32 user_time;
+ EphyEmbed *embed;
+ const char *address;
+ guint32 user_time;
- embed = ephy_embed_container_get_active_child
- (EPHY_EMBED_CONTAINER (window));
- g_return_if_fail (embed != NULL);
+ embed = ephy_embed_container_get_active_child
+ (EPHY_EMBED_CONTAINER (window));
+ g_return_if_fail (embed != NULL);
- address = ephy_web_view_get_address (ephy_embed_get_web_view (embed));
+ address = ephy_web_view_get_address (ephy_embed_get_web_view (embed));
#if 0
-FIXME: Disabled due to bug #738475
-
- if (g_settings_get_boolean (EPHY_SETTINGS_MAIN,
- EPHY_PREFS_INTERNAL_VIEW_SOURCE))
- {
- view_source_embedded (address, embed);
- return;
- }
+ FIXME: Disabled due to bug #738475
+
+ if (g_settings_get_boolean (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_INTERNAL_VIEW_SOURCE)) {
+ view_source_embedded (address, embed);
+ return;
+ }
#endif
- user_time = gtk_get_current_event_time ();
+ user_time = gtk_get_current_event_time ();
+
+ if (g_str_has_prefix (address, "file://")) {
+ GFile *file;
+
+ file = g_file_new_for_uri (address);
+ ephy_file_launch_handler ("text/plain", file, user_time);
- if (g_str_has_prefix (address, "file://"))
- {
- GFile *file;
-
- file = g_file_new_for_uri (address);
- ephy_file_launch_handler ("text/plain", file, user_time);
-
- g_object_unref (file);
- }
- else
- {
- save_temp_source (embed, user_time);
- }
+ g_object_unref (file);
+ } else {
+ save_temp_source (embed, user_time);
+ }
}
void
window_cmd_help_contents (GtkAction *action,
- GtkWidget *window)
+ GtkWidget *window)
{
- ephy_gui_help (window, NULL);
+ ephy_gui_help (window, NULL);
}
#define ABOUT_GROUP "About"
void
window_cmd_help_about (GtkAction *action,
- GtkWidget *window)
-{
- char *comments = NULL;
- GKeyFile *key_file;
- GError *error = NULL;
- char **list, **authors, **contributors, **past_authors, **artists, **documenters;
- gsize n_authors, n_contributors, n_past_authors, n_artists, n_documenters, i, j;
-
- key_file = g_key_file_new ();
- if (!g_key_file_load_from_file (key_file, DATADIR G_DIR_SEPARATOR_S "about.ini",
- 0, &error))
- {
- g_warning ("Couldn't load about data: %s\n", error->message);
- g_error_free (error);
- return;
- }
-
- list = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Authors",
- &n_authors, NULL);
- contributors = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Contributors",
- &n_contributors, NULL);
- past_authors = g_key_file_get_string_list (key_file, ABOUT_GROUP, "PastAuthors",
- &n_past_authors, NULL);
-
-#define APPEND(_to,_from) \
- _to[i++] = g_strdup (_from);
-
-#define APPEND_STRV_AND_FREE(_to,_from) \
- if (_from)\
- {\
- for (j = 0; _from[j] != NULL; ++j)\
- {\
- _to[i++] = _from[j];\
- }\
- g_free (_from);\
- }
-
- authors = g_new (char *, (list ? n_authors : 0) +
- (contributors ? n_contributors : 0) +
- (past_authors ? n_past_authors : 0) + 7 + 1);
- i = 0;
- APPEND_STRV_AND_FREE (authors, list);
- APPEND (authors, "");
- APPEND (authors, _("Contact us at:"));
- APPEND (authors, "<epiphany-list gnome org>");
- APPEND (authors, "");
- APPEND (authors, _("Contributors:"));
- APPEND_STRV_AND_FREE (authors, contributors);
- APPEND (authors, "");
- APPEND (authors, _("Past developers:"));
- APPEND_STRV_AND_FREE (authors, past_authors);
- authors[i++] = NULL;
-
- list = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Artists", &n_artists, NULL);
-
- artists = g_new (char *, (list ? n_artists : 0) + 4 + 1);
- i = 0;
- APPEND_STRV_AND_FREE (artists, list);
- artists[i++] = NULL;
-
- list = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Documenters", &n_documenters, NULL);
-
- documenters = g_new (char *, (list ? n_documenters : 0) + 3 + 1);
- i = 0;
- APPEND_STRV_AND_FREE (documenters, list);
- APPEND (documenters, "");
- APPEND (documenters, _("Contact us at:"));
- APPEND (documenters, "<gnome-doc-list gnome org>");
- documenters[i++] = NULL;
-
+ GtkWidget *window)
+{
+ char *comments = NULL;
+ GKeyFile *key_file;
+ GError *error = NULL;
+ char **list, **authors, **contributors, **past_authors, **artists, **documenters;
+ gsize n_authors, n_contributors, n_past_authors, n_artists, n_documenters, i, j;
+
+ key_file = g_key_file_new ();
+ if (!g_key_file_load_from_file (key_file, DATADIR G_DIR_SEPARATOR_S "about.ini",
+ 0, &error)) {
+ g_warning ("Couldn't load about data: %s\n", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ list = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Authors",
+ &n_authors, NULL);
+ contributors = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Contributors",
+ &n_contributors, NULL);
+ past_authors = g_key_file_get_string_list (key_file, ABOUT_GROUP, "PastAuthors",
+ &n_past_authors, NULL);
+
+#define APPEND(_to, _from) \
+ _to[i++] = g_strdup (_from);
+
+#define APPEND_STRV_AND_FREE(_to, _from) \
+ if (_from) \
+ { \
+ for (j = 0; _from[j] != NULL; ++j) \
+ { \
+ _to[i++] = _from[j]; \
+ } \
+ g_free (_from); \
+ }
+
+ authors = g_new (char *, (list ? n_authors : 0) +
+ (contributors ? n_contributors : 0) +
+ (past_authors ? n_past_authors : 0) + 7 + 1);
+ i = 0;
+ APPEND_STRV_AND_FREE (authors, list);
+ APPEND (authors, "");
+ APPEND (authors, _("Contact us at:"));
+ APPEND (authors, "<epiphany-list gnome org>");
+ APPEND (authors, "");
+ APPEND (authors, _("Contributors:"));
+ APPEND_STRV_AND_FREE (authors, contributors);
+ APPEND (authors, "");
+ APPEND (authors, _("Past developers:"));
+ APPEND_STRV_AND_FREE (authors, past_authors);
+ authors[i++] = NULL;
+
+ list = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Artists", &n_artists, NULL);
+
+ artists = g_new (char *, (list ? n_artists : 0) + 4 + 1);
+ i = 0;
+ APPEND_STRV_AND_FREE (artists, list);
+ artists[i++] = NULL;
+
+ list = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Documenters", &n_documenters, NULL);
+
+ documenters = g_new (char *, (list ? n_documenters : 0) + 3 + 1);
+ i = 0;
+ APPEND_STRV_AND_FREE (documenters, list);
+ APPEND (documenters, "");
+ APPEND (documenters, _("Contact us at:"));
+ APPEND (documenters, "<gnome-doc-list gnome org>");
+ documenters[i++] = NULL;
+
#undef APPEND
#undef APPEND_STRV_AND_FREE
- g_key_file_free (key_file);
-
- comments = g_strdup_printf (_("A simple, clean, beautiful view of the web.\n"
- "Powered by WebKit %d.%d.%d"),
- webkit_get_major_version (),
- webkit_get_minor_version (),
- webkit_get_micro_version ());
-
- gtk_show_about_dialog (window ? GTK_WINDOW (window) : NULL,
- "program-name", _("Web"),
- "version", VERSION,
- "copyright", "Copyright © 2002–2004 Marco Pesenti Gritti\n"
- "Copyright © 2003–2014 The Web Developers",
- "artists", artists,
- "authors", authors,
- "comments", comments,
- "documenters", documenters,
- /* Translators: This is a special message that shouldn't be translated
- * literally. It is used in the about box to give credits to
- * the translators.
- * Thus, you should translate it to your name and email address.
- * You should also include other translators who have contributed to
- * this translation; in that case, please write each of them on a separate
- * line seperated by newlines (\n).
- */
- "translator-credits", _("translator-credits"),
- "logo-icon-name", "web-browser",
- "website", "https://wiki.gnome.org/Apps/Web",
- "website-label", _("Web Website"),
- "license-type", GTK_LICENSE_GPL_2_0,
- "wrap-license", TRUE,
- NULL);
-
- g_free (comments);
- g_strfreev (artists);
- g_strfreev (authors);
- g_strfreev (documenters);
+ g_key_file_free (key_file);
+
+ comments = g_strdup_printf (_("A simple, clean, beautiful view of the web.\n"
+ "Powered by WebKit %d.%d.%d"),
+ webkit_get_major_version (),
+ webkit_get_minor_version (),
+ webkit_get_micro_version ());
+
+ gtk_show_about_dialog (window ? GTK_WINDOW (window) : NULL,
+ "program-name", _("Web"),
+ "version", VERSION,
+ "copyright", "Copyright © 2002–2004 Marco Pesenti Gritti\n"
+ "Copyright © 2003–2014 The Web Developers",
+ "artists", artists,
+ "authors", authors,
+ "comments", comments,
+ "documenters", documenters,
+ /* Translators: This is a special message that shouldn't be translated
+ * literally. It is used in the about box to give credits to
+ * the translators.
+ * Thus, you should translate it to your name and email address.
+ * You should also include other translators who have contributed to
+ * this translation; in that case, please write each of them on a separate
+ * line seperated by newlines (\n).
+ */
+ "translator-credits", _("translator-credits"),
+ "logo-icon-name", "web-browser",
+ "website", "https://wiki.gnome.org/Apps/Web",
+ "website-label", _("Web Website"),
+ "license-type", GTK_LICENSE_GPL_2_0,
+ "wrap-license", TRUE,
+ NULL);
+
+ g_free (comments);
+ g_strfreev (artists);
+ g_strfreev (authors);
+ g_strfreev (documenters);
}
void
-window_cmd_tabs_next (GtkAction *action,
- EphyWindow *window)
+window_cmd_tabs_next (GtkAction *action,
+ EphyWindow *window)
{
- GtkWidget *nb;
+ GtkWidget *nb;
- nb = ephy_window_get_notebook (window);
- g_return_if_fail (nb != NULL);
+ nb = ephy_window_get_notebook (window);
+ g_return_if_fail (nb != NULL);
- ephy_notebook_next_page (EPHY_NOTEBOOK (nb));
+ ephy_notebook_next_page (EPHY_NOTEBOOK (nb));
}
void
-window_cmd_tabs_previous (GtkAction *action,
- EphyWindow *window)
+window_cmd_tabs_previous (GtkAction *action,
+ EphyWindow *window)
{
- GtkWidget *nb;
+ GtkWidget *nb;
- nb = ephy_window_get_notebook (window);
- g_return_if_fail (nb != NULL);
+ nb = ephy_window_get_notebook (window);
+ g_return_if_fail (nb != NULL);
- ephy_notebook_prev_page (EPHY_NOTEBOOK (nb));
+ ephy_notebook_prev_page (EPHY_NOTEBOOK (nb));
}
void
-window_cmd_tabs_move_left (GtkAction *action,
- EphyWindow *window)
+window_cmd_tabs_move_left (GtkAction *action,
+ EphyWindow *window)
{
- GtkWidget *child;
- GtkNotebook *notebook;
- int page;
+ GtkWidget *child;
+ GtkNotebook *notebook;
+ int page;
- notebook = GTK_NOTEBOOK (ephy_window_get_notebook (window));
- page = gtk_notebook_get_current_page (notebook);
- if (page < 1) return;
+ notebook = GTK_NOTEBOOK (ephy_window_get_notebook (window));
+ page = gtk_notebook_get_current_page (notebook);
+ if (page < 1) return;
- child = gtk_notebook_get_nth_page (notebook, page);
- gtk_notebook_reorder_child (notebook, child, page - 1);
+ child = gtk_notebook_get_nth_page (notebook, page);
+ gtk_notebook_reorder_child (notebook, child, page - 1);
}
-void window_cmd_tabs_move_right (GtkAction *action,
- EphyWindow *window)
+void window_cmd_tabs_move_right (GtkAction *action,
+ EphyWindow *window)
{
- GtkWidget *child;
- GtkNotebook *notebook;
- int page, n_pages;
+ GtkWidget *child;
+ GtkNotebook *notebook;
+ int page, n_pages;
- notebook = GTK_NOTEBOOK (ephy_window_get_notebook (window));
- page = gtk_notebook_get_current_page (notebook);
- n_pages = gtk_notebook_get_n_pages (notebook) - 1;
- if (page > n_pages - 1) return;
+ notebook = GTK_NOTEBOOK (ephy_window_get_notebook (window));
+ page = gtk_notebook_get_current_page (notebook);
+ n_pages = gtk_notebook_get_n_pages (notebook) - 1;
+ if (page > n_pages - 1) return;
- child = gtk_notebook_get_nth_page (notebook, page);
- gtk_notebook_reorder_child (notebook, child, page + 1);
+ child = gtk_notebook_get_nth_page (notebook, page);
+ gtk_notebook_reorder_child (notebook, child, page + 1);
}
void
-window_cmd_tabs_detach (GtkAction *action,
- EphyWindow *window)
+window_cmd_tabs_detach (GtkAction *action,
+ EphyWindow *window)
{
- EphyEmbed *embed;
- GtkNotebook *notebook;
- EphyWindow *new_window;
+ EphyEmbed *embed;
+ GtkNotebook *notebook;
+ EphyWindow *new_window;
- notebook = GTK_NOTEBOOK (ephy_window_get_notebook (window));
- if (gtk_notebook_get_n_pages (notebook) <= 1)
- return;
+ notebook = GTK_NOTEBOOK (ephy_window_get_notebook (window));
+ if (gtk_notebook_get_n_pages (notebook) <= 1)
+ return;
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
- g_object_ref_sink (embed);
- gtk_notebook_remove_page (notebook, gtk_notebook_page_num (notebook, GTK_WIDGET (embed)));
+ g_object_ref_sink (embed);
+ gtk_notebook_remove_page (notebook, gtk_notebook_page_num (notebook, GTK_WIDGET (embed)));
- new_window = ephy_window_new ();
- ephy_embed_container_add_child (EPHY_EMBED_CONTAINER (new_window), embed, 0, FALSE);
- g_object_unref (embed);
+ new_window = ephy_window_new ();
+ ephy_embed_container_add_child (EPHY_EMBED_CONTAINER (new_window), embed, 0, FALSE);
+ g_object_unref (embed);
- gtk_window_present (GTK_WINDOW (new_window));
+ gtk_window_present (GTK_WINDOW (new_window));
}
void
-window_cmd_load_location (GtkAction *action,
- EphyWindow *window)
+window_cmd_load_location (GtkAction *action,
+ EphyWindow *window)
{
- const char *location;
+ const char *location;
- location = ephy_window_get_location (window);
+ location = ephy_window_get_location (window);
- if (location)
- {
- EphyBookmarks *bookmarks;
- char *address;
+ if (location) {
+ EphyBookmarks *bookmarks;
+ char *address;
- bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
+ bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
- address = ephy_bookmarks_resolve_address (bookmarks, location, NULL);
- g_return_if_fail (address != NULL);
+ address = ephy_bookmarks_resolve_address (bookmarks, location, NULL);
+ g_return_if_fail (address != NULL);
- ephy_link_open (EPHY_LINK (window), address,
- ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window)),
- ephy_link_flags_from_current_event ());
- }
+ ephy_link_open (EPHY_LINK (window), address,
+ ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window)),
+ ephy_link_flags_from_current_event ());
+ }
}
void
-window_cmd_browse_with_caret (GtkAction *action,
- EphyWindow *window)
+window_cmd_browse_with_caret (GtkAction *action,
+ EphyWindow *window)
{
- gboolean active;
- EphyEmbed *embed;
+ gboolean active;
+ EphyEmbed *embed;
+
+ embed = ephy_embed_container_get_active_child
+ (EPHY_EMBED_CONTAINER (window));
- embed = ephy_embed_container_get_active_child
- (EPHY_EMBED_CONTAINER (window));
-
- active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
- /* FIXME: perhaps a bit of a kludge; we check if there's an
- * active embed because we don't want to show the dialog on
- * startup when we sync the GtkAction with our GConf
- * preference */
- if (active && embed)
- {
- GtkWidget *dialog;
- int response;
+ /* FIXME: perhaps a bit of a kludge; we check if there's an
+ * active embed because we don't want to show the dialog on
+ * startup when we sync the GtkAction with our GConf
+ * preference */
+ if (active && embed) {
+ GtkWidget *dialog;
+ int response;
- dialog = gtk_message_dialog_new (GTK_WINDOW (window),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION, GTK_BUTTONS_CANCEL,
- _("Enable caret browsing mode?"));
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION, GTK_BUTTONS_CANCEL,
+ _("Enable caret browsing mode?"));
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("Pressing F7 turns caret browsing on or off. This
feature "
- "places a moveable cursor in web pages, allowing
you to move "
- "around with your keyboard. Do you want to enable
caret browsing?"));
- gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Enable"), GTK_RESPONSE_ACCEPT);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ _("Pressing F7 turns caret browsing on or off. This feature "
+ "places a moveable cursor in web pages, allowing you to move
"
+ "around with your keyboard. Do you want to enable caret
browsing?"));
+ gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Enable"), GTK_RESPONSE_ACCEPT);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
- response = gtk_dialog_run (GTK_DIALOG (dialog));
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_widget_destroy (dialog);
- if (response == GTK_RESPONSE_CANCEL)
- {
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), FALSE);
- return;
- }
- }
+ if (response == GTK_RESPONSE_CANCEL) {
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), FALSE);
+ return;
+ }
+ }
- g_settings_set_boolean (EPHY_SETTINGS_MAIN,
- EPHY_PREFS_ENABLE_CARET_BROWSING, active);
+ g_settings_set_boolean (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_ENABLE_CARET_BROWSING, active);
}
void
-window_cmd_view_encoding (GtkAction *action,
+window_cmd_view_encoding (GtkAction *action,
EphyWindow *window)
{
- EphyEncodingDialog *dialog;
+ EphyEncodingDialog *dialog;
- dialog = ephy_encoding_dialog_new (window);
- gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
- gtk_dialog_run (GTK_DIALOG (dialog));
+ dialog = ephy_encoding_dialog_new (window);
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
+ gtk_dialog_run (GTK_DIALOG (dialog));
}
diff --git a/tests/.deps/ephy-bookmarks-test.Po b/tests/.deps/ephy-bookmarks-test.Po
new file mode 100644
index 0000000..9ce06a8
--- /dev/null
+++ b/tests/.deps/ephy-bookmarks-test.Po
@@ -0,0 +1 @@
+# dummy
diff --git a/tests/.deps/ephy-completion-model-test.Po b/tests/.deps/ephy-completion-model-test.Po
new file mode 100644
index 0000000..9ce06a8
--- /dev/null
+++ b/tests/.deps/ephy-completion-model-test.Po
@@ -0,0 +1 @@
+# dummy
diff --git a/tests/.deps/ephy-download-test.Po b/tests/.deps/ephy-download-test.Po
new file mode 100644
index 0000000..9ce06a8
--- /dev/null
+++ b/tests/.deps/ephy-download-test.Po
@@ -0,0 +1 @@
+# dummy
diff --git a/tests/.deps/ephy-embed-shell-test.Po b/tests/.deps/ephy-embed-shell-test.Po
new file mode 100644
index 0000000..9ce06a8
--- /dev/null
+++ b/tests/.deps/ephy-embed-shell-test.Po
@@ -0,0 +1 @@
+# dummy
diff --git a/tests/.deps/ephy-embed-utils-test.Po b/tests/.deps/ephy-embed-utils-test.Po
new file mode 100644
index 0000000..9ce06a8
--- /dev/null
+++ b/tests/.deps/ephy-embed-utils-test.Po
@@ -0,0 +1 @@
+# dummy
diff --git a/tests/.deps/ephy-encodings-test.Po b/tests/.deps/ephy-encodings-test.Po
new file mode 100644
index 0000000..9ce06a8
--- /dev/null
+++ b/tests/.deps/ephy-encodings-test.Po
@@ -0,0 +1 @@
+# dummy
diff --git a/tests/.deps/ephy-history-test.Po b/tests/.deps/ephy-history-test.Po
new file mode 100644
index 0000000..9ce06a8
--- /dev/null
+++ b/tests/.deps/ephy-history-test.Po
@@ -0,0 +1 @@
+# dummy
diff --git a/tests/.deps/ephy-location-entry-test.Po b/tests/.deps/ephy-location-entry-test.Po
new file mode 100644
index 0000000..9ce06a8
--- /dev/null
+++ b/tests/.deps/ephy-location-entry-test.Po
@@ -0,0 +1 @@
+# dummy
diff --git a/tests/.deps/ephy-migration-test.Po b/tests/.deps/ephy-migration-test.Po
new file mode 100644
index 0000000..9ce06a8
--- /dev/null
+++ b/tests/.deps/ephy-migration-test.Po
@@ -0,0 +1 @@
+# dummy
diff --git a/tests/.deps/ephy-sqlite-test.Po b/tests/.deps/ephy-sqlite-test.Po
new file mode 100644
index 0000000..9ce06a8
--- /dev/null
+++ b/tests/.deps/ephy-sqlite-test.Po
@@ -0,0 +1 @@
+# dummy
diff --git a/tests/.deps/ephy-string-test.Po b/tests/.deps/ephy-string-test.Po
new file mode 100644
index 0000000..9ce06a8
--- /dev/null
+++ b/tests/.deps/ephy-string-test.Po
@@ -0,0 +1 @@
+# dummy
diff --git a/tests/.deps/ephy-uri-helpers-test.Po b/tests/.deps/ephy-uri-helpers-test.Po
new file mode 100644
index 0000000..9ce06a8
--- /dev/null
+++ b/tests/.deps/ephy-uri-helpers-test.Po
@@ -0,0 +1 @@
+# dummy
diff --git a/tests/.deps/ephy-web-view-test.Po b/tests/.deps/ephy-web-view-test.Po
new file mode 100644
index 0000000..9ce06a8
--- /dev/null
+++ b/tests/.deps/ephy-web-view-test.Po
@@ -0,0 +1 @@
+# dummy
diff --git a/tests/.deps/epiphany-resources.Po b/tests/.deps/epiphany-resources.Po
new file mode 100644
index 0000000..9ce06a8
--- /dev/null
+++ b/tests/.deps/epiphany-resources.Po
@@ -0,0 +1 @@
+# dummy
diff --git a/tests/.deps/test_ephy_file_helpers-ephy-file-helpers-test.Po
b/tests/.deps/test_ephy_file_helpers-ephy-file-helpers-test.Po
new file mode 100644
index 0000000..9ce06a8
--- /dev/null
+++ b/tests/.deps/test_ephy_file_helpers-ephy-file-helpers-test.Po
@@ -0,0 +1 @@
+# dummy
diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644
index 0000000..a704368
--- /dev/null
+++ b/tests/Makefile
@@ -0,0 +1,1233 @@
+# Makefile.in generated by automake 1.15 from Makefile.am.
+# tests/Makefile. Generated from Makefile.in by configure.
+
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+
+
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/epiphany
+pkgincludedir = $(includedir)/epiphany
+pkglibdir = $(libdir)/epiphany
+pkglibexecdir = $(libexecdir)/epiphany
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = x86_64-unknown-linux-gnu
+host_triplet = x86_64-unknown-linux-gnu
+noinst_PROGRAMS = test-ephy-bookmarks$(EXEEXT) \
+ test-ephy-completion-model$(EXEEXT) \
+ test-ephy-download$(EXEEXT) test-ephy-embed-shell$(EXEEXT) \
+ test-ephy-embed-utils$(EXEEXT) test-ephy-encodings$(EXEEXT) \
+ test-ephy-file-helpers$(EXEEXT) test-ephy-history$(EXEEXT) \
+ test-ephy-location-entry$(EXEEXT) test-ephy-migration$(EXEEXT) \
+ test-ephy-sqlite$(EXEEXT) test-ephy-string$(EXEEXT) \
+ test-ephy-uri-helpers$(EXEEXT) test-ephy-web-view$(EXEEXT)
+subdir = tests
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/libgd/libgd.m4 \
+ $(top_srcdir)/m4/appstream-xml.m4 \
+ $(top_srcdir)/m4/ax_append_compile_flags.m4 \
+ $(top_srcdir)/m4/ax_append_flag.m4 \
+ $(top_srcdir)/m4/ax_append_link_flags.m4 \
+ $(top_srcdir)/m4/ax_check_compile_flag.m4 \
+ $(top_srcdir)/m4/ax_check_enable_debug.m4 \
+ $(top_srcdir)/m4/ax_check_link_flag.m4 \
+ $(top_srcdir)/m4/ax_code_coverage.m4 \
+ $(top_srcdir)/m4/ax_compiler_flags.m4 \
+ $(top_srcdir)/m4/ax_compiler_flags_cflags.m4 \
+ $(top_srcdir)/m4/ax_compiler_flags_gir.m4 \
+ $(top_srcdir)/m4/ax_compiler_flags_ldflags.m4 \
+ $(top_srcdir)/m4/ax_is_release.m4 \
+ $(top_srcdir)/m4/ax_require_defined.m4 \
+ $(top_srcdir)/m4/gsettings.m4 $(top_srcdir)/m4/intltool.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/yelp.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+PROGRAMS = $(noinst_PROGRAMS)
+am_test_ephy_bookmarks_OBJECTS = ephy-bookmarks-test.$(OBJEXT)
+test_ephy_bookmarks_OBJECTS = $(am_test_ephy_bookmarks_OBJECTS)
+test_ephy_bookmarks_LDADD = $(LDADD)
+am__DEPENDENCIES_1 =
+test_ephy_bookmarks_DEPENDENCIES = $(top_builddir)/src/libephymain.la \
+ $(top_builddir)/src/bookmarks/libephybookmarks.la \
+ $(top_builddir)/embed/libephyembed.la \
+ $(top_builddir)/lib/widgets/libephywidgets.la \
+ $(top_builddir)/lib/history/libephyhistory.la \
+ $(top_builddir)/lib/libephymisc.la \
+ $(top_builddir)/lib/egg/libegg.la $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+am__v_lt_1 =
+am_test_ephy_completion_model_OBJECTS = \
+ ephy-completion-model-test.$(OBJEXT)
+test_ephy_completion_model_OBJECTS = \
+ $(am_test_ephy_completion_model_OBJECTS)
+test_ephy_completion_model_LDADD = $(LDADD)
+test_ephy_completion_model_DEPENDENCIES = \
+ $(top_builddir)/src/libephymain.la \
+ $(top_builddir)/src/bookmarks/libephybookmarks.la \
+ $(top_builddir)/embed/libephyembed.la \
+ $(top_builddir)/lib/widgets/libephywidgets.la \
+ $(top_builddir)/lib/history/libephyhistory.la \
+ $(top_builddir)/lib/libephymisc.la \
+ $(top_builddir)/lib/egg/libegg.la $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+am_test_ephy_download_OBJECTS = ephy-download-test.$(OBJEXT)
+test_ephy_download_OBJECTS = $(am_test_ephy_download_OBJECTS)
+test_ephy_download_LDADD = $(LDADD)
+test_ephy_download_DEPENDENCIES = $(top_builddir)/src/libephymain.la \
+ $(top_builddir)/src/bookmarks/libephybookmarks.la \
+ $(top_builddir)/embed/libephyembed.la \
+ $(top_builddir)/lib/widgets/libephywidgets.la \
+ $(top_builddir)/lib/history/libephyhistory.la \
+ $(top_builddir)/lib/libephymisc.la \
+ $(top_builddir)/lib/egg/libegg.la $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+am_test_ephy_embed_shell_OBJECTS = ephy-embed-shell-test.$(OBJEXT)
+test_ephy_embed_shell_OBJECTS = $(am_test_ephy_embed_shell_OBJECTS)
+test_ephy_embed_shell_LDADD = $(LDADD)
+test_ephy_embed_shell_DEPENDENCIES = \
+ $(top_builddir)/src/libephymain.la \
+ $(top_builddir)/src/bookmarks/libephybookmarks.la \
+ $(top_builddir)/embed/libephyembed.la \
+ $(top_builddir)/lib/widgets/libephywidgets.la \
+ $(top_builddir)/lib/history/libephyhistory.la \
+ $(top_builddir)/lib/libephymisc.la \
+ $(top_builddir)/lib/egg/libegg.la $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+am_test_ephy_embed_utils_OBJECTS = ephy-embed-utils-test.$(OBJEXT)
+test_ephy_embed_utils_OBJECTS = $(am_test_ephy_embed_utils_OBJECTS)
+test_ephy_embed_utils_LDADD = $(LDADD)
+test_ephy_embed_utils_DEPENDENCIES = \
+ $(top_builddir)/src/libephymain.la \
+ $(top_builddir)/src/bookmarks/libephybookmarks.la \
+ $(top_builddir)/embed/libephyembed.la \
+ $(top_builddir)/lib/widgets/libephywidgets.la \
+ $(top_builddir)/lib/history/libephyhistory.la \
+ $(top_builddir)/lib/libephymisc.la \
+ $(top_builddir)/lib/egg/libegg.la $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+am_test_ephy_encodings_OBJECTS = ephy-encodings-test.$(OBJEXT)
+test_ephy_encodings_OBJECTS = $(am_test_ephy_encodings_OBJECTS)
+test_ephy_encodings_LDADD = $(LDADD)
+test_ephy_encodings_DEPENDENCIES = $(top_builddir)/src/libephymain.la \
+ $(top_builddir)/src/bookmarks/libephybookmarks.la \
+ $(top_builddir)/embed/libephyembed.la \
+ $(top_builddir)/lib/widgets/libephywidgets.la \
+ $(top_builddir)/lib/history/libephyhistory.la \
+ $(top_builddir)/lib/libephymisc.la \
+ $(top_builddir)/lib/egg/libegg.la $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+am_test_ephy_file_helpers_OBJECTS = \
+ test_ephy_file_helpers-ephy-file-helpers-test.$(OBJEXT)
+test_ephy_file_helpers_OBJECTS = $(am_test_ephy_file_helpers_OBJECTS)
+test_ephy_file_helpers_LDADD = $(LDADD)
+test_ephy_file_helpers_DEPENDENCIES = \
+ $(top_builddir)/src/libephymain.la \
+ $(top_builddir)/src/bookmarks/libephybookmarks.la \
+ $(top_builddir)/embed/libephyembed.la \
+ $(top_builddir)/lib/widgets/libephywidgets.la \
+ $(top_builddir)/lib/history/libephyhistory.la \
+ $(top_builddir)/lib/libephymisc.la \
+ $(top_builddir)/lib/egg/libegg.la $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+am_test_ephy_history_OBJECTS = ephy-history-test.$(OBJEXT)
+test_ephy_history_OBJECTS = $(am_test_ephy_history_OBJECTS)
+test_ephy_history_LDADD = $(LDADD)
+test_ephy_history_DEPENDENCIES = $(top_builddir)/src/libephymain.la \
+ $(top_builddir)/src/bookmarks/libephybookmarks.la \
+ $(top_builddir)/embed/libephyembed.la \
+ $(top_builddir)/lib/widgets/libephywidgets.la \
+ $(top_builddir)/lib/history/libephyhistory.la \
+ $(top_builddir)/lib/libephymisc.la \
+ $(top_builddir)/lib/egg/libegg.la $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+am_test_ephy_location_entry_OBJECTS = \
+ ephy-location-entry-test.$(OBJEXT)
+test_ephy_location_entry_OBJECTS = \
+ $(am_test_ephy_location_entry_OBJECTS)
+test_ephy_location_entry_LDADD = $(LDADD)
+test_ephy_location_entry_DEPENDENCIES = \
+ $(top_builddir)/src/libephymain.la \
+ $(top_builddir)/src/bookmarks/libephybookmarks.la \
+ $(top_builddir)/embed/libephyembed.la \
+ $(top_builddir)/lib/widgets/libephywidgets.la \
+ $(top_builddir)/lib/history/libephyhistory.la \
+ $(top_builddir)/lib/libephymisc.la \
+ $(top_builddir)/lib/egg/libegg.la $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+am_test_ephy_migration_OBJECTS = ephy-migration-test.$(OBJEXT)
+test_ephy_migration_OBJECTS = $(am_test_ephy_migration_OBJECTS)
+test_ephy_migration_LDADD = $(LDADD)
+test_ephy_migration_DEPENDENCIES = $(top_builddir)/src/libephymain.la \
+ $(top_builddir)/src/bookmarks/libephybookmarks.la \
+ $(top_builddir)/embed/libephyembed.la \
+ $(top_builddir)/lib/widgets/libephywidgets.la \
+ $(top_builddir)/lib/history/libephyhistory.la \
+ $(top_builddir)/lib/libephymisc.la \
+ $(top_builddir)/lib/egg/libegg.la $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+am_test_ephy_sqlite_OBJECTS = ephy-sqlite-test.$(OBJEXT)
+test_ephy_sqlite_OBJECTS = $(am_test_ephy_sqlite_OBJECTS)
+test_ephy_sqlite_LDADD = $(LDADD)
+test_ephy_sqlite_DEPENDENCIES = $(top_builddir)/src/libephymain.la \
+ $(top_builddir)/src/bookmarks/libephybookmarks.la \
+ $(top_builddir)/embed/libephyembed.la \
+ $(top_builddir)/lib/widgets/libephywidgets.la \
+ $(top_builddir)/lib/history/libephyhistory.la \
+ $(top_builddir)/lib/libephymisc.la \
+ $(top_builddir)/lib/egg/libegg.la $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+am_test_ephy_string_OBJECTS = ephy-string-test.$(OBJEXT)
+test_ephy_string_OBJECTS = $(am_test_ephy_string_OBJECTS)
+test_ephy_string_LDADD = $(LDADD)
+test_ephy_string_DEPENDENCIES = $(top_builddir)/src/libephymain.la \
+ $(top_builddir)/src/bookmarks/libephybookmarks.la \
+ $(top_builddir)/embed/libephyembed.la \
+ $(top_builddir)/lib/widgets/libephywidgets.la \
+ $(top_builddir)/lib/history/libephyhistory.la \
+ $(top_builddir)/lib/libephymisc.la \
+ $(top_builddir)/lib/egg/libegg.la $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+am_test_ephy_uri_helpers_OBJECTS = ephy-uri-helpers-test.$(OBJEXT)
+test_ephy_uri_helpers_OBJECTS = $(am_test_ephy_uri_helpers_OBJECTS)
+test_ephy_uri_helpers_LDADD = $(LDADD)
+test_ephy_uri_helpers_DEPENDENCIES = \
+ $(top_builddir)/src/libephymain.la \
+ $(top_builddir)/src/bookmarks/libephybookmarks.la \
+ $(top_builddir)/embed/libephyembed.la \
+ $(top_builddir)/lib/widgets/libephywidgets.la \
+ $(top_builddir)/lib/history/libephyhistory.la \
+ $(top_builddir)/lib/libephymisc.la \
+ $(top_builddir)/lib/egg/libegg.la $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+am_test_ephy_web_view_OBJECTS = epiphany-resources.$(OBJEXT) \
+ ephy-web-view-test.$(OBJEXT)
+test_ephy_web_view_OBJECTS = $(am_test_ephy_web_view_OBJECTS)
+test_ephy_web_view_LDADD = $(LDADD)
+test_ephy_web_view_DEPENDENCIES = $(top_builddir)/src/libephymain.la \
+ $(top_builddir)/src/bookmarks/libephybookmarks.la \
+ $(top_builddir)/embed/libephyembed.la \
+ $(top_builddir)/lib/widgets/libephywidgets.la \
+ $(top_builddir)/lib/history/libephyhistory.la \
+ $(top_builddir)/lib/libephymisc.la \
+ $(top_builddir)/lib/egg/libegg.la $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+AM_V_P = $(am__v_P_$(V))
+am__v_P_ = $(am__v_P_$(AM_DEFAULT_VERBOSITY))
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I. -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = $(test_ephy_bookmarks_SOURCES) \
+ $(test_ephy_completion_model_SOURCES) \
+ $(test_ephy_download_SOURCES) $(test_ephy_embed_shell_SOURCES) \
+ $(test_ephy_embed_utils_SOURCES) \
+ $(test_ephy_encodings_SOURCES) \
+ $(test_ephy_file_helpers_SOURCES) $(test_ephy_history_SOURCES) \
+ $(test_ephy_location_entry_SOURCES) \
+ $(test_ephy_migration_SOURCES) $(test_ephy_sqlite_SOURCES) \
+ $(test_ephy_string_SOURCES) $(test_ephy_uri_helpers_SOURCES) \
+ $(test_ephy_web_view_SOURCES)
+DIST_SOURCES = $(test_ephy_bookmarks_SOURCES) \
+ $(test_ephy_completion_model_SOURCES) \
+ $(test_ephy_download_SOURCES) $(test_ephy_embed_shell_SOURCES) \
+ $(test_ephy_embed_utils_SOURCES) \
+ $(test_ephy_encodings_SOURCES) \
+ $(test_ephy_file_helpers_SOURCES) $(test_ephy_history_SOURCES) \
+ $(test_ephy_location_entry_SOURCES) \
+ $(test_ephy_migration_SOURCES) $(test_ephy_sqlite_SOURCES) \
+ $(test_ephy_string_SOURCES) $(test_ephy_uri_helpers_SOURCES) \
+ $(test_ephy_web_view_SOURCES)
+RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
+ ctags-recursive dvi-recursive html-recursive info-recursive \
+ install-data-recursive install-dvi-recursive \
+ install-exec-recursive install-html-recursive \
+ install-info-recursive install-pdf-recursive \
+ install-ps-recursive install-recursive installcheck-recursive \
+ installdirs-recursive pdf-recursive ps-recursive \
+ tags-recursive uninstall-recursive
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
+ distclean-recursive maintainer-clean-recursive
+am__recursive_targets = \
+ $(RECURSIVE_TARGETS) \
+ $(RECURSIVE_CLEAN_TARGETS) \
+ $(am__extra_recursive_targets)
+AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
+ distdir
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+am__DIST_COMMON = $(srcdir)/Makefile.in \
+ $(top_srcdir)/build-aux/depcomp
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+ dir0=`pwd`; \
+ sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+ sed_rest='s,^[^/]*/*,,'; \
+ sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+ sed_butlast='s,/*[^/]*$$,,'; \
+ while test -n "$$dir1"; do \
+ first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+ if test "$$first" != "."; then \
+ if test "$$first" = ".."; then \
+ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+ else \
+ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+ if test "$$first2" = "$$first"; then \
+ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+ else \
+ dir2="../$$dir2"; \
+ fi; \
+ dir0="$$dir0"/"$$first"; \
+ fi; \
+ fi; \
+ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+ done; \
+ reldir="$$dir2"
+ACLOCAL = ${SHELL} /home/mcatanzaro/src/jhbuild/checkout/epiphany/build-aux/missing aclocal-1.15
+ALL_LINGUAS =
+AMTAR = $${TAR-tar}
+AM_DEFAULT_VERBOSITY = 0
+APPSTREAM_UTIL = /usr/bin/appstream-util
+AR = ar
+AUTOCONF = ${SHELL} /home/mcatanzaro/src/jhbuild/checkout/epiphany/build-aux/missing autoconf
+AUTOHEADER = ${SHELL} /home/mcatanzaro/src/jhbuild/checkout/epiphany/build-aux/missing autoheader
+AUTOMAKE = ${SHELL} /home/mcatanzaro/src/jhbuild/checkout/epiphany/build-aux/missing automake-1.15
+AWK = gawk
+CC = gcc
+CCDEPMODE = depmode=gcc3
+CFLAGS = -ggdb3 -Og -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -O0
+CODE_COVERAGE_CFLAGS =
+CODE_COVERAGE_ENABLED = no
+CODE_COVERAGE_LDFLAGS =
+CPP = gcc -E
+CPPFLAGS =
+CYGPATH_W = echo
+DEFS = -DHAVE_CONFIG_H
+DEPDIR = .deps
+DEPENDENCIES_CFLAGS = -pthread -D_REENTRANT
-I/home/mcatanzaro/src/jhbuild/install/include/gtk-3.0/unix-print
-I/home/mcatanzaro/src/jhbuild/install/include/libwnck-3.0
-I/home/mcatanzaro/src/jhbuild/install/include/webkitgtk-4.0
-I/home/mcatanzaro/src/jhbuild/install/include/libsoup-2.4
-I/home/mcatanzaro/src/jhbuild/install/include/libsecret-1
-I/home/mcatanzaro/src/jhbuild/install/include/gnome-desktop-3.0
-I/home/mcatanzaro/src/jhbuild/install/include/gcr-3 -I/home/mcatanzaro/src/jhbuild/install/include/gtk-3.0
-I/home/mcatanzaro/src/jhbuild/install/include/at-spi2-atk/2.0
-I/home/mcatanzaro/src/jhbuild/install/include/at-spi-2.0
-I/home/mcatanzaro/src/jhbuild/install/include/gtk-3.0
-I/home/mcatanzaro/src/jhbuild/install/include/gio-unix-2.0/
-I/home/mcatanzaro/src/jhbuild/install/include/pango-1.0
-I/home/mcatanzaro/src/jhbuild/install/include/harfbuzz
-I/home/mcatanzaro/src/jhbuild/install/include/pango-1.0
-I/home/mcatanzaro/src/jhbuild/install/include/atk-1.0 -I/hom
e/mcatanzaro/src/jhbuild/install/include/gdk-pixbuf-2.0 -I/home/mcatanzaro/src/jhbuild/install/include/gcr-3
-I/home/mcatanzaro/src/jhbuild/install/include/gck-1 -I/home/mcatanzaro/src/jhbuild/install/include/glib-2.0
-I/home/mcatanzaro/src/jhbuild/install/lib/glib-2.0/include
-I/home/mcatanzaro/src/jhbuild/install/include/gsettings-desktop-schemas
-I/usr/include/startup-notification-1.0 -I/usr/include/libxml2 -I/usr/include/dbus-1.0
-I/usr/lib64/dbus-1.0/include -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2
-I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libdrm -I/usr/include/libpng16
-I/usr/include/p11-kit-1
+DEPENDENCIES_LIBS = -L/home/mcatanzaro/src/jhbuild/install/lib -lgthread-2.0 -pthread -lgio-2.0 -lX11
-lwnck-3 -lxslt -lxml2 -lz -lm -ldl -lm -lxml2 -lwebkit2gtk-4.0 -ljavascriptcoregtk-4.0 -lsoup-2.4 -lsecret-1
-lgnome-desktop-3 -lnotify -lsqlite3 -lgcr-ui-3 -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0
-lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgcr-base-3 -lgck-1 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lp11-kit
-lavahi-gobject -lavahi-common -lavahi-client
+DLLTOOL = false
+DSYMUTIL =
+DUMPBIN =
+ECHO_C =
+ECHO_N = -n
+ECHO_T =
+EGREP = /usr/bin/grep -E
+EPIPHANY_MAJOR = 3.20
+EXEEXT =
+FGREP = /usr/bin/grep -F
+GCOV =
+GENHTML =
+GETTEXT_PACKAGE = epiphany
+GLIB_COMPILE_SCHEMAS = glib-compile-schemas
+GLIB_MKENUMS = /home/mcatanzaro/src/jhbuild/install/bin/glib-mkenums
+GMSGFMT = /usr/bin/msgfmt
+GREP = /usr/bin/grep
+GSETTINGS_DISABLE_SCHEMAS_COMPILE =
+HELP_DIR = ${datadir}/help
+INSTALL = /usr/bin/install -c
+INSTALL_DATA = ${INSTALL} -m 644
+INSTALL_PROGRAM = ${INSTALL}
+INSTALL_SCRIPT = ${INSTALL}
+INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
+INTLTOOL_EXTRACT = /usr/bin/intltool-extract
+INTLTOOL_MERGE = /usr/bin/intltool-merge
+INTLTOOL_PERL = /usr/bin/perl
+INTLTOOL_UPDATE = /usr/bin/intltool-update
+INTLTOOL_V_MERGE = $(INTLTOOL__v_MERGE_$(V))
+INTLTOOL_V_MERGE_OPTIONS = $(intltool__v_merge_options_$(V))
+INTLTOOL__v_MERGE_ = $(INTLTOOL__v_MERGE_$(AM_DEFAULT_VERBOSITY))
+INTLTOOL__v_MERGE_0 = @echo " ITMRG " $@;
+ITSTOOL = itstool
+LCOV =
+LD = /usr/bin/ld -m elf_x86_64
+LDFLAGS = -L/home/mcatanzaro/src/jhbuild/install/lib
+LIBGD_CFLAGS = -pthread -I/home/mcatanzaro/src/jhbuild/install/include/gtk-3.0
-I/home/mcatanzaro/src/jhbuild/install/include/at-spi2-atk/2.0
-I/home/mcatanzaro/src/jhbuild/install/include/at-spi-2.0
-I/home/mcatanzaro/src/jhbuild/install/include/gtk-3.0
-I/home/mcatanzaro/src/jhbuild/install/include/gio-unix-2.0/
-I/home/mcatanzaro/src/jhbuild/install/include/pango-1.0
-I/home/mcatanzaro/src/jhbuild/install/include/harfbuzz
-I/home/mcatanzaro/src/jhbuild/install/include/pango-1.0
-I/home/mcatanzaro/src/jhbuild/install/include/atk-1.0
-I/home/mcatanzaro/src/jhbuild/install/include/gdk-pixbuf-2.0
-I/home/mcatanzaro/src/jhbuild/install/include/glib-2.0
-I/home/mcatanzaro/src/jhbuild/install/lib/glib-2.0/include -I/usr/include/dbus-1.0
-I/usr/lib64/dbus-1.0/include -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2
-I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libdrm -I/usr/include/libpng16
+LIBGD_GIR_INCLUDES = Gtk-3.0
+LIBGD_LIBS = -L/home/mcatanzaro/src/jhbuild/install/lib -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0
-latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0
+LIBGD_MODULE_DIR = libgd
+LIBGD_SOURCES =
+LIBM = -lm
+LIBOBJS =
+LIBS =
+LIBTOOL = $(SHELL) $(top_builddir)/libtool
+LIPO =
+LN_S = ln -s
+LSB_RELEASE =
+LTLIBOBJS =
+LT_SYS_LIBRARY_PATH =
+MAINT =
+MAKEINFO = ${SHELL} /home/mcatanzaro/src/jhbuild/checkout/epiphany/build-aux/missing makeinfo
+MANIFEST_TOOL = :
+MKDIR_P = /usr/bin/mkdir -p
+MSGFMT = /usr/bin/msgfmt
+MSGMERGE = /usr/bin/msgmerge
+NM = /usr/bin/nm -B
+NMEDIT =
+NSS_CFLAGS = -I/usr/include/nss3 -I/usr/include/nspr4
+NSS_LIBS = -lssl3 -lsmime3 -lnss3 -lnssutil3 -lplds4 -lplc4 -lnspr4 -lpthread -ldl
+OBJDUMP = objdump
+OBJEXT = o
+OTOOL =
+OTOOL64 =
+PACKAGE = epiphany
+PACKAGE_BUGREPORT = http://bugzilla.gnome.org/enter_bug.cgi?product=epiphany
+PACKAGE_NAME = GNOME Web Browser
+PACKAGE_STRING = GNOME Web Browser 3.20.0
+PACKAGE_TARNAME = epiphany
+PACKAGE_URL =
+PACKAGE_VERSION = 3.20.0
+PATH_SEPARATOR = :
+PKG_CONFIG = /usr/bin/pkg-config
+PKG_CONFIG_LIBDIR =
+PKG_CONFIG_PATH =
/home/mcatanzaro/src/jhbuild/install/lib/pkgconfig:/home/mcatanzaro/src/jhbuild/install/share/pkgconfig:/usr/lib64/pkgconfig:/usr/share/pkgconfig
+RANLIB = ranlib
+SED = /usr/bin/sed
+SET_MAKE =
+SHELL = /bin/sh
+STRIP = strip
+USE_NLS = yes
+VERSION = 3.20.0
+WARN_CFLAGS = -fno-strict-aliasing -Wall -Wextra -Wundef -Wnested-externs -Wwrite-strings -Wpointer-arith
-Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wno-unused-parameter
-Wno-missing-field-initializers -Wdeclaration-after-statement -Wformat=2 -Wold-style-definition -Wcast-align
-Wformat-nonliteral -Wformat-security -Wsign-compare -Wstrict-aliasing -Wshadow -Winline -Wpacked
-Wmissing-format-attribute -Wmissing-noreturn -Winit-self -Wmissing-include-dirs -Wunused-but-set-variable
-Warray-bounds -Wimplicit-function-declaration -Wreturn-type -Wswitch-enum -Wswitch-default
-Wno-deprecated-declarations -Werror -Wno-suggest-attribute=format -Wno-error=unused-parameter
-Wno-error=missing-field-initializers -Wno-error=deprecated-declarations
+WARN_LDFLAGS = -Wl,--no-as-needed -Wl,--fatal-warnings
+WARN_SCANNERFLAGS = --warn-all
--warn-error
+WEB_EXTENSION_CFLAGS = -pthread -I/home/mcatanzaro/src/jhbuild/install/include/webkitgtk-4.0
-I/home/mcatanzaro/src/jhbuild/install/include/gtk-3.0
-I/home/mcatanzaro/src/jhbuild/install/include/at-spi2-atk/2.0
-I/home/mcatanzaro/src/jhbuild/install/include/at-spi-2.0
-I/home/mcatanzaro/src/jhbuild/install/include/gtk-3.0
-I/home/mcatanzaro/src/jhbuild/install/include/gio-unix-2.0/
-I/home/mcatanzaro/src/jhbuild/install/include/pango-1.0
-I/home/mcatanzaro/src/jhbuild/install/include/harfbuzz
-I/home/mcatanzaro/src/jhbuild/install/include/pango-1.0
-I/home/mcatanzaro/src/jhbuild/install/include/atk-1.0
-I/home/mcatanzaro/src/jhbuild/install/include/gdk-pixbuf-2.0
-I/home/mcatanzaro/src/jhbuild/install/include/libsoup-2.4
-I/home/mcatanzaro/src/jhbuild/install/include/webkitgtk-4.0
-I/home/mcatanzaro/src/jhbuild/install/include/libsecret-1
-I/home/mcatanzaro/src/jhbuild/install/include/glib-2.0
-I/home/mcatanzaro/src/jhbuild/install/lib/glib-2.0/include -I/usr/include/dbus-1.
0 -I/usr/lib64/dbus-1.0/include -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2
-I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libdrm -I/usr/include/libpng16
-I/usr/include/libxml2
+WEB_EXTENSION_LIBS = -L/home/mcatanzaro/src/jhbuild/install/lib -lwebkit2gtk-4.0 -lgtk-3 -lgdk-3
-lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lsoup-2.4
-ljavascriptcoregtk-4.0 -lsecret-1 -lgio-2.0 -lgobject-2.0 -lglib-2.0
+XGETTEXT = /usr/bin/xgettext
+XMLLINT = xmllint
+YELP_LC_DIST = true
+YELP_LC_MEDIA_LINKS = true
+abs_builddir = /home/mcatanzaro/src/jhbuild/checkout/epiphany/tests
+abs_srcdir = /home/mcatanzaro/src/jhbuild/checkout/epiphany/tests
+abs_top_builddir = /home/mcatanzaro/src/jhbuild/checkout/epiphany
+abs_top_srcdir = /home/mcatanzaro/src/jhbuild/checkout/epiphany
+ac_ct_AR = ar
+ac_ct_CC = gcc
+ac_ct_DUMPBIN =
+am__include = include
+am__leading_dot = .
+am__quote =
+am__tar = tar --format=ustar -chf - "$$tardir"
+am__untar = tar -xf -
+appstreamxmldir = ${datarootdir}/appdata
+bindir = ${exec_prefix}/bin
+build = x86_64-unknown-linux-gnu
+build_alias =
+build_cpu = x86_64
+build_os = linux-gnu
+build_vendor = unknown
+builddir = .
+datadir = ${datarootdir}
+datarootdir = ${prefix}/share
+docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
+dvidir = ${docdir}
+exec_prefix = ${prefix}
+gsettingsschemadir = ${datarootdir}/glib-2.0/schemas
+host = x86_64-unknown-linux-gnu
+host_alias =
+host_cpu = x86_64
+host_os = linux-gnu
+host_vendor = unknown
+htmldir = ${docdir}
+includedir = ${prefix}/include
+infodir = ${datarootdir}/info
+install_sh = ${SHELL} /home/mcatanzaro/src/jhbuild/checkout/epiphany/build-aux/install-sh
+intltool__v_merge_options_ = $(intltool__v_merge_options_$(AM_DEFAULT_VERBOSITY))
+intltool__v_merge_options_0 = -q
+libdir = ${exec_prefix}/lib
+libexecdir = ${exec_prefix}/libexec
+localedir = ${datarootdir}/locale
+localstatedir = ${prefix}/var
+mandir = ${datarootdir}/man
+mkdir_p = $(MKDIR_P)
+oldincludedir = /usr/include
+pdfdir = ${docdir}
+prefix = /home/mcatanzaro/src/jhbuild/install
+program_transform_name = s,x,x,
+psdir = ${docdir}
+sbindir = ${exec_prefix}/sbin
+sharedstatedir = ${prefix}/com
+srcdir = .
+sysconfdir = ${prefix}/etc
+target_alias =
+top_build_prefix = ../
+top_builddir = ..
+top_srcdir = ..
+SUBDIRS = data
+
+# Mostly copied from Makefile.decl in glib
+GTESTER = gtester
+GTESTER_REPORT = gtester-report
+
+# initialize variables for unconditional += appending
+TEST_PROGS = ${noinst_PROGRAMS}
+AM_CPPFLAGS = \
+ -I$(top_srcdir)/embed \
+ -I$(top_srcdir)/lib \
+ -I$(top_srcdir)/lib/history \
+ -I$(top_srcdir)/lib/widgets \
+ -I$(top_builddir)/lib/widgets \
+ -I$(top_srcdir)/src \
+ -I$(top_srcdir)/src/bookmarks
+
+AM_CFLAGS = \
+ -DTEST_DIR=\"$(srcdir)\"\
+ $(DEPENDENCIES_CFLAGS) \
+ $(CODE_COVERAGE_CFLAGS) \
+ $(WARN_CFLAGS)
+
+AM_LDFLAGS = $(WARN_LDFLAGS)
+LDADD = \
+ $(top_builddir)/src/libephymain.la \
+ $(top_builddir)/src/bookmarks/libephybookmarks.la \
+ $(top_builddir)/embed/libephyembed.la \
+ $(top_builddir)/lib/widgets/libephywidgets.la \
+ $(top_builddir)/lib/history/libephyhistory.la \
+ $(top_builddir)/lib/libephymisc.la \
+ $(top_builddir)/lib/egg/libegg.la \
+ $(DBUS_LIBS) \
+ $(CODE_COVERAGE_LDFLAGS) \
+ $(DEPENDENCIES_LIBS)
+
+test_ephy_bookmarks_SOURCES = \
+ ephy-bookmarks-test.c
+
+test_ephy_completion_model_SOURCES = \
+ ephy-completion-model-test.c
+
+test_ephy_download_SOURCES = \
+ ephy-download-test.c
+
+test_ephy_embed_shell_SOURCES = \
+ ephy-embed-shell-test.c
+
+test_ephy_embed_utils_SOURCES = \
+ ephy-embed-utils-test.c
+
+test_ephy_encodings_SOURCES = \
+ ephy-encodings-test.c
+
+test_ephy_file_helpers_SOURCES = \
+ ephy-file-helpers-test.c
+
+test_ephy_file_helpers_CPPFLAGS = \
+ -DTOP_SRC_DIR=\"$(abs_top_srcdir)\" \
+ $(AM_CPPFLAGS)
+
+test_ephy_history_SOURCES = \
+ ephy-history-test.c
+
+test_ephy_location_entry_SOURCES = \
+ ephy-location-entry-test.c
+
+test_ephy_migration_SOURCES = \
+ ephy-migration-test.c
+
+
+# https://bugzilla.gnome.org/show_bug.cgi?id=707220
+# test_ephy_session_SOURCES = \
+# ephy-session-test.c \
+# ephy-test-utils.c \
+# ephy-test-utils.h \
+# $(top_builddir)/src/epiphany-resources.c \
+# $(top_builddir)/src/epiphany-resources.h
+
+# https://bugzilla.gnome.org/show_bug.cgi?id=693369
+# https://bugzilla.gnome.org/show_bug.cgi?id=695703
+# https://bugzilla.gnome.org/show_bug.cgi?id=707217
+# test_ephy_shell_SOURCES = \
+# $(top_builddir)/src/epiphany-resources.c \
+# $(top_builddir)/src/epiphany-resources.h \
+# ephy-shell-test.c \
+# ephy-test-utils.c \
+# ephy-test-utils.h
+
+# https://bugzilla.gnome.org/show_bug.cgi?id=762753
+#test_ephy_snapshot_service_SOURCES = \
+# ephy-snapshot-service-test.c
+test_ephy_sqlite_SOURCES = \
+ ephy-sqlite-test.c
+
+test_ephy_string_SOURCES = \
+ ephy-string-test.c
+
+test_ephy_uri_helpers_SOURCES = \
+ ephy-uri-helpers-test.c
+
+
+# https://bugzilla.gnome.org/show_bug.cgi?id=759256
+# test_ephy_web_app_utils_SOURCES = \
+# ephy-web-app-utils-test.c
+test_ephy_web_view_SOURCES = \
+ $(top_builddir)/src/epiphany-resources.c \
+ ephy-web-view-test.c
+
+EXTRA_DIST = \
+ data/test.html \
+ applications/epiphany.desktop \
+ applications/defaults.list
+
+all: all-recursive
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign tests/Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstPROGRAMS:
+ @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+
+test-ephy-bookmarks$(EXEEXT): $(test_ephy_bookmarks_OBJECTS) $(test_ephy_bookmarks_DEPENDENCIES)
$(EXTRA_test_ephy_bookmarks_DEPENDENCIES)
+ @rm -f test-ephy-bookmarks$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(test_ephy_bookmarks_OBJECTS) $(test_ephy_bookmarks_LDADD) $(LIBS)
+
+test-ephy-completion-model$(EXEEXT): $(test_ephy_completion_model_OBJECTS)
$(test_ephy_completion_model_DEPENDENCIES) $(EXTRA_test_ephy_completion_model_DEPENDENCIES)
+ @rm -f test-ephy-completion-model$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(test_ephy_completion_model_OBJECTS) $(test_ephy_completion_model_LDADD) $(LIBS)
+
+test-ephy-download$(EXEEXT): $(test_ephy_download_OBJECTS) $(test_ephy_download_DEPENDENCIES)
$(EXTRA_test_ephy_download_DEPENDENCIES)
+ @rm -f test-ephy-download$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(test_ephy_download_OBJECTS) $(test_ephy_download_LDADD) $(LIBS)
+
+test-ephy-embed-shell$(EXEEXT): $(test_ephy_embed_shell_OBJECTS) $(test_ephy_embed_shell_DEPENDENCIES)
$(EXTRA_test_ephy_embed_shell_DEPENDENCIES)
+ @rm -f test-ephy-embed-shell$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(test_ephy_embed_shell_OBJECTS) $(test_ephy_embed_shell_LDADD) $(LIBS)
+
+test-ephy-embed-utils$(EXEEXT): $(test_ephy_embed_utils_OBJECTS) $(test_ephy_embed_utils_DEPENDENCIES)
$(EXTRA_test_ephy_embed_utils_DEPENDENCIES)
+ @rm -f test-ephy-embed-utils$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(test_ephy_embed_utils_OBJECTS) $(test_ephy_embed_utils_LDADD) $(LIBS)
+
+test-ephy-encodings$(EXEEXT): $(test_ephy_encodings_OBJECTS) $(test_ephy_encodings_DEPENDENCIES)
$(EXTRA_test_ephy_encodings_DEPENDENCIES)
+ @rm -f test-ephy-encodings$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(test_ephy_encodings_OBJECTS) $(test_ephy_encodings_LDADD) $(LIBS)
+
+test-ephy-file-helpers$(EXEEXT): $(test_ephy_file_helpers_OBJECTS) $(test_ephy_file_helpers_DEPENDENCIES)
$(EXTRA_test_ephy_file_helpers_DEPENDENCIES)
+ @rm -f test-ephy-file-helpers$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(test_ephy_file_helpers_OBJECTS) $(test_ephy_file_helpers_LDADD) $(LIBS)
+
+test-ephy-history$(EXEEXT): $(test_ephy_history_OBJECTS) $(test_ephy_history_DEPENDENCIES)
$(EXTRA_test_ephy_history_DEPENDENCIES)
+ @rm -f test-ephy-history$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(test_ephy_history_OBJECTS) $(test_ephy_history_LDADD) $(LIBS)
+
+test-ephy-location-entry$(EXEEXT): $(test_ephy_location_entry_OBJECTS)
$(test_ephy_location_entry_DEPENDENCIES) $(EXTRA_test_ephy_location_entry_DEPENDENCIES)
+ @rm -f test-ephy-location-entry$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(test_ephy_location_entry_OBJECTS) $(test_ephy_location_entry_LDADD) $(LIBS)
+
+test-ephy-migration$(EXEEXT): $(test_ephy_migration_OBJECTS) $(test_ephy_migration_DEPENDENCIES)
$(EXTRA_test_ephy_migration_DEPENDENCIES)
+ @rm -f test-ephy-migration$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(test_ephy_migration_OBJECTS) $(test_ephy_migration_LDADD) $(LIBS)
+
+test-ephy-sqlite$(EXEEXT): $(test_ephy_sqlite_OBJECTS) $(test_ephy_sqlite_DEPENDENCIES)
$(EXTRA_test_ephy_sqlite_DEPENDENCIES)
+ @rm -f test-ephy-sqlite$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(test_ephy_sqlite_OBJECTS) $(test_ephy_sqlite_LDADD) $(LIBS)
+
+test-ephy-string$(EXEEXT): $(test_ephy_string_OBJECTS) $(test_ephy_string_DEPENDENCIES)
$(EXTRA_test_ephy_string_DEPENDENCIES)
+ @rm -f test-ephy-string$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(test_ephy_string_OBJECTS) $(test_ephy_string_LDADD) $(LIBS)
+
+test-ephy-uri-helpers$(EXEEXT): $(test_ephy_uri_helpers_OBJECTS) $(test_ephy_uri_helpers_DEPENDENCIES)
$(EXTRA_test_ephy_uri_helpers_DEPENDENCIES)
+ @rm -f test-ephy-uri-helpers$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(test_ephy_uri_helpers_OBJECTS) $(test_ephy_uri_helpers_LDADD) $(LIBS)
+
+test-ephy-web-view$(EXEEXT): $(test_ephy_web_view_OBJECTS) $(test_ephy_web_view_DEPENDENCIES)
$(EXTRA_test_ephy_web_view_DEPENDENCIES)
+ @rm -f test-ephy-web-view$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(test_ephy_web_view_OBJECTS) $(test_ephy_web_view_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+include ./$(DEPDIR)/ephy-bookmarks-test.Po
+include ./$(DEPDIR)/ephy-completion-model-test.Po
+include ./$(DEPDIR)/ephy-download-test.Po
+include ./$(DEPDIR)/ephy-embed-shell-test.Po
+include ./$(DEPDIR)/ephy-embed-utils-test.Po
+include ./$(DEPDIR)/ephy-encodings-test.Po
+include ./$(DEPDIR)/ephy-history-test.Po
+include ./$(DEPDIR)/ephy-location-entry-test.Po
+include ./$(DEPDIR)/ephy-migration-test.Po
+include ./$(DEPDIR)/ephy-sqlite-test.Po
+include ./$(DEPDIR)/ephy-string-test.Po
+include ./$(DEPDIR)/ephy-uri-helpers-test.Po
+include ./$(DEPDIR)/ephy-web-view-test.Po
+include ./$(DEPDIR)/epiphany-resources.Po
+include ./$(DEPDIR)/test_ephy_file_helpers-ephy-file-helpers-test.Po
+
+.c.o:
+ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+# $(AM_V_CC)source='$<' object='$@' libtool=no \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+# $(AM_V_CC)source='$<' object='$@' libtool=no \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+# $(AM_V_CC)source='$<' object='$@' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(LTCOMPILE) -c -o $@ $<
+
+test_ephy_file_helpers-ephy-file-helpers-test.o: ephy-file-helpers-test.c
+ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_ephy_file_helpers_CPPFLAGS)
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_ephy_file_helpers-ephy-file-helpers-test.o -MD -MP -MF
$(DEPDIR)/test_ephy_file_helpers-ephy-file-helpers-test.Tpo -c -o
test_ephy_file_helpers-ephy-file-helpers-test.o `test -f 'ephy-file-helpers-test.c' || echo
'$(srcdir)/'`ephy-file-helpers-test.c
+ $(AM_V_at)$(am__mv) $(DEPDIR)/test_ephy_file_helpers-ephy-file-helpers-test.Tpo
$(DEPDIR)/test_ephy_file_helpers-ephy-file-helpers-test.Po
+# $(AM_V_CC)source='ephy-file-helpers-test.c' object='test_ephy_file_helpers-ephy-file-helpers-test.o'
libtool=no \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_ephy_file_helpers_CPPFLAGS)
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_ephy_file_helpers-ephy-file-helpers-test.o `test -f
'ephy-file-helpers-test.c' || echo '$(srcdir)/'`ephy-file-helpers-test.c
+
+test_ephy_file_helpers-ephy-file-helpers-test.obj: ephy-file-helpers-test.c
+ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_ephy_file_helpers_CPPFLAGS)
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_ephy_file_helpers-ephy-file-helpers-test.obj -MD -MP -MF
$(DEPDIR)/test_ephy_file_helpers-ephy-file-helpers-test.Tpo -c -o
test_ephy_file_helpers-ephy-file-helpers-test.obj `if test -f 'ephy-file-helpers-test.c'; then $(CYGPATH_W)
'ephy-file-helpers-test.c'; else $(CYGPATH_W) '$(srcdir)/ephy-file-helpers-test.c'; fi`
+ $(AM_V_at)$(am__mv) $(DEPDIR)/test_ephy_file_helpers-ephy-file-helpers-test.Tpo
$(DEPDIR)/test_ephy_file_helpers-ephy-file-helpers-test.Po
+# $(AM_V_CC)source='ephy-file-helpers-test.c'
object='test_ephy_file_helpers-ephy-file-helpers-test.obj' libtool=no \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_ephy_file_helpers_CPPFLAGS)
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_ephy_file_helpers-ephy-file-helpers-test.obj `if test -f
'ephy-file-helpers-test.c'; then $(CYGPATH_W) 'ephy-file-helpers-test.c'; else $(CYGPATH_W)
'$(srcdir)/ephy-file-helpers-test.c'; fi`
+
+epiphany-resources.o: $(top_builddir)/src/epiphany-resources.c
+ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
$(CFLAGS) -MT epiphany-resources.o -MD -MP -MF $(DEPDIR)/epiphany-resources.Tpo -c -o epiphany-resources.o
`test -f '$(top_builddir)/src/epiphany-resources.c' || echo
'$(srcdir)/'`$(top_builddir)/src/epiphany-resources.c
+ $(AM_V_at)$(am__mv) $(DEPDIR)/epiphany-resources.Tpo $(DEPDIR)/epiphany-resources.Po
+# $(AM_V_CC)source='$(top_builddir)/src/epiphany-resources.c' object='epiphany-resources.o' libtool=no \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
$(CFLAGS) -c -o epiphany-resources.o `test -f '$(top_builddir)/src/epiphany-resources.c' || echo
'$(srcdir)/'`$(top_builddir)/src/epiphany-resources.c
+
+epiphany-resources.obj: $(top_builddir)/src/epiphany-resources.c
+ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
$(CFLAGS) -MT epiphany-resources.obj -MD -MP -MF $(DEPDIR)/epiphany-resources.Tpo -c -o
epiphany-resources.obj `if test -f '$(top_builddir)/src/epiphany-resources.c'; then $(CYGPATH_W)
'$(top_builddir)/src/epiphany-resources.c'; else $(CYGPATH_W)
'$(srcdir)/$(top_builddir)/src/epiphany-resources.c'; fi`
+ $(AM_V_at)$(am__mv) $(DEPDIR)/epiphany-resources.Tpo $(DEPDIR)/epiphany-resources.Po
+# $(AM_V_CC)source='$(top_builddir)/src/epiphany-resources.c' object='epiphany-resources.obj'
libtool=no \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
$(CFLAGS) -c -o epiphany-resources.obj `if test -f '$(top_builddir)/src/epiphany-resources.c'; then
$(CYGPATH_W) '$(top_builddir)/src/epiphany-resources.c'; else $(CYGPATH_W)
'$(srcdir)/$(top_builddir)/src/epiphany-resources.c'; fi`
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run 'make' without going through this Makefile.
+# To change the values of 'make' variables: instead of editing Makefiles,
+# (1) if the variable is set in 'config.status', edit 'config.status'
+# (which will cause the Makefiles to be regenerated when you run 'make');
+# (2) otherwise, pass the desired values on the 'make' command line.
+$(am__recursive_targets):
+ @fail=; \
+ if $(am__make_keepgoing); then \
+ failcom='fail=yes'; \
+ else \
+ failcom='exit 1'; \
+ fi; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ for subdir in $$list; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ dot_seen=yes; \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done; \
+ if test "$$dot_seen" = "no"; then \
+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+ fi; test -z "$$fail"
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-recursive
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+ include_option=--etags-include; \
+ empty_fix=.; \
+ else \
+ include_option=--include; \
+ empty_fix=; \
+ fi; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test ! -f $$subdir/TAGS || \
+ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+ fi; \
+ done; \
+ $(am__define_uniq_tagged_files); \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: ctags-recursive
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-recursive
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ $(am__make_dryrun) \
+ || test -d "$(distdir)/$$subdir" \
+ || $(MKDIR_P) "$(distdir)/$$subdir" \
+ || exit 1; \
+ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+ $(am__relativize); \
+ new_distdir=$$reldir; \
+ dir1=$$subdir; dir2="$(top_distdir)"; \
+ $(am__relativize); \
+ new_top_distdir=$$reldir; \
+ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir"
distdir="$$new_distdir" \\"; \
+ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+ ($(am__cd) $$subdir && \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$$new_top_distdir" \
+ distdir="$$new_distdir" \
+ am__remove_distdir=: \
+ am__skip_length_check=: \
+ am__skip_mode_fix=: \
+ distdir) \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) check-local
+check: check-recursive
+all-am: Makefile $(PROGRAMS)
+installdirs: installdirs-recursive
+installdirs-am:
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
+ mostlyclean-am
+
+distclean: distclean-recursive
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(am__recursive_targets) check-am install-am install-strip
+
+.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \
+ check-am check-local clean clean-generic clean-libtool \
+ clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ installdirs-am maintainer-clean maintainer-clean-generic \
+ mostlyclean mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
+ uninstall-am
+
+.PRECIOUS: Makefile
+
+
+### testing rules
+
+# test: run all tests in cwd and subdirs
+test: test-nonrecursive
+ @for subdir in $(SUBDIRS) . ; do \
+ test "$$subdir" = "." -o "$$subdir" = "po" || \
+ ( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@ ) || exit $? ; \
+ done
+
+# test-nonrecursive: run tests only in cwd
+test-nonrecursive: ${TEST_PROGS}
+ @test -z "${TEST_PROGS}" || G_DEBUG=gc-friendly MALLOC_CHECK_=2 MALLOC_PERTURB_=$$(($${RANDOM:-256} %
256)) ${GTESTER} --verbose ${TEST_PROGS}
+
+# test-report: run tests in subdirs and generate report
+# perf-report: run tests in subdirs with -m perf and generate report
+# full-report: like test-report: with -m perf and -m slow
+test-report perf-report full-report: ${TEST_PROGS}
+ @test -z "${TEST_PROGS}" || { \
+ case $@ in \
+ test-report) test_options="-k";; \
+ perf-report) test_options="-k -m=perf";; \
+ full-report) test_options="-k -m=perf -m=slow";; \
+ esac ; \
+ if test -z "$$GTESTER_LOGDIR" ; then \
+ ${GTESTER} --verbose $$test_options -o test-report.xml ${TEST_PROGS} ; \
+ elif test -n "${TEST_PROGS}" ; then \
+ ${GTESTER} --verbose $$test_options -o `mktemp "$$GTESTER_LOGDIR/log-XXXXXX"` ${TEST_PROGS} ; \
+ fi ; \
+ }
+ @ ignore_logdir=true ; \
+ if test -z "$$GTESTER_LOGDIR" ; then \
+ GTESTER_LOGDIR=`mktemp -d "\`pwd\`/.testlogs-XXXXXX"`; export GTESTER_LOGDIR ; \
+ ignore_logdir=false ; \
+ fi ; \
+ if test -d "$(top_srcdir)/.git" ; then \
+ REVISION=`git describe` ; \
+ else \
+ REVISION=$(VERSION) ; \
+ fi ; \
+ for subdir in $(SUBDIRS) . ; do \
+ test "$$subdir" = "." -o "$$subdir" = "po" || \
+ ( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@ ) || exit $? ; \
+ done ; \
+ $$ignore_logdir || { \
+ echo '<?xml version="1.0"?>' > $ xml ; \
+ echo '<report-collection>' >> $ xml ; \
+ echo '<info>' >> $ xml ; \
+ echo ' <package>$(PACKAGE)</package>' >> $ xml ; \
+ echo ' <version>$(VERSION)</version>' >> $ xml ; \
+ echo " <revision>$$REVISION</revision>" >> $ xml ; \
+ echo '</info>' >> $ xml ; \
+ for lf in `ls -L "$$GTESTER_LOGDIR"/.` ; do \
+ sed '1,1s/^<?xml\b[^>?]*?>//' <"$$GTESTER_LOGDIR"/"$$lf" >> $ xml ; \
+ done ; \
+ echo >> $ xml ; \
+ echo '</report-collection>' >> $ xml ; \
+ rm -rf "$$GTESTER_LOGDIR"/ ; \
+ ${GTESTER_REPORT} --version 2>/dev/null 1>&2 ; test "$$?" != 0 || ${GTESTER_REPORT} $ xml >$
html ; \
+ }
+.PHONY: test test-report perf-report full-report test-nonrecursive
+
+# run tests in cwd as part of make check
+check-local: test-nonrecursive
+
+-include $(top_srcdir)/git.mk
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/tests/data/Makefile b/tests/data/Makefile
new file mode 100644
index 0000000..765fc35
--- /dev/null
+++ b/tests/data/Makefile
@@ -0,0 +1,509 @@
+# Makefile.in generated by automake 1.15 from Makefile.am.
+# tests/data/Makefile. Generated from Makefile.in by configure.
+
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/epiphany
+pkgincludedir = $(includedir)/epiphany
+pkglibdir = $(libdir)/epiphany
+pkglibexecdir = $(libexecdir)/epiphany
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = x86_64-unknown-linux-gnu
+host_triplet = x86_64-unknown-linux-gnu
+subdir = tests/data
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/libgd/libgd.m4 \
+ $(top_srcdir)/m4/appstream-xml.m4 \
+ $(top_srcdir)/m4/ax_append_compile_flags.m4 \
+ $(top_srcdir)/m4/ax_append_flag.m4 \
+ $(top_srcdir)/m4/ax_append_link_flags.m4 \
+ $(top_srcdir)/m4/ax_check_compile_flag.m4 \
+ $(top_srcdir)/m4/ax_check_enable_debug.m4 \
+ $(top_srcdir)/m4/ax_check_link_flag.m4 \
+ $(top_srcdir)/m4/ax_code_coverage.m4 \
+ $(top_srcdir)/m4/ax_compiler_flags.m4 \
+ $(top_srcdir)/m4/ax_compiler_flags_cflags.m4 \
+ $(top_srcdir)/m4/ax_compiler_flags_gir.m4 \
+ $(top_srcdir)/m4/ax_compiler_flags_ldflags.m4 \
+ $(top_srcdir)/m4/ax_is_release.m4 \
+ $(top_srcdir)/m4/ax_require_defined.m4 \
+ $(top_srcdir)/m4/gsettings.m4 $(top_srcdir)/m4/intltool.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/yelp.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_P = $(am__v_P_$(V))
+am__v_P_ = $(am__v_P_$(AM_DEFAULT_VERBOSITY))
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+am__v_at_1 =
+SOURCES =
+DIST_SOURCES =
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = ${SHELL} /home/mcatanzaro/src/jhbuild/checkout/epiphany/build-aux/missing aclocal-1.15
+ALL_LINGUAS =
+AMTAR = $${TAR-tar}
+AM_DEFAULT_VERBOSITY = 0
+APPSTREAM_UTIL = /usr/bin/appstream-util
+AR = ar
+AUTOCONF = ${SHELL} /home/mcatanzaro/src/jhbuild/checkout/epiphany/build-aux/missing autoconf
+AUTOHEADER = ${SHELL} /home/mcatanzaro/src/jhbuild/checkout/epiphany/build-aux/missing autoheader
+AUTOMAKE = ${SHELL} /home/mcatanzaro/src/jhbuild/checkout/epiphany/build-aux/missing automake-1.15
+AWK = gawk
+CC = gcc
+CCDEPMODE = depmode=gcc3
+CFLAGS = -ggdb3 -Og -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -O0
+CODE_COVERAGE_CFLAGS =
+CODE_COVERAGE_ENABLED = no
+CODE_COVERAGE_LDFLAGS =
+CPP = gcc -E
+CPPFLAGS =
+CYGPATH_W = echo
+DEFS = -DHAVE_CONFIG_H
+DEPDIR = .deps
+DEPENDENCIES_CFLAGS = -pthread -D_REENTRANT
-I/home/mcatanzaro/src/jhbuild/install/include/gtk-3.0/unix-print
-I/home/mcatanzaro/src/jhbuild/install/include/libwnck-3.0
-I/home/mcatanzaro/src/jhbuild/install/include/webkitgtk-4.0
-I/home/mcatanzaro/src/jhbuild/install/include/libsoup-2.4
-I/home/mcatanzaro/src/jhbuild/install/include/libsecret-1
-I/home/mcatanzaro/src/jhbuild/install/include/gnome-desktop-3.0
-I/home/mcatanzaro/src/jhbuild/install/include/gcr-3 -I/home/mcatanzaro/src/jhbuild/install/include/gtk-3.0
-I/home/mcatanzaro/src/jhbuild/install/include/at-spi2-atk/2.0
-I/home/mcatanzaro/src/jhbuild/install/include/at-spi-2.0
-I/home/mcatanzaro/src/jhbuild/install/include/gtk-3.0
-I/home/mcatanzaro/src/jhbuild/install/include/gio-unix-2.0/
-I/home/mcatanzaro/src/jhbuild/install/include/pango-1.0
-I/home/mcatanzaro/src/jhbuild/install/include/harfbuzz
-I/home/mcatanzaro/src/jhbuild/install/include/pango-1.0
-I/home/mcatanzaro/src/jhbuild/install/include/atk-1.0 -I/hom
e/mcatanzaro/src/jhbuild/install/include/gdk-pixbuf-2.0 -I/home/mcatanzaro/src/jhbuild/install/include/gcr-3
-I/home/mcatanzaro/src/jhbuild/install/include/gck-1 -I/home/mcatanzaro/src/jhbuild/install/include/glib-2.0
-I/home/mcatanzaro/src/jhbuild/install/lib/glib-2.0/include
-I/home/mcatanzaro/src/jhbuild/install/include/gsettings-desktop-schemas
-I/usr/include/startup-notification-1.0 -I/usr/include/libxml2 -I/usr/include/dbus-1.0
-I/usr/lib64/dbus-1.0/include -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2
-I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libdrm -I/usr/include/libpng16
-I/usr/include/p11-kit-1
+DEPENDENCIES_LIBS = -L/home/mcatanzaro/src/jhbuild/install/lib -lgthread-2.0 -pthread -lgio-2.0 -lX11
-lwnck-3 -lxslt -lxml2 -lz -lm -ldl -lm -lxml2 -lwebkit2gtk-4.0 -ljavascriptcoregtk-4.0 -lsoup-2.4 -lsecret-1
-lgnome-desktop-3 -lnotify -lsqlite3 -lgcr-ui-3 -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0
-lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgcr-base-3 -lgck-1 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lp11-kit
-lavahi-gobject -lavahi-common -lavahi-client
+DLLTOOL = false
+DSYMUTIL =
+DUMPBIN =
+ECHO_C =
+ECHO_N = -n
+ECHO_T =
+EGREP = /usr/bin/grep -E
+EPIPHANY_MAJOR = 3.20
+EXEEXT =
+FGREP = /usr/bin/grep -F
+GCOV =
+GENHTML =
+GETTEXT_PACKAGE = epiphany
+GLIB_COMPILE_SCHEMAS = glib-compile-schemas
+GLIB_MKENUMS = /home/mcatanzaro/src/jhbuild/install/bin/glib-mkenums
+GMSGFMT = /usr/bin/msgfmt
+GREP = /usr/bin/grep
+GSETTINGS_DISABLE_SCHEMAS_COMPILE =
+HELP_DIR = ${datadir}/help
+INSTALL = /usr/bin/install -c
+INSTALL_DATA = ${INSTALL} -m 644
+INSTALL_PROGRAM = ${INSTALL}
+INSTALL_SCRIPT = ${INSTALL}
+INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
+INTLTOOL_EXTRACT = /usr/bin/intltool-extract
+INTLTOOL_MERGE = /usr/bin/intltool-merge
+INTLTOOL_PERL = /usr/bin/perl
+INTLTOOL_UPDATE = /usr/bin/intltool-update
+INTLTOOL_V_MERGE = $(INTLTOOL__v_MERGE_$(V))
+INTLTOOL_V_MERGE_OPTIONS = $(intltool__v_merge_options_$(V))
+INTLTOOL__v_MERGE_ = $(INTLTOOL__v_MERGE_$(AM_DEFAULT_VERBOSITY))
+INTLTOOL__v_MERGE_0 = @echo " ITMRG " $@;
+ITSTOOL = itstool
+LCOV =
+LD = /usr/bin/ld -m elf_x86_64
+LDFLAGS = -L/home/mcatanzaro/src/jhbuild/install/lib
+LIBGD_CFLAGS = -pthread -I/home/mcatanzaro/src/jhbuild/install/include/gtk-3.0
-I/home/mcatanzaro/src/jhbuild/install/include/at-spi2-atk/2.0
-I/home/mcatanzaro/src/jhbuild/install/include/at-spi-2.0
-I/home/mcatanzaro/src/jhbuild/install/include/gtk-3.0
-I/home/mcatanzaro/src/jhbuild/install/include/gio-unix-2.0/
-I/home/mcatanzaro/src/jhbuild/install/include/pango-1.0
-I/home/mcatanzaro/src/jhbuild/install/include/harfbuzz
-I/home/mcatanzaro/src/jhbuild/install/include/pango-1.0
-I/home/mcatanzaro/src/jhbuild/install/include/atk-1.0
-I/home/mcatanzaro/src/jhbuild/install/include/gdk-pixbuf-2.0
-I/home/mcatanzaro/src/jhbuild/install/include/glib-2.0
-I/home/mcatanzaro/src/jhbuild/install/lib/glib-2.0/include -I/usr/include/dbus-1.0
-I/usr/lib64/dbus-1.0/include -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2
-I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libdrm -I/usr/include/libpng16
+LIBGD_GIR_INCLUDES = Gtk-3.0
+LIBGD_LIBS = -L/home/mcatanzaro/src/jhbuild/install/lib -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0
-latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0
+LIBGD_MODULE_DIR = libgd
+LIBGD_SOURCES =
+LIBM = -lm
+LIBOBJS =
+LIBS =
+LIBTOOL = $(SHELL) $(top_builddir)/libtool
+LIPO =
+LN_S = ln -s
+LSB_RELEASE =
+LTLIBOBJS =
+LT_SYS_LIBRARY_PATH =
+MAINT =
+MAKEINFO = ${SHELL} /home/mcatanzaro/src/jhbuild/checkout/epiphany/build-aux/missing makeinfo
+MANIFEST_TOOL = :
+MKDIR_P = /usr/bin/mkdir -p
+MSGFMT = /usr/bin/msgfmt
+MSGMERGE = /usr/bin/msgmerge
+NM = /usr/bin/nm -B
+NMEDIT =
+NSS_CFLAGS = -I/usr/include/nss3 -I/usr/include/nspr4
+NSS_LIBS = -lssl3 -lsmime3 -lnss3 -lnssutil3 -lplds4 -lplc4 -lnspr4 -lpthread -ldl
+OBJDUMP = objdump
+OBJEXT = o
+OTOOL =
+OTOOL64 =
+PACKAGE = epiphany
+PACKAGE_BUGREPORT = http://bugzilla.gnome.org/enter_bug.cgi?product=epiphany
+PACKAGE_NAME = GNOME Web Browser
+PACKAGE_STRING = GNOME Web Browser 3.20.0
+PACKAGE_TARNAME = epiphany
+PACKAGE_URL =
+PACKAGE_VERSION = 3.20.0
+PATH_SEPARATOR = :
+PKG_CONFIG = /usr/bin/pkg-config
+PKG_CONFIG_LIBDIR =
+PKG_CONFIG_PATH =
/home/mcatanzaro/src/jhbuild/install/lib/pkgconfig:/home/mcatanzaro/src/jhbuild/install/share/pkgconfig:/usr/lib64/pkgconfig:/usr/share/pkgconfig
+RANLIB = ranlib
+SED = /usr/bin/sed
+SET_MAKE =
+SHELL = /bin/sh
+STRIP = strip
+USE_NLS = yes
+VERSION = 3.20.0
+WARN_CFLAGS = -fno-strict-aliasing -Wall -Wextra -Wundef -Wnested-externs -Wwrite-strings -Wpointer-arith
-Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wno-unused-parameter
-Wno-missing-field-initializers -Wdeclaration-after-statement -Wformat=2 -Wold-style-definition -Wcast-align
-Wformat-nonliteral -Wformat-security -Wsign-compare -Wstrict-aliasing -Wshadow -Winline -Wpacked
-Wmissing-format-attribute -Wmissing-noreturn -Winit-self -Wmissing-include-dirs -Wunused-but-set-variable
-Warray-bounds -Wimplicit-function-declaration -Wreturn-type -Wswitch-enum -Wswitch-default
-Wno-deprecated-declarations -Werror -Wno-suggest-attribute=format -Wno-error=unused-parameter
-Wno-error=missing-field-initializers -Wno-error=deprecated-declarations
+WARN_LDFLAGS = -Wl,--no-as-needed -Wl,--fatal-warnings
+WARN_SCANNERFLAGS = --warn-all
--warn-error
+WEB_EXTENSION_CFLAGS = -pthread -I/home/mcatanzaro/src/jhbuild/install/include/webkitgtk-4.0
-I/home/mcatanzaro/src/jhbuild/install/include/gtk-3.0
-I/home/mcatanzaro/src/jhbuild/install/include/at-spi2-atk/2.0
-I/home/mcatanzaro/src/jhbuild/install/include/at-spi-2.0
-I/home/mcatanzaro/src/jhbuild/install/include/gtk-3.0
-I/home/mcatanzaro/src/jhbuild/install/include/gio-unix-2.0/
-I/home/mcatanzaro/src/jhbuild/install/include/pango-1.0
-I/home/mcatanzaro/src/jhbuild/install/include/harfbuzz
-I/home/mcatanzaro/src/jhbuild/install/include/pango-1.0
-I/home/mcatanzaro/src/jhbuild/install/include/atk-1.0
-I/home/mcatanzaro/src/jhbuild/install/include/gdk-pixbuf-2.0
-I/home/mcatanzaro/src/jhbuild/install/include/libsoup-2.4
-I/home/mcatanzaro/src/jhbuild/install/include/webkitgtk-4.0
-I/home/mcatanzaro/src/jhbuild/install/include/libsecret-1
-I/home/mcatanzaro/src/jhbuild/install/include/glib-2.0
-I/home/mcatanzaro/src/jhbuild/install/lib/glib-2.0/include -I/usr/include/dbus-1.
0 -I/usr/lib64/dbus-1.0/include -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2
-I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libdrm -I/usr/include/libpng16
-I/usr/include/libxml2
+WEB_EXTENSION_LIBS = -L/home/mcatanzaro/src/jhbuild/install/lib -lwebkit2gtk-4.0 -lgtk-3 -lgdk-3
-lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lsoup-2.4
-ljavascriptcoregtk-4.0 -lsecret-1 -lgio-2.0 -lgobject-2.0 -lglib-2.0
+XGETTEXT = /usr/bin/xgettext
+XMLLINT = xmllint
+YELP_LC_DIST = true
+YELP_LC_MEDIA_LINKS = true
+abs_builddir = /home/mcatanzaro/src/jhbuild/checkout/epiphany/tests/data
+abs_srcdir = /home/mcatanzaro/src/jhbuild/checkout/epiphany/tests/data
+abs_top_builddir = /home/mcatanzaro/src/jhbuild/checkout/epiphany
+abs_top_srcdir = /home/mcatanzaro/src/jhbuild/checkout/epiphany
+ac_ct_AR = ar
+ac_ct_CC = gcc
+ac_ct_DUMPBIN =
+am__include = include
+am__leading_dot = .
+am__quote =
+am__tar = tar --format=ustar -chf - "$$tardir"
+am__untar = tar -xf -
+appstreamxmldir = ${datarootdir}/appdata
+bindir = ${exec_prefix}/bin
+build = x86_64-unknown-linux-gnu
+build_alias =
+build_cpu = x86_64
+build_os = linux-gnu
+build_vendor = unknown
+builddir = .
+datadir = ${datarootdir}
+datarootdir = ${prefix}/share
+docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
+dvidir = ${docdir}
+exec_prefix = ${prefix}
+gsettingsschemadir = ${datarootdir}/glib-2.0/schemas
+host = x86_64-unknown-linux-gnu
+host_alias =
+host_cpu = x86_64
+host_os = linux-gnu
+host_vendor = unknown
+htmldir = ${docdir}
+includedir = ${prefix}/include
+infodir = ${datarootdir}/info
+install_sh = ${SHELL} /home/mcatanzaro/src/jhbuild/checkout/epiphany/build-aux/install-sh
+intltool__v_merge_options_ = $(intltool__v_merge_options_$(AM_DEFAULT_VERBOSITY))
+intltool__v_merge_options_0 = -q
+libdir = ${exec_prefix}/lib
+libexecdir = ${exec_prefix}/libexec
+localedir = ${datarootdir}/locale
+localstatedir = ${prefix}/var
+mandir = ${datarootdir}/man
+mkdir_p = $(MKDIR_P)
+oldincludedir = /usr/include
+pdfdir = ${docdir}
+prefix = /home/mcatanzaro/src/jhbuild/install
+program_transform_name = s,x,x,
+psdir = ${docdir}
+sbindir = ${exec_prefix}/sbin
+sharedstatedir = ${prefix}/com
+srcdir = .
+sysconfdir = ${prefix}/etc
+target_alias =
+top_build_prefix = ../../
+top_builddir = ../..
+top_srcdir = ../..
+EXTRA_DIST = user-dirs.dirs
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/data/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign tests/data/Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+tags TAGS:
+
+ctags CTAGS:
+
+cscope cscopelist:
+
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+ cscopelist-am ctags-am distclean distclean-generic \
+ distclean-libtool distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags-am uninstall uninstall-am
+
+.PRECIOUS: Makefile
+
+
+-include $(top_srcdir)/git.mk
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/tests/ephy-bookmarks-test.c b/tests/ephy-bookmarks-test.c
index ab76042..0c3353e 100644
--- a/tests/ephy-bookmarks-test.c
+++ b/tests/ephy-bookmarks-test.c
@@ -25,7 +25,7 @@
#include "ephy-profile-utils.h"
#include "ephy-shell.h"
-const char* bookmarks_paths[] = { EPHY_BOOKMARKS_FILE, EPHY_BOOKMARKS_FILE_RDF };
+const char *bookmarks_paths[] = { EPHY_BOOKMARKS_FILE, EPHY_BOOKMARKS_FILE_RDF };
static void
clear_bookmark_files (void)
@@ -35,7 +35,6 @@ clear_bookmark_files (void)
guint i;
for (i = 0; i < G_N_ELEMENTS (bookmarks_paths); i++) {
-
path = g_build_filename (ephy_dot_dir (),
bookmarks_paths[i],
NULL);
@@ -66,12 +65,12 @@ test_ephy_bookmarks_add (void)
bookmarks = ephy_bookmarks_new ();
g_assert (bookmarks);
-
+
node = ephy_bookmarks_add (bookmarks, "GNOME", "http://www.gnome.org");
g_assert (node);
result = ephy_bookmarks_find_bookmark (bookmarks, "http://www.gnome.org");
g_assert (node == result);
-
+
g_object_unref (bookmarks);
clear_bookmark_files ();
diff --git a/tests/ephy-completion-model-test.c b/tests/ephy-completion-model-test.c
index cb0db48..f00653e 100644
--- a/tests/ephy-completion-model-test.c
+++ b/tests/ephy-completion-model-test.c
@@ -28,47 +28,47 @@
static void
test_ephy_completion_model_create (void)
{
- EphyCompletionModel *model;
- model = ephy_completion_model_new (EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service
(ephy_embed_shell_get_default ())),
- ephy_shell_get_bookmarks (ephy_shell_get_default ()));
- g_assert (model);
- g_object_unref (model);
+ EphyCompletionModel *model;
+ model = ephy_completion_model_new (EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service
(ephy_embed_shell_get_default ())),
+ ephy_shell_get_bookmarks (ephy_shell_get_default ()));
+ g_assert (model);
+ g_object_unref (model);
}
static void
update_empty_cb (EphyHistoryService *service,
- gboolean success,
- gpointer result_data,
- GMainLoop *loop)
+ gboolean success,
+ gpointer result_data,
+ GMainLoop *loop)
{
- GList *results = (GList*)result_data;
+ GList *results = (GList *)result_data;
- g_assert (success);
- g_assert (results == NULL);
+ g_assert (success);
+ g_assert (results == NULL);
- g_main_loop_quit (loop);
+ g_main_loop_quit (loop);
}
static void
test_ephy_completion_model_update_empty (void)
{
- EphyCompletionModel *model;
- GMainLoop *loop = NULL;
+ EphyCompletionModel *model;
+ GMainLoop *loop = NULL;
- model = ephy_completion_model_new (EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service
(ephy_embed_shell_get_default ())),
- ephy_shell_get_bookmarks (ephy_shell_get_default ()));
- g_assert (model);
+ model = ephy_completion_model_new (EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service
(ephy_embed_shell_get_default ())),
+ ephy_shell_get_bookmarks (ephy_shell_get_default ()));
+ g_assert (model);
- loop = g_main_loop_new (NULL, FALSE);
+ loop = g_main_loop_new (NULL, FALSE);
- ephy_completion_model_update_for_string (model, "hello",
- (EphyHistoryJobCallback)update_empty_cb,
- loop);
+ ephy_completion_model_update_for_string (model, "hello",
+ (EphyHistoryJobCallback)update_empty_cb,
+ loop);
- g_main_loop_run (loop);
+ g_main_loop_run (loop);
- g_object_unref (model);
- g_main_loop_unref (loop);
+ g_object_unref (model);
+ g_main_loop_unref (loop);
}
int
diff --git a/tests/ephy-download-test.c b/tests/ephy-download-test.c
index 4262245..74f1037 100644
--- a/tests/ephy-download-test.c
+++ b/tests/ephy-download-test.c
@@ -51,12 +51,12 @@ get_uri_for_path (const char *path)
}
static void
-server_callback (SoupServer *server,
- SoupMessage *msg,
- const char *path,
- GHashTable *query,
+server_callback (SoupServer *server,
+ SoupMessage *msg,
+ const char *path,
+ GHashTable *query,
SoupClientContext *context,
- gpointer data)
+ gpointer data)
{
soup_message_set_status (msg, SOUP_STATUS_OK);
@@ -124,7 +124,7 @@ test_file_was_downloaded (EphyDownload *download)
static void
completed_cb (EphyDownload *download,
- Fixture *fixture)
+ Fixture *fixture)
{
g_assert (test_file_was_downloaded (download));
g_main_loop_quit (fixture->loop);
@@ -142,7 +142,7 @@ test_ephy_download_new_for_uri (Fixture *fixture, gconstpointer data)
WebKitDownload *download = ephy_download_get_webkit_download (fixture->download);
WebKitURIRequest *request = webkit_download_get_request (download);
- g_assert(request);
+ g_assert (request);
g_assert_cmpstr (fixture->source, ==, webkit_uri_request_get_uri (request));
}
@@ -160,7 +160,7 @@ int
main (int argc, char *argv[])
{
int ret;
- GSList* uris;
+ GSList *uris;
SoupServer *server;
gtk_test_init (&argc, &argv);
@@ -182,7 +182,7 @@ main (int argc, char *argv[])
SOUP_SERVER_LISTEN_IPV4_ONLY,
NULL);
uris = soup_server_get_uris (server);
- base_uri = (SoupURI*)uris->data;
+ base_uri = (SoupURI *)uris->data;
g_slist_free (uris);
soup_server_add_handler (server, NULL, server_callback, NULL, NULL);
diff --git a/tests/ephy-embed-shell-test.c b/tests/ephy-embed-shell-test.c
index 1c607cc..19211b5 100644
--- a/tests/ephy-embed-shell-test.c
+++ b/tests/ephy-embed-shell-test.c
@@ -36,48 +36,48 @@
static void
test_ephy_embed_shell_launch_handler (void)
{
- EphyEmbedShell *embed_shell;
- gboolean ret;
- GFile *file;
+ EphyEmbedShell *embed_shell;
+ gboolean ret;
+ GFile *file;
- embed_shell = ephy_embed_shell_get_default ();
+ embed_shell = ephy_embed_shell_get_default ();
- ret = ephy_embed_shell_launch_handler (embed_shell, NULL, "text/html", 0);
- g_assert (ret == FALSE);
+ ret = ephy_embed_shell_launch_handler (embed_shell, NULL, "text/html", 0);
+ g_assert (ret == FALSE);
- file = g_file_new_for_path (TEST_DIR"/data/test.html");
- g_assert (file);
+ file = g_file_new_for_path (TEST_DIR "/data/test.html");
+ g_assert (file);
- ret = ephy_embed_shell_launch_handler (embed_shell, file, NULL, 0);
- g_assert (ret == FALSE);
+ ret = ephy_embed_shell_launch_handler (embed_shell, file, NULL, 0);
+ g_assert (ret == FALSE);
- ret = ephy_embed_shell_launch_handler (embed_shell, file, "text/html", 0);
- g_assert (ret == FALSE);
+ ret = ephy_embed_shell_launch_handler (embed_shell, file, "text/html", 0);
+ g_assert (ret == FALSE);
- g_object_unref (file);
+ g_object_unref (file);
}
static void
web_view_created_cb (EphyEmbedShell *shell, EphyWebView *view, gpointer user_data)
{
- gboolean *web_view_created = (gboolean*)user_data;
- *web_view_created = TRUE;
+ gboolean *web_view_created = (gboolean *)user_data;
+ *web_view_created = TRUE;
}
static void
test_ephy_embed_shell_web_view_created (void)
{
- EphyEmbedShell *embed_shell;
- GtkWidget *view;
- gboolean web_view_created = FALSE;
+ EphyEmbedShell *embed_shell;
+ GtkWidget *view;
+ gboolean web_view_created = FALSE;
- embed_shell = ephy_embed_shell_get_default ();
- g_signal_connect (embed_shell, "web-view-created",
- G_CALLBACK (web_view_created_cb), &web_view_created);
+ embed_shell = ephy_embed_shell_get_default ();
+ g_signal_connect (embed_shell, "web-view-created",
+ G_CALLBACK (web_view_created_cb), &web_view_created);
- view = ephy_web_view_new ();
- g_assert (web_view_created);
- gtk_widget_destroy (view);
+ view = ephy_web_view_new ();
+ g_assert (web_view_created);
+ gtk_widget_destroy (view);
}
int
diff --git a/tests/ephy-embed-utils-test.c b/tests/ephy-embed-utils-test.c
index 5d42032..572fb9d 100644
--- a/tests/ephy-embed-utils-test.c
+++ b/tests/ephy-embed-utils-test.c
@@ -138,7 +138,7 @@ main (int argc, char *argv[])
test.name, NULL);
g_test_add_data_func (test_name, test.test,
- (GTestDataFunc) test_address_has_web_scheme);
+ (GTestDataFunc)test_address_has_web_scheme);
g_free (test_name);
}
@@ -152,7 +152,7 @@ main (int argc, char *argv[])
test.name, NULL);
g_test_add_data_func (test_name, test.test,
- (GTestDataFunc) test_address_no_web_scheme);
+ (GTestDataFunc)test_address_no_web_scheme);
g_free (test_name);
}
diff --git a/tests/ephy-file-helpers-test.c b/tests/ephy-file-helpers-test.c
index 0ec310e..7368b59 100644
--- a/tests/ephy-file-helpers-test.c
+++ b/tests/ephy-file-helpers-test.c
@@ -190,7 +190,7 @@ test_ephy_file_create_delete_dir (void)
g_assert (ephy_file_delete_dir_recursively (test.dir, &error) == test.can_delete);
if (error)
- g_error_free (error);
+ g_error_free (error);
if (test.exists)
g_assert (g_file_test (test.dir, G_FILE_TEST_EXISTS) != test.can_delete);
diff --git a/tests/ephy-history-test.c b/tests/ephy-history-test.c
index 9b07779..ade796c 100644
--- a/tests/ephy-history-test.c
+++ b/tests/ephy-history-test.c
@@ -27,7 +27,7 @@
#include <gtk/gtk.h>
static EphyHistoryService *
-ensure_empty_history (const char* filename, gboolean readonly)
+ensure_empty_history (const char *filename, gboolean readonly)
{
if (g_file_test (filename, G_FILE_TEST_IS_REGULAR))
g_unlink (filename);
@@ -71,7 +71,7 @@ test_create_history_service_and_destroy_later (void)
gchar *temporary_file = g_build_filename (g_get_tmp_dir (), "epiphany-history-test.db", NULL);
EphyHistoryService *service = ensure_empty_history (temporary_file, FALSE);
g_free (temporary_file);
- g_timeout_add (100, (GSourceFunc) destroy_history_service_and_end_main_loop, service);
+ g_timeout_add (100, (GSourceFunc)destroy_history_service_and_end_main_loop, service);
gtk_main ();
}
@@ -117,7 +117,7 @@ create_test_page_visit_list (void)
static void
verify_create_history_entry_cb (EphyHistoryService *service, gboolean success, gpointer result_data,
gpointer user_data)
{
- GList *visits = (GList *) result_data;
+ GList *visits = (GList *)result_data;
GList *baseline_visits = create_test_page_visit_list ();
GList *current = visits;
GList *current_baseline = baseline_visits;
@@ -131,8 +131,8 @@ verify_create_history_entry_cb (EphyHistoryService *service, gboolean success, g
EphyHistoryPageVisit *visit, *baseline_visit;
g_assert (current);
- visit = (EphyHistoryPageVisit *) current->data;
- baseline_visit = (EphyHistoryPageVisit *) current_baseline->data;
+ visit = (EphyHistoryPageVisit *)current->data;
+ baseline_visit = (EphyHistoryPageVisit *)current_baseline->data;
g_assert_cmpstr (visit->url->url, ==, baseline_visit->url->url);
g_assert_cmpstr (visit->url->title, ==, baseline_visit->url->title);
@@ -154,7 +154,7 @@ static void
verify_create_history_entry (EphyHistoryService *service, gboolean success, gpointer result_data, gpointer
user_data)
{
g_assert (result_data == NULL);
- g_assert_cmpint (42, ==, GPOINTER_TO_INT(user_data));
+ g_assert_cmpint (42, ==, GPOINTER_TO_INT (user_data));
g_assert (success);
ephy_history_service_find_visits_in_time (service, 0, 8, NULL, verify_create_history_entry_cb, NULL);
}
@@ -168,7 +168,7 @@ test_create_history_entries (void)
GList *visits = create_test_page_visit_list ();
/* We use 42 here just to verify that user_data is passed properly to the callback */
- ephy_history_service_add_visits (service, visits, NULL, verify_create_history_entry, GINT_TO_POINTER(42));
+ ephy_history_service_add_visits (service, visits, NULL, verify_create_history_entry, GINT_TO_POINTER (42));
ephy_history_page_visit_list_free (visits);
g_free (temporary_file);
@@ -178,7 +178,7 @@ test_create_history_entries (void)
static void
get_url (EphyHistoryService *service, gboolean success, gpointer result_data, gpointer user_data)
{
- EphyHistoryURL *url = (EphyHistoryURL *) result_data;
+ EphyHistoryURL *url = (EphyHistoryURL *)result_data;
g_assert (success == TRUE);
g_assert (url != NULL);
@@ -186,7 +186,7 @@ get_url (EphyHistoryService *service, gboolean success, gpointer result_data, gp
ephy_history_url_free (url);
g_object_unref (service);
- gtk_main_quit();
+ gtk_main_quit ();
}
static void
@@ -251,7 +251,7 @@ test_set_url_title_url_not_existent (void)
ephy_history_service_set_url_title (service, "http://www.gnome.org", "GNOME", NULL,
set_url_title_url_not_existent, NULL);
- gtk_main();
+ gtk_main ();
}
static void
@@ -298,7 +298,7 @@ test_get_url_helper (gboolean add_entry)
} else
ephy_history_service_get_url (service, "http://www.gnome.org", NULL, test_get_url_done, GINT_TO_POINTER
(add_entry));
- gtk_main();
+ gtk_main ();
}
static void
@@ -335,32 +335,32 @@ create_visits_for_complex_tests (void)
static void
verify_complex_url_query (EphyHistoryService *service,
- gboolean success,
- gpointer result_data,
- gpointer user_data)
+ gboolean success,
+ gpointer result_data,
+ gpointer user_data)
{
EphyHistoryURL *url, *baseline;
- GList *urls = (GList*) result_data;
+ GList *urls = (GList *)result_data;
/* Only one result expected. */
g_assert_cmpint (g_list_length (urls), ==, 1);
- url = (EphyHistoryURL *) urls->data;
- baseline = (EphyHistoryURL *) user_data;
+ url = (EphyHistoryURL *)urls->data;
+ baseline = (EphyHistoryURL *)user_data;
g_assert_cmpstr (url->url, ==, baseline->url);
g_assert_cmpuint (url->visit_count, ==, baseline->visit_count);
g_object_unref (service);
- gtk_main_quit();
+ gtk_main_quit ();
}
static void
perform_complex_url_query (EphyHistoryService *service,
- gboolean success,
- gpointer result_data,
- gpointer user_data)
+ gboolean success,
+ gpointer result_data,
+ gpointer user_data)
{
EphyHistoryQuery *query;
EphyHistoryURL *url;
@@ -397,9 +397,9 @@ test_complex_url_query (void)
static void
perform_complex_url_query_with_time_range (EphyHistoryService *service,
- gboolean success,
- gpointer result_data,
- gpointer user_data)
+ gboolean success,
+ gpointer result_data,
+ gpointer user_data)
{
EphyHistoryQuery *query;
EphyHistoryURL *url;
@@ -437,25 +437,25 @@ test_complex_url_query_with_time_range (void)
static void
verify_query_after_clear (EphyHistoryService *service,
- gboolean success,
- gpointer result_data,
- gpointer user_data)
+ gboolean success,
+ gpointer result_data,
+ gpointer user_data)
{
- GList *urls = (GList*)result_data;
+ GList *urls = (GList *)result_data;
/* No results expected. */
g_assert_cmpint (g_list_length (urls), ==, 0);
g_object_unref (service);
- gtk_main_quit();
+ gtk_main_quit ();
}
static void
perform_query_after_clear (EphyHistoryService *service,
- gboolean success,
- gpointer result_data,
- gpointer user_data)
+ gboolean success,
+ gpointer result_data,
+ gpointer user_data)
{
EphyHistoryQuery *query;
diff --git a/tests/ephy-migration-test.c b/tests/ephy-migration-test.c
index 375f533..91c24cc 100644
--- a/tests/ephy-migration-test.c
+++ b/tests/ephy-migration-test.c
@@ -32,19 +32,19 @@
static void
test_do_migration_simple (void)
{
- gboolean ret;
+ gboolean ret;
- ret = ephy_profile_utils_do_migration (NULL, -1, TRUE);
- g_assert (ret);
+ ret = ephy_profile_utils_do_migration (NULL, -1, TRUE);
+ g_assert (ret);
}
static void
test_do_migration_invalid (void)
{
- gboolean ret;
+ gboolean ret;
- ret = ephy_profile_utils_do_migration (NULL, EPHY_PROFILE_MIGRATION_VERSION + 1, TRUE);
- g_assert (ret == FALSE);
+ ret = ephy_profile_utils_do_migration (NULL, EPHY_PROFILE_MIGRATION_VERSION + 1, TRUE);
+ g_assert (ret == FALSE);
}
int
diff --git a/tests/ephy-session-test.c b/tests/ephy-session-test.c
index 5c02cd7..b0c15f6 100644
--- a/tests/ephy-session-test.c
+++ b/tests/ephy-session-test.c
@@ -35,20 +35,20 @@
#include <gtk/gtk.h>
#include <string.h>
-const char *session_data =
-"<?xml version=\"1.0\"?>"
-"<session>"
- "<window x=\"94\" y=\"48\" width=\"1132\" height=\"684\" active-tab=\"0\"
role=\"epiphany-window-67c6e8a5\">"
- "<embed url=\"about:memory\" title=\"Memory usage\"/>"
- "</window>"
-"</session>";
+const char *session_data =
+ "<?xml version=\"1.0\"?>"
+ "<session>"
+ "<window x=\"94\" y=\"48\" width=\"1132\" height=\"684\" active-tab=\"0\"
role=\"epiphany-window-67c6e8a5\">"
+ "<embed url=\"about:memory\" title=\"Memory usage\"/>"
+ "</window>"
+ "</session>";
static gboolean load_stream_retval;
static void
-load_from_stream_cb (GObject *object,
+load_from_stream_cb (GObject *object,
GAsyncResult *result,
- gpointer user_data)
+ gpointer user_data)
{
GMainLoop *loop = (GMainLoop *)user_data;
@@ -58,7 +58,7 @@ load_from_stream_cb (GObject *object,
static gboolean
load_session_from_string (EphySession *session,
- const char *data)
+ const char *data)
{
GMainLoop *loop;
GInputStream *stream;
@@ -91,50 +91,50 @@ disable_delayed_loading (void)
static void
test_ephy_session_load (void)
{
- EphySession *session;
- gboolean ret;
- GList *l;
- EphyEmbed *embed;
- EphyWebView *view;
- GMainLoop *loop;
+ EphySession *session;
+ gboolean ret;
+ GList *l;
+ EphyEmbed *embed;
+ EphyWebView *view;
+ GMainLoop *loop;
- disable_delayed_loading ();
+ disable_delayed_loading ();
- session = ephy_shell_get_session (ephy_shell_get_default ());
- g_assert (session);
+ session = ephy_shell_get_session (ephy_shell_get_default ());
+ g_assert (session);
- loop = ephy_test_utils_setup_ensure_web_views_are_loaded ();
+ loop = ephy_test_utils_setup_ensure_web_views_are_loaded ();
- ret = load_session_from_string (session, session_data);
- g_assert (ret);
+ ret = load_session_from_string (session, session_data);
+ g_assert (ret);
- ephy_test_utils_ensure_web_views_are_loaded (loop);
+ ephy_test_utils_ensure_web_views_are_loaded (loop);
- l = gtk_application_get_windows (GTK_APPLICATION (ephy_shell_get_default ()));
- g_assert (l);
- g_assert_cmpint (g_list_length (l), ==, 1);
+ l = gtk_application_get_windows (GTK_APPLICATION (ephy_shell_get_default ()));
+ g_assert (l);
+ g_assert_cmpint (g_list_length (l), ==, 1);
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (l->data));
- g_assert (embed);
- view = ephy_embed_get_web_view (embed);
- g_assert (view);
- ephy_test_utils_check_ephy_web_view_address (view, "ephy-about:memory");
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (l->data));
+ g_assert (embed);
+ view = ephy_embed_get_web_view (embed);
+ g_assert (view);
+ ephy_test_utils_check_ephy_web_view_address (view, "ephy-about:memory");
- ephy_session_clear (session);
+ ephy_session_clear (session);
- enable_delayed_loading ();
+ enable_delayed_loading ();
}
const char *session_data_many_windows =
-"<?xml version=\"1.0\"?>"
-"<session>"
- "<window x=\"100\" y=\"26\" width=\"1067\" height=\"740\" active-tab=\"0\"
role=\"epiphany-window-7da420dd\">"
- "<embed url=\"about:epiphany\" title=\"Epiphany\"/>"
- "</window>"
- "<window x=\"73\" y=\"26\" width=\"1067\" height=\"740\" active-tab=\"0\"
role=\"epiphany-window-1261c786\">"
- "<embed url=\"about:config\" title=\"Epiphany\"/>"
- "</window>"
-"</session>";
+ "<?xml version=\"1.0\"?>"
+ "<session>"
+ "<window x=\"100\" y=\"26\" width=\"1067\" height=\"740\" active-tab=\"0\"
role=\"epiphany-window-7da420dd\">"
+ "<embed url=\"about:epiphany\" title=\"Epiphany\"/>"
+ "</window>"
+ "<window x=\"73\" y=\"26\" width=\"1067\" height=\"740\" active-tab=\"0\"
role=\"epiphany-window-1261c786\">"
+ "<embed url=\"about:config\" title=\"Epiphany\"/>"
+ "</window>"
+ "</session>";
static void
test_ephy_session_clear (void)
@@ -162,178 +162,178 @@ test_ephy_session_clear (void)
g_assert (ephy_session_get_can_undo_tab_closed (session) == FALSE);
}
-const char *session_data_empty =
-"";
+const char *session_data_empty =
+ "";
#if 0
static void
test_ephy_session_load_empty_session (void)
{
- EphySession *session;
- gboolean ret;
- GList *l;
- EphyEmbed *embed;
- EphyWebView *view;
- GMainLoop *loop;
+ EphySession *session;
+ gboolean ret;
+ GList *l;
+ EphyEmbed *embed;
+ EphyWebView *view;
+ GMainLoop *loop;
- disable_delayed_loading ();
+ disable_delayed_loading ();
- session = ephy_shell_get_session (ephy_shell_get_default ());
- g_assert (session);
+ session = ephy_shell_get_session (ephy_shell_get_default ());
+ g_assert (session);
- loop = ephy_test_utils_setup_ensure_web_views_are_loaded ();
+ loop = ephy_test_utils_setup_ensure_web_views_are_loaded ();
- ret = load_session_from_string (session, session_data_empty);
- g_assert (ret == FALSE);
+ ret = load_session_from_string (session, session_data_empty);
+ g_assert (ret == FALSE);
- /* Loading the session should have failed, but we should still get
- * the default empty window. Got to spin the mainloop though,
- * since the fallback is done by queueing another session
- * command. */
- ephy_test_utils_ensure_web_views_are_loaded (loop);
+ /* Loading the session should have failed, but we should still get
+ * the default empty window. Got to spin the mainloop though,
+ * since the fallback is done by queueing another session
+ * command. */
+ ephy_test_utils_ensure_web_views_are_loaded (loop);
- l = gtk_application_get_windows (GTK_APPLICATION (ephy_shell_get_default ()));
- g_assert (l);
- g_assert_cmpint (g_list_length (l), ==, 1);
+ l = gtk_application_get_windows (GTK_APPLICATION (ephy_shell_get_default ()));
+ g_assert (l);
+ g_assert_cmpint (g_list_length (l), ==, 1);
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (l->data));
- g_assert (embed);
- view = ephy_embed_get_web_view (embed);
- g_assert (view);
- ephy_test_utils_check_ephy_web_view_address (view, "ephy-about:overview");
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (l->data));
+ g_assert (embed);
+ view = ephy_embed_get_web_view (embed);
+ g_assert (view);
+ ephy_test_utils_check_ephy_web_view_address (view, "ephy-about:overview");
- enable_delayed_loading ();
- ephy_session_clear (session);
+ enable_delayed_loading ();
+ ephy_session_clear (session);
}
#endif
static void
test_ephy_session_load_many_windows (void)
{
- EphySession *session;
- gboolean ret;
- GList *l, *p;
- EphyEmbed *embed;
- EphyWebView *view;
- GMainLoop *loop;
+ EphySession *session;
+ gboolean ret;
+ GList *l, *p;
+ EphyEmbed *embed;
+ EphyWebView *view;
+ GMainLoop *loop;
- disable_delayed_loading ();
+ disable_delayed_loading ();
- session = ephy_shell_get_session (ephy_shell_get_default ());
- g_assert (session);
+ session = ephy_shell_get_session (ephy_shell_get_default ());
+ g_assert (session);
- loop = ephy_test_utils_setup_ensure_web_views_are_loaded ();
+ loop = ephy_test_utils_setup_ensure_web_views_are_loaded ();
- ret = load_session_from_string (session, session_data_many_windows);
- g_assert (ret);
- g_assert_cmpint (ephy_test_utils_get_web_view_ready_counter (), >=, 0);
- g_assert_cmpint (ephy_test_utils_get_web_view_ready_counter (), <=, 2);
+ ret = load_session_from_string (session, session_data_many_windows);
+ g_assert (ret);
+ g_assert_cmpint (ephy_test_utils_get_web_view_ready_counter (), >=, 0);
+ g_assert_cmpint (ephy_test_utils_get_web_view_ready_counter (), <=, 2);
- ephy_test_utils_ensure_web_views_are_loaded (loop);
+ ephy_test_utils_ensure_web_views_are_loaded (loop);
- l = gtk_application_get_windows (GTK_APPLICATION (ephy_shell_get_default ()));
- g_assert (l);
- g_assert_cmpint (g_list_length (l), ==, 2);
+ l = gtk_application_get_windows (GTK_APPLICATION (ephy_shell_get_default ()));
+ g_assert (l);
+ g_assert_cmpint (g_list_length (l), ==, 2);
- for (p = l; p; p = p->next) {
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (p->data));
- g_assert (embed);
- view = ephy_embed_get_web_view (embed);
- g_assert (view);
- }
+ for (p = l; p; p = p->next) {
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (p->data));
+ g_assert (embed);
+ view = ephy_embed_get_web_view (embed);
+ g_assert (view);
+ }
- enable_delayed_loading ();
- ephy_session_clear (session);
+ enable_delayed_loading ();
+ ephy_session_clear (session);
}
static void
-open_uris_after_loading_session (const char** uris, int final_num_windows)
+open_uris_after_loading_session (const char **uris, int final_num_windows)
{
- EphySession *session;
- gboolean ret;
- GList *l, *p;
- EphyEmbed *embed;
- EphyWebView *view;
- guint32 user_time;
- GMainLoop *loop;
+ EphySession *session;
+ gboolean ret;
+ GList *l, *p;
+ EphyEmbed *embed;
+ EphyWebView *view;
+ guint32 user_time;
+ GMainLoop *loop;
- disable_delayed_loading ();
+ disable_delayed_loading ();
- session = ephy_shell_get_session (ephy_shell_get_default ());
- g_assert (session);
+ session = ephy_shell_get_session (ephy_shell_get_default ());
+ g_assert (session);
- loop = ephy_test_utils_setup_ensure_web_views_are_loaded ();
+ loop = ephy_test_utils_setup_ensure_web_views_are_loaded ();
- user_time = gdk_x11_display_get_user_time (gdk_display_get_default ());
+ user_time = gdk_x11_display_get_user_time (gdk_display_get_default ());
- ret = load_session_from_string (session, session_data_many_windows);
- g_assert (ret);
- g_assert_cmpint (ephy_test_utils_get_web_view_ready_counter (), >=, 0);
- g_assert_cmpint (ephy_test_utils_get_web_view_ready_counter (), <=, 2);
+ ret = load_session_from_string (session, session_data_many_windows);
+ g_assert (ret);
+ g_assert_cmpint (ephy_test_utils_get_web_view_ready_counter (), >=, 0);
+ g_assert_cmpint (ephy_test_utils_get_web_view_ready_counter (), <=, 2);
- ephy_test_utils_ensure_web_views_are_loaded (loop);
+ ephy_test_utils_ensure_web_views_are_loaded (loop);
- l = gtk_application_get_windows (GTK_APPLICATION (ephy_shell_get_default ()));
+ l = gtk_application_get_windows (GTK_APPLICATION (ephy_shell_get_default ()));
- g_assert (l);
- g_assert_cmpint (g_list_length (l), ==, 2);
+ g_assert (l);
+ g_assert_cmpint (g_list_length (l), ==, 2);
- for (p = l; p; p = p->next) {
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (p->data));
- g_assert (embed);
- view = ephy_embed_get_web_view (embed);
- g_assert (view);
- }
+ for (p = l; p; p = p->next) {
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (p->data));
+ g_assert (embed);
+ view = ephy_embed_get_web_view (embed);
+ g_assert (view);
+ }
- /* Causing a session load here should not create new windows, since we
- * already have some.
- */
- ephy_session_save (session);
+ /* Causing a session load here should not create new windows, since we
+ * already have some.
+ */
+ ephy_session_save (session);
- ephy_session_resume (session, user_time, NULL, NULL, NULL);
+ ephy_session_resume (session, user_time, NULL, NULL, NULL);
- /* Ensure the queue is processed. */
- while (gtk_events_pending ())
- gtk_main_iteration_do (FALSE);
+ /* Ensure the queue is processed. */
+ while (gtk_events_pending ())
+ gtk_main_iteration_do (FALSE);
- l = gtk_application_get_windows (GTK_APPLICATION (ephy_shell_get_default ()));
- g_assert (l);
- g_assert_cmpint (g_list_length (l), ==, 2);
+ l = gtk_application_get_windows (GTK_APPLICATION (ephy_shell_get_default ()));
+ g_assert (l);
+ g_assert_cmpint (g_list_length (l), ==, 2);
- /* We should still have only 2 windows after the session load
- * command - it should bail after noticing there are windows
- * already.
- */
- ephy_shell_open_uris (ephy_shell_get_default (), uris, 0, user_time);
+ /* We should still have only 2 windows after the session load
+ * command - it should bail after noticing there are windows
+ * already.
+ */
+ ephy_shell_open_uris (ephy_shell_get_default (), uris, 0, user_time);
- while (gtk_events_pending ())
- gtk_main_iteration_do (FALSE);
+ while (gtk_events_pending ())
+ gtk_main_iteration_do (FALSE);
- /* We should still have 2 windows here, since the new URI should be
- * in a new tab of an existing window.
- */
- l = gtk_application_get_windows (GTK_APPLICATION (ephy_shell_get_default ()));
- g_assert (l);
- g_assert_cmpint (g_list_length (l), ==, final_num_windows);
+ /* We should still have 2 windows here, since the new URI should be
+ * in a new tab of an existing window.
+ */
+ l = gtk_application_get_windows (GTK_APPLICATION (ephy_shell_get_default ()));
+ g_assert (l);
+ g_assert_cmpint (g_list_length (l), ==, final_num_windows);
- enable_delayed_loading ();
- ephy_session_clear (session);
+ enable_delayed_loading ();
+ ephy_session_clear (session);
}
static void
test_ephy_session_open_uri_after_loading_session (void)
{
- const char* uris[] = { "ephy-about:epiphany", NULL };
+ const char *uris[] = { "ephy-about:epiphany", NULL };
- open_uris_after_loading_session (uris, 2);
+ open_uris_after_loading_session (uris, 2);
}
static void
test_ephy_session_open_empty_uri_forces_new_window (void)
{
- const char* uris[] = { "", NULL };
+ const char *uris[] = { "", NULL };
- open_uris_after_loading_session (uris, 3);
+ open_uris_after_loading_session (uris, 3);
}
int
diff --git a/tests/ephy-shell-test.c b/tests/ephy-shell-test.c
index cf94462..4ccdbc4 100644
--- a/tests/ephy-shell-test.c
+++ b/tests/ephy-shell-test.c
@@ -54,13 +54,13 @@ test_ephy_shell_basic_embeds (void)
/* Embed should be created. */
embed1 = ephy_shell_new_tab_full
- (ephy_shell,
- NULL, /* title */
- NULL, /* related view */
- window,
- NULL, /* embed */
- EPHY_NEW_TAB_DONT_SHOW_WINDOW, /* flags */
- gtk_get_current_event_time ());
+ (ephy_shell,
+ NULL, /* title */
+ NULL, /* related view */
+ window,
+ NULL, /* embed */
+ EPHY_NEW_TAB_DONT_SHOW_WINDOW, /* flags */
+ gtk_get_current_event_time ());
g_assert (EPHY_IS_EMBED (embed1));
g_assert (gtk_widget_get_toplevel (GTK_WIDGET (embed1)) == GTK_WIDGET (window));
@@ -71,13 +71,13 @@ test_ephy_shell_basic_embeds (void)
/* Another embed should be created */
embed2 = ephy_shell_new_tab_full
- (ephy_shell,
- NULL, /* title */
- NULL, /* related view */
- window, /* window */
- NULL, /* embed */
- EPHY_NEW_TAB_DONT_SHOW_WINDOW, /* flags */
- gtk_get_current_event_time ());
+ (ephy_shell,
+ NULL, /* title */
+ NULL, /* related view */
+ window, /* window */
+ NULL, /* embed */
+ EPHY_NEW_TAB_DONT_SHOW_WINDOW, /* flags */
+ gtk_get_current_event_time ());
g_assert (EPHY_IS_EMBED (embed2));
/* A second children should exist now. */
@@ -101,8 +101,8 @@ test_ephy_shell_parent_windows (void)
/* parent-window provided */
embed = ephy_shell_new_tab
- (ephy_shell, EPHY_WINDOW (window), NULL,
- EPHY_NEW_TAB_DONT_SHOW_WINDOW);
+ (ephy_shell, EPHY_WINDOW (window), NULL,
+ EPHY_NEW_TAB_DONT_SHOW_WINDOW);
g_assert (EPHY_IS_EMBED (embed));
g_assert (gtk_widget_get_toplevel (GTK_WIDGET (embed)) == window);
@@ -112,8 +112,8 @@ test_ephy_shell_parent_windows (void)
/* Another new-window */
window2 = GTK_WIDGET (ephy_window_new ());
embed = ephy_shell_new_tab
- (ephy_shell, EPHY_WINDOW (window2), NULL,
- EPHY_NEW_TAB_DONT_SHOW_WINDOW);
+ (ephy_shell, EPHY_WINDOW (window2), NULL,
+ EPHY_NEW_TAB_DONT_SHOW_WINDOW);
/* The parent window should be a completely new one. */
g_assert (EPHY_IS_EMBED (embed));
@@ -140,8 +140,8 @@ test_ephy_shell_tab_load (void)
/* homepage is "about:blank" for now, see embed/ephy-web-view.c */
embed = ephy_shell_new_tab
- (ephy_shell, EPHY_WINDOW (window), NULL,
- EPHY_NEW_TAB_DONT_SHOW_WINDOW);
+ (ephy_shell, EPHY_WINDOW (window), NULL,
+ EPHY_NEW_TAB_DONT_SHOW_WINDOW);
ephy_web_view_load_homepage (ephy_embed_get_web_view (embed));
g_assert (EPHY_IS_EMBED (embed));
@@ -159,8 +159,8 @@ test_ephy_shell_tab_load (void)
/* open-page "about:epiphany" for testing. */
embed = ephy_shell_new_tab
- (ephy_shell, EPHY_WINDOW (window), NULL,
- EPHY_NEW_TAB_DONT_SHOW_WINDOW);
+ (ephy_shell, EPHY_WINDOW (window), NULL,
+ EPHY_NEW_TAB_DONT_SHOW_WINDOW);
ephy_web_view_load_url (ephy_embed_get_web_view (embed), "about:epiphany");
g_assert (EPHY_IS_EMBED (embed));
@@ -248,7 +248,7 @@ test_ephy_shell_tab_from_external (void)
loop = ephy_test_utils_setup_ensure_web_views_are_loaded ();
embed = ephy_shell_new_tab (ephy_shell, NULL, NULL, "about:epiphany",
- EPHY_NEW_TAB_DONT_SHOW_WINDOW | EPHY_NEW_TAB_OPEN_PAGE);
+ EPHY_NEW_TAB_DONT_SHOW_WINDOW | EPHY_NEW_TAB_OPEN_PAGE);
window = gtk_widget_get_toplevel (GTK_WIDGET (embed));
notebook = ephy_window_get_notebook (EPHY_WINDOW (window));
@@ -289,7 +289,7 @@ test_ephy_shell_tab_from_external (void)
/* This should work */
ephy_test_utils_check_ephy_embed_address (embed2, "ephy-about:overview");
g_assert_cmpint (gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)), ==, 1);
-
+
loop = ephy_test_utils_setup_wait_until_load_is_committed (ephy_embed_get_web_view (embed2));
embed5 = ephy_shell_new_tab (ephy_shell, EPHY_WINDOW (window), NULL, "about:applications",
diff --git a/tests/ephy-snapshot-service-test.c b/tests/ephy-snapshot-service-test.c
index 8974a3f..a442a38 100644
--- a/tests/ephy-snapshot-service-test.c
+++ b/tests/ephy-snapshot-service-test.c
@@ -29,8 +29,8 @@ SoupServer *server;
static gboolean
quit_when_test_done (GtkWidget *w,
- GdkEvent *event,
- gint *tests)
+ GdkEvent *event,
+ gint *tests)
{
if (--(*tests) == 0)
gtk_main_quit ();
@@ -39,13 +39,13 @@ quit_when_test_done (GtkWidget *w,
}
static void
-on_snapshot_ready (GObject *source,
+on_snapshot_ready (GObject *source,
GAsyncResult *res,
- gint *tests)
+ gint *tests)
{
GdkPixbuf *pixbuf;
#if 0
- GtkWidget *w,*i;
+ GtkWidget *w, *i;
#endif
GError *error = NULL;
@@ -61,14 +61,14 @@ on_snapshot_ready (GObject *source,
} else
#if 0
- w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
i = gtk_image_new_from_pixbuf (pixbuf);
gtk_container_add (GTK_CONTAINER (w), i);
gtk_widget_show_all (w);
g_signal_connect (w, "delete-event",
G_CALLBACK (quit_when_test_done), tests);
#else
- quit_when_test_done (NULL, NULL, tests);
+ quit_when_test_done (NULL, NULL, tests);
#endif
}
@@ -213,12 +213,11 @@ server_callback (SoupServer *s, SoupMessage *msg,
const char *response = "<html><h1>This is a header</h1></html>";
if (msg->method == SOUP_METHOD_GET) {
- soup_message_set_status (msg, SOUP_STATUS_OK);
- soup_message_body_append (msg->response_body, SOUP_MEMORY_STATIC,
+ soup_message_set_status (msg, SOUP_STATUS_OK);
+ soup_message_body_append (msg->response_body, SOUP_MEMORY_STATIC,
response, strlen (response));
- soup_message_body_complete (msg->response_body);
- }
- else
+ soup_message_body_complete (msg->response_body);
+ } else
soup_message_set_status (msg, SOUP_STATUS_NOT_IMPLEMENTED);
}
@@ -230,12 +229,12 @@ main (int argc, char *argv[])
server = soup_server_new (SOUP_SERVER_SERVER_HEADER, "snapshot-service-test-server",
NULL);
- soup_server_add_handler (server, NULL,
+ soup_server_add_handler (server, NULL,
server_callback, NULL, NULL);
soup_server_listen_local (server, 45716,
SOUP_SERVER_LISTEN_IPV4_ONLY,
NULL);
- mtime = time(NULL);
+ mtime = time (NULL);
g_test_add_func ("/lib/ephy-snapshot-service/test_snapshot",
test_snapshot);
diff --git a/tests/ephy-sqlite-test.c b/tests/ephy-sqlite-test.c
index d97ece1..8ca8a36 100644
--- a/tests/ephy-sqlite-test.c
+++ b/tests/ephy-sqlite-test.c
@@ -27,7 +27,7 @@
#include <gtk/gtk.h>
static EphySQLiteConnection *
-ensure_empty_database (const char* filename)
+ensure_empty_database (const char *filename)
{
EphySQLiteConnection *connection = ephy_sqlite_connection_new ();
GError *error = NULL;
@@ -49,9 +49,9 @@ test_create_connection (void)
EphySQLiteConnection *connection = ensure_empty_database (temporary_file);
ephy_sqlite_connection_close (connection);
- g_assert ( g_file_test (temporary_file, G_FILE_TEST_IS_REGULAR));
+ g_assert (g_file_test (temporary_file, G_FILE_TEST_IS_REGULAR));
g_unlink (temporary_file);
- g_assert ( !g_file_test (temporary_file, G_FILE_TEST_IS_REGULAR));
+ g_assert (!g_file_test (temporary_file, G_FILE_TEST_IS_REGULAR));
g_free (temporary_file);
temporary_file = g_build_filename (g_get_tmp_dir (), "directory-that-does-not-exist",
"epiphany_sqlite_test.db", NULL);
@@ -66,7 +66,7 @@ static void
test_create_statement (void)
{
gchar *temporary_file = g_build_filename (g_get_tmp_dir (), "epiphany-sqlite-test.db", NULL);
- EphySQLiteConnection* connection = ensure_empty_database (temporary_file);
+ EphySQLiteConnection *connection = ensure_empty_database (temporary_file);
GError *error = NULL;
EphySQLiteStatement *statement = NULL;
@@ -132,7 +132,7 @@ static void
test_create_table_and_insert_row (void)
{
gchar *temporary_file = g_build_filename (g_get_tmp_dir (), "epiphany-sqlite-test.db", NULL);
- EphySQLiteConnection* connection = ensure_empty_database (temporary_file);
+ EphySQLiteConnection *connection = ensure_empty_database (temporary_file);
create_table_and_insert_row (connection);
@@ -145,7 +145,7 @@ static void
test_bind_data (void)
{
gchar *temporary_file = g_build_filename (g_get_tmp_dir (), "epiphany-sqlite-test.db", NULL);
- EphySQLiteConnection* connection = ensure_empty_database (temporary_file);
+ EphySQLiteConnection *connection = ensure_empty_database (temporary_file);
GError *error = NULL;
EphySQLiteStatement *statement = NULL;
@@ -183,7 +183,7 @@ static void
test_table_exists (void)
{
gchar *temporary_file = g_build_filename (g_get_tmp_dir (), "epiphany-sqlite-test.db", NULL);
- EphySQLiteConnection* connection = ensure_empty_database (temporary_file);
+ EphySQLiteConnection *connection = ensure_empty_database (temporary_file);
g_assert (!ephy_sqlite_connection_table_exists (connection, "test"));
g_assert (!ephy_sqlite_connection_table_exists (connection, "something_fakey"));
diff --git a/tests/ephy-test-utils.c b/tests/ephy-test-utils.c
index a6e1383..af6cbb4 100644
--- a/tests/ephy-test-utils.c
+++ b/tests/ephy-test-utils.c
@@ -40,16 +40,16 @@ ephy_test_utils_check_ephy_web_view_address (EphyWebView *view,
}
void
-ephy_test_utils_check_ephy_embed_address (EphyEmbed *embed,
+ephy_test_utils_check_ephy_embed_address (EphyEmbed *embed,
const gchar *address)
{
ephy_test_utils_check_ephy_web_view_address (ephy_embed_get_web_view (embed), address);
}
static void
-load_changed_cb (WebKitWebView *web_view,
+load_changed_cb (WebKitWebView *web_view,
WebKitLoadEvent status,
- GMainLoop *loop)
+ GMainLoop *loop)
{
if (status == WEBKIT_LOAD_COMMITTED) {
web_view_ready_counter--;
@@ -58,7 +58,6 @@ load_changed_cb (WebKitWebView *web_view,
if (web_view_ready_counter == 0)
g_main_loop_quit (loop);
}
-
}
static void
@@ -74,7 +73,7 @@ web_view_created_cb (EphyEmbedShell *shell, EphyWebView *view, GMainLoop *loop)
wait_until_load_is_committed (WEBKIT_WEB_VIEW (view), loop);
}
-GMainLoop*
+GMainLoop *
ephy_test_utils_setup_ensure_web_views_are_loaded (void)
{
GMainLoop *loop;
@@ -99,7 +98,7 @@ ephy_test_utils_ensure_web_views_are_loaded (GMainLoop *loop)
g_main_loop_unref (loop);
}
-GMainLoop*
+GMainLoop *
ephy_test_utils_setup_wait_until_load_is_committed (EphyWebView *view)
{
GMainLoop *loop;
diff --git a/tests/ephy-uri-helpers-test.c b/tests/ephy-uri-helpers-test.c
index a3ae24e..b7beaa1 100644
--- a/tests/ephy-uri-helpers-test.c
+++ b/tests/ephy-uri-helpers-test.c
@@ -44,14 +44,13 @@ test_ephy_uri_helpers_remove_tracking (void)
{ "http://foo.youtube.com/?feature=foo", "http://foo.youtube.com/" },
/* https://bugzilla.gnome.org/show_bug.cgi?id=724724 */
{ "http://git.savannah.gnu.org/gitweb/?p=grep.git;a=commit;h=97318f5e59a1ef6feb8a378434a00932a3fc1e0b",
- "http://git.savannah.gnu.org/gitweb/?p=grep.git;a=commit;h=97318f5e59a1ef6feb8a378434a00932a3fc1e0b"},
+ "http://git.savannah.gnu.org/gitweb/?p=grep.git;a=commit;h=97318f5e59a1ef6feb8a378434a00932a3fc1e0b" },
/* https://bugzilla.gnome.org/show_bug.cgi?id=730464 */
{
"https://mail.google.com/mail/u/0/?ui=2&ik=37373eb942&rid=7cea..&auto=1&view=lno&_reqid=1168127&pcd=1&mb=0&rt=j",
"https://mail.google.com/mail/u/0/?ui=2&ik=37373eb942&rid=7cea..&auto=1&view=lno&_reqid=1168127&pcd=1&mb=0&rt=j"
},
{ "http://www.test.com/?utm_source=feedburner&view=lno&_reqid=1234",
"http://www.test.com/?view=lno&_reqid=1234" },
{ "http://www.test.com/?some&valid&query", "http://www.test.com/?some&valid&query" },
{ "http://www.test.com/?utm_source=feedburner&some&valid&query", "http://www.test.com/?some&valid&query"
},
-
};
guint i;
diff --git a/tests/ephy-web-view-test.c b/tests/ephy-web-view-test.c
index cc0b789..0f3d3d6 100644
--- a/tests/ephy-web-view-test.c
+++ b/tests/ephy-web-view-test.c
@@ -42,12 +42,12 @@
#define SERVER_PORT 12321
static void
-server_callback (SoupServer *server,
- SoupMessage *msg,
- const char *path,
- GHashTable *query,
+server_callback (SoupServer *server,
+ SoupMessage *msg,
+ const char *path,
+ GHashTable *query,
SoupClientContext *context,
- gpointer data)
+ gpointer data)
{
if (g_str_equal (path, "/cancelled"))
soup_message_set_status (msg, SOUP_STATUS_CANT_CONNECT);
@@ -271,9 +271,9 @@ normalize_or_autosearch_t normalize_or_autosearch_test_google[] = {
};
static void
-verify_normalize_or_autosearch_urls (EphyWebView *view,
+verify_normalize_or_autosearch_urls (EphyWebView *view,
normalize_or_autosearch_t *test,
- gint n_tests)
+ gint n_tests)
{
int i;
@@ -295,7 +295,7 @@ test_ephy_web_view_normalize_or_autosearch (void)
{
char *default_engine_url;
EphyWebView *view;
-
+
view = EPHY_WEB_VIEW (ephy_web_view_new ());
default_engine_url = g_settings_get_string (EPHY_SETTINGS_MAIN,
EPHY_PREFS_KEYWORD_SEARCH_URL);
@@ -333,10 +333,10 @@ quit_main_loop_when_load_finished (WebKitWebView *view, WebKitLoadEvent load_eve
static guint back_forward_list_counter = 0;
static void
-back_forward_list_changed (WebKitBackForwardList *list,
+back_forward_list_changed (WebKitBackForwardList *list,
WebKitBackForwardListItem *added_item,
- GList *removed_items,
- GMainLoop *loop)
+ GList *removed_items,
+ GMainLoop *loop)
{
back_forward_list_counter--;
@@ -346,13 +346,13 @@ back_forward_list_changed (WebKitBackForwardList *list,
static void
wait_until_back_forward_list_changes (WebKitWebView *view,
- GMainLoop *loop)
+ GMainLoop *loop)
{
- WebKitBackForwardList *back_forward_list = webkit_web_view_get_back_forward_list (view);
- g_signal_connect (back_forward_list, "changed", G_CALLBACK (back_forward_list_changed), loop);
+ WebKitBackForwardList *back_forward_list = webkit_web_view_get_back_forward_list (view);
+ g_signal_connect (back_forward_list, "changed", G_CALLBACK (back_forward_list_changed), loop);
}
-static GMainLoop*
+static GMainLoop *
setup_ensure_back_forward_list_changes (EphyWebView *view)
{
GMainLoop *loop;
@@ -378,70 +378,70 @@ ensure_back_forward_list_changes (GMainLoop *loop)
static void
test_ephy_web_view_provisional_load_failure_updates_back_forward_list (void)
{
- GMainLoop *loop;
- EphyWebView *view;
- const char *bad_url;
+ GMainLoop *loop;
+ EphyWebView *view;
+ const char *bad_url;
- view = EPHY_WEB_VIEW (ephy_web_view_new ());
+ view = EPHY_WEB_VIEW (ephy_web_view_new ());
- loop = setup_ensure_back_forward_list_changes (view);
- bad_url = "http://localhost:2984375932/";
+ loop = setup_ensure_back_forward_list_changes (view);
+ bad_url = "http://localhost:2984375932/";
- ephy_web_view_load_url (view, bad_url);
+ ephy_web_view_load_url (view, bad_url);
- ensure_back_forward_list_changes (loop);
+ ensure_back_forward_list_changes (loop);
- g_assert (webkit_back_forward_list_get_current_item (
- webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (view))));
+ g_assert (webkit_back_forward_list_get_current_item (
+ webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (view))));
- g_assert_cmpstr (bad_url, ==, webkit_back_forward_list_item_get_uri (
- webkit_back_forward_list_get_current_item (
- webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (view)))));
+ g_assert_cmpstr (bad_url, ==, webkit_back_forward_list_item_get_uri (
+ webkit_back_forward_list_get_current_item (
+ webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (view)))));
- g_object_unref (g_object_ref_sink (view));
+ g_object_unref (g_object_ref_sink (view));
}
static gboolean
-visit_url_cb (EphyHistoryService *service,
- const char *url,
+visit_url_cb (EphyHistoryService *service,
+ const char *url,
EphyHistoryPageVisit visit_type,
- gpointer user_data)
+ gpointer user_data)
{
- /* We are only loading an error page, this code should never be
- * reached. */
- g_assert_not_reached ();
+ /* We are only loading an error page, this code should never be
+ * reached. */
+ g_assert_not_reached ();
- return FALSE;
+ return FALSE;
}
static void
test_ephy_web_view_error_pages_not_stored_in_history (void)
{
- GMainLoop *loop;
- EphyWebView *view;
- const char *bad_url;
- EphyHistoryService *history_service;
- EphyEmbedShell *embed_shell = ephy_embed_shell_get_default ();
+ GMainLoop *loop;
+ EphyWebView *view;
+ const char *bad_url;
+ EphyHistoryService *history_service;
+ EphyEmbedShell *embed_shell = ephy_embed_shell_get_default ();
- view = EPHY_WEB_VIEW (ephy_web_view_new ());
- loop = g_main_loop_new (NULL, FALSE);
- bad_url = "http://localhost:2984375932/";
+ view = EPHY_WEB_VIEW (ephy_web_view_new ());
+ loop = g_main_loop_new (NULL, FALSE);
+ bad_url = "http://localhost:2984375932/";
- history_service = EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service (embed_shell));
- g_assert (history_service);
- g_signal_connect (history_service, "visit-url",
- G_CALLBACK (visit_url_cb), NULL);
-
- ephy_web_view_load_url (view, bad_url);
+ history_service = EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service (embed_shell));
+ g_assert (history_service);
+ g_signal_connect (history_service, "visit-url",
+ G_CALLBACK (visit_url_cb), NULL);
- g_signal_connect (view, "load-changed",
- G_CALLBACK (quit_main_loop_when_load_finished), loop);
+ ephy_web_view_load_url (view, bad_url);
- g_main_loop_run (loop);
- g_main_loop_unref (loop);
- g_signal_handlers_disconnect_by_func (history_service, G_CALLBACK (visit_url_cb), NULL);
+ g_signal_connect (view, "load-changed",
+ G_CALLBACK (quit_main_loop_when_load_finished), loop);
- g_object_unref (g_object_ref_sink (view));
+ g_main_loop_run (loop);
+ g_main_loop_unref (loop);
+ g_signal_handlers_disconnect_by_func (history_service, G_CALLBACK (visit_url_cb), NULL);
+
+ g_object_unref (g_object_ref_sink (view));
}
int
@@ -466,7 +466,7 @@ main (int argc, char *argv[])
server = soup_server_new (NULL, NULL);
soup_server_add_handler (server, NULL, server_callback, NULL, NULL);
soup_server_listen_local (server, SERVER_PORT,
- SOUP_SERVER_LISTEN_IPV4_ONLY, NULL);
+ SOUP_SERVER_LISTEN_IPV4_ONLY, NULL);
g_test_add_func ("/embed/ephy-web-view/non_search_regex",
test_ephy_web_view_non_search_regex);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]