Re: [Proposal] Helper functions in GTK+ for showing help and URIs



On Feb 18, 2008 1:20 PM, Alexander Larsson <alexl redhat com> wrote:
>
> On Sun, 2008-02-17 at 14:00 +0100, Jaap A. Haitsma wrote:
>
> > Hi,
> >
> > Currently applications need quite some code to show help or to show an
> > URI, if you don't want to depend on the deprecated libgnomeui and
> > gnome-vfs. My proposal is to add to function to gtk+: gtk_show_help
> > and gtk_show_uri
> >
> > I attached gtk_show.c with these functions implemented.
> >
> > Comments?
>
> If gtk_show_uri doesn't take an (optional) event timestamp, then all
> users of it will be unable to use focus stealing prevention.
>
Alex, Emanuelle,

Thanks for your comments. I've incorporated them (see attachment)
If there is consensus that these functions should be incorporated in
GTK+, I can add documentation and prepare a patch for GTK+ trunk

Comments?


Jaap
#include <glib.h>
#include <gio/gio.h>
#include "gtkwidget.h"

gboolean
gtk_show_help (GtkWidget *parent, 
	       const char* application_name, 
               const char* section, 
               guint32 timestamp, 
               GError **error)
{
  char *uri;
  gboolean ret;

  g_return_if_fail (application_name != NULL);

  if (section && *section != '\0')
    uri = g_strconcat ("ghelp:",
                        application_name,
                        "?",
                        section,
                        NULL);
  else
    uri = g_strconcat ("ghelp:", application_name, NULL);

  ret = gtk_show_uri (parent, uri, timestamp error);

  g_free (uri);
}

gboolean
gtk_show_uri (GtkWidget *parent, 
              const char* uri, 
              guint32 timestamp, 
              GError **error)
{
  GdkAppLaunchContext *context;
  GdkScreen *screen;

  g_return_if_fail (uri != NULL);

  context = gdk_app_launch_context_new ();

  if (parent)
    screen = gtk_widget_get_screen (parent);
  else
    screen = gdk_screen_get_default ();

  gdk_app_launch_context_set_screen (context, screen);
  
  gdk_app_launch_context_set_timestamp (context, timestamp);

  ret = g_app_info_launch_default_for_uri (uri, app_context, error);
  g_object_unref (context);

  return ret;
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]