aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Escalante Urrelo <diegoe@gnome.org>2009-12-18 08:20:35 +0800
committerDiego Escalante Urrelo <diegoe@gnome.org>2009-12-19 05:36:12 +0800
commit7aa9ee599f7a1379b045ad020fc4c4ed94ece79e (patch)
treea0b1b74024dd0fa8f6de4455eaeeadd0b2e83ae7
parente896b194fbff39b480c571483c7d549865f38960 (diff)
downloadgsoc2013-epiphany-7aa9ee599f7a1379b045ad020fc4c4ed94ece79e.tar.gz
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
-rw-r--r--lib/ephy-gui.c85
-rw-r--r--lib/ephy-gui.h5
-rw-r--r--src/bookmarks/ephy-bookmark-properties.c3
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.c4
-rw-r--r--src/ephy-encoding-dialog.c2
-rw-r--r--src/ephy-history-window.c4
-rw-r--r--src/ephy-toolbar-editor.c2
-rw-r--r--src/pdm-dialog.c5
-rw-r--r--src/prefs-dialog.c2
-rw-r--r--src/window-commands.c2
10 files changed, 38 insertions, 76 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
diff --git a/lib/ephy-gui.h b/lib/ephy-gui.h
index 301f05412..b32fd7f20 100644
--- a/lib/ephy-gui.h
+++ b/lib/ephy-gui.h
@@ -64,9 +64,8 @@ gboolean ephy_gui_is_middle_click (void);
gboolean ephy_gui_check_location_writable (GtkWidget *parent,
const char *filename);
-void ephy_gui_help (GtkWindow *parent,
- const char *file_name,
- const char *link_id);
+void ephy_gui_help (GtkWidget *parent,
+ const char *section);
void ephy_gui_window_update_user_time (GtkWidget *window,
guint32 user_time);
diff --git a/src/bookmarks/ephy-bookmark-properties.c b/src/bookmarks/ephy-bookmark-properties.c
index ed8f9b2cd..e08e2add0 100644
--- a/src/bookmarks/ephy-bookmark-properties.c
+++ b/src/bookmarks/ephy-bookmark-properties.c
@@ -383,8 +383,7 @@ bookmark_properties_response_cb (GtkDialog *dialog,
switch (response_id)
{
case GTK_RESPONSE_HELP:
- ephy_gui_help (GTK_WINDOW (dialog),
- "epiphany",
+ ephy_gui_help (GTK_WIDGET (dialog),
"to-edit-bookmark-properties");
return;
case GTK_RESPONSE_ACCEPT:
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c
index ea5c37f7a..db892ba68 100644
--- a/src/bookmarks/ephy-bookmarks-editor.c
+++ b/src/bookmarks/ephy-bookmarks-editor.c
@@ -1114,9 +1114,7 @@ static void
cmd_help_contents (GtkAction *action,
EphyBookmarksEditor *editor)
{
- ephy_gui_help (GTK_WINDOW (editor),
- "epiphany",
- "ephy-managing-bookmarks");
+ ephy_gui_help (GTK_WINDOW (editor), "ephy-managing-bookmarks");
}
static void
diff --git a/src/ephy-encoding-dialog.c b/src/ephy-encoding-dialog.c
index eb986a837..7bb055c73 100644
--- a/src/ephy-encoding-dialog.c
+++ b/src/ephy-encoding-dialog.c
@@ -235,7 +235,7 @@ ephy_encoding_dialog_response_cb (GtkWidget *widget,
{
if (response == GTK_RESPONSE_HELP)
{
- ephy_gui_help (GTK_WINDOW (widget), "epiphany", "text-encoding");
+ ephy_gui_help (widget, "text-encoding");
return;
}
diff --git a/src/ephy-history-window.c b/src/ephy-history-window.c
index 731b20e51..4500c155d 100644
--- a/src/ephy-history-window.c
+++ b/src/ephy-history-window.c
@@ -490,9 +490,7 @@ static void
cmd_help_contents (GtkAction *action,
EphyHistoryWindow *editor)
{
- ephy_gui_help (GTK_WINDOW (editor),
- "epiphany",
- "ephy-managing-history");
+ ephy_gui_help (GTK_WIDGET (editor), "ephy-managing-history");
}
static void
diff --git a/src/ephy-toolbar-editor.c b/src/ephy-toolbar-editor.c
index 8400a4d0c..a583ede62 100644
--- a/src/ephy-toolbar-editor.c
+++ b/src/ephy-toolbar-editor.c
@@ -134,7 +134,7 @@ ephy_toolbar_editor_response (GtkDialog *dialog,
}
else if (response == GTK_RESPONSE_HELP)
{
- ephy_gui_help (GTK_WINDOW (dialog), "epiphany", "to-edit-toolbars");
+ ephy_gui_help (GTK_WIDGET (dialog), "to-edit-toolbars");
return;
}
diff --git a/src/pdm-dialog.c b/src/pdm-dialog.c
index 39fa7b709..8b1633f83 100644
--- a/src/pdm-dialog.c
+++ b/src/pdm-dialog.c
@@ -183,7 +183,7 @@ pdm_dialog_show_help (PdmDialog *pd)
id = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
g_return_if_fail (id == 0 || id == 1);
- ephy_gui_help (GTK_WINDOW (window), "epiphany", help_preferences[id]);
+ ephy_gui_help (window, help_preferences[id]);
}
typedef struct
@@ -255,8 +255,7 @@ clear_all_dialog_response_cb (GtkDialog *dialog,
if (response == GTK_RESPONSE_HELP)
{
/* Show help and return early */
-
- ephy_gui_help (GTK_WINDOW (dialog), "epiphany", "clearing-personal-data");
+ ephy_gui_help (GTK_WIDGET (dialog), "clearing-personal-data");
return;
}
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index ca94c28f4..60936b2c0 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -241,7 +241,7 @@ prefs_dialog_show_help (EphyDialog *dialog)
id = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
id = CLAMP (id, 0, 3);
- ephy_gui_help (GTK_WINDOW (window), "epiphany", help_preferences[id]);
+ ephy_gui_help (window, help_preferences[id]);
}
static void
diff --git a/src/window-commands.c b/src/window-commands.c
index c94035682..e4c799897 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -895,7 +895,7 @@ void
window_cmd_help_contents (GtkAction *action,
EphyWindow *window)
{
- ephy_gui_help (GTK_WINDOW (window), "epiphany", NULL);
+ ephy_gui_help (GTK_WIDGET (window), NULL);
}
#define ABOUT_GROUP "About"