|
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@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
gtk_show_uri (NULL, "ghelp:cheese", timestamp, &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 (dialog),
"%s", error->message);
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
gtk_window_present (GTK_WINDOW (dialog));
g_error_free (error);
}Opening a specific section like the intro for cheese can be done like this
gtk_show_uri (NULL, "ghelp:cheese?intro", timestamp, &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 (dialog),
"%s", error->message);
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
gtk_window_present (GTK_WINDOW (dialog));
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
|
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.
Tarball |
Status |
Desktop |
|
alacarte |
to do |
bug-buddy |
to do |
to do |
|
to do |
|
dasher |
not needed |
not needed |
|
eel |
not needed |
to do |
|
to do |
|
to do |
|
to do |
|
evolution-data-server |
not needed |
to do |
|
evolution-exchange |
not needed |
evolution-webcal |
not needed |
fast-user-switch-applet |
to do |
file-roller |
done |
gcalctool |
to do |
gconf-editor |
to do |
to do |
|
done |
|
to do |
|
gnome-backgrounds |
not needed |
gnome-desktop |
not needed |
not needed |
|
to do |
|
gnome-icon-theme |
not needed |
gnome-keyring |
not needed |
gnome-netstatus |
to do |
gnome-nettool |
to do |
gnome-mag |
to do |
to do |
|
gnome-menus |
to do |
to do |
|
gnome-power-manager |
to do |
gnome-python-desktop |
to do |
to do |
|
gnome-session |
to do |
gnome-settings-daemon |
to do |
to do |
|
gnome-system-monitor |
to do |
to do |
|
gnome-terminal |
to do |
not needed |
|
gnome-user-docs |
not needed |
to do |
|
gnome-volume-manager |
to do |
to do |
|
to do |
|
gst-plugins |
to do |
not needed |
|
gtkhtml |
not needed |
not needed |
|
to do |
|
gvfs |
not needed |
libgail-gnome |
not needed |
libgnomekbd |
to do |
libgtop |
not needed |
libgweather |
not needed |
liboobs |
not needed |
librsvg |
not needed |
not needed |
|
libwnck |
not needed |
metacity |
not needed |
mousetweaks |
to do |
to do |
|
nautilus-cd-burner |
to do |
orca |
not needed |
pygtksourceview |
not needed |
to do |
|
to do |
|
swfdec-gnome |
not needed |
tomboy |
not needed |
totem-pl-parser |
not needed |
vino |
to do |
vinagre |
|
vte |
not needed |
to do |
|
not needed |
|
Desktop (to be deprecated) |
|
libgnomeprint |
not needed |
libgnomeprintui |
not needed |
Platform |
|
not needed |
|
Admin |
|
not needed |
|
sabayon |
not needed |
Development Tools |
|
accerciser |
to do |
anjuta |
to do |
devhelp |
to do |
gdl |
not needed |
glade3 |
to do |
Other |
|
brasero |
to do |
gthumb |
to do |
nemiver |
to do |
rhythmbox |
to do |
