Commit 05b45341 authored by Carlos Garcia Campos's avatar Carlos Garcia Campos Committed by Carlos Garcia Campos

Remove the overview widget and use the html based one instead

parent 65a1e4d1
......@@ -21,7 +21,6 @@ INST_H_FILES = \
ephy-embed-shell.h \
ephy-embed-utils.h \
ephy-find-toolbar.h \
ephy-overview.h \
ephy-web-view.h \
ephy-web-extension-proxy.h
......@@ -43,7 +42,6 @@ libephyembed_la_SOURCES = \
ephy-encodings.c \
ephy-file-monitor.c \
ephy-find-toolbar.c \
ephy-overview.c \
ephy-embed-prefs.c \
ephy-web-view.c \
ephy-web-extension-proxy.c \
......
......@@ -596,7 +596,7 @@ ephy_about_handler_handle_request (EphyAboutHandler *handler,
handled = ephy_about_handler_handle_epiphany (handler, request);
else if (!g_strcmp0 (path, "applications"))
handled = ephy_about_handler_handle_applications (handler, request);
else if (!g_strcmp0 (path, "html-overview"))
else if (!g_strcmp0 (path, "overview"))
handled = ephy_about_handler_handle_html_overview (handler, request);
else if (!g_strcmp0 (path, "incognito"))
handled = ephy_about_handler_handle_incognito (handler, request);
......
......@@ -66,8 +66,6 @@ struct _EphyEmbedPrivate
WebKitURIRequest *delayed_request;
GtkWidget *overview;
guint overview_mode : 1;
GSList *messages;
GSList *keys;
......@@ -89,7 +87,6 @@ enum
{
PROP_0,
PROP_WEB_VIEW,
PROP_OVERVIEW_MODE,
};
G_DEFINE_TYPE (EphyEmbed, ephy_embed, GTK_TYPE_BOX)
......@@ -248,20 +245,8 @@ load_changed_cb (WebKitWebView *web_view,
WebKitLoadEvent load_event,
EphyEmbed *embed)
{
switch (load_event) {
case WEBKIT_LOAD_STARTED: {
const char *uri;
uri = webkit_web_view_get_uri (web_view);
ephy_embed_set_overview_mode (embed, g_strcmp0 (uri, "ephy-about:overview") == 0);
break;
}
case WEBKIT_LOAD_COMMITTED:
if (load_event == WEBKIT_LOAD_COMMITTED)
ephy_embed_destroy_top_widgets (embed);
break;
default:
break;
}
}
static void
......@@ -400,9 +385,6 @@ ephy_embed_set_property (GObject *object,
case PROP_WEB_VIEW:
embed->priv->web_view = g_value_get_object (value);
break;
case PROP_OVERVIEW_MODE:
ephy_embed_set_overview_mode (embed, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -422,9 +404,6 @@ ephy_embed_get_property (GObject *object,
case PROP_WEB_VIEW:
g_value_set_object (value, ephy_embed_get_web_view (embed));
break;
case PROP_OVERVIEW_MODE:
g_value_set_boolean (value, ephy_embed_get_overview_mode (embed));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -462,18 +441,6 @@ ephy_embed_class_init (EphyEmbedClass *klass)
"The WebView contained in the embed",
EPHY_TYPE_WEB_VIEW,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
/**
* EphyEmbed:overview-mode:
*
* If %TRUE activates the overview mode in this #EphyEmbed.
**/
g_object_class_install_property (object_class,
PROP_OVERVIEW_MODE,
g_param_spec_boolean ("overview-mode",
"Overview mode",
"Whether the embed is showing the overview",
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_type_class_add_private (G_OBJECT_CLASS (klass), sizeof(EphyEmbedPrivate));
}
......@@ -669,19 +636,6 @@ ephy_embed_constructed (GObject *object)
GDK_LEAVE_NOTIFY_MASK);
gtk_container_add (GTK_CONTAINER (overlay), GTK_WIDGET (priv->web_view));
/* The overview. In incognito mode we don't use it. */
if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) !=
EPHY_EMBED_SHELL_MODE_INCOGNITO) {
priv->overview = ephy_overview_new ();
gtk_widget_set_halign (priv->overview, GTK_ALIGN_FILL);
gtk_widget_set_valign (priv->overview, GTK_ALIGN_FILL);
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), priv->overview);
g_object_bind_property (embed, "overview-mode",
priv->overview, "visible",
G_BINDING_SYNC_CREATE);
}
/* Floating message popup for fullscreen mode. */
priv->fullscreen_message_label = gtk_label_new (NULL);
gtk_widget_set_name (priv->fullscreen_message_label, "fullscreen-popup");
......@@ -851,31 +805,6 @@ ephy_embed_remove_top_widget (EphyEmbed *embed, GtkWidget *widget)
GTK_WIDGET (widget));
}
void
ephy_embed_set_overview_mode (EphyEmbed *embed, gboolean overview_mode)
{
EphyEmbedPrivate *priv;
g_return_if_fail (EPHY_IS_EMBED (embed));
priv = embed->priv;
if (priv->overview_mode == overview_mode)
return;
priv->overview_mode = overview_mode;
g_object_notify (G_OBJECT (embed), "overview-mode");
}
gboolean
ephy_embed_get_overview_mode (EphyEmbed *embed)
{
g_return_val_if_fail (EPHY_IS_EMBED (embed), FALSE);
return embed->priv->overview_mode;
}
/**
* ephy_embed_set_delayed_load_request:
* @embed: a #EphyEmbed
......@@ -912,18 +841,3 @@ ephy_embed_has_load_pending (EphyEmbed *embed)
return !!embed->priv->delayed_request;
}
/**
* ephy_embed_get_overview:
* @embed: a #EphyEmbed
*
* Gets the #EphyOverview in this @embed
*
* Returns: (transfer none): the overview widget
**/
EphyOverview *
ephy_embed_get_overview (EphyEmbed *embed)
{
g_return_val_if_fail (EPHY_IS_EMBED (embed), NULL);
return EPHY_OVERVIEW (embed->priv->overview);
}
......@@ -23,7 +23,6 @@
#define EPHY_EMBED_H
#include "ephy-find-toolbar.h"
#include "ephy-overview.h"
#include "ephy-web-view.h"
#include <gtk/gtk.h>
......@@ -65,10 +64,6 @@ void ephy_embed_leaving_fullscreen (EphyEmbed *embed);
void ephy_embed_set_delayed_load_request (EphyEmbed *embed,
WebKitURIRequest *request);
gboolean ephy_embed_has_load_pending (EphyEmbed *embed);
void ephy_embed_set_overview_mode (EphyEmbed *embed,
gboolean overview_mode);
gboolean ephy_embed_get_overview_mode (EphyEmbed *embed);
EphyOverview* ephy_embed_get_overview (EphyEmbed *embed);
G_END_DECLS
......
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
/* vim: set sw=2 ts=2 sts=2 et: */
/*
* Copyright © 2012 Igalia S.L.
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "config.h"
#include "ephy-overview.h"
#include "ephy-embed-private.h"
#include "ephy-embed-shell.h"
#include "ephy-frecent-store.h"
#include <gtk/gtk.h>
#define EPHY_OVERVIEW_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_OVERVIEW, EphyOverviewPrivate))
struct _EphyOverviewPrivate
{
GtkWidget *frecent_view;
};
G_DEFINE_TYPE (EphyOverview, ephy_overview, GTK_TYPE_GRID)
static gboolean
frecent_view_item_deleted (GtkWidget *widget,
gchar *path,
gpointer data)
{
EphyFrecentStore *store;
GtkTreeIter iter;
GtkTreePath *tree_path;
store = EPHY_FRECENT_STORE (gd_main_view_get_model (GD_MAIN_VIEW (widget)));
tree_path = gtk_tree_path_new_from_string (path);
gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, tree_path);
ephy_frecent_store_set_hidden (store, &iter);
gtk_tree_path_free (tree_path);
return TRUE;
}
static void
main_view_item_activated (GtkWidget *widget,
gchar *id,
GtkTreePath *path,
EphyOverview *overview)
{
GtkTreeModel *model;
GtkTreeIter iter;
char *url;
model = gd_main_view_get_model (GD_MAIN_VIEW (widget));
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter,
EPHY_OVERVIEW_STORE_URI, &url,
-1);
g_signal_emit_by_name (overview, "open-link", url);
g_free (url);
}
static gboolean
iconview_motion_notify (GtkWidget *widget,
GdkEvent *event,
EphyOverview *overview)
{
GdkCursor *cursor;
GtkIconView *iconview = GTK_ICON_VIEW (widget);
GdkEventMotion *ev = (GdkEventMotion *)event;
if (gtk_icon_view_get_item_at_pos (iconview, ev->x, ev->y, NULL, NULL)) {
cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), GDK_HAND2);
gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
g_object_unref (cursor);
} else
gdk_window_set_cursor (gtk_widget_get_window (widget), NULL);
return FALSE;
}
static void
ephy_overview_constructed (GObject *object)
{
EphyOverviewStore *store;
EphyOverview *self = EPHY_OVERVIEW (object);
GtkWidget *iconview;
if (G_OBJECT_CLASS (ephy_overview_parent_class)->constructed)
G_OBJECT_CLASS (ephy_overview_parent_class)->constructed (object);
self->priv->frecent_view = GTK_WIDGET (gd_main_view_new (GD_MAIN_VIEW_ICON));
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (self->priv->frecent_view),
GTK_SHADOW_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (self->priv->frecent_view),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
iconview = gtk_bin_get_child (GTK_BIN (self->priv->frecent_view));
gtk_icon_view_set_columns (GTK_ICON_VIEW (iconview), 5);
g_signal_connect (iconview, "motion-notify-event",
G_CALLBACK (iconview_motion_notify),
self);
g_object_set (self->priv->frecent_view,
"halign", GTK_ALIGN_FILL,
"valign", GTK_ALIGN_FILL, NULL);
g_object_set (iconview,
"halign", GTK_ALIGN_CENTER,
"valign", GTK_ALIGN_CENTER, NULL);
g_signal_connect (self->priv->frecent_view, "item-activated",
G_CALLBACK (main_view_item_activated), object);
g_signal_connect (self->priv->frecent_view, "item-deleted",
G_CALLBACK (frecent_view_item_deleted), NULL);
store = EPHY_OVERVIEW_STORE (ephy_embed_shell_get_frecent_store (ephy_embed_shell_get_default ()));
gd_main_view_set_model (GD_MAIN_VIEW (self->priv->frecent_view),
GTK_TREE_MODEL (store));
gtk_grid_attach (GTK_GRID (self), self->priv->frecent_view,
0, 0, 1, 1);
gtk_widget_show_all (GTK_WIDGET (self));
}
static void
ephy_overview_class_init (EphyOverviewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructed = ephy_overview_constructed;
g_signal_new ("open-link",
EPHY_TYPE_OVERVIEW,
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
g_cclosure_marshal_generic,
G_TYPE_NONE,
1,
G_TYPE_STRING);
g_type_class_add_private (object_class, sizeof (EphyOverviewPrivate));
}
static void
ephy_overview_init (EphyOverview *self)
{
self->priv = EPHY_OVERVIEW_GET_PRIVATE (self);
gtk_orientable_set_orientation (GTK_ORIENTABLE (self),
GTK_ORIENTATION_VERTICAL);
}
GtkWidget *
ephy_overview_new (void)
{
return g_object_new (EPHY_TYPE_OVERVIEW,
NULL);
}
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
/* vim: set sw=2 ts=2 sts=2 et: */
/*
* Copyright © 2011, 2012 Igalia S.L.
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef _EPHY_OVERVIEW_H
#define _EPHY_OVERVIEW_H
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define EPHY_TYPE_OVERVIEW ephy_overview_get_type()
#define EPHY_OVERVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EPHY_TYPE_OVERVIEW, EphyOverview))
#define EPHY_OVERVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EPHY_TYPE_OVERVIEW, EphyOverviewClass))
#define EPHY_IS_OVERVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EPHY_TYPE_OVERVIEW))
#define EPHY_IS_OVERVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EPHY_TYPE_OVERVIEW))
#define EPHY_OVERVIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EPHY_TYPE_OVERVIEW, EphyOverviewClass))
typedef struct _EphyOverview EphyOverview;
typedef struct _EphyOverviewClass EphyOverviewClass;
typedef struct _EphyOverviewPrivate EphyOverviewPrivate;
struct _EphyOverview {
GtkGrid parent;
/*< private >*/
EphyOverviewPrivate *priv;
};
struct _EphyOverviewClass {
GtkGridClass parent_class;
};
#define EPHY_OVERVIEW_TITLE _("Most Visited")
GType ephy_overview_get_type (void) G_GNUC_CONST;
GtkWidget * ephy_overview_new (void);
G_END_DECLS
#endif /* _EPHY_OVERVIEW_H */
......@@ -37,7 +37,6 @@
#include "ephy-file-monitor.h"
#include "ephy-form-auth-data.h"
#include "ephy-history-service.h"
#include "ephy-overview.h"
#include "ephy-prefs.h"
#include "ephy-settings.h"
#include "ephy-string.h"
......@@ -739,7 +738,7 @@ get_title_from_address (const char *address)
return g_strdup (address + 7);
else if (!strcmp (address, EPHY_ABOUT_SCHEME":overview") ||
!strcmp (address, "about:overview"))
return g_strdup (EPHY_OVERVIEW_TITLE);
return g_strdup (_("Most Visited"));
else
return ephy_string_get_host_name (address);
}
......@@ -2302,6 +2301,18 @@ ephy_web_view_get_is_blank (EphyWebView *view)
return view->priv->is_blank;
}
gboolean
ephy_web_view_is_overview (EphyWebView *view)
{
EphyWebViewPrivate *priv = view->priv;
if (!priv->address)
return FALSE;
return (!strcmp (priv->address, EPHY_ABOUT_SCHEME":overview") ||
!strcmp (priv->address, "about:overview"));
}
/**
* ephy_web_view_get_address:
* @view: an #EphyWebView
......
......@@ -137,6 +137,7 @@ const char * ephy_web_view_get_typed_address (EphyWebView
void ephy_web_view_set_typed_address (EphyWebView *view,
const char *address);
gboolean ephy_web_view_get_is_blank (EphyWebView *view);
gboolean ephy_web_view_is_overview (EphyWebView *view);
void ephy_web_view_has_modified_forms (EphyWebView *view,
GCancellable *cancellable,
GAsyncReadyCallback callback,
......
......@@ -5,7 +5,6 @@ BUILT_SOURCES = \
ephy-widgets-type-builtins.h
TYPES_H_FILES = \
ephy-removable-pixbuf-renderer.h \
ephy-location-entry.h
CLEANFILES = $(stamp_files) $(BUILT_SOURCES)
......@@ -78,26 +77,12 @@ libephywidgets_la_SOURCES = \
ephy-node-view.h \
ephy-overview-store.c \
ephy-overview-store.h \
ephy-removable-pixbuf-renderer.c \
ephy-removable-pixbuf-renderer.h \
ephy-tree-model-node.c \
ephy-tree-model-node.h \
ephy-tree-model-sort.c \
ephy-tree-model-sort.h \
ephy-zoom-action.h \
ephy-zoom-action.c \
gd-main-icon-view.c \
gd-main-icon-view.h \
gd-main-list-view.c \
gd-main-list-view.h \
gd-main-view-generic.c \
gd-main-view-generic.h \
gd-main-view.c \
gd-main-view.h \
gd-toggle-pixbuf-renderer.c \
gd-toggle-pixbuf-renderer.h \
gd-two-lines-renderer.c \
gd-two-lines-renderer.h \
nautilus-floating-bar.c \
nautilus-floating-bar.h \
totem-glow-button.c \
......
......@@ -21,7 +21,6 @@
#include "config.h"
#include "ephy-history-service.h"
#include "ephy-overview-store.h"
#include "ephy-removable-pixbuf-renderer.h"
#include "ephy-snapshot-service.h"
#include "ephy-widgets-type-builtins.h"
......@@ -165,7 +164,6 @@ ephy_overview_store_init (EphyOverviewStore *self)
types[EPHY_OVERVIEW_STORE_SELECTED] = G_TYPE_BOOLEAN;
types[EPHY_OVERVIEW_STORE_SNAPSHOT_CANCELLABLE] = G_TYPE_CANCELLABLE;
types[EPHY_OVERVIEW_STORE_SNAPSHOT_MTIME] = G_TYPE_INT;
types[EPHY_OVERVIEW_STORE_CLOSE_BUTTON_RENDER_POLICY] = EPHY_TYPE_REMOVABLE_PIXBUF_RENDER_POLICY;
gtk_list_store_set_column_types (GTK_LIST_STORE (self),
EPHY_OVERVIEW_STORE_NCOLS, types);
......@@ -616,10 +614,6 @@ ephy_overview_store_animated_remove (EphyOverviewStore *store,
gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path);
gtk_tree_path_free (path);
gtk_list_store_set (GTK_LIST_STORE (store), &iter,
EPHY_OVERVIEW_STORE_CLOSE_BUTTON_RENDER_POLICY,
EPHY_REMOVABLE_PIXBUF_RENDER_NEVER, -1);
id = g_timeout_add (40, (GSourceFunc) animated_remove_func, ctx);
g_source_set_name_by_id (id, "[epiphany] animated_remove_func");
}
......
......@@ -23,7 +23,6 @@
#include <gtk/gtk.h>
#include <webkit2/webkit2.h>
#include "gd-main-view.h"
G_BEGIN_DECLS
......@@ -51,16 +50,15 @@ struct _EphyOverviewStoreClass
};
enum {
EPHY_OVERVIEW_STORE_ID = GD_MAIN_COLUMN_ID,
EPHY_OVERVIEW_STORE_URI = GD_MAIN_COLUMN_URI,
EPHY_OVERVIEW_STORE_TITLE = GD_MAIN_COLUMN_TITLE,
EPHY_OVERVIEW_STORE_AUTHOR = GD_MAIN_COLUMN_AUTHOR,
EPHY_OVERVIEW_STORE_SNAPSHOT = GD_MAIN_COLUMN_ICON,
EPHY_OVERVIEW_STORE_LAST_VISIT = GD_MAIN_COLUMN_MTIME,
EPHY_OVERVIEW_STORE_SELECTED = GD_MAIN_COLUMN_SELECTED,
EPHY_OVERVIEW_STORE_ID,
EPHY_OVERVIEW_STORE_URI,
EPHY_OVERVIEW_STORE_TITLE,
EPHY_OVERVIEW_STORE_AUTHOR,
EPHY_OVERVIEW_STORE_SNAPSHOT,
EPHY_OVERVIEW_STORE_LAST_VISIT,
EPHY_OVERVIEW_STORE_SELECTED,
EPHY_OVERVIEW_STORE_SNAPSHOT_CANCELLABLE,
EPHY_OVERVIEW_STORE_SNAPSHOT_MTIME,
EPHY_OVERVIEW_STORE_CLOSE_BUTTON_RENDER_POLICY,
EPHY_OVERVIEW_STORE_NCOLS
};
......
/*
* Copyright (c) 2011 Red Hat, Inc.
* Copyright (c) 2012 Igalia, S.L.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Based on gd-toggle-pixbuf-renderer by Cosimo Cecchi <cosimoc@redhat.com>
*
*/
#include "config.h"
#include "ephy-removable-pixbuf-renderer.h"
#include "ephy-widgets-type-builtins.h"
G_DEFINE_TYPE (EphyRemovablePixbufRenderer, ephy_removable_pixbuf_renderer, GD_TYPE_TOGGLE_PIXBUF_RENDERER);
enum {
DELETE_CLICKED,
LAST_SIGNAL
};
enum {
PROP_0 = 0,
PROP_RENDER_POLICY
};
static guint signals[LAST_SIGNAL] = { 0 };
struct _EphyRemovablePixbufRendererPrivate {
EphyRemovablePixbufRenderPolicy policy;
GdkPixbuf *close_icon;
};
static void
get_icon_rectangle (GtkWidget *widget,
GtkCellRenderer *cell,
const GdkRectangle *cell_area,
GdkPixbuf *icon,
GdkRectangle *rectangle)
{
GtkTextDirection direction;
gint x_offset, y_offset, xpad, ypad;
gint icon_size;
gint w = 0, h = 0;
GdkPixbuf *pixbuf;
gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
direction = gtk_widget_get_direction (widget);
icon_size = gdk_pixbuf_get_width (icon);
g_object_get (cell, "pixbuf", &pixbuf, NULL);
if (pixbuf) {
w = gdk_pixbuf_get_width (pixbuf);
h = gdk_pixbuf_get_height (pixbuf);
g_object_unref (pixbuf);
}
x_offset = (cell_area->width - w)/2 + 10;
y_offset = (cell_area->height - h)/2 + 9;
if (direction == GTK_TEXT_DIR_RTL)
x_offset += xpad;
else
x_offset = cell_area->width - icon_size - xpad - x_offset;
rectangle->x = cell_area->x + x_offset;
rectangle->y = cell_area->y + ypad + y_offset;
rectangle->width = rectangle->height = icon_size;
}
static void
ephy_removable_pixbuf_renderer_render (GtkCellRenderer *cell,
cairo_t *cr,
GtkWidget *widget,
const GdkRectangle *background_area,
const GdkRectangle *cell_area,
GtkCellRendererState flags)
{
GtkStyleContext *context;
EphyRemovablePixbufRenderer *self = EPHY_REMOVABLE_PIXBUF_RENDERER (cell);
GdkRectangle icon_area;
GTK_CELL_RENDERER_CLASS (ephy_removable_pixbuf_renderer_parent_class)->render
(cell, cr, widget,
background_area, cell_area, flags);
if (self->priv->policy == EPHY_REMOVABLE_PIXBUF_RENDER_NEVER ||
(self->priv->policy == EPHY_REMOVABLE_PIXBUF_RENDER_PRELIT && !(flags & GTK_CELL_RENDERER_PRELIT)))
return;
get_icon_rectangle (widget, cell, cell_area, self->priv->close_icon, &icon_area);
context = gtk_widget_get_style_context (widget);
gtk_render_icon (context, cr, self->priv->close_icon, icon_area.x, icon_area.y);
}
static gboolean
ephy_removable_pixbuf_renderer_activate (GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
const gchar *path,
const GdkRectangle *background_area,
const GdkRectangle *cell_area,
GtkCellRendererState flags)
{
GdkRectangle icon_area;
GdkEventButton *ev = (GdkEventButton *) gtk_get_current_event();
EphyRemovablePixbufRendererPrivate *priv = EPHY_REMOVABLE_PIXBUF_RENDERER (cell)->priv;
if (priv->policy == EPHY_REMOVABLE_PIXBUF_RENDER_NEVER)
return FALSE;
get_icon_rectangle (widget, cell, cell_area, priv->close_icon, &icon_area);
if (icon_area.x <= ev->x && ev->x <= icon_area.x + icon_area.width &&
icon_area.y <= ev->y && ev->y <= icon_area.y + icon_area.height) {
g_signal_emit (cell, signals [DELETE_CLICKED], 0, path);
return TRUE;
}
return FALSE;
}
static void
ephy_removable_pixbuf_renderer_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
EphyRemovablePixbufRenderer *self = EPHY_REMOVABLE_PIXBUF_RENDERER (object);
switch (property_id)
{
case PROP_RENDER_POLICY:
g_value_set_enum (value, self->priv->policy);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
ephy_removable_pixbuf_renderer_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
EphyRemovablePixbufRenderer *self = EPHY_REMOVABLE_PIXBUF_RENDERER (object);
switch (property_id)
{
case PROP_RENDER_POLICY:
self->priv->policy = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
ephy_removable_pixbuf_renderer_dispose (GObject *object)
{
EphyRemovablePixbufRendererPrivate *priv = EPHY_REMOVABLE_PIXBUF_RENDERER (object)->priv;
if (priv->close_icon)
g_clear_object (&priv->close_icon);