r39829 - in /branches/upstream/libgtk2-unique-perl/current: Changes META.yml examples/sample.pl lib/Gtk2/Unique.pm t/UniqueApp.t xs/UniqueApp.xs

ryan52-guest at users.alioth.debian.org ryan52-guest at users.alioth.debian.org
Mon Jul 13 19:45:26 UTC 2009


Author: ryan52-guest
Date: Mon Jul 13 19:45:20 2009
New Revision: 39829

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

Modified:
    branches/upstream/libgtk2-unique-perl/current/Changes
    branches/upstream/libgtk2-unique-perl/current/META.yml
    branches/upstream/libgtk2-unique-perl/current/examples/sample.pl
    branches/upstream/libgtk2-unique-perl/current/lib/Gtk2/Unique.pm
    branches/upstream/libgtk2-unique-perl/current/t/UniqueApp.t
    branches/upstream/libgtk2-unique-perl/current/xs/UniqueApp.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=39829&op=diff
==============================================================================
--- branches/upstream/libgtk2-unique-perl/current/Changes (original)
+++ branches/upstream/libgtk2-unique-perl/current/Changes Mon Jul 13 19:45:20 2009
@@ -1,6 +1,9 @@
 Revision history for Gtk2::Unique
+
+
+0.02 Sun Jul 12 16:28:57 CEST 2009
+	More perlish API with send_message_by_name()
 
 
 0.01 Thu Apr  2 15:44:36 CEST 2009
 	First version, released on an unsuspecting world.
-

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=39829&op=diff
==============================================================================
--- branches/upstream/libgtk2-unique-perl/current/META.yml (original)
+++ branches/upstream/libgtk2-unique-perl/current/META.yml Mon Jul 13 19:45:20 2009
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:                Gtk2-Unique
-version:             0.01
+version:             0.02
 abstract:            Use single instance applications
 license:             perl, lgpl
 author:              

