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
=== modified file 'midori/midori-locationaction.c'
--- midori/midori-locationaction.c 2015-03-28 15:40:41 +0000
+++ midori/midori-locationaction.c 2015-04-18 18:22:36 +0000
@@ -26,10 +26,6 @@
2626
27#include <sqlite3.h>27#include <sqlite3.h>
2828
29#ifdef HAVE_GRANITE
30#include <granite/granite.h>
31#endif
32
33struct _MidoriLocationAction29struct _MidoriLocationAction
34{30{
35 GtkAction parent_instance;31 GtkAction parent_instance;
@@ -1369,7 +1365,60 @@
1369 "granting" : "revoking", error->message);1365 "granting" : "revoking", error->message);
1370 g_error_free (error);1366 g_error_free (error);
1371 }1367 }
1372 gtk_widget_destroy (dialog);1368 gtk_widget_hide (dialog);
1369}
1370#endif
1371
1372#if GTK_CHECK_VERSION (3, 12, 0)
1373static void
1374midori_location_action_button_cb (GtkWidget* button,
1375 GtkWidget* dialog)
1376{
1377 GcrCertificate* gcr_cert = g_object_get_data (G_OBJECT (dialog), "gcr-cert");
1378 const gchar* label = gtk_button_get_label (GTK_BUTTON (button));
1379 gint response;
1380 if (!strcmp (label, _("_Don't trust this website")))
1381 response = MIDORI_CERT_REVOKE;
1382 else if (!strcmp (label, _("_Trust this website")))
1383 response = MIDORI_CERT_TRUST;
1384 else if (!strcmp (label, _("_Export certificate")))
1385 response = MIDORI_CERT_EXPORT;
1386 else
1387 g_assert_not_reached ();
1388 midori_location_action_cert_response_cb (dialog, response, gcr_cert);
1389}
1390
1391static gboolean
1392midori_location_action_popover_button_press_event_cb (GtkWidget* widget,
1393 GdkEventButton* event,
1394 gpointer user_data)
1395{
1396 return GDK_EVENT_STOP;
1397}
1398
1399static gboolean
1400midori_location_action_popover_button_release_event_cb (GtkWidget* widget,
1401 GdkEventButton* event,
1402 gpointer user_data)
1403{
1404 /* The default GtkPopOver button-press doesn't work with
1405 GcrCertificateDetailsWidget and fails with an assertion:
1406 gtk_widget_is_ancestor: assertion 'GTK_IS_WIDGET (widget)' */
1407 GtkWidget* child = gtk_bin_get_child (GTK_BIN (widget));
1408 GtkWidget* event_widget = gtk_get_event_widget ((GdkEvent*)event);
1409 if (child && event->window == gtk_widget_get_window (widget))
1410 {
1411 GtkAllocation child_alloc;
1412 gtk_widget_get_allocation (child, &child_alloc);
1413 if (event->x < child_alloc.x ||
1414 event->x > child_alloc.x + child_alloc.width ||
1415 event->y < child_alloc.y ||
1416 event->y > child_alloc.y + child_alloc.height)
1417 gtk_widget_hide (widget);
1418 }
1419 else if (event_widget && !gtk_widget_is_ancestor (event_widget, widget))
1420 gtk_widget_hide (widget);
1421 return GDK_EVENT_STOP;
1373}1422}
1374#endif1423#endif
13751424
@@ -1437,6 +1486,27 @@
1437 gtk_container_add (GTK_CONTAINER (box), details);1486 gtk_container_add (GTK_CONTAINER (box), details);
1438 #endif1487 #endif
14391488
1489 #if GTK_CHECK_VERSION (3, 12, 0)
1490 GtkWidget* button;
1491 GtkWidget* actions = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
1492 gtk_box_pack_start (GTK_BOX (box), actions, FALSE, FALSE, 0);
1493 if (gcr_trust_is_certificate_pinned (gcr_cert, GCR_PURPOSE_SERVER_AUTH, hostname, NULL, NULL))
1494 {
1495 button = gtk_button_new_with_mnemonic (_("_Don't trust this website"));
1496 gtk_box_pack_start (GTK_BOX (actions), button, FALSE, FALSE, 0);
1497 g_signal_connect (button, "clicked", G_CALLBACK (midori_location_action_button_cb), dialog);
1498 }
1499 else if (tls_flags > 0)
1500 {
1501 button = gtk_button_new_with_mnemonic (_("_Trust this website"));
1502 gtk_box_pack_start (GTK_BOX (actions), button, FALSE, FALSE, 0);
1503 g_signal_connect (button, "clicked", G_CALLBACK (midori_location_action_button_cb), dialog);
1504 }
1505 button = gtk_button_new_with_mnemonic (_("_Export certificate"));
1506 g_signal_connect (button, "clicked", G_CALLBACK (midori_location_action_button_cb), dialog);
1507 gtk_box_pack_end (GTK_BOX (actions), button, FALSE, FALSE, 0);
1508 gtk_widget_show_all (actions);
1509 #else
1440 if (gcr_trust_is_certificate_pinned (gcr_cert, GCR_PURPOSE_SERVER_AUTH, hostname, NULL, NULL))1510 if (gcr_trust_is_certificate_pinned (gcr_cert, GCR_PURPOSE_SERVER_AUTH, hostname, NULL, NULL))
1441 gtk_dialog_add_buttons (GTK_DIALOG (dialog),1511 gtk_dialog_add_buttons (GTK_DIALOG (dialog),
1442 ("_Don't trust this website"), MIDORI_CERT_REVOKE, NULL);1512 ("_Don't trust this website"), MIDORI_CERT_REVOKE, NULL);
@@ -1446,11 +1516,12 @@
1446 gtk_container_child_set (GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (dialog))),1516 gtk_container_child_set (GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (dialog))),
1447 gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Export certificate"), MIDORI_CERT_EXPORT),1517 gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Export certificate"), MIDORI_CERT_EXPORT),
1448 "secondary", TRUE, NULL);1518 "secondary", TRUE, NULL);
1519 g_signal_connect (dialog, "response",
1520 G_CALLBACK (midori_location_action_cert_response_cb), gcr_cert);
1521 #endif
14491522
1450 g_object_set_data_full (G_OBJECT (gcr_cert), "peer", hostname, (GDestroyNotify)g_free);1523 g_object_set_data_full (G_OBJECT (gcr_cert), "peer", hostname, (GDestroyNotify)g_free);
1451 g_object_set_data_full (G_OBJECT (dialog), "gcr-cert", gcr_cert, (GDestroyNotify)g_object_unref);1524 g_object_set_data_full (G_OBJECT (dialog), "gcr-cert", gcr_cert, (GDestroyNotify)g_object_unref);
1452 g_signal_connect (dialog, "response",
1453 G_CALLBACK (midori_location_action_cert_response_cb), gcr_cert);
1454 #endif1525 #endif
14551526
1456 /* With GTK+2 the scrolled contents can't communicate a natural size to the window */1527 /* With GTK+2 the scrolled contents can't communicate a natural size to the window */
@@ -1511,37 +1582,32 @@
1511 return;1582 return;
1512 }1583 }
15131584
1514 const gchar* title = _("Security details");
1515 GtkWidget* content_area;1585 GtkWidget* content_area;
1516 GtkWidget* hbox;1586 GtkWidget* hbox;
1517 #ifdef HAVE_GRANITE1587
1518 gint wx, wy;1588 #if GTK_CHECK_VERSION (3, 12, 0)
1519 GtkAllocation allocation;1589 dialog = gtk_popover_new (widget);
1590 content_area = gtk_vbox_new (FALSE, 6);
1591 gtk_container_add (GTK_CONTAINER (dialog), content_area);
1592 g_signal_connect (dialog, "button-press-event",
1593 G_CALLBACK (midori_location_action_popover_button_press_event_cb), NULL);
1594 g_signal_connect (dialog, "button-release-event",
1595 G_CALLBACK (midori_location_action_popover_button_release_event_cb), NULL);
1596
1520 GdkRectangle icon_rect;1597 GdkRectangle icon_rect;
1521
1522 /* FIXME: granite: should return GtkWidget* like GTK+ */
1523 dialog = (GtkWidget*)granite_widgets_pop_over_new ();
1524 gchar* markup = g_strdup_printf ("<b>%s</b>", title);
1525 GtkWidget* label = gtk_label_new (markup);
1526 content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
1527 g_free (markup);
1528 gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
1529 gtk_box_pack_start (GTK_BOX (content_area), label, FALSE, FALSE, 0);
1530
1531 gtk_widget_get_allocation (widget, &allocation);
1532 gdk_window_get_origin (gtk_widget_get_window (widget), &wx, &wy);
1533 wx += allocation.x;
1534 gtk_entry_get_icon_area (GTK_ENTRY (widget), icon_pos, &icon_rect);1598 gtk_entry_get_icon_area (GTK_ENTRY (widget), icon_pos, &icon_rect);
1535 wx += (icon_rect.x + icon_rect.width / 2);1599 gtk_popover_set_relative_to (GTK_POPOVER (dialog), widget);
1536 wy += (icon_rect.y + icon_rect.height);1600 gtk_popover_set_pointing_to (GTK_POPOVER (dialog), &icon_rect);
1537 granite_widgets_pop_over_move_to_coords (GRANITE_WIDGETS_POP_OVER (dialog),1601 g_signal_connect (dialog, "closed", G_CALLBACK (gtk_widget_destroyed), &dialog);
1538 wx, wy, TRUE);
1539 #else1602 #else
1603 const gchar* title = _("Security details");
1540 dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (gtk_widget_get_toplevel (widget)),1604 dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (gtk_widget_get_toplevel (widget)),
1541 GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, NULL, NULL);1605 GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, NULL, NULL);
1542 content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));1606 content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
1607 g_signal_connect (dialog, "destroy", G_CALLBACK (gtk_widget_destroyed), &dialog);
1543 #endif1608 #endif
1544 hbox = gtk_hbox_new (FALSE, 0);1609 gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
1610 hbox = gtk_hbox_new (FALSE, 6);
1545 gtk_box_pack_start (GTK_BOX (hbox), gtk_image_new_from_gicon (1611 gtk_box_pack_start (GTK_BOX (hbox), gtk_image_new_from_gicon (
1546 gtk_entry_get_icon_gicon (GTK_ENTRY (widget), icon_pos), GTK_ICON_SIZE_DIALOG), FALSE, FALSE, 0);1612 gtk_entry_get_icon_gicon (GTK_ENTRY (widget), icon_pos), GTK_ICON_SIZE_DIALOG), FALSE, FALSE, 0);
1547 gtk_box_pack_start (GTK_BOX (hbox),1613 gtk_box_pack_start (GTK_BOX (hbox),
@@ -1550,7 +1616,6 @@
1550 #ifdef HAVE_LIBSOUP_2_34_01616 #ifdef HAVE_LIBSOUP_2_34_0
1551 midori_location_action_show_page_info (widget, GTK_BOX (content_area), dialog);1617 midori_location_action_show_page_info (widget, GTK_BOX (content_area), dialog);
1552 #endif1618 #endif
1553 g_signal_connect (dialog, "destroy", G_CALLBACK (gtk_widget_destroyed), &dialog);
1554 gtk_widget_show_all (dialog);1619 gtk_widget_show_all (dialog);
1555 }1620 }
1556 if (icon_pos == GTK_ENTRY_ICON_SECONDARY)1621 if (icon_pos == GTK_ENTRY_ICON_SECONDARY)

Subscribers

People subscribed via source and target branches

to all changes: