r49177 - in /branches/upstream/libgtk2-unique-perl/current: Changes META.yml lib/Gtk2/Unique.pm t/Unique.t t/UniqueApp.t t/UniqueBackend.t t/unit-tests.pl xs/Unique.xs xs/UniqueApp.xs xs/UniqueBackend.xs xs/UniqueMessageData.xs

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Tue Dec 22 16:16:49 UTC 2009


Author: jawnsy-guest
Date: Tue Dec 22 16:16:44 2009
New Revision: 49177

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=49177
Log:
[svn-upgrade] Integrating new upstream version, libgtk2-unique-perl (0.04)

Modified:
    branches/upstream/libgtk2-unique-perl/current/Changes
    branches/upstream/libgtk2-unique-perl/current/META.yml
    branches/upstream/libgtk2-unique-perl/current/lib/Gtk2/Unique.pm
    branches/upstream/libgtk2-unique-perl/current/t/Unique.t
    branches/upstream/libgtk2-unique-perl/current/t/UniqueApp.t
    branches/upstream/libgtk2-unique-perl/current/t/UniqueBackend.t
    branches/upstream/libgtk2-unique-perl/current/t/unit-tests.pl
    branches/upstream/libgtk2-unique-perl/current/xs/Unique.xs
    branches/upstream/libgtk2-unique-perl/current/xs/UniqueApp.xs
    branches/upstream/libgtk2-unique-perl/current/xs/UniqueBackend.xs
    branches/upstream/libgtk2-unique-perl/current/xs/UniqueMessageData.xs

Modified: branches/upstream/libgtk2-unique-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libgtk2-unique-perl/current/Changes?rev=49177&op=diff
==============================================================================
--- branches/upstream/libgtk2-unique-perl/current/Changes (original)
+++ branches/upstream/libgtk2-unique-perl/current/Changes Tue Dec 22 16:16:44 2009
@@ -1,8 +1,19 @@
 Revision history for Gtk2::Unique
+
+0.04 Tue Nov  3 22:27:54 CET 2009
+	The signal Gtk2::UniqueApp::message-received now receives command name
+	instaed of the command id.
+	The macro UNIQUE_CHECK_VERSION will be fixed in 1.1.0.
+
+
+0.03 Tue Oct 20 20:21:27 CEST 2009
+	Add the version check macros to the bindings.
+	Fix the unit tests (now using the bacon backend).
+	Documentation updates.
 
 
 0.02 Sun Jul 12 16:28:57 CEST 2009
-	More perlish API with send_message_by_name()
+	More perlish API with send_message_by_name().
 
 
 0.01 Thu Apr  2 15:44:36 CEST 2009

Modified: branches/upstream/libgtk2-unique-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libgtk2-unique-perl/current/META.yml?rev=49177&op=diff
==============================================================================
--- branches/upstream/libgtk2-unique-perl/current/META.yml (original)
+++ branches/upstream/libgtk2-unique-perl/current/META.yml Tue Dec 22 16:16:44 2009
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:                Gtk2-Unique
-version:             0.02
+version:             0.04
 abstract:            Use single instance applications
 license:             perl, lgpl
 author:              

Modified: branches/upstream/libgtk2-unique-perl/current/lib/Gtk2/Unique.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libgtk2-unique-perl/current/lib/Gtk2/Unique.pm?rev=49177&op=diff
==============================================================================
--- branches/upstream/libgtk2-unique-perl/current/lib/Gtk2/Unique.pm (original)
+++ branches/upstream/libgtk2-unique-perl/current/lib/Gtk2/Unique.pm Tue Dec 22 16:16:44 2009
@@ -91,7 +91,7 @@
 
 use Gtk2;
 
-our $VERSION = '0.02';
+our $VERSION = '0.04';
 
 sub dl_load_flags { $^O eq 'darwin' ? 0x00 : 0x01 }
 

Modified: branches/upstream/libgtk2-unique-perl/current/t/Unique.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libgtk2-unique-perl/current/t/Unique.t?rev=49177&op=diff
==============================================================================
--- branches/upstream/libgtk2-unique-perl/current/t/Unique.t (original)
+++ branches/upstream/libgtk2-unique-perl/current/t/Unique.t Tue Dec 22 16:16:44 2009
@@ -3,13 +3,41 @@
 use strict;
 use warnings;
 
-use Gtk2::TestHelper tests => 1;
+use Gtk2::TestHelper tests => 12;
 
 use Gtk2::Unique;
 
 exit tests();
 
