Improve usage of Granite about dialog

Fixes: https://bugs.launchpad.net/midori/+bug/1020392
This commit is contained in:
Christian Dywan 2012-07-29 13:01:12 +02:00
parent 6c0e9c43f6
commit 21387841d2
1 changed files with 15 additions and 25 deletions

View File

@ -5037,7 +5037,7 @@ _action_about_activate_email (GtkAboutDialog* about,
#endif #endif
static gchar* static gchar*
midori_browser_get_docs () midori_browser_get_docs (gboolean error)
{ {
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
gchar* path = sokoke_find_data_filename ("doc/midori/faq.html", FALSE); gchar* path = sokoke_find_data_filename ("doc/midori/faq.html", FALSE);
@ -5050,7 +5050,7 @@ midori_browser_get_docs ()
return g_strdup ("file://" DOCDIR "/faq.html"); return g_strdup ("file://" DOCDIR "/faq.html");
else else
#endif #endif
return g_strdup ("error:nodocs share/doc/midori/faq.html"); return error ? g_strdup ("error:nodocs share/doc/midori/faq.html") : NULL;
} }
g_free (path); g_free (path);
#else #else
@ -5059,7 +5059,7 @@ midori_browser_get_docs ()
return g_strdup ("file://" DOCDIR "/faq.html"); return g_strdup ("file://" DOCDIR "/faq.html");
else else
#endif #endif
return g_strdup ("error:nodocs " DOCDIR "/faq.html"); return error ? g_strdup ("error:nodocs " DOCDIR "/faq.html") : NULL;
#endif #endif
} }
@ -5075,38 +5075,27 @@ _action_about_activate (GtkAction* action,
"modify it under the terms of the GNU Lesser General Public " "modify it under the terms of the GNU Lesser General Public "
"License as published by the Free Software Foundation; either " "License as published by the Free Software Foundation; either "
"version 2.1 of the License, or (at your option) any later version."); "version 2.1 of the License, or (at your option) any later version.");
GtkWidget* dialog;
#if !GTK_CHECK_VERSION (2, 24, 0) #if !GTK_CHECK_VERSION (2, 24, 0)
gtk_about_dialog_set_email_hook (_action_about_activate_email, NULL, NULL); gtk_about_dialog_set_email_hook (_action_about_activate_email, NULL, NULL);
gtk_about_dialog_set_url_hook (_action_about_activate_link, browser, NULL); gtk_about_dialog_set_url_hook (_action_about_activate_link, browser, NULL);
#endif #endif
#ifdef HAVE_GRANITE #ifdef HAVE_GRANITE
/* FIXME: granite: should return GtkWidget* like GTK+ */ gchar* docs = midori_browser_get_docs (FALSE);
dialog = (GtkWidget*)granite_widgets_about_dialog_new (); granite_widgets_show_about_dialog (GTK_WINDOW (browser),
{
gchar* docs = midori_browser_get_docs ();
if (!g_str_has_prefix (docs, "error:"))
g_object_set (dialog, "help", docs, NULL);
g_free (docs);
}
g_object_set (dialog,
"translate", "https://translations.xfce.org/projects/p/midori/", "translate", "https://translations.xfce.org/projects/p/midori/",
"bugs", PACKAGE_BUGREPORT, "bug", PACKAGE_BUGREPORT,
NULL); "help", docs,
"copyright", "2007-2011 Christian Dywan",
#else #else
dialog = gtk_about_dialog_new (); gtk_show_about_dialog (GTK_WINDOW (browser),
g_object_set (dialog,
"wrap-license", TRUE, "wrap-license", TRUE,
NULL); "copyright", "Copyright © 2007-2011 Christian Dywan",
#endif #endif
g_object_set (dialog,
"transient-for", browser,
"logo-icon-name", gtk_window_get_icon_name (GTK_WINDOW (browser)), "logo-icon-name", gtk_window_get_icon_name (GTK_WINDOW (browser)),
"name", PACKAGE_NAME, "program-name", PACKAGE_NAME,
"version", PACKAGE_VERSION, "version", PACKAGE_VERSION,
"comments", comments, "comments", comments,
"copyright", "Copyright © 2007-2011 Christian Dywan",
"website", "http://www.twotoasts.de", "website", "http://www.twotoasts.de",
"authors", credits_authors, "authors", credits_authors,
"documenters", credits_documenters, "documenters", credits_documenters,
@ -5115,8 +5104,9 @@ _action_about_activate (GtkAction* action,
"translator-credits", _("translator-credits"), "translator-credits", _("translator-credits"),
NULL); NULL);
g_free (comments); g_free (comments);
gtk_dialog_run (GTK_DIALOG (dialog)); #ifdef HAVE_GRANITE
gtk_widget_destroy (dialog); g_free (docs);
#endif
} }
static void static void
@ -5126,7 +5116,7 @@ _action_help_link_activate (GtkAction* action,
const gchar* action_name = gtk_action_get_name (action); const gchar* action_name = gtk_action_get_name (action);
gchar* uri = NULL; gchar* uri = NULL;
if (!strncmp ("HelpFAQ", action_name, 7)) if (!strncmp ("HelpFAQ", action_name, 7))
uri = midori_browser_get_docs (); uri = midori_browser_get_docs (TRUE);
else if (!strncmp ("HelpBugs", action_name, 8)) else if (!strncmp ("HelpBugs", action_name, 8))
{ {
if (!g_spawn_command_line_async ("ubuntu-bug " PACKAGE_NAME, NULL)) if (!g_spawn_command_line_async ("ubuntu-bug " PACKAGE_NAME, NULL))