[gtkmm-documentation] Dialog examples: Small updates
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm-documentation] Dialog examples: Small updates
- Date: Tue, 12 Jul 2022 16:59:49 +0000 (UTC)
commit e2b64f2bffcbb85a8b834058e41034711008d52c
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Tue Jul 12 18:56:51 2022 +0200
Dialog examples: Small updates
ColorChooserDialog, FileChooserDialog, FileChooserNative,
FontChooserDialog, MessageDialog:
Use std::make_unique. Print value of response_id if an unexpected
button is clicked.
examples/book/dialogs/colorchooserdialog/examplewindow.cc | 2 +-
examples/book/dialogs/filechooserdialog/examplewindow.cc | 4 ++--
examples/book/dialogs/filechoosernative/examplewindow.cc | 2 +-
examples/book/dialogs/fontchooserdialog/examplewindow.cc | 2 +-
examples/book/dialogs/messagedialog/examplewindow.cc | 13 +++++++++----
5 files changed, 14 insertions(+), 9 deletions(-)
---
diff --git a/examples/book/dialogs/colorchooserdialog/examplewindow.cc
b/examples/book/dialogs/colorchooserdialog/examplewindow.cc
index 55ce98f..14388fd 100644
--- a/examples/book/dialogs/colorchooserdialog/examplewindow.cc
+++ b/examples/book/dialogs/colorchooserdialog/examplewindow.cc
@@ -61,7 +61,7 @@ void ExampleWindow::on_button_dialog_clicked()
{
if (!m_pDialog)
{
- m_pDialog.reset(new Gtk::ColorChooserDialog("Please choose a color", *this));
+ m_pDialog = std::make_unique<Gtk::ColorChooserDialog>("Please choose a color", *this);
m_pDialog->set_modal(true);
m_pDialog->set_hide_on_close(true);
m_pDialog->signal_response().connect(
diff --git a/examples/book/dialogs/filechooserdialog/examplewindow.cc
b/examples/book/dialogs/filechooserdialog/examplewindow.cc
index af22fca..8b7d2d7 100644
--- a/examples/book/dialogs/filechooserdialog/examplewindow.cc
+++ b/examples/book/dialogs/filechooserdialog/examplewindow.cc
@@ -99,7 +99,7 @@ void ExampleWindow::on_file_dialog_response(int response_id, Gtk::FileChooserDia
}
default:
{
- std::cout << "Unexpected button clicked." << std::endl;
+ std::cout << "Unexpected button clicked: " << response_id << std::endl;
break;
}
}
@@ -141,7 +141,7 @@ void ExampleWindow::on_folder_dialog_response(int response_id, Gtk::FileChooserD
}
default:
{
- std::cout << "Unexpected button clicked." << std::endl;
+ std::cout << "Unexpected button clicked: " << response_id << std::endl;
break;
}
}
diff --git a/examples/book/dialogs/filechoosernative/examplewindow.cc
b/examples/book/dialogs/filechoosernative/examplewindow.cc
index 850a78f..6594bc2 100644
--- a/examples/book/dialogs/filechoosernative/examplewindow.cc
+++ b/examples/book/dialogs/filechoosernative/examplewindow.cc
@@ -77,7 +77,7 @@ void ExampleWindow::on_dialog_response(int response_id)
break;
default:
- std::cout << "Unexpected button clicked." << std::endl;
+ std::cout << "Unexpected button clicked: " << response_id << std::endl;
break;
}
}
diff --git a/examples/book/dialogs/fontchooserdialog/examplewindow.cc
b/examples/book/dialogs/fontchooserdialog/examplewindow.cc
index 598fa2c..1b99347 100644
--- a/examples/book/dialogs/fontchooserdialog/examplewindow.cc
+++ b/examples/book/dialogs/fontchooserdialog/examplewindow.cc
@@ -53,7 +53,7 @@ void ExampleWindow::on_button_dialog_clicked()
{
if (!m_pDialog)
{
- m_pDialog.reset(new Gtk::FontChooserDialog("Please choose a font", *this));
+ m_pDialog = std::make_unique<Gtk::FontChooserDialog>("Please choose a font", *this);
m_pDialog->set_modal(true);
m_pDialog->set_hide_on_close(true);
m_pDialog->signal_response().connect(
diff --git a/examples/book/dialogs/messagedialog/examplewindow.cc
b/examples/book/dialogs/messagedialog/examplewindow.cc
index eeb7165..f242190 100644
--- a/examples/book/dialogs/messagedialog/examplewindow.cc
+++ b/examples/book/dialogs/messagedialog/examplewindow.cc
@@ -45,7 +45,7 @@ ExampleWindow::~ExampleWindow()
void ExampleWindow::on_button_info_clicked()
{
- m_pDialog.reset(new Gtk::MessageDialog(*this, "This is an INFO MessageDialog"));
+ m_pDialog = std::make_unique<Gtk::MessageDialog>(*this, "This is an INFO MessageDialog");
m_pDialog->set_secondary_text(
"And this is the secondary text that explains things.");
m_pDialog->set_modal(true);
@@ -58,9 +58,9 @@ void ExampleWindow::on_button_info_clicked()
void ExampleWindow::on_button_question_clicked()
{
- m_pDialog.reset(new Gtk::MessageDialog(*this, "This is a QUESTION MessageDialog",
+ m_pDialog = std::make_unique<Gtk::MessageDialog>(*this, "This is a QUESTION MessageDialog",
false /* use_markup */, Gtk::MessageType::QUESTION,
- Gtk::ButtonsType::OK_CANCEL, true /* modal */));
+ Gtk::ButtonsType::OK_CANCEL, true /* modal */);
m_pDialog->set_secondary_text(
"And this is the secondary text that explains things.");
m_pDialog->set_hide_on_close(true);
@@ -87,9 +87,14 @@ void ExampleWindow::on_question_dialog_response(int response_id)
std::cout << "Cancel clicked." << std::endl;
break;
}
+ case Gtk::ResponseType::DELETE_EVENT:
+ {
+ std::cout << "Dialog closed." << std::endl;
+ break;
+ }
default:
{
- std::cout << "Unexpected button clicked." << std::endl;
+ std::cout << "Unexpected button clicked: " << response_id << std::endl;
break;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]