perl-Gtk2 r2106 - in trunk: . t xs



Author: tsch
Date: Tue Jan 13 20:13:19 2009
New Revision: 2106
URL: http://svn.gnome.org/viewvc/perl-Gtk2?rev=2106&view=rev

Log:
Wrap the new GtkEntry API.  Patch by Emmanuel Rodriguez.


Added:
   trunk/maps-2.16
Modified:
   trunk/AUTHORS
   trunk/ChangeLog
   trunk/MANIFEST
   trunk/t/GtkEntry.t
   trunk/xs/GtkEntry.xs

Modified: trunk/AUTHORS
==============================================================================
--- trunk/AUTHORS	(original)
+++ trunk/AUTHORS	Tue Jan 13 20:13:19 2009
@@ -32,6 +32,7 @@
 Grant McLean		 grant at mclean dot net dot nz
 Philipp Rumpf		 prumpf at gmail dot com
 Kevin Ryde		 user42 zip com au
+Emmanuel Rodriguez       emmanuel rodriguez gmail com
 
 several important bits of gtk2-perl were heavily inspired by pygtk, gtk-perl,
 and a good read-through of the gtk+ source code, so credit goes to those guys

Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST	(original)
+++ trunk/MANIFEST	Tue Jan 13 20:13:19 2009
@@ -92,6 +92,7 @@
 maps-2.10
 maps-2.12
 maps-2.14
+maps-2.16
 maps-2.2
 maps-2.4
 maps-2.6

Added: trunk/maps-2.16
==============================================================================
--- (empty file)
+++ trunk/maps-2.16	Tue Jan 13 20:13:19 2009
@@ -0,0 +1 @@
+GTK_TYPE_ENTRY_ICON_POSITION  GtkEntryIconPosition  GEnum  Gtk2::EntryIconPosition

Modified: trunk/t/GtkEntry.t
==============================================================================
--- trunk/t/GtkEntry.t	(original)
+++ trunk/t/GtkEntry.t	Tue Jan 13 20:13:19 2009
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 use strict;
-use Gtk2::TestHelper tests => 23;
+use Gtk2::TestHelper tests => 59;
 
 # $Id$
 
@@ -99,6 +99,107 @@
   is ($entry -> get_overwrite_mode(), FALSE);
 }
 
