[balsa] Fix deprecation issues in gtk 3.22



commit 85a3ad9d5f6a28c3f4c9d1e0c85c9ec0335b7a53
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Fri Oct 21 22:25:55 2016 -0400

    Fix deprecation issues in gtk 3.22
    
        The Gtk+ API for popping up context menus has changed in 3.22;
        gtk_menu_popup is deprecated.
    
        * src/balsa-index.c (bndx_do_popup):
        * src/balsa-mblist.c (bmbl_do_popup):
        * src/balsa-message.c (balsa_headers_attachments_popup),
        (tree_mult_selection_popup), (tree_button_press_cb):
        * src/balsa-mime-widget-image.c (balsa_image_button_press_cb):
        * src/balsa-mime-widget-text.c (balsa_gtk_html_popup):
        * src/pref-manager.c (address_book_add_cb), (server_add_cb):
        * src/sendmsg-window.c (attachment_button_press_cb),
        (attachment_popup_cb):
        * src/toolbar-factory.c (tm_do_popup_menu):

 ChangeLog                     |   18 ++++++++++++++++++
 src/balsa-index.c             |   11 +++++++++++
 src/balsa-mblist.c            |   13 +++++++++++++
 src/balsa-message.c           |   34 ++++++++++++++++++++++++++++++++++
 src/balsa-mime-widget-image.c |    4 ++++
 src/balsa-mime-widget-text.c  |   15 +++++++++++++++
 src/pref-manager.c            |   12 ++++++++++++
 src/sendmsg-window.c          |   12 ++++++++++++
 src/toolbar-factory.c         |   16 ++++++++++++++++
 9 files changed, 135 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 49a1302..7568551 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2016-10-21  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       Fix deprecation issues in gtk 3.22
+
+       The Gtk+ API for popping up context menus has changed in 3.22;
+       gtk_menu_popup is deprecated.
+
+       * src/balsa-index.c (bndx_do_popup):
+       * src/balsa-mblist.c (bmbl_do_popup):
+       * src/balsa-message.c (balsa_headers_attachments_popup),
+       (tree_mult_selection_popup), (tree_button_press_cb):
+       * src/balsa-mime-widget-image.c (balsa_image_button_press_cb):
+       * src/balsa-mime-widget-text.c (balsa_gtk_html_popup):
+       * src/pref-manager.c (address_book_add_cb), (server_add_cb):
+       * src/sendmsg-window.c (attachment_button_press_cb),
+       (attachment_popup_cb):
+       * src/toolbar-factory.c (tm_do_popup_menu):
+
 2016-10-18  Albrecht Dreß
 
        Usually, RFC 3156 (PGP/MIME) signature parts
diff --git a/src/balsa-index.c b/src/balsa-index.c
index 1a4f815..f9c0330 100644
--- a/src/balsa-index.c
+++ b/src/balsa-index.c
@@ -1882,6 +1882,7 @@ bndx_popup_menu_create(BalsaIndex * index)
 /* If the menu is popped up in response to a keystroke, center it
  * below the headers of the tree-view.
  */
+#if !GTK_CHECK_VERSION(3, 22, 0)
 static void
 bndx_popup_position_func(GtkMenu * menu, gint * x, gint * y,
                          gboolean * push_in, gpointer user_data)
@@ -1914,6 +1915,7 @@ bndx_popup_position_func(GtkMenu * menu, gint * x, gint * y,
 
     *push_in = FALSE;
 }
+#endif                          /*GTK_CHECK_VERSION(3, 22, 0) */
 
 static void
 bndx_do_popup(BalsaIndex * index, GdkEventButton * event)
@@ -1971,6 +1973,14 @@ bndx_do_popup(BalsaIndex * index, GdkEventButton * event)
 
     gtk_widget_show_all(menu);
 