+
 sub tests {
-	ok($Gtk2::Unique::VERSION, "Library loaded");
+	test_version();
 	return 0;
 }
+
+
+sub test_version {
+	ok($Gtk2::Unique::VERSION, "Module loaded");
+
+
+	ok(Gtk2::Unique::VERSION, "Version");
+	ok(Gtk2::Unique::VERSION_HEX, "Version hex");
+	ok(Gtk2::Unique::API_VERSION, "API version");
+	ok(Gtk2::Unique::PROTOCOL_VERSION, "Protocol version");
+	ok(Gtk2::Unique::DEFAULT_BACKEND, "Default backend");
+
+	ok(defined Gtk2::Unique::MAJOR_VERSION, "MAJOR_VERSION exists");
+	ok(defined Gtk2::Unique::MINOR_VERSION, "MINOR_VERSION exists");
+	ok(defined Gtk2::Unique::MICRO_VERSION, "MICRO_VERSION exists");
+
+	ok (Gtk2::Unique->CHECK_VERSION(0,0,0), "CHECK_VERSION pass");
+	ok (!Gtk2::Unique->CHECK_VERSION(50,0,0), "CHECK_VERSION fail");
+
+	my @version = Gtk2::Unique->GET_VERSION_INFO;
+	my @expected = (
+		Gtk2::Unique::MAJOR_VERSION,
+		Gtk2::Unique::MINOR_VERSION,
+		Gtk2::Unique::MICRO_VERSION,
+	);
+	is_deeply(\@version, \@expected, "GET_VERSION_INFO");
+}

Modified: branches/upstream/libgtk2-unique-perl/current/t/UniqueApp.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libgtk2-unique-perl/current/t/UniqueApp.t?rev=49177&op=diff
==============================================================================
--- branches/upstream/libgtk2-unique-perl/current/t/UniqueApp.t (original)
+++ branches/upstream/libgtk2-unique-perl/current/t/UniqueApp.t Tue Dec 22 16:16:44 2009
@@ -3,13 +3,24 @@
 use strict;
 use warnings;
 
-use Gtk2::TestHelper tests => 16;
+use Gtk2::TestHelper tests => 20;
 
 use Gtk2::Unique;
 
 my $COMMAND_FOO = 1;
 my $COMMAND_BAR = 2;
 my $APP_NAME = 'org.example.UnitTets';
+
+
+# The D-Bus backend doesn't seem to realize that an application is no longer
+# running when created from the same Perl script. The second call to
+# Gtk2::UniqueApp->new() will think that the application is already running when
+# it isn't. This happens even if the original $app variable exists no longer.
+#
+# Besides the bacon backend is the only one guaranteed to exist.
+#
+local $ENV{UNIQUE_BACKEND} = 'bacon';
+
 
 exit tests();
 
@@ -79,11 +90,17 @@
 	
 	if (! $app->is_running()) {
 		SKIP: {
-			skip "No app is running; execute perl -Mblib t/unit-tests.pl", 6;
+			skip "No app is running; execute perl -Mblib t/unit-tests.pl", 8;
 		}
 		return;
 	}
 	my $response;
+
+	$response = $app->send_message($COMMAND_FOO, data => "data in here");
+	is($response, 'ok', "send_message(data)");
+
+	$response = $app->send_message_by_name(foo => data => "data in here");
+	is($response, 'ok', "send_message_by_name(data)");
 
 	$response = $app->send_message($COMMAND_FOO, text => "hello");
 	is($response, 'ok', "send_message(text)");

Modified: branches/upstream/libgtk2-unique-perl/current/t/UniqueBackend.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libgtk2-unique-perl/current/t/UniqueBackend.t?rev=49177&op=diff
==============================================================================
--- branches/upstream/libgtk2-unique-perl/current/t/UniqueBackend.t (original)
+++ branches/upstream/libgtk2-unique-perl/current/t/UniqueBackend.t Tue Dec 22 16:16:44 2009
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Gtk2::TestHelper tests => 9;
+use Gtk2::TestHelper tests => 8;
 
 use Gtk2::Unique;
 
@@ -26,7 +26,7 @@
 	is($backend->get_screen, Gtk2::Gdk::Screen->get_default, "set_screen()");
 	
 	ok($backend->get_workspace >= 0, "get_workspace()");
