[uniquemm] Construct the App and Backend object using Glib::RefPtr



commit d375482573c6efbbe072984147887ad90e8f734d
Author: Fabien Parent <parent f gmail com>
Date:   Thu Sep 10 19:16:03 2009 +0200

    Construct the App and Backend object using Glib::RefPtr

 examples/unique-simple.cc |   12 ++++++------
 examples/unique.cc        |   14 +++++++-------
 unique/src/app.hg         |    5 ++++-
 unique/src/backend.hg     |    5 ++++-
 4 files changed, 21 insertions(+), 15 deletions(-)
---
diff --git a/examples/unique-simple.cc b/examples/unique-simple.cc
index 22fa946..1bdc6d1 100644
--- a/examples/unique-simple.cc
+++ b/examples/unique-simple.cc
@@ -42,24 +42,24 @@ Unique::Response on_message_received(int command, Unique::MessageData message_da
 int main(int argc, char** argv)
 {
 	Gtk::Main kit(argc, argv);
-	Unique::App app("org.gnome.TestUnique", "test");
-	app.add_command("foo", COMMAND_FOO);
+	Glib::RefPtr<Unique::App> app = Unique::App::create("org.gnome.TestUnique", "test");
+	app->add_command("foo", COMMAND_FOO);
 	
-	if (app.is_running())
+	if (app->is_running())
 	{
 		Unique::MessageData message;
 		Unique::Response response;
 		int command = COMMAND_FOO;
 		message.set_text("bar");
-		response = app.send_message(command, message);
+		response = app->send_message(command, message);
 
 		std::cout << "Response code: " << response << std::endl;
 	}
 	else
 	{
 		Gtk::Window window;
-		app.watch_window(window);
-		app.signal_message_received().connect(sigc::ptr_fun(&on_message_received), false);
+		app->watch_window(window);
+		app->signal_message_received().connect(sigc::ptr_fun(&on_message_received), false);
 		Gtk::Main::run(window);
 	}
 	
diff --git a/examples/unique.cc b/examples/unique.cc
index 2089d97..cb77faa 100644
--- a/examples/unique.cc
+++ b/examples/unique.cc
@@ -131,11 +131,11 @@ int main(int argc, char** argv)
 	
 	Gtk::Main kit(argc, argv);
 	window = new Gtk::Window;
-	Unique::App app("org.gnome.TestUnique", "test");
-	app.add_command("foo", COMMAND_FOO);
-	app.add_command("bar", COMMAND_BAR);
+	Glib::RefPtr<Unique::App> app = Unique::App::create("org.gnome.TestUnique", "test");
+	app->add_command("foo", COMMAND_FOO);
+	app->add_command("bar", COMMAND_BAR);
 	
-	if (app.is_running())
+	if (app->is_running())
 	{
 		Unique::MessageData message;
 		Unique::Response response;
@@ -157,14 +157,14 @@ int main(int argc, char** argv)
 		}
 		else
 			command = COMMAND_BAR;
-		response = app.send_message(command, message);
+		response = app->send_message(command, message);
 
 		std::cout << "Response code: " << response << std::endl;
 	}
 	else
 	{
-		app.watch_window(*window);
-		app.signal_message_received().connect(sigc::ptr_fun(&on_message_received), false);
+		app->watch_window(*window);
+		app->signal_message_received().connect(sigc::ptr_fun(&on_message_received), false);
 		Gtk::Main::run(*window);
 	}
 	
diff --git a/unique/src/app.hg b/unique/src/app.hg
index 3c4c7f3..0e771b0 100644
--- a/unique/src/app.hg
+++ b/unique/src/app.hg
@@ -63,6 +63,9 @@ class App : public Glib::Object
 {
   _CLASS_GOBJECT(App, UniqueApp, UNIQUE_APP, Glib::Object, GObject)
   
+protected:
+  explicit App(const Glib::ustring& name, const Glib::ustring& startup_id = Glib::ustring());
+  
 public:
   /**
    * Creates a new Unique::App instance for @a name passing a start-up
@@ -84,7 +87,7 @@ public:
    * @param name the name of the application's instance
    * @param startup_id the startup notification id
    */
-  explicit App(const Glib::ustring& name, const Glib::ustring& startup_id = Glib::ustring());
+  _WRAP_CREATE(const Glib::ustring& name, const Glib::ustring& startup_id = Glib::ustring())
 
   /**
    * Adds @a command_name as a custom command that can be used by @a app.
diff --git a/unique/src/backend.hg b/unique/src/backend.hg
index 5095908..d0b9a57 100644
--- a/unique/src/backend.hg
+++ b/unique/src/backend.hg
@@ -43,6 +43,9 @@ _CC_INCLUDE(unique/uniquebackend.h)
 class Backend : public Glib::Object
 {
   _CLASS_GOBJECT(Backend, UniqueBackend, UNIQUE_BACKEND, Glib::Object, GObject)
+
+protected:
+  _CTOR_DEFAULT
   
 public:
   /**
@@ -50,7 +53,7 @@ public:
    * You can override the default backend by setting the UNIQUE_BACKEND
    * environment variable with the name of the desired backend.
    */
-  _WRAP_CTOR(Backend(), unique_backend_create)
+  _WRAP_CREATE()
   
   _WRAP_METHOD(Glib::ustring get_name() const, unique_backend_get_name)
   _WRAP_METHOD(void set_name(const Glib::ustring& name), unique_backend_set_name)



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