File: amtk-application-window.c

package info (click to toggle)
libgedit-amtk 5.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 692 kB
  • sloc: ansic: 2,996; xml: 288; makefile: 7
file content (649 lines) | stat: -rw-r--r-- 18,669 bytes parent folder | download | duplicates (3)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
/* SPDX-FileCopyrightText: 2017 - Sébastien Wilmet <swilmet@gnome.org>
 * SPDX-License-Identifier: LGPL-3.0-or-later
 */

#include "amtk-config.h"
#include "amtk-application-window.h"
#include <glib/gi18n-lib.h>
#include "amtk-action-info.h"
#include "amtk-action-info-central-store.h"
#include "amtk-menu-item.h"
#include "amtk-menu-shell.h"
#include "amtk-utils.h"

/**
 * SECTION:amtk-application-window
 * @Short_description: An extension of GtkApplicationWindow
 * @Title: AmtkApplicationWindow
 *
 * #AmtkApplicationWindow extends the #GtkApplicationWindow class with a
 * #AmtkApplicationWindow:statusbar property and functions to show longer
 * descriptions of #GtkMenuItem's to the #GtkStatusbar.
 *
 * Note that #AmtkApplicationWindow extends the #GtkApplicationWindow class but
 * without subclassing it, because several libraries might want to extend
 * #GtkApplicationWindow and an application needs to be able to use all those
 * extensions at the same time.
 */

/* API design:
 *
 * AmtkApplicationWindow was first implemented in Tepl, and
 * TeplApplicationWindow needs to access the GtkApplicationWindow for the
 * GActionMap. Currently AmtkApplicationWindow could be renamed to AmtkWindow
 * and be an extension of GtkWindow instead of GtkApplicationWindow, it would
 * have the advantage to have shorter function names and be a little more
 * re-usable. But I think it's not a big problem to keep AmtkApplicationWindow
 * as is, because (1) the A in Amtk is all about GActions, so normally the app
 * already uses GtkApplicationWindow, (2) it is easy to port an application to
 * use GtkApplicationWindow, most of the time it's just changing the parent
 * class when subclassing GtkWindow, (3) it is more future-proof for Amtk to
 * have access to the GtkApplicationWindow, in case we want to add some features
 * that require the GActionMap or whatever. -- swilmet
 */

struct _AmtkApplicationWindowPrivate
{
	GtkApplicationWindow *gtk_window;
	GtkStatusbar *statusbar;
};

enum
{
	PROP_0,
	PROP_APPLICATION_WINDOW,
	PROP_STATUSBAR,
	N_PROPERTIES
};

#define AMTK_APPLICATION_WINDOW_KEY "amtk-application-window-key"
#define MENU_SHELL_STATUSBAR_CONTEXT_ID_KEY "amtk-menu-shell-statusbar-context-id-key"
#define MENU_SHELL_FOR_RECENT_CHOOSER_KEY "amtk-menu-shell-for-recent-chooser-key"

static GParamSpec *properties[N_PROPERTIES];

G_DEFINE_TYPE_WITH_PRIVATE (AmtkApplicationWindow, amtk_application_window, G_TYPE_OBJECT)

static void
amtk_application_window_get_property (GObject    *object,
				      guint       prop_id,
				      GValue     *value,
				      GParamSpec *pspec)
{
	AmtkApplicationWindow *amtk_window = AMTK_APPLICATION_WINDOW (object);

	switch (prop_id)
	{
		case PROP_APPLICATION_WINDOW:
			g_value_set_object (value, amtk_application_window_get_application_window (amtk_window));
			break;

		case PROP_STATUSBAR:
			g_value_set_object (value, amtk_application_window_get_statusbar (amtk_window));
			break;

		default:
			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
			break;
	}
}

static void
amtk_application_window_set_property (GObject      *object,
				      guint         prop_id,
				      const GValue *value,
				      GParamSpec   *pspec)
{
	AmtkApplicationWindow *amtk_window = AMTK_APPLICATION_WINDOW (object);

	switch (prop_id)
	{
		case PROP_APPLICATION_WINDOW:
			g_assert (amtk_window->priv->gtk_window == NULL);
			amtk_window->priv->gtk_window = g_value_get_object (value);
			break;

		case PROP_STATUSBAR:
			amtk_application_window_set_statusbar (amtk_window, g_value_get_object (value));
			break;

		default:
			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
			break;
	}
}

static void
amtk_application_window_dispose (GObject *object)
{
	AmtkApplicationWindow *amtk_window = AMTK_APPLICATION_WINDOW (object);

	amtk_window->priv->gtk_window = NULL;
	g_clear_object (&amtk_window->priv->statusbar);

	G_OBJECT_CLASS (amtk_application_window_parent_class)->dispose (object);
}