+#if GTK_CHECK_VERSION(3, 22, 0)
+    if (event)
+        gtk_menu_popup_at_pointer(GTK_MENU(menu), (GdkEvent *) event);
+    else
+        gtk_menu_popup_at_widget(GTK_MENU(menu), GTK_WIDGET(index),
+                                 GDK_GRAVITY_CENTER, GDK_GRAVITY_CENTER,
+                                 NULL);
+#else                           /*GTK_CHECK_VERSION(3, 22, 0) */
     if (event)
         gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
                        event->button, event->time);
@@ -1978,6 +1988,7 @@ bndx_do_popup(BalsaIndex * index, GdkEventButton * event)
         gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
                        bndx_popup_position_func, index,
                        0, gtk_get_current_event_time());
+#endif                          /*GTK_CHECK_VERSION(3, 22, 0) */
 }
 
 static GtkWidget *
diff --git a/src/balsa-mblist.c b/src/balsa-mblist.c
index d8927a9..68444ba 100644
--- a/src/balsa-mblist.c
+++ b/src/balsa-mblist.c
@@ -728,8 +728,10 @@ bmbl_do_popup(GtkTreeView * tree_view, GtkTreePath * path,
               GdkEventButton * event)
 {
     BalsaMailboxNode *mbnode = NULL;
+#if !GTK_CHECK_VERSION(3, 22, 0)
     gint event_button;
     guint event_time;
+#endif                          /*GTK_CHECK_VERSION(3, 22, 0) */
     GtkWidget *menu;
 
     if (path) {
@@ -741,6 +743,7 @@ bmbl_do_popup(GtkTreeView * tree_view, GtkTreePath * path,
         gtk_tree_path_free(path);
     }
 
+#if !GTK_CHECK_VERSION(3, 22, 0)
     if (event) {
         event_button = event->button;
         event_time = event->time;
@@ -748,12 +751,22 @@ bmbl_do_popup(GtkTreeView * tree_view, GtkTreePath * path,
         event_button = 0;
         event_time = gtk_get_current_event_time();
     }
+#endif                          /*GTK_CHECK_VERSION(3, 22, 0) */
 
     menu = balsa_mailbox_node_get_context_menu(mbnode);
     g_object_ref(menu);
     g_object_ref_sink(menu);
+#if GTK_CHECK_VERSION(3, 22, 0)
+    if (event)
+        gtk_menu_popup_at_pointer(GTK_MENU(menu), (GdkEvent *) event);
+    else
+        gtk_menu_popup_at_widget(GTK_MENU(menu), GTK_WIDGET(tree_view),
+                                 GDK_GRAVITY_CENTER, GDK_GRAVITY_CENTER,
+                                 NULL);
+#else                           /*GTK_CHECK_VERSION(3, 22, 0) */
     gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
                   event_button, event_time);
+#endif                          /*GTK_CHECK_VERSION(3, 22, 0) */
     g_object_unref(menu);
 
     if (mbnode)
diff --git a/src/balsa-message.c b/src/balsa-message.c
index 1b74b58..0cc5fea 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -255,8 +255,15 @@ static void
 balsa_headers_attachments_popup(GtkButton * button, BalsaMessage * bm)
 {
     if (bm->parts_popup)
+#if GTK_CHECK_VERSION(3, 22, 0)
+        gtk_menu_popup_at_widget(GTK_MENU(bm->parts_popup),
+                                 GTK_WIDGET(bm),
+                                 GDK_GRAVITY_CENTER, GDK_GRAVITY_CENTER,
+                                 NULL);
+#else                           /*GTK_CHECK_VERSION(3, 22, 0) */
        gtk_menu_popup(GTK_MENU(bm->parts_popup), NULL, NULL, NULL, NULL, 0,
                       gtk_get_current_event_time());
+#endif                          /*GTK_CHECK_VERSION(3, 22, 0) */
 }
 
 
@@ -953,12 +960,23 @@ tree_mult_selection_popup(BalsaMessage * bm, GdkEventButton * event,
     if (selected == 1) {
         BalsaPartInfo *info = BALSA_PART_INFO(bm->save_all_list->data);
         if (info->popup_menu) {
+#if GTK_CHECK_VERSION(3, 22, 0)
+            if (event)
+                gtk_menu_popup_at_pointer(GTK_MENU(info->popup_menu),
+                                          (GdkEvent *) event);
+            else
+                gtk_menu_popup_at_widget(GTK_MENU(info->popup_menu),
+                                         GTK_WIDGET(bm),
+                                         GDK_GRAVITY_CENTER, GDK_GRAVITY_CENTER,
+                                         NULL);
+#else                           /*GTK_CHECK_VERSION(3, 22, 0) */
             if (event)
                 gtk_menu_popup(GTK_MENU(info->popup_menu), NULL, NULL, NULL,
                                NULL, event->button, event->time);
             else
                 gtk_menu_popup(GTK_MENU(info->popup_menu), NULL, NULL, NULL,
                                NULL, 0, gtk_get_current_event_time());
+#endif                          /*GTK_CHECK_VERSION(3, 22, 0) */
         }
         g_list_free(bm->save_all_list);
         bm->save_all_list = NULL;
@@ -981,12 +999,23 @@ tree_mult_selection_popup(BalsaMessage * bm, GdkEventButton * event,
                           G_CALLBACK (part_context_dump_all_cb),
                           (gpointer) bm->save_all_list);
         gtk_menu_shell_append (GTK_MENU_SHELL (bm->save_all_popup), menu_item);
+#if GTK_CHECK_VERSION(3, 22, 0)
+        if (event)
+            gtk_menu_popup_at_pointer(GTK_MENU(bm->save_all_popup),
+                                      (GdkEvent *) event);
+        else
+            gtk_menu_popup_at_widget(GTK_MENU(bm->save_all_popup),
+                                     GTK_WIDGET(bm),
+                                     GDK_GRAVITY_CENTER, GDK_GRAVITY_CENTER,
+                                     NULL);
+#else                           /*GTK_CHECK_VERSION(3, 22, 0) */
         if (event)
             gtk_menu_popup(GTK_MENU(bm->save_all_popup), NULL, NULL, NULL,
                            NULL, event->button, event->time);
         else
             gtk_menu_popup(GTK_MENU(bm->save_all_popup), NULL, NULL, NULL,
                            NULL, 0, gtk_get_current_event_time());
+#endif                          /*GTK_CHECK_VERSION(3, 22, 0) */
     }
 }
 
@@ -1039,8 +1068,13 @@ tree_button_press_cb(GtkWidget * widget, GdkEventButton * event,
                 gtk_tree_model_get(model, &iter, PART_INFO_COLUMN, &info, -1);
                 if (info) {
                     if (info->popup_menu)
+#if GTK_CHECK_VERSION(3, 22, 0)
+                        gtk_menu_popup_at_pointer(GTK_MENU(info->popup_menu),
+                                                  (GdkEvent *) event);
+#else                           /*GTK_CHECK_VERSION(3, 22, 0) */
                         gtk_menu_popup(GTK_MENU(info->popup_menu), NULL, NULL,
                                        NULL, NULL, event->button, event->time);
+#endif                          /*GTK_CHECK_VERSION(3, 22, 0) */
                     g_object_unref(info);
                 }
             }
diff --git a/src/balsa-mime-widget-image.c b/src/balsa-mime-widget-image.c
index f701b58..5e373bc 100644
--- a/src/balsa-mime-widget-image.c
+++ b/src/balsa-mime-widget-image.c
@@ -177,8 +177,12 @@ balsa_image_button_press_cb(GtkWidget * widget, GdkEventButton * event,
                             GtkMenu * menu)
 {
     if (menu && event->type == GDK_BUTTON_PRESS && event->button == 3) {
+#if GTK_CHECK_VERSION(3, 22, 0)
+        gtk_menu_popup_at_pointer(menu, (GdkEvent *) event);
+#else                           /*GTK_CHECK_VERSION(3, 22, 0) */
         gtk_menu_popup(menu, NULL, NULL, NULL, NULL,
                        event->button, event->time);
+#endif                          /*GTK_CHECK_VERSION(3, 22, 0) */
         return TRUE;
     } else
         return FALSE;
diff --git a/src/balsa-mime-widget-text.c b/src/balsa-mime-widget-text.c
index 04b7ca0..a977f55 100644
--- a/src/balsa-mime-widget-text.c
+++ b/src/balsa-mime-widget-text.c
@@ -1097,8 +1097,10 @@ balsa_gtk_html_popup(GtkWidget * html, BalsaMessage * bm)
     GtkWidget *menu;
     const GdkEvent *event;
     GdkEvent *current_event = NULL;
+#if !GTK_CHECK_VERSION(3, 22, 0)
     guint32 time;
     guint button;
+#endif                          /*GTK_CHECK_VERSION(3, 22, 0) */
 
     menu = gtk_menu_new();
     bmwt_populate_popup_menu(bm, html, GTK_MENU(menu));
@@ -1111,6 +1113,18 @@ balsa_gtk_html_popup(GtkWidget * html, BalsaMessage * bm)
     event = g_object_get_data(G_OBJECT(html), LIBBALSA_HTML_POPUP_EVENT);
     if (!event)
         event = current_event = gtk_get_current_event();
+#if GTK_CHECK_VERSION(3, 22, 0)
+    if (event)
+        gtk_menu_popup_at_pointer(GTK_MENU(menu),
+                                  (GdkEvent *) event);
+    else
+        gtk_menu_popup_at_widget(GTK_MENU(menu),
+                                 GTK_WIDGET(bm),
+                                 GDK_GRAVITY_CENTER, GDK_GRAVITY_CENTER,
+                                 NULL);
+    if (current_event)
+        gdk_event_free(current_event);
+#else                           /*GTK_CHECK_VERSION(3, 22, 0) */
     time = gdk_event_get_time(event);
     button = 0;
     gdk_event_get_button(event, &button);
@@ -1118,6 +1132,7 @@ balsa_gtk_html_popup(GtkWidget * html, BalsaMessage * bm)
         gdk_event_free(current_event);
 
     gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button, time);
+#endif                          /*GTK_CHECK_VERSION(3, 22, 0) */
 
     return TRUE;
 }
diff --git a/src/pref-manager.c b/src/pref-manager.c
index 46b3d86..31744e7 100644
--- a/src/pref-manager.c
+++ b/src/pref-manager.c
@@ -3131,8 +3131,14 @@ static void
 address_book_add_cb(GtkWidget * menu)
 {
     gtk_widget_show_all(menu);
+#if GTK_CHECK_VERSION(3, 22, 0)
+    gtk_menu_popup_at_widget(GTK_MENU(menu), GTK_WIDGET(pui->view),
+                             GDK_GRAVITY_CENTER, GDK_GRAVITY_CENTER,
+                             NULL);
+#else                           /*GTK_CHECK_VERSION(3, 22, 0) */
     gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0,
                    gtk_get_current_event_time());
+#endif                          /*GTK_CHECK_VERSION(3, 22, 0) */
 }
 
 static void