-	ok($backend->request_name(), "request_name()");
+#	ok($backend->request_name(), "request_name()");
 	
 #	my $response = $backend->send_message(1, undef, 0);
 #	is ($response, '', "send_message()");

Modified: branches/upstream/libgtk2-unique-perl/current/t/unit-tests.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libgtk2-unique-perl/current/t/unit-tests.pl?rev=49177&op=diff
==============================================================================
--- branches/upstream/libgtk2-unique-perl/current/t/unit-tests.pl (original)
+++ branches/upstream/libgtk2-unique-perl/current/t/unit-tests.pl Tue Dec 22 16:16:44 2009
@@ -10,6 +10,11 @@
 
 my $COMMAND_FOO = 1;
 my $COMMAND_BAR = 2;
+
+
+# Use the bacon backend as it is the only that really works with unit tests.
+# See t/UniqueApp.t for more details.
+local $ENV{UNIQUE_BACKEND} = 'bacon';
 
 
 exit main();

Modified: branches/upstream/libgtk2-unique-perl/current/xs/Unique.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libgtk2-unique-perl/current/xs/Unique.xs?rev=49177&op=diff
==============================================================================
--- branches/upstream/libgtk2-unique-perl/current/xs/Unique.xs (original)
+++ branches/upstream/libgtk2-unique-perl/current/xs/Unique.xs Tue Dec 22 16:16:44 2009
@@ -1,5 +1,9 @@
 #include "unique-perl.h"
 
+#define _FIXED_UNIQUE_CHECK_VERSION(major,minor,micro) \
+        ((UNIQUE_MAJOR_VERSION > (major)) || \
+         (UNIQUE_MAJOR_VERSION == (major) && UNIQUE_MINOR_VERSION > (minor)) || \
+         (UNIQUE_MAJOR_VERSION == (major) && UNIQUE_MINOR_VERSION == (minor) && UNIQUE_MICRO_VERSION > (micro)))
 
 MODULE = Gtk2::Unique  PACKAGE = Gtk2::Unique  PREFIX = unique_
 
@@ -9,3 +13,109 @@
 BOOT:
 #include "register.xsh"
 #include "boot.xsh"
+
+
+guint
+MAJOR_VERSION ()
+	CODE:
+		RETVAL = UNIQUE_MAJOR_VERSION;
+
+	OUTPUT:
+		RETVAL
+
+
+guint
+MINOR_VERSION ()
+	CODE:
+		RETVAL = UNIQUE_MINOR_VERSION;
+
+	OUTPUT:
+		RETVAL
+
+
+guint
+MICRO_VERSION ()
+	CODE:
+		RETVAL = UNIQUE_MICRO_VERSION;
+
+	OUTPUT:
+		RETVAL
+
+
+void
+GET_VERSION_INFO (class)
+	PPCODE:
+		EXTEND (SP, 3);
+		PUSHs (sv_2mortal (newSViv (UNIQUE_MAJOR_VERSION)));
+		PUSHs (sv_2mortal (newSViv (UNIQUE_MINOR_VERSION)));
+		PUSHs (sv_2mortal (newSViv (UNIQUE_MICRO_VERSION)));
+		PERL_UNUSED_VAR (ax);
+
+
+gboolean
+CHECK_VERSION (class, guint major, guint minor, guint micro)
+	CODE:
+/*
+ * So check version is broken as it has a typo and won't compile. But we need
+ * check version to see if libunique has fixed this!
+ *
+ * For now we define our own check version and use that one instead.
+ */
+#if ! _FIXED_UNIQUE_CHECK_VERSION(1, 1, 0)
+		RETVAL = _FIXED_UNIQUE_CHECK_VERSION(major, minor, micro);
+#else
+		RETVAL = UNIQUE_CHECK_VERSION(major, minor, micro);
+#endif
+
+	OUTPUT:
+		RETVAL
+
+
+const gchar*
+VERSION ()
+
+	CODE:
+		RETVAL = UNIQUE_VERSION_S;
+
+	OUTPUT:
+		RETVAL
+
+
+guint
+VERSION_HEX ()
+
+	CODE:
+		RETVAL = UNIQUE_VERSION_HEX;
+
+	OUTPUT:
+		RETVAL
+
+
+const gchar*
+API_VERSION ()
+
+	CODE:
+		RETVAL = UNIQUE_API_VERSION_S;
+
+	OUTPUT:
+		RETVAL
+
+
+const gchar*
+PROTOCOL_VERSION ()
+
+	CODE:
+		RETVAL = UNIQUE_PROTOCOL_VERSION_S;
+
+	OUTPUT:
+		RETVAL
+
+
+const gchar*
+DEFAULT_BACKEND ()
+
+	CODE:
+		RETVAL = UNIQUE_DEFAULT_BACKEND_S;
+
+	OUTPUT:
+		RETVAL

