Patch for GtkOrientable et GtkEntry (again) 2.16
- From: Emmanuel Rodriguez <emmanuel rodriguez gmail com>
- To: gtk-perl-list gnome org
- Subject: Patch for GtkOrientable et GtkEntry (again) 2.16
- Date: Sun, 11 Jan 2009 16:44:24 +0100
Hi,
Here's the patch for adding GtkOrientable, a new interface added in Gtk
2.16. I tried to do my best and took a look at other interfaces
(Gtk2::Editable and Gtk2::Buildable). This patch might need some guidance.
I've resubmitted GtkEntry, because I realized that svn diff doesn't take
into a count the files that it doesn't know (the ones svn status lists
with '?'). This new version adds the typemap for 2.16.
Emmanuel
Index: maps-2.16
===================================================================
--- maps-2.16 (revision 0)
+++ maps-2.16 (revision 0)
@@ -0,0 +1 @@
+GTK_TYPE_ENTRY_ICON_POSITION GtkEntryIconPosition GEnum Gtk2::EntryIconPosition
Index: xs/GtkEntry.xs
===================================================================
--- xs/GtkEntry.xs (revision 2104)
+++ xs/GtkEntry.xs (working copy)
@@ -227,6 +227,60 @@
#endif /* 2.14 */
+
+#if GTK_CHECK_VERSION(2, 16, 0)
+
+#
+# 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?
##
Index: t/GtkEntry.t
===================================================================
--- t/GtkEntry.t (revision 2104)
+++ t/GtkEntry.t (working copy)
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
use strict;
-use Gtk2::TestHelper tests => 23;
+use Gtk2::TestHelper tests => 61;
# $Id$
@@ -99,6 +99,113 @@
is ($entry -> get_overwrite_mode(), FALSE);
}
+SKIP: {
+ skip 'progress methods', 4
+ unless Gtk2->CHECK_VERSION(2, 16, 0);
+
+ my $entry = Gtk2::Entry -> new();
+ is ($entry -> get_icon_at_pos(0, 0), -1);
+
+ is ($entry -> get_progress_fraction(), 0.0);
+ is ($entry -> get_progress_pulse_step(), 0.1);
+
+ $entry -> progress_pulse(); # We can't see the changes :(
+
+ $entry -> set_progress_fraction(0.3);
+ is ($entry -> get_progress_fraction(), 0.3);
+
+ $entry -> set_progress_pulse_step(0.2);
+}
+
+SKIP: {
+ skip 'unset_invisible_char', 2
+ unless Gtk2->CHECK_VERSION(2, 16, 0);
+
+ # 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);
+}
+
+SKIP: {
+ skip 'icon methods', 18
+ unless Gtk2->CHECK_VERSION(2, 16, 0);
+
+ test_icon_methods('primary');
+ test_icon_methods('secondary');
+}
+
+
+sub test_icon_methods {
+ my ($icon_pos) = @_;
+
+ my $entry = Gtk2::Entry -> new();
+
+ is ($entry -> get_icon_activatable($icon_pos), FALSE);
+ is ($entry -> get_icon_name($icon_pos), undef);
+ is ($entry -> get_icon_sensitive($icon_pos), TRUE);
+ is ($entry -> get_pixbuf($icon_pos), undef);
+ is ($entry -> get_stock($icon_pos), undef);
+
+ $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_sensitive($icon_pos, TRUE);
+ $entry -> set_icon_sensitive($icon_pos, FALSE);
+
+ $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
Index: maps-2.16
===================================================================
--- maps-2.16 (revision 0)
+++ maps-2.16 (revision 0)
@@ -0,0 +1 @@
+GTK_TYPE_ORIENTABLE GtkOrientable GInterface Gtk2::Orientable
Index: xs/GtkOrientable.xs
===================================================================
--- xs/GtkOrientable.xs (revision 0)
+++ xs/GtkOrientable.xs (revision 0)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2009 by the gtk2-perl team (see the file AUTHORS)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307 USA.
+ *
+ * $Id: NEW FILE $
+ */
+
+#include "gtk2perl.h"
+
+
+MODULE = Gtk2::Orientable PACKAGE = Gtk2::Orientable PREFIX = gtk_orientable_
+
+=for object Gtk2::Orientable - Interface for flippable widgets
+=cut
+
+=for apidoc __hide__
+=cut
+void
+_ADD_INTERFACE (class, const char * target_class)
+ CODE:
+ {
+ static const GInterfaceInfo iface_info = {
+ (GInterfaceInitFunc) NULL,
+ (GInterfaceFinalizeFunc) NULL,
+ (gpointer) NULL
+ };
+ GType gtype = gperl_object_type_from_package (target_class);
+ g_type_add_interface_static (gtype, GTK_TYPE_ORIENTABLE, &iface_info);
+ }
+
+
+GtkOrientation gtk_orientable_get_orientation (GtkOrientable *orientable);
+
+void gtk_orientable_set_orientation (GtkOrientable *orientable, GtkOrientation orientation);
Index: xs_files-2.16
===================================================================
--- xs_files-2.16 (revision 0)
+++ xs_files-2.16 (revision 0)
@@ -0,0 +1 @@
+xs/GtkOrientable.xs
Index: t/GtkOrientable.t
===================================================================
--- t/GtkOrientable.t (revision 0)
+++ t/GtkOrientable.t (revision 0)
@@ -0,0 +1,30 @@
+#!/usr/bin/perl -w
+use strict;
+use Gtk2::TestHelper
+ tests => 6,
+ at_least_version => [2, 16, 0, 'GtkOrientable: it appeared in 2.16'];
+
+# $Id: NEW FILE $
+
+
+my $vbox = Gtk2::VBox -> new();
+isa_ok($vbox, "Gtk2::Orientable");
+is($vbox->get_orientation, 'vertical');
+
+my $hbox = Gtk2::HBox -> new();
+isa_ok($hbox, "Gtk2::Orientable");
+is($hbox->get_orientation, 'horizontal');
+
+
+# Swap the orientation
+$vbox->set_orientation('horizontal');
+is($vbox->get_orientation, 'horizontal');
+
+$hbox->set_orientation('vertical');
+is($hbox->get_orientation, 'vertical');
+
+
+__END__
+
+Copyright (C) 2009 by the gtk2-perl team (see the file AUTHORS for the
+full list). See LICENSE for more information.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]