@@ -3172,8 +3178,14 @@ static void
 server_add_cb(GtkWidget * menu)
 {
     gtk_widget_show_all(menu);
+#if GTK_CHECK_VERSION(3, 22, 0)
+    gtk_menu_popup_at_widget(GTK_MENU(menu), GTK_WIDGET(pui->view),
+                             GDK_GRAVITY_CENTER, GDK_GRAVITY_CENTER,
+                             NULL);
+#else                           /*GTK_CHECK_VERSION(3, 22, 0) */
     gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0,
                    gtk_get_current_event_time());
+#endif                          /*GTK_CHECK_VERSION(3, 22, 0) */
 }
 
 static GtkWidget *
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index 70a88f0..3a31a7e 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -2457,8 +2457,13 @@ attachment_button_press_cb(GtkWidget * widget, GdkEventButton * event,
            gtk_tree_model_get(model, &iter, ATTACH_INFO_COLUMN, &attach_info, -1);
            if (attach_info) {
                if (attach_info->popup_menu)
+#if GTK_CHECK_VERSION(3, 22, 0)
+                    gtk_menu_popup_at_pointer(GTK_MENU(attach_info->popup_menu),
+                                              (GdkEvent *) event);
+#else                           /*GTK_CHECK_VERSION(3, 22, 0) */
                    gtk_menu_popup(GTK_MENU(attach_info->popup_menu), NULL, NULL,
                                   NULL, NULL, event->button, event->time);
+#endif                          /*GTK_CHECK_VERSION(3, 22, 0) */
                g_object_unref(attach_info);
            }
         }