Modified: branches/upstream/libgtk2-unique-perl/current/xs/UniqueApp.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libgtk2-unique-perl/current/xs/UniqueApp.xs?rev=49177&op=diff
==============================================================================
--- branches/upstream/libgtk2-unique-perl/current/xs/UniqueApp.xs (original)
+++ branches/upstream/libgtk2-unique-perl/current/xs/UniqueApp.xs Tue Dec 22 16:16:44 2009
@@ -1,17 +1,169 @@
 #include "unique-perl.h"
+#include <gperl_marshal.h>
+
+static void
+perl_unique_app_marshall_message_received (
+	GClosure *closure,
+	GValue *return_value,
+	guint n_param_values,
+	const GValue *param_values,
+	gpointer invocant_hint,
+	gpointer marshal_data)
+{
+	UniqueApp *app;
+	gint command;
+	const gchar *command_name;
+
+	dGPERL_CLOSURE_MARSHAL_ARGS;
+	PERL_UNUSED_VAR (return_value);
+	PERL_UNUSED_VAR (n_param_values);
+	PERL_UNUSED_VAR (invocant_hint);
+
+	GPERL_CLOSURE_MARSHAL_INIT (closure, marshal_data);
+
+	ENTER;
+	SAVETMPS;
+	PUSHMARK (SP);
+
+	GPERL_CLOSURE_MARSHAL_PUSH_INSTANCE (param_values);
+
+	app = (UniqueApp *) g_value_get_object (param_values + 0);
+	command = g_value_get_int (param_values + 1);
+	command_name = (const gchar *) unique_command_to_string (app, command);
+
+	XPUSHs (sv_2mortal (newSVpv (command_name, 0)));
+	XPUSHs (sv_2mortal (gperl_sv_from_value (param_values + 2)));
+	XPUSHs (sv_2mortal (gperl_sv_from_value (param_values + 3)));
+
+	GPERL_CLOSURE_MARSHAL_PUSH_DATA;
+
+	PUTBACK;
+
+	GPERL_CLOSURE_MARSHAL_CALL (G_SCALAR);
+
+	SPAGAIN;
+
+	if (count != 1) {
+		croak ("message-received handlers need to return a single value");
+	}
+
+	g_value_set_enum (return_value, SvUniqueResponse (POPs));
+
+	FREETMPS;
+	LEAVE;
+
+}
 
 
 MODULE = Gtk2::UniqueApp  PACKAGE = Gtk2::UniqueApp  PREFIX = unique_app_
 
