/* $Id$ */ /*- * Copyright (c) 2005 Benedikt Meurer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H #include #endif #include #include struct _ThunarVfsMimeAction { gint ref_count; gchar *name; gchar *icon; gchar *exec; }; GType thunar_vfs_mime_action_get_type (void) { static GType type = G_TYPE_INVALID; if (G_UNLIKELY (type == G_TYPE_INVALID)) { type = g_boxed_type_register_static ("ThunarVfsMimeAction", (GBoxedCopyFunc) thunar_vfs_mime_action_ref, (GBoxedFreeFunc) thunar_vfs_mime_action_unref); } return type; } /** * thunar_vfs_mime_action_new: * @name : the name of the action. * @icon : the icon for the action or %NULL. * @exec : the command line string. * * Allocates a new #ThunarVfsMimeAction with * the given @name, @icon and @exec, and an * initial reference count of one. * * The caller is responsible to free the * returned instance using * thunar_vfs_mime_action_unref() when no * longer needed. * * Return value: the newly allocated * #ThunarVfsMimeAction. **/ ThunarVfsMimeAction* thunar_vfs_mime_action_new (const gchar *name, const gchar *icon, const gchar *exec) { ThunarVfsMimeAction *action; g_return_val_if_fail (name != NULL, NULL); g_return_val_if_fail (exec != NULL, NULL); action = g_new (ThunarVfsMimeAction, 1); action->ref_count = 1; action->name = g_strdup (name); action->icon = g_strdup (icon); action->exec = g_strdup (exec); return action; } /** * thunar_vfs_mime_action_ref: * @action : a #ThunarVfsMimeAction. * * Increases the reference count on @action by * one and returns a reference to @action. * * Return value: a reference to @action. **/ ThunarVfsMimeAction* thunar_vfs_mime_action_ref (ThunarVfsMimeAction *action) { _thunar_vfs_sysdep_ref (&action->ref_count); return action; } /** * thunar_vfs_mime_action_unref: * @action : a #ThunarVfsMimeAction. * * Decreases the reference count on @action by one * and releases the resources allocated for @action * once the reference count drops to zero. **/ void thunar_vfs_mime_action_unref (ThunarVfsMimeAction *action) { if (_thunar_vfs_sysdep_unref (&action->ref_count)) { g_free (action->name); g_free (action->icon); g_free (action->exec); g_free (action); } } /** * thunar_vfs_mime_action_get_name: * @action : a #ThunarVfsMimeAction. * * Returns the name of @action. * * Return value: the name of @action. **/ const gchar* thunar_vfs_mime_action_get_name (const ThunarVfsMimeAction *action) { return action->name; } /** * thunar_vfs_mime_action_exec: * @action : a #ThunarVfsMimeAction. * @screen : a #GdkScreen %NULL to use the default screen. * @uris : a list of #ThunarVfsURIs to open. * @error : return location for errors or %NULL. * * Wrapper to thunar_vfs_mime_action_exec_with_env(), which * simply passes a %NULL pointer for the environment variables. * * Return value: %TRUE if the execution succeed, else %FALSE. **/ gboolean thunar_vfs_mime_action_exec (const ThunarVfsMimeAction *action, GdkScreen *screen, GList *uris, GError **error) { }