Merge lp:~midori/midori/alcoPops2 into lp:midori

Proposed by Cris Dywan
Status: Merged
Approved by: Paweł Forysiuk
Approved revision: 6913
Merged at revision: 6933
Proposed branch: lp:~midori/midori/alcoPops2
Merge into: lp:midori
Diff against target: 182 lines (+95/-30)
1 file modified
midori/midori-locationaction.c (+95/-30)
To merge this branch: bzr merge lp:~midori/midori/alcoPops2
Reviewer Review Type Date Requested Status
Paweł Forysiuk Approve
Danielle Foré (community) Needs Fixing
Review via email: mp+253901@code.launchpad.net

Commit message

Port location action from Granite.PopOver to Gtk.Popover

To post a comment you must log in.
Revision history for this message
Danielle Foré (danrabbit) wrote :

Clicking "Details" closes the popover. This is a regression.

The layout is pretty funky. I would suggest using the kind of standard dialog layout used by GNOME and elementary where you have the primary text and secondary text next to the icon. Dialogs don't have titles. http://elementary.io/docs/human-interface-guidelines/dialogs But it's already like this is trunk, so I guess it's not a blocker.

review: Needs Fixing
Revision history for this message
Danielle Foré (danrabbit) wrote :

midori-locationaction.c:1547:22: error: unused variable ‘title’ [-Werror=unused-variable]
         const gchar* title = _("Security details");
                      ^
Oops :p

Revision history for this message
Danielle Foré (danrabbit) wrote :

Still closes with (midori4:29631): Gtk-CRITICAL **: gtk_widget_is_ancestor: assertion 'GTK_IS_WIDGET (widget)' failed when you click the "details" bit.

I think I liked the right-aligned position of the "Export certificate" button more. This is more in line with where the typical action area is in dialogs/popovers.

As an aside, usually button labels are title case. So it'd be "Export Certificate"

review: Needs Fixing
Revision history for this message
Cris Dywan (kalikiana) wrote :

I reversed the buttons and found a solution for the assertion.

I did not change the button label because we want to release - so I'd rather do this separately to avoid screwing up all localizations.

lp:~midori/midori/alcoPops2 updated
6912. By Cris Dywan

Merge lp:midori

Revision history for this message
Danielle Foré (danrabbit) wrote :

Works in Gtk3, but there's no content besides "verified and encrypted connection" in gtk2

lp:~midori/midori/alcoPops2 updated
6913. By Cris Dywan

Consider popover child widget allocation