Modified: branches/upstream/libgtk2-unique-perl/current/examples/sample.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libgtk2-unique-perl/current/examples/sample.pl?rev=39829&op=diff
==============================================================================
--- branches/upstream/libgtk2-unique-perl/current/examples/sample.pl (original)
+++ branches/upstream/libgtk2-unique-perl/current/examples/sample.pl Mon Jul 13 19:45:20 2009
@@ -33,8 +33,7 @@
 	# If there already is an instance running, this will return TRUE; there's no
 	# race condition because the check is already performed at construction time.
 	if ($app->is_running) {
-		my $data = [$text, '/etc/passwd'];
-		my $response = $app->send_message($COMMAND_WRITE, data => '/etc/passwd');
+		my $response = $app->send_message_by_name(write => data => $text);
 		return 0;
 	}
 

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=39829&op=diff
==============================================================================
--- branches/upstream/libgtk2-unique-perl/current/lib/Gtk2/Unique.pm (original)
+++ branches/upstream/libgtk2-unique-perl/current/lib/Gtk2/Unique.pm Mon Jul 13 19:45:20 2009
@@ -22,7 +22,7 @@
 	if ($app->is_running) {
 		# The application is already running, send it a message
 		my ($text) = @ARGV ? @ARGV : ("Foo text here");
-		$app->send_message($COMMAND_FOO, text => $text);
+		$app->send_message_by_name('foo', text => $text);
 	}
 	else {
 		# Create the single application instance and wait for other requests
@@ -91,7 +91,7 @@
 
 use Gtk2;
 
-our $VERSION = '0.01';
+our $VERSION = '0.02';
 
 sub dl_load_flags { $^O eq 'darwin' ? 0x00 : 0x01 }
 

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=39829&op=diff
==============================================================================
--- branches/upstream/libgtk2-unique-perl/current/t/UniqueApp.t (original)
+++ branches/upstream/libgtk2-unique-perl/current/t/UniqueApp.t Mon Jul 13 19:45:20 2009
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Gtk2::TestHelper tests => 10;
+use Gtk2::TestHelper tests => 16;
 
 use Gtk2::Unique;
 
@@ -79,7 +79,7 @@
 	
 	if (! $app->is_running()) {
 		SKIP: {
-			skip "No app is running; execute perl -Mblib t/unit-tests.pl", 3;
+			skip "No app is running; execute perl -Mblib t/unit-tests.pl", 6;
 		}
 		return;
 	}
@@ -88,8 +88,16 @@
 	$response = $app->send_message($COMMAND_FOO, text => "hello");
 	is($response, 'ok', "send_message(text)");
 
+	$response = $app->send_message_by_name(foo => text => "hello");
+	is($response, 'ok', "send_message_by_name(text)");
+
+
 	$response = $app->send_message($COMMAND_BAR, filename => __FILE__);
 	is($response, 'invalid', "send_message(filename)");
+
+	$response = $app->send_message_by_name(bar => filename => __FILE__);
+	is($response, 'invalid', "send_message_by_name(filename)");
+
 
 	$response = $app->send_message($COMMAND_FOO, uris => [
 		'http://live.gnome.org/LibUnique',
@@ -97,6 +105,12 @@
 	]);
 	is($response, 'ok', "send_message(uris)");
 
+	$response = $app->send_message_by_name(foo =>, uris => [
+		'http://live.gnome.org/LibUnique',
+		'http://gtk2-perl.sourceforge.net/',
+	]);
+	is($response, 'ok', "send_message_by_name(uris)");
+
 	
 	my $window = Gtk2::Window->new();
 	$app->watch_window($window);

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=39829&op=diff
==============================================================================
--- branches/upstream/libgtk2-unique-perl/current/xs/UniqueApp.xs (original)
+++ branches/upstream/libgtk2-unique-perl/current/xs/UniqueApp.xs Mon Jul 13 19:45:20 2009
@@ -7,7 +7,7 @@
 UniqueApp_noinc*
 unique_app_new (class, const gchar *name, const gchar_ornull *startup_id, ...)
 	ALIAS:
-		Gtk2::UniqueApp::new_with_commands = 1
+		new_with_commands = 1
 	
 	PREINIT:
 		UniqueApp *app = NULL;
@@ -70,19 +70,51 @@
 unique_app_is_running (UniqueApp *app)
 
 
+#
 # $app->send_message($ID) -> unique_app_send_message(app, command_id, NULL);
 # $app->send_message($ID, text => $text) -> set_text() unique_app_send_message(app, command_id, message);
 # $app->send_message($ID, data => $data) -> set() unique_app_send_message(app, command_id, message);
 # $app->send_message($ID, uris => @uri) -> set_uris() unique_app_send_message(app, command_id, message);
 #
+# $app->send_message_by_name('command') -> unique_app_send_message(app, command_id, NULL);
+# $app->send_message_by_name('command', text => $text) -> set_text() unique_app_send_message(app, command_id, message);
+# $app->send_message_by_name('command', data => $data) -> set() unique_app_send_message(app, command_id, message);
+# $app->send_message_by_name('command', uris => @uri) -> set_uris() unique_app_send_message(app, command_id, message);
+#
 #
 UniqueResponse
-unique_app_send_message (UniqueApp *app, gint command_id, ...)
+unique_app_send_message (UniqueApp *app, SV *command, ...)
+	ALIAS:
+		send_message_by_name = 1
+
 	PREINIT:
 		UniqueMessageData *message = NULL;
 		SV **s = NULL;
+		gint command_id = 0;
 
 	CODE:
+
+		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);
+					if (command_id == 0) {
+							croak("Command '%s' isn't registered with the application", command_name);
+					}
+				}
+			break;
+
+			default:
+				croak("Method called with the wrong name");
+		}
+
 		if (items == 4) {
 			SV *sv_data;
 			gchar *type;




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