@@ -2483,8 +2488,15 @@ attachment_popup_cb(GtkWidget *widget, gpointer user_data)
     gtk_tree_model_get(model, &iter, ATTACH_INFO_COLUMN, &attach_info, -1);
     if (attach_info) {
        if (attach_info->popup_menu)
+#if GTK_CHECK_VERSION(3, 22, 0)
+            gtk_menu_popup_at_widget(GTK_MENU(attach_info->popup_menu),
+                                     GTK_WIDGET(widget),
+                                     GDK_GRAVITY_CENTER, GDK_GRAVITY_CENTER,
+                                     NULL);
+#else                           /*GTK_CHECK_VERSION(3, 22, 0) */
        gtk_menu_popup(GTK_MENU(attach_info->popup_menu), NULL, NULL, NULL,
                       NULL, 0, gtk_get_current_event_time());
+#endif                          /*GTK_CHECK_VERSION(3, 22, 0) */
        g_object_unref(attach_info);
     }
 
diff --git a/src/toolbar-factory.c b/src/toolbar-factory.c
index c303c29..e6aa094 100644
--- a/src/toolbar-factory.c
+++ b/src/toolbar-factory.c
@@ -661,6 +661,7 @@ tm_remove_underscore(const gchar * text)
     return r;
 }
 
