[epiphany] ephy_gui_help: use gtk_show_uri to open help
- From: Diego Escalante Urrelo <diegoe src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [epiphany] ephy_gui_help: use gtk_show_uri to open help
- Date: Fri, 18 Dec 2009 21:38:23 +0000 (UTC)
commit 7aa9ee599f7a1379b045ad020fc4c4ed94ece79e
Author: Diego Escalante Urrelo <diegoe gnome org>
Date: Thu Dec 17 19:20:35 2009 -0500
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
lib/ephy-gui.c | 85 +++++++++--------------------
lib/ephy-gui.h | 5 +-
src/bookmarks/ephy-bookmark-properties.c | 3 +-
src/bookmarks/ephy-bookmarks-editor.c | 4 +-
src/ephy-encoding-dialog.c | 2 +-
src/ephy-history-window.c | 4 +-
src/ephy-toolbar-editor.c | 2 +-
src/pdm-dialog.c | 5 +-
src/prefs-dialog.c | 2 +-
src/window-commands.c | 2 +-
10 files changed, 38 insertions(+), 76 deletions(-)
---
diff --git a/lib/ephy-gui.c b/lib/ephy-gui.c
index d16eac8..0e495df 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 301f054..b32fd7f 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 ed8f9b2..e08e2ad 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 ea5c37f..db892ba 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 eb986a8..7bb055c 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 731b20e..4500c15 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 8400a4d..a583ede 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 39fa7b7..8b1633f 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 ca94c28..60936b2 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 c940356..e4c7998 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"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]