[gcr] ui: use gdk_popup_menu_at_widget()



commit ff8e6cadddbe19345069beaac9bc09804d63b045
Author: Dmitry Eremin-Solenikov <dbaryshkov gmail com>
Date:   Mon Jan 13 00:08:06 2020 +0300

    ui: use gdk_popup_menu_at_widget()
    
    Gdk 3.22 has deprecated gdk_popup_menu(). Replace it with much
    simpler code using gdk_popup_menu_at_widget().
    
    Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov gmail com>

 ui/gcr-import-button.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
---
diff --git a/ui/gcr-import-button.c b/ui/gcr-import-button.c
index c1840f1..b03ecf4 100644
--- a/ui/gcr-import-button.c
+++ b/ui/gcr-import-button.c
@@ -390,6 +390,7 @@ update_importer_menu (GcrImportButton *self)
        }
 }
 
+#if !GTK_CHECK_VERSION (3,22,0)
 static void
 on_menu_position (GtkMenu *menu,
                   gint *x,
@@ -458,6 +459,7 @@ on_menu_position (GtkMenu *menu,
 
        *push_in = FALSE;
 }
+#endif
 
 static void
 gcr_import_button_clicked (GtkButton *button)
@@ -470,8 +472,22 @@ gcr_import_button_clicked (GtkButton *button)
        /* More than one importer, show the menu */
        if (self->pv->importers->next) {
                update_importer_menu (self);
+#if GTK_CHECK_VERSION (3,22,0)
+               if (gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_LTR)
+                       gtk_menu_popup_at_widget (self->pv->menu,
+                                                 GTK_WIDGET (self),
+                                                 GDK_GRAVITY_SOUTH_WEST, GDK_GRAVITY_NORTH_WEST,
+                                                 NULL);
+               else
+                       gtk_menu_popup_at_widget (self->pv->menu,
+                                                 GTK_WIDGET (self),
+                                                 GDK_GRAVITY_SOUTH_EAST, GDK_GRAVITY_NORTH_EAST,
+                                                 NULL);
+
+#else
                gtk_menu_popup (self->pv->menu, NULL, NULL, on_menu_position,
                                self, 1, gtk_get_current_event_time ());
+#endif
 
        /* Only one importer, import on click */
        } else {


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