[gnome-builder] tree: Set popover direction on initialization instead of mouse click popup



commit a70bb6d7bce1d87e346795ae63277adc04cf0bf8
Author: vanadiae <vanadiae35 gmail com>
Date:   Tue Jul 20 12:17:52 2021 +0200

    tree: Set popover direction on initialization instead of mouse click popup
    
    If the first time the popover is shown only the menu key is used, the popover
    will be going upwards instead of to the right. So this commit instead sets
    the popover position (i.e. direction) when initializing it instead of when
    poping up the popover with the mouse (since the menu key doesn't go through
    the same code path here).

 src/libide/tree/ide-tree.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/src/libide/tree/ide-tree.c b/src/libide/tree/ide-tree.c
index 4b6233593..2c6dce4ec 100644
--- a/src/libide/tree/ide-tree.c
+++ b/src/libide/tree/ide-tree.c
@@ -398,16 +398,12 @@ ide_tree_popup (IdeTree        *self,
 {
   IdeTreePrivate *priv = ide_tree_get_instance_private (self);
   const GdkRectangle area = { target_x, target_y, 0, 0 };
-  GtkTextDirection dir;
 
   g_assert (IDE_IS_TREE (self));
   g_assert (IDE_IS_TREE_NODE (node));
   g_assert (priv->popover != NULL);
 
-  dir = gtk_widget_get_direction (GTK_WIDGET (self));
-
   gtk_popover_set_pointing_to (priv->popover, &area);
-  gtk_popover_set_position (priv->popover, dir == GTK_TEXT_DIR_LTR ? GTK_POS_RIGHT : GTK_POS_LEFT);
 
   ide_tree_show_popover_at_node (self, node, priv->popover);
 }
@@ -669,11 +665,15 @@ ide_tree_set_context_menu (IdeTree *self,
 
   if (g_set_object (&priv->context_menu, menu))
     {
+      GtkTextDirection dir;
+
       if (priv->popover != NULL)
         gtk_widget_destroy (GTK_WIDGET (priv->popover));
 
       priv->popover = GTK_POPOVER (gtk_popover_new_from_model (GTK_WIDGET (self),
                                                                G_MENU_MODEL (priv->context_menu)));
+      dir = gtk_widget_get_direction (GTK_WIDGET (self));
+      gtk_popover_set_position (priv->popover, dir == GTK_TEXT_DIR_LTR ? GTK_POS_RIGHT : GTK_POS_LEFT);
       g_signal_connect (priv->popover,
                         "destroy",
                         G_CALLBACK (gtk_widget_destroyed),


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