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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Displaying the Recently Used Documents: GTK+ 2 Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="index.html" title="GTK+ 2 Reference Manual">
<link rel="up" href="gtk-migrating-GtkRecentChooser.html" title="Migrating from EggRecent to GtkRecentChooser">
<link rel="prev" href="gtk-migrating-GtkRecentChooser.html" title="Migrating from EggRecent to GtkRecentChooser">
<link rel="next" href="gtkrecent-advanced.html" title="Advanced usage">
<meta name="generator" content="GTK-Doc V1.33.0 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts"></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="gtk-migrating-GtkRecentChooser.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="gtk-migrating-GtkRecentChooser.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="gtkrecent-advanced.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="gtkrecent-chooser"></a>Displaying the Recently Used Documents</h2></div></div></div>
<p>
Displaying the Recently Used Documents list is handled by any widget
implementing the <a class="link" href="GtkRecentChooser.html" title="GtkRecentChooser"><span class="type">GtkRecentChooser</span></a> interface. These widgets also handle
the sorting and filtering of the list; they will create their own
<a class="link" href="GtkRecentManager.html" title="GtkRecentManager"><span class="type">GtkRecentManager</span></a> objects by default:
</p>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>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</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="n">GtkWidget</span> <span class="o">*</span><span class="n">chooser</span><span class="p">;</span>
<span class="n">gint</span> <span class="n">response</span><span class="p">;</span>
<span class="cm">/* create a new dialog with the recently used documents list shown</span>
<span class="cm"> * using a GtkTreeView widget</span>
<span class="cm"> */</span>
<span class="n">chooser</span> <span class="o">=</span> <span class="n">gtk_recent_chooser_dialog_new</span> <span class="p">(</span><span class="s">"Recent Documents"</span><span class="p">,</span>
<span class="n">parent_window</span><span class="p">,</span>
<span class="n">GTK_STOCK_CLOSE</span><span class="p">,</span> <span class="n">GTK_RESPONSE_CANCEL</span><span class="p">,</span>
<span class="n">GTK_STOCK_OPEN</span><span class="p">,</span> <span class="n">GTK_RESPONSE_OK</span><span class="p">,</span>
<span class="nb">NULL</span><span class="p">);</span>
<span class="cm">/* set the sorting order to "most recently used first" */</span>
<span class="n">gtk_recent_chooser_set_sort_type</span> <span class="p">(</span><span class="n">GTK_RECENT_CHOOSER</span> <span class="p">(</span><span class="n">chooser</span><span class="p">),</span> <span class="n">GTK_RECENT_SORT_MRU</span><span class="p">);</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">gtk_dialog_run</span> <span class="p">(</span><span class="n">GTK_DIALOG</span> <span class="p">(</span><span class="n">chooser</span><span class="p">));</span>
<span class="k">if</span> <span class="p">(</span><span class="n">response</span> <span class="o">==</span> <span class="n">GTK_RESPONSE_OK</span><span class="p">)</span>
<span class="p">{</span>
<span class="n">GtkRecentInfo</span> <span class="o">*</span><span class="n">info</span><span class="p">;</span>
<span class="n">info</span> <span class="o">=</span> <span class="n">gtk_recent_chooser_get_current_item</span> <span class="p">(</span><span class="n">GTK_RECENT_CHOOSER</span> <span class="p">(</span><span class="n">chooser</span><span class="p">));</span>
<span class="n">do_something_with_the_item</span> <span class="p">(</span><span class="n">info</span><span class="p">);</span>
<span class="n">gtk_recent_info_unref</span> <span class="p">(</span><span class="n">info</span><span class="p">);</span>
<span class="p">}</span>
<span class="n">gtk_widget_destroy</span> <span class="p">(</span><span class="n">chooser</span><span class="p">);</span></pre></td>
</tr>
</tbody>
</table>
</div>
<p>
</p>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.33.0</div>
</body>
</html>
|