[gtkmm-documentation] Dialogs chapter: Add Non-modal AboutDialog section.



commit ccd87aad394ba32d7f161b178785e70d11dd4288
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Mon May 27 16:41:46 2013 +0200

    Dialogs chapter: Add Non-modal AboutDialog section.
    
    * docs/tutorial/C/gtkmm-tutorial-in.xml: Add a section that describes a
    non-modal dialog, using Gtk::AboutDialog as an example.
    * docs/tutorial/C/figures/dialogs_about.png: Update this figure.
    * examples/book/dialogs/aboutdialog/examplewindow.[h|cc]: Add a label.

 ChangeLog                                          |    9 ++++++
 docs/tutorial/C/figures/dialogs_about.png          |  Bin 13091 -> 21042 bytes
 docs/tutorial/C/gtkmm-tutorial-in.xml              |   31 ++++++++++++++++++++
 examples/book/dialogs/aboutdialog/examplewindow.cc |   30 ++++++++++++++-----
 examples/book/dialogs/aboutdialog/examplewindow.h  |    2 +
 5 files changed, 64 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 449d252..be377c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2013-05-27  Kjell Ahlstedt <kjell ahlstedt bredband net>
+
+       Dialogs chapter: Add Non-modal AboutDialog section.
+
+       * docs/tutorial/C/gtkmm-tutorial-in.xml: Add a section that describes a
+       non-modal dialog, using Gtk::AboutDialog as an example.
+       * docs/tutorial/C/figures/dialogs_about.png: Update this figure.
+       * examples/book/dialogs/aboutdialog/examplewindow.[h|cc]: Add a label.
+
 2013-05-23  Kjell Ahlstedt <kjell ahlstedt bredband net>
 
        Fix some details in the Clipboard chapter.
diff --git a/docs/tutorial/C/figures/dialogs_about.png b/docs/tutorial/C/figures/dialogs_about.png
index 7b6e1df..44e8749 100644
Binary files a/docs/tutorial/C/figures/dialogs_about.png and b/docs/tutorial/C/figures/dialogs_about.png 
differ
diff --git a/docs/tutorial/C/gtkmm-tutorial-in.xml b/docs/tutorial/C/gtkmm-tutorial-in.xml
index de4cc0c..442e048 100644
--- a/docs/tutorial/C/gtkmm-tutorial-in.xml
+++ b/docs/tutorial/C/gtkmm-tutorial-in.xml
@@ -4044,6 +4044,37 @@ when it is clicked.
 
 </sect1>
 
+<sect1 id="sec-about-dialog"><title>Non-modal AboutDialog</title>
+<para>
+The <classname>AboutDialog</classname> offers a simple way to display information
+about a program, like its logo, name, copyright, website and license.
+</para>
+<para>
+Most dialogs in this chapter are modal, that is, they freeze the rest of
+the application while they are shown. It's also possible to create a non-modal
+dialog, which does not freeze other windows in the application.
+The following example shows a non-modal <classname>AboutDialog</classname>. This is
+perhaps not the kind of dialog you would normally make non-modal, but non-modal
+dialogs can be useful in other cases. E.g. <application>gedit</application>'s
+search-and-replace dialog is non-modal.
+</para>
+
+<para><ulink url="&url_refdocs_base_gtk;AboutDialog.html">Reference</ulink></para>
+
+<sect2 id="aboutdialog-example">
+<title>Example</title>
+
+<figure id="figure-dialogs-about">
+  <title>AboutDialog</title>
+  <screenshot>
+    <graphic format="PNG" fileref="&url_figures_base;dialogs_about.png"/>
+  </screenshot>
+</figure>
+
+<para><ulink url="&url_examples_base;dialogs/aboutdialog">Source Code</ulink></para>
+</sect2>
+
+</sect1>
 
 </chapter>
 