+SKIP: {
+  skip '2.16 stuff', 36
+    unless Gtk2->CHECK_VERSION(2, 15, 0); # FIXME: 2.16
+
+  ## progress methods
+
+  my $entry = Gtk2::Entry -> new();
+  is($entry -> get_icon_at_pos(0, 0), -1);
+
+  delta_ok($entry -> get_progress_fraction(), 0.0);
+  delta_ok($entry -> get_progress_pulse_step(), 0.1);
+
+  $entry -> progress_pulse(); # We can't see the changes :(
+
+  $entry -> set_progress_fraction(0.3);
+  delta_ok($entry -> get_progress_fraction(), 0.3);
+
+  $entry -> set_progress_pulse_step(0.2);
+
+  ## unset_invisible_char
+
+  # Try the new password methods
+  my $password = Gtk2::Entry -> new();
+  $password -> set_visibility(FALSE);
+
+
+  # Change the default character
+  my $default = $password -> get_invisible_char();
+  my $char = $default eq 'X' ? '?' : 'X';
+  $password -> set_invisible_char($char);
+  is($password -> get_invisible_char(), $char);
+
+  # Restore the default character
+  $password -> unset_invisible_char();
+  is($password -> get_invisible_char(), $default);
+
+  ## icon methods
+
+  test_icon_methods('primary');
+  test_icon_methods('secondary');
+}
+
+
+sub test_icon_methods {
+  my ($icon_pos) = @_;
+
+  my $entry = Gtk2::Entry -> new();
+
+  is($entry -> get_icon_name($icon_pos), undef);
+  is($entry -> get_pixbuf($icon_pos), undef);
+  is($entry -> get_stock($icon_pos), undef);
+
+  $entry -> set_icon_sensitive($icon_pos, TRUE);
+  is($entry -> get_icon_sensitive($icon_pos), TRUE);
+
+  $entry -> set_icon_activatable($icon_pos, TRUE);
+  is($entry -> get_icon_activatable($icon_pos), TRUE);
+
+
+
+  # Is an 'icon name' the same as a 'stock icon'?
+  is($entry -> get_icon_name($icon_pos), undef);
+  $entry -> set_icon_from_icon_name($icon_pos, 'gtk-yes');
+  is($entry -> get_icon_name($icon_pos), 'gtk-yes');
+  ok($entry -> get_pixbuf($icon_pos));
+
+  # Reset through icon_name
+  $entry -> set_icon_from_icon_name($icon_pos, undef);
+  is($entry -> get_pixbuf($icon_pos), undef);
+
+
+
+  # Set and unset the icon through a stock image
+  $entry -> set_icon_from_stock($icon_pos, 'gtk-yes');
+  ok($entry -> get_pixbuf($icon_pos));
+  $entry -> set_icon_from_stock($icon_pos, undef);
+  is($entry -> get_pixbuf($icon_pos), undef);
+
+  # Reset
+  $entry -> set_icon_from_stock($icon_pos, undef);
+  is($entry -> get_icon_name($icon_pos), undef);
+  is($entry -> get_pixbuf($icon_pos), undef);
+
+
+
+  # Set and unset the icon through a pixbuf
+  my $pixbuf = Gtk2::Gdk::Pixbuf->new('rgb', TRUE, 8, 16, 16);
+  $entry -> set_icon_from_pixbuf($icon_pos, $pixbuf);
+  is($entry -> get_pixbuf($icon_pos), $pixbuf);
+  $entry -> set_icon_from_pixbuf($icon_pos, undef);
+  is($entry -> get_pixbuf($icon_pos), undef);
+
+
+  # This method can't be tested, at least we call them just in case they crash
+  $entry -> set_icon_tooltip_markup($icon_pos, "<b>Pan</b><i>Go</i> tooltip");
+  $entry -> set_icon_tooltip_markup($icon_pos, undef);
+
+  $entry -> set_icon_tooltip_text($icon_pos, "Text tooltip");
+  $entry -> set_icon_tooltip_text($icon_pos, undef);
+}
+
 __END__
 
 Copyright (C) 2003-2006 by the gtk2-perl team (see the file AUTHORS for the

Modified: trunk/xs/GtkEntry.xs
==============================================================================
--- trunk/xs/GtkEntry.xs	(original)
+++ trunk/xs/GtkEntry.xs	Tue Jan 13 20:13:19 2009
@@ -227,6 +227,60 @@
 
 #endif /* 2.14 */
 
+
+#if GTK_CHECK_VERSION(2, 15, 0) /* FIXME: 2.16 */
+
+#
+# FIXME: Missing typemap, actually I don't think that gio is available through Perl
+#
+# GIcon_ornull* gtk_entry_get_gicon (GtkEntry *entry, GtkEntryIconPosition icon_pos);
+# void gtk_entry_set_icon_from_gicon (GtkEntry *entry, GtkEntryIconPosition icon_pos, GIcon_ornull *icon);
+#
+
+gboolean gtk_entry_get_icon_activatable (GtkEntry *entry, GtkEntryIconPosition icon_pos);
+
+gint gtk_entry_get_icon_at_pos (GtkEntry *entry, gint x, gint y);
+
+const gchar_ornull* gtk_entry_get_icon_name (GtkEntry *entry, GtkEntryIconPosition icon_pos);
+
+gboolean gtk_entry_get_icon_sensitive (GtkEntry *entry, GtkEntryIconPosition icon_pos);
+
+GdkPixbuf_ornull* gtk_entry_get_pixbuf (GtkEntry *entry, GtkEntryIconPosition icon_pos);
+
+gdouble gtk_entry_get_progress_fraction (GtkEntry *entry);
+
+gdouble gtk_entry_get_progress_pulse_step (GtkEntry *entry);
+
+void gtk_entry_progress_pulse (GtkEntry *entry);
+
+const gchar_ornull* gtk_entry_get_stock (GtkEntry *entry, GtkEntryIconPosition icon_pos);
+
+GtkImageType gtk_entry_get_storage_type (GtkEntry *entry, GtkEntryIconPosition icon_pos);
+
+void gtk_entry_set_icon_activatable (GtkEntry *entry, GtkEntryIconPosition icon_pos, gboolean activatable);
+
+void gtk_entry_set_icon_from_icon_name (GtkEntry *entry, GtkEntryIconPosition icon_pos, const gchar_ornull *icon_name);
+
+void gtk_entry_set_icon_from_pixbuf (GtkEntry *entry, GtkEntryIconPosition icon_pos, GdkPixbuf_ornull *pixbuf);
+
+void gtk_entry_set_icon_from_stock (GtkEntry *entry, GtkEntryIconPosition icon_pos, const gchar_ornull *stock_id);
+
+void gtk_entry_set_icon_sensitive (GtkEntry *entry, GtkEntryIconPosition icon_pos, gboolean sensitive);
+
+void gtk_entry_set_icon_tooltip_markup (GtkEntry *entry, GtkEntryIconPosition icon_pos, const gchar_ornull *tooltip);
+
+void gtk_entry_set_icon_tooltip_text (GtkEntry *entry, GtkEntryIconPosition icon_pos, const gchar_ornull *tooltip);
+
+void gtk_entry_set_progress_fraction (GtkEntry *entry, gdouble fraction);
+
+void gtk_entry_set_progress_pulse_step (GtkEntry *entry, gdouble fraction);
+
+void gtk_entry_unset_invisible_char (GtkEntry *entry);
+
+
+#endif /* 2.16 */
+
+
 ##
 ## hey, these are deprecated!  is that new as of 2.3.x?
 ##



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