| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/gtk/process_singleton_dialog.h" | 5 #include "chrome/browser/ui/gtk/process_singleton_dialog.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> |
| 8 |
| 7 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 8 #include "chrome/browser/ui/gtk/gtk_util.h" | 10 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 9 #include "grit/chromium_strings.h" | 11 #include "grit/chromium_strings.h" |
| 10 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
| 11 | 13 |
| 12 // static | 14 // static |
| 13 void ProcessSingletonDialog::ShowAndRun(const std::string& message) { | 15 void ProcessSingletonDialog::ShowAndRun(const std::string& message) { |
| 14 ProcessSingletonDialog dialog(message); | 16 ProcessSingletonDialog dialog(message); |
| 15 } | 17 } |
| 16 | 18 |
| 17 ProcessSingletonDialog::ProcessSingletonDialog(const std::string& message) { | 19 ProcessSingletonDialog::ProcessSingletonDialog(const std::string& message) { |
| 18 dialog_ = gtk_message_dialog_new( | 20 dialog_ = gtk_message_dialog_new( |
| 19 NULL, | 21 NULL, |
| 20 static_cast<GtkDialogFlags>(0), | 22 static_cast<GtkDialogFlags>(0), |
| 21 GTK_MESSAGE_ERROR, | 23 GTK_MESSAGE_ERROR, |
| 22 GTK_BUTTONS_NONE, | 24 GTK_BUTTONS_NONE, |
| 23 "%s", | 25 "%s", |
| 24 message.c_str()); | 26 message.c_str()); |
| 25 gtk_util::ApplyMessageDialogQuirks(dialog_); | 27 gtk_util::ApplyMessageDialogQuirks(dialog_); |
| 26 gtk_window_set_title(GTK_WINDOW(dialog_), | 28 gtk_window_set_title(GTK_WINDOW(dialog_), |
| 27 l10n_util::GetStringUTF8(IDS_PRODUCT_NAME).c_str()); | 29 l10n_util::GetStringUTF8(IDS_PRODUCT_NAME).c_str()); |
| 28 gtk_dialog_add_button(GTK_DIALOG(dialog_), GTK_STOCK_QUIT, | 30 gtk_dialog_add_button(GTK_DIALOG(dialog_), GTK_STOCK_QUIT, |
| 29 GTK_RESPONSE_REJECT); | 31 GTK_RESPONSE_REJECT); |
| 30 | 32 |
| 31 g_signal_connect(dialog_, "response", G_CALLBACK(OnResponse), this); | 33 g_signal_connect(dialog_, "response", G_CALLBACK(OnResponseThunk), this); |
| 32 | 34 |
| 33 gtk_widget_show_all(dialog_); | 35 gtk_widget_show_all(dialog_); |
| 34 MessageLoop::current()->Run(); | 36 MessageLoop::current()->Run(); |
| 35 } | 37 } |
| 36 | 38 |
| 37 // static | 39 void ProcessSingletonDialog::OnResponse(GtkWidget* dialog, int response_id) { |
| 38 void ProcessSingletonDialog::OnResponse(GtkWidget* widget, int response, | 40 gtk_widget_destroy(dialog_); |
| 39 ProcessSingletonDialog* dialog) { | |
| 40 gtk_widget_destroy(dialog->dialog_); | |
| 41 MessageLoop::current()->Quit(); | 41 MessageLoop::current()->Quit(); |
| 42 } | 42 } |
| OLD | NEW |