notebook: Update arrows when text direction changes
authorMatthias Clasen <mclasen@redhat.com>
Thu, 6 Feb 2020 07:07:22 +0000 (02:07 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 6 Feb 2020 12:13:10 +0000 (07:13 -0500)
Fixes https://gitlab.gnome.org/GNOME/gtk/issues/103

gtk/gtknotebook.c

index b3feea7fe367900e477770a1d89647b6b12870d1..70fa1a92bc6d91a41b26f00015398c3dfe7a802e 100644 (file)
@@ -693,6 +693,8 @@ static void gtk_notebook_grab_notify         (GtkWidget          *widget,
                                               gboolean            was_grabbed);
 static void gtk_notebook_state_flags_changed (GtkWidget          *widget,
                                               GtkStateFlags       previous_state);
+static void gtk_notebook_direction_changed   (GtkWidget        *widget,
+                                              GtkTextDirection  previous_direction);
 static gboolean gtk_notebook_focus           (GtkWidget        *widget,
                                               GtkDirectionType  direction);
 
@@ -958,6 +960,7 @@ gtk_notebook_class_init (GtkNotebookClass *class)
   widget_class->popup_menu = gtk_notebook_popup_menu;
   widget_class->grab_notify = gtk_notebook_grab_notify;
   widget_class->state_flags_changed = gtk_notebook_state_flags_changed;
+  widget_class->direction_changed = gtk_notebook_direction_changed;
   widget_class->focus = gtk_notebook_focus;
   widget_class->compute_expand = gtk_notebook_compute_expand;
 
@@ -3016,11 +3019,16 @@ update_arrow_nodes (GtkNotebook *notebook)
       up_icon_name = "pan-down-symbolic";
       down_icon_name = "pan-up-symbolic";
     }
-  else
+  else if (gtk_widget_get_direction (GTK_WIDGET (notebook)) == GTK_TEXT_DIR_LTR)
     {
       up_icon_name = "pan-end-symbolic";
       down_icon_name = "pan-start-symbolic";
     }
+  else
+    {
+      up_icon_name = "pan-start-symbolic";
+      down_icon_name = "pan-end-symbolic";
+    }
 
   arrow[0] = TRUE;
   arrow[1] = FALSE;
@@ -3105,6 +3113,13 @@ update_arrow_nodes (GtkNotebook *notebook)
     }
 }
 
+static void
+gtk_notebook_direction_changed (GtkWidget        *widget,
+                                GtkTextDirection  previous_direction)
+{
+  update_arrow_nodes (GTK_NOTEBOOK (widget));
+}
+
 static void
 gtk_notebook_dnd_finished_cb (GdkDrag   *drag,
                               GtkWidget *widget)