]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtknotebook.c
Replace a lot of idle and timeout calls by the new gdk_threads api.
[~andy/gtk] / gtk / gtknotebook.c
index cd52f6fb286d9d3b9b8d729130d603471efbf71a..1448a52073010fdddfbfc8e0443a2ce2474472ee 100644 (file)
@@ -1066,14 +1066,33 @@ gtk_notebook_change_current_page (GtkNotebook *notebook,
 
   while (offset != 0)
     {
-      current = gtk_notebook_search_page (notebook, current, offset < 0 ? STEP_PREV : STEP_NEXT, TRUE);
+      current = gtk_notebook_search_page (notebook, current,
+                                          offset < 0 ? STEP_PREV : STEP_NEXT,
+                                          TRUE);
+
+      if (!current)
+        {
+          gboolean wrap_around;
+
+          g_object_get (gtk_widget_get_settings (GTK_WIDGET (notebook)),
+                        "gtk-keynav-wrap-around", &wrap_around,
+                        NULL);
+
+          if (wrap_around)
+            current = gtk_notebook_search_page (notebook, NULL,
+                                                offset < 0 ? STEP_PREV : STEP_NEXT,
+                                                TRUE);
+          else
+            break;
+        }
+
       offset += offset < 0 ? 1 : -1;
     }
 
   if (current)
     gtk_notebook_switch_page (notebook, current->data, -1);
   else
-    gdk_display_beep (gtk_widget_get_display (GTK_WIDGET (notebook)));
+    gtk_widget_error_bell (GTK_WIDGET (notebook));
 }
 
 static GtkDirectionType
@@ -2725,8 +2744,6 @@ scroll_notebook_timer (gpointer data)
   GtkNotebookPointerPosition pointer_position;
   GList *element, *first_tab;
 
-  GDK_THREADS_ENTER ();
-
   priv = GTK_NOTEBOOK_GET_PRIVATE (notebook);
   pointer_position = get_pointer_position (notebook);
 
@@ -2748,8 +2765,6 @@ scroll_notebook_timer (gpointer data)
       gdk_window_raise (priv->drag_window);
     }
 
-  GDK_THREADS_LEAVE ();
-
   return TRUE;
 }
 
@@ -2856,8 +2871,8 @@ gtk_notebook_motion_notify (GtkWidget      *widget,
              settings = gtk_widget_get_settings (GTK_WIDGET (notebook));
              g_object_get (settings, "gtk-timeout-repeat", &timeout, NULL);
 
-             priv->dnd_timer = g_timeout_add (timeout * SCROLL_DELAY_FACTOR,
-                                              (GSourceFunc) scroll_notebook_timer, 
+             priv->dnd_timer = gdk_threads_add_timeout (timeout * SCROLL_DELAY_FACTOR,
+                                              scroll_notebook_timer, 
                                               (gpointer) notebook);
            }
        }
@@ -3071,8 +3086,6 @@ gtk_notebook_switch_tab_timeout (gpointer data)
   GList *tab;
   gint x, y;
 
-  GDK_THREADS_ENTER ();
-
   notebook = GTK_NOTEBOOK (data);
   priv = GTK_NOTEBOOK_GET_PRIVATE (notebook);
 
@@ -3089,8 +3102,6 @@ gtk_notebook_switch_tab_timeout (gpointer data)
       gtk_notebook_switch_focus_tab (notebook, tab);
     }
 
-  GDK_THREADS_LEAVE ();
-
   return FALSE;
 }
 
@@ -3170,8 +3181,8 @@ gtk_notebook_drag_motion (GtkWidget      *widget,
           settings = gtk_widget_get_settings (widget);
 
           g_object_get (settings, "gtk-timeout-expand", &timeout, NULL);
-         priv->switch_tab_timer = g_timeout_add (timeout,
-                                                 (GSourceFunc) gtk_notebook_switch_tab_timeout,
+         priv->switch_tab_timer = gdk_threads_add_timeout (timeout,
+                                                 gtk_notebook_switch_tab_timeout,
                                                  widget);
        }
     }
@@ -3589,11 +3600,24 @@ focus_tabs_move (GtkNotebook     *notebook,
 
   new_page = gtk_notebook_search_page (notebook, notebook->focus_tab,
                                       search_direction, TRUE);
+  if (!new_page)
+    {
+      gboolean wrap_around;
+
+      g_object_get (gtk_widget_get_settings (GTK_WIDGET (notebook)),
+                    "gtk-keynav-wrap-around", &wrap_around,
+                    NULL);
+
+      if (wrap_around)
+        new_page = gtk_notebook_search_page (notebook, NULL,
+                                             search_direction, TRUE);
+    }
+
   if (new_page)
     gtk_notebook_switch_focus_tab (notebook, new_page);
   else
-    gdk_display_beep (gtk_widget_get_display (GTK_WIDGET (notebook)));
-  
+    gtk_widget_error_bell (GTK_WIDGET (notebook));
+
   return TRUE;
 }
 
@@ -4044,13 +4068,11 @@ gtk_notebook_redraw_arrows (GtkNotebook *notebook)
     }
 }
 
-static gint
+static gboolean
 gtk_notebook_timer (GtkNotebook *notebook)
 {
   gboolean retval = FALSE;
 
-  GDK_THREADS_ENTER ();
-
   if (notebook->timer)
     {
       gtk_notebook_do_arrow (notebook, notebook->click_child);
@@ -4064,7 +4086,7 @@ gtk_notebook_timer (GtkNotebook *notebook)
           g_object_get (settings, "gtk-timeout-repeat", &timeout, NULL);
 
          notebook->need_timer = FALSE;
-         notebook->timer = g_timeout_add (timeout * SCROLL_DELAY_FACTOR,
+         notebook->timer = gdk_threads_add_timeout (timeout * SCROLL_DELAY_FACTOR,
                                           (GSourceFunc) gtk_notebook_timer,
                                           (gpointer) notebook);
        }
@@ -4072,8 +4094,6 @@ gtk_notebook_timer (GtkNotebook *notebook)
        retval = TRUE;
     }
 
-  GDK_THREADS_LEAVE ();
-
   return retval;
 }
 
@@ -4089,7 +4109,7 @@ gtk_notebook_set_scroll_timer (GtkNotebook *notebook)
 
       g_object_get (settings, "gtk-timeout-initial", &timeout, NULL);
 
-      notebook->timer = g_timeout_add (timeout,
+      notebook->timer = gdk_threads_add_timeout (timeout,
                                       (GSourceFunc) gtk_notebook_timer,
                                       (gpointer) notebook);
       notebook->need_timer = TRUE;