nautilus-3.6.3/libnautilus-private/nautilus-recent.c

No issues found

 1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 2 /*
 3  * Copyright (C) 2002 James Willcox
 4  *
 5  * This program is free software; you can redistribute it and/or modify
 6  * it under the terms of the GNU General Public License as published by
 7  * the Free Software Foundation; either version 2 of the License, or
 8  * (at your option) any later version.
 9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, 
18  * Boston, MA 02111-1307, USA. 
19  */
20 
21 #include "config.h"
22 #include "nautilus-recent.h"
23 
24 #include <eel/eel-vfs-extensions.h>
25 
26 #define DEFAULT_APP_EXEC "gnome-open %u"
27 
28 static GtkRecentManager *
29 nautilus_recent_get_manager (void)
30 {
31 	static GtkRecentManager *manager = NULL;
32 
33 	if (manager == NULL) {
34 		manager = gtk_recent_manager_get_default ();
35 	}
36 
37 	return manager;
38 }
39 
40 void
41 nautilus_recent_add_file (NautilusFile *file,
42 			  GAppInfo *application)
43 {
44 	GtkRecentData recent_data;
45 	char *uri;
46 
47 	uri = nautilus_file_get_activation_uri (file);
48 	if (uri == NULL) {
49 		uri = nautilus_file_get_uri (file);
50 	}
51 
52 	/* do not add trash:// etc */
53 	if (eel_uri_is_trash (uri)  ||
54 	    eel_uri_is_search (uri) ||
55 	    eel_uri_is_recent (uri) ||
56 	    eel_uri_is_desktop (uri)) {
57 		g_free (uri);
58 		return;
59 	}
60 
61 	recent_data.display_name = NULL;
62 	recent_data.description = NULL;
63 
64 	recent_data.mime_type = nautilus_file_get_mime_type (file);
65 	recent_data.app_name = g_strdup (g_get_application_name ());
66 
67 	if (application != NULL)
68 		recent_data.app_exec = g_strdup (g_app_info_get_commandline (application));
69 	else
70 		recent_data.app_exec = g_strdup (DEFAULT_APP_EXEC);
71 
72 	recent_data.groups = NULL;
73 	recent_data.is_private = FALSE;
74 
75 	gtk_recent_manager_add_full (nautilus_recent_get_manager (),
76 				     uri, &recent_data);
77 
78 	g_free (recent_data.mime_type);
79 	g_free (recent_data.app_name);
80 	g_free (recent_data.app_exec);
81 	
82 	g_free (uri);
83 }