[gtkmm-documentation] Split the Gtk::Application example into two.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm-documentation] Split the Gtk::Application example into two.
- Date: Sat, 19 Mar 2011 12:26:48 +0000 (UTC)
commit 823a50c5557f2eddcf514ff8579ddb4c12565300
Author: Murray Cumming <murrayc murrayc com>
Date: Sat Mar 19 13:26:39 2011 +0100
Split the Gtk::Application example into two.
* examples/book/application/: Split this into:
* examples/book/application/simple/ with no command-line handling, and:
* examples/book/application/command_line_handling/ because custom
handling of the command line makes the open signal (and maybe others) useless.
As planned on bug #637445.
ChangeLog | 10 ++
examples/Makefile.am | 26 ++++--
.../exampleapplication.cc | 0
.../exampleapplication.h | 0
.../exampleoptiongroup.cc | 0
.../exampleoptiongroup.h | 0
.../{ => command_line_handling}/examplewindow.cc | 0
.../{ => command_line_handling}/examplewindow.h | 0
.../{ => command_line_handling}/main.cc | 0
.../book/application/simple/exampleapplication.cc | 89 ++++++++++++++++++++
.../application/{ => simple}/exampleapplication.h | 1 -
.../book/application/{ => simple}/examplewindow.cc | 0
.../book/application/{ => simple}/examplewindow.h | 0
examples/book/application/{ => simple}/main.cc | 0
14 files changed, 116 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6581c6a..2db99c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-03-19 Murray Cumming <murrayc murrayc-x61>
+
+ Split the Gtk::Application example into two.
+
+ * examples/book/application/: Split this into:
+ * examples/book/application/simple/ with no command-line handling, and:
+ * examples/book/application/command_line_handling/ because custom
+ handling of the command line makes the open signal (and maybe others) useless.
+ As planned on bug #637445.
+
2011-03-18 Kalev Lember <kalev smartlink ee>
ComboBox: Use set_entry_text_column() instead of set_text_column()
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 9383470..87ed7cf 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -8,7 +8,8 @@ LDADD = $(GTKMM_LIBS)
check_PROGRAMS = \
book/alignment/example \
- book/application/example \
+ book/application/simple/example \
+ book/application/command_line_handling/example \
book/aspectframe/example \
book/assistant/example \
book/base/base \
@@ -128,14 +129,21 @@ dist_noinst_DATA = \
book/iconview/xmms.xpm \
book/menus_and_toolbars/rain.png
-book_application_example_SOURCES = \
- book/application/exampleapplication.cc \
- book/application/exampleapplication.h \
- book/application/exampleoptiongroup.cc \
- book/application/exampleoptiongroup.h \
- book/application/examplewindow.cc \
- book/application/examplewindow.h \
- book/application/main.cc
+book_application_simple_example_SOURCES = \
+ book/application/simple/exampleapplication.cc \
+ book/application/simple/exampleapplication.h \
+ book/application/simple/examplewindow.cc \
+ book/application/simple/examplewindow.h \
+ book/application/simple/main.cc
+
+book_application_command_line_handling_example_SOURCES = \
+ book/application/command_line_handling/exampleapplication.cc \
+ book/application/command_line_handling/exampleapplication.h \
+ book/application/command_line_handling/exampleoptiongroup.cc \
+ book/application/command_line_handling/exampleoptiongroup.h \
+ book/application/command_line_handling/examplewindow.cc \
+ book/application/command_line_handling/examplewindow.h \
+ book/application/command_line_handling/main.cc
book_alignment_example_SOURCES = \
book/alignment/examplewindow.cc \
diff --git a/examples/book/application/exampleapplication.cc b/examples/book/application/command_line_handling/exampleapplication.cc
similarity index 100%
rename from examples/book/application/exampleapplication.cc
rename to examples/book/application/command_line_handling/exampleapplication.cc
diff --git a/examples/book/application/exampleapplication.h b/examples/book/application/command_line_handling/exampleapplication.h
similarity index 100%
copy from examples/book/application/exampleapplication.h
copy to examples/book/application/command_line_handling/exampleapplication.h
diff --git a/examples/book/application/exampleoptiongroup.cc b/examples/book/application/command_line_handling/exampleoptiongroup.cc
similarity index 100%
rename from examples/book/application/exampleoptiongroup.cc
rename to examples/book/application/command_line_handling/exampleoptiongroup.cc
diff --git a/examples/book/application/exampleoptiongroup.h b/examples/book/application/command_line_handling/exampleoptiongroup.h
similarity index 100%
rename from examples/book/application/exampleoptiongroup.h
rename to examples/book/application/command_line_handling/exampleoptiongroup.h
diff --git a/examples/book/application/examplewindow.cc b/examples/book/application/command_line_handling/examplewindow.cc
similarity index 100%
copy from examples/book/application/examplewindow.cc
copy to examples/book/application/command_line_handling/examplewindow.cc
diff --git a/examples/book/application/examplewindow.h b/examples/book/application/command_line_handling/examplewindow.h
similarity index 100%
copy from examples/book/application/examplewindow.h
copy to examples/book/application/command_line_handling/examplewindow.h
diff --git a/examples/book/application/main.cc b/examples/book/application/command_line_handling/main.cc
similarity index 100%
copy from examples/book/application/main.cc
copy to examples/book/application/command_line_handling/main.cc
diff --git a/examples/book/application/simple/exampleapplication.cc b/examples/book/application/simple/exampleapplication.cc
new file mode 100644
index 0000000..245b635
--- /dev/null
+++ b/examples/book/application/simple/exampleapplication.cc
@@ -0,0 +1,89 @@
+/* gtkmm example Copyright (C) 2002 gtkmm development team
+ *
+ * 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, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "exampleapplication.h"
+#include "examplewindow.h"
+#include <iostream>
+
+ExampleApplication::ExampleApplication()
+: Gtk::Application("org.gtkmm.examples.application", Gio::APPLICATION_HANDLES_OPEN)
+{
+}
+
+Glib::RefPtr<ExampleApplication> ExampleApplication::create()
+{
+ return Glib::RefPtr<ExampleApplication>( new ExampleApplication() );
+}
+
+void ExampleApplication::create_window(const Glib::RefPtr<Gio::File>& file)
+{
+ ExampleWindow* window = new ExampleWindow();
+
+ //Make sure that the application runs for as long this window is still open:
+ add_window(*window);
+
+ //Delete the window when it is hidden.
+ //That's enough for this simple example.
+ window->signal_hide().connect(sigc::bind<Gtk::Window*>(sigc::mem_fun(*this,
+ &ExampleApplication::on_window_hide), window));
+
+ window->show();
+
+ if(!file)
+ {
+ //This is probably an new empty file, as a result of an activation rather
+ //than an open.
+ return;
+ }
+
+ const bool loaded = window->load_file(file);
+ if(!loaded)
+ std::cerr << "This file could not be loaded: " << file->get_path() << std::endl;
+}
+
+void ExampleApplication::on_window_hide(Gtk::Window* window)
+{
+ delete window;
+}
+
+void ExampleApplication::on_activate()
+{
+ //std::cout << "debug1: " << G_STRFUNC << std::endl;
+ // The application has been started, so let's show a window.
+ // A real application might want to reuse this "empty" window in on_open(),
+ // when asked to open a file, if no changes have been made yet.
+ create_window();
+}
+
+void ExampleApplication::on_open(const Gio::Application::type_vec_files& files,
+ const Glib::ustring& hint)
+{
+ // The application has been asked to open some files,
+ // so let's open a new window for each one.
+ //std::cout << "debug: files.size()=" << files.size() << std::endl;
+ for(guint i = 0; i < files.size(); i++)
+ {
+ Glib::RefPtr<Gio::File> file = files[0];
+ if(!file)
+ {
+ std::cerr << G_STRFUNC << ": file is null." << std::endl;
+ }
+ else
+ create_window(file);
+ }
+
+ Application::on_open(files, hint);
+}
diff --git a/examples/book/application/exampleapplication.h b/examples/book/application/simple/exampleapplication.h
similarity index 93%
rename from examples/book/application/exampleapplication.h
rename to examples/book/application/simple/exampleapplication.h
index c968e02..f8e1b0d 100644
--- a/examples/book/application/exampleapplication.h
+++ b/examples/book/application/simple/exampleapplication.h
@@ -32,7 +32,6 @@ protected:
virtual void on_activate();
virtual void on_open(const Gio::Application::type_vec_files& files,
const Glib::ustring& hint);
- virtual int on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line);
private:
void create_window(const Glib::RefPtr<Gio::File>& file = Glib::RefPtr<Gio::File>());
diff --git a/examples/book/application/examplewindow.cc b/examples/book/application/simple/examplewindow.cc
similarity index 100%
rename from examples/book/application/examplewindow.cc
rename to examples/book/application/simple/examplewindow.cc
diff --git a/examples/book/application/examplewindow.h b/examples/book/application/simple/examplewindow.h
similarity index 100%
rename from examples/book/application/examplewindow.h
rename to examples/book/application/simple/examplewindow.h
diff --git a/examples/book/application/main.cc b/examples/book/application/simple/main.cc
similarity index 100%
rename from examples/book/application/main.cc
rename to examples/book/application/simple/main.cc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]