static void
amtk_application_window_class_init (AmtkApplicationWindowClass *klass)
{
	GObjectClass *object_class = G_OBJECT_CLASS (klass);

	object_class->get_property = amtk_application_window_get_property;
	object_class->set_property = amtk_application_window_set_property;
	object_class->dispose = amtk_application_window_dispose;

	/**
	 * AmtkApplicationWindow:application-window:
	 *
	 * The #GtkApplicationWindow.
	 *
	 * Since: 2.0
	 */
	properties[PROP_APPLICATION_WINDOW] =
		g_param_spec_object ("application-window",
				     "GtkApplicationWindow",
				     "",
				     GTK_TYPE_APPLICATION_WINDOW,
				     G_PARAM_READWRITE |
				     G_PARAM_CONSTRUCT_ONLY |
				     G_PARAM_STATIC_STRINGS);

	/**
	 * AmtkApplicationWindow:statusbar:
	 *
	 * The #GtkStatusbar. %NULL by default.
	 *
	 * Since: 2.0
	 */
	properties[PROP_STATUSBAR] =
		g_param_spec_object ("statusbar",
				     "GtkStatusbar",
				     "",
				     GTK_TYPE_STATUSBAR,
				     G_PARAM_READWRITE |
				     G_PARAM_STATIC_STRINGS);

	g_object_class_install_properties (object_class, N_PROPERTIES, properties);
}

static void
amtk_application_window_init (AmtkApplicationWindow *amtk_window)
{
	amtk_window->priv = amtk_application_window_get_instance_private (amtk_window);
}

/**
 * amtk_application_window_get_from_gtk_application_window:
 * @gtk_window: a #GtkApplicationWindow.
 *
 * Returns the #AmtkApplicationWindow of @gtk_window. The returned object is
 * guaranteed to be the same for the lifetime of @gtk_window.
 *
 * Returns: (transfer none): the #AmtkApplicationWindow of @gtk_window.
 * Since: 2.0
 */
AmtkApplicationWindow *
amtk_application_window_get_from_gtk_application_window (GtkApplicationWindow *gtk_window)
{
	AmtkApplicationWindow *amtk_window;

	g_return_val_if_fail (GTK_IS_APPLICATION_WINDOW (gtk_window), NULL);

	amtk_window = g_object_get_data (G_OBJECT (gtk_window), AMTK_APPLICATION_WINDOW_KEY);

	if (amtk_window == NULL)
	{
		amtk_window = g_object_new (AMTK_TYPE_APPLICATION_WINDOW,
					    "application-window", gtk_window,
					    NULL);

		g_object_set_data_full (G_OBJECT (gtk_window),
					AMTK_APPLICATION_WINDOW_KEY,
					amtk_window,
					g_object_unref);
	}

	g_return_val_if_fail (AMTK_IS_APPLICATION_WINDOW (amtk_window), NULL);
	return amtk_window;
}

/**
 * amtk_application_window_get_application_window:
 * @amtk_window: an #AmtkApplicationWindow.
 *
 * Returns: (transfer none): the #GtkApplicationWindow of @amtk_window.
 * Since: 2.0
 */
GtkApplicationWindow *
amtk_application_window_get_application_window (AmtkApplicationWindow *amtk_window)
{
	g_return_val_if_fail (AMTK_IS_APPLICATION_WINDOW (amtk_window), NULL);

	return amtk_window->priv->gtk_window;
}

/**
 * amtk_application_window_get_statusbar:
 * @amtk_window: an #AmtkApplicationWindow.
 *
 * Returns: (transfer none) (nullable): the #AmtkApplicationWindow:statusbar.
 * Since: 2.0
 */
GtkStatusbar *
amtk_application_window_get_statusbar (AmtkApplicationWindow *amtk_window)
{
	g_return_val_if_fail (AMTK_IS_APPLICATION_WINDOW (amtk_window), NULL);

	return amtk_window->priv->statusbar;
}

/**
 * amtk_application_window_set_statusbar:
 * @amtk_window: an #AmtkApplicationWindow.
 * @statusbar: (nullable): a #GtkStatusbar, or %NULL.
 *
 * Sets the #AmtkApplicationWindow:statusbar property.
 *
 * Since: 2.0
 */
void
amtk_application_window_set_statusbar (AmtkApplicationWindow *amtk_window,
				       GtkStatusbar          *statusbar)
{
	g_return_if_fail (AMTK_IS_APPLICATION_WINDOW (amtk_window));
	g_return_if_fail (statusbar == NULL || GTK_IS_STATUSBAR (statusbar));

	if (amtk_window->priv->statusbar == statusbar)
	{
		return;
	}

	if (statusbar != NULL)
	{
		g_object_ref_sink (statusbar);
	}

	if (amtk_window->priv->statusbar != NULL)
	{
		g_object_unref (amtk_window->priv->statusbar);
	}

	amtk_window->priv->statusbar = statusbar;
	g_object_notify_by_pspec (G_OBJECT (amtk_window), properties[PROP_STATUSBAR]);
}

/* Returns: %TRUE if a context ID exists and has been set to @context_id. */
static gboolean
get_statusbar_context_id_for_menu_shell (AmtkApplicationWindow *amtk_window,
					 AmtkMenuShell         *amtk_menu_shell,
					 gboolean               create,
					 guint                 *context_id)
{
	gpointer data;

	g_assert (amtk_window->priv->statusbar != NULL);
	g_assert (context_id != NULL);

	data = g_object_get_data (G_OBJECT (amtk_menu_shell), MENU_SHELL_STATUSBAR_CONTEXT_ID_KEY);

	if (data == NULL && !create)
	{
		return FALSE;
	}

	if (data == NULL)
	{
		*context_id = gtk_statusbar_get_context_id (amtk_window->priv->statusbar,
							    "Show long description of menu items.");

		g_object_set_data (G_OBJECT (amtk_menu_shell),
				   MENU_SHELL_STATUSBAR_CONTEXT_ID_KEY,
				   GUINT_TO_POINTER (*context_id));
	}
	else
	{
		*context_id = GPOINTER_TO_UINT (data);
	}

	return TRUE;
}

/* Free the return value with g_free(). */
static gchar *
get_menu_item_long_description (AmtkMenuShell *amtk_menu_shell,
				GtkMenuItem   *menu_item)
{
	const gchar *long_description;
	gpointer data;
	gboolean is_for_recent_chooser;

	long_description = amtk_menu_item_get_long_description (menu_item);
	if (long_description != NULL)
	{
		return g_strdup (long_description);
	}

	data = g_object_get_data (G_OBJECT (amtk_menu_shell), MENU_SHELL_FOR_RECENT_CHOOSER_KEY);
	is_for_recent_chooser = data != NULL ? GPOINTER_TO_INT (data) : FALSE;

	if (is_for_recent_chooser)
	{
		GtkMenuShell *gtk_menu_shell;
		GtkRecentChooserMenu *recent_chooser_menu;
		gchar *uri;
		GFile *file;
		gchar *parse_name;
		gchar *nicer_filename;
		gchar *ret;

		gtk_menu_shell = amtk_menu_shell_get_menu_shell (amtk_menu_shell);
		recent_chooser_menu = GTK_RECENT_CHOOSER_MENU (gtk_menu_shell);
		uri = amtk_utils_recent_chooser_menu_get_item_uri (recent_chooser_menu, menu_item);

		if (uri == NULL)
		{
			return NULL;
		}

		file = g_file_new_for_uri (uri);
		g_free (uri);

		parse_name = g_file_get_parse_name (file);
		g_object_unref (file);

		nicer_filename = _amtk_utils_replace_home_dir_with_tilde (parse_name);
		g_free (parse_name);

		/* Translators: %s is a filename. */
		ret = g_strdup_printf (_("Open “%s”"), nicer_filename);
		g_free (nicer_filename);

		return ret;
	}

	return NULL;
}

static void
menu_item_selected_cb (AmtkMenuShell *amtk_menu_shell,
		       GtkMenuItem   *menu_item,
		       gpointer       user_data)
{
	AmtkApplicationWindow *amtk_window = AMTK_APPLICATION_WINDOW (user_data);
	gchar *long_description;
	guint context_id;

	if (amtk_window->priv->statusbar == NULL)
	{
		return;
	}

	long_description = get_menu_item_long_description (amtk_menu_shell, menu_item);
	if (long_description == NULL)
	{
		return;
	}

	get_statusbar_context_id_for_menu_shell (amtk_window,
						 amtk_menu_shell,
						 TRUE,
						 &context_id);

	gtk_statusbar_push (amtk_window->priv->statusbar,
			    context_id,
			    long_description);

	g_free (long_description);
}