Revision history for this message
Paweł Forysiuk (tuxator) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'midori/midori-locationaction.c'
2--- midori/midori-locationaction.c 2015-03-28 15:40:41 +0000
3+++ midori/midori-locationaction.c 2015-04-18 18:22:36 +0000
4@@ -26,10 +26,6 @@
5
6 #include <sqlite3.h>
7
8-#ifdef HAVE_GRANITE
9-#include <granite/granite.h>
10-#endif
11-
12 struct _MidoriLocationAction
13 {
14 GtkAction parent_instance;
15@@ -1369,7 +1365,60 @@
16 "granting" : "revoking", error->message);
17 g_error_free (error);
18 }
19- gtk_widget_destroy (dialog);
20+ gtk_widget_hide (dialog);
21+}
22+#endif
23+
24+#if GTK_CHECK_VERSION (3, 12, 0)
25+static void
26+midori_location_action_button_cb (GtkWidget* button,
27+ GtkWidget* dialog)
28+{
29+ GcrCertificate* gcr_cert = g_object_get_data (G_OBJECT (dialog), "gcr-cert");
30+ const gchar* label = gtk_button_get_label (GTK_BUTTON (button));
31+ gint response;
32+ if (!strcmp (label, _("_Don't trust this website")))
33+ response = MIDORI_CERT_REVOKE;
34+ else if (!strcmp (label, _("_Trust this website")))
35+ response = MIDORI_CERT_TRUST;
36+ else if (!strcmp (label, _("_Export certificate")))
37+ response = MIDORI_CERT_EXPORT;
38+ else
39+ g_assert_not_reached ();
40+ midori_location_action_cert_response_cb (dialog, response, gcr_cert);
41+}
42+
43+static gboolean
44+midori_location_action_popover_button_press_event_cb (GtkWidget* widget,
45+ GdkEventButton* event,
46+ gpointer user_data)
47+{
48+ return GDK_EVENT_STOP;
49+}
50+
51+static gboolean
52+midori_location_action_popover_button_release_event_cb (GtkWidget* widget,
53+ GdkEventButton* event,
54+ gpointer user_data)
55+{
56+ /* The default GtkPopOver button-press doesn't work with
57+ GcrCertificateDetailsWidget and fails with an assertion:
58+ gtk_widget_is_ancestor: assertion 'GTK_IS_WIDGET (widget)' */
59+ GtkWidget* child = gtk_bin_get_child (GTK_BIN (widget));
60+ GtkWidget* event_widget = gtk_get_event_widget ((GdkEvent*)event);
61+ if (child && event->window == gtk_widget_get_window (widget))
62+ {
63+ GtkAllocation child_alloc;
64+ gtk_widget_get_allocation (child, &child_alloc);
65+ if (event->x < child_alloc.x ||
66+ event->x > child_alloc.x + child_alloc.width ||
67+ event->y < child_alloc.y ||
68+ event->y > child_alloc.y + child_alloc.height)
69+ gtk_widget_hide (widget);
70+ }
71+ else if (event_widget && !gtk_widget_is_ancestor (event_widget, widget))
72+ gtk_widget_hide (widget);
73+ return GDK_EVENT_STOP;
74 }
75 #endif
76
77@@ -1437,6 +1486,27 @@
78 gtk_container_add (GTK_CONTAINER (box), details);
79 #endif
80
81+ #if GTK_CHECK_VERSION (3, 12, 0)
82+ GtkWidget* button;
83+ GtkWidget* actions = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
84+ gtk_box_pack_start (GTK_BOX (box), actions, FALSE, FALSE, 0);
85+ if (gcr_trust_is_certificate_pinned (gcr_cert, GCR_PURPOSE_SERVER_AUTH, hostname, NULL, NULL))
86+ {
87+ button = gtk_button_new_with_mnemonic (_("_Don't trust this website"));
88+ gtk_box_pack_start (GTK_BOX (actions), button, FALSE, FALSE, 0);
89+ g_signal_connect (button, "clicked", G_CALLBACK (midori_location_action_button_cb), dialog);
90+ }
91+ else if (tls_flags > 0)
92+ {
93+ button = gtk_button_new_with_mnemonic (_("_Trust this website"));
94+ gtk_box_pack_start (GTK_BOX (actions), button, FALSE, FALSE, 0);
95+ g_signal_connect (button, "clicked", G_CALLBACK (midori_location_action_button_cb), dialog);
96+ }
97+ button = gtk_button_new_with_mnemonic (_("_Export certificate"));
98+ g_signal_connect (button, "clicked", G_CALLBACK (midori_location_action_button_cb), dialog);
99+ gtk_box_pack_end (GTK_BOX (actions), button, FALSE, FALSE, 0);
100+ gtk_widget_show_all (actions);
101+ #else
102 if (gcr_trust_is_certificate_pinned (gcr_cert, GCR_PURPOSE_SERVER_AUTH, hostname, NULL, NULL))
103 gtk_dialog_add_buttons (GTK_DIALOG (dialog),
104 ("_Don't trust this website"), MIDORI_CERT_REVOKE, NULL);
105@@ -1446,11 +1516,12 @@
106 gtk_container_child_set (GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (dialog))),
107 gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Export certificate"), MIDORI_CERT_EXPORT),
108 "secondary", TRUE, NULL);
109+ g_signal_connect (dialog, "response",
110+ G_CALLBACK (midori_location_action_cert_response_cb), gcr_cert);
111+ #endif
112
113 g_object_set_data_full (G_OBJECT (gcr_cert), "peer", hostname, (GDestroyNotify)g_free);
114 g_object_set_data_full (G_OBJECT (dialog), "gcr-cert", gcr_cert, (GDestroyNotify)g_object_unref);
115- g_signal_connect (dialog, "response",
116- G_CALLBACK (midori_location_action_cert_response_cb), gcr_cert);
117 #endif
118
119 /* With GTK+2 the scrolled contents can't communicate a natural size to the window */
120@@ -1511,37 +1582,32 @@
121 return;
122 }
123
124- const gchar* title = _("Security details");
125 GtkWidget* content_area;
126 GtkWidget* hbox;
127- #ifdef HAVE_GRANITE
128- gint wx, wy;
129- GtkAllocation allocation;
130+
131+ #if GTK_CHECK_VERSION (3, 12, 0)
132+ dialog = gtk_popover_new (widget);
133+ content_area = gtk_vbox_new (FALSE, 6);
134+ gtk_container_add (GTK_CONTAINER (dialog), content_area);
135+ g_signal_connect (dialog, "button-press-event",
136+ G_CALLBACK (midori_location_action_popover_button_press_event_cb), NULL);
137+ g_signal_connect (dialog, "button-release-event",
138+ G_CALLBACK (midori_location_action_popover_button_release_event_cb), NULL);
139+
140 GdkRectangle icon_rect;
141-
142- /* FIXME: granite: should return GtkWidget* like GTK+ */
143- dialog = (GtkWidget*)granite_widgets_pop_over_new ();
144- gchar* markup = g_strdup_printf ("<b>%s</b>", title);
145- GtkWidget* label = gtk_label_new (markup);
146- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
147- g_free (markup);
148- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
149- gtk_box_pack_start (GTK_BOX (content_area), label, FALSE, FALSE, 0);
150-
151- gtk_widget_get_allocation (widget, &allocation);
152- gdk_window_get_origin (gtk_widget_get_window (widget), &wx, &wy);
153- wx += allocation.x;
154 gtk_entry_get_icon_area (GTK_ENTRY (widget), icon_pos, &icon_rect);
155- wx += (icon_rect.x + icon_rect.width / 2);
156- wy += (icon_rect.y + icon_rect.height);
157- granite_widgets_pop_over_move_to_coords (GRANITE_WIDGETS_POP_OVER (dialog),
158- wx, wy, TRUE);
159+ gtk_popover_set_relative_to (GTK_POPOVER (dialog), widget);
160+ gtk_popover_set_pointing_to (GTK_POPOVER (dialog), &icon_rect);
161+ g_signal_connect (dialog, "closed", G_CALLBACK (gtk_widget_destroyed), &dialog);
162 #else
163+ const gchar* title = _("Security details");
164 dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (gtk_widget_get_toplevel (widget)),
165 GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, NULL, NULL);
166 content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
167+ g_signal_connect (dialog, "destroy", G_CALLBACK (gtk_widget_destroyed), &dialog);
168 #endif
169- hbox = gtk_hbox_new (FALSE, 0);
170+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
171+ hbox = gtk_hbox_new (FALSE, 6);
172 gtk_box_pack_start (GTK_BOX (hbox), gtk_image_new_from_gicon (
173 gtk_entry_get_icon_gicon (GTK_ENTRY (widget), icon_pos), GTK_ICON_SIZE_DIALOG), FALSE, FALSE, 0);
174 gtk_box_pack_start (GTK_BOX (hbox),
175@@ -1550,7 +1616,6 @@
176 #ifdef HAVE_LIBSOUP_2_34_0
177 midori_location_action_show_page_info (widget, GTK_BOX (content_area), dialog);
178 #endif
179- g_signal_connect (dialog, "destroy", G_CALLBACK (gtk_widget_destroyed), &dialog);
180 gtk_widget_show_all (dialog);
181 }
182 if (icon_pos == GTK_ENTRY_ICON_SECONDARY)

Subscribers

People subscribed via source and target branches

to all changes: