[balsa/wip/gtk4: 8/351] Fix gpgme-related files



commit 9fd2134c26f54dba3c085383575318cf44d971fd
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Wed Oct 4 10:14:31 2017 -0400

    Fix gpgme-related files

 libbalsa/libbalsa-gpgme-cb.c   |   41 ++++++++++++++++++++++-----------------
 src/balsa-mime-widget-crypto.c |   31 +++++++++++++++--------------
 2 files changed, 39 insertions(+), 33 deletions(-)
---
diff --git a/libbalsa/libbalsa-gpgme-cb.c b/libbalsa/libbalsa-gpgme-cb.c
index b3320c9..5632203 100644
--- a/libbalsa/libbalsa-gpgme-cb.c
+++ b/libbalsa/libbalsa-gpgme-cb.c
@@ -125,26 +125,25 @@ lb_gpgme_passphrase(void *hook, const gchar * uid_hint,
 }
 
 
-static gboolean
-key_button_event_press_cb(GtkWidget * widget,
-                          GdkEvent  * event,
-                          gpointer    data)
+static void
+tree_view_multi_press_cb(GtkGestureMultiPress * gesture,
+                         gint                   n_press,
+                         gdouble                x,
+                         gdouble                y,
+                         gpointer               user_data)
 {
-    GtkTreeView *tree_view = GTK_TREE_VIEW(widget);
+    GtkTreeView *tree_view = g_object_get_data(G_OBJECT(gesture), "tree-view-gesture");
     GtkTreeSelection *selection = gtk_tree_view_get_selection(tree_view);
     GtkTreePath *path;
     GtkTreeIter iter;
     GtkTreeModel *model;
-    gdouble x_win, y_win;
 
-    g_return_val_if_fail(event != NULL, FALSE);
-
-    if (gdk_event_get_event_type(event) != GDK_2BUTTON_PRESS ||
-        !gdk_event_get_coords(event, &x_win, &y_win)) {
-        return FALSE;
+    if (n_press != 2) {
+        return;
     }
+    gtk_gesture_set_state(GTK_GESTURE(gesture), GTK_EVENT_SEQUENCE_CLAIMED);
 
-    if (gtk_tree_view_get_path_at_pos(tree_view, (gint) x_win, (gint) y_win, &path, NULL, NULL, NULL)) {
+    if (gtk_tree_view_get_path_at_pos(tree_view, (gint) x, (gint) y, &path, NULL, NULL, NULL)) {
         if (!gtk_tree_selection_path_is_selected(selection, path)) {
             gtk_tree_view_set_cursor(tree_view, path, NULL, FALSE);
             gtk_tree_view_scroll_to_cell(tree_view, path, NULL, FALSE, 0, 0);
@@ -156,13 +155,13 @@ key_button_event_press_cb(GtkWidget * widget,
        gpgme_key_t key;
        GtkWidget *dialog;
 
-               gtk_tree_model_get(model, &iter, GPG_KEY_PTR_COLUMN, &key, -1);
-               dialog = libbalsa_key_dialog(GTK_WINDOW(data), GTK_BUTTONS_CLOSE, key, GPG_SUBKEY_CAP_ALL, 
NULL, NULL);
-               (void) gtk_dialog_run(GTK_DIALOG(dialog));
-               gtk_widget_destroy(dialog);
+        gtk_tree_model_get(model, &iter, GPG_KEY_PTR_COLUMN, &key, -1);
+        dialog = libbalsa_key_dialog(GTK_WINDOW(user_data), GTK_BUTTONS_CLOSE, key, GPG_SUBKEY_CAP_ALL, 
NULL, NULL);
+        (void) gtk_dialog_run(GTK_DIALOG(dialog));
+        gtk_widget_destroy(dialog);
     }
 
-    return TRUE;
+    return;
 }
 
 
@@ -184,6 +183,7 @@ lb_gpgme_select_key(const gchar * user_name, lb_key_sel_md_t mode, GList * keys,
     gint width, height;
        GtkCellRenderer *renderer;
        GtkTreeViewColumn *column;
+    GtkGesture *gesture;
 
     /* FIXME: create dialog according to the Gnome HIG */
     dialog = gtk_dialog_new_with_buttons(_("Select key"),
@@ -286,7 +286,12 @@ lb_gpgme_select_key(const gchar * user_name, lb_key_sel_md_t mode, GList * keys,
        gtk_tree_view_column_set_resizable(column, TRUE);
 
     gtk_container_add(GTK_CONTAINER(scrolled_window), tree_view);
-    g_signal_connect(tree_view, "button_press_event", G_CALLBACK(key_button_event_press_cb), dialog);
+
+    gesture = gtk_gesture_multi_press_new(tree_view);
+    g_object_set_data_full(G_OBJECT(tree_view), "tree-view-gesture",
+                           gesture, g_object_unref);
+    g_object_set_data(G_OBJECT(gesture), "tree-view-gesture", tree_view);
+    g_signal_connect(gesture, "pressed", G_CALLBACK(tree_view_multi_press_cb), dialog);
 
     /* set window size to 2/3 of the parent */
     gtk_window_get_size(parent, &width, &height);
diff --git a/src/balsa-mime-widget-crypto.c b/src/balsa-mime-widget-crypto.c
index 0ce7189..8c499b6 100644
--- a/src/balsa-mime-widget-crypto.c
+++ b/src/balsa-mime-widget-crypto.c
@@ -117,13 +117,13 @@ balsa_mime_widget_signature_widget(LibBalsaMessageBody * mime_body,
     label = gtk_label_new((lines[1] != NULL) ? lines[1] : lines[0]);
     gtk_label_set_selectable(GTK_LABEL(label), TRUE);
     gtk_widget_set_halign(label, GTK_ALIGN_START);
-    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(vbox), label);
     if (mime_body->sig_info->key != NULL) {
        GtkWidget *key_widget;
 
        /* show only the subkey which has been used to sign the message */
        key_widget = libbalsa_gpgme_key(mime_body->sig_info->key, mime_body->sig_info->fingerprint, 0U, 
FALSE);
-        gtk_box_pack_start(GTK_BOX(vbox), key_widget, FALSE, FALSE, 0);
+        gtk_box_pack_start(GTK_BOX(vbox), key_widget);
     }
     if (mime_body->sig_info->protocol == GPGME_PROTOCOL_OpenPGP) {
         GtkWidget *button;
@@ -136,7 +136,7 @@ balsa_mime_widget_signature_widget(LibBalsaMessageBody * mime_body,
         g_signal_connect(G_OBJECT(button), "clicked",
                          G_CALLBACK(on_gpg_key_button),
                          (gpointer)mime_body->sig_info->fingerprint);
-        gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
+        gtk_box_pack_start(GTK_BOX(vbox), button);
     }
 
     if (lines[1] != NULL) {
@@ -153,7 +153,7 @@ balsa_mime_widget_signature_widget(LibBalsaMessageBody * mime_body,
     } else {
         signature_widget = vbox;
     }
-    gtk_container_set_border_width(GTK_CONTAINER(signature_widget), BMW_CONTAINER_BORDER);
+    g_object_set(G_OBJECT(signature_widget), "margin", BMW_CONTAINER_BORDER, NULL);
 
     g_strfreev(lines);
 
@@ -178,8 +178,7 @@ balsa_mime_widget_crypto_frame(LibBalsaMessageBody * mime_body, GtkWidget * chil
         gtk_box_pack_start(GTK_BOX(icon_box),
                            gtk_image_new_from_icon_name
                            (balsa_icon_id(BALSA_PIXMAP_ENCR),
-                            GTK_ICON_SIZE_MENU),
-                           FALSE, FALSE, 0);
+                            GTK_ICON_SIZE_MENU));
     if (!no_signature) {
        const gchar * icon_name =
            balsa_mime_widget_signature_icon_name(libbalsa_message_body_protect_state(mime_body));
@@ -187,16 +186,15 @@ balsa_mime_widget_crypto_frame(LibBalsaMessageBody * mime_body, GtkWidget * chil
            icon_name = BALSA_PIXMAP_SIGN;
         gtk_box_pack_start(GTK_BOX(icon_box),
                            gtk_image_new_from_icon_name
-                           (balsa_icon_id(icon_name), GTK_ICON_SIZE_MENU),
-                           FALSE, FALSE, 0);
+                           (balsa_icon_id(icon_name), GTK_ICON_SIZE_MENU));
     }
     gtk_frame_set_label_widget(GTK_FRAME(frame), icon_box);
-    gtk_container_set_border_width(GTK_CONTAINER(vbox), BMW_MESSAGE_PADDING);
+    g_object_set(G_OBJECT(vbox), "margin", BMW_MESSAGE_PADDING, NULL);
 
-    gtk_box_pack_start(GTK_BOX(vbox), child, FALSE, FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(vbox), child);
 
     if (signature) {
-       gtk_box_pack_end(GTK_BOX(vbox), signature, FALSE, FALSE, 0);
+       gtk_box_pack_end(GTK_BOX(vbox), signature);
     }
 
     return frame;
@@ -312,16 +310,19 @@ create_import_keys_widget(GtkBox *box, const gchar *key_buf, GError **error)
                                                success = FALSE;
                                        } else {
                                                key_widget = libbalsa_gpgme_key(this_key, NULL, 
GPG_SUBKEY_CAP_ALL, FALSE);
-                                               gtk_box_pack_start(box, key_widget, FALSE, FALSE, 0);
+                                               gtk_box_pack_start(box, key_widget);
 
                                                import_btn = gtk_button_new_with_label(_("Import key into the 
local key ring"));
                                                g_object_set_data_full(G_OBJECT(import_btn), "keydata", 
key_ascii, (GDestroyNotify) g_free);
                                                g_signal_connect(G_OBJECT(import_btn), "clicked", (GCallback) 
on_key_import_button, NULL);
-                                               gtk_box_pack_start(box, import_btn, FALSE, FALSE, 0);
+                                               gtk_box_pack_start(box, import_btn);
 
                                                if (item->next != NULL) {
-                                                       gtk_box_pack_start(box, 
gtk_separator_new(GTK_ORIENTATION_HORIZONTAL), FALSE, FALSE,
-                                                               BMW_VBOX_SPACE);
+                                                    GtkWidget *separator;
+
+                                                       separator = 
gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
+                                                        gtk_widget_set_margin_top(separator, BMW_VBOX_SPACE);
+                                                       gtk_box_pack_start(box, separator);
                                                }
                                        }
                                }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]