[gtkmm-documentation] Fix 'make check' with the latest gtkmm version
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm-documentation] Fix 'make check' with the latest gtkmm version
- Date: Mon, 24 Mar 2014 11:36:52 +0000 (UTC)
commit 070d462beea3ef5278cdd3b19e16bd8545483444
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Mon Mar 24 12:32:48 2014 +0100
Fix 'make check' with the latest gtkmm version
* examples/book/scrolledwindow/examplewindow.[cc|h]:
Use Gtk::Dialog::add_button() instead of the deprecated get_action_area().
examples/book/scrolledwindow/examplewindow.cc | 34 ++++++++++++------------
examples/book/scrolledwindow/examplewindow.h | 3 +-
2 files changed, 18 insertions(+), 19 deletions(-)
---
diff --git a/examples/book/scrolledwindow/examplewindow.cc b/examples/book/scrolledwindow/examplewindow.cc
index 76334ad..3f68fe3 100644
--- a/examples/book/scrolledwindow/examplewindow.cc
+++ b/examples/book/scrolledwindow/examplewindow.cc
@@ -17,10 +17,9 @@
*/
#include "examplewindow.h"
-#include <cstdio>
+#include <iostream>
ExampleWindow::ExampleWindow()
-: m_Button_Close("Close")
{
set_title("Gtk::ScrolledWindow example");
set_border_width(0);
@@ -58,19 +57,12 @@ ExampleWindow::ExampleWindow()
}
/* Add a "close" button to the bottom of the dialog */
- m_Button_Close.signal_clicked().connect( sigc::mem_fun(*this,
- &ExampleWindow::on_button_close));
+ add_button("_Close", Gtk::RESPONSE_CLOSE);
+ signal_response().connect(sigc::mem_fun(*this, &ExampleWindow::on_dialog_response));
- /* this makes it so the button is the default. */
- m_Button_Close.set_can_default();
-
- Gtk::Box* pBox = get_action_area();
- if(pBox)
- pBox->pack_start(m_Button_Close);
-
- /* This grabs this button to be the default button. Simply hitting
- * the "Enter" key will cause this button to activate. */
- m_Button_Close.grab_default();
+ /* This makes it so the button is the default.
+ * Simply hitting the "Enter" key will cause this button to activate. */
+ set_default_response(Gtk::RESPONSE_CLOSE);
show_all_children();
}
@@ -79,8 +71,16 @@ ExampleWindow::~ExampleWindow()
{
}
-void ExampleWindow::on_button_close()
+void ExampleWindow::on_dialog_response(int response_id)
{
- hide();
+ switch (response_id)
+ {
+ case Gtk::RESPONSE_CLOSE:
+ case Gtk::RESPONSE_DELETE_EVENT:
+ hide();
+ break;
+ default:
+ std::cout << "Unexpected response_id=" << response_id << std::endl;
+ break;
+ }
}
-
diff --git a/examples/book/scrolledwindow/examplewindow.h b/examples/book/scrolledwindow/examplewindow.h
index 3e0e7e3..26b055b 100644
--- a/examples/book/scrolledwindow/examplewindow.h
+++ b/examples/book/scrolledwindow/examplewindow.h
@@ -29,12 +29,11 @@ public:
protected:
//Signal handlers:
- void on_button_close();
+ void on_dialog_response(int response_id);
//Child widgets:
Gtk::ScrolledWindow m_ScrolledWindow;
Gtk::Grid m_Grid;
- Gtk::Button m_Button_Close;
};
#endif //GTKMM_EXAMPLEWINDOW_H
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]