Menu items visible in Unity, but not Gnome
gscan2pdf users are reporting[1] that they cannot see menu items in Gnome, but if they switch to, say Unity, then things work properly. I assume that if this were a general problem with gtk+-3, then there would be lots of bug reports, but my internet search drew a blank. I'm wondering if it is a theme problem - gscan2pdf doesn't ship any css and relies on defaults, as this has always worked for me (xfce and kde). Does anyone have any insight what might be going on? Regards Jeff [1] https://sourceforge.net/p/gscan2pdf/mailman/message/36394393/ ___ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Gtk3::Application and handles-command-line
Investing Gtk3::Application further, I find that if I try to run the code below, it falls over calling Glib::IO::ApplicationCommandLine::get_options_dict() GType GVariantDict (46597648) is not registered with gperl at /usr/lib/i386-linux-gnu/perl5/5.26/Glib/Object/Introspection.pm line 67. What can I do to get this running? Regards Jeff #!/usr/bin/perl package MyApp; BEGIN { use Glib::Object::Introspection; Glib::Object::Introspection->setup( basename => 'Gio', version => '2.0', package => 'Glib::IO'); } use strict; use warnings; use Gtk3; use Glib qw/TRUE FALSE/; my $window; use Glib::Object::Subclass qw/Gtk3::Application/; sub STARTUP { my ($app) = @_; print "entering STARTUP with $app\n"; $app->SUPER::STARTUP (); $app->add_main_option('test', ord('t'), [], 'none', 'Command line test', undef); $window = Gtk3::ApplicationWindow->new ($app); print "after new\n"; $window->set_title ('Welcome to GNOME'); $window->set_default_size (200, 200); $window->signal_connect ('delete_event' => sub {$app->quit()}); $window->show_all (); print "leaving STARTUP\n"; return; } sub ACTIVATE { my ($app) = @_; print "entering ACTIVATE\n"; $window->present; print "leaving ACTIVATE\n"; return $app->SUPER::ACTIVATE (); } sub OPEN { my ($app, $files, $nfiles, $arg3) = @_; print "in open\n"; use Data::Dumper; print Dumper($files, $nfiles, $arg3); for my $file (@$files) { print $file->get_path(), "\n"; } } sub COMMAND_LINE { my ($app, $command_line) = @_; print "in command line $command_line\n"; my $options = $command_line->get_options_dict(); return $app->SUPER::COMMAND_LINE ($command_line); } sub SHUTDOWN { my ($app) = @_; print "entering SHUTDOWN\n"; return $app->SUPER::SHUTDOWN (); } package main; my $app = MyApp->new( application_id => 'app.test', flags => ['handles-open','handles-command-line']); exit $app->run([$0, @ARGV]); ___ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Gtk3::Application and vfuncs causing segfault
Unfortunately, the Gtk3::Application examples we were throwing about before were not very realistic, as they built the UI in the activate callback/vfunc. However, the logic is that the startup callback/vfunc is the one that is called first and once only, and the activate callback immediately afterwards, and then before any open callback. However, if I rewrite the vfunc version to build the UI in the startup method, it segfaults during the Gtk3::ApplicationWindow->new($app) call. I can make the whole thing work by using a vfunc for the OPEN method (that doesn't work with callbacks yet) and callbacks everywhere else. Please find the two versions below in the hope that someone who knows more about the internals can work out what is causing the segfault. Regards Jeff #!/usr/bin/perl package MyApp; BEGIN { use Glib::Object::Introspection; Glib::Object::Introspection->setup( basename => 'Gio', version => '2.0', package => 'Glib::IO'); } use strict; use warnings; use Gtk3; use Glib qw/TRUE FALSE/; my $window; use Glib::Object::Subclass qw/Gtk3::Application/; sub STARTUP { my ($app) = @_; print "entering STARTUP with $app\n"; $window = Gtk3::ApplicationWindow->new ($app); print "after new\n"; $window->set_title ('Welcome to GNOME'); $window->set_default_size (200, 200); $window->signal_connect ('delete_event' => sub {$app->quit()}); $window->show_all (); print "leaving STARTUP\n"; return $app->SUPER::STARTUP (); } sub ACTIVATE { my ($app) = @_; print "entering ACTIVATE\n"; $window->present; print "leaving ACTIVATE\n"; return $app->SUPER::ACTIVATE (); } sub OPEN { my ($app, $files, $nfiles, $arg3) = @_; print "in open\n"; use Data::Dumper; print Dumper($files, $nfiles, $arg3); for my $file (@$files) { print $file->get_path(), "\n"; } } sub SHUTDOWN { my ($app) = @_; print "entering SHUTDOWN\n"; return $app->SUPER::SHUTDOWN (); } package main; my $app = MyApp->new( application_id => 'app.test', flags => 'handles-open'); exit $app->run([$0, @ARGV]); #!/usr/bin/perl package MyApp; BEGIN { use Glib::Object::Introspection; Glib::Object::Introspection->setup( basename => 'Gio', version => '2.0', package => 'Glib::IO'); } use strict; use warnings; use Gtk3; use Glib qw/TRUE FALSE/; my $window; use Glib::Object::Subclass qw/Gtk3::Application/; sub OPEN { my ($app, $files, $nfiles, $arg3) = @_; print "in open\n"; use Data::Dumper; print Dumper($files, $nfiles, $arg3); for my $file (@$files) { print $file->get_path(), "\n"; } } package main; my $app = MyApp->new( application_id => 'app.test', flags => 'handles-open'); $app->signal_connect('startup' => \_callback ); $app->signal_connect('activate' => \_callback ); $app->signal_connect('shutdown' => \_callback ); exit $app->run([$0, @ARGV]); sub startup_callback { my ($app) = @_; print "entering STARTUP with $app\n"; $window = Gtk3::ApplicationWindow->new ($app); print "after new\n"; $window->set_title ('Welcome to GNOME'); $window->set_default_size (200, 200); $window->signal_connect ('delete_event' => sub {$app->quit()}); $window->show_all (); print "leaving STARTUP\n"; } sub activate_callback { my ($app) = @_; print "entering ACTIVATE\n"; $window->present; print "leaving ACTIVATE\n"; } sub shutdown_callback { my ($app) = @_; # Handle cleanup print "Goodbye world!\n"; } ___ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Override for Gtk3::TargetEntry
The enhancement below adds an override to make it easier to supply the Gtk3::TargetFlags arguments for a Gtk3::TargetEntry https://bugzilla.gnome.org/show_bug.cgi?id=795780 Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Gtk3->GET_VERSION_INFO
On Wed, 2 May 2018 18:10:57 +0100 Emmanuele Bassiwrote: > Could you please open an issue on Bugzilla, here: > > https://bugzilla.gnome.org/enter_bug.cgi?product=gnome-perl=Gtk3 > > and attach your patch there? It would help making it easier for the > maintainers to review and apply your patch. Done: https://bugzilla.gnome.org/show_bug.cgi?id=795778 Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Gtk3->GET_VERSION_INFO
>> What is the Gtk3 equivalent of >> Gtk2->GET_VERSION_INFO >> and >> Gtk2->get_version_info >> ? > It looks like these convenience functions never made it from Gtk2.pm > to Gtk3.pm. You can instead use Gtk3::get_major_version (), > Gtk3::get_micro_version () and Gtk3::get_minor_version () as well as > Gtk3::MAJOR_VERSION and friends. I'd also gladly accept a patch adding > ports of the old helpers to Gtk3.pm. Please find attached a patch to do add the above functionality, along with some tests. Regards Jeff From a0842203f949dd51d23d0af6148cfe525c86317e Mon Sep 17 00:00:00 2001 From: Jeffrey Ratcliffe <jeffrey.ratcli...@gmail.com> Date: Wed, 2 May 2018 17:45:19 +0200 Subject: [PATCH] + helper functions Gtk3->get_version_info, Gtk3->GET_VERSION_INFO --- lib/Gtk3.pm | 9 + t/00-init.t | 31 +-- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/lib/Gtk3.pm b/lib/Gtk3.pm index 241632d..f328d37 100644 --- a/lib/Gtk3.pm +++ b/lib/Gtk3.pm @@ -2381,6 +2381,15 @@ sub ge { package Gtk3; +sub get_version_info { +return Gtk3::get_major_version(), Gtk3::get_minor_version(), +Gtk3::get_micro_version(); +} + +sub GET_VERSION_INFO { +return Gtk3->MAJOR_VERSION, Gtk3->MINOR_VERSION, Gtk3->MICRO_VERSION; +} + 1; __END__ diff --git a/t/00-init.t b/t/00-init.t index 34f5cf1..0bc1794 100644 --- a/t/00-init.t +++ b/t/00-init.t @@ -17,12 +17,7 @@ unless (eval { Gtk3->import; 1 }) { } } -plan tests => 3; - -diag (sprintf 'Testing against gtk+ %d.%d.%d', - Gtk3::get_major_version (), - Gtk3::get_minor_version (), - Gtk3::get_micro_version ()); +plan tests => 16; SKIP: { @ARGV = qw(--help --name gtk2perl --urgs tree); @@ -42,3 +37,27 @@ SKIP: { eval { my $b = Gtk3::LinkButton->new; }; like ($@, qr/00-init\.t/); } + +my @run_version = Gtk3->get_version_info; +my @compile_version = Gtk3->GET_VERSION_INFO; + +diag 'Testing Gtk3 ', $Gtk3::VERSION; +diag ' Running against gtk+ ', join '.', @run_version; +diag ' Compiled against gtk+ ', join '.', @compile_version; + +is( @run_version, 3, 'version info is three items long' ); +is (Gtk3->check_version(0,0,0), 'GTK+ version too new (major mismatch)', +'check_version fail 1'); +is (Gtk3->check_version(3,0,0), undef, 'check_version pass'); +is (Gtk3->check_version(50,0,0), 'GTK+ version too old (major mismatch)', +'check_version fail 2'); +ok (defined (Gtk3::get_major_version()), 'major_version'); +ok (defined (Gtk3::get_minor_version()), 'minor_version'); +ok (defined (Gtk3::get_micro_version()), 'micro_version'); + +is (@compile_version, 3, 'version info is three items long'); +ok (Gtk3->CHECK_VERSION(3,0,0), 'CHECK_VERSION pass'); +ok (!Gtk3->CHECK_VERSION(50,0,0), 'CHECK_VERSION fail'); +is (Gtk3->MAJOR_VERSION, $compile_version[0], 'MAJOR_VERSION'); +is (Gtk3->MINOR_VERSION, $compile_version[1], 'MINOR_VERSION'); +is (Gtk3->MICRO_VERSION, $compile_version[2], 'MICRO_VERSION'); -- 2.17.0 ___ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Gtk3::Application open signal
On Mon, 23 Apr 2018 09:43:37 +0200 Jeffrey Ratcliffe <jf...@posteo.net> wrote: > I've been failing to make the Gtk3::Application "open" signal work. > Below, I've adapted an example from maxperl's tutorial on github. This > should take filenames as arguments. These callbacks are implemented as vfuncs in Python, and I see that Perl vfuncs that clash with core methods have a _VFUNC appended. Could this be the reason for the open signal never being emitted in Perl? Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Gtk3::Application open signal
On Mon, 23 Apr 2018 13:00:06 + oldtechaawrote: > I haven't used the open signal, but with the reference here [1], it > appears it is emitted when g_application_open() is emitted, as also > documented here. [2] Are you using g_application_open() anywhere? > > oldtechaa > > [1] > https://developer.gnome.org/gio/stable/GApplication.html#GApplication-open > [2] > https://developer.gnome.org/gio/stable/GApplication.html#g-application-open Thanks for the links, but I think they just confirm what I already thought, that assuming the handles-open flag is set, if files are passed to the application, either by someone "using with", or via arguments on the command line, or by gdbus, then this signal will be emitted, along with the list of files. Normally, you don't have to call g_application_open() yourself, this is done for you. You can call g_application_open() if you want to handle, say files passed via the command line yourself. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Gtk3::Application open signal
I've been failing to make the Gtk3::Application "open" signal work. Below, I've adapted an example from maxperl's tutorial on github. This should take filenames as arguments. Unfortunately the open signal is never emitted. Below the Perl example is a Python one which works as expected. I've poked around the Gtk3 and Gio code, but can't find any reference to the GtkApplication stuff. Any help would be much appreciated Regards Jeff #!/usr/bin/perl # Make a binding to the Gio API in the Perl program (just copy ;-)) # This is necessary mainly for Gtk3::Application and some more stuff # Alternatively you find an early implementation as a Perl module # on https://git.gnome.org/browse/perl-Glib-IO (not yet published on CPAN!) # Hopefully this module simplifies the use of the Gio API in the future # (see also the notes above). BEGIN { use Glib::Object::Introspection; Glib::Object::Introspection->setup( basename => 'Gio', version => '2.0', package => 'Glib::IO'); } use strict; use warnings; use Gtk3; use Glib qw/TRUE FALSE/; # The MAIN FUNCTION should be as small as possible and do almost nothing except creating # your Gtk3::Application and running it # The "real work" should always be done in response to the signals fired by Gtk3::Application. # see below my $app = Gtk3::Application->new('app.test', 'handles-open'); $app->signal_connect('startup' => \&_init ); $app->signal_connect('activate' => \&_build_ui ); $app->signal_connect('open' => \&_open ); $app->signal_connect('shutdown' => \&_cleanup ); print "starting with @ARGV\n"; $app->run(\@ARGV); exit; # The CALLBACK FUNCTIONS to the SIGNALS fired by the main function. # Here we do the "real work" (see above) sub _init { my ($app) = @_; # Handle program initialization print "Hello world!\n"; } sub _build_ui { my ($app) = @_; print "running activate\n"; my $window = Gtk3::ApplicationWindow->new($app); $window->set_title ('Welcome to GNOME'); $window->set_default_size (200, 200); $window->signal_connect( 'delete_event' => sub {$app->quit()} ); $window->show(); } sub _open { my ($app, $files) = @_; print "files: $files\n"; } sub _cleanup { my ($app) = @_; # Handle cleanup print "Goodbye world!\n"; } import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk, Gio import sys # a Gtk ApplicationWindow class MyWindow(Gtk.ApplicationWindow): # constructor: the title is "Welcome to GNOME" and the window belongs # to the application app def __init__(self, app): Gtk.Window.__init__(self, title="Welcome to GNOME", application=app) class MyApplication(Gtk.Application): # constructor of the Gtk Application def __init__(self): Gtk.Application.__init__(self, flags=Gio.ApplicationFlags.HANDLES_OPEN) # create and activate a MyWindow, with self (the MyApplication) as # application the window belongs to. # Note that the function in C activate() becomes do_activate() in Python def do_activate(self): win = MyWindow(self) # show the window and all its content # this line could go in the constructor of MyWindow as well win.show_all() print "activate" # start up the application # Note that the function in C startup() becomes do_startup() in Python def do_startup(self): Gtk.Application.do_startup(self) print "startup" # open any files # Note that the function in C open() becomes do_open() in Python def do_open(self, list_of_file_objects, number_of_files, arg3): print "open", list_of_file_objects, number_of_files, arg3 for f in list_of_file_objects: print f.get_basename() Gtk.Application.do_open(self, list_of_file_objects, str(number_of_files)) # create and run the application, exit with the value returned by # running the program app = MyApplication() exit_status = app.run(sys.argv) sys.exit(exit_status) ___ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Removing entries from EntryCompletion
On 14 February 2017 at 21:10, Jeffrey Ratcliffe <jeffrey.ratcli...@gmail.com> wrote: > I'll open a wishlist bug and hope that the developers can provide an > API for this in a future release. Done: https://bugzilla.gnome.org/show_bug.cgi?id=778626 ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Removing entries from EntryCompletion
Hi Eric, On 14 February 2017 at 00:56,wrote: > For this you need the private data of the entry completion to get it to > work. That means looking around the GTK source and seeing how you might put > something together. Of course, it is not recommended to use something that > can be changed at anytime by the GTK developers. So... I gave it a try to > see if it could be done. I got something working but it might very well > interfere with other code. Brilliant. Thanks for the proof of concept. My application is written in Perl with Gtk2 bindings, so it looks as though I have no chance of getting at the private data. I'll open a wishlist bug and hope that the developers can provide an API for this in a future release. Regards Jeff ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Removing entries from EntryCompletion
On 12 February 2017 at 17:48, Norbert de Jongewrote: > As soon as you click anywhere outside the area with suggestions > (matching entries), the overview of suggestions disappears. This means > that users can never hover over a suggestion to highlight it and then > press a delete button. Unless I'm misunderstanding what you have in > mind. If you hover the mouse over a particular matching entry, it is highlighted. I would like to be able to then pick up delete key press and know which matching entry was highlighted. > Anyway, why not add a button to open a completely new window that allows > users to remove suggestions from a tree view. This should also allow > them to remove multiple entries at once. Another, lazier solution, > could be to add a delete button that will delete the suggestion > matching what's currently in the entry. Both had crossed my mind. I don't like the first, because it seems very cumbersome in comparison to the solution I would like. However this is the only solution I currently know how to implement. The second solution would be very annoying, as many users, having seen the word they want is not suggested, press delete to clear extraneous data from the entry, and would thus probably also delete a matching entry they would have wanted to keep. > Something else that may or may not be possible, is add a > g_signal_connect (entry, "key_press_event", G_CALLBACK (Delete), NULL); > and then check in Delete() > if (strcmp (gdk_keyval_name (event->key.keyval), "Delete") == 0) > and if that's the case, somehow obtain the active suggestion. > The problem here is that a GtkEntryCompletion only contains only > private data. At least, I think. > I tried using > selection = gtk_tree_view_get_selection (GTK_TREE_VIEW > (completion->priv->tree_view_proposals)); > to get a selection, but this doesn't seem to work. Indeed. This is what I have been failing to make work. Thanks for the suggestions. Regards Jeff ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Removing entries from EntryCompletion
In my application, I use an entry widget with completion, which gets appended to when the user adds new strings. So far, so vanilla. Users are asking for the possibility to remove strings from the list of suggestions. Is seems to me that the easiest way for the user to indicate to the GUI that a particular suggestion should be removed would be via the delete button whilst that suggestion is highlighted. However, I can't see how to tell which suggestion is highlighted (if at all). I would be grateful for any help, or suggestions for alternative methods. Regards Jeff ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: EntryCompletion
On 24 January 2017 at 21:38, Torsten Schoenfeldwrote: > Maybe check the "has-focus" property of the entry. Thanks for the suggestion. It seems that the entry never loses the focus, probably because otherwise the completion would get in the way of the entry. If anyone has any good ideas of a mechanism with which the user could signal to the GUI that a particular suggestion should be deleted, I would be very grateful. Regards Jeff Here is a small example of an entry with a completion: #!/usr/bin/perl use strict; use warnings; use Gtk2 -init; use Glib qw(TRUE FALSE); my $window = Gtk2::Window->new; $window->signal_connect (destroy => sub { Gtk2->main_quit }); my $model = Gtk2::ListStore->new ('Glib::String'); for ('one', 'one and a half', 'one and two thirds', 'one and three quarters') { $model->set ($model->append, 0, $_) } my $completion = Gtk2::EntryCompletion->new; $completion->set_model ($model); $completion->set_text_column (0); $completion->set_inline_completion(TRUE); my $entry = Gtk2::Entry->new; $entry->set_completion($completion); $entry->signal_connect( 'delete-from-cursor' => sub { my ( $widget, $delete_type, $count, $user_param1 ) = @_; my $text = $widget->get_text; print "'delete-from-cursor' $widget, $delete_type, $count, $text\n"; print "entry has focus ", $widget->has_focus, "\n"; print "entry is focus ", $widget->is_focus, "\n"; print "entry state ", $widget->state, "\n"; #if ($widget->state >= 'normal') { "normal\n" }; #if ($widget->state >= 'active') { "active\n" }; #if ($widget->state >= 'prelight') { "prelight\n" }; #if ($widget->state >= 'selected') { "selected\n" }; #if ($widget->state >= 'insensitive') { "insensitive\n" }; #print "completion has focus ", $completion->get_property('has-focus'), "\n"; } ); $completion->signal_connect( 'action-activated' => sub { my ( $widget, $index, $user_param1 ) = @_; my $text = $widget->get_text; print "'action-activated' $widget, $index, $text\n"; } ); $completion->signal_connect( 'cursor-on-match' => sub { my ( $widget, $model, $iter, $user_param1 ) = @_; my $suggestion = $model->get( $iter, 0 ); print "'cursor-on-match' $widget, $suggestion\n"; } ); $completion->signal_connect( 'match-selected' => sub { my ( $widget, $model, $iter, $user_param1 ) = @_; my $suggestion = $model->get( $iter, 0 ); print "'match-selected' $widget, $suggestion\n"; } ); #$completion->signal_connect( #'key-press-event' => sub { #my ( $widget, $event ) = @_; #my $key = $event->keyval; #print "'key-press-event' $widget, $event, $key\n"; #} #); $window->add ($entry); $window->show_all; Gtk2->main; ___ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list
EntryCompletion
I use EntryCompletion widgets in my application. I would like to be able to trap somebody pressing del whilst a suggestion is highlighted to remove that suggestion from the model. I can't work out how to tell if a suggestion is highlighted. The EntryCompletion widget doesn't seem to have a key-press-event. Can somebody give me some pointers? Thanks in advance. Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Locale/Encoding problem in menus
A couple of gscan2pdf users have a locale/encoding problem with menus in gscan2pdf in French with KDE 4 & 5: https://sourceforge.net/p/gscan2pdf/bugs/230/ To summarise, non-ASCII characters in menus are replaced by a black diamond/rhombus with a question mark inside: https://sourceforge.net/p/gscan2pdf/bugs/_discuss/thread/aa2fd1b1/1190/attachment/Screenshot_20161031_155115.png Needless to say, I cannot reproduce the problem on my machines with MATE or Cinnamon. However, I do not have a machine with KDE 4 or 5 to test on. But, as gscan2pdf has been translated into 34 languages, most of which use non-ASCII characters, I feel this cannot be a problem with gscan2pdf, and is likely a bug or misconfiguration somewhere else, or I would have more than two users with reports like this. The problem doesn't seem to affect all GTK applications, as they say GIMP is OK. Does anyone have any insight on what might be causing this? Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list
drag-n-drop
I'd like to write tests for the drag-n-drop functionality in my application. I spent some time hacking around trying to emit the 'drag-data-received' signal with the correct parameters to no effect. I've tried variations on a drag_begin() invocation. Then I looked for inspiration in the Gtk2 tests and found in https://git.gnome.org/browse/perl-Gtk2/tree/t/GtkTreeView-Dnd.t # TODO/FIXME: synthesize the drag So - I've love to be able to solve this. Any pointers? Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: stdout/sterr to GtkTextView at runtime
On 11 December 2015 at 06:14,wrote: > How can i achieve to get all output at runtime in my textview? And how do i > check if test_output is done running? I found an old solution using Gtk+ > itself but my perl skills aren't good enough to reproduce this: > https://mail.gnome.org/archives/gtk-list/2006-February/msg00040.html Below is the relevant code which gscan2pdf uses to read the output from scanimage. The following callbacks are run as the process starts, while it is running, and when it finished, respectively: $options{started_callback}, $options{running_callback}, $options{finished_callback} The following callbacks are triggered when data is available from the appropriate stream: $options{out_callback}, $options{err_callback} Obviously, the command is passed in. $options{cmd} You use the above hooks to update the GUI, which is therefore not blocked by the process. The code is for Gtk2, but I assume it should work very similarly in Gtk3, and should also be independent of the shell that is being used. HTH Jeff use IPC::Open3; use IO::Handle; sub _watch_cmd { my (%options) = @_; my $out_finished = FALSE; my $err_finished = FALSE; my $error_flag = FALSE; $logger->info( $options{cmd} ); if ( defined $options{running_callback} ) { my $timer = Glib::Timeout->add( $_POLL_INTERVAL, sub { $options{running_callback}->(); return Glib::SOURCE_REMOVE if ( $out_finished or $err_finished ); return Glib::SOURCE_CONTINUE; } ); } my ( $write, $read ); my $error = IO::Handle->new; my $pid = IPC::Open3::open3( $write, $read, $error, $options{cmd} ); if ( defined $options{started_callback} ) { $options{started_callback}->() } my ( $stdout, $stderr, $error_message ); _add_watch( $read, sub { my ($line) = @_; $stdout .= $line; if ( defined $options{out_callback} ) { $options{out_callback}->($line); } }, sub { # Don't flag this until after the callback to avoid the race condition # where stdout is truncated by stderr prematurely reaping the process $out_finished = TRUE; }, sub { ($error_message) = @_; $error_flag = TRUE; } ); _add_watch( $error, sub { my ($line) = @_; $stderr .= $line; if ( defined $options{err_callback} ) { $options{err_callback}->($line); } }, sub { # Don't flag this until after the callback to avoid the race condition # where stderr is truncated by stdout prematurely reaping the process $err_finished = TRUE; }, sub { ($error_message) = @_; $error_flag = TRUE; } ); # Watch for the process to hang up before running the finished callback Glib::Child->watch_add( $pid, sub { # Although the process has hung up, we may still have output to read, # so wait until the _watch_add flags that the process has ended first. my $timer = Glib::Timeout->add( $_POLL_INTERVAL, sub { if ($error_flag) { if ( defined $options{error_callback} ) { $options{error_callback}->($error_message); } return Glib::SOURCE_REMOVE; } elsif ( $out_finished and $err_finished ) { if ( defined $options{finished_callback} ) { $options{finished_callback}->( $stdout, $stderr ); } waitpid $ALL_PENDING_ZOMBIE_PROCESSES, WNOHANG ); return Glib::SOURCE_REMOVE; } return Glib::SOURCE_CONTINUE; } ); } ); return; } sub _add_watch { my ( $fh, $line_callback, $finished_callback, $error_callback ) = @_; my $line; Glib::IO->add_watch( fileno($fh), [ 'in', 'hup' ], sub { my ( $fileno, $condition ) = @_; my $buffer; if ( $condition & 'in' ) { # bit field operation. >= would also work # Only reading one buffer, rather than until sysread gives EOF # because things seem to be strange for stderr sysread $fh, $buffer, $_1KB; if ($buffer) { $line .= $buffer } while ( $line =~ /([\r\n])/xsm ) { my $le = $1; if ( defined $line_callback ) { $line_callback->( substr $line, 0, index( $line, $le ) + 1
Re: Signals MacOS
On 2 April 2015 at 01:17, Brian Manning c...@xaoc.org wrote: Maybe select/IO::Select on your file descriptors then, to see if you get the same behavior? Thanks for the tip, but my reading of select/IO::Select is that they always block, whereas the nice thing about Glib::IO-add_watch() is that it sets up a callback. To use a blocking watch in a GUI, I would have to put it in a thread, and presumably the only way of then killing the blocking watch would be to kill the thread. Is no one using Glib::IO-add_watch() on a Mac? Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Signals MacOS
On 31 March 2015 at 22:56, Brian Manning c...@xaoc.org wrote: Macs I have, but spare time right now... not so much. I know the problem. One suggestion would be to replace the Glib::IO-add_watch with a normal Perl signal handler (via %SIG), or another Perl module that can handle signals, and see if you still run into same problem. Thanks for the help. Maybe I'm being dull, but I don't see how to do that. Glib::IO-add_watch() looks for events (GIO::Conditions) on a file descriptor, not signals in the normal sense. Or am I missing something? Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Signals MacOS
Does nobody have a Mac? Or at least a little insight? Regards Jeff On 13 March 2015 at 22:41, Jeffrey Ratcliffe jeffrey.ratcli...@gmail.com wrote: Now, at last with a small working example. The following code works fine on Linux, but on MacOS: a. the gui does not seem to respond to the hup signal from the subprocess b. gets far more in signals than it should Unfortunately, the above description is secondhand, as I do not have access to a Mac. I would be very glad if somebody could give me a clue how to get things working under both operating systems. Regards Jeff #!/usr/bin/perl use warnings; use strict; use Gtk2 -init; use Glib qw(TRUE FALSE);# To get TRUE and FALSE use POSIX qw(locale_h :signal_h :errno_h :sys_wait_h); use IPC::Open3; use IO::Handle; use Readonly; Readonly my $_POLL_INTERVAL = 100;# ms Readonly my $_1KB = 1024; my $EMPTY = q{}; # Create the windows my $window = Gtk2::Window-new('toplevel'); my $box = Gtk2::VBox-new; my $entry = Gtk2::Entry-new; my $pbar= Gtk2::ProgressBar-new; my $qbutton = Gtk2::Button-new('Quit'); my $sbutton = Gtk2::Button-new('Start'); $window-add($box); $box-add($pbar); $box-add($qbutton); $box-add($sbutton); # We should also link this to the destroy message on the main window, # this is just quick and dirty $qbutton-signal_connect( clicked = sub { Gtk2-main_quit } ); $sbutton-signal_connect( clicked = \start_process ); $window-show_all; Gtk2-main; sub start_process { watch_cmd( cmd = 'for i in `seq 1 5`; do echo $i; sleep 1; done', running_callback = sub { $pbar-pulse; }, started_callback = sub { $pbar-set_text('Started'); }, out_callback = sub { my ($line) = @_; $pbar-set_text($line); }, err_callback = sub { my ($line) = @_; $pbar-set_text(Error: $line); }, finished_callback = sub { $pbar-set_text('Finished'); }, ); return; } sub watch_cmd { my (%options) = @_; my $out_finished = FALSE; my $err_finished = FALSE; my $error_flag = FALSE; print $options{cmd}\n; if ( defined $options{running_callback} ) { my $timer = Glib::Timeout-add( $_POLL_INTERVAL, sub { $options{running_callback}-(); return Glib::SOURCE_REMOVE if ( $out_finished or $err_finished ); return Glib::SOURCE_CONTINUE; } ); } my ( $write, $read ); my $error = IO::Handle-new; my $pid = IPC::Open3::open3( $write, $read, $error, $options{cmd} ); print Forked PID $pid\n; if ( defined $options{started_callback} ) { $options{started_callback}-() } my ( $stdout, $stderr, $error_message ); add_watch( $read, sub { my ($line) = @_; $stdout .= $line; if ( defined $options{out_callback} ) { $options{out_callback}-($line); } }, sub { # Don't flag this until after the callback to avoid the race condition # where stdout is truncated by stderr prematurely reaping the process $out_finished = TRUE; }, sub { ($error_message) = @_; $error_flag = TRUE; } ); add_watch( $error, sub { my ($line) = @_; $stderr .= $line; if ( defined $options{err_callback} ) { $options{err_callback}-($line); } }, sub { # Don't flag this until after the callback to avoid the race condition # where stderr is truncated by stdout prematurely reaping the process $err_finished = TRUE; }, sub { ($error_message) = @_; $error_flag = TRUE; } ); # Watch for the process to hang up before running the finished callback Glib::Child-watch_add( $pid, sub { # Although the process has hung up, we may still have output to read, # so wait until the _watch_add flags that the process has ended first. my $timer = Glib::Timeout-add( $_POLL_INTERVAL, sub { if ($error_flag) { if ( defined $options{error_callback} ) { $options{error_callback}-($error_message); } return Glib::SOURCE_REMOVE; } elsif ( $out_finished and $err_finished ) { if ( defined $options{finished_callback} ) { $options{finished_callback}-( $stdout, $stderr
Signals MacOS
Now, at last with a small working example. The following code works fine on Linux, but on MacOS: a. the gui does not seem to respond to the hup signal from the subprocess b. gets far more in signals than it should Unfortunately, the above description is secondhand, as I do not have access to a Mac. I would be very glad if somebody could give me a clue how to get things working under both operating systems. Regards Jeff #!/usr/bin/perl use warnings; use strict; use Gtk2 -init; use Glib qw(TRUE FALSE);# To get TRUE and FALSE use POSIX qw(locale_h :signal_h :errno_h :sys_wait_h); use IPC::Open3; use IO::Handle; use Readonly; Readonly my $_POLL_INTERVAL = 100;# ms Readonly my $_1KB = 1024; my $EMPTY = q{}; # Create the windows my $window = Gtk2::Window-new('toplevel'); my $box = Gtk2::VBox-new; my $entry = Gtk2::Entry-new; my $pbar= Gtk2::ProgressBar-new; my $qbutton = Gtk2::Button-new('Quit'); my $sbutton = Gtk2::Button-new('Start'); $window-add($box); $box-add($pbar); $box-add($qbutton); $box-add($sbutton); # We should also link this to the destroy message on the main window, # this is just quick and dirty $qbutton-signal_connect( clicked = sub { Gtk2-main_quit } ); $sbutton-signal_connect( clicked = \start_process ); $window-show_all; Gtk2-main; sub start_process { watch_cmd( cmd = 'for i in `seq 1 5`; do echo $i; sleep 1; done', running_callback = sub { $pbar-pulse; }, started_callback = sub { $pbar-set_text('Started'); }, out_callback = sub { my ($line) = @_; $pbar-set_text($line); }, err_callback = sub { my ($line) = @_; $pbar-set_text(Error: $line); }, finished_callback = sub { $pbar-set_text('Finished'); }, ); return; } sub watch_cmd { my (%options) = @_; my $out_finished = FALSE; my $err_finished = FALSE; my $error_flag = FALSE; print $options{cmd}\n; if ( defined $options{running_callback} ) { my $timer = Glib::Timeout-add( $_POLL_INTERVAL, sub { $options{running_callback}-(); return Glib::SOURCE_REMOVE if ( $out_finished or $err_finished ); return Glib::SOURCE_CONTINUE; } ); } my ( $write, $read ); my $error = IO::Handle-new; my $pid = IPC::Open3::open3( $write, $read, $error, $options{cmd} ); print Forked PID $pid\n; if ( defined $options{started_callback} ) { $options{started_callback}-() } my ( $stdout, $stderr, $error_message ); add_watch( $read, sub { my ($line) = @_; $stdout .= $line; if ( defined $options{out_callback} ) { $options{out_callback}-($line); } }, sub { # Don't flag this until after the callback to avoid the race condition # where stdout is truncated by stderr prematurely reaping the process $out_finished = TRUE; }, sub { ($error_message) = @_; $error_flag = TRUE; } ); add_watch( $error, sub { my ($line) = @_; $stderr .= $line; if ( defined $options{err_callback} ) { $options{err_callback}-($line); } }, sub { # Don't flag this until after the callback to avoid the race condition # where stderr is truncated by stdout prematurely reaping the process $err_finished = TRUE; }, sub { ($error_message) = @_; $error_flag = TRUE; } ); # Watch for the process to hang up before running the finished callback Glib::Child-watch_add( $pid, sub { # Although the process has hung up, we may still have output to read, # so wait until the _watch_add flags that the process has ended first. my $timer = Glib::Timeout-add( $_POLL_INTERVAL, sub { if ($error_flag) { if ( defined $options{error_callback} ) { $options{error_callback}-($error_message); } return Glib::SOURCE_REMOVE; } elsif ( $out_finished and $err_finished ) { if ( defined $options{finished_callback} ) { $options{finished_callback}-( $stdout, $stderr ); } print Waiting to reap process\n; # -1 indicates a non-blocking wait for all pending zombie processes print 'Reaped PID ', waitpid( -1,## no critic (ProhibitMagicNumbers) WNOHANG
Signals MacOS
I've got code with Glib::IO-add_watch() to watch for in or hup signals in a pipe that has always worked fine on Linux. A colleague of mine tried it on his MacOS box - and the hup is never caught. Indeed, in seem to be thrown a great deal, even when there is nothing to read. Is there a known list of issues that have to be handled differently under MacOS? I've no access to MacOS, so debugging is hard. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: open/fork from a callback hang the windows (gtk2::helper)
On 15 January 2015 at 07:21, Prunk Dump prunkd...@gmail.com wrote: On all gtk2::helper examples I've found, the open call is made before Gtk2-main. How can I do if the windows is already displayed and if I'm inside gtkmain ? I use Glib::Timeout() to update the progress bar. I start the subprocess with IPC::Open3::open3(), and Glib::IO-add_watch() to monitor the output. You can see the gory details in https://sourceforge.net/p/gscan2pdf/code/ci/master/tree/lib/Gscan2pdf/Frontend/CLI.pm Search for _watch_cmd Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Fwd: GLib-GObject-WARNING **: Attempt to add property after class was initialised
Users are reporting GLib-GObject-WARNING **: Attempt to add property after class was initialised[1]. As there are also Glib-Perl builds with the same warning[2], I assume that this is an issue with the Glib bindings. Does anyone have any insight? [1] https://bugzilla.redhat.com/show_bug.cgi?id=1033565 [2] http://vlcore.vectorlinux.com/buildbot/builders/perl-glib/builds/0/steps/64-bit%20build/logs/stdio/text Regards, Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list
More adventures with subclassing
It seems that in subclassed a widget, any properties assigned in -new() are not available in INIT_INSTANCE. Therefore, if I want to use values passed in -new() during the construction of the widget, I must override new(). How? Regards, Jeff window_subclass.pl Description: Binary data ___ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Subclassing Gtk2::Window
It seems a little better for me to $widget-destroy in the delete instead of chaining up, but I'm still suffering under glib chaining not Yup. I'd be doubtful about the destroy handler not destroying. Is it enough for the property to control delete-event behaviour, and leave the destroy alone? You're right. I don't know what I was thinking. Cargo cult programming again - I started like that at the beginning of time and have never questioned it since. Thanks Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Subclassing Gtk2::Window
I'm trying to subclass Gtk2::Window with a property which decides whether to hide or destroy the window. Demo code is attached. Trapping the delete and destroy events to hide the window works, as does allowing destroy to destroy, but I can't get the delete event to destroy. What am I missing? Regards Jeff window_subclass.pl Description: Binary data ___ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Popup focus
On 21 April 2012 21:02, Torsten Schoenfeld kaffeeti...@gmx.de wrote: $win-get_focus() seems to work. Yes. Thanks. I had somehow convinced myself before that this wouldn't work. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Popup focus
Hi all, In the attached code, I've got two simple lists which respond to rmb clicks. In my production code, I've also got ordinary menus and keyboard accelerators, which means the paste method can be called from various places. How can I tell inside the paste method which widget (simple list) popped up the menu to paste? Regards Jeff slistrmbdemo2.pl Description: Binary data ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Goo::Canvas versus Gnome2::Canvas
On 16 February 2012 13:48, Dov Grobgeld dov.grobg...@gmail.com wrote: I also have a feeling that Goo::Canvas is still being maintained wheras the Gnome::Canvas stopped its support several years ago. I might be mistaken on this point though. When I gave the previous maintainer some patches some time ago, he politely handed the whole thing over to me and ran. So in theory - I am the maintainer - but I don't have time to spend on it - which is unfortunate, because there is more or less no documentation, and there are still methods to be wrapped. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: GUI Testing Tools
On 26 February 2011 01:44, Kevin Ryde use...@zip.com.au wrote: Not necessarily split into modules, but in functions which can be exercised without too much gui. Creating some widgets to support How do you test a function that is not in a module? Can you just use lib path/to/bin/with/function in the t/.t? Is there an advantage to not putting it an a module? ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: GUI Testing Tools
On 25 February 2011 22:06, Kevin Ryde use...@zip.com.au wrote: I haven't gone beyond calling module methods or activating Gtk2::Action or buttons etc. Getting enough state and waiting and whatnot for even that tends to be a bit tedious. I guess that is the answer - put everything that doesn't involve the GUI into module(s) and use Test::More, if necessary refactoring the GUI code to just call module methods. Thanks for the response ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Gtk3
Is there any plan for Gtk3? I assume that large portions of Gtk2 will work out of the box compiled against Gtk3. However, I understand that it will be possible to install Gtk2 and 3 in parallel, and that won't be possible with the Perl bindings unless we do some work. Comments? Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
GUI Testing Tools
I'm looking at ways of automatically testing my Gtk2-Perl app. I see that there are various GUI testing tools, like dogtail, strongwind, LDTP, etc. Has anyone tried to use these (or a different tool) for testing a Gtk2-Perl app? Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: how can I create such a element?
On 3 November 2010 16:46, Attila bardi attila.ba...@gmail.com wrote: do you know what is the name of this gtk object? I mean the box where the pictures are. It works like the notebook but looks much better:) There's probably a way of finding out that doesn't involve looking at the Firefox source, but in the mean time, Gtk2::IconView would probably do what you want. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Gtk2::PrintOperation
On 5 August 2010 23:19, Mario Kemper mario.kem...@googlemail.com wrote: This should work: Thanks for the help. This line got me one step further: Gtk2::Gdk::Cairo::Context::set_source_pixbuf( $cr, $pixbuf, 0, 0 ); Why isn't set_source_pixbuf in Cairo::Context? I was still getting a PDF where the image scaling was mostly such that it was so far off the paper that nothing was visible. I found this, though: http://www.gtkforums.com/about6520.html which works. My working callback: $op-signal_connect( draw_page = sub { my ($op, $context) = @_; my $cr = $context-get_cairo_context; # Context dimensions my $pwidth = $context-get_width; my $pheight = $context-get_height; # Image dimensions my $pixbuf = Gtk2::Gdk::Pixbuf-new_from_file( $slist-{data}[0][2] ); my $iwidth = $pixbuf-get_width; my $iheight = $pixbuf-get_height; # Scale context to fit image my $scale = $pwidth / $iwidth; $scale = $pheight / $iheight if ( $pheight / $iheight $scale ); $cr-scale( $scale, $scale ); # Set source pixbuf Gtk2::Gdk::Cairo::Context::set_source_pixbuf( $cr, $pixbuf, 0, 0 ); # Paint $cr-paint; return; } ); ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Bug#590453: libgtk2-perl: Gtk2::FileChooserDialog signal produces different response to -run()
Package: libgtk2-perl Version: 1:1.230-2 Severity: normal Under Gtk2 1.230, the attached script produces $ filechooser.pl signal returned -5 run returned ok $ filechooser.pl signal returned -6 run returned cancel depending which button is pressed. #!/usr/bin/perl -w use strict; use Gtk2 -init; my $file_chooser = Gtk2::FileChooserDialog-new( 'Open file', undef, 'open', 'gtk-cancel' = 'cancel', 'gtk-ok' = 'ok' ); $file_chooser-signal_connect( response = sub { my ( $dialog, $response ) = @_; print signal returned $response\n; } ); print run returned ,$file_chooser-run, \n; $file_chooser-destroy; exit( 0 ); ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Bug#590453: libgtk2-perl: Gtk2::FileChooserDialog signal produces different response to -run()
After some rooting around, the problem comes from Gtk2::Dialog ancestor, as demonstrated by the attached script. This looks a great deal like https://bugzilla.gnome.org/show_bug.cgi?id=549138 But I'm not sure why we suddenly seeing problem spotted 2 years ago now. And my example doesn't do any subclassing. The problem is present in 1.230, but not in 1.221. Does anyone have any insight before I fire up git-bisect? Regards Jeff dialog.pl Description: Binary data ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Gtk2::Ex::WYSIWYG
On 13 May 2010 06:57, Matthew Braid ptkp...@mdb.id.au wrote: I've 'nearly' completed a Gtk2 WYSIWYG editor widget, and in the Cool. far from perfect, but for my current requirements it fits nicely. It also contains three other 'mini' packages - one for generating html And seems to require XML::Quote. But it looks great. To make it integrate better into existing apps, it would be good to be able to place the toolbar separately from the editor widget. Also, it might be useful to be able to restrict the number of fonts. I'm thinking of writing a PDF where by default only certain fonts are available. Assuming it is at least partially ok, I'll probably put it up on CPAN too. Absolutely. Anyway, I hope someone finds this useful at some point. It is Definitely. Thanks for sharing! Some warning messages. With #!/usr/bin/perl use warnings; use strict; use lib 'Gtk2-Ex-WYSIWYG'; use Gtk2::Ex::WYSIWYG; use Gtk2 -init; my $window = Gtk2::Window - new; $window - signal_connect ( 'delete-event' = sub { Gtk2 - main_quit } ); my $main_vbox = Gtk2::VBox - new; $window - add ( $main_vbox ); my $edit = Gtk2::Ex::WYSIWYG-new(undo_stack = 0); $main_vbox - add ( $edit ); $window - show_all; Gtk2 - main; I am getting GLib-GObject-WARNING **: invalid (NULL) pointer instance at Gtk2-Ex-WYSIWYG/Gtk2/Ex/WYSIWYG.pm line 536. GLib-GObject-CRITICAL **: g_signal_connect_data: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed at Gtk2-Ex-WYSIWYG/Gtk2/Ex/WYSIWYG.pm line 536. GLib-GObject-WARNING **: invalid (NULL) pointer instance at Gtk2-Ex-WYSIWYG/Gtk2/Ex/WYSIWYG.pm line 540. GLib-GObject-CRITICAL **: g_signal_connect_data: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed at Gtk2-Ex-WYSIWYG/Gtk2/Ex/WYSIWYG.pm line 540. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: How to extend Canvas Group?
2010/4/7 Xi Yang jianding...@msn.com: Tk don't work well with threads; WxWidget don't have a canvas. So it seems GObject-derived ones or Clutter are optimum. Which one is easier to extend? As I know, WxWidget classes can be extended directly in perl without XS works, but It don't have canvas... What do you mean by extended? Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: How to extend Canvas Group?
Please keep the group in the loop. 2010/4/7 Xi Yang jianding...@msn.com: package My::Class; our @isa = qw/Gnome2::Canvas::Group/; sub myMethod {} # is that available to use GObject as hash ref directly? # as I would store something in object sub myDataAccessor { my ($self,$value) = @_; $self-{myKey} = $value; } I've never used Gnome::Canvas. Perhaps someone else can answer. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: How to extend Canvas Group?
2010/4/7 Xi Yang jianding...@msn.com: Actually, I don't know which one to use. Which one is easier to be extended? There's run-down of canvas widgets here: http://blogs.perl.org/users/su-shee/2010/01/perl-made-all-pretty.html Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: How to extend Canvas Group?
Which canvas? There are several - Goo::Canvas, Clutter... Regards Jeff signature.asc Description: Digital signature ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
X instance name
Does anyone know how to set the X instance name from Perl? There's a bug[1] open against gscan2pdf and I haven't a clue what I can do about it. Regards Jeff [1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=554023 signature.asc Description: Digital signature ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: X instance name
On Mon, Nov 30, 2009 at 12:47:37PM +0100, Mario Kemper wrote: You can use $window-set_wmclass ($wmclass_name, $wmclass_class) for this. http://gtk2-perl.sourceforge.net/doc/pod/Gtk2/Window.html#_window_set_wmclass_ But the documentation recommends to avoid this function for special reasons, see: http://library.gnome.org/devel/gtk/stable/GtkWindow.html#gtk-window-set-wmclass If you want to check the current values of a window you can use the tool 'xprop'. You have to look for WM_CLASS(STRING). I've quickly checked some of the windows gscan2pdf creates and I can't see any difference to other applications here. Thanks! Exactly the information that I was looking for and too stupid to find. Regards Jeff signature.asc Description: Digital signature ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Re: Gtk2 build error
On Aug 11, 2009 9:06pm, Torsten Schoenfeld kaffeeti...@gmx.de wrote: This seems to suggest that your pkg-config thinks you have gtk+ = 2.14 whereas your compiler sees gtk+ Not sure what is going on there - so compiling gtk+ 2.16.5 and then Gtk2 1.221. All tests pass, but: t/00.Gtk2..ok 1/44# Testing Gtk2 1.221 # Running against gtk+ 2.16.5 # Compiled against gtk+ 2.16.5 # and pango 1.22.4 t/00.Gtk2..ok t/01.GtkWindow.ok 59/114Gdk-CRITICAL **: gdk_x11_atom_to_xatom_for_display: assertion `atom != GDK_NONE' failed at t/01.GtkWindow.t line 243. Gdk-CRITICAL **: gdk_x11_atom_to_xatom_for_display: assertion `atom != GDK_NONE' failed at t/01.GtkWindow.t line 246. Gdk-CRITICAL **: gdk_x11_atom_to_xatom_for_display: assertion `atom != GDK_NONE' failed at t/01.GtkWindow.t line 273. Gdk-CRITICAL **: gdk_x11_atom_to_xatom_for_display: assertion `atom != GDK_NONE' failed at t/01.GtkWindow.t line 274. Gdk-CRITICAL **: gdk_x11_atom_to_xatom_for_display: assertion `atom != GDK_NONE' failed at t/01.GtkWindow.t line 284. Gdk-CRITICAL **: gdk_x11_atom_to_xatom_for_display: assertion `atom != GDK_NONE' failed at t/01.GtkWindow.t line 284. Gdk-CRITICAL **: gdk_x11_atom_to_xatom_for_display: assertion `atom != GDK_NONE' failed at t/01.GtkWindow.t line 285. Gdk-CRITICAL **: gdk_x11_atom_to_xatom_for_display: assertion `atom != GDK_NONE' failed at t/01.GtkWindow.t line 285. (I get this in a couple of other places, too) [...] t/GdkPixmapGdk-WARNING **: XID collision, trouble ahead at t/GdkPixmap.t line 16. t/GdkPixmapok 1/6Gdk-WARNING **: XID collision, trouble ahead at t/GdkPixmap.t line 25. Gdk-WARNING **: XID collision, trouble ahead at t/GdkPixmap.t line 40. I can't see any problems otherwise. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Gtk2 build error (was Re: Re: List Cairo Fonts)
On Aug 10, 2009 7:29pm, Torsten Schoenfeld kaffeeti...@gmx.de wrote: use Pango; Had to compile Pango, and therefore the latest Glib. Pango also wanted the latest Gtk2 for tests, but: xs/GtkToolShell.c: In function `XS_Gtk2__ToolShell_get_icon_size': xs/GtkToolShell.c:39: error: `GtkToolShell' undeclared (first use in this function) xs/GtkToolShell.c:39: error: (Each undeclared identifier is reported only once xs/GtkToolShell.c:39: error: for each function it appears in.) xs/GtkToolShell.c:39: error: `shell' undeclared (first use in this function) xs/GtkToolShell.c: In function `XS_Gtk2__ToolShell_get_orientation': xs/GtkToolShell.c:63: error: `GtkToolShell' undeclared (first use in this function) xs/GtkToolShell.c:63: error: `shell' undeclared (first use in this function) xs/GtkToolShell.c: In function `XS_Gtk2__ToolShell_get_relief_style': xs/GtkToolShell.c:87: error: `GtkToolShell' undeclared (first use in this function) xs/GtkToolShell.c:87: error: `shell' undeclared (first use in this function) xs/GtkToolShell.c: In function `XS_Gtk2__ToolShell_get_style': xs/GtkToolShell.c:111: error: `GtkToolShell' undeclared (first use in this function) xs/GtkToolShell.c:111: error: `shell' undeclared (first use in this function) xs/GtkToolShell.c: In function `XS_Gtk2__ToolShell_rebuild_menu': xs/GtkToolShell.c:134: error: `GtkToolShell' undeclared (first use in this function) xs/GtkToolShell.c:134: error: `shell' undeclared (first use in this function) make: *** [xs/GtkToolShell.o] Error 1 I assume that Gtk2 needs a newer version of GTK+, and therefore the dependencies are wrong. I'll investigate further later... Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Re: List Cairo Fonts
On Aug 10, 2009 7:29pm, Torsten Schoenfeld kaffeeti...@gmx.de wrote: I think this is best done with Pango: • fetch the system's font map with Pango::Cairo::FontMap-get_default; • call list_families() on the result; • call list_faces() on each of the families; • call get_face_name() and list_sizes() on each of the faces. Excellent. Thanks. Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
List Cairo Fonts
There are some OCR libraries that give box output, indicating the position and size of the recognised text - but no font information. gscan2pdf embeds the OCR output behind the scanned image to allow the PDFs to be searched and the OCR output highlighted and copied through the scan. However, it is tricky to pick the correct size/font combination to match the box information that the OCR library returns. To aid this, is there a way of retrieving the font/size combinations available? Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Re: Re: Strange interaction between Gtk2::Dialog and signal from Goo::Canvas
On Jul 20, 2009 2:15pm, Mario Kemper mario.kem...@googlemail.com wrote: In both your and my examples, I can only get the first Goo::Canvas::Text created to emit a pressed signal. Really? Did you add the 'pointer_ungrab' call to your code? Yup. With the ungrab call, your code only emits a signal for the text 0 - clicks on the other text is ignored. If I put the text in groups, then it works as expected. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Re: Re: Re: Strange interaction between Gtk2::Dialog and signal from Goo::Canvas
On Jul 20, 2009 2:40pm, Mario Kemper mario.kem...@googlemail.com wrote: Yup. With the ungrab call, your code only emits a signal for the text 0 - clicks on the other text is ignored. If I put the text in groups, then it works as expected. No apologies. Yours also works as expected. If I remove height = $y2-$y1 from the Goo::Canvas::Text-new() call in mine, mine does too, or as I said before, if I put it in a group. Strange. I'll try and find some time to rewrite the examples in C ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Maximize Glade window while loading....
On Jul 13, 2009 11:01am, Sreejith S srssreej...@gmail.com wrote: Is there any possibility to maximize the glade window when we run the window.??So the glade window can fit in the screen.. How about $window - maximize ? Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: About Treeview update with thread
2009/5/13 Emmanuel Rodriguez emmanuel.rodrig...@gmail.com: From what I understood perl has a lot of troubles with threads and objects (blessed references). I recall when threads where first available in Perl that sharing blessed references will loose the blessing. The data is passed intact to the other thread but the blessing is lost, this makes calling methods on objects useless. I'm not sure if this is the issue with your program but your should keep it in mind. I have been using the module forks for a while now with success - the threads API, but using fork(), and therefore by definition everything is thread-safe. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Re: Goo::Canvas
On May 12, 2009 10:02am, Torsten Schoenfeld kaffeeti...@gmx.de wrote: Well, what do you mean by to group maintain? Currently, I'm the only one maintaining the modules commonly referred to as gtk2-perl. And due to various reasons, I haven't been able to tend to all the things that need doing lately. So I don't want to take over another module. I can understand that. I am in the same position. But if you want to just put Goo::Canvas under the gtk2-perl umbrella by hosting it where all the other modules are hosted, that's fine with me. For that, you'd have to request a GNOME account: http://live.gnome.org/NewAccounts. (For some reason, the Perl modules still don't show up in the list of vouchers, but you can add a comment about this and then select gnome-perl-introspection as the voucher. This way, the request still reaches me.) OK. I'll do this. ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Goo::Canvas
2009/5/7 jeffrey.ratcli...@gmail.com: I was playing around with Goo::Canvas yesterday, noticed there were a couple of methods missing, for which I worked up patches and sent them to the author, Ye Wenbin. He asked me if I would like to take over the bindings. I see that now the C API is somehow part of GTK (http://live.gnome.org/GooCanvas), it would make sense if Goo::Canvas were maintained by gtk2-perl. Does nobody else think that it would be a good idea for gtk2-perl to group maintain Goo::Canvas? It is currently hosted at http://code.google.com/p/libgoo-canvas-perl/. The docs could do with some work, and I don't know what other methods are missing. That SVN repo has more or less one commit of v0.06 = v0.05 + the patches I sent him. I was thinking about taking it over on my own, but I'd really rather share the load. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Re: Glib::Object and Storable
On May 7, 2009 2:21pm, Dave Howorth dhowo...@mrc-lmb.cam.ac.uk wrote: Emmanuele Bassi wrote: unless you can override the deserialization sequence in order to create an underlying C instance first, otherwise no. Thanks for confirming that. http://search.cpan.org/~ams/Storable-2.18/Storable.pm#Hooks ?? Maybe that would be possible, but not at my level of knowledge. Thanks for pointing it out. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Re: Re: Glib::Object and Storable
On May 8, 2009 11:52am, Sergei Steshenko sergst...@yahoo.com wrote: When I needed to store the state of my GUI, I wrote a routines which upon encountering widgets converted them into their properties, for example: Doing that in a generic way is a bright idea (I ended up doing a tiny subset of it in a similar manner), but rather hard to do properly, keeping the references between widgets correct, etc., especially as not all Glib::Objects have a straight new() method. Nevertheless, done well, it would be worth a module on CPAN, and I would use it. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Auto-complete text entry widget?
On May 7, 2009 9:32am, Grant McLean gr...@mclean.net.nz wrote: Is there a Gtk widget that augments a text entry with an auto-completed list of possible alternatives - similar to Ajax widgets that all the best web apps have? Check out Gtk2::EntryCompletion Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Goo::Canvas
I was playing around with Goo::Canvas yesterday, noticed there were a couple of methods missing, for which I worked up patches and sent them to the author, Ye Wenbin. He asked me if I would like to take over the bindings. I see that now the C API is somehow part of GTK (http://live.gnome.org/GooCanvas), it would make sense if Goo::Canvas were maintained by gtk2-perl. It is currently hosted at http://code.google.com/p/libgoo-canvas-perl/. The docs could do with some work, and I don't know what other methods are missing. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Segfault in Gtk2::Ex::Simple::List 0.50
In the following code, pushing a 0 instead of a Pixbuf provokes a segfault, but strangely, not in the debugger. Regards Jeff #!/usr/bin/perl use warnings; use strict; use Gtk2 -init; use Gtk2::Ex::Simple::List; my $win = Gtk2::Window-new; $win-signal_connect (delete_event = sub { Gtk2-main_quit; }); my $vbox = Gtk2::VBox-new; $win-add ($vbox); my $slist = Gtk2::Ex::Simple::List-new ( 'Int' = 'int', 'Pixbuf' = 'pixbuf' ); $vbox-add ($slist); my $button = Gtk2::Button-new ( 'Add' ); $vbox-add ($button); $button - signal_connect(clicked = sub { push @{$slist-{data}}, [ 1, 0 ] }); $win-show_all; Gtk2-main; ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: gktimageview on windows
2009/3/13 Jamie Lahowetz jlahow...@gmail.com: How can I gt this on windows so that I can install Gtk2::Imageview? What is the sticking point - that you can't get the c library gtkimageview to compile under windows? Then you'd be better of asking the author of the c library, Björn Lindqvist bjourne ( at ) gmail.com If the c library works, but you can't get the Perl bindings going, please post the error message, but I can't promise to help, as I am not running windows. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Re-sampling a 32 bit geotif
2009/3/7 Jamie Lahowetz deadpic...@gmail.com: I am trying to display a geotif using Gtk2::Gdk::Pixbuf but the geotif is 32 bits and only a 24 bit image can be read in. I want to know if there is a way to resample the geotif so that it can be loaded into my Perl program. I imagine Imagemagick is your friend... Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Re: Gtk2::ImageView memory issue
I wonder if the return for gtk_image_tool_selector_new() in the .xs should be SVGtkIImageTool_noinc, if that func gives you a ref to take over. Seems to make it work for me ... Fixed it for me too. Thanks for the patch. I'll get a new release out. Yes. Constructors and other functions returning new instances of direct GObject descendants need to use the _noinc typemaps to assume ownership. This is not necessary for GtkObject descendants. The same applies to Gtk2::ImageView::Tool::Dragger and Gtk2::ImageView::Tool::Painter. Presumably this is also the case for Glib::Boxed (Gtk2::Gdk::Pixbuf::Draw::Cache), although as the library supplies gdk_pixbuf_draw_cache_free, I should create a DESTROY method which calls this instead. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Re: Re: Gtk2::ImageView memory issue
On Mar 6, 2009 10:29am, jeffrey.ratcli...@gmail.com wrote: Presumably this is also the case for Glib::Boxed (Gtk2::Gdk::Pixbuf::Draw::Cache), although as the library supplies gdk_pixbuf_draw_cache_free, I should create a DESTROY method which calls this instead. Hmm... Can't do this, as Gtk2::Gdk::Pixbuf::Draw::Cache is not an object. So - how do I bless Gtk2::Gdk::Pixbuf::Draw::Cache when the C library thinks it is GBoxed? Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Gtk2::ImageView memory issue
2009/3/6 Torsten Schoenfeld kaffeeti...@gmx.de: GBoxed descendants have their own memory management infrastructure and thus also their own typemap variants: for functions returning newly constructed instances of GBoxed descendants, use the _own typemap variant. Then, I've had to write code to convert the GBox struct to a hash and back again - e.g. static SV * newSVGdkPixbufDrawCache (GdkPixbufDrawCache * cache) { HV * hv = newHV(); hv_store (hv, last_pixbuf, 11, newSVGdkPixbuf (cache-last_pixbuf), 0); hv_store (hv, old, 3, newSVGdkPixbufDrawOpts (cache-old), 0); hv_store (hv, check_size, 10, newSViv (cache-check_size), 0); return newRV_noinc ((SV *) hv); } Is the _own variant useful here? Glib::Boxed::DESTROY will call the free function registered for the GBoxed descendant. (Perl packages representing GBoxed descendants are automatically set up to inherit from Glib::Boxed.) So I should set up the type to call the _free method as follows: GType gdk_pixbuf_draw_cache_get_type(void) { static GType t = 0; if (!t) { t = g_boxed_type_register_static(GdkPixbufDrawCache, (GBoxedCopyFunc) g_boxed_copy, (GBoxedFreeFunc) gdk_pixbuf_draw_cache_free); } return t; } ? How can I test that the _free method is being called? Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Gtk2::ImageView memory issue
2009/3/5 Jeffrey Ratcliffe jeffrey.ratcli...@gmail.com: As a first thought, the DESTROY method should simple contain a call to g_object_unref. Having said that, as Gtk2::ImageView::Tool::Selector is a Glib::Object, why doesn't it inherit the Glib::Object DESTROY method, which would call g_object_unref? Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: updating gui while running a subroutine
2009/1/30 Daniel Gaston daniel.gas...@gmail.com: Is there something special I need to do with the piped open/fork to have it work for a subroutine within the same program code? Below is what I have been doing - the forked code is here sub {sleep 10}. Regards Jeff #!/usr/bin/perl use warnings; use strict; use Gtk2 -init; use Glib qw(TRUE FALSE); # To get TRUE and FALSE use POSIX; my $window = Gtk2::Window-new; $window - signal_connect (delete_event = \quit); my $pbar = Gtk2::ProgressBar-new; $pbar - set_pulse_step(.1); $window - add($pbar); my %helperTag; $SIG{CHLD} = \sig_child; my $pid = start_process(sub {sleep 10}); Glib::Timeout-add (100, sub { if (defined $helperTag{$pid}) { $pbar-pulse; return TRUE; } else { return FALSE; } }); $window-show_all; Gtk2-main; # Process the exit of the child. If you were doing something useful, # you might keep things like information about what data needs # to be reloaded when a child process exits. sub sig_child { my $pid = wait; if ($pid = 0) { warn(process $pid finished\n); delete $helperTag{$pid}; } } sub start_process { my ( $process ) = @_; my $pid = fork(); if ($pid) { # We're still in the parent; note pid $helperTag{$pid} = $pid; warn(Started process $pid\n); return $pid; } else { # We're in the child. Do whatever processes we need to. We *must* # exit this process with POSIX::_exit(...), because exit() would # clean up open file handles, including our display connection, # and merely returning from this subroutine in a separate process # would *really* confuse things. $process-(); POSIX::_exit(0); } } # We should clean up after ourselves so that we don't # leave dead processes flying around. sub quit { # 15 = SIGTERM kill 15, $_ foreach (keys %helperTag); Gtk2-main_quit; } ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Failure to load some SVG files
I have just recompiled GTK, etc., and for *some* SVG icons I now get Couldn't recognise the image file format for file... errors. Other SVGs still work fine. rsvg-view still views the problem SVGs with no error. What can I do to fix the problem? Please CC me on replies as I am not subscribed. Regards Jeff ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Forks
Searching for a simple method of running separate processes without ignoring muppet's constant advice not to use threads, I stumbled upon forks[1] (a drop-in replacement to threads using forks, including shared variables), which seems an excellent solution. What makes me suspicious, however, is that a 6-year-old module does not seem to have been packaged by Debian or Fedora, although Mandriva seems to have one[2]. Does anyone have any experience of this module? Regards Jeff [1] http://search.cpan.org/~rybskej/forks/lib/forks.pm [2] http://rpmfind.net/linux/rpm2html/search.php?query=perl-forks ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Gtk2::SpinButton with blank value
2008/11/14 muppet [EMAIL PROTECTED]: Looks like Tadej's suggestion of the output signal may pay off. Thanks Tadej, thanks muppet. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Gtk2::SpinButton with blank value
2008/11/13 muppet [EMAIL PROTECTED]: The obvious question is, why do you want to do this? What are these certain situations? Maybe there's another solution that doesn't involve hackery here... In gscan2pdf, I am adding a dialog to change the resolution/page size of one or more images. Select one image, the SpinButton gives you the current resolution and invites you to change it. Select two or more images with the same resolution, same UI. Select two or more images with different current resolutions, and I'd like to have that greyed look, (not ghosted-out), indicating that as there are two or more values, they can't be shown in one widget, but the widget can still change all values to whatever the user enters. That greyed look I have no clue how to do, and at the moment, I have a Gtk2::Entry which only accepts digits (but can also crucially be set to ), but a SpinButton seems a better choice. Still with me? Thanks for any help Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Gtk2::SpinButton with blank value
I'd like to set a Gtk2::SpinButton to a blank value in certain situations. set_value() complains that isn't numeric, but Gtk2::SpinButton inherits from Gtk2::Entry, so set_text() should work, but is simply ignored (or possibly set, and updated to the nearest numeric value, as happens when entering a blank value manually and hitting return). Is it doable? #!/usr/bin/perl use warnings; use strict; use Gtk2 -init; use Glib qw(TRUE FALSE); # To get TRUE and FALSE my $window = Gtk2::Window - new; $window - signal_connect (destroy = sub { Gtk2 - main_quit } ); my $vbox = Gtk2::VBox - new; $window - add ($vbox); my $spinbutton = Gtk2::SpinButton - new_with_range(1, , 1); $spinbutton-set_numeric (FALSE); $spinbutton-set_text(''); $vbox - add($spinbutton); $window - show_all; Gtk2 - main; Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: threads and trayicon error
2008/9/29 anguila [EMAIL PROTECTED]: I'm writing a code that check if there is any news my universiti website. Why don't you use Specto? http://specto.sourceforge.net Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Another question about foreach loops and gtk
2008/6/24 Mike Martin [EMAIL PROTECTED]: I have a long-running foreach loop which I want to give feedback through the GUI The GUI is only updated in idle cycles on the main loop. Therefore, you should consider doing things in idle cycles (see Glib::Idle), or use Gtk2-main_iteration() while (Gtk2-events_pending); Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Dragging a Canvas::Line with the mouse?
2008/6/19 walt [EMAIL PROTECTED]: The only graphics trick I know is to draw the line by XOR'ing it with the canvas and again a second time to erase it. (That's to avoid redrawing the whole screen with every move of the cursor.) Is there a way to do that with gtk-perl? google is your friend here: xor site:http://mail.gnome.org/archives/gtk-perl-list/ gives you this thread: http://mail.gnome.org/archives/gtk-perl-list/2007-November/msg00049.html Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: geoTiff Application
2008/6/2 Jamie Lahowetz [EMAIL PROTECTED]: I am writing a simple Gtk2 application that loads a geotiff and allows the user to add and remove waypoints. So far the user can add a waypoint by double clicking and is able to drag the window to navigate. I would like to see if anyone can help me with adding some of the other features. 1. ZOOMING. I added a zooming feature to the map but when you zoom in or out and try to add a waypoint, the circle is far off from where the user clicked. Can anyone give examples on how to fix this? (thanks to zentara for the help) I very much recommend the use of Gtk2::ImageView (http://trac.bjourne.webfactional.com/) as an image viewing widget, which will sort out all the zooming, panning, selecting for you. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Pango perl bindings
On 26/03/2008, Torsten Schoenfeld [EMAIL PROTECTED] wrote: Yes, I think it does make sense to be able to use pango independently of Gtk2. The question is how to do the separation in a backwards-compatible way. Why try to be truly backwards-compatible? Why not simply deprecate Gtk2::Pango, but don't remove it for the time being. Make Gtk2 depend on Pango, as you say. Do all maintenance in Pango only, and after Pango usage has become widespread, remove Gtk2::Pango. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Announce: X11::Aosd 0.02
On 16/03/2008, Jörn Reder [EMAIL PROTECTED] wrote: I just added one to the website: http://www.exit1.org/img/X11-Aosd-Screen-1.png Thanks! For more details about libaosd refer to: http://www.atheme.org/projects/libaosd.shtml I looked there, but there isn't much info. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: CPAN Testing
On 28/02/2008, Jeffrey Ratcliffe [EMAIL PROTECTED] wrote: So if I understand you correctly, until Glib::MakeHelper::get_configure_requires_yaml hits a stable release, the best I can do is WriteMakefile with NO_META = 1, and write the META.yml manually with the appropriate configure_requires: entry? I really shouldn't write anything until I let the coffee sink in. Anyway - might I suggest use ExtUtils::MakeMaker 6.31; as that was the first version with EXTRA_META support. Either that, or a construct like: my @extra = $ExtUtils::MakeMaker::VERSION 6.30 ? qw(EXTRA_META $configure_requires) : (); WriteMakefile( [...] @extra, ); LICENSE and AUTHOR also set fields in META.yaml - perhaps it might be useful to fill them too, although you'll need the same sort of construct for the LICENSE field for EU::MM 6.031. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: CPAN Testing
So if I understand you correctly, until Glib::MakeHelper::get_configure_requires_yaml hits a stable release, the best I can do is WriteMakefile with NO_META = 1, and write the META.yml manually with the appropriate configure_requires: entry? Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Gtk2::FileChooser default sort
Is there any way of influencing the default sort of a Gtk2::FileChooser? I would like to be able to remember what sort the user previously used - I find myself every time switching from the default ascending sort on filename to a descending sort on date. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
CPAN Testing
I uploaded Gtk2::ImageView to CPAN and see that it is failing tests due to missing dependencies, and that Gtk2-Perl is doing the same thing. Is there some reason that Gtk2-Perl hasn't been set up to ignore failures like this? Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Can't locate Gtk2/Window.pm in @INC
On 25/02/2008, Open Source [EMAIL PROTECTED] wrote: I am running the program typing Perl and name of the program at the console. You could make the program executable, and just run it directly. Can't locate Gtk2/Window.pm in @INC (@INC contains: Looks to me as though you haven't installed Gtk2-Perl. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: drawing on an image, colour manipulation
On 18/02/2008, Johan Aberg [EMAIL PROTECTED] wrote: I'd like to draw a simple rectangle over a Gtk2::Image. What would be the best way of doing this. There are a few options, canvas, drawable, composit etc. Ideally, this rectangle would trace position of the mouse in realtime. Have you seen http://mail.gnome.org/archives/gtk-perl-list/2007-November/msg00054.html ? Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: two-way communication with a forked process
On 14/02/2008, Jeffrey Ratcliffe [EMAIL PROTECTED] wrote: What I don't understand is that if I comment out the (debugging) print statement, then it doesn't work. I had my sockets in a knot. This works. Sorry for the noise. Jeff #!/usr/bin/perl use warnings; use strict; use Socket; use Gtk2 -init; use Glib qw(TRUE FALSE); # To get TRUE and FALSE use FileHandle; use POSIX; # Create the windows my $window = Gtk2::Window-new('toplevel'); my $box = Gtk2::VBox-new; my $entry = Gtk2::Entry-new; my $pbar = Gtk2::ProgressBar-new; my $button = Gtk2::Button-new('Quit'); my ($child, $parent); start_process(); $window-add ($box); $box-add($entry); $box-add($pbar); $box-add($button); my %helperTag; # We should also link this to the destroy message on the main window, # this is just quick and dirty $button-signal_connect(clicked = \on_quit_clicked); $entry-signal_connect(activate = sub {send($parent, $entry-get_text, 0)}); $window-show_all; Gtk2-main; # Process the exit of the child. If you were doing something useful, # you might keep things like information about what data needs # to be reloaded when a child process exits. sub sig_child { my $pid = wait; if ($pid = 0) { delete $helperTag{$pid}; } } $SIG{CHLD} = \sig_child; sub start_process { my $pid; $child = FileHandle-new; $parent = FileHandle-new; socketpair($child, $parent, AF_UNIX, SOCK_DGRAM, PF_UNSPEC); binmode $child, ':utf8'; binmode $parent, ':utf8'; $pid = fork(); if ($pid) { # We're still in the parent, set up to watch the streams: my $line; $helperTag{$pid} = Glib::IO-add_watch($parent-fileno(), ['in', 'hup'], sub { my ($fileno, $condition) = @_; if ($condition 'in') { # bit field operation. = would also work recv($parent, $line, 1000, 0); if (defined($line) and $line =~ /(\d*\.?\d*)(.*)/) { my $fraction=$1; my $text=$2; $pbar-set_fraction($fraction); $pbar-set_text($text); } } # Can't have elsif here because of the possibility that both in and hup are set. # Only allow the hup if sure an empty buffer has been read. if (($condition 'hup') and (! defined($line) or $line eq '')) { # bit field operation. = would also work return FALSE; # uninstall } return TRUE; # continue without uninstalling }); } else { # We're in the child. Do whatever processes we need to. We *must* # exit this process with POSIX::_exit(...), because exit() would # clean up open file handles, including our display connection, # and merely returning from this subroutine in a separate process # would *really* confuse things. $pid = getpid(); # Now block until the GUI passes a message while (TRUE) { my $rin = ''; my $rout = ''; vec($rin, $child-fileno(), 1) = 1; my $line; if (select($rout=$rin,undef,undef,undef)) { recv($child, $line, 1000, 0); } POSIX::_exit(0) if ($line eq '-1'); my $n = 4; for (my $i = 0; $i = $n; $i++) { sleep(1); send($child, $i/$n.Running $line $i of $n\n, 0); } } } } # We should clean up after ourselves so that we don't # leave dead processes flying around. sub on_quit_clicked { # 15 = SIGTERM kill 15, $_ foreach (keys %helperTag); Gtk2-main_quit; } ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
two-way communication with a forked process
Below is a little demo of two-way communication with a forked process. What I don't understand is that if I comment out the (debugging) print statement, then it doesn't work. Any ideas? Regards Jeff #!/usr/bin/perl use warnings; use strict; use Socket; use Gtk2 -init; use Glib qw(TRUE FALSE); # To get TRUE and FALSE use FileHandle; use POSIX; # Create the windows my $window = Gtk2::Window-new('toplevel'); my $box = Gtk2::VBox-new; my $entry = Gtk2::Entry-new; my $pbar = Gtk2::ProgressBar-new; my $button = Gtk2::Button-new('Quit'); my ($reader, $writer); start_process(); $window-add ($box); $box-add($entry); $box-add($pbar); $box-add($button); my %helperTag; # We should also link this to the destroy message on the main window, # this is just quick and dirty $button-signal_connect(clicked = \on_quit_clicked); $entry-signal_connect(activate = sub {send($writer, $entry-get_text, 0)}); $window-show_all; Gtk2-main; # Process the exit of the child. If you were doing something useful, # you might keep things like information about what data needs # to be reloaded when a child process exits. sub sig_child { my $pid = wait; if ($pid = 0) { delete $helperTag{$pid}; } } $SIG{CHLD} = \sig_child; sub start_process { my $pid; $reader = FileHandle-new; $writer = FileHandle-new; socketpair($reader, $writer, AF_UNIX, SOCK_DGRAM, PF_UNSPEC); binmode $reader, ':utf8'; binmode $writer, ':utf8'; $pid = fork(); if ($pid) { # We're still in the parent, set up to watch the streams: shutdown($writer, 0); my $line; $helperTag{$pid} = Glib::IO-add_watch($reader-fileno(), ['in', 'hup'], sub { my ($fileno, $condition) = @_; if ($condition 'in') { # bit field operation. = would also work recv($reader, $line, 1000, 0); if (defined($line) and $line =~ /(\d*\.?\d*)(.*)/) { my $fraction=$1; my $text=$2; $pbar-set_fraction($fraction); $pbar-set_text($text); } } # Can't have elsif here because of the possibility that both in and hup are set. # Only allow the hup if sure an empty buffer has been read. if (($condition 'hup') and (! defined($line) or $line eq '')) { # bit field operation. = would also work return FALSE; # uninstall } return TRUE; # continue without uninstalling }); } else { # We're in the child. Do whatever processes we need to. We *must* # exit this process with POSIX::_exit(...), because exit() would # clean up open file handles, including our display connection, # and merely returning from this subroutine in a separate process # would *really* confuse things. shutdown($reader, 1); $pid = getpid(); # Now block until the GUI passes a message while (TRUE) { my $rin = ''; my $rout = ''; vec($rin, $reader-fileno(), 1) = 1; my $line; if (select($rout=$rin,undef,undef,undef)) { recv($reader, $line, 1000, 0); } POSIX::_exit(0) if ($line eq '-1'); my $n = 4; for (my $i = 0; $i = $n; $i++) { sleep(1); print Running $line $i of $n\n; send($writer, $i/$n.Running $line $i of $n\n, 0); } } } } # We should clean up after ourselves so that we don't # leave dead processes flying around. sub on_quit_clicked { # 15 = SIGTERM kill 15, $_ foreach (keys %helperTag); Gtk2-main_quit; } ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: GtkImageView
I held off releasing the Perl bindings for gtkimageview 1.5.0 because the author wanted to add the GTypes and a couple of other things. This he has done, and I have updated the bindings to match (http://trac.bjourne.webfactional.com/). There are, however, a couple of things that I don't understand: a. there is an enum (not a gobject), GdkPixbufDrawOpts, which is used in both gtkiimagetool.h and gdkpixbufdrawcache.h. I find I have to include the newSVGdkPixbufDrawOpts and SvGdkPixbufDrawOpts definitions in the bindings twice, once for each header file, to avoid errors missing the SvGdkPixbufDrawOpts symbol. What am I doing wrong? b. compiling gives me the message: GdkPixbufDrawOpts is not registered with the GLib type system. c. Gtk2::Gdk::Pixbuf::Draw::Cache::get_method segfaults at the moment if it not fed with the requisite two GdkPixbufDrawOpts. As the Perl version of GdkPixbufDrawOpts is a hash, what is the best way of checking that the hash is a Gtk2::Gdk::Pixbuf::Draw::Opts? isa doesn't work, because it is a hash, not a gobject. Should I be blessing the hash? Everything I've got up to now is committed to the svn repository on the website. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
FileChooser overwrite_confirmation
My application forces the extension of saved files, in this case, to be .pdf. Up to now, I have used my own dialog box to check if a file should be overwritten. Just, spotting that the FileChooser has set_do_overwrite_confirmation (TRUE) - and wanting to use it for consistency with other Gtk+ apps, I am having trouble with the possibility that the user types in a new filename that, without an extension, does not already exist, but with one, does. I can't seem to get FileChooser to recheck the filename. Should I be emitting a specific signal? Below is a code fragment showing where I am. Thanks for any ideas Jeff my $file_chooser = Gtk2::FileChooserDialog - new('PDF filename', $window, 'save', 'gtk-cancel' = 'cancel', 'gtk-save' = 'ok'); $file_chooser - set_default_response('ok'); $file_chooser-set_do_overwrite_confirmation (TRUE); $file_chooser - signal_connect (response = sub { my ($dialog, $response) = @_; if ($response eq 'ok') { my $filename = $file_chooser - get_filename; if ($filename !~ /\.pdf$/i) { $filename = $filename.'.pdf'; $file_chooser - set_filename($filename); $file_chooser-response ('ok'); #$file_chooser - signal_emit('file-activated'); } else { $file_chooser - destroy; [do something with file] } } }); $file_chooser - show; ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: forked process exiting before output read
Back last year, I started using datagram sockets for communication between a parent (GUI) and forked process: http://mail.gnome.org/archives/gtk-perl-list/2007-July/msg00070.html On 31/07/2007, muppet [EMAIL PROTECTED] wrote: If small lines of text are what you have, you might actually want to use datagram sockets, because you'll get guaranteed delivery of entire messages. This seems to break for utf8 messages, with: *** unhandled exception in callback: *** Wide character in send I've tried creating the filehandles with $fh = FileHandle-new(:utf8); or binmode $fh, ':utf8'; without success. Is it possible to get this working for datagrams, or am I going to have to use a different technique? Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: forked process exiting before output read
On 31/01/2008, Jeffrey Ratcliffe [EMAIL PROTECTED] wrote: This seems to break for utf8 messages, with: *** unhandled exception in callback: *** Wide character in send I've tried creating the filehandles with $fh = FileHandle-new(:utf8); or binmode $fh, ':utf8'; Here's a demo trying to send/recv a utf8 character. It crashes with: $ ../ForkDemo8.pl writing 0 of 4 *** unhandled exception in callback: *** Wide character in send at ../ForkDemo8.pl line 96. *** ignoring at ../ForkDemo8.pl line 30. Thanks for any pointers Jeff #!/usr/bin/perl use warnings; use strict; use Socket; use Gtk2 -init; use Glib qw(TRUE FALSE); # To get TRUE and FALSE use FileHandle; use POSIX; # Create the windows my $window = Gtk2::Window-new('toplevel'); my $box = Gtk2::VBox-new; my $pbar = Gtk2::ProgressBar-new; my $buttonQuit = Gtk2::Button-new('Quit'); my $buttonStart = Gtk2::Button-new('Start'); $window-add ($box); $box-add ($pbar); $box-add($buttonQuit); $box-add($buttonStart); my %helperTag; # We should also link this to the destroy message on the main window, # this is just quick and dirty $buttonQuit-signal_connect(clicked = \on_quit_clicked); $buttonStart-signal_connect(clicked = \start_process); $window-show_all; Gtk2-main; # Process the exit of the child. If you were doing something useful, # you might keep things like information about what data needs # to be reloaded when a child process exits. sub sig_child { my $pid = wait; if ($pid = 0) { delete $helperTag{$pid}; } } $SIG{CHLD} = \sig_child; sub start_process { my $pid; my ($reader, $writer); $reader = FileHandle-new(:utf8); $writer = FileHandle-new(:utf8); socketpair($reader, $writer, AF_UNIX, SOCK_DGRAM, PF_UNSPEC); $pid = fork(); if ($pid) { # We're still in the parent, set up to watch the streams: shutdown($writer, 0); my $line; $helperTag{$pid} = Glib::IO-add_watch($reader-fileno(), ['in', 'hup'], sub { my ($fileno, $condition) = @_; if ($condition 'in') { # bit field operation. = would also work recv($reader, $line, 1000, 0); if (defined($line) and $line =~ /(\d*\.?\d*)(.*)/) { my $fraction=$1; my $text=$2; $pbar-set_fraction($fraction); $pbar-set_text($text); Gtk2-main_iteration while Gtk2-events_pending; sleep(2); } } # Can't have elsif here because of the possibility that both in and hup are set. # Only allow the hup if sure an empty buffer has been read. if (($condition 'hup') and (! defined($line) or $line eq '')) { # bit field operation. = would also work return FALSE; # uninstall } return TRUE; # continue without uninstalling }); } else { # We're in the child. Do whatever processes we need to. We *must* # exit this process with POSIX::_exit(...), because exit() would # clean up open file handles, including our display connection, # and merely returning from this subroutine in a separate process # would *really* confuse things. shutdown($reader, 1); $pid = getpid(); my $n = 4; for (my $i = 0; $i = $n; $i++) { sleep(1); send($writer, $i/$n.Running \x{2013} $i of $n\n, 0); } POSIX::_exit(0); } } # We should clean up after ourselves so that we don't # leave dead processes flying around. sub on_quit_clicked { # 15 = SIGTERM kill 15, $_ foreach (keys %helperTag); Gtk2-main_quit; } ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: forked process exiting before output read
On 01/02/2008, Jeffrey Ratcliffe [EMAIL PROTECTED] wrote: Here's a demo trying to send/recv a utf8 character. It crashes with: Apologies for the noise. The solution is binmode $reader, ':utf8'; binmode $writer, ':utf8'; AFTER the socketpair call. I had previously tried putting binmode immediately after creating the filehandle. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Glib::ParamSpec-enum or boxed
Below is some demo code for composite widget. At the moment, it used Glib::ParamSpec-string for the property, but as only three values are possible, enum or boxed I assume would be better - but I can't see how to do it. Any hints? Thanks Jeff #!/usr/bin/perl package Foo::PageRange; use strict; use warnings; use Gtk2; use Glib qw(TRUE FALSE); # To get TRUE and FALSE use Glib::Object::Subclass Gtk2::Frame::, signals = { changed = {}, }, properties = [ Glib::ParamSpec-string ( 'range', # name 'Range', # nickname 'Either current, selected, or all', #blurb 'all', # default [qw/readable writable/] #flags ), ] ; sub INIT_INSTANCE { my ($self, $range) = @_; $range = 'all' if (!$range); $self-{range} = $range; my $frame = Gtk2::Frame-new; $self-add ($frame); my $vbox = Gtk2::VBox - new; # $vboxp - set_border_width($border_width); $frame - add ($vbox); #the first radio button has to set the group, #which is undef for the first button # All button my $buttona = Gtk2::RadioButton - new(undef, 'All'); $vbox - pack_start($buttona, TRUE, TRUE, 0); my @group = $buttona - get_group; # Current button my $buttonc = Gtk2::RadioButton - new(@group, 'Current'); $vbox - pack_start($buttonc, TRUE, TRUE, 0); # Selected button my $buttons = Gtk2::RadioButton - new(@group, 'Selected'); $vbox - pack_start($buttons, TRUE, TRUE, 0); # Set default if ($self-{range} eq 'current') { $buttonc - set_active(TRUE); } elsif ($self-{range} eq 'selected') { $buttons - set_active(TRUE); } else { $buttona - set_active(TRUE); } $buttona - signal_connect ('toggled' = sub { $self-set_active('all') if ($buttona - get_active); }); $buttonc - signal_connect ('toggled' = sub { $self-set_active('current') if ($buttonc - get_active); }); $buttons - signal_connect ('toggled' = sub { $self-set_active('selected') if ($buttons - get_active); }); } sub get_active { my ($self) = @_; return $self-get ('range'); } sub set_active { my ($self, $range) = @_; $self-{range} = $range; $self-signal_emit ('changed'); } package main; use strict; use warnings; use Glib qw(TRUE FALSE); # To get TRUE and FALSE use Gtk2 -init; my $window = Gtk2::Window-new; $window-set_title ('Page Range'); $window-signal_connect (delete_event = sub { Gtk2-main_quit; TRUE }); my $vbox = Gtk2::VBox-new; $window-add ($vbox); my $pr = Foo::PageRange-new; $vbox-pack_start ($pr, TRUE, TRUE, 0); $pr-signal_connect (changed = sub { warn $_[0]-get_active, \n; }); $window-show_all; Gtk2-main; ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Glib::ParamSpec-enum or boxed
On 23/01/2008, muppet [EMAIL PROTECTED] wrote: Super easy. Changes to your code inline below: Thanks. Perfect. In the mean time, it occurred to me that it would be generally useful to be able to do something like: my $pr = Gtk2::Ex::Simple::RadioButtonGroup-new(all = 'All', current = 'Current', selected = 'Selected'); where the keys to the hash are what would be returned by get_active(), and the values would be the button titles. But I don't see how to pass the keys to Glib::Type-register_enum before initialising the object. Any ideas? Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: GtkImageView
On 05/01/2008, Emmanuele Bassi [EMAIL PROTECTED] wrote: try with: GdkRectangle_copy * instead of GtkRectangle_ornull *. That works, thanks for the help. Why didn't it work before? Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: GtkImageView
$rectangle = $selector-get_selection doesn't seem to be producing sensible results. Selections in examples/interactive.pl are nonsense, whereas the c version is OK. I assume, therefore, that there is something wrong in ImageToolSelector.xs: ## call as $rectangle = $selector-get_selection ## void gtk_image_tool_selector_get_selection (GtkImageToolSelector *selector, GdkRectangle *rect); GdkRectangle_ornull * gtk_image_tool_selector_get_selection (selector) GtkImageToolSelector * selector PREINIT: GdkRectanglerect; CODE: gtk_image_tool_selector_get_selection(selector, rect); RETVAL = rect; OUTPUT: RETVAL Any ideas? Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: GtkImageView
On 27/12/2007, Torsten Schoenfeld [EMAIL PROTECTED] wrote: This happens when the type registration facility in Glib::Object encounters a type that's not mapped to a corresponding Perl package. This usually happens via lines in the various maps files. Now, we don't have such a line for AtkImplementorIface because we don't wrap ATK at all yet. But we do have GtkBuildable support in Gtk2 1.160, so if you upgrade, Glib::Object::_Unregistered::GtkBuildable will turn into Gtk2::Buildable. Ah yes. Gutsy has 1.140. Sid has 1.161. What would we gain by wrapping ATK? Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: GtkImageView
On 25/12/2007, muppet [EMAIL PROTECTED] wrote: Hint: Glib::MakeHelper::postamble_docs(). I usually use Gnome2::Canvas as my template for these things, as it is a very simple module that builds atop Gtk2, but most of the modules in the gtk2-perl- xs cvs tree should do nicely. Very cool. Thanks. Just committed the docs for Gtk2::ImageView; I've still got the other modules to do. Why do some of the items in the INTERFACES heading have _Unregistered? e.g. Gtk2::Widget. For Gtk2::ImageView, they are: Glib::Object::_Unregistered::AtkImplementorIface Glib::Object::_Unregistered::GtkBuildable Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: GtkImageView
On 24/12/2007, muppet [EMAIL PROTECTED] wrote: Now that everything is under the Gtk2::ImageView namespace, the ignore pattern in the call to Glib::CodeGen::write_boot() is ignoring all of the packages in the module, so nothing actually gets booted correctly. You need to change that so that it ignores *only* the master package (which is needed to avoid an infinite loop at startup -- see the Glib::CodeGen manpage). Grr. Thanks for pointing that out. Now I've just got to sort out the documentation and that should be that. I appreciate all the help. I couldn't have done without it, and I've learned a great deal in the process. Regards Jeff ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: GtkImageView
On 22/12/2007, muppet [EMAIL PROTECTED] wrote: interactive.pl: a quick transliteration of gtkimageview/tests/ interactive.c. Note that the way this program uses the GtkImageTransp values in the UI manager actions doesn't really play nicely with perl syntax for enums, so there's a terrible, evil, horrible hack in its place. If you golf this down to more perlish code, using closures and such, you can sidestep the problem. Do you mind my including this in an examples directory, attributing you? I was getting: No anim! Can't call method set_sensitive on an undefined value at ./examples/interactive.pl line 74. *** unhandled exception in callback: *** FATAL: invalid enum GtkImageTransp value 1, expecting: color / GTK_IMAGE_TRANSP_COLOR, background / GTK_IMAGE_TRANSP_BACKGROUND, grid / GTK_IMAGE_TRANSP_GRID at ./examples/interactive.pl line 206. *** ignoring at ./examples/interactive.pl line 602. which the attached patch fixes. But I don't see how to do it differently with a closure. I'd appreciate a hint. I attempted to clean up the namespace with the second patch, but now the tests fail: t/animview.NOK 3# Failed test 'The object isa Gtk2::ImageView::Anim' # in t/animview.t at line 23. # The object isn't a 'Gtk2::ImageView::Anim' it's a 'Gtk2::ImageView' t/imagescrollwin...ok 1/3Usage: Gtk2::Table::new(class, rows, columns, homogeneous=FALSE) at /usr/lib/perl5/Glib.pm line 211. t/imagetooldragger.ok t/imagetoolselectorok 1/4Can't locate object method get_selection via package Gtk2::ImageView::Tool::Selector at t/imagetoolselector.t line 29. I must have done something right, as t/imagetooldragger is OK, but t/imagescrollwin is particularly strange. Thanks for any clue. Jeff Index: examples/interactive.pl === --- examples/interactive.pl (revision 447) +++ examples/interactive.pl (working copy) @@ -83,12 +100,16 @@ sprintf (%d, %d)-[%d, %d], $r-x, $r-y, $r-width, $r-height; } +sub get_enum_nick { +my ($package, $value) = @_; +my @v = Glib::Type-list_values ($package); +return $v[$value]{nick}; +} + sub get_enum_value { my ($package, $string) = @_; my @v = Glib::Type-list_values ($package); for (my $i = 0 ; $i @v ; $i++) { use Data::Dumper; print Dumper($v[$i]); return $i if $v[$i]{name} eq $string or $v[$i]{nick} eq $string; } } @@ -199,11 +220,11 @@ sub change_transp_type_cb { my ($action, $current) = @_; my $color = 0; my $transp = $current-get_current_value (); if ($transp == GTK_IMAGE_TRANSP_COLOR) { $color = 0x00; } -$view-set_transp ($transp, $color); +$view-set_transp (get_enum_nick('Gtk2::ImageTransp', $transp), $color); } sub menu_item_select_cb { @@ -495,7 +516,7 @@ $uimanager-insert_action_group ($image_group, 0); # Transform group -my $transform_group = Gtk2::ActionGroup-new (transform); +$transform_group = Gtk2::ActionGroup-new (transform); if ($transform_group) { $transform_group-add_actions ([EMAIL PROTECTED]); $transform_group-set_sensitive (FALSE); Index: ImageNav.xs === --- ImageNav.xs (revision 441) +++ ImageNav.xs (working copy) @@ -1,7 +1,7 @@ #include gtkimageviewperl.h -MODULE = Gtk2::ImageNav PACKAGE = Gtk2::ImageNav PREFIX = gtk_image_nav_ +MODULE = Gtk2::ImageView::Nav PACKAGE = Gtk2::ImageView::Nav PREFIX = gtk_image_nav_ GtkWidget * Index: IImageTool.xs === --- IImageTool.xs (revision 441) +++ IImageTool.xs (working copy) @@ -79,7 +79,7 @@ } -MODULE = Gtk2::IImageTool PACKAGE = Gtk2::IImageTool PREFIX = gtk_iimage_tool_ +MODULE = Gtk2::ImageView::Tool PACKAGE = Gtk2::ImageView::Tool PREFIX = gtk_iimage_tool_ gboolean Index: ImageToolPainter.xs === --- ImageToolPainter.xs (revision 441) +++ ImageToolPainter.xs (working copy) @@ -1,7 +1,7 @@ #include gtkimageviewperl.h -MODULE = Gtk2::ImageToolPainter PACKAGE = Gtk2::ImageToolPainter PREFIX = gtk_image_tool_painter_ +MODULE = Gtk2::ImageView::Tool::Painter PACKAGE = Gtk2::ImageView::Tool::Painter PREFIX = gtk_image_tool_painter_ GtkIImageTool * Index: maps === --- maps (revision 443) +++ maps (working copy) @@ -1,9 +1,10 @@ GTK_TYPE_IMAGE_VIEW GtkImageView GObject Gtk2::ImageView -GTK_TYPE_ANIM_VIEW GtkAnimView GObject Gtk2::AnimView -GTK_TYPE_IIMAGE_TOOL GtkIImageTool GObject Gtk2::IImageTool -GTK_TYPE_IMAGE_NAV GtkImageNav GObject Gtk2::ImageNav -GTK_TYPE_IMAGE_SCROLL_WIN GtkImageScrollWin GObject Gtk2::ImageScrollWin -GTK_TYPE_IMAGE_TOOL_DRAGGER GtkImageToolDragger GObject Gtk2::ImageToolDragger -GTK_TYPE_IMAGE_TOOL_SELECTOR GtkImageToolSelector