From 0e004c696b0e68b2cff37a4c3315b022a35eaf43 Mon Sep 17 00:00:00 2001 From: Perberos Date: Thu, 1 Dec 2011 22:24:23 -0300 Subject: moving from https://github.com/perberos/mate-desktop-environment --- libcaja-private/caja-recent.c | 80 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 libcaja-private/caja-recent.c (limited to 'libcaja-private/caja-recent.c') diff --git a/libcaja-private/caja-recent.c b/libcaja-private/caja-recent.c new file mode 100644 index 00000000..7d496678 --- /dev/null +++ b/libcaja-private/caja-recent.c @@ -0,0 +1,80 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Copyright (C) 2002 James Willcox + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "caja-recent.h" + +#include + +#define DEFAULT_APP_EXEC "mate-open %u" + +static GtkRecentManager * +caja_recent_get_manager (void) +{ + static GtkRecentManager *manager = NULL; + + if (manager == NULL) + { + manager = gtk_recent_manager_get_default (); + } + + return manager; +} + +void +caja_recent_add_file (CajaFile *file, + GAppInfo *application) +{ + GtkRecentData recent_data; + char *uri; + + uri = caja_file_get_uri (file); + + /* do not add trash:// etc */ + if (eel_uri_is_trash (uri) || + eel_uri_is_search (uri) || + eel_uri_is_desktop (uri)) + { + g_free (uri); + return; + } + + recent_data.display_name = NULL; + recent_data.description = NULL; + + recent_data.mime_type = caja_file_get_mime_type (file); + recent_data.app_name = g_strdup (g_get_application_name ()); + + if (application != NULL) + recent_data.app_exec = g_strdup (g_app_info_get_commandline (application)); + else + recent_data.app_exec = g_strdup (DEFAULT_APP_EXEC); + + recent_data.groups = NULL; + recent_data.is_private = FALSE; + + gtk_recent_manager_add_full (caja_recent_get_manager (), + uri, &recent_data); + + g_free (recent_data.mime_type); + g_free (recent_data.app_name); + g_free (recent_data.app_exec); + + g_free (uri); +} -- cgit v1.2.1