Patch for GtkImageMenuItem and GtkImageMenuItem 2.16
- From: Emmanuel Rodriguez <emmanuel rodriguez gmail com>
- To: gtk-perl-list gnome org
- Subject: Patch for GtkImageMenuItem and GtkImageMenuItem 2.16
- Date: Sun, 11 Jan 2009 12:44:29 +0100
Hi,
Her's the patch adding the new methods in Gtk 2.16 to the modules
Gtk2::ImageMenuItem and Gtk2::IMMulticontext.
I'm not too sure on what a Gtk2::IMMulticontex nor on how to use it. So
$context->get_context_id is quite tricky. I noticed that if I call
focus_is that the context selected is 'gtk-im-context-simple'. I just
hope that this is portable among all environments and locales.
Emmanuel
Index: xs/GtkImageMenuItem.xs
===================================================================
--- xs/GtkImageMenuItem.xs (revision 2104)
+++ xs/GtkImageMenuItem.xs (working copy)
@@ -62,3 +62,25 @@
gtk_image_menu_item_get_image (image_menu_item)
GtkImageMenuItem * image_menu_item
+
+#if GTK_CHECK_VERSION(2, 16, 0)
+
+## gboolean gtk_image_menu_item_get_use_stock (GtkImageMenuItem *image_menu_item);
+gboolean
+gtk_image_menu_item_get_use_stock (image_menu_item)
+ GtkImageMenuItem * image_menu_item
+
+## void gtk_image_menu_item_set_use_stock (GtkImageMenuItem *image_menu_item, gboolean use_stock);
+void
+gtk_image_menu_item_set_use_stock (image_menu_item, use_stock)
+ GtkImageMenuItem * image_menu_item
+ gboolean use_stock
+
+## void gtk_image_menu_item_set_accel_group (GtkImageMenuItem *image_menu_item, GtkAccelGroup *accel_group);
+void
+gtk_image_menu_item_set_accel_group (image_menu_item, accel_group)
+ GtkImageMenuItem * image_menu_item
+ GtkAccelGroup * accel_group
+
+#endif /* 2.16 */
+
Index: xs/GtkIMMulticontext.xs
===================================================================
--- xs/GtkIMMulticontext.xs (revision 2104)
+++ xs/GtkIMMulticontext.xs (working copy)
@@ -28,3 +28,10 @@
/*void*/
void gtk_im_multicontext_append_menuitems (GtkIMMulticontext *context, GtkMenuShell *menushell);
+
+
+#if GTK_CHECK_VERSION(2, 16, 0)
+
+const char* gtk_im_multicontext_get_context_id (GtkIMMulticontext *context);
+
+#endif /* 2.16 */
Index: t/GtkIMContext.t
===================================================================
--- t/GtkIMContext.t (revision 2104)
+++ t/GtkIMContext.t (working copy)
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
# vim: set ft=perl :
-use Gtk2::TestHelper tests => 7;
+use Gtk2::TestHelper tests => 9;
my $context = Gtk2::IMContextSimple->new;
isa_ok ($context, 'Gtk2::IMContextSimple');
@@ -59,3 +59,14 @@
isa_ok ($context, 'Glib::Object');
$context->append_menuitems (Gtk2::Menu->new);
+
+SKIP: {
+ skip '2.16 additions', 2
+ unless Gtk2->CHECK_VERSION (2, 16, 0);
+
+ is ($context->get_context_id, undef, 'No default context ID');
+
+ # Get a default context
+ $context->focus_in ();
+ is ($context->get_context_id, 'gtk-im-context-simple', 'Simple context');
+}
Index: t/GtkImageMenuItem.t
===================================================================
--- t/GtkImageMenuItem.t (revision 2104)
+++ t/GtkImageMenuItem.t (working copy)
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
use strict;
-use Gtk2::TestHelper tests => 7;
+use Gtk2::TestHelper tests => 11;
# $Id$
@@ -27,6 +27,29 @@
$item -> set_image($image);
is($item -> get_image(), $image);
+SKIP: {
+ skip 'use_stock methods', 4
+ unless Gtk2->CHECK_VERSION(2, 16, 0);
+
+ # Get an item from a stock and test the getter/setter
+ my $from_stock = Gtk2::ImageMenuItem -> new_from_stock("gtk-yes");
+ is($from_stock -> get_use_stock(), TRUE);
+ $from_stock -> set_use_stock(FALSE);
+ is($from_stock -> get_use_stock(), FALSE);
+
+
+ # Get an item WITHOUT a stock and test the getter/setter
+ my $with_label = Gtk2::ImageMenuItem -> new_with_label("Fake");
+ is($with_label -> get_use_stock(), FALSE);
+ $with_label -> set_use_stock(TRUE);
+ is($with_label -> get_use_stock(), TRUE);
+
+ # Add an accelator (applies only to stock items). Can't be verified, at least
+ # the method call is tested for a crash
+ my $with_accelartor = Gtk2::ImageMenuItem -> new_from_stock("gtk-no");
+ $from_stock -> set_accel_group(Gtk2::AccelGroup -> new());
+}
+
__END__
Copyright (C) 2003 by the gtk2-perl team (see the file AUTHORS for the
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]