Bug 414071 - Let escape key close crash reporter dialog. r=ted
authorArchana <kcarchana77@gmail.com>
Thu, 16 Jan 2014 08:44:45 -0500
changeset 163784 08951f068c4cb198afc98b388a70655d99e379bb
parent 163783 647072336c9e4f5f1e3d876eda5fb0345b537728
child 163785 cfb15dfbdb69cf11ede2ba5d3fd55c5144079d6a
push id38564
push userryanvm@gmail.com
push dateThu, 16 Jan 2014 20:07:29 +0000
treeherdermozilla-inbound@f9374ef0fbed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs414071
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 414071 - Let escape key close crash reporter dialog. r=ted
toolkit/crashreporter/client/crashreporter_gtk_common.cpp
toolkit/crashreporter/client/crashreporter_gtk_common.h
toolkit/crashreporter/client/crashreporter_linux.cpp
--- a/toolkit/crashreporter/client/crashreporter_gtk_common.cpp
+++ b/toolkit/crashreporter/client/crashreporter_gtk_common.cpp
@@ -12,26 +12,31 @@
 #include <gtk/gtk.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <gdk/gdkkeysyms.h>
 
 #include <algorithm>
 #include <string>
 #include <vector>
 
 #include "mozilla/NullPtr.h"
 #include "common/linux/http_upload.h"
 #include "crashreporter.h"
 #include "crashreporter_gtk_common.h"
 
+#ifndef GDK_KEY_Escape
+#define GDK_KEY_Escape GDK_Escape
+#endif
+
 using std::string;
 using std::vector;
 
 using namespace CrashReporter;
 
 GtkWidget* gWindow = 0;
 GtkWidget* gSubmitReportCheck = 0;
 GtkWidget* gIncludeURLCheck = 0;
@@ -210,24 +215,35 @@ gpointer SendThread(gpointer args)
   // on the main thread, see:
   // http://library.gnome.org/devel/gtk-faq/stable/x499.html
   g_idle_add(ReportCompleted, (gpointer)success);
 
   return nullptr;
 }
 
 gboolean WindowDeleted(GtkWidget* window,
-                              GdkEvent* event,
-                              gpointer userData)
+                       GdkEvent* event,
+                       gpointer userData)
 {
   SaveSettings();
   gtk_main_quit();
   return TRUE;
 }
 
+gboolean check_escape(GtkWidget* window,
+                      GdkEventKey* event,
+                      gpointer userData)
+{
+  if (event->keyval == GDK_KEY_Escape) {
+    gtk_main_quit();
+    return TRUE;
+  }
+  return FALSE;
+}
+
 static void MaybeSubmitReport()
 {
   if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gSubmitReportCheck))) {
     gDidTrySend = true;
     SendReport();
   } else {
     gtk_main_quit();
   }
--- a/toolkit/crashreporter/client/crashreporter_gtk_common.h
+++ b/toolkit/crashreporter/client/crashreporter_gtk_common.h
@@ -34,16 +34,17 @@ extern std::string gCACertificateFile;
 extern std::string gSendURL;
 extern std::string gURLParameter;
 
 void LoadProxyinfo();
 gpointer SendThread(gpointer args);
 gboolean WindowDeleted(GtkWidget* window,
                        GdkEvent* event,
                        gpointer userData);
+gboolean check_escape(GtkWidget* window, GdkEventKey* event, gpointer data);
 void SubmitReportChecked(GtkButton* sender, gpointer userData);
 void IncludeURLClicked(GtkButton* sender, gpointer userData);
 void CloseClicked(GtkButton* button,
                   gpointer userData);
 void RestartClicked(GtkButton* button,
                     gpointer userData);
 
 #endif // CRASHREPORTER_GTK_COMMON_H__
--- a/toolkit/crashreporter/client/crashreporter_linux.cpp
+++ b/toolkit/crashreporter/client/crashreporter_linux.cpp
@@ -391,16 +391,17 @@ bool UIShowCrashUI(const string& dumpfil
 
   gWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   gtk_window_set_title(GTK_WINDOW(gWindow),
                        gStrings[ST_CRASHREPORTERTITLE].c_str());
   gtk_window_set_resizable(GTK_WINDOW(gWindow), FALSE);
   gtk_window_set_position(GTK_WINDOW(gWindow), GTK_WIN_POS_CENTER);
   gtk_container_set_border_width(GTK_CONTAINER(gWindow), 12);
   g_signal_connect(gWindow, "delete-event", G_CALLBACK(WindowDeleted), 0);
+  g_signal_connect(gWindow, "key_press_event", G_CALLBACK(check_escape), nullptr);
 
   GtkWidget* vbox = gtk_vbox_new(FALSE, 6);
   gtk_container_add(GTK_CONTAINER(gWindow), vbox);
 
   GtkWidget* titleLabel = gtk_label_new("");
   gtk_box_pack_start(GTK_BOX(vbox), titleLabel, FALSE, FALSE, 0);
   gtk_misc_set_alignment(GTK_MISC(titleLabel), 0, 0.5);
   char* markup = g_strdup_printf("<b>%s</b>",