## Displaying the Recently Used Documents

Displaying the Recently Used Documents list is handled by any widget implementing the GtkRecentChooser interface. These widgets also handle the sorting and filtering of the list; they will create their own GtkRecentManager objects by default:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    GtkWidget *chooser;
            gint response;

            /* create a new dialog with the recently used documents list shown
             * using a GtkTreeView widget
             */
            chooser = gtk_recent_chooser_dialog_new ("Recent Documents",
                                                     parent_window,
                                                     GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL,
                                                     GTK_STOCK_OPEN, GTK_RESPONSE_OK,
                                                     NULL);
            /* set the sorting order to "most recently used first" */
            gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (chooser), GTK_RECENT_SORT_MRU);
            response = gtk_dialog_run (GTK_DIALOG (chooser));
            if (response == GTK_RESPONSE_OK)
              {
                GtkRecentInfo *info;

                info = gtk_recent_chooser_get_current_item (GTK_RECENT_CHOOSER (chooser));
                do_something_with_the_item (info);

                gtk_recent_info_unref (info);
              }

            gtk_widget_destroy (chooser);