[epiphany] Open certificate popover if title box lock clicked
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Open certificate popover if title box lock clicked
- Date: Wed, 13 Aug 2014 02:57:55 +0000 (UTC)
commit 564a6951839a8e6a6c61c6794ca9e62701050e8d
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Fri Aug 8 15:54:20 2014 -0500
Open certificate popover if title box lock clicked
We show two locks in the header bar: the lock in the location entry, and
the lock in the title box. Previously, only the lock in the location
entry was actually functional, but clicking the lock in the title box
ought to work, too, since you should not need to open the location entry
to perform any actions.
Arguably the lock should be removed from the location entry so that this
functionality only exists in one place, but this patch leaves both locks
intact.
https://bugzilla.gnome.org/show_bug.cgi?id=666808
lib/widgets/ephy-certificate-popover.h | 8 +++---
po/POTFILES.in | 2 +-
src/ephy-title-box.c | 35 ++++++++++++++++++++++++-
src/ephy-window.c | 44 ++++++++++++++++++++++++++------
4 files changed, 75 insertions(+), 14 deletions(-)
---
diff --git a/lib/widgets/ephy-certificate-popover.h b/lib/widgets/ephy-certificate-popover.h
index bc4b0f3..7d214c1 100644
--- a/lib/widgets/ephy-certificate-popover.h
+++ b/lib/widgets/ephy-certificate-popover.h
@@ -44,15 +44,15 @@ typedef struct _EphyCertificatePopoverPrivate EphyCertificatePopoverPrivate;
struct _EphyCertificatePopover
{
- GtkPopover parent_object;
+ GtkPopover parent_object;
- /*< private >*/
- EphyCertificatePopoverPrivate *priv;
+ /*< private >*/
+ EphyCertificatePopoverPrivate *priv;
};
struct _EphyCertificatePopoverClass
{
- GtkPopoverClass parent_class;
+ GtkPopoverClass parent_class;
};
GType ephy_certificate_popover_get_type (void);
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 207e453..b626774 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -13,7 +13,6 @@ embed/ephy-embed-utils.c
embed/ephy-encodings.c
embed/ephy-find-toolbar.c
embed/ephy-web-view.c
-lib/ephy-certificate-popover.c
lib/ephy-file-chooser.c
lib/ephy-file-helpers.c
lib/ephy-form-auth-data.c
@@ -27,6 +26,7 @@ lib/ephy-time-helpers.c
lib/ephy-zoom.h
lib/history/ephy-history-service-hosts-table.c
lib/widgets/ephy-certificate-dialog.c
+lib/widgets/ephy-certificate-popover.c
lib/widgets/ephy-download-widget.c
lib/widgets/ephy-location-entry.c
src/bookmarks/ephy-bookmark-action.c
diff --git a/src/ephy-title-box.c b/src/ephy-title-box.c
index e9c439b..4cddeae 100644
--- a/src/ephy-title-box.c
+++ b/src/ephy-title-box.c
@@ -44,6 +44,14 @@ enum {
static GParamSpec *object_properties[N_PROPERTIES] = { NULL, };
+enum
+{
+ LOCK_CLICKED,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+
typedef struct
{
EphyWindow *window;
@@ -326,6 +334,7 @@ ephy_title_box_button_press_event (GtkWidget *widget,
{
EphyTitleBox *title_box = EPHY_TITLE_BOX (widget);
EphyTitleBoxPrivate *priv = ephy_title_box_get_instance_private (title_box);
+ GtkAllocation lock_allocation;
if (priv->mode != EPHY_TITLE_BOX_MODE_TITLE
|| event->button != GDK_BUTTON_PRIMARY
@@ -334,7 +343,14 @@ ephy_title_box_button_press_event (GtkWidget *widget,
LOG ("button-press-event title-box %p event %p", title_box, event);
- if (event->type == GDK_BUTTON_PRESS) {
+ gtk_widget_get_allocation (priv->lock_image, &lock_allocation);
+
+ if (event->x >= lock_allocation.x &&
+ event->x < lock_allocation.x + lock_allocation.width &&
+ event->y >= lock_allocation.y &&
+ event->y < lock_allocation.y + lock_allocation.height) {
+ g_signal_emit (title_box, signals[LOCK_CLICKED], 0, (GdkRectangle *)&lock_allocation);
+ } else if (event->type == GDK_BUTTON_PRESS) {
priv->button_down = TRUE;
} else {
priv->button_down = FALSE;
@@ -414,6 +430,23 @@ ephy_title_box_class_init (EphyTitleBoxClass *klass)
g_object_class_install_properties (object_class,
N_PROPERTIES,
object_properties);
+
+ /**
+ * EphyTitleBox::lock-clicked:
+ * @title_box: the object on which the signal is emitted
+ * @lock_position: the position of the lock icon
+ *
+ * Emitted when the user clicks the security icon inside the
+ * #EphyTitleBox.
+ */
+ signals[LOCK_CLICKED] = g_signal_new ("lock-clicked",
+ EPHY_TYPE_TITLE_BOX,
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_generic,
+ G_TYPE_NONE,
+ 1,
+ GDK_TYPE_RECTANGLE | G_SIGNAL_TYPE_STATIC_SCOPE);
}
static void
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 165882b..e88ef73 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -3064,8 +3064,9 @@ zoom_to_level_cb (GtkAction *action,
}
static void
-lock_clicked_cb (EphyLocationController *controller,
- EphyWindow *window)
+open_certificate_popover (EphyWindow *window,
+ GtkWidget *relative_to,
+ GdkRectangle *lock_position)
{
EphyWindowPrivate *priv = window->priv;
EphyWebView *view;
@@ -3074,25 +3075,47 @@ lock_clicked_cb (EphyLocationController *controller,
EphySecurityLevel security_level;
GtkWidget *location_entry;
GtkWidget *certificate_popover;
- GdkRectangle lock_position;
view = ephy_embed_get_web_view (priv->active_embed);
ephy_web_view_get_security_level (view, &security_level, &certificate, &tls_errors);
location_entry = ephy_toolbar_get_location_entry (EPHY_TOOLBAR (priv->toolbar));
- certificate_popover = ephy_certificate_popover_new (location_entry,
- ephy_location_controller_get_address (controller),
+ certificate_popover = ephy_certificate_popover_new (relative_to,
+ ephy_location_entry_get_location
(EPHY_LOCATION_ENTRY (location_entry)),
certificate,
tls_errors,
security_level);
- gtk_entry_get_icon_area (GTK_ENTRY (location_entry), GTK_ENTRY_ICON_SECONDARY, &lock_position);
- gtk_popover_set_pointing_to (GTK_POPOVER (certificate_popover), &lock_position);
g_signal_connect (certificate_popover, "closed",
G_CALLBACK (gtk_widget_destroy), NULL);
+ gtk_popover_set_pointing_to (GTK_POPOVER (certificate_popover), lock_position);
gtk_widget_show (certificate_popover);
}
+static void
+location_controller_lock_clicked_cb (EphyLocationController *controller,
+ gpointer user_data)
+{
+ EphyWindow *window = EPHY_WINDOW (user_data);
+ EphyWindowPrivate *priv = window->priv;
+ GtkWidget *location_entry;
+ GdkRectangle lock_position;
+
+ location_entry = ephy_toolbar_get_location_entry (EPHY_TOOLBAR (priv->toolbar));
+ gtk_entry_get_icon_area (GTK_ENTRY (location_entry), GTK_ENTRY_ICON_SECONDARY, &lock_position);
+ open_certificate_popover (window, location_entry, &lock_position);
+}
+
+static void
+title_box_lock_clicked_cb (EphyTitleBox *title_box,
+ GdkRectangle *lock_position,
+ gpointer user_data)
+{
+ EphyWindow *window = EPHY_WINDOW (user_data);
+
+ open_certificate_popover (window, GTK_WIDGET (title_box), lock_position);
+}
+
static GtkWidget *
setup_toolbar (EphyWindow *window)
{
@@ -3100,6 +3123,7 @@ setup_toolbar (EphyWindow *window)
GtkAction *action;
EphyWindowPrivate *priv = window->priv;
EphyEmbedShellMode app_mode;
+ EphyTitleBox *title_box;
toolbar = ephy_toolbar_new (window);
gtk_window_set_titlebar (GTK_WINDOW (window), toolbar);
@@ -3129,6 +3153,10 @@ setup_toolbar (EphyWindow *window)
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);
+
return toolbar;
}
@@ -3148,7 +3176,7 @@ setup_location_controller (EphyWindow *window,
g_signal_connect_swapped (location_controller, "open-link",
G_CALLBACK (ephy_link_open), window);
g_signal_connect (location_controller, "lock-clicked",
- G_CALLBACK (lock_clicked_cb), window);
+ G_CALLBACK (location_controller_lock_clicked_cb), window);
return location_controller;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]