[perl-Gtk2] Wrap missing gtk+ 2.18 API
- From: Torsten Schönfeld <tsch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perl-Gtk2] Wrap missing gtk+ 2.18 API
- Date: Wed, 29 Dec 2010 23:16:07 +0000 (UTC)
commit dc1359bc154752c60e6543344f68342ba134da1a
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date: Thu Dec 30 00:14:33 2010 +0100
Wrap missing gtk+ 2.18 API
The Gtk2::Widget, Gtk2::EntryBuffer and Gtk2::Entry changes are based on
previous patches by Emmanuele Bassi.
constants-2.18 | 1 +
maps-2.18 | 1 +
t/GtkCellRenderer.t | 27 +++++++++++++++-
t/GtkCellRendererToggle.t | 10 +++++-
t/GtkEntry.t | 13 +++++++-
t/GtkEntryBuffer.t | 46 +++++++++++++++++++++++++++
t/GtkPrintOperation.t | 21 +++++++++++-
t/GtkWidget.t | 36 ++++++++++++++++++++-
xs/GtkCellRenderer.xs | 20 ++++++++++++
xs/GtkCellRendererToggle.xs | 8 +++++
xs/GtkEntry.xs | 13 +++++++-
xs/GtkEntryBuffer.xs | 73 +++++++++++++++++++++++++++++++++++++++++++
xs/GtkPrintOperation.xs | 18 ++++++++++
xs/GtkWidget.xs | 59 +++++++++++++++++++++++++++++++++-
xs_files-2.18 | 1 +
15 files changed, 338 insertions(+), 9 deletions(-)
---
diff --git a/constants-2.18 b/constants-2.18
new file mode 100644
index 0000000..5d63390
--- /dev/null
+++ b/constants-2.18
@@ -0,0 +1 @@
+GTK_ENTRY_BUFFER_MAX_SIZE newSVuv
diff --git a/maps-2.18 b/maps-2.18
index db45a65..e556d11 100644
--- a/maps-2.18
+++ b/maps-2.18
@@ -1 +1,2 @@
GTK_TYPE_INFO_BAR GtkInfoBar GtkObject Gtk2::InfoBar
+GTK_TYPE_ENTRY_BUFFER GtkEntryBuffer GObject Gtk2::EntryBuffer
diff --git a/t/GtkCellRenderer.t b/t/GtkCellRenderer.t
index 9a8c6de..da02ab3 100644
--- a/t/GtkCellRenderer.t
+++ b/t/GtkCellRenderer.t
@@ -2,7 +2,7 @@
# $Id$
-use Gtk2::TestHelper tests => 20;
+use Gtk2::TestHelper tests => 26;
use strict;
package Mup::CellRendererPopup;
@@ -199,6 +199,7 @@ SKIP: {
skip "editing_canceled is new in 2.4", 0
unless Gtk2->CHECK_VERSION (2, 4, 0);
+ my $renderer = Gtk2::CellRendererText->new;
$renderer->editing_canceled;
}
@@ -206,9 +207,33 @@ SKIP: {
skip "stop_editing is new in 2.6", 0
unless Gtk2->CHECK_VERSION (2, 6, 0);
+ my $renderer = Gtk2::CellRendererText->new;
$renderer->stop_editing (FALSE);
}
+SKIP: {
+ skip 'new 2.18 stuff', 6
+ unless Gtk2->CHECK_VERSION(2, 18, 0);
+
+ my $renderer = Gtk2::CellRendererText->new;
+
+ $renderer->set_visible (TRUE);
+ ok ($renderer->get_visible);
+
+ $renderer->set_sensitive (TRUE);
+ ok ($renderer->get_sensitive);
+
+ $renderer->set_alignment (0.5, 0.5);
+ my ($x, $y) = $renderer->get_alignment;
+ delta_ok ($x, 0.5);
+ delta_ok ($y, 0.5);
+
+ $renderer->set_padding (23, 42);
+ ($x, $y) = $renderer->get_padding;
+ is ($x, 23);
+ is ($y, 42);
+}
+
##########################################################################
run_main sub {
diff --git a/t/GtkCellRendererToggle.t b/t/GtkCellRendererToggle.t
index 2872aa5..a4fb2a8 100644
--- a/t/GtkCellRendererToggle.t
+++ b/t/GtkCellRendererToggle.t
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
use strict;
-use Gtk2::TestHelper tests => 3, noinit => 1;
+use Gtk2::TestHelper tests => 4, noinit => 1;
# $Id$
@@ -13,6 +13,14 @@ is($toggle -> get_radio(), 1);
$toggle -> set_active(1);
is($toggle -> get_active(), 1);
+SKIP: {
+ skip 'new 2.18 stuff', 1
+ unless Gtk2->CHECK_VERSION(2, 18, 0);
+
+ $toggle -> set_activatable(TRUE);
+ ok($toggle -> get_activatable());
+}
+
__END__
Copyright (C) 2003 by the gtk2-perl team (see the file AUTHORS for the
diff --git a/t/GtkEntry.t b/t/GtkEntry.t
index 44b45b3..be17afb 100644
--- a/t/GtkEntry.t
+++ b/t/GtkEntry.t
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
use strict;
-use Gtk2::TestHelper tests => 66;
+use Gtk2::TestHelper tests => 68;
# $Id$
@@ -142,6 +142,17 @@ SKIP: {
}
SKIP: {
+ skip 'new 2.18 stuff', 2
+ unless Gtk2->CHECK_VERSION(2, 18, 0);
+
+ my $buffer = Gtk2::EntryBuffer->new;
+ my $entry = Gtk2::Entry->new_with_buffer ($buffer);
+ isa_ok ($entry, 'Gtk2::Entry');
+ $entry->set_buffer ($buffer);
+ is ($entry->get_buffer, $buffer);
+}
+
+SKIP: {
skip 'new 2.20 stuff', 2
unless Gtk2->CHECK_VERSION(2, 20, 0);
diff --git a/t/GtkEntryBuffer.t b/t/GtkEntryBuffer.t
new file mode 100644
index 0000000..fc0aad7
--- /dev/null
+++ b/t/GtkEntryBuffer.t
@@ -0,0 +1,46 @@
+#!/usr/bin/perl -w
+# vim: set filetype=perl expandtab shiftwidth=2 softtabstop=2 :
+use utf8;
+use Gtk2::TestHelper tests => 18, at_least_version => [ 2, 18, 0 ];
+
+my $buffer = Gtk2::EntryBuffer->new();
+isa_ok( $buffer, 'Gtk2::EntryBuffer' );
+is( $buffer->get_text(), '' );
+is( $buffer->get_bytes(), 0 );
+is( $buffer->get_length(), 0 );
+
+my $text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit";
+
+$buffer = Gtk2::EntryBuffer->new($text);
+isnt( $buffer->get_text(), '' );
+is( $buffer->get_length(), length($text) );
+is( $buffer->get_bytes(), length($text) );
+
+my $utf8_text = "â?¥ Lorem ipsum dolor sit amet, consectetur adipisicing elit";
+$buffer->set_text($utf8_text);
+is( $buffer->get_length(), length($utf8_text) );
+is( $buffer->get_bytes(), length($utf8_text) + 2 ); # â?¥ == 0xE2 0x99 0xA5
+is( $buffer->get_text(), $utf8_text );
+
+$buffer = Gtk2::EntryBuffer->new(substr($utf8_text, 0, 5));
+is( $buffer->get_text(), 'â?¥ Lor' );
+is( $buffer->get_length(), 5 );
+is( $buffer->get_bytes(), 7 );
+
+$buffer->insert_text(0, 'Do ');
+is( $buffer->get_text(), 'Do â?¥ Lor' );
+
+$buffer->insert_text(-1, 'em ipsum');
+is( $buffer->get_text(), 'Do â?¥ Lorem ipsum' );
+
+$buffer->delete_text(10, -1);
+is( $buffer->get_text(), 'Do â?¥ Lorem' );
+
+$buffer->delete_text();
+is( $buffer->get_bytes(), 0 );
+
+$buffer->set_max_length(23);
+is( $buffer->get_max_length(), 23 );
+
+$buffer->emit_inserted_text(0, 'Lorem', 5);
+$buffer->emit_deleted_text(0, 5);
diff --git a/t/GtkPrintOperation.t b/t/GtkPrintOperation.t
index 2028b10..fb5c508 100644
--- a/t/GtkPrintOperation.t
+++ b/t/GtkPrintOperation.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
use Gtk2::TestHelper
- tests => 13,
+ tests => 17,
at_least_version => [2, 10, 0, "GtkPrintOperation is new in 2.10"];
# $Id$
@@ -40,6 +40,8 @@ sub get_op {
return $op;
}
+END { unlink "test.pdf"; }
+
$op = get_op();
ok(defined $op -> run("export", undef));
$op -> cancel();
@@ -81,8 +83,23 @@ SKIP: {
ok(defined $op -> run("export", Gtk2::Window -> new()));
}
+SKIP: {
+ skip 'new 2.18 stuff', 4
+ unless Gtk2->CHECK_VERSION(2, 18, 0);
+
+ my $op = Gtk2::PrintOperation -> new();
+
+ $op -> set_embed_page_setup(TRUE);
+ ok($op -> get_embed_page_setup());
+
+ $op -> set_support_selection(TRUE);
+ ok($op -> get_support_selection());
-unlink "test.pdf";
+ $op -> set_has_selection(TRUE);
+ ok($op -> get_has_selection());
+
+ ok(defined $op -> get_n_pages_to_print());
+}
=comment
diff --git a/t/GtkWidget.t b/t/GtkWidget.t
index b498532..4a9b321 100644
--- a/t/GtkWidget.t
+++ b/t/GtkWidget.t
@@ -6,7 +6,7 @@
use warnings;
use strict;
-use Gtk2::TestHelper tests => 144;
+use Gtk2::TestHelper tests => 157;
# we can't instantiate Gtk2::Widget, it's abstract. use a button instead.
@@ -503,6 +503,40 @@ SKIP: {
}
SKIP: {
+ skip 'new 2.18 stuff', 13
+ unless Gtk2->CHECK_VERSION(2, 18, 0);
+ my $widget = Gtk2::Label->new ('Bla');
+
+ my $rect = Gtk2::Gdk::Rectangle->new (0, 0, 23, 42);
+ $widget->set_allocation ($rect);
+ my $new_rect = $widget->get_allocation;
+ is ($new_rect->width, $rect->width);
+
+ $widget->set_can_default (TRUE);
+ ok ($widget->get_can_default);
+
+ $widget->set_can_focus (TRUE);
+ ok ($widget->get_can_focus);
+
+ $widget->set_has_window (TRUE);
+ ok ($widget->get_has_window);
+
+ $widget->set_receives_default (TRUE);
+ ok ($widget->get_receives_default);
+
+ $widget->set_visible (TRUE);
+ ok ($widget->get_visible);
+
+ ok (defined $widget->get_app_paintable);
+ ok (defined $widget->get_double_buffered);
+ ok (defined $widget->get_sensitive);
+ ok (defined $widget->get_state);
+ ok (defined $widget->is_drawable);
+ ok (defined $widget->is_sensitive);
+ ok (defined $widget->is_toplevel);
+}
+
+SKIP: {
skip 'new 2.20 stuff', 4
unless Gtk2->CHECK_VERSION(2, 20, 0);
diff --git a/xs/GtkCellRenderer.xs b/xs/GtkCellRenderer.xs
index b7bee0a..09a77eb 100644
--- a/xs/GtkCellRenderer.xs
+++ b/xs/GtkCellRenderer.xs
@@ -623,6 +623,26 @@ void gtk_cell_renderer_stop_editing (GtkCellRenderer *cell, gboolean canceled)
#endif
+#if GTK_CHECK_VERSION (2, 18, 0)
+
+gboolean gtk_cell_renderer_get_visible (GtkCellRenderer *cell);
+
+void gtk_cell_renderer_set_visible (GtkCellRenderer *cell, gboolean visible);
+
+gboolean gtk_cell_renderer_get_sensitive (GtkCellRenderer *cell);
+
+void gtk_cell_renderer_set_sensitive (GtkCellRenderer *cell, gboolean sensitive);
+
+void gtk_cell_renderer_get_alignment (GtkCellRenderer *cell, OUTLIST gfloat xalign, OUTLIST gfloat yalign);
+
+void gtk_cell_renderer_set_alignment (GtkCellRenderer *cell, gfloat xalign, gfloat yalign);
+
+void gtk_cell_renderer_get_padding (GtkCellRenderer *cell, OUTLIST gint xpad, OUTLIST gint ypad);
+
+void gtk_cell_renderer_set_padding (GtkCellRenderer *cell, gint xpad, gint ypad);
+
+#endif /* 2.18 */
+
##
## Modify the underlying GObjectClass structure for the given package
## to call Perl methods as virtual overrides for the get_size, render,
diff --git a/xs/GtkCellRendererToggle.xs b/xs/GtkCellRendererToggle.xs
index d2dd009..b3c8ad7 100644
--- a/xs/GtkCellRendererToggle.xs
+++ b/xs/GtkCellRendererToggle.xs
@@ -50,3 +50,11 @@ gtk_cell_renderer_toggle_set_active (toggle, setting)
GtkCellRendererToggle * toggle
gboolean setting
+#if GTK_CHECK_VERSION (2, 18, 0)
+
+gboolean gtk_cell_renderer_toggle_get_activatable (GtkCellRendererToggle *toggle);
+
+void gtk_cell_renderer_toggle_set_activatable (GtkCellRendererToggle *toggle, gboolean setting);
+
+#endif /* 2.18 */
+
diff --git a/xs/GtkEntry.xs b/xs/GtkEntry.xs
index c27b1e7..d88260b 100644
--- a/xs/GtkEntry.xs
+++ b/xs/GtkEntry.xs
@@ -233,7 +233,6 @@ guint16 gtk_entry_get_text_length (GtkEntry *entry);
#endif /* 2.14 */
-
#if GTK_CHECK_VERSION (2, 16, 0)
#
@@ -289,6 +288,18 @@ gint gtk_entry_get_current_icon_drag_source (GtkEntry *entry);
#endif /* 2.16 */
+#if GTK_CHECK_VERSION (2, 18, 0)
+
+GtkWidget *gtk_entry_new_with_buffer (class, GtkEntryBuffer *buffer)
+ C_ARGS:
+ buffer
+
+GtkEntryBuffer *gtk_entry_get_buffer (GtkEntry *entry);
+
+void gtk_entry_set_buffer (GtkEntry *entry, GtkEntryBuffer *buffer);
+
+#endif /* 2.18 */
+
#if GTK_CHECK_VERSION (2, 20, 0)
GdkWindow * gtk_entry_get_icon_window (GtkEntry *entry, GtkEntryIconPosition icon_pos);
diff --git a/xs/GtkEntryBuffer.xs b/xs/GtkEntryBuffer.xs
new file mode 100644
index 0000000..b268dda
--- /dev/null
+++ b/xs/GtkEntryBuffer.xs
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2010 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, see http://www.gnu.org/licenses/
+ */
+
+#include "gtk2perl.h"
+
+MODULE = Gtk2::EntryBuffer PACKAGE = Gtk2::EntryBuffer PREFIX = gtk_entry_buffer_
+
+=for apidoc
+=for position DESCRIPTION
+
+The B<Gtk2::EntryBuffer> class contains the actual text displayed in a
+L<Gtk2::Entry> widget.
+
+A single Gtk2::EntryBuffer object can be shared by multiple Gtk2::Entry
+widgets which will then share the same text content, but not the cursor
+position, visibility attributes, icon etc.
+
+Gtk2::EntryBuffer may be derived from. Such a derived class might allow
+text to be stored in an alternate location, such as non-pageable memory,
+useful in the case of important passwords. Or a derived class could
+integrate with an application's concept of undo/redo.
+
+=cut
+
+=for apidoc
+=for signature entrybuffer = Gtk2::EntryBuffer->new ($initial_chars=undef)
+=for arg initial_chars (string)
+=cut
+GtkEntryBuffer_noinc *
+gtk_entry_buffer_new (class, const gchar_utf8_length *initial_chars=NULL, gint length(initial_chars))
+ CODE:
+ if (initial_chars == NULL) {
+ RETVAL = gtk_entry_buffer_new (NULL, 0);
+ }
+ else {
+ RETVAL = gtk_entry_buffer_new (initial_chars, XSauto_length_of_initial_chars);
+ }
+ OUTPUT:
+ RETVAL
+
+gsize gtk_entry_buffer_get_bytes (GtkEntryBuffer *buffer);
+
+guint gtk_entry_buffer_get_length (GtkEntryBuffer *buffer);
+
+const gchar * gtk_entry_buffer_get_text (GtkEntryBuffer *buffer);
+
+void gtk_entry_buffer_set_text (GtkEntryBuffer *buffer, const gchar_utf8_length *chars, gint length(chars));
+
+void gtk_entry_buffer_set_max_length (GtkEntryBuffer *buffer, gint max_length);
+
+gint gtk_entry_buffer_get_max_length (GtkEntryBuffer *buffer);
+
+void gtk_entry_buffer_insert_text (GtkEntryBuffer *buffer, guint position, const gchar_utf8_length *chars, gint length(chars));
+
+guint gtk_entry_buffer_delete_text (GtkEntryBuffer *buffer, guint position=0, gint n_chars=-1);
+
+void gtk_entry_buffer_emit_inserted_text (GtkEntryBuffer *buffer, guint position, const gchar *chars, guint n_chars);
+
+void gtk_entry_buffer_emit_deleted_text (GtkEntryBuffer *buffer, guint position, guint n_chars);
diff --git a/xs/GtkPrintOperation.xs b/xs/GtkPrintOperation.xs
index d073f79..525bdd8 100644
--- a/xs/GtkPrintOperation.xs
+++ b/xs/GtkPrintOperation.xs
@@ -121,6 +121,24 @@ void gtk_print_operation_set_defer_drawing (GtkPrintOperation *op);
#endif /* 2.16 */
+#if GTK_CHECK_VERSION (2, 18, 0)
+
+void gtk_print_operation_set_embed_page_setup (GtkPrintOperation *op, gboolean embed);
+
+gboolean gtk_print_operation_get_embed_page_setup (GtkPrintOperation *op);
+
+void gtk_print_operation_set_support_selection (GtkPrintOperation *op, gboolean support_selection);
+
+gboolean gtk_print_operation_get_support_selection (GtkPrintOperation *op);
+
+void gtk_print_operation_set_has_selection (GtkPrintOperation *op, gboolean has_selection);
+
+gboolean gtk_print_operation_get_has_selection (GtkPrintOperation *op);
+
+gint gtk_print_operation_get_n_pages_to_print (GtkPrintOperation *op);
+
+#endif /* 2.18 */
+
MODULE = Gtk2::PrintOperation PACKAGE = Gtk2::Print PREFIX = gtk_print_
# GtkPageSetup * gtk_print_run_page_setup_dialog (GtkWindow *parent, GtkPageSetup *page_setup, GtkPrintSettings *settings);
diff --git a/xs/GtkWidget.xs b/xs/GtkWidget.xs
index aa812ad..1befdfa 100644
--- a/xs/GtkWidget.xs
+++ b/xs/GtkWidget.xs
@@ -62,8 +62,6 @@ _INSTALL_OVERRIDES (const char * package)
}
}
-
-
MODULE = Gtk2::Widget PACKAGE = Gtk2::Requisition
gint
@@ -1330,6 +1328,63 @@ GdkPixmap_noinc_ornull * gtk_widget_get_snapshot (GtkWidget *widget, GdkRectang
#endif /* 2.14 */
+#if GTK_CHECK_VERSION (2, 18, 0)
+
+void gtk_widget_set_allocation (GtkWidget *widget, const GdkRectangle *allocation);
+
+GdkRectangle_copy * gtk_widget_get_allocation (GtkWidget *widget)
+ PREINIT:
+ GdkRectangle allocation;
+ CODE:
+ gtk_widget_get_allocation (widget, &allocation);
+ RETVAL = &allocation;
+ OUTPUT:
+ RETVAL
+
+gboolean gtk_widget_get_app_paintable (GtkWidget *widget);
+
+gboolean gtk_widget_get_can_default (GtkWidget *widget);
+
+void gtk_widget_set_can_default (GtkWidget *widget, gboolean can_default);
+
+gboolean gtk_widget_get_can_focus (GtkWidget *widget);
+
+void gtk_widget_set_can_focus (GtkWidget *widget, gboolean can_focus);
+
+gboolean gtk_widget_get_double_buffered (GtkWidget *widget);
+
+void gtk_widget_set_has_window (GtkWidget *widget, gboolean has_window);
+
+gboolean gtk_widget_get_has_window (GtkWidget *widget);
+
+void gtk_widget_set_receives_default (GtkWidget *widget, gboolean receives_default);
+
+gboolean gtk_widget_get_receives_default (GtkWidget *widget);
+
+gboolean gtk_widget_get_sensitive (GtkWidget *widget);
+
+GtkStateType gtk_widget_get_state (GtkWidget *widget);
+
+gboolean gtk_widget_get_visible (GtkWidget *widget);
+
+void gtk_widget_set_visible (GtkWidget *widget, gboolean visible);
+
+# These conflict with our custom accessors and don't provide new
+# functionality. So just skip them for now.
+#gboolean gtk_widget_has_default (GtkWidget *widget);
+#gboolean gtk_widget_has_focus (GtkWidget *widget);
+#gboolean gtk_widget_has_grab (GtkWidget *widget);
+
+gboolean gtk_widget_is_drawable (GtkWidget *widget);
+
+gboolean gtk_widget_is_sensitive (GtkWidget *widget);
+
+gboolean gtk_widget_is_toplevel (GtkWidget *widget);
+
+void gtk_widget_set_window (GtkWidget *widget, GdkWindow *window);
+
+#endif /* 2.18 */
+
#if GTK_CHECK_VERSION (2, 20, 0)
void gtk_widget_set_realized (GtkWidget *widget, gboolean realized);
diff --git a/xs_files-2.18 b/xs_files-2.18
index a650343..657124c 100644
--- a/xs_files-2.18
+++ b/xs_files-2.18
@@ -1 +1,2 @@
xs/GtkInfoBar.xs
+xs/GtkEntryBuffer.xs
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]