GtkRecentChooserMenu: Set current uri before activating an item.
When activating an item using mnemonics GtkRecentChooserMenu does not select a item before calling the item-activated signal thus gtk_recent_chooser_get_current_uri() always return the last selected item instead of the activated one. Fixes Bug 495105 "Open recent file keyboard shortcuts do not work correctly"
This commit is contained in:
@ -488,10 +488,11 @@ gtk_recent_chooser_menu_set_current_uri (GtkRecentChooser *chooser,
|
|||||||
GList *children, *l;
|
GList *children, *l;
|
||||||
GtkWidget *menu_item = NULL;
|
GtkWidget *menu_item = NULL;
|
||||||
gboolean found = FALSE;
|
gboolean found = FALSE;
|
||||||
|
gint i = 0;
|
||||||
|
|
||||||
children = gtk_container_get_children (GTK_CONTAINER (menu));
|
children = gtk_container_get_children (GTK_CONTAINER (menu));
|
||||||
|
|
||||||
for (l = children; l != NULL; l = l->next)
|
for (l = children; l != NULL; l = l->next, i++)
|
||||||
{
|
{
|
||||||
GtkRecentInfo *info;
|
GtkRecentInfo *info;
|
||||||
|
|
||||||
@ -503,9 +504,7 @@ gtk_recent_chooser_menu_set_current_uri (GtkRecentChooser *chooser,
|
|||||||
|
|
||||||
if (strcmp (uri, gtk_recent_info_get_uri (info)) == 0)
|
if (strcmp (uri, gtk_recent_info_get_uri (info)) == 0)
|
||||||
{
|
{
|
||||||
gtk_menu_shell_activate_item (GTK_MENU_SHELL (menu),
|
gtk_menu_set_active (GTK_MENU (menu), i);
|
||||||
menu_item,
|
|
||||||
TRUE);
|
|
||||||
found = TRUE;
|
found = TRUE;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -1114,7 +1113,9 @@ item_activate_cb (GtkWidget *widget,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GtkRecentChooser *chooser = GTK_RECENT_CHOOSER (user_data);
|
GtkRecentChooser *chooser = GTK_RECENT_CHOOSER (user_data);
|
||||||
|
GtkRecentInfo *info = g_object_get_data (G_OBJECT (widget), "gtk-recent-info");
|
||||||
|
|
||||||
|
gtk_recent_chooser_menu_set_current_uri (chooser, gtk_recent_info_get_uri (info), NULL);
|
||||||
_gtk_recent_chooser_item_activated (chooser);
|
_gtk_recent_chooser_item_activated (chooser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user