diff options
author | Diego Escalante Urrelo <diegoe@gnome.org> | 2009-12-18 08:20:35 +0800 |
---|---|---|
committer | Diego Escalante Urrelo <diegoe@gnome.org> | 2009-12-19 05:36:12 +0800 |
commit | 7aa9ee599f7a1379b045ad020fc4c4ed94ece79e (patch) | |
tree | a0b1b74024dd0fa8f6de4455eaeeadd0b2e83ae7 /lib/ephy-gui.c | |
parent | e896b194fbff39b480c571483c7d549865f38960 (diff) | |
download | gsoc2013-epiphany-7aa9ee599f7a1379b045ad020fc4c4ed94ece79e.tar gsoc2013-epiphany-7aa9ee599f7a1379b045ad020fc4c4ed94ece79e.tar.gz gsoc2013-epiphany-7aa9ee599f7a1379b045ad020fc4c4ed94ece79e.tar.bz2 gsoc2013-epiphany-7aa9ee599f7a1379b045ad020fc4c4ed94ece79e.tar.lz gsoc2013-epiphany-7aa9ee599f7a1379b045ad020fc4c4ed94ece79e.tar.xz gsoc2013-epiphany-7aa9ee599f7a1379b045ad020fc4c4ed94ece79e.tar.zst gsoc2013-epiphany-7aa9ee599f7a1379b045ad020fc4c4ed94ece79e.zip |
ephy_gui_help: use gtk_show_uri to open help
We were doing some ugly path searching for this. The correct method is to use
gtk_show_uri.
Bug #604024
Diffstat (limited to 'lib/ephy-gui.c')
-rw-r--r-- | lib/ephy-gui.c | 85 |
1 files changed, 27 insertions, 58 deletions
diff --git a/lib/ephy-gui.c b/lib/ephy-gui.c index d16eac8fc..0e495df82 100644 --- a/lib/ephy-gui.c +++ b/lib/ephy-gui.c @@ -355,68 +355,37 @@ ephy_gui_check_location_writable (GtkWidget *parent, return TRUE; } -static gboolean -open_url (GtkWindow *parent, - const char *uri, - guint32 user_time, - GError **error) +/** + * ephy_gui_help: + * @parent: the parent window where help is being called + * @section: help section to open or %NULL + * + * Displays Epiphany's help, opening the section indicated by @section. + * + * Note that @parent is used to know the #GdkScreen where to open the help + * window. + **/ +void +ephy_gui_help (GtkWidget *parent, + const char *section) { - GdkScreen *screen; + GError *error = NULL; + GdkScreen *screen; + char *url; - if (parent) - screen = gtk_widget_get_screen (GTK_WIDGET (parent)); - else - screen = gdk_screen_get_default (); + if (section) + url = g_strdup_printf ("ghelp:epiphany?%s", section); + else + url = g_strdup ("ghelp:epiphany"); - return gtk_show_uri (screen, uri, user_time, error); -} + screen = gtk_widget_get_screen (parent); + gtk_show_uri (screen, url, gtk_get_current_event_time (), &error); -void -ephy_gui_help (GtkWindow *parent, - const char *file_name, - const char *link_id) -{ - GError *error = NULL; - const char *lang; - char *uri = NULL, *url; - guint i; - - const char * const * langs = g_get_language_names (); - for (i = 0; langs[i]; i++) { - lang = langs[i]; - if (strchr (lang, '.')) - continue; - - uri = g_build_filename (DATADIR, - "gnome", "help", PACKAGE, - lang, - file_name, - NULL); - - if (g_file_test (uri, G_FILE_TEST_EXISTS)) - break; - - g_free (uri); - uri = NULL; - } - - if (!uri) - return; - - if (link_id) - { - url = g_strdup_printf ("ghelp://%s?%s", uri, link_id); - } - else - { - url = g_strdup_printf ("ghelp://%s", uri); - } - - if (!open_url (parent, url, gtk_get_current_event_time (), &error)) - { + if (error != NULL) + { GtkWidget *dialog; - dialog = gtk_message_dialog_new (parent, + dialog = gtk_message_dialog_new (GTK_WINDOW (parent), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, @@ -427,9 +396,9 @@ ephy_gui_help (GtkWindow *parent, g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL); gtk_widget_show (dialog); - } + } - g_free (url); + g_free (url); } void |