diff --git a/examples/book/dialogs/aboutdialog/examplewindow.cc 
b/examples/book/dialogs/aboutdialog/examplewindow.cc
index 1ac80b0..1427c2c 100644
--- a/examples/book/dialogs/aboutdialog/examplewindow.cc
+++ b/examples/book/dialogs/aboutdialog/examplewindow.cc
@@ -17,25 +17,31 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/aboutdialog.h>
 #include <iostream>
 
-
 ExampleWindow::ExampleWindow()
-: m_ButtonBox(Gtk::ORIENTATION_VERTICAL),
+: m_VBox(Gtk::ORIENTATION_VERTICAL),
+  m_Label("The AboutDialog is non-modal. "
+    "You can select parts of this text while the AboutDialog is shown."),
+  m_ButtonBox(Gtk::ORIENTATION_VERTICAL),
   m_Button("Show AboutDialog")
 {
   set_title("Gtk::AboutDialog example");
 
-  add(m_ButtonBox);
+  add(m_VBox);
+
+  m_VBox.pack_start(m_Label);
+  m_Label.set_line_wrap(true);
+  m_Label.set_selectable(true);
 
+  m_VBox.pack_start(m_ButtonBox);
   m_ButtonBox.pack_start(m_Button);
   m_Button.signal_clicked().connect(sigc::mem_fun(*this,
               &ExampleWindow::on_button_clicked) );
 
   m_Dialog.set_transient_for(*this);
 
-  m_Dialog.set_name("Example application");
+  m_Dialog.set_program_name("Example application");
   m_Dialog.set_version("1.0.0");
   m_Dialog.set_copyright("Murray Cumming");
   m_Dialog.set_comments("This is just an example application.");
@@ -50,9 +56,14 @@ ExampleWindow::ExampleWindow()
   list_authors.push_back("AN Other");
   m_Dialog.set_authors(list_authors);
 
-  m_Dialog.signal_response().connect( sigc::mem_fun(*this, &ExampleWindow::on_about_dialog_response) );
+  m_Dialog.signal_response().connect(
+    sigc::mem_fun(*this, &ExampleWindow::on_about_dialog_response) );
 
   show_all_children();
+
+  // The widget must be realized and mapped before grab_focus() is called.
+  // That's why it's called after show_all_children().
+  m_Button.grab_focus();
 }
 
 ExampleWindow::~ExampleWindow()
@@ -62,7 +73,11 @@ ExampleWindow::~ExampleWindow()
 
 void ExampleWindow::on_about_dialog_response(int response_id)
 {
-  std::cout << response_id << ", close=" << GTK_RESPONSE_CLOSE << ", cancel=" << GTK_RESPONSE_CANCEL << 
std::endl;
+  std::cout << response_id
+    << ", close=" << Gtk::RESPONSE_CLOSE
+    << ", cancel=" << Gtk::RESPONSE_CANCEL
+    << ", delete_event=" << Gtk::RESPONSE_DELETE_EVENT
+    << std::endl;
 
   if((response_id == Gtk::RESPONSE_CLOSE) ||
      (response_id == Gtk::RESPONSE_CANCEL) )
@@ -78,4 +93,3 @@ void ExampleWindow::on_button_clicked()
   //Bring it to the front, in case it was already shown:
   m_Dialog.present();
 }
-
diff --git a/examples/book/dialogs/aboutdialog/examplewindow.h 
b/examples/book/dialogs/aboutdialog/examplewindow.h
index 41d5ca3..9d1c4a3 100644
--- a/examples/book/dialogs/aboutdialog/examplewindow.h
+++ b/examples/book/dialogs/aboutdialog/examplewindow.h
@@ -33,6 +33,8 @@ protected:
   void on_about_dialog_response(int response_id);
 
   //Child widgets:
+  Gtk::Box m_VBox;
+  Gtk::Label m_Label;
   Gtk::ButtonBox m_ButtonBox;
   Gtk::Button m_Button;
   Gtk::AboutDialog m_Dialog;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]