]> Pileus Git - ~andy/gtk/commitdiff
Apply a patch by Paolo Borelli to make the tab menu keynavigatable.
authorMatthias Clasen <mclasen@redhat.com>
Wed, 22 Feb 2006 16:35:09 +0000 (16:35 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Wed, 22 Feb 2006 16:35:09 +0000 (16:35 +0000)
2006-02-22  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtknotebook.c: Apply a patch by Paolo Borelli to
        make the tab menu keynavigatable.  (#331440)

ChangeLog
ChangeLog.pre-2-10
gtk/gtknotebook.c

index 816835ecd8256e565ad0eef473633228f71636ee..584b91d2af40b4f08bd68b4a941ce102f6fdbee7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-02-22  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtknotebook.c: Apply a patch by Paolo Borelli to
+       make the tab menu keynavigatable.  (#331440)
+
 2006-02-22  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkaboutdialog.c: Change Close buttons to GTK_RESPONSE_CANCEL
index 816835ecd8256e565ad0eef473633228f71636ee..584b91d2af40b4f08bd68b4a941ce102f6fdbee7 100644 (file)
@@ -1,3 +1,8 @@
+2006-02-22  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtknotebook.c: Apply a patch by Paolo Borelli to
+       make the tab menu keynavigatable.  (#331440)
+
 2006-02-22  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkaboutdialog.c: Change Close buttons to GTK_RESPONSE_CANCEL
index 5f114166dd4ab967bed94d0618da5e523fccb727..28d59890db6d753bea91d251adc0bbccc9f9115d 100644 (file)
@@ -165,6 +165,7 @@ static gint gtk_notebook_button_press        (GtkWidget        *widget,
                                              GdkEventButton   *event);
 static gint gtk_notebook_button_release      (GtkWidget        *widget,
                                              GdkEventButton   *event);
+static gboolean gtk_notebook_popup_menu      (GtkWidget        *widget);
 static gint gtk_notebook_enter_notify        (GtkWidget        *widget,
                                              GdkEventCrossing *event);
 static gint gtk_notebook_leave_notify        (GtkWidget        *widget,
@@ -372,6 +373,7 @@ gtk_notebook_class_init (GtkNotebookClass *class)
   widget_class->scroll_event = gtk_notebook_scroll;
   widget_class->button_press_event = gtk_notebook_button_press;
   widget_class->button_release_event = gtk_notebook_button_release;
+  widget_class->popup_menu = gtk_notebook_popup_menu;
   widget_class->enter_notify_event = gtk_notebook_enter_notify;
   widget_class->leave_notify_event = gtk_notebook_leave_notify;
   widget_class->motion_notify_event = gtk_notebook_motion_notify;
@@ -1040,6 +1042,7 @@ gtk_notebook_get_property (GObject         *object,
  * gtk_notebook_scroll
  * gtk_notebook_button_press
  * gtk_notebook_button_release
+ * gtk_notebook_popup_menu
  * gtk_notebook_enter_notify
  * gtk_notebook_leave_notify
  * gtk_notebook_motion_notify
@@ -1907,6 +1910,59 @@ gtk_notebook_button_press (GtkWidget      *widget,
   return TRUE;
 }
 
+static void
+popup_position_func (GtkMenu  *menu,
+                     gint     *x,
+                     gint     *y,
+                     gboolean *push_in,
+                     gpointer  data)
+{
+  GtkNotebook *notebook = data;
+  GtkWidget *w;
+  GtkRequisition requisition;
+
+  if (notebook->focus_tab)
+    {
+      GtkNotebookPage *page;
+
+      page = notebook->focus_tab->data;
+      w = page->tab_label;
+    }
+  else
+   {
+     w = GTK_WIDGET (notebook);
+   }
+
+  gdk_window_get_origin (w->window, x, y);
+  gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
+
+  if (gtk_widget_get_direction (w) == GTK_TEXT_DIR_RTL)
+    *x += w->allocation.x + w->allocation.width - requisition.width;
+  else
+    *x += w->allocation.x;
+
+  *y += w->allocation.y + w->allocation.height;
+
+  *push_in = FALSE;
+}
+
+static gboolean
+gtk_notebook_popup_menu (GtkWidget *widget)
+{
+  GtkNotebook *notebook = GTK_NOTEBOOK (widget);
+
+  if (notebook->menu)
+    {
+      gtk_menu_popup (GTK_MENU (notebook->menu), NULL, NULL, 
+                     popup_position_func, notebook,
+                     0, gtk_get_current_event_time ());
+      gtk_menu_shell_select_first (GTK_MENU_SHELL (notebook->menu), FALSE);
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
 static void 
 stop_scrolling (GtkNotebook *notebook)
 {