-
+BOOT:
+	gperl_signal_set_marshaller_for (
+		UNIQUE_TYPE_APP,
+		"message-received",
+		perl_unique_app_marshall_message_received
+	);
+
+=for object Gtk2::UniqueApp - Base class for singleton applications
+=cut
+
+=for position SYNOPSIS
+
+=head1 SYNOPSIS
+
+	my $app = Gtk2::UniqueApp->new(
+		"org.example.UnitTets", undef,
+		foo => $COMMAND_FOO,
+		bar => $COMMAND_BAR,
+	);
+	if ($app->is_running) {
+		# The application is already running, send it a message
+		$app->send_message_by_name('foo', text => "Hello world");
+	}
+	else {
+		my $window = Gtk2::Window->new();
+		my $label = Gtk2::Label->new("Waiting for a message");
+		$window->add($label);
+		$window->set_size_request(480, 120);
+		$window->show_all();
+
+		$window->signal_connect(delete_event => sub {
+			Gtk2->main_quit();
+			return TRUE;
+		});
+
+		# Watch the main window and register a handler that will be called each time
+		# that there's a new message.
+		$app->watch_window($window);
+		$app->signal_connect('message-received' => sub {
+			my ($app, $command, $message, $time) = @_;
+			$label->set_text($message->get_text);
+			return 'ok';
+		});
+
+		Gtk2->main();
+	}
+
+=for position DESCRIPTION
+
+=head1 DESCRIPTION
+
+B<Gtk2::UniqueApp> is the base class for single instance applications. You can
+either create an instance of UniqueApp via C<Gtk2::UniqueApp-E<gt>new()> and
+C<Gtk2::UniqueApp-E<gt>_with_commands()>; or you can subclass Gtk2::UniqueApp
+with your own application class.
+
+A Gtk2::UniqueApp instance is guaranteed to either be the first running at the
+time of creation or be able to send messages to the currently running instance;
+there is no race possible between the creation of the Gtk2::UniqueApp instance
+and the call to C<Gtk2::UniqueApp::is_running()>.
+
+The usual method for using the Gtk2::UniqueApp API is to create a new instance,
+passing an application-dependent name as construction-only property; the
+C<Gtk2::UniqueApp:name> property is required, and should be in the form of a
+domain name, like I<org.gnome.YourApplication>.
+
+After the creation, you should check whether an instance of your application is
+already running, using C<Gtk2::UniqueApp::is_running()>; if this method returns
+C<FALSE> the usual application construction sequence can continue; if it returns
+C<TRUE> you can either exit or send a message using L<Gtk2::UniqueMessageData>
+and C<Gtk2::UniqueMessageData::send_message()>.
+
+You can define custom commands using C<Gtk2::UniqueApp::add_command()>: you need
+to provide an arbitrary integer and a string for the command.
+
+=cut
+
+=for apidoc new_with_commands
+
+An alias for C<Gtk2::UniqueApp-E<gt>new()>.
+
+=cut
+=for apidoc
+
+Creates a new Gtk2::UniqueApp instance for name passing a start-up notification
+id startup_id. The name must be a unique identifier for the application, and it
+must be in form of a domain name, like I<org.gnome.YourApplication>.
+
+If startup_id is C<undef> the DESKTOP_STARTUP_ID environment variable will be
+check, and if that fails a "fake" startup notification id will be created.
+
+Once you have created a Gtk2::UniqueApp instance, you should check if any other
+instance is running, using C<Gtk2::UniqueApp::is_running()>. If another
+instance is running you can send a command to it, using the
+C<Gtk2::UniqueApp::send_message()> function; after that, the second instance
+should quit. If no other instance is running, the usual logic for creating the
+application can follow.
+
+=cut
 UniqueApp_noinc*
 unique_app_new (class, const gchar *name, const gchar_ornull *startup_id, ...)
 	ALIAS:
 		new_with_commands = 1
-	
+
 	PREINIT:
 		UniqueApp *app = NULL;
-		
+
 	CODE:
 		PERL_UNUSED_VAR(ix);
 
