Patch GtkSelection 2.16



Hi,

Here's the patch for upgrading GtkSelection to Gtk 2.16.

This patch is tricky and needs some revision because the new method added gtk_selection_data_get_selection() exists already and is aliased to 13 methods! Here's the old definition:

SV *
get_selection (d)
   GtkSelectionData * d
   ALIAS:
   Gtk2::SelectionData::selection     = 1
   Gtk2::SelectionData::get_target    = 2
   Gtk2::SelectionData::target        = 3
   Gtk2::SelectionData::get_data_type = 4
   Gtk2::SelectionData::type          = 5
   Gtk2::SelectionData::get_format    = 6
   Gtk2::SelectionData::format        = 7
   Gtk2::SelectionData::get_data      = 8
   Gtk2::SelectionData::data          = 9
   Gtk2::SelectionData::get_length    = 10
   Gtk2::SelectionData::length        = 11
   Gtk2::SelectionData::get_display   = 12
   Gtk2::SelectionData::display       = 13

I renamed the old implementation get_selection_. I used such an ugly syntax in order to stress that this is a private method, at least that's what the lack of documentation seems to be telling.

Best regards,
Emmanuel

Index: xs/GtkSelection.xs
===================================================================
--- xs/GtkSelection.xs  (revision 2111)
+++ xs/GtkSelection.xs  (working copy)
@@ -395,7 +395,7 @@
 
 MODULE = Gtk2::Selection       PACKAGE = Gtk2::SelectionData   PREFIX = gtk_selection_data_
 
-=for apidoc Gtk2::SelectionData::selection __hide__
+=for apidoc Gtk2::SelectionData::selection_ __hide__
 =cut
 
 =for apidoc Gtk2::SelectionData::target __hide__
@@ -422,7 +422,7 @@
 # const guchar *gtk_selection_data_get_data (GtkSelectionData *selection_data, gint *length);
 # GdkDisplay *gtk_selection_data_get_display (GtkSelectionData *selection_data);
 SV *
-get_selection (d)
+get_selection_ (d)
        GtkSelectionData * d
     ALIAS:
        Gtk2::SelectionData::selection     = 1
@@ -639,3 +639,18 @@
 gboolean gtk_selection_data_targets_include_uri (GtkSelectionData *selection_data) 
 
 #endif /* 2.10 */
+
+#if GTK_CHECK_VERSION (2, 15, 0)
+
+#
+# WARNING: Previous perl-Gtk2 bindings introduced already the method
+#          get_selection() that was fully implemented in XS. This clashes with
+#          the new method added in Gtk 2.16 gtk_selection_data_get_selection().
+#          In order to fix this the old method get_selection() was renamed to
+#          get_selection_() since it seems to be a private method not
+#          documented.
+#
+
+GdkAtom gtk_selection_data_get_selection (GtkSelectionData *selection_data);
+
+#endif /* 2.16 */
Index: t/GtkClipboard.t
===================================================================
--- t/GtkClipboard.t    (revision 2111)
+++ t/GtkClipboard.t    (working copy)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 # vim: set ft=perl :
-use Gtk2::TestHelper tests => 115,
+use Gtk2::TestHelper tests => 119,
        at_least_version => [2, 2, 0, "GtkClipboard didn't exist in 2.0.x"];
 
 # $Id$
@@ -149,6 +149,22 @@
        });
 }
 
+SKIP: {
+       skip "new 2.16 stuff", 4
+               unless Gtk2->CHECK_VERSION (2, 15, 0);
+
+       my $pixbuf = Gtk2::Gdk::Pixbuf->new ("rgb", FALSE, 8, 23, 42);
+       $clipboard->set_image ($pixbuf);
+       is ($clipboard->wait_is_image_available, TRUE);
+
+       my $contents = $clipboard->wait_for_contents(Gtk2::Gdk::Atom->intern('image/png'));
+       isa_ok ($contents, "Gtk2::SelectionData");
+       
+       my $atom = $contents->get_selection;
+       isa_ok ($atom, 'Gtk2::Gdk::Atom');
+       is ($atom->name, 'PRIMARY');
+}
+
 run_main;
 
 #print "----------------------------------\n";


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