GNOME Goal: Replace gnome_help and gnome-open calls with gtk_show_uri

Currently many GNOME apps still use gnome_help calls and code that uses launching of gnome-open to open files. The gnome_help API and the gnome-open are part of the libgnome library which is deprecated.

GTK+ 2.13.1 contains a new API call gtk_show_uri to replace gnome_help and gnome-open. Programs that don't depend on libgnome usually spawn xdg-open. Replacing that with gtk_show_uri is a cleaner solution.

/**
 * gtk_show_uri:
 * @screen: screen to show the uri on or %NULL for the default screen
 * @uri: the uri to show
 * @timestamp: a timestamp to prevent focus stealing. 
 * @error: a #GError that is returned in case of errors
 *
 * This is a convenience function for launching the default application 
 * to show the uri. The uri must be of a form understood by GIO. Typical
 * examples are 
 * <simplelist>
 *   <member><filename>file:///home/gnome/pict.jpg</filename></member>
 *   <member><filename>http://www.gnome.org</filename></member>
 *   <member><filename>mailto:me&commat;gnome.org</filename></member>
 * </simplelist>
 * Ideally the timestamp is taken from the event triggering 
 * the gtk_show_uri() call. If timestamp is not known you can take 
 * %GDK_CURRENT_TIME.
 *
 * This function can be used as a replacement for gnome_vfs_url_show() 
 * and gnome_url_show().
 *
 * Returns: %TRUE on success, %FALSE on error.
 *
 * Since: 2.14
 */

Opening help file with gtk_show_uri

E.g opening the help for cheese can be done like this

screen = gtk_widget_get_screen (cheese_window->window);
gtk_show_uri (screen, "ghelp:cheese",  gtk_get_current_event_time (), &error);

if (error != NULL)
{
  GtkWidget *d;
  d = gtk_message_dialog_new (GTK_WINDOW (cheese_window->window), 
                              GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
                              GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, 
                              "%s", _("Unable to open help file"));
  gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (d),
                                                                  "%s", error->message);
  g_signal_connect (d, "response", G_CALLBACK (gtk_widget_destroy), NULL);
  gtk_window_present (GTK_WINDOW (d));

  g_error_free (error);
}

Opening a specific section like the intro for cheese can be done like this

screen = gtk_widget_get_screen (cheese_window->window);

gtk_show_uri (screen, "ghelp:cheese?intro",  gtk_get_current_event_time (), &error);

if (error != NULL)
{
  GtkWidget *d;
  d = gtk_message_dialog_new (GTK_WINDOW (cheese_window->window), 
                              GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
                              GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, 
                              "%s", _("Unable to open help file"));
  gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (d),
                                                                  "%s", error->message);
  g_signal_connect (d, "response", G_CALLBACK (gtk_widget_destroy), NULL);
  gtk_window_present (GTK_WINDOW (d));

  g_error_free (error);
}

Note that for the timestamp to pass to gtk_show_uri, you should take the event time as taken from the GdkEventKey, GdkEventButton etc event that triggers the action, or use gtk_get_current_event_time(). Only as a last resort should GDK_CURRENT_TIME be used.

Comments

Status of this goal

/!\ Note: Updated automatical stats can be found at http://www.gnome.org/~fpeters/reports/gnome_help.html

{i} Tip: If you choose to work on a module, create the bug report on the GNOME bugzilla. This way people will know someone already works on it, and won't duplicate the work you're doing.

State

Markup

todo

<: #ff8080> todo

patch

<: #ffc849> [[GnomeBug:xxxxx|patch]]

done

<: #80ff80> [[GnomeBug:xxxxx|done]]

not needed

<: #80ff80> not needed

Above are the states and corresponding markup to update the modules state table below.

/!\ Warning:
Since the example code above has changed multiple times and people have been marking things as done below, when the goal becomes official, a small team should quickly check that the updated code in the modules marked as done is okay (you can grep for "ghelp" for this).

Tarball

Status

Desktop

alacarte

done

Uses python: gnome.help_display_desktop

brasero

done

bug-buddy

not needed

cheese

done

dasher

done

deskbar-applet

not needed

ekiga

done

Need to retain older GTK+ compatibility

empathy

done

eog

done

epiphany

not needed

evince

done

evolution-data-server

not needed

evolution

done

evolution-exchange

not needed

evolution-webcal

not needed

file-roller

done

gcalctool

done

gconf-editor

not needed

gdm

not needed

gedit

done

gnome-applets

done

gnome-backgrounds

not needed

gnome-control-center

done

gnome-desktop

not needed

gnome-doc-utils

not needed

gnome-games

done

gnome-icon-theme

not needed

gnome-keyring

not needed

gnome-netstatus

done

gnome-nettool

not needed

gnome-mag

not needed

gnome-media

not needed

Only in gnome-cd and cddb-slave2 (that are deprecated)

gnome-menus

not needed

gnome-panel

not needed

gnome-power-manager

done

gnome-python-desktop

not needed

gnome-screensaver

done

gnome-session

done

gnome-settings-daemon

not needed

gnome-speech

not needed

gnome-system-monitor

done

gnome-system-tools

not needed

gnome-terminal

not needed

gnome-themes

not needed

gnome-user-docs

not needed

gnome-utils

not needed

gok

done

gstreamer

not needed

gst-plugins

not needed

gtk-engines

not needed

gtkhtml

not needed

gtksourceview

not needed

gucharmap

not needed

gvfs

not needed

hamster-applet

not needed

libgail-gnome

not needed

libgnomekbd

not needed

libgtop

not needed

libgweather

not needed

liboobs

not needed

librsvg

not needed

libsoup

not needed

libwnck

not needed

metacity

not needed

mousetweaks

not needed

nautilus

done

Orca

done

Uses python: gnome.help_display_with_doc_id()

pygtksourceview

not needed

seahorse

done

sound-juicer

done

swfdec-gnome

not needed

tomboy

done

totem-pl-parser

not needed

totem

done

vino

done

vinagre

done

vte

not needed

yelp

done

zenity

not needed

Desktop (to be deprecated)

libgnomeprint

not needed

libgnomeprintui

not needed

Platform

gtk+

not needed

Admin

pessulus

done

sabayon

not needed

Development Tools

accerciser

not needed

anjuta

not needed

devhelp

done

gdl

not needed

glade3

not needed

Other

abiword

not needed

gnome_help with a #ifdef, but link to use gtk_show_uri only

dia

done

ghex

done

glom

not needed

Gnumeric

not needed

goffice

not needed

GParted

done

gthumb

done

nemiver

not needed

planner

done

rhythmbox

not needed

Initiatives/GnomeGoals/RemoveGnomeOpenGnomeHelp (last edited 2013-12-18 13:44:50 by LuisMenina)