From 44c265193227e062c5c2366dafb662f4993976b4 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 22 Feb 2006 16:35:09 +0000 Subject: [PATCH] Apply a patch by Paolo Borelli to make the tab menu keynavigatable. 2006-02-22 Matthias Clasen * gtk/gtknotebook.c: Apply a patch by Paolo Borelli to make the tab menu keynavigatable. (#331440) --- ChangeLog | 5 +++++ ChangeLog.pre-2-10 | 5 +++++ gtk/gtknotebook.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) diff --git a/ChangeLog b/ChangeLog index 816835ecd8..584b91d2af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-02-22 Matthias Clasen + + * gtk/gtknotebook.c: Apply a patch by Paolo Borelli to + make the tab menu keynavigatable. (#331440) + 2006-02-22 Matthias Clasen * gtk/gtkaboutdialog.c: Change Close buttons to GTK_RESPONSE_CANCEL diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 816835ecd8..584b91d2af 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,8 @@ +2006-02-22 Matthias Clasen + + * gtk/gtknotebook.c: Apply a patch by Paolo Borelli to + make the tab menu keynavigatable. (#331440) + 2006-02-22 Matthias Clasen * gtk/gtkaboutdialog.c: Change Close buttons to GTK_RESPONSE_CANCEL diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 5f114166dd..28d59890db 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -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) {