[gtkmm-documentation] Add Gtk::Assistant example and tutorial
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm-documentation] Add Gtk::Assistant example and tutorial
- Date: Thu, 1 Apr 2010 21:41:07 +0000 (UTC)
commit 2e68da2fd2a96f32d7404036377f778e9cc907ce
Author: David King <davidk openismus com>
Date: Thu Apr 1 17:07:16 2010 +0200
Add Gtk::Assistant example and tutorial
* docs/tutorial/Makefile.am:
* docs/tutorial/C/figures/assistant.png: Add screenshot.
* docs/tutorial/C/gtkmm-tutorial-in.xml: Add tutorial text.
* examples/book/assistant/*:
* examples/Makefile.am: Add example source code.
ChangeLog | 10 +++
docs/tutorial/C/figures/assistant.png | Bin 0 -> 17268 bytes
docs/tutorial/C/gtkmm-tutorial-in.xml | 40 +++++++++++
docs/tutorial/Makefile.am | 1 +
examples/Makefile.am | 6 ++
examples/book/assistant/examplewindow.cc | 104 ++++++++++++++++++++++++++++++
examples/book/assistant/examplewindow.h | 46 +++++++++++++
examples/book/assistant/main.cc | 29 ++++++++
8 files changed, 236 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0b5af14..9020d1e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2010-04-01 David King <davidk openismus com>
+ Add Gtk::Assistant example and tutorial text
+
+ * docs/tutorial/Makefile.am:
+ * docs/tutorial/C/figures/assistant.png: Add screenshot.
+ * docs/tutorial/C/gtkmm-tutorial-in.xml: Add tutorial text.
+ * examples/book/assistant/*:
+ * examples/Makefile.am: Add example source code.
+
+2010-04-01 David King <davidk openismus com>
+
Fix capitalisation of Qt in tutorial
* docs/tutorial/C/gtkmm-tutorial-in.xml: Qt, not QT.
diff --git a/docs/tutorial/C/figures/assistant.png b/docs/tutorial/C/figures/assistant.png
new file mode 100644
index 0000000..097d8e8
Binary files /dev/null and b/docs/tutorial/C/figures/assistant.png differ
diff --git a/docs/tutorial/C/gtkmm-tutorial-in.xml b/docs/tutorial/C/gtkmm-tutorial-in.xml
index 420974f..21611bc 100644
--- a/docs/tutorial/C/gtkmm-tutorial-in.xml
+++ b/docs/tutorial/C/gtkmm-tutorial-in.xml
@@ -2679,6 +2679,46 @@ of the <classname>PageList</classname>:
</sect2>
+<sect2 id="sec-assistant">
+<title>Assistant</title>
+
+<para>
+An <classname>Assistant</classname> is used to split a generally complex operation into steps. A step is represented by a page, and each page contains a header, a supplied child widget and an action area. Navigation buttons are provided by the <classname>Assistant</classname> and placed in the action area, and update automatically depending on the type of the page, which can be set with <methodname>set_page_type()</methodname>.
+</para>
+
+<para>
+Use the <methodname>append_page()</methodname>, <methodname>prepend_page</methodname> and <methodname>insert_page()</methodname> methods to add pages to the <classname>Assistant</classname>, supplying the child widget for each page.
+</para>
+
+<para>
+To determine the currently-visible page, use the <methodname>get_current_page()</methodname> method, and pass the result to <methodname>get_nth_page()</methodname>, which returns a pointer to the actual widget. To programmatically change the current page, use the <methodname>set_current_page()</methodname> method.
+</para>
+
+<para>
+To set the title of a page, use the <methodname>set_page_title()</methodname> method. The header and side images of a page can be set with the <methodname>set_page_header_image()</methodname> and <methodname>set_page_side_image()</methodname> methods.
+</para>
+
+<para>
+Widgets can be added to the action area with <methodname>add_action_widget()</methodname>, where they will be packed alongside the buttons provided by the <classname>Assistant</classname>. A widget can be removed with the <methodname>remove_action_widget()</methodname> method.
+</para>
+
+<para><ulink url="&url_refdocs_base_gtk;Assistant.html">Reference</ulink></para>
+
+<sect3 id="assistant-example"><title>Example</title>
+
+<figure id="figure-assistant">
+ <title>Assistant</title>
+ <screenshot>
+ <graphic format="PNG" fileref="&url_figures_base;assistant.png"/>
+ </screenshot>
+</figure>
+
+<para><ulink url="&url_examples_base;assistant/">Source Code</ulink></para>
+
+</sect3>
+
+</sect2>
+
</sect1>
</chapter>
diff --git a/docs/tutorial/Makefile.am b/docs/tutorial/Makefile.am
index 823d84c..f45ed51 100644
--- a/docs/tutorial/Makefile.am
+++ b/docs/tutorial/Makefile.am
@@ -20,6 +20,7 @@ DOC_INCLUDES =
DOC_FIGURES = \
figures/alignment.png \
figures/aspectframe.png \
+ figures/assistant.png \
figures/box_packing1.png \
figures/box_packing2.png \
figures/box_packing3.png \
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 0db3fd1..88af17b 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -9,6 +9,7 @@ LDADD = $(GTKMM_LIBS)
check_PROGRAMS = \
book/alignment/example \
book/aspectframe/example \
+ book/assistant/example \
book/box/example \
book/builder/basic/example \
book/builder/derived/example \
@@ -138,6 +139,11 @@ book_aspectframe_example_SOURCES = \
book/aspectframe/examplewindow.h \
book/aspectframe/main.cc
+book_assistant_example_SOURCES = \
+ book/assistant/examplewindow.cc \
+ book/assistant/examplewindow.h \
+ book/assistant/main.cc
+
book_box_example_SOURCES = \
book/box/examplewindow.cc \
book/box/examplewindow.h \
diff --git a/examples/book/assistant/examplewindow.cc b/examples/book/assistant/examplewindow.cc
new file mode 100644
index 0000000..b1a8cde
--- /dev/null
+++ b/examples/book/assistant/examplewindow.cc
@@ -0,0 +1,104 @@
+/* gtkmm example Copyright (C) 2010 Openismus GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <iostream>
+#include "examplewindow.h"
+
+ExampleWindow::ExampleWindow()
+: m_box(false, 12),
+ m_label1("Type text to allow the assistant to continue:"),
+ m_label2("Confirmation page"),
+ m_check("Optional extra information")
+{
+ set_title("Gtk::Assistant example");
+ set_border_width(12);
+ set_default_size(400, 300);
+
+ m_box.pack_start(m_label1);
+ m_box.pack_start(m_entry);
+
+ append_page(m_box);
+ append_page(m_check);
+ append_page(m_label2);
+
+ set_page_title(*get_nth_page(0), "Page 1");
+ set_page_title(*get_nth_page(1), "Page 2");
+ set_page_title(*get_nth_page(2), "Confirmation");
+
+ set_page_complete(m_check, true);
+ set_page_complete(m_label2, true);
+
+ set_page_type(m_box, Gtk::ASSISTANT_PAGE_INTRO);
+ set_page_type(m_label2, Gtk::ASSISTANT_PAGE_CONFIRM);
+
+ signal_apply().connect(sigc::mem_fun(*this,
+ &ExampleWindow::on_assistant_apply));
+ signal_cancel().connect(sigc::mem_fun(*this,
+ &ExampleWindow::on_assistant_cancel));
+ signal_close().connect(sigc::mem_fun(*this,
+ &ExampleWindow::on_assistant_close));
+ signal_prepare().connect(sigc::mem_fun(*this,
+ &ExampleWindow::on_assistant_prepare));
+
+ m_entry.signal_changed().connect(sigc::mem_fun(*this,
+ &ExampleWindow::on_entry_changed));
+
+ show_all_children();
+}
+
+ExampleWindow::~ExampleWindow()
+{
+}
+
+void ExampleWindow::on_assistant_apply()
+{
+ std::cout << "Apply was clicked";
+ print_status();
+}
+
+void ExampleWindow::on_assistant_cancel()
+{
+ std::cout << "Cancel was clicked";
+ print_status();
+}
+
+void ExampleWindow::on_assistant_close()
+{
+ std::cout << "Assistant was closed";
+ print_status();
+}
+
+void ExampleWindow::on_assistant_prepare(Gtk::Widget* /* widget */)
+{
+ set_title(Glib::ustring::compose("Gtk::Assistant example (Page %1 of %2)",
+ get_current_page() + 1, get_n_pages()));
+}
+
+void ExampleWindow::on_entry_changed()
+{
+ // The page is only complete if the entry contains text.
+ if(m_entry.get_text_length())
+ set_page_complete(m_box, true);
+ else
+ set_page_complete(m_box, false);
+}
+
+void ExampleWindow::print_status()
+{
+ std::cout << ", entry contents: \"" << m_entry.get_text()
+ << "\", checkbutton status: " << m_check.get_active() << std::endl;
+ hide();
+}
diff --git a/examples/book/assistant/examplewindow.h b/examples/book/assistant/examplewindow.h
new file mode 100644
index 0000000..4b23c3b
--- /dev/null
+++ b/examples/book/assistant/examplewindow.h
@@ -0,0 +1,46 @@
+/* gtkmm example Copyright (C) 2010 Openismus GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef GTKMM_EXAMPLEWINDOW_H
+#define GTKMM_EXAMPLEWINDOW_H
+
+#include <gtkmm.h>
+
+class ExampleWindow : public Gtk::Assistant
+{
+public:
+ ExampleWindow();
+ virtual ~ExampleWindow();
+
+private:
+ // Signal handlers:
+ void on_assistant_apply();
+ void on_assistant_cancel();
+ void on_assistant_close();
+ void on_assistant_prepare(Gtk::Widget* widget);
+ void on_entry_changed();
+
+ // Member functions:
+ void print_status();
+
+ // Child widgets:
+ Gtk::HBox m_box;
+ Gtk::Label m_label1, m_label2;
+ Gtk::CheckButton m_check;
+ Gtk::Entry m_entry;
+};
+
+#endif /* GTKMM_EXAMPLEWINDOW_H */
diff --git a/examples/book/assistant/main.cc b/examples/book/assistant/main.cc
new file mode 100644
index 0000000..064e739
--- /dev/null
+++ b/examples/book/assistant/main.cc
@@ -0,0 +1,29 @@
+/* gtkmm example Copyright (C) 2010 Openismus GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <gtkmm/main.h>
+#include "examplewindow.h"
+
+int main(int argc, char *argv[])
+{
+ Gtk::Main kit(argc, argv);
+
+ ExampleWindow window;
+ // Shows the window and returns when it is closed.
+ Gtk::Main::run(window);
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]