[Xfce4-commits] <midori:master> Add 'Show last crash log' button to diagnostic dialog
Christian Dywan
noreply at xfce.org
Tue Mar 26 08:18:02 CET 2013
Updating branch refs/heads/master
to 7dcbee43f9cb428bccabbee6b256c2482fdca508 (commit)
from be0e4aa9c86c6a51ed94b61f2d6311117b7c10d4 (commit)
commit 7dcbee43f9cb428bccabbee6b256c2482fdca508
Author: Christian Dywan <christian at twotoasts.de>
Date: Sun Mar 24 14:08:28 2013 +0100
Add 'Show last crash log' button to diagnostic dialog
katze/midori-paths.vala | 21 +++++++++++++++------
midori/main.c | 12 ++++++------
midori/midori-frontend.c | 22 ++++++++++++++++++++++
3 files changed, 43 insertions(+), 12 deletions(-)
diff --git a/katze/midori-paths.vala b/katze/midori-paths.vala
index 2f7f540..d404a5f 100644
--- a/katze/midori-paths.vala
+++ b/katze/midori-paths.vala
@@ -35,6 +35,7 @@ namespace Midori {
namespace Paths {
static string? exec_path = null;
static string[] command_line = null;
+ static string? runtime_dir = null;
static RuntimeMode mode = RuntimeMode.UNDEFINED;
static string? config_dir = null;
@@ -74,18 +75,26 @@ namespace Midori {
return mode;
}
- private static string get_runtime_dir () {
+ public static unowned string get_runtime_dir () {
+ if (runtime_dir != null)
+ return runtime_dir;
+
#if HAVE_WIN32
- string? runtime_dir = Environment.get_variable ("XDG_RUNTIME_DIR");
+ runtime_dir = Environment.get_variable ("XDG_RUNTIME_DIR");
if (runtime_dir == null || runtime_dir == "")
runtime_dir = Environment.get_user_data_dir ();
#else
- string? runtime_dir = Environment.get_variable ("XDG_RUNTIME_DIR");
- if (runtime_dir == null || runtime_dir == "")
- return Path.build_path (Path.DIR_SEPARATOR_S,
+ runtime_dir = Environment.get_variable ("XDG_RUNTIME_DIR");
+ if (runtime_dir == null || runtime_dir == "") {
+ runtime_dir = Path.build_path (Path.DIR_SEPARATOR_S,
Environment.get_tmp_dir (), PACKAGE_NAME + "-" + Environment.get_user_name ());
+ mkdir_with_parents (runtime_dir);
+ return runtime_dir;
+ }
#endif
- return Path.build_path (Path.DIR_SEPARATOR_S, runtime_dir, PACKAGE_NAME);
+ runtime_dir = Path.build_path (Path.DIR_SEPARATOR_S, runtime_dir, PACKAGE_NAME);
+ mkdir_with_parents (runtime_dir);
+ return runtime_dir;
}
public static void init (RuntimeMode new_mode, string? config) {
diff --git a/midori/main.c b/midori/main.c
index adc93b0..a24a025 100644
--- a/midori/main.c
+++ b/midori/main.c
@@ -144,15 +144,15 @@ main (int argc,
{
gchar* gdb = g_find_program_in_path ("gdb");
gchar* args = midori_paths_get_command_line_str (FALSE);
+ const gchar* runtime_dir = midori_paths_get_runtime_dir ();
gchar* cmd = g_strdup_printf (
"--batch -ex 'set print thread-events off' -ex run "
- "-ex 'set logging on %s' -ex 'bt' --return-child-result "
+ "-ex 'set logging on %s/%s' -ex 'bt' --return-child-result "
"--args %s",
- "/tmp/midori-gdb.bt", args);
- if (gdb != NULL)
- sokoke_spawn_program (gdb, TRUE, cmd, FALSE, TRUE);
- else
- g_print (_("Error: \"gdb\" can't be found\n"));
+ runtime_dir, "gdb.bt", args);
+ if (gdb == NULL)
+ midori_error (_("Error: \"gdb\" can't be found\n"));
+ sokoke_spawn_program (gdb, TRUE, cmd, FALSE, TRUE);
g_free (gdb);
g_free (cmd);
g_free (args);
diff --git a/midori/midori-frontend.c b/midori/midori-frontend.c
index 6322ff5..c8a8ea8 100644
--- a/midori/midori-frontend.c
+++ b/midori/midori-frontend.c
@@ -296,6 +296,15 @@ button_modify_preferences_clicked_cb (GtkWidget* button,
gtk_widget_destroy (dialog);
}
+static void
+midori_frontend_crash_log_cb (GtkWidget* button,
+ gchar* crash_log)
+{
+ GError* error = NULL;
+ if (!sokoke_show_uri (gtk_widget_get_screen (button), crash_log, 0, &error))
+ midori_error (error->message);
+}
+
static MidoriStartup
midori_frontend_diagnostic_dialog (MidoriApp* app,
MidoriWebSettings* settings,
@@ -343,6 +352,19 @@ midori_frontend_diagnostic_dialog (MidoriApp* app,
_("Show last tabs without loading"), MIDORI_STARTUP_DELAYED_PAGES,
_("Show last open tabs"), MIDORI_STARTUP_LAST_OPEN_PAGES,
NULL);
+
+ gchar* crash_log = g_build_filename (midori_paths_get_runtime_dir (), "gdb.bt", NULL);
+ if (g_access (crash_log, F_OK) == 0)
+ {
+ GtkWidget* button = gtk_button_new_with_mnemonic (_("Show last crash _log"));
+ g_signal_connect_data (button, "clicked",
+ G_CALLBACK (midori_frontend_crash_log_cb), crash_log,
+ (GClosureNotify)g_free, 0);
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 4);
+ }
+ else
+ g_free (crash_log);
gtk_dialog_set_default_response (GTK_DIALOG (dialog),
load_on_startup == MIDORI_STARTUP_HOMEPAGE
? MIDORI_STARTUP_BLANK_PAGE : load_on_startup);
More information about the Xfce4-commits
mailing list