diff --git a/desmume/src/gtk/main.cpp b/desmume/src/gtk/main.cpp index d3849a870..49eb4e83c 100644 --- a/desmume/src/gtk/main.cpp +++ b/desmume/src/gtk/main.cpp @@ -126,6 +126,7 @@ static const char *ui_description = " " " " " " +" " " " " " " " @@ -247,6 +248,7 @@ static const char *ui_description = static const GtkActionEntry action_entries[] = { { "FileMenu", NULL, "_File" }, { "open", "gtk-open", "_Open", "o", NULL, OpenNdsDialog }, + { "RecentMenu", NULL, "Open _recent" }, { "savestateto", NULL, "Save state _to ...", NULL, NULL, SaveStateDialog }, { "loadstatefrom", NULL, "Load state _from ...", NULL, NULL, LoadStateDialog }, { "recordmovie", NULL, "Record movie _to ...", NULL, NULL, RecordMovieDialog }, @@ -903,6 +905,18 @@ static void OpenNdsDialog() gtk_dialog_run(GTK_DIALOG(pDialog)); gtk_widget_destroy(pDialog); } else { + GtkRecentData recentData; + memset(&recentData, 0, sizeof(GtkRecentData)); + recentData.mime_type = "application/x-nds-binary"; + recentData.app_name = (gchar *) g_get_application_name (); + recentData.app_exec = g_strjoin (" ", g_get_prgname (), "%f", NULL); + + GtkRecentManager *manager; + manager = gtk_recent_manager_get_default (); + gtk_recent_manager_add_full (manager, g_filename_to_uri(sPath, NULL, NULL), &recentData); + + g_free(recentData.app_exec); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "run"), TRUE); } @@ -916,6 +930,13 @@ static void OpenNdsDialog() gtk_widget_destroy(pFileSelection); } +static void OpenRecent(GtkRecentChooser *chooser, gpointer user_data) +{ + Open(g_filename_from_uri(gtk_recent_chooser_get_current_uri(chooser), NULL, NULL)); + + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "run"), TRUE); +} + static void Reset() { NDS_Reset(); @@ -1871,6 +1892,16 @@ common_gtk_main( struct configured_features *my_config) pToolBar = gtk_ui_manager_get_widget (ui_manager, "/ToolBar"); gtk_box_pack_start (GTK_BOX(pVBox), pToolBar, FALSE, FALSE, 0); + { + GtkWidget * recentMenu = gtk_ui_manager_get_widget (ui_manager, "/MainMenu/FileMenu/RecentMenu"); + GtkWidget * recentFiles = gtk_recent_chooser_menu_new(); + GtkRecentFilter * recentFilter = gtk_recent_filter_new(); + gtk_recent_filter_add_mime_type(recentFilter, "application/x-nds-binary"); + gtk_recent_chooser_set_filter(GTK_RECENT_CHOOSER(recentFiles), recentFilter); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(recentMenu), recentFiles); + g_signal_connect(G_OBJECT(recentFiles), "item-activated", G_CALLBACK(OpenRecent), NULL); + } + /* Creating the place for showing DS screens */ pDrawingArea = gtk_drawing_area_new(); gtk_container_add (GTK_CONTAINER (pVBox), pDrawingArea);