static void
menu_item_deselected_cb (AmtkMenuShell *amtk_menu_shell,
			 GtkMenuItem   *menu_item,
			 gpointer       user_data)
{
	AmtkApplicationWindow *amtk_window = AMTK_APPLICATION_WINDOW (user_data);
	const gchar *long_description;
	gpointer data;
	gboolean is_for_recent_chooser;
	guint context_id;

	if (amtk_window->priv->statusbar == NULL)
	{
		return;
	}

	long_description = amtk_menu_item_get_long_description (menu_item);

	data = g_object_get_data (G_OBJECT (amtk_menu_shell), MENU_SHELL_FOR_RECENT_CHOOSER_KEY);
	is_for_recent_chooser = data != NULL ? GPOINTER_TO_INT (data) : FALSE;

	if (long_description == NULL && !is_for_recent_chooser)
	{
		return;
	}

	if (get_statusbar_context_id_for_menu_shell (amtk_window,
						     amtk_menu_shell,
						     FALSE,
						     &context_id))
	{
		gtk_statusbar_pop (amtk_window->priv->statusbar, context_id);
	}
}

static void
statusbar_notify_cb (AmtkApplicationWindow *amtk_window,
		     GParamSpec            *pspec,
		     gpointer               user_data)
{
	AmtkMenuShell *amtk_menu_shell = AMTK_MENU_SHELL (user_data);

	g_object_set_data (G_OBJECT (amtk_menu_shell),
			   MENU_SHELL_STATUSBAR_CONTEXT_ID_KEY,
			   NULL);
}

/**
 * amtk_application_window_connect_menu_to_statusbar:
 * @amtk_window: an #AmtkApplicationWindow.
 * @menu_shell: a #GtkMenuShell.
 *
 * Connects to the #AmtkMenuShell::menu-item-selected and
 * #AmtkMenuShell::menu-item-deselected signals of @menu_shell to push/pop the
 * long description of #GtkMenuItem's to the #AmtkApplicationWindow:statusbar.
 *
 * The long description is retrieved with amtk_menu_item_get_long_description().
 * So amtk_menu_item_set_long_description() must have been called, which is the
 * case if the #GtkMenuItem has been created with #AmtkFactory.
 *
 * Since: 2.0
 */
void
amtk_application_window_connect_menu_to_statusbar (AmtkApplicationWindow *amtk_window,
						   GtkMenuShell          *menu_shell)
{
	AmtkMenuShell *amtk_menu_shell;

	g_return_if_fail (AMTK_IS_APPLICATION_WINDOW (amtk_window));
	g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell));

	amtk_menu_shell = amtk_menu_shell_get_from_gtk_menu_shell (menu_shell);

	g_signal_connect_object (amtk_menu_shell,
				 "menu-item-selected",
				 G_CALLBACK (menu_item_selected_cb),
				 amtk_window,
				 0);

	g_signal_connect_object (amtk_menu_shell,
				 "menu-item-deselected",
				 G_CALLBACK (menu_item_deselected_cb),
				 amtk_window,
				 0);

	g_signal_connect_object (amtk_window,
				 "notify::statusbar",
				 G_CALLBACK (statusbar_notify_cb),
				 amtk_menu_shell,
				 0);
}

/**
 * amtk_application_window_connect_recent_chooser_menu_to_statusbar:
 * @amtk_window: an #AmtkApplicationWindow.
 * @menu: a #GtkRecentChooserMenu.
 *
 * An alternative to gtk_recent_chooser_set_show_tips(). Shows the full path in
 * the #AmtkApplicationWindow:statusbar when a #GtkMenuItem of @menu is
 * selected.
 *
 * The full path is retrieved with
 * amtk_utils_recent_chooser_menu_get_item_uri().
 *
 * Since: 2.0
 */
void
amtk_application_window_connect_recent_chooser_menu_to_statusbar (AmtkApplicationWindow *amtk_window,
								  GtkRecentChooserMenu  *menu)
{
	AmtkMenuShell *amtk_menu_shell;

	g_return_if_fail (AMTK_IS_APPLICATION_WINDOW (amtk_window));
	g_return_if_fail (GTK_IS_RECENT_CHOOSER_MENU (menu));

	amtk_menu_shell = amtk_menu_shell_get_from_gtk_menu_shell (GTK_MENU_SHELL (menu));

	g_object_set_data (G_OBJECT (amtk_menu_shell),
			   MENU_SHELL_FOR_RECENT_CHOOSER_KEY,
			   GINT_TO_POINTER (TRUE));

	amtk_application_window_connect_menu_to_statusbar (amtk_window, GTK_MENU_SHELL (menu));
}

/**
 * amtk_application_window_create_open_recent_menu_base:
 *
 * Creates the base of a simple and generic #GtkRecentChooserMenu.
 *
 * The #GtkRecentChooser is configured to show files only recently used with the
 * current application, as returned by g_get_application_name(). If recent files
 * are added to the default #GtkRecentManager with
 * gtk_recent_manager_add_item(), the files will normally show up in the
 * #GtkRecentChooserMenu.
 *
 * Returns: (transfer floating): a new #GtkRecentChooserMenu.
 * Since: 5.6
 */