@@ -20,7 +172,7 @@
 		}
 		else if (items > 3 && (items % 2 == 1)) {
 			/* Calling unique_app_new_with_command(), First create a new app with
-			   unique_app_new() and the populate the commands one by one with
+			   unique_app_new() and then populate the commands one by one with
 			   unique_app_add_command().
 			 */
 			int i;
@@ -57,15 +209,33 @@
 	OUTPUT:
 		RETVAL
 
-
+=for apidoc
+
+Adds command_name as a custom command that can be used by app. You must call
+C<Gtk2::UniqueApp::add_command()> before C<Gtk2::UniqueApp::send_message()> in
+order to use the newly added command.
+
+The command name is used internally: you need to use the command's logical id in
+C<Gtk2::UniqueApp::send_message()> and inside the I<message-received> signal.
+
+=cut
 void
 unique_app_add_command (UniqueApp *app, const gchar *command_name, gint command_id)
 
 
+=for apidoc
+
+Makes app "watch" a window. Every watched window will receive startup notification changes automatically.
+
+=cut
 void
 unique_app_watch_window (UniqueApp *app, GtkWindow *window)
 
-
+=for apidoc
+
+Checks whether another instance of app is running.
+
+=cut
 gboolean
 unique_app_is_running (UniqueApp *app)
 
@@ -82,10 +252,60 @@
 # $app->send_message_by_name('command', uris => @uri) -> set_uris() unique_app_send_message(app, command_id, message);
 #
 #
+
+=for apidoc send_message
+
+Same as C<Gkt2::UniqueApp::send_message_by_name()>, but uses a message id
+instead of a name.
+
+=cut
+=for apidoc
+
+Sends command to a running instance of app. If you need to pass data to the
+instance, you have to indicate the type of message that will be passed. The
+accepted types are:
+
+=over
+
+=item text
+
+A plain text message
+
+=item data
+
+Rad data
+
+=item filename
+
+A file name
+
+=item uris
+
+URI, multiple values can be passed
+
+=back
+
+The running application will receive a I<message-received> signal and will call
+the various signal handlers attach to it. If any handler returns a
+C<Gtk2::UniqueResponse> different than C<ok>, the emission will stop.
+
+Usages:
+
+	$app->send_message_by_name(write => data => $data);
+	$app->send_message_by_name(greet => text => "Hello World!");
+	$app->send_message_by_name(open  => uris =>
+		'http://search.cpan.org/',
+		'http://www.gnome.org/',
+	);
+
+B<NOTE>: If you prefer to use an ID instead of a message name then use the
+function C<Gkt2::UniqueApp::send_message()>. The usage is the same as this one.
+
+=cut
 UniqueResponse
-unique_app_send_message (UniqueApp *app, SV *command, ...)
+unique_app_send_message_by_name (UniqueApp *app, SV *command, ...)
 	ALIAS:
-		send_message_by_name = 1
+		send_message = 1
 
 	PREINIT:
 		UniqueMessageData *message = NULL;
@@ -96,12 +316,6 @@
 
 		switch (ix) {
 			case 0:
-				{
-					command_id = (gint) SvIV(command);
-				}
-			break;
-
-			case 1:
 				{
 					gchar *command_name = SvGChar(command);
 					command_id = unique_command_from_string(app, command_name);
@@ -111,6 +325,12 @@
 				}
 			break;
 
+			case 1:
+				{
+					command_id = (gint) SvIV(command);
+				}
+			break;
+
 			default:
 				croak("Method called with the wrong name");
 		}
@@ -122,12 +342,12 @@
 			message = unique_message_data_new();
 			type = SvGChar(ST(2));
 			sv_data = ST(3);
-			
+
 			if (g_strcmp0(type, "data") == 0) {
 				SV *sv;
 				STRLEN length;
 				char *data;
-				
+
 				length = sv_len(sv_data);
 				data = SvPV(sv_data, length);
 				unique_message_data_set(message, data, length);
@@ -135,7 +355,7 @@
 			else if (g_strcmp0(type, "text") == 0) {
 				STRLEN length;
 				char *text;
-				
+
 				length = sv_len(sv_data);
 				text = SvGChar(sv_data);
 				unique_message_data_set_text(message, text, length);
@@ -143,7 +363,7 @@
 			else if (g_strcmp0(type, "filename") == 0) {
 				SV *sv;
 				char *filename;
-				
+
 				filename = SvGChar(sv_data);
 				unique_message_data_set_filename(message, filename);
 			}
@@ -161,7 +381,7 @@
 				/* Convert the Perl array into a C array of strings */
 				av = (AV*) SvRV(sv_data);
 				length = av_len(av) + 2; /* last index + extra NULL padding */
-				
+
 				uris = g_new0(gchar *, length);
 				for (i = 0; i < length - 1; ++i) {
 					SV **uri_sv = av_fetch(av, i, FALSE);
@@ -187,12 +407,13 @@
 				" or $app->send_message($id)"
 			);
 		}
-		
+
 		RETVAL = unique_app_send_message(app, command_id, message);
-		
+
 		if (message) {
 			unique_message_data_free(message);
 		}
 
 	OUTPUT:
 		RETVAL
+

Modified: branches/upstream/libgtk2-unique-perl/current/xs/UniqueBackend.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libgtk2-unique-perl/current/xs/UniqueBackend.xs?rev=49177&op=diff
==============================================================================
--- branches/upstream/libgtk2-unique-perl/current/xs/UniqueBackend.xs (original)
+++ branches/upstream/libgtk2-unique-perl/current/xs/UniqueBackend.xs Tue Dec 22 16:16:44 2009
@@ -3,8 +3,28 @@
 
 MODULE = Gtk2::UniqueBackend  PACKAGE = Gtk2::UniqueBackend  PREFIX = unique_backend_
 
+=for object Gtk2::UniqueBackend - Backend abstraction
+=cut
 
-UniqueBackend*
+=for position DESCRIPTION
+
+=head1 DESCRIPTION
+
+Gkt2::UniqueBackend is the base, abstract class implemented by the different IPC
+mechanisms used by Gtk2::Unique. Each Gtk2::UniqueApp instance creates a
+Gkt2::UniqueBackend to request the name or to send messages.
+
+=cut
+
+
+=for apidoc
+
+Creates a Gkt2::UniqueBackend using the default backend defined at compile time.
+You can override the default backend by setting the UNIQUE_BACKEND environment
+variable with the name of the desired backend.
+
+=cut
+UniqueBackend_noinc*
 unique_backend_create (class)
 	C_ARGS: /* No args */
 
@@ -33,14 +53,30 @@
 unique_backend_set_screen (UniqueBackend *backend, GdkScreen *screen)
 
 
+=for apidoc
+
+Retrieves the current workspace.
+
+=cut
 guint
 unique_backend_get_workspace (UniqueBackend *backend)
 
 
+=for apidoc
+
+Requests the name set using C<Gtk2::set_name()> and this backend.
+
+=cut
 gboolean
 unique_backend_request_name  (UniqueBackend *backend)
 
 
+=for apidoc
+
+Sends command_id, and optionally message_data, to a running instance using
+backend.
+
+=cut
 UniqueResponse
 unique_backend_send_message (UniqueBackend *backend, gint command_id, UniqueMessageData_ornull *message_data, guint time_)
 

Modified: branches/upstream/libgtk2-unique-perl/current/xs/UniqueMessageData.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libgtk2-unique-perl/current/xs/UniqueMessageData.xs?rev=49177&op=diff
==============================================================================
--- branches/upstream/libgtk2-unique-perl/current/xs/UniqueMessageData.xs (original)
+++ branches/upstream/libgtk2-unique-perl/current/xs/UniqueMessageData.xs Tue Dec 22 16:16:44 2009
@@ -3,6 +3,37 @@
 
 MODULE = Gtk2::UniqueMessageData  PACKAGE = Gtk2::UniqueMessageData  PREFIX = unique_message_data_
 
+=for object Gtk2::UniqueMessageData - Message container for Gtk2::UniqueApp
+=cut
+
+=for position DESCRIPTION
+
+=head1 DESCRIPTION
+
+This class wraps the messages passed to a C<Gtk2::UniqueApp>. Usually you will
+never create a message with the Perl API has this is done by the bindings on
+your behalf. Since messages are only read through the Perl bidings the methods
+for setting the contents of a message are not accessible.
+
+What's important to understand is that a C<Gtk2::MessageData> is a generic
+container for all message types (text, data, filename and uris). There's no way
+to query what kind of message a C<Gtk2::MessageData> holds. It is the
+responsability of each application to know it in advance and to call the proper
+get methods. If you don't call the proper get method you could have a
+segmentation fault in your application as the C library will try to unmarshall
+the message with the wrong code.
+
+You can retrieve the data set using C<Gkt2::MessageData::get()>,
+C<Gkt2::MessageData::get_text()> or C<Gkt2::MessageData::get_uris()>.
+
+=cut
+
+
+=for apidoc
+
+Retrieves the raw data of the message.
+
+=cut
 SV*
 unique_message_data_get (UniqueMessageData *message_data)
 	PREINIT:
@@ -18,14 +49,30 @@
 	OUTPUT:
 		RETVAL
 
+
+=for apidoc
+
+Retrieves the text.
+
+=cut
 gchar*
 unique_message_data_get_text (UniqueMessageData *message_data)
 
 
+=for apidoc
+
+Retrieves the filename.
+
+=cut
 gchar*
 unique_message_data_get_filename (UniqueMessageData *message_data)
 
 
+=for apidoc
+
+Retrieves the URIs as an array.
+
+=cut
 void
 unique_message_data_get_uris (UniqueMessageData *message_data)
 	PREINIT:
@@ -46,13 +93,32 @@
 		g_strfreev(uris);
 
 
+=for apidoc
+
+Returns a pointer to the screen from where the message came. You can use
+C<Gkt2::Window::set_screen()> to move windows or dialogs to the right screen.
+This field is always set by the Unique library.
+
+=cut
 GdkScreen*
 unique_message_data_get_screen (UniqueMessageData *message_data)
 
 
+=for apidoc
+
+Retrieves the startup notification id set inside message_data. This field is
+always set by the Unique library.
+=cut
 const gchar*
 unique_message_data_get_startup_id (UniqueMessageData *message_data)
 
 
+=for apidoc
+
+Retrieves the workspace number from where the message came. This field is
+always set by the Unique library.
+
+=cut
 guint
 unique_message_data_get_workspace (UniqueMessageData *message_data)
+




More information about the Pkg-perl-cvs-commits mailing list