+#if !GTK_CHECK_VERSION(3, 22, 0)
 /* If the menu is popped up in response to a keystroke, center it
  * immediately below the toolbar.
  */
@@ -696,13 +697,16 @@ tm_popup_position_func(GtkMenu * menu, gint * x, gint * y,
 
     *push_in = FALSE;
 }
+#endif                          /*GTK_CHECK_VERSION(3, 22, 0) */
 
 static gboolean
 tm_do_popup_menu(GtkWidget * toolbar, GdkEventButton * event,
                  toolbar_info * info)
 {
     GtkWidget *menu;
+#if !GTK_CHECK_VERSION(3, 22, 0)
     int button, event_time;
+#endif                          /*GTK_CHECK_VERSION(3, 22, 0) */
     guint i;
     GSList *group = NULL;
     GtkToolbarStyle default_style = tm_default_style();
@@ -792,6 +796,17 @@ tm_do_popup_menu(GtkWidget * toolbar, GdkEventButton * event,
 
     gtk_widget_show_all(menu);
 
+#if GTK_CHECK_VERSION(3, 22, 0)
+    gtk_menu_attach_to_widget(GTK_MENU(menu), toolbar, NULL);
+    if (event)
+        gtk_menu_popup_at_pointer(GTK_MENU(menu),
+                                  (GdkEvent *) event);
+    else
+        gtk_menu_popup_at_widget(GTK_MENU(menu),
+                                 GTK_WIDGET(toolbar),
+                                 GDK_GRAVITY_CENTER, GDK_GRAVITY_CENTER,
+                                 NULL);
+#else                           /*GTK_CHECK_VERSION(3, 22, 0) */
     if (event) {
         button = event->button;
         event_time = event->time;
@@ -807,6 +822,7 @@ tm_do_popup_menu(GtkWidget * toolbar, GdkEventButton * event,
     else
         gtk_menu_popup(GTK_MENU(menu), NULL, NULL, tm_popup_position_func,
                        toolbar, button, event_time);
+#endif                          /*GTK_CHECK_VERSION(3, 22, 0) */
 
     return TRUE;
 }


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