GtkRecentChooserMenu *
amtk_application_window_create_open_recent_menu_base (void)
{
	GtkRecentChooserMenu *recent_chooser_menu;
	GtkRecentChooser *recent_chooser;
	GtkRecentFilter *filter;

	recent_chooser_menu = GTK_RECENT_CHOOSER_MENU (gtk_recent_chooser_menu_new ());

	recent_chooser = GTK_RECENT_CHOOSER (recent_chooser_menu);
	gtk_recent_chooser_set_local_only (recent_chooser, FALSE);
	gtk_recent_chooser_set_sort_type (recent_chooser, GTK_RECENT_SORT_MRU);

	filter = gtk_recent_filter_new ();
	gtk_recent_filter_add_application (filter, g_get_application_name ());
	gtk_recent_chooser_set_filter (recent_chooser, filter);

	return recent_chooser_menu;
}

static void
open_recent_file_cb (GtkRecentChooser *recent_chooser,
		     gpointer          user_data)
{
	AmtkApplicationWindow *amtk_window = AMTK_APPLICATION_WINDOW (user_data);
	gchar *uri;
	GFile *files[1];
	GtkApplication *app;

	uri = gtk_recent_chooser_get_current_uri (recent_chooser);
	files[0] = g_file_new_for_uri (uri);

	app = gtk_window_get_application (GTK_WINDOW (amtk_window->priv->gtk_window));
	g_application_open (G_APPLICATION (app), files, 1, "");

	g_free (uri);
	g_object_unref (files[0]);
}

/**
 * amtk_application_window_create_open_recent_menu:
 * @amtk_window: an #AmtkApplicationWindow.
 *
 * This function creates a #GtkRecentChooserMenu with
 * amtk_application_window_create_open_recent_menu_base(), and setup these
 * additional things:
 *
 * - The #GtkRecentChooserMenu is connected to the statusbar with
 *   amtk_application_window_connect_recent_chooser_menu_to_statusbar().
 *
 * - When the #GtkRecentChooser::item-activated signal is emitted,
 *   g_application_open() is called (with an empty hint), so the #GApplication
 *   must have the %G_APPLICATION_HANDLES_OPEN flag set.
 *
 * Returns: (transfer floating): a new #GtkRecentChooserMenu.
 * Since: 3.0
 */
GtkWidget *
amtk_application_window_create_open_recent_menu (AmtkApplicationWindow *amtk_window)
{
	GtkRecentChooserMenu *recent_chooser_menu;

	g_return_val_if_fail (AMTK_IS_APPLICATION_WINDOW (amtk_window), NULL);

	recent_chooser_menu = amtk_application_window_create_open_recent_menu_base ();

	amtk_application_window_connect_recent_chooser_menu_to_statusbar (amtk_window, recent_chooser_menu);

	g_signal_connect_object (recent_chooser_menu,
				 "item-activated",
				 G_CALLBACK (open_recent_file_cb),
				 amtk_window,
				 0);

	return GTK_WIDGET (recent_chooser_menu);
}

/**
 * amtk_application_window_create_open_recent_menu_item:
 * @amtk_window: an #AmtkApplicationWindow.
 *
 * Creates a #GtkMenuItem with a simple and generic #GtkRecentChooserMenu as
 * submenu. The #GtkRecentChooserMenu is created with
 * amtk_application_window_create_open_recent_menu().
 *
 * Returns: (transfer floating): a new #GtkMenuItem.
 * Since: 2.0
 */
GtkWidget *
amtk_application_window_create_open_recent_menu_item (AmtkApplicationWindow *amtk_window)
{
	GtkMenuItem *menu_item;
	gchar *long_description;
	GtkWidget *recent_chooser_menu;

	g_return_val_if_fail (AMTK_IS_APPLICATION_WINDOW (amtk_window), NULL);

	menu_item = GTK_MENU_ITEM (gtk_menu_item_new_with_mnemonic (_("Open _Recent")));

	/* Translators: %s is the application name. */
	long_description = g_strdup_printf (_("Open a file recently used with %s"),
					    g_get_application_name ());
	amtk_menu_item_set_long_description (menu_item, long_description);
	g_free (long_description);

	recent_chooser_menu = amtk_application_window_create_open_recent_menu (amtk_window);
	gtk_menu_item_set_submenu (menu_item, recent_chooser_menu);

	return GTK_WIDGET (menu_item);
}

/* ex:set ts=8 noet: */