summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/ephy-bookmark-action-group.c201
-rw-r--r--src/bookmarks/ephy-bookmark-action.c620
-rw-r--r--src/bookmarks/ephy-bookmark-properties.c696
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.c2737
-rw-r--r--src/bookmarks/ephy-bookmarks-export.c859
-rw-r--r--src/bookmarks/ephy-bookmarks-import.c1596
-rw-r--r--src/bookmarks/ephy-bookmarks-menu.c384
-rw-r--r--src/bookmarks/ephy-bookmarks-ui.c486
-rw-r--r--src/bookmarks/ephy-bookmarks.c2409
-rw-r--r--src/bookmarks/ephy-nodes-cover.c271
-rw-r--r--src/bookmarks/ephy-open-tabs-action.c163
-rw-r--r--src/bookmarks/ephy-topic-action-group.c139
-rw-r--r--src/bookmarks/ephy-topic-action.c450
-rw-r--r--src/bookmarks/ephy-topics-entry.c935
-rw-r--r--src/bookmarks/ephy-topics-palette.c498
-rw-r--r--src/clear-data-dialog.c171
-rw-r--r--src/cookies-dialog.c539
-rw-r--r--src/ephy-action-helper.c40
-rw-r--r--src/ephy-combined-stop-reload-action.c27
-rw-r--r--src/ephy-completion-model.c100
-rw-r--r--src/ephy-encoding-dialog.c589
-rw-r--r--src/ephy-encoding-row.c118
-rw-r--r--src/ephy-history-window.c1002
-rw-r--r--src/ephy-home-action.c78
-rw-r--r--src/ephy-link-action.c140
-rw-r--r--src/ephy-link.c120
-rw-r--r--src/ephy-location-controller.c1205
-rw-r--r--src/ephy-lockdown.c31
-rw-r--r--src/ephy-main.c72
-rw-r--r--src/ephy-navigation-history-action.c124
-rw-r--r--src/ephy-notebook.c1242
-rw-r--r--src/ephy-search-provider-main.c2
-rw-r--r--src/ephy-search-provider.c179
-rw-r--r--src/ephy-session.c2160
-rw-r--r--src/ephy-shell.c134
-rw-r--r--src/ephy-title-box.c36
-rw-r--r--src/ephy-toolbar.c92
-rw-r--r--src/ephy-window-action.c72
-rw-r--r--src/ephy-window.c5449
-rw-r--r--src/passwords-dialog.c667
-rw-r--r--src/popup-commands.c522
-rw-r--r--src/prefs-dialog.c1916
-rw-r--r--src/window-commands.c2298
43 files changed, 15245 insertions, 16324 deletions
diff --git a/src/bookmarks/ephy-bookmark-action-group.c b/src/bookmarks/ephy-bookmark-action-group.c
index a2ad23b6c..c96be0716 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 3f0a28ced..f323ecdea 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 45495390e..43aa16858 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 9b73e9d66..38529440b 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 e8dd98206..8dd6c4452 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 72ce993a2..7447d7102 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, "&amp;", 5) == 0)
- {
- g_string_append_c (result, '&');
- jump = 5;
- }
- else if (g_ascii_strncasecmp (iterator, "&lt;", 4) == 0)
- {
- g_string_append_c (result, '<');
- jump = 4;
- }
- else if (g_ascii_strncasecmp (iterator, "&gt;", 4) == 0)
- {
- g_string_append_c (result, '>');
- jump = 4;
- }
- else if (g_ascii_strncasecmp (iterator, "&quot;", 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, "&amp;", 5) == 0) {
+ g_string_append_c (result, '&');
+ jump = 5;
+ } else if (g_ascii_strncasecmp (iterator, "&lt;", 4) == 0) {
+ g_string_append_c (result, '<');
+ jump = 4;
+ } else if (g_ascii_strncasecmp (iterator, "&gt;", 4) == 0) {
+ g_string_append_c (result, '>');
+ jump = 4;
+ } else if (g_ascii_strncasecmp (iterator, "&quot;", 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 4a4da38c3..e6cd7d577 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 2dc619a1c..465ca4035 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 cca581ccb..d00e723fd 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 2e5fe7d63..0abbc3a75 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 99cf64116..51b2972df 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 521c9acfb..18c428d23 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 016dba1e2..d125ea056 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 f872c8d30..ae43a261f 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 1ab08448f..19a3443bb 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 2b0cc6a27..8bba234c5 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 629d4bb0e..7399d84e2 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 83a4e949f..a810672ad 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 31841015a..012e09e38 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 6c0ebcde0..8c4e69dd6 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 aa0928533..d61444254 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 72edf8d77..d82f7809b 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 9d13691a5..544e66682 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 b45f28644..7de40d23b 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 9c48ad712..980e1b1be 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 aa0fd05de..262bdb449 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 44b9fbc11..cef9802d1 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 22eaea316..358938586 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 7f9d55c48..ae0dd1b80 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 69cc2d718..6cc1b021c 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 153eb59d6..ff859ac47 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 adab13482..a2b2d4009 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 3db9817be..e1231dc8a 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 6622080b6..f836053e9 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 88560e894..4543ca4ff 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 0223eea61..70af11b0c 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 aeec11399..7b21dd19f 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 4f91f935e..875d8e33c 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 9fc746c75..4c42a5d6d 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 ab51b23ea..649f04374 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 1ed949c29..3dc6e79a9 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 ab1f71aa5..f4ab10e12 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 &amp;
- * 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 &amp;
+ * 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 c899e4e83..c83fdd514 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));
}