Blame gtk/gtkshow.c

Packit Service fb6fa5
/*
Packit Service fb6fa5
 * GTK - The GIMP Toolkit
Packit Service fb6fa5
 * Copyright (C) 2008  Jaap Haitsma <jaap@haitsma.org>
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * All rights reserved.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * This library is free software; you can redistribute it and/or
Packit Service fb6fa5
 * modify it under the terms of the GNU Lesser General Public
Packit Service fb6fa5
 * License as published by the Free Software Foundation; either
Packit Service fb6fa5
 * version 2 of the License, or (at your option) any later version.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * This library is distributed in the hope that it will be useful,
Packit Service fb6fa5
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service fb6fa5
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service fb6fa5
 * Lesser General Public License for more details.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * You should have received a copy of the GNU Lesser General Public
Packit Service fb6fa5
 * License along with this library; if not, write to the
Packit Service fb6fa5
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Packit Service fb6fa5
 * Boston, MA 02111-1307, USA.
Packit Service fb6fa5
 */
Packit Service fb6fa5
Packit Service fb6fa5
#include "config.h"
Packit Service fb6fa5
Packit Service fb6fa5
#include <gdk/gdk.h>
Packit Service fb6fa5
Packit Service fb6fa5
#include "gtkshow.h"
Packit Service fb6fa5
Packit Service fb6fa5
#include "gtkalias.h"
Packit Service fb6fa5
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_show_uri:
Packit Service fb6fa5
 * @screen: (allow-none): screen to show the uri on or %NULL for the default screen
Packit Service fb6fa5
 * @uri: the uri to show
Packit Service fb6fa5
 * @timestamp: a timestamp to prevent focus stealing.
Packit Service fb6fa5
 * @error: a #GError that is returned in case of errors
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * This is a convenience function for launching the default application
Packit Service fb6fa5
 * to show the uri. The uri must be of a form understood by GIO (i.e. you
Packit Service fb6fa5
 * need to install gvfs to get support for uri schemes such as http://
Packit Service fb6fa5
 * or ftp://, as only local files are handled by GIO itself).
Packit Service fb6fa5
 * Typical examples are
Packit Service fb6fa5
 * <simplelist>
Packit Service fb6fa5
 *   <member><filename>file:///home/gnome/pict.jpg</filename></member>
Packit Service fb6fa5
 *   <member><filename>http://www.gnome.org</filename></member>
Packit Service fb6fa5
 *   <member><filename>mailto:me@gnome.org</filename></member>
Packit Service fb6fa5
 * </simplelist>
Packit Service fb6fa5
 * Ideally the timestamp is taken from the event triggering
Packit Service fb6fa5
 * the gtk_show_uri() call. If timestamp is not known you can take
Packit Service fb6fa5
 * %GDK_CURRENT_TIME.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * This function can be used as a replacement for gnome_vfs_url_show()
Packit Service fb6fa5
 * and gnome_url_show().
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Returns: %TRUE on success, %FALSE on error.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Since: 2.14
Packit Service fb6fa5
 */
Packit Service fb6fa5
gboolean
Packit Service fb6fa5
gtk_show_uri (GdkScreen    *screen,
Packit Service fb6fa5
              const gchar  *uri,
Packit Service fb6fa5
              guint32       timestamp,
Packit Service fb6fa5
              GError      **error)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GdkAppLaunchContext *context;
Packit Service fb6fa5
  gboolean ret;
Packit Service fb6fa5
Packit Service fb6fa5
  g_return_val_if_fail (uri != NULL, FALSE);
Packit Service fb6fa5
Packit Service fb6fa5
  context = gdk_app_launch_context_new ();
Packit Service fb6fa5
  gdk_app_launch_context_set_screen (context, screen);
Packit Service fb6fa5
  gdk_app_launch_context_set_timestamp (context, timestamp);
Packit Service fb6fa5
Packit Service fb6fa5
  ret = g_app_info_launch_default_for_uri (uri, (GAppLaunchContext*)context, error);
Packit Service fb6fa5
  g_object_unref (context);
Packit Service fb6fa5
Packit Service fb6fa5
  return ret;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
Packit Service fb6fa5
#define __GTK_SHOW_C__
Packit Service fb6fa5
#include "gtkaliasdef.c"