Another startup-time result
My configuration is a bit odd, but it works. The reason I'm still with Gtk2 1.042 is I can't get newer versions of Pango to work yet. ;-( I have a Duron 800 Mhz, 512 Meg Ram Cold load: time to load Glib 1.061: 0.546s time to load Gtk2 1.042: 2.477s time for Gtk2->init: 0.059s total startup time: 3.082s Glib built for 2.6.1, running with 2.6.1 Gtk2 built for 2.4.0, running with 2.4.14 Cached load: time to load Glib 1.061: 0.032s time to load Gtk2 1.042: 0.098s time for Gtk2->init: 0.038s total startup time: 0.167s Glib built for 2.6.1, running with 2.6.1 Gtk2 built for 2.4.0, running with 2.4.14 -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: external application output to a buffer
On Sun, 20 Feb 2005 12:00:58 -0500 (EST) [EMAIL PROTECTED] wrote: Besides the piped form of open, you can use IPC::Open3it will give you more control. You can separate the STDERR from the STDOUT if you need to. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
no WM decorations with fvwm2
Hi, Has anyone figured out how to remove decorations on fvwm2? Is fvwm2 just not cooperating? This script dosn't work for me. #!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; # dosn't seem to work on fvwm2 my $window = Gtk2::Window->new(); $window->set_decorated(0); Gtk2::Window::set_decorated($window, 0); print $window->get_decorated(),"\n"; $window ->signal_connect( 'destroy' => \&delete_event ); $window ->signal_connect( 'delete-event' => \&delete_event ); $window->set_border_width(10); $window->set_size_request(300,200); my $vbox = Gtk2::VBox->new( FALSE, 6 ); $window->add($vbox); $vbox->set_border_width(2); my $hbox= Gtk2::HBox->new( FALSE, 6 ); $vbox->pack_end($hbox,FALSE,FALSE,0); $hbox->set_border_width(2); my $button = Gtk2::Button->new_from_stock('gtk-quit'); $hbox->pack_end( $button, FALSE, FALSE, 0 ); $button->signal_connect( clicked => \&delete_event ); $window->set_position('center'); $window->show_all(); Gtk2->main; return 0; # sub delete_event { Gtk2->main_quit; return FALSE; } __END__ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: no WM decorations with fvwm2
On Mon, 25 Apr 2005 07:26:19 IDT Dov Grobgeld <[EMAIL PROTECTED]> wrote: >The following almost works for me under fvwm2: > >if (!$do_windowed) { >$mw->realize; >my(@geom) = $mw->window->get_geometry(); >$mw->window->set_override_redirect(1); >$mw->window->move($win_pos_x-$geom[0], $win_pos_y-$geom[1]); >} > >Unfortunately it still pops up at (0,0) on the screen. I.e. the move >command doesn't work. > >Regards, >Dov > Thanks. Yes, Tk uses overrideredirect to do this. I have found a way to work around it, by using 'popup', instead of 'toplevel' The 'move' method to work. Is a 'popup' window going to work like a 'toplevel' in most cases? #!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; my $window = Gtk2::Window->new('toplevel'); my $window1 = Gtk2::Window->new('popup'); $window ->signal_connect( 'destroy' => \&delete_event ); $window ->signal_connect( 'delete-event' => \&delete_event ); $window->set_size_request(300,200); $window1->set_size_request(100,100); my $button = Gtk2::Button->new_from_stock('gtk-quit'); $window->add( $button ); $button->signal_connect( clicked => \&delete_event ); $window->set_position('center'); #$window1->set_position('center'); $window1->move(200,200); $window->show_all(); $window1->show_all(); Gtk2->main; return 0; # sub delete_event { Gtk2->main_quit; return FALSE; } __END__ ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: How about a 'recipes' page in the wiki ?
Hi, I like the idea, and would be willing to help. I'm a beginner at Gtk2 myself, and am making a collection of my own from the tutorials and this list. As part of my "learning process" I would be happy to upload my snippet collection to a beginner's repository, or help ( within my capabilities) to test other snippets for the wiki. My snippets collection is organized into catagories like: font/fun/ glade/ objects/ Gtk1/ gnome/ packing/ progressbar/ signal/ buttons/ socket/ canvas/ color/ text/ combobox/ threads/ unicode/ images/ date-time/ io-add_watch/ dialogs/ ipc/keyboard/ window/ drag-n-drop/ labels/ entry/ events/ lists/ file-dir-ops/ menu/ file-select/ misc/ Email me if interested, and tell me what I can do. I have alot of free time on my hands. :-) -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: no WM decorations with fvwm2
On Mon, 25 Apr 2005 08:06:31 -0400 muppet <[EMAIL PROTECTED]> wrote: > >On Apr 25, 2005, at 5:45 AM, zentara wrote: > >> Thanks. Yes, Tk uses overrideredirect to do this. I have found a way >> to >> work around it, by using 'popup', instead of 'toplevel' The 'move' >Basically, the problem is that fvwm2 is not behaving nicely, as it >predates the netwm spec (which was created to solve problems such as >this, iirc). 'popup' is supposed to be used for "special" windows that >aren't really normal and may be ignored by the window manager: Ok, I took the time to post this as a bug report on the fvwm2 bug tracker. Maybe they will find a fix. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
a simple color question
Hi, I'm finding that setting up colors in Gtk2 is not that simple, and the docs are sending me in circles. :-) For example in the following script, how to I set the "active hightlight color" of the blue button, i.e. when the mouse is over it? A second question is how can I change the fill color of the "control frame"? There is a hbox in the frame, but changing the hbox color does nothing. #!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; my $window = Gtk2::Window->new('toplevel'); $window->set_title('Z'); $window ->signal_connect( 'destroy' => \&delete_event ); $window ->signal_connect( 'delete-event' => \&delete_event ); $window->set_border_width(10); $window->set_size_request(300,200); my $vbox = Gtk2::VBox->new( FALSE, 6 ); $window->add($vbox); $vbox->set_border_width(2); my $hbox= Gtk2::HBox->new( FALSE, 6 ); $vbox->pack_end($hbox,FALSE,FALSE,0); $hbox->set_border_width(2); my $frame0 = Gtk2::Frame->new('Controls'); $vbox->pack_end( $frame0, FALSE, FALSE, 0 ); $frame0->set_border_width(3); my $hbox0 = Gtk2::HBox->new( FALSE, 6 ); $frame0->add($hbox0); $hbox0->set_border_width(3); my $button = Gtk2::Button->new_from_stock('gtk-quit'); $hbox0->pack_end( $button, FALSE, FALSE, 0 ); $button->signal_connect( clicked => \&delete_event ); my $button1 = Gtk2::Button->new('Color-test'); $hbox0->pack_end( $button1, FALSE, FALSE, 0 ); $button1->signal_connect( clicked => sub{ print chr(07); }); my $red = Gtk2::Gdk::Color->new (0x,0,0); my $green = Gtk2::Gdk::Color->new (0,0x,0); my $blue = Gtk2::Gdk::Color->new (0,0,0x); my $blue1 = Gtk2::Gdk::Color->new (0,0x,0x); $window->modify_bg ('normal', $green); $hbox0->modify_bg ('normal', $red); $frame0->modify_bg ('normal', $red); $button1->modify_bg ('normal', $blue1); $button1->modify_bg ('selected', $blue); $window->show_all(); Gtk2->main; # sub delete_event { Gtk2->main_quit; return FALSE; } __END__ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: a simple color question
On Wed, 27 Apr 2005 22:40:12 -0400 muppet <[EMAIL PROTECTED]> wrote: > >On Apr 27, 2005, at 3:53 PM, zentara wrote: > >> For example in the following script, how to I set the "active >> hightlight color" of the blue button, i.e. when the mouse is over it? > >/me runs the script > >seriously, have you heard the party line on setting widget colors yet? Thanks for the pointers, it's a bit confusing that a label can set it's fg but not it's bg, and having to put a label in an EventBox. Anyways, for beginners looking thru archives, here is a updated beginner's color script. Blast away. :-) #!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; #GTK_STATE_NORMAL State during normal operation. #GKT_STATE_ACTIVE State of a currently active widget, such as a depressed button. #GTK_STATE_PRELIGHTState indicating that the mouse pointer is over the widget #GTK_STATE_SELECTEDState of a selected item, such the selected row in a list. #GTK_STATE_INSENSITIVE State indicating that the widget is unresponsive to user actions. my $red = Gtk2::Gdk::Color->new (0x,0,0); my $greyl = Gtk2::Gdk::Color->new (0x,0x,0x); my $greenl = Gtk2::Gdk::Color->new (0,0x,0x); my $blueh = Gtk2::Gdk::Color->new (0,0x,0x); my $bluel = Gtk2::Gdk::Color->new (0,0x,0x); my $white = Gtk2::Gdk::Color->new (0x,0x,0x); my $window = Gtk2::Window->new('toplevel'); $window->set_title('Z'); $window ->signal_connect( 'destroy' => \&delete_event ); $window->set_border_width(10); $window->set_size_request(300,200); $window->modify_bg ('normal', $greenl); my $vbox = Gtk2::VBox->new( FALSE, 6 ); $window->add($vbox); $vbox->set_border_width(2); my $hbox= Gtk2::HBox->new( FALSE, 6 ); $vbox->pack_end($hbox,FALSE,FALSE,0); $hbox->set_border_width(2); #used for coloring background my $coleventb0 = Gtk2::EventBox->new(); $vbox->pack_end( $coleventb0, FALSE, FALSE, 0 ); $coleventb0->set_border_width(3); $coleventb0->modify_bg ('normal', $greyl); $coleventb0->set_border_width(2); my $frame0 = Gtk2::Frame->new('Controls'); $coleventb0->add( $frame0); $frame0->set_border_width(3); $frame0->modify_bg ('normal', $red); my $hbox0 = Gtk2::HBox->new( FALSE, 6 ); $frame0->add($hbox0); $hbox0->set_border_width(3); my $button = Gtk2::Button->new_from_stock('gtk-quit'); $hbox0->pack_end( $button, FALSE, FALSE, 0 ); $button->signal_connect( clicked => \&delete_event ); my $button1 = Gtk2::Button->new('Color-test'); $hbox0->pack_end( $button1, FALSE, FALSE, 0 ); $button1->signal_connect( clicked => sub{ print chr(07),"\n"; # \n or use $|++ }); $button1->modify_bg ('normal', $bluel); $button1->modify_bg ('prelight', $blueh); $button1->modify_bg ('active', $white); my $label = Gtk2::Label->new("This is a Colored Label"); $label->modify_fg('normal', $white); #used for coloring background of labal my $coleventb1 = Gtk2::EventBox->new(); $coleventb1->set_border_width(3); $coleventb1->modify_bg ('normal', $red); $coleventb1->set_border_width(2); $coleventb1->add($label); $hbox0->pack_start( $coleventb1, FALSE, FALSE, 0 ); $window->show_all(); Gtk2->main; # sub delete_event { Gtk2->main_quit; return FALSE; } __END__ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Can this be used from Gtk2-perl? GtkDatabox
Hi, I saw a cool Gtk2+ library on freshmeat today. Is it possible to take these libs, and make a Gtk2-Perl module out it? I guess what I'm asking is this, is there some standardized or automated way to convert to Gtk2-Perl? Is the C to Perl easy or hard, with Gtk2? GtkDatabox A widget to display large sets of data as dots (or lines). Different data sets will have different colors, you may change colors and style of the data The widget gives the possibility to zoom into and out of the data and to scroll around. It also offers a grid like on an oscilloscope. The homepage of the GtkDatabox is http://www.eudoxos.de/gtk/gtkdatabox/ Thanks. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Can this be used from Gtk2-perl? GtkDatabox
On Sat, 30 Apr 2005 11:02:06 -0400 muppet <[EMAIL PROTECTED]> wrote: > >On Apr 30, 2005, at 9:55 AM, zentara wrote: > >> I saw a cool Gtk2+ library on freshmeat today. Is it possible >> to take these libs, and make a Gtk2-Perl module out it? >> I guess what I'm asking is this, is there some standardized or >> automated way to convert to Gtk2-Perl? Is the C to Perl easy >> or hard, with Gtk2? > >http://gtk2-perl.sourceforge.net/doc/binding_howto.pod.html > > >> GtkDatabox > >http://mail.gnome.org/archives/gtk-perl-list/2004-March/msg00077.html Hi, thanks, it runs good, and it is a nice example of doing xs with Gtk2. I did notice 1 small error in the examples, which I have also seen throughout the tutorials, that is using :: notation where you need a ->. For example in lissajous.pl around line 75, #$window->signal_connect (destroy => \&Gkt2::main_quit); needs to be $window->signal_connect (destroy => sub {Gtk2->main_quit}); When I've been going thru the tutorials, I've seen this in quit a few of the code snippets and code, and it probably will confuse alot of beginners...it took me a bit of time to figure it out. :-) -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
forking a new mainwindow from a module
Hi, In Tk, I was able to make a module which forked and opened a new Tk mainwindow, to display the parent's pid and mem usage. I'm trying to do the same thing with Gtk2, but I am getting crashes, with the error: Xlib: unexpected async reply (sequence 0xd7)! The program 'ztest' received an X Window System error. This probably reflects a bug in the program. The error was 'BadRequest (invalid request code or no such operation)'. (Details: serial 218 error_code 1 request_code 0 minor_code 0) If I call the module from a Tk, or commandline program, the Gtk2 window opens fine. It crashes when I call it from a Gtk2 program. This is GMeM.pm placed in PERL5LIB ## package GMeM; use warnings; use strict; my $pid =$$; print "$pid\n"; if (fork() == 0) { print "forked ok\n"; use Gtk2 '-init'; my $win = Gtk2::Window->new('toplevel'); $win->signal_connect( 'destroy' => \&delete_event ); my ($xscr, $yscr) = (Gtk2::Gdk->screen_width, Gtk2::Gdk->screen_height); $win->move($xscr - 80, $yscr - 15); my $lab = Gtk2::Label->new("PID: $pid-> " ); my $font = Gtk2::Pango::FontDescription->from_string("Sans Bold 14"); $lab->modify_font($font); $win->add($lab); $win->show_all(); Gtk2->main; # sub delete_event { Gtk2->main_quit; return 0; } } 1; and here is a Gtk2 test program which crashes: # #!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; use GMeM; my $window = Gtk2::Window->new('toplevel'); $window ->signal_connect( 'destroy' => \&delete_event ); $window->set_title('GMeM-test'); $window->set_size_request(300,200); my $button = Gtk2::Button->new_from_stock('gtk-quit'); $window->add( $button); $button->signal_connect( clicked => \&delete_event ); $window->show_all(); Gtk2->main; # sub delete_event { Gtk2->main_quit; return FALSE; } # Any ideas on what I can do to fix this? Thanks. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: forking a new mainwindow from a module
On Fri, 6 May 2005 19:10:29 -0400 muppet <[EMAIL PROTECTED]> wrote: > >On May 6, 2005, at 5:42 PM, zentara wrote: > >> Any ideas on what I can do to fix this? > >What's happening is that the child is inheriting the X connection >socket from the parent, and both the child and parent are trying to >communicate over the same socket. It blows up just like two threads >trying to talk at the same time. > >I presume that the Tk version didn't do that because it initializes X >differently. It works with other programs because they're not fighting >for the same X connection. > >Here's a minor hack of your module to exec itself in the child to force >the socket to close. > Thanks for showing me that clever mechanism. I had to add a bit of defined testing, but it works. if ((defined $ARGV[0]) and ($ARGV[0] eq 'GMeM')){... Another snippet for the "ole bag-o-tricks" :-) -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
GMeM -- a gtk2 memory monitor utlity module
Hi, thanks to muppet, I have a gtk2-perl version of my memory monitoring utility. I use it when I want to watch for memory gains in scripts. Just put GMeM.pm in your PERL5LIB and put "use GMeM;" in your script. It will autoclose when the calling script closes, or you can click it to close it. I use an asmutils version of cat ( it's only 147 bytes :-) ), but you can change it to use the system cat. I place it in the bottom right corner, because I keep my toolbar at the top. GMeM.pm package GMeM; use warnings; use strict; my $pid =$$; #gets the caller script's pid and #passes it thru the fork-&-exec below #only gets created after fork and exec to prevent #module's X socket connection from interfering with #calling program's X socket connection if ((defined $ARGV[0]) and ($ARGV[0] eq 'GMeM')) { use Gtk2 '-init'; $pid = $ARGV[1]; my $blueh = Gtk2::Gdk::Color->new (0,0x,0x); my $bluel = Gtk2::Gdk::Color->new (0,0x,0x); Gtk2::Rc->parse_string(<<___EOS); style "normal" { font_name ="Sans Bold 12" } widget "*" style "normal" ___EOS my $win = Gtk2::Window->new('popup'); $win->signal_connect( 'destroy' => \&delete_event ); my ($xscr, $yscr) = (Gtk2::Gdk->screen_width, Gtk2::Gdk->screen_height); $win->move($xscr - 180, $yscr - 20); my $but = Gtk2::Button->new("PID: $pid-> " ); $but->modify_bg ('normal', $blueh); $but->modify_bg ('prelight', $bluel); $but->signal_connect( 'clicked' => \&delete_event ); $win->add($but); $0 = "GMeM $pid"; $win->show_all(); &refresh($pid); my $repeater = Glib::Timeout->add(1000, sub{ refresh($pid) ; 1;} ); Gtk2->main; # sub delete_event { Gtk2->main_quit; return 0; } sub refresh { my $pid = shift; #asmutils version of cat my @size = split "\n", `/home/zentara/perl5lib/cat /proc/$pid/status`; #my @size = split "\n", `cat /proc/$pid/status`; (my $vmsize) = grep { /VmSize/ } @size; my (undef, $size) = split ' ', $vmsize; $but->set_label("PID: $pid -> $size"); if ($size eq '') { exit } } } elsif (fork() == 0) { exec "$^X -MGMeM -e1 GMeM $pid"; } 1; __END__ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
ignoring .gtkrc-2.0 defaults
Hi, I have a .gtkrc-2.0 file, and it sets a default font and coloring for my c-based gtk2 apps like Sylpheed and Gimp. Now when I start a gtk2-perl app, it also uses those defaults. Is there something I can put in the gtkrc-2.0 file, to tell gtk2-perl apps to ignore it? I'm lazy, and want to avoid having to put an extra line in all my scripts. :-) -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Resize Pixbuf
On Thu, 12 May 2005 08:10:35 -0400 (EDT) >I have a Gtk2::Gtk::Image wich contains a Gtk2::Gtk::Pixbuf displaying >an Image larger than the the Gtk2::Gtk::Image. How can I resize and >update the Pixbuf whenever the Image-widget resizes? Hi, Just some 2 cents.. I ran your code, and got it to partially work. It reminded me of the excellent Gtk2::ImageViewer by Dov Grobgeld http://imagic.weizmann.ac.il/~dov/freesw/gtk/gtk-image-viewer It has resizing, mouse zoom and mouse pan. It seems to do what you are trying to do, but it uses mouse only. Maybe you could add some key-bindings, or get some clues from what he does. ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
any Perl bindings for gtk+extra?
Hi, The last time I asked about a binding here, I lucked out, so I'm asking again. :-) Is there any Perl bindings to the GtkExtra Widget Set at http://gtkextra.sourceforge.net/ ?? Thanks. I wish I was smart enough to do it myself. Joe -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
experimenting with embedding with windowid
Hi, What I'm trying to do is embed an xterm(and possibly mc) into a gtk2 window. In Tk it is possible to do this, by creating windows in containers in different widgets, then the xterm and it's app would transparently function within the Tk window. After searching thru the mail archives, I came up with something in Gtk2, but it dosn't quite work. In the code below, I can embed the xterm and mc, but it only goes into the main Gtk2 window, and it responds to the mouse only, no keyboard connection. So there are 2 questions: 1. How can I connect the keyboard to the xterm? 2. Is there a container widget of some type, that will give an XWINDOW id independent of the parent window's id? So I can embed the xterm into just a portion of the main window? (Like the container in Tk) #!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; my $window = Gtk2::Window->new('toplevel'); $window->set_title('Embed test'); $window ->signal_connect( 'destroy' => \&delete_event ); $window->set_border_width(10); $window->set_size_request(500,500); my $vbox = Gtk2::VBox->new( FALSE, 6 ); $window->add($vbox); $vbox->set_border_width(2); my $hbox= Gtk2::HBox->new( FALSE, 6 ); $vbox->pack_end($hbox,FALSE,FALSE,0); $hbox->set_border_width(2); $vbox->pack_end (Gtk2::HSeparator->new, FALSE, FALSE, 0); my $button = Gtk2::Button->new_from_stock('gtk-quit'); $hbox->pack_end( $button, FALSE, FALSE, 0 ); $button->signal_connect( clicked => \&delete_event ); my $button1 = Gtk2::Button->new('Get ID'); $hbox->pack_end( $button1, FALSE, FALSE, 0 ); $button1->signal_connect( clicked => \&get_id ); $window->show_all(); Gtk2->main; # sub delete_event { Gtk2->main_quit; return FALSE; } ## sub get_id{ my $gdkwindow = $window->window; print "gdkwin->$gdkwindow\n"; my $gdkwindow1 = $vbox->window; print "gdkvbox->$gdkwindow1\n"; my $xid = $gdkwindow->XWINDOW; print "xid->$xid\n"; system("xterm -into $xid -e /usr/bin/mc &"); } -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: progress bar
Here is a simple example. #!/usr/bin/perl use warnings; use strict; use Gtk2; Gtk2->init(); my $window = new Gtk2::Window; my $pbar = new Gtk2::ProgressBar; $pbar->set_pulse_step(.1); # set_text not allowed in pulser # ! $pbar->set_text('foobar'); my $vb = new Gtk2::VBox(0, 0); my $b = new Gtk2::Button('Quit'); $window->add($vb); $vb->add($pbar); $vb->add($b); $b->signal_connect('clicked', sub {Gtk2->main_quit}); $window->signal_connect('destroy', sub {Gtk2->main_quit}); $window->show_all(); my $timer = Glib::Timeout->add (100,\&show_progress); # timer will run until callback returns false Gtk2->main; # sub show_progress{ $pbar->pulse(); return 1; } __END__ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
non-blocking loop delay
Hi, I'm either missing something, or I'm searching for something which dosn't exist. Is there a way to slow down a loop, without blocking the gui? I know the code below, could (and probably should) be rewritten using Glib::Timeout->add () instead of a for loop, but what if I wanted or needed the for loop. How to I install a non-blocking loop delay? In Tk, there was a form of the "after" or "repeat" statement, where you just use $widget->after(10); to get a 10 millisecond delay. Anything similar in Gtk2? #!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; my $count = 0; my $window = Gtk2::Window->new('toplevel'); $window->set_title('Z'); $window ->signal_connect( 'destroy' => \&delete_event ); $window->set_border_width(10); $window->set_size_request(300,200); my $vbox = Gtk2::VBox->new( FALSE, 6 ); $window->add($vbox); $vbox->set_border_width(2); my $hbox= Gtk2::HBox->new( FALSE, 6 ); $vbox->pack_end($hbox,FALSE,FALSE,0); $hbox->set_border_width(2); $vbox->pack_end (Gtk2::HSeparator->new, FALSE, FALSE, 0); my $button = Gtk2::Button->new_from_stock('gtk-quit'); $hbox->pack_end( $button, FALSE, FALSE, 0 ); $button->signal_connect( clicked => \&delete_event ); my $button1 = Gtk2::Button->new('Start'); $hbox->pack_end( $button1, FALSE, FALSE, 0 ); $button1->signal_connect( clicked => \&start_count ); $window->show_all(); Gtk2->main; # sub delete_event { Gtk2->main_quit; return FALSE; } sub start_count{ for(1..100){ $count++; print "$count\n"; #looking to slow this loop down #in a non-blocking manner #something like this ? Glib::Timeout->add (100, sub{ return FALSE } ); #of course this dosn't work and the loop just flies thru } } # -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: non-blocking loop delay
Thanks muppet, your technique for suspending the mainloop works just like I wanted. sub non_blocking_delay { my $milliseconds = shift; my $mainloop = Glib::MainLoop->new; Glib::Timeout->add ($milliseconds, sub { $mainloop->quit; FALSE; }); $mainloop->run; } I was responding to someone offlist trying to make a pulse-progressbar example work in a situation where a series of subroutines were to be run sequentially. I was using a simple counter as the test subs, but they went too fast. When I tried the conventional Timeout, they ran in parallel. I resorted to just counting to a very high number, which of course just max out the cpu. In case anyone is interested, this is how I actually used your non-blocking-delay sub. I was using the horrible technique in process_b to acheive the result, but it maxed cpu. Thanks again, I will always remember this sub. #!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; #this is a sequential processor my $wait_dialog = 0; #just a global flag to track wait popup my $window = Gtk2::Window->new('toplevel'); $window->set_title('Z'); $window ->signal_connect( 'destroy' => \&delete_event ); $window->set_border_width(10); $window->set_size_request(300,200); my $vbox = Gtk2::VBox->new( FALSE, 6 ); $window->add($vbox); $vbox->set_border_width(2); my $hbox= Gtk2::HBox->new( FALSE, 6 ); $vbox->pack_end($hbox,FALSE,FALSE,0); $hbox->set_border_width(2); $vbox->pack_end (Gtk2::HSeparator->new, FALSE, FALSE, 0); my $button = Gtk2::Button->new_from_stock('gtk-quit'); $hbox->pack_end( $button, FALSE, FALSE, 0 ); $button->signal_connect( clicked => \&delete_event ); my $button1 = Gtk2::Button->new('Init Dialog'); $hbox->pack_end( $button1, FALSE, FALSE, 0 ); $button1->signal_connect( clicked => \&initialize ); $window->show_all(); Gtk2->main; # sub delete_event { Gtk2->main_quit; return FALSE; } ### sub initialize{ $window->window->set_cursor(Gtk2::Gdk::Cursor -> new("watch")); $wait_dialog = 1; #set the flag &display_popup; #display the popup &run_stuff; } # sub run_stuff{ &start_process_a; &start_process_b; &start_process_c; } ## sub display_popup { #create the 'waiting' dialog my $popup = Gtk2::Window->new('popup'); $popup -> set_resizable (FALSE); $popup->set_position('center'); my $pbar = Gtk2::ProgressBar->new(); $pbar->set_pulse_step(.1); my $vbox0 = Gtk2::VBox->new (FALSE, 6); $vbox0->set_border_width(10); my $label=Gtk2::Label->new (); $label->set_justify('GTK_JUSTIFY_CENTER'); $label->set_markup("".("Please wait... loading data...").""); $vbox0->pack_start($label,FALSE, FALSE, 0); $vbox0->pack_start($pbar,FALSE, FALSE, 0); $pbar->show; $vbox0->show_all; $popup->add($vbox0); $popup->show_all; my $timer = Glib::Timeout->add (100, sub{ if($wait_dialog == 1){ $pbar->pulse; return TRUE; }else{ $window->window->set_cursor(Gtk2::Gdk::Cursor -> new("left-ptr")); $popup->destroy; return FALSE; } } ); } ### sub start_process_a{ print "In a\n"; my $count = 0; for(1..5){ $count++; print "$count-a\n"; non_blocking_delay(1000); } } sub start_process_b{ print "In b\n"; my $count = 0; for(1..30){ $count++; # print "$count-b\n"; Gtk2->main_iteration while Gtk2->events_pending; } } sub start_process_c{ print "In c\n"; $wait_dialog = 0; #set flag to destroy popup } sub non_blocking_delay { my $milliseconds = shift; my $mainloop = Glib::MainLoop->new; Glib::Timeout->add ($milliseconds, sub { $mainloop->quit; FALSE; }); $mainloop->run; } __END__ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
style name for Text insertion cursor
Hi, I like to use a black background in my text boxes. But I can't seem to find the style setting to make the insertion cursor visible. Can someone point it out to me please? Thanks. #!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; Gtk2::Rc->parse_string(<<__); style "my_text" { font_name ="sans 24" text[NORMAL] = "#FFAA00" base[NORMAL] = "#00" } widget "*Text*" style "my_text" __ my $window = Gtk2::Window->new('toplevel'); $window->set_title('Z'); $window ->signal_connect( 'destroy' => \&delete_event ); $window->set_border_width(10); $window->set_size_request(400,400); my $vbox = Gtk2::VBox->new( FALSE, 6 ); $window->add($vbox); $vbox->set_border_width(2); my $hbox= Gtk2::HBox->new( FALSE, 6 ); $vbox->pack_end($hbox,FALSE,FALSE,0); my $ebutton = Gtk2::Button->new_from_stock('gtk-quit'); $hbox->pack_end( $ebutton, FALSE, FALSE, 0 ); $ebutton->signal_connect( clicked => \&delete_event ); my $textbuffer = Gtk2::TextBuffer->new(); $textbuffer->set_text('yadda yadda yadda'); my $textview = Gtk2::TextView->new_with_buffer($textbuffer); my $scrolledwindow = Gtk2::ScrolledWindow->new( undef, undef ); $scrolledwindow->add($textview); $vbox->pack_start($scrolledwindow, 1, 1, 0 ); $window->show_all(); Gtk2->main; # sub delete_event { Gtk2->main_quit; return FALSE; } ### -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
a couple of Gnome2::Canvas problems
Hi, I'm trying to make a simple gauge with the Gnome2::Canvas. It all works well, except when I destroy the meter. I get an error nomeCanvas-CRITICAL **: file gnome-canvas.c: line 3698 (gnome_canvas_request_redraw): assertion `GNOME_IS_CANVAS (canvas)' failed during global destruction. I have found through trial and error, that I get this repeated twice, but have found that I can reduce it to 1 by putting a "$canvas->destroy;" in my delete_event subroutine. Additionally, I can stop the error by NOT updating the $text->set(text => $value); in the update_meter sub. So that is my main question, how do I stop this annoying error message, when I update the Canvas Text widget? As a bonus question :-), how do I prevent the $gauge circle from being seen at the bottom, when you drag the main window to a bigger size? I only want an "ARC" , but Ellipse dosn't seem to have limit points available to set. I tried to limit the size of the $canvas, but the circle will still show. Am I forced to mask it with something? Thanks. #Simple Meter #!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; use Gnome2::Canvas; use constant PI => 3.1415926; use Tie::Watch; my $width = 200; my $height = 100; my $value = 0; my $max = 100; my $min = 0; my $watch = Tie::Watch->new( -variable => \$value, -shadow => 0, -store=> \&update_meter, ); my $window = Gtk2::Window->new; $window->signal_connect( 'destroy' => \&delete_event ); $window->set_default_size( $width, $height ); my $canvas = Gnome2::Canvas->new_aa(); $canvas->set_scroll_region( 0, 0, $width, $height ); #to get upper left corner $canvas->set_size_request( $width, $height ); #useless? $window->add($canvas); $window->show_all; my $root = $canvas->root(); my $text = Gnome2::Canvas::Item->new( $root, 'Gnome2::Canvas::Text', x => $width / 2, y => $height * .50, fill_color => 'yellow', font => 'Sans 14', anchor => 'GTK_ANCHOR_CENTER', text => $value ); my $box = Gnome2::Canvas::Item->new( $root, 'Gnome2::Canvas::Rect', x1=> 0, y1=> 0, x2=> $width, y2=> $height, fill_color=> 'black', outline_color => 'black' ); my $hub = Gnome2::Canvas::Item->new( $root, "Gnome2::Canvas::Ellipse", x1=> $width / 2 - 8, y1=> ( $height * .80 ) - 8, x2=> $width / 2 + 8, y2=> ( $height * .80 ) + 8, fill_color=> 'white', outline_color => 'black' ); my $gauge = Gnome2::Canvas::Item->new( $root, "Gnome2::Canvas::Ellipse", x1=> $width / 2 - 80, y1=> ( $height * .80 ) - 80, x2=> $width / 2 + 80, y2=> ( $height * .80 ) + 80, outline_color => 'white', fill_color=> 'steelblue' ); my $floor = Gnome2::Canvas::Item->new( $root, 'Gnome2::Canvas::Rect', x1=> 0, y1=> $height * .80, x2=> $width, y2=> $height, fill_color=> 'black', ); my $needle = Gnome2::Canvas::Item->new( $root, "Gnome2::Canvas::Line", points => [ $width / 2, ( $height * .80 ), $width / 2, 10 ], width_units=> 5, fill_color => 'hotpink', last_arrowhead => 1, arrow_shape_b => 20 ); $box->lower_to_bottom; $needle->raise_to_top; $hub->raise_to_top; $text->raise($gauge); my $toggle = 1; my $count = 0; Glib::Timeout->add (50, sub { $count += $toggle; $value = $count; return TRUE; } ); Gtk2->main; ###3 sub delete_event { $watch->Unwatch; $canvas->destroy; Gtk2->main_quit; return 0; } ###3 sub update_meter { if ( $value <= $min ) { $toggle = 1 } if ( $value >= $max ) { $toggle = -1 } my $pos = $value * PI/$max; my $x = $width/2 - $height * .80 * ( cos( $pos ) ); my $y = $height * .80 - $height * .80 * ( sin( $pos ) ) ; $needle->set( points => [ $width / 2, ( $height * .80 ), $x, $y ], ); $text->set(text => $value); #causes error message on exit return $value; } __END__ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: a couple of Gnome2::Canvas problems
On Wed, 13 Jul 2005 08:30:31 -0400 muppet <[EMAIL PROTECTED]> wrote: > >On Jul 11, 2005, at 12:58 PM, zentara wrote: > >> I'm trying to make a simple gauge with the Gnome2::Canvas. >> It all works well, except when I destroy the meter. I get an error >> >> nomeCanvas-CRITICAL **: file gnome-canvas.c: line 3698 >> (gnome_canvas_request_redraw): assertion `GNOME_IS_CANVAS (canvas)' >> failed during global destruction. >Simple solution -- clear your own item references just before >destroying the canvas. > > >> ###3 >> sub delete_event { > > # clear our item references, so things can die in peace. > $text = undef; > $box = undef; > $hub = undef; > $gauge = undef; > $floor = undef; > $needle = undef; > >> $watch->Unwatch; >> $canvas->destroy; >> Gtk2->main_quit; >> return 0; >> } Thanks, I did try $text->destroy,etc, but no luck. I should have thought of undef. By the way, I also found the way to clip the bottom of the gauge circle, ...just put the canvas into a vbox..doh!!!. my $vbox = Gtk2::VBox->new( FALSE, 6 ); $window->add($vbox); $vbox->set_border_width(2); my $canvas = Gnome2::Canvas->new_aa(); $canvas->set_size_request($width,$height); $canvas->set_scroll_region( 0, 0, $width, $height ); #to get upper left corner $canvas->set_size_request( $width, $height ); #useless ? $vbox->pack_start($canvas,FALSE,FALSE,0); $window->show_all; Thanks again. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: a couple of Gnome2::Canvas problems
On Wed, 13 Jul 2005 08:33:21 -0400 (EDT) >Date: Wed, 13 Jul 2005 17:47:38 +1200 >From: Grant McLean <[EMAIL PROTECTED]> >Subject: Re: a couple of Gnome2::Canvas problems >To: "gtk-perl-list@gnome.org" >I tried your script and got the same errors. It piqued my interest >because the error seem to occur even when all calls to update meter are >removed. If I put a die in the update_meter routine, it was never >reached and yet commenting out the $needle->set and $text->set made the >errors go away. Very odd. > >I was testing on Debian Sarge and a colleague tested on Debian unstable. >He did not get the errors. I'm assuming that the libraries are >different versions. > >Anyway, I was able to make the errors go away by making these 3 changes: > >-$window->signal_connect( 'destroy' => \&delete_event ); >+$window->signal_connect( 'delete-event' => \&delete_event ); > >... > > sub delete_event { > $watch->Unwatch; >-$canvas->destroy; > Gtk2->main_quit; >-return 0; >+return 1; >} That didn't work for me. >Was there any particular need to destroy the canvas object rather than >leaving it to be cleaned up? Well it was just the steps I took in the programming. The first version, had no text display, and I got the error. The error went away with adding $canvas->destroy; Then I added the text, and the error appeared again, but it would not go away, as long as the text was being updated. I tried to put $text->destroy but that didn't work. But as muppet pointed out undef $text ( and all the canvas items) does the trick. > >I've attached a tweaked version of the script that uses a Bezier curve >to create a half circle rather than using an ellipse object. > >Cheers >Grant GreatI was looking for an example to make a Bezier, but I guess we are the ones making examples for others. :-) Thanks. By the way, I did figure out clipping the circle, by just putting the $canvas into a vbox. Joe -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: radioitem
On Tue, 19 Jul 2005 12:00:33 -0400 (EDT) Beast wrote: >Subject: radioitem >Any sample to use callback for ? > >It will call both One and Two when togle the selection. >TIA This is no match for muppet's and Torsten's solution, but here is a way I got around the double signal. It seems pretty "clunky" by comparison. But thats me...clunky. :-) I post it just for jollies. (Someone complained that if you hold the mouse button down and drag to the other button, this will cause a bit of "reset havoc", but it works pretty good for me.) #!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; my $window = Gtk2::Window->new('toplevel'); $window->set_title('Z'); $window ->signal_connect( 'destroy' => \&delete_event ); $window->set_border_width(10); $window->set_size_request(300,200); my $vbox = Gtk2::VBox->new( FALSE, 6 ); $window->add($vbox); $vbox->set_border_width(2); my $hbox= Gtk2::HBox->new( FALSE, 6 ); $vbox->pack_end($hbox,FALSE,FALSE,0); $hbox->set_border_width(2); $vbox->pack_end (Gtk2::HSeparator->new, FALSE, FALSE, 0); my $button = Gtk2::Button->new_from_stock('gtk-quit'); $hbox->pack_end( $button, FALSE, FALSE, 0 ); $button->signal_connect( clicked => \&delete_event ); my $value; my $button1 = Gtk2::RadioButton->new(undef,"Radio Button 1"); my $but1_sigid = $button1->signal_connect( "toggled" => sub { $value = "button1"; sighandler(); }, "Radio Button 1" ); $button1->signal_handler_block ($but1_sigid); $vbox->pack_start($button1, TRUE, TRUE, 0); $button1->set_active(TRUE); $button1->show; my @group = $button1->get_group; my $button2 = Gtk2::RadioButton->new_with_label(@group,"Radio Button 2"); my $but2_sigid = $button2->signal_connect( "toggled" => sub {$value = "button2"; sighandler(); }, "Radio Button 2" ); $button2->signal_handler_block ($but2_sigid); $button1->signal_connect( "enter" => sub { $button1->signal_handler_unblock ($but1_sigid) }); $button1->signal_connect( "leave" => sub { $button1->signal_handler_block ($but1_sigid) }); $button2->signal_connect( "enter" => sub { $button2->signal_handler_unblock ($but2_sigid) }); $button2->signal_connect( "leave" => sub { $button2->signal_handler_block ($but2_sigid)}); $vbox->pack_start($button2, TRUE, TRUE, 0); $button2->show; $window->show_all(); Gtk2->main; # sub delete_event { Gtk2->main_quit; return FALSE; } sub sighandler { print "value-> $value\n"; } ## -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: can_activate_acce
On Wed, 20 Jul 2005 17:46:22 -0400 (EDT) [EMAIL PROTECTED] >Subject: can_activate_accel >To: gtk-perl-list@gnome.org >If I understand the documentation correctly, one should be able to disable >the keyboard accelerator for a widget by connecting to the >can_activate_accel signal and returning false. This isn't working for me, >however. > >Can someone tell me if I'm doing something wrong, or is there a bug in >gtk/gtk-perl? Example program below... using gtk 2.4.9 and gtk-perl 1.092, >typing a "b" in the text entry will click the button despite the >can_activate_accel handler. > Hi, this is how I got it working, however, I'm just learning myself. There probably is a more elegant solution. #!/usr/bin/perl use warnings; use strict; use Gtk2 qw(-init); my $window = Gtk2::Window->new; my $button = Gtk2::Button->new('button'); my $entry = Gtk2::Entry->new; my $vbox = Gtk2::VBox->new(0,2); my $accel = Gtk2::AccelGroup->new; $window->add($vbox); $vbox->pack_start($button,1,1,0); $vbox->pack_start($entry,1,1,0); $button->add_accelerator('clicked', $accel, ord('b'), [], [] ); $window->add_accel_group($accel); $window->signal_connect(destroy => sub { Gtk2->main_quit; }); $button->signal_connect(clicked => sub { print "clicked\n"; }); #$button->signal_connect(can_activate_accel => sub { return 0; }); $entry->signal_connect (event => sub { my ($item, $event) = @_; if( $event->type eq 'enter-notify'){ Gtk2::AccelGroup::disconnect_key($accel, ord('b'),[]); } if( $event->type eq 'leave-notify'){ $button->add_accelerator('clicked', $accel, ord('b'), [], [] ); } }); $window->show_all; Gtk2->main(); __END__ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: mplayer-embedding
On Sun, 31 Jul 2005 12:00:36 -0400 (EDT) [EMAIL PROTECTED] wrote: >Date: Sun, 31 Jul 2005 13:42:24 +0200 >From: Bo?tjan ?peti? <[EMAIL PROTECTED]> >Subject: mplayer? >hi >is there an easy way of embeding mplayer into gtk2? >regards, bostjan Hi, I did it with Tk, and had some success embedding mplayer. See script below. First of all, I took an embedding script I was testing with dillo, and just thru the mplayer command into it. It works, but I've included no frills. To see a "frill-full" Tk version, see http://perlmonks.org?node_id=417164 You have to use some special features of mplayer (see it's docs) to run it as a slave. Here is a script that runs on my machine. You will need an init.mpg to give an initial screen, until you load some file. See the above perlmonk link to get the sample files I use. P.S. I played alot with embedding and gtk2, but have only got the mouse to function in the embedded window, no keys connect. ## #!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2; use Gtk2 '-init'; my $pid; #global for killing mplayer on exit my $window = Gtk2::Window->new('toplevel'); $window->set_title('Embed test'); $window ->signal_connect( 'destroy' => \&delete_event ); $window->set_border_width(10); $window->set_size_request(600,600); set_style(); my $vbox = Gtk2::VBox->new( FALSE, 6 ); $window->add($vbox); $vbox->set_border_width(2); my $hbox= Gtk2::HBox->new( FALSE, 6 ); $vbox->pack_end($hbox,FALSE,FALSE,0); $hbox->set_border_width(2); $vbox->pack_end (Gtk2::HSeparator->new, FALSE, FALSE, 0); my $vbox1 = Gtk2::VBox->new( FALSE, 6 ); $vbox1->set_size_request(600,500); $vbox->pack_end($vbox1,FALSE,FALSE,0); $vbox1->set_border_width(2); my $button = Gtk2::Button->new_from_stock('gtk-quit'); $hbox->pack_end( $button, FALSE, FALSE, 0 ); $button->signal_connect( clicked => \&delete_event ); my $button1 = Gtk2::Button->new('Mplayer'); $hbox->pack_end( $button1, FALSE, FALSE, 0 ); $button1->signal_connect( clicked => \&do_mplayer ); $window->show_all(); Gtk2->main; # sub delete_event { kill 9, $pid; Gtk2->main_quit; return FALSE; } ## sub do_mplayer{ my $gdkwindow = $window->window; print "gdkwin->$gdkwindow\n"; my $gdkwindow1 = $vbox1->window; print "gdkvbox->$gdkwindow1\n"; my $xid = $gdkwindow1->XWINDOW; print "xid->$xid\n"; my $url =''; my @options = ( '-slave','-loop 0', '-zoom', "-x 600", "-y 450", '-really-quiet', "-wid $xid", ); my $mpg = 'z-men.mpg'; my $pid = open(MP, "| mplayer @options init.mpg >/dev/null 2>&1 "); syswrite(MP, "loadfile $mpg\n"); } sub set_style{ Gtk2::Rc->parse_string(<<__); style "normal" { font_name ="serif 12" } style "my_text" { font_name ="sans 12" text[NORMAL] = "#FFAA00" base[NORMAL] = "#00" GtkTextView::cursor-color = "red" } widget "*" style "normal" widget "*Text*" style "my_text" __ } ### -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: gtk-perl-list Digest, Vol 16, Issue 2
On Tue, 2 Aug 2005 09:06:04 -0400 (EDT) [EMAIL PROTECTED] wrote: >Date: Tue, 02 Aug 2005 20:05:29 +0700 >From: Beast <[EMAIL PROTECTED]> >Subject: Button with image >1. Is it possible to create new button with image without adding in >Gtk2::Stock? > >2. I can not found gtk_stock_add documentation in gtk+ site, however it >was there in gtk-perl site, is Gtk2::Stock only available in gtk-perl? >--beast Here is an example I have, I didn't write it, found it in a tutorial somewhere or from the net. #!/usr/bin/perl use warnings; use strict; ## # An example illustrating images and markup. ## use Gtk2 '-init'; my $window = Gtk2::Window->new; my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file("bridget-1.jpg"); my $image = Gtk2::Image->new_from_pixbuf($pixbuf); my $button = Gtk2::Button->new(); my $vbox = Gtk2::VBox->new(); my $label = Gtk2::Label->new("Press this button!"); $vbox->pack_start( $label, 0, 0, 0 ); $vbox->pack_start( $image, 0, 0, 0 ); $window->set( border_width => 15 ); $button->add($vbox);# <- You can pack any widget inside a button! $window->add($button); $button->signal_connect( clicked => sub { $label->set_markup( "Thank " . "" . "you!" ); } ); $window->signal_connect('destroy', sub { Gtk2->main_quit }); $window->show_all(); Gtk2->main; -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
gtkdatabox version 3.0 xs problem
Hi Muppet, I know you are extremely busy, but your xs interface to the latest version of gtkdatabox seems to have a small problem. I could "experiment and guess" until I got it to run, but it may be better if you, "with your vast knowledge and experience" looked at it. It seems the author changed the gtkdatabox.h file from version 2.4.7 (which worked) to version 3.0 (which the xs dosn't work). If complied against the latst version 3.0 your Gtk2-Databox-0.001 examples will fail with: /usr/bin/perl: relocation error: /usr/lib/perl5/site_perl/5.8.6/i686-linux-thread-multi/auto/Gtk2/Databox/Databox.so: undefined symbol: gtk_databox_data_add_x_y It seems that the new v3 header file has gtk_databox_data_add instead of gtk_databox_data_add_x_y I have tried to simply change the names to get it to run, but have run into other problems in the examples. If I change the names in the header file from gtk_databox_data_add_x_y to gtk_databox_data_add It compiles, but I run into problems in the examples where you use gtk_databox_data_add_y So I figured I would ask. :-) Thanks. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: [ANNOUNCE] Gtk2::Ex::DBI-1.2 and Gtk2::Ex::Datasheet::DBI-0.8
On Mon, 15 Aug 2005 12:00:39 -0400 (EDT) >From: Dan <[EMAIL PROTECTED]> >Subject: [ANNOUNCE] Gtk2::Ex::DBI-1.2 and Gtk2::Ex::Datasheet::DBI-0.8 >I'm pleased to announce the next round of updates to Axis Not Evil, a >suit of Perl modules that combine to provide an alternative to a >'leading' software vendor's RAD design tool for database access. > >Project Page: >http://entropy.homelinux.org/axis_not_evil/ Hi, very nice website, but I found a small glitch in your downloads. Your http://entropy.homelinux.org/axis_not_evil/src/demo_application_package.tar.gz actually is a tar.bz2 file. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Subject: Progress Bar question
On Mon, 22 Aug 2005 05:53:47 -0400 (EDT) >Date: Mon, 22 Aug 2005 03:48:09 +0300 (EEST) >From: Gergely Korodi <[EMAIL PROTECTED]> >Subject: Progress Bar question You need to set up a timer to control the progressbar. #!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; my $window = Gtk2::Window->new('toplevel'); $window->signal_connect( delete_event => sub { Gtk2->main_quit; } ); $window->set_border_width(10); my $vbox = Gtk2::VBox->new( 0, 5 ); my $button = Gtk2::Button->new("Progress"); $button->signal_connect( clicked => \&cb1, $window ); $vbox->pack_start( $button, TRUE, TRUE, 0 ); my $progress = new Gtk2::ProgressBar; my $fraction = 0.0; $progress->set_fraction($fraction); $vbox->pack_start( $progress, TRUE, TRUE, 0 ); $window->add($vbox); $window->show_all; Gtk2->main; 0; # sub cb1 { my $timer = Glib::Timeout->add (100,\&show_progress); } sub show_progress{ $fraction += 0.01; if($fraction >= 1){return 0} #stops timer $progress->set_fraction($fraction); return 1; } __END__ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: imagmap
On Sat, 27 Aug 2005 21:26:13 -0400 (EDT) [EMAIL PROTECTED] wrote: >Re: imagmap Does anyone have a code snippet to load an image and as the mouse moves over it, display the rgb values of the pixel beneath the mouse pointer? Is this possible? Thanks. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Gnome2::Sound question
On Thu, 6 Oct 2005 12:00:48 -0400 (EDT) >Date: Thu, 6 Oct 2005 10:42:45 +0200 >From: Simon P?ter <[EMAIL PROTECTED]> >Subject: Re: Gnome2::Sound question >To: gtk-perl-list@gnome.org >Message-ID: <[EMAIL PROTECTED]> >Content-Type: text/plain; charset="iso-8859-2" > >Hi, > >Tazman Ordog 2005. okt_ber 2. 19.04 d_tummal ezt _rta: >> Hi List, >> >> I use Gnome2::Sound in one of my program. If the sound server is >> unreachable then I get error like this: "audio_alsa: no cards found!". >> Of course this must to be happends. I would like to know is there any >> chance to detect the connection to sound server before I turn on >> Gnome2::Sound? (On other hands perl-Gtk2 frozen after too many "audio_alsa: >> no cards found" error, I after ~ 20 errors the main window frozen...) > >I also don't know, but very interested. I've got same trouble. >Is there any way to check the connection to sound server before we try to use? Here are a couple of ideas. 1. Do "alsactl power 0" and check the results. 0 is the soundcard number. 2. Use Audio::DSP to try and setup the dsp, and check for an error. 3. Do an lsmod and check for "snd" -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Shopping Cart Tax Exempt Feature Broken
On Thu, 13 Oct 2005 12:00:46 -0400 (EDT) [EMAIL PROTECTED] wrote: >From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> >Subject: Shopping Cart Tax Exempt Feature Broken >Hopefully someone here will be willing to help me. Hi, you should submit this question to the perl.beginners maillist. Info on how to subscribe can be had by going to http://learnperl.org From just casually looking at your code, you do nothing to test for tax exempt status. And you don't show your &moneyfy sub. Any replies to here will be ignored. $main::global->{form}->{'taxexempt'} = $main::global->{userinfo}->{'taxexempt'}; $main::global->{form}->{'totalsalestax'} = &moneyfy( $main::global->{form}->{'precalcs'}, $main::global->{config}->{'precision'} ); -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Threads and Gtk2
On Thu, 20 Oct 2005 12:00:43 -0400 (EDT) [EMAIL PROTECTED] wrote: >Message: 1 >Date: Wed, 19 Oct 2005 11:28:49 -0700 >From: Javier Godinez <[EMAIL PROTECTED]> >Subject: Threads and Gtk2 >To: gtk-perl-list@gnome.org >Message-ID: > <[EMAIL PROTECTED]> >Content-Type: text/plain; charset=ISO-8859-1 > >Hello, > >Is there a way to gracefully stop a thread from a Gtk2 callback by >using a global? >I am not sure how to get out of the running thread as shown here: > ># >Any help will be greatly appreciated... >Thanks, Javier Godinez I will just mention 1 other little detail, which can cause messages like "a thread exited while 1 other was running". Before a thread can be joined, it must go to the end of it's code-block. So this is the basic thread model I use, where shared variables control the sleeping and dieing of the thread. I know goto's are currently out of favor, but it is a pretty useful here. sub work{ #the thread code block $|++; while(1){ if($thread{'die'} == 1){goto END } if ( $thread{'go'} == 1 ){ #do your stuff here in a loop and sprinkle the code with # if($thread{'go'} == 0){last} # if($thread{'die'} == 1){goto END} # in case you need to kill the thread or current code run # during a long running process $thread{'go'} = 0; #turn off self before returning }else { sleep 1 } } END: } # then when you want to exit your app, you can do sub clean_exit{ $thread{'die'} = 1; $thread->join; exit; } -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
How does semi-transparency work on the anti-aliased canvas?
Hi, This all started by someone asking how to make Venn diagrams in Perl. See attached example, reverse-ripped from the canvas demo. In the demo for the latest Gnome2-Canvas-1.002, in particular at the "canvas-primitives" tab. It has a "cadet-blue" ellipse, which is created on the anti-aliased canvas, like this: setup_item (Gnome2::Canvas::Item->new ($root, 'Gnome2::Canvas::Ellipse', "x1", 210.0, "y1", 80.0, "x2", 280.0, "y2", 140.0, "fill_color_rgba", 0x3cb37180, "outline_color", "black", "width_pixels", 0)); I can manipulate the "fill_color_rgba" hex number to give me a few different semi-transparent ellipses, but can anyone explain how the hex numbering actually works to produce the semi-transparent effect? The canvas demo, is set up, to allow you to choose a normal (not anti-aliased) example, which does it on the basis of using a stiple. It's alot uglier, but it is always how I thought it was done, coming from Tk. Thanks. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html canvas-primitives4 Description: Binary data ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Gtk2 apps killing my Perl/Tk apps
Hi, This is a really strange problem, and if anyone would know the answer, muppet would. :-) I have the latest gtk+-2.8.6, and the c-libs demo will cause the same problem, but since this is a gtk-perl list, the demo from Gtk2-1.110/gtk-demo does it too. To cause the problem, start a simple perl/Tk app, say ### #!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Table; my $mw= tkinit; $mw->geometry("400x400+100+100"); my $table = $mw->Scrolled('Table', -rows => 20, -columns => 50, -scrollbars => 'osoe', -takefocus => 1, # -fixedrows => 9, )->pack; foreach my $row (0 .. 8) { foreach my $col (0 .. 8) { my $cell = $table->Entry ( -width => 4, -text => "$col, $row"); $table->put ($row, $col, $cell); } } MainLoop; __END__ ## Then start the gtk-demo and when you double-click on an item in the left list( to start it's demo), the Perl/Tk app will seg-fault. If I restart the Tk app, the problem will not re-occur, it only happens the first time the gtk button is pressed after it's initial launch. I ran strace on the Perl/Tk apps, to see what happens differently when it seg-faults. Each time the lines readv(3, [{"_GTK_LOAD_ICONTHEMES", 20}, {"", 0}], 2) = 20 select(4, [3], [], [], NULL)= 1 (in [3]) ioctl(3, FIONREAD, [32])= 0 read(3, "\241 \220\33\1\0 \2\313\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 32) = 32 --- SIGSEGV (Segmentation fault) @ 0 (0) --- +++ killed by SIGSEGV +++ appear, and the only thing obvious is readv(3, [{"_GTK_LOAD_ICONTHEMES", 20}, {"", 0}], 2) = 20 So why does my Perl/Tk app get the _GTK_LOAD_ICONTHEME command? Why does my Tk app die, should'nt the Gtk2 app die if the c-lib is running over it's memory boundaries? Any answers other than to revert to an earlier gtk+ version? Thanks. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: gtk-perl-list Digest, Vol 19, Issue 16
On Wed, 16 Nov 2005 08:30:38 -0500 (EST) [EMAIL PROTECTED] wrote: >Message: 4 >Date: Wed, 16 Nov 2005 01:49:27 +0100 >From: "A. Pagaltzis" <[EMAIL PROTECTED]> >Subject: Re: Gtk2 apps killing my Perl/Tk apps >To: gtk-perl-list@gnome.org >Message-ID: <[EMAIL PROTECTED]> >Content-Type: text/plain; charset=utf-8 > >* zentara <[EMAIL PROTECTED]> [2005-11-15 20:55]: >> So why does my Perl/Tk app get the _GTK_LOAD_ICONTHEME command? > >I assume it___s because gtk2 is broadcasting it to all windows; >which normally should cause no problems. > >> Why does my Tk app die, should'nt the Gtk2 app die if the c-lib >> is running over it's memory boundaries? > >No memory boundaries are being run over. Tk reacts badly to the >reception of that command (atom? not sure about the X11 >terminology). > >In other words, this *may* be a bug in gtk2, but it *definitely* >is a bug in Tk. > >Just another reason to use gtk2 rather than Tk___ :-) > >Regards, >-- >#Aristotle Yeah, it seems that evolution applies to languages too.survival of the fittest. Gtk2 kills Tk. :-) But maybe the "intelligent design gods" will help Tk mutate and survive. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
how to use set_threadsafe
Hi, I'm looking at the thread_usage example from the latest gtk+-2.8.7 and the perl GTK2-1.111 and I'm already stymied. :-) The thread_usage example provided works fine, but the example is an object-oriented one, and it differs from the one from earlier versions, which was more of a functional style. Anyways. I have an example which was working under the older libraries I had, and wanted to see how far I could "push" the thread-safety capabilities. So my first step was just to ue the standard init statements used in the example. So I put the lines in the script below and the die statement causes a non-fatal warning: use Gtk2 qw/-init -threads-init/; die "Glib::Object thread safetly failed" unless Glib::Object->set_threadsafe (TRUE); The warning I get is: GLib-CRITICAL **: g_hash_table_foreach: assertion `hash_table != NULL' failed at ./basic-thread-test line 23. If I comment out the die statement, I don't get the error. The script runs fine either way. So what is set_threadsafe complaining about? Also, if anyone can give tips on how far the thread-safety mechanism can be pushed, it would be appreciated. Can you directly access widgets in the main thread from a worker thread? Thanks. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html basic-thread-test Description: Binary data ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: how to use set_threadsafe
On Fri, 18 Nov 2005 13:35:27 -0500 (EST) "muppet" <[EMAIL PROTECTED]> wrote: > >zentara said: >> The warning I get is: >> GLib-CRITICAL **: g_hash_table_foreach: assertion `hash_table != NULL' failed >> at ./basic-thread-test line 23. >This is not actually from the set_threadsafe() call. > >So, you're turning on threadsafety object tracking and then proceeding to >create your thread before creating any GObjects (that go all the way to perl). Thanks, that sure looks like it. I modified the code to start the thread after the main loop is up and running, and the error dissappears. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html basic-thread-test1 Description: Binary data ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: desktop exit signals
On Mon, 28 Nov 2005 21:13:39 +0100 Jaap Karssenberg <[EMAIL PROTECTED]> wrote: >Hi, > >I was wondering which signal I need to intercept if I want to know when >the desktop exits while my application is still open. I tried catching >SIGHUP, SIGTERM and SIGKILL but no luck so far. (The obvious purpose of >this is to save the state of the application before it exits.) > >I know this has been discussed before and the "right" way to do this >would be using gnome session. The problem is that I do not want to >depend on gnome libs unless really necessary. I have this working on ICEWM. It will save on a logout from X, but not a Control-Alt-Backspace. It will also save if you accidently hit the X in the Window Manager's toolbar. You can prevent Cntrl-Alt-BS in Xorg.conf, so it might be useful. #!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; # will save on a Window Manager logout under ICEWM # or clicking the WM X button. # but not a Control-Alt-Backspace $SIG{__DIE__} = sub {&save_it(); exit}; $SIG{INT} = sub {&save_it(); exit}; my $window = Gtk2::Window->new('toplevel'); $window->set_title('Z'); $window ->signal_connect( 'destroy' => \&save_it ); $window->set_border_width(10); $window->set_size_request(300,200); my $vbox = Gtk2::VBox->new( FALSE, 6 ); $window->add($vbox); $vbox->set_border_width(2); my $hbox= Gtk2::HBox->new( FALSE, 6 ); $vbox->pack_end($hbox,FALSE,FALSE,0); $hbox->set_border_width(2); $vbox->pack_end (Gtk2::HSeparator->new, FALSE, FALSE, 0); my $button = Gtk2::Button->new_from_stock('gtk-quit'); $hbox->pack_end( $button, FALSE, FALSE, 0 ); $button->signal_connect( clicked => \&delete_event ); $window->show_all(); Gtk2->main; # sub delete_event { Gtk2->main_quit; return FALSE; } # sub save_it{ open(FH,"> save.txt"); print FH 'saved '.time."\n"; close FH; exit; } __END__ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Announcement: Glib::Event module
On Sun, 27 Nov 2005 20:40:45 +0100 Marc Lehmann <[EMAIL PROTECTED]> wrote: >I am pleased to announce the (very alpha-ish) release of Glib::Event. Hi, I ran into a bit of a problem when trying your module. First, when I ran "perl Makefile.pl" I get an error: Looks good MakeMaker FATAL: prerequisites not found (Event 1) Please install these modules first and rerun 'perl Makefile.PL'. So I changed Makefile.pl from PREREQ_PM=> { Event => 1, ExtUtils::PkgConfig => 0, to PREREQ_PM=> { Event => 0, ExtUtils::PkgConfig => 0, then it installed. If I'm wrong, where do I get Event 1 ? The latest I have is .87 ? Or what mistake am I making? :-) -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Announcement: Glib::Event module
On Tue, 29 Nov 2005 13:51:25 -0500 zentara <[EMAIL PROTECTED]> wrote: >On Sun, 27 Nov 2005 20:40:45 +0100 >Marc Lehmann <[EMAIL PROTECTED]> wrote: > >>I am pleased to announce the (very alpha-ish) release of Glib::Event. > >Hi, I ran into a bit of a problem when trying your module. >First, when I ran "perl Makefile.pl" I get an error: > >Looks good >MakeMaker FATAL: prerequisites not found (Event 1) > Please install these modules first and rerun 'perl Makefile.PL'. > >If I'm wrong, where do I get Event 1 ? >The latest I have is .87 ? >Or what mistake am I making? :-) Sorry. Doh!! The search engines at cpan don't always work right. I found http://search.cpan.org/~jprit/Event-1.06/ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Why use Gtk2::Bin ?
Hi, I was just going through the great study-guide by Dirk van der Walt at http://forge.novell.com/modules/xfcontent/downloads.php/exam/documentation/ He makes a big point about the object heirarchies. I was just wondering, why are Windows and Buttons derived from Gtk2::Bin instead of Gtk2::Box? Does it make them more efficient? -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
another Gtk2 theme
Hi, I worked out this theme , based on BumbleBee, but it is easier on my eyes. :-) Screenshot-> http://zentara.net/gtk2-theme/screenshot-Z.jpg Tarball-> http://zentara.net/gtk2-theme/Z-Theme.tgz If you like it, have at it. :-) zentara -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: another Gtk2 theme
On Wed, 28 Dec 2005 13:55:26 -0500 zentara <[EMAIL PROTECTED]> wrote: >Hi, >I worked out this theme , based on BumbleBee, >but it is easier on my eyes. :-) > >Screenshot-> http://zentara.net/gtk2-theme/screenshot-Z.jpg >Tarball-> http://zentara.net/gtk2-theme/Z-Theme.tgz > >If you like it, have at it. :-) >zentara Ooops, prepend a www to tose addresses if your browser has trouble. Screenshot-> http://www.zentara.net/gtk2-theme/screenshot-Z.jpg Tarball-> http://www.zentara.net/gtk2-theme/Z-Theme.tgz -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: what's the name?
On Thu, 29 Dec 2005 17:09:57 +0700 Beast <[EMAIL PROTECTED]> wrote: >Thanks. But any idea what widget is used in this screen? >It allow user to select some area which toggle the hours and days. It looks like a Table to me. The rows are the days of the week, and the columns are the hours of the day. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Can a popup catch keys?
Hi, I've been trying to figure out the way popup's and eventbox's handle keys. It seems that an eventbox in a popup will just pass the key signals onto the controlling terminal. Is there a way to make the popup catch the 'q' ? Furthermore, if I don't catch the mouse button signals, a click will be transparent and invoke my window manager's menu from the desktop when the window is a popup. What are the tips, tricks, and secrets for popups? Thanks. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html gtk2_popup-keys.pl Description: Perl program ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Space and Enter triggering buttons
On Wed, 4 Jan 2006 13:02:16 -0500 zentara <[EMAIL PROTECTED]> wrote: >Hi, >How do you solve the problem of the space or enter >key triggering the last button that was clicked with a mouse. > >Here is a simplified example with 1 button. When the app >has focus, hitting the space or enter key signals the button. >I want to prevent that. Yeah, it was pretty simple $window->signal_connect( 'key_press_event' => sub{ return 1 } ); that prevents the default focus from connecting any space or enter to the last focussed button. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
background-stipple on TextBuffer
Hi, Is it possible to set a background-stipple as a background on a text widget? I can set this stipple up with no warnings, but it dosn't seem to have any visible effect. The red tag seems to work OK, but the background-stipple dosn't work. Does it have something to do with the $colormap setup? #!/usr/bin/perl use warnings; use strict; use Gtk2 -init; # Copy the entire file into a string (str) my $str; my $file = shift || $0; open( TEST, "< $file" ) or die "Cannot open test.txt\n"; while () { $str .= $_;} close TEST; my $window = Gtk2::Window->new; # a simple xpm for stipple my @z_xpm = ( '20 3 2 1', ' c None', '+ c #1A1A1A', '+ + + + + + + + + + ', '+ + + + + + + + + + ', '+ + + + + + + + + + ',); #my $colormap = Gtk2::Gdk::Colormap->get_system; my $colormap = $window->get_default_colormap; my $pixmap = Gtk2::Gdk::Pixmap->colormap_create_from_xpm_d (undef, $colormap, undef, @z_xpm ); # Create a textbuffer to contain that string my $textbuffer = Gtk2::TextBuffer->new(); $textbuffer->set_text($str); my $zmap = $textbuffer->create_tag('zmap', 'background-stipple' => $pixmap ); my $rmap = $textbuffer->create_tag('rmap', 'background' => 'red' ); $textbuffer->insert_with_tags_by_name ($textbuffer->get_start_iter,"\nYADDA YADDA\n",'rmap'); $textbuffer->insert_with_tags_by_name ($textbuffer->get_start_iter,"No stipple here\nYADDA\nYADDA\n",'zmap'); # Create a textview using that textbuffer my $textview = Gtk2::TextView->new_with_buffer($textbuffer); # Add the textview to a scrolledwindow my $scrolledwindow = Gtk2::ScrolledWindow->new( undef, undef ); $scrolledwindow->add($textview); $window->signal_connect( destroy => sub { Gtk2->main_quit; } ); $window->add($scrolledwindow); $window->set_default_size( 500, 400 ); $window->show_all; Gtk2->main; __END__ Thanks -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: signal_handlers_destroy()
On Tue, 10 Jan 2006 18:18:20 +0100 Mario Ospelt <[EMAIL PROTECTED]> wrote: >I wanted to use the signal_handlers_destroy() method to remove the >connected signals of my button. But something doesn't work. I always get >this error: > >Can't locate object method "signal_handlers_destroy" via package >"Gtk2::Button" > >Why can't the method be found? Is it spelled differently? Maybe you are looking for signal_handler_disconnect() ? Followed by an undef ? #!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; sub callback{ my ($button, $data) = @_; print "Hello again - $data was pressed\n"; } sub delete_event{ Gtk2->main_quit; return FALSE; } my $window = Gtk2::Window->new('toplevel'); $window->set_title("Hello Buttons!"); $window->signal_connect(delete_event => \&delete_event); $window->set_border_width(10); my $box1 = Gtk2::HBox->new(FALSE, 0); $window->add($box1); my $button1 = Gtk2::Button->new("Button 1"); $button1->signal_connect(clicked => \&callback, 'button 1'); $box1->pack_start($button1, TRUE, TRUE, 0); $button1->show; my $button2 = Gtk2::Button->new("Button 2"); my $sigbut2 = $button2->signal_connect(clicked => \&callback, 'button 2'); $box1->pack_start($button2, TRUE, TRUE, 0); $button2->show; $box1->show; $button2->signal_handler_disconnect($sigbut2 ); undef $sigbut2; $window->show; Gtk2->main; __END__ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: background-stipple on TextBuffer
On Tue, 10 Jan 2006 13:19:04 -0500 zentara <[EMAIL PROTECTED]> wrote: >Hi, Is it possible to set a background-stipple as a >background on a text widget? >I can set this stipple up with no warnings, but it dosn't >seem to have any visible effect. The red tag seems to >work OK, but the background-stipple dosn't work. > >Does it have something to do with the $colormap setup? Doh! Ignore my previous post. I got a pixmap and bitmap confused. A stipple needs to be a Gtk2::Gdk::Bitmap and be used in conjunction with a solid color tag. I was "hoping" I could use a pixmap as a background, like a watermark on a TextView. Nope!. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: packaging for windows
On Thu, 12 Jan 2006 12:49:08 +0100 Jaap Karssenberg <[EMAIL PROTECTED]> wrote: >Hi, > >Did anyone look into packaging perl/gtk applications for windows ? > >I have some users that would really like a package that "Just Works" >(when perl was installed already). >I installed my application manually on one system but it involved >manually unzipping a lot of dll's which is quite obscure. > >Thanks, I would write to ActiveState and ask them to include it in their Perl distribution, like they do with Tk. Most Windows users wouldn't be able to use Tk, if it wasn't for the pre-packaging that ActiveState does. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: packaging for windows
On Thu, 12 Jan 2006 19:41:10 +0300 "Konovalov, Vadim" <[EMAIL PROTECTED]> wrote: >But I very doubt you'll convince ActiveState perl people to include Gtk into >Perl distribution > >So, this is impossible because its not practical :) > >Also imagine including wxWidgets here and so on... Well couldn't they make separate ppm's for Gtk2 and Wx? They do it for Zinc? -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
A visual snippet browser
Hi, I needed something to do to get some experience with textbuffers, so I made a visual grep using Gtk2. A screenshot and the file is at http://zentara.net/vgrep Feel free to offer improvements, use it, etc. Specifically, I had to resort to a method of reprinting the file to include/remove line numbers for copy&pasting. I was wondering if there was a way to filter out the line numbers upon a selection or copy event? Is there some trick to tag some text so it is visible to see, but invisible to a copy/selection? -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: A visual snippet browser
On Thu, 19 Jan 2006 21:44:21 +0100 Emmanuele Bassi <[EMAIL PROTECTED]> wrote: >On Thu, 2006-01-19 at 15:06 -0500, zentara wrote: >> Specifically, I had to resort to a method of reprinting >> the file to include/remove line numbers for copy&pasting. > >You could use the Gtk2::SourceView module, binding the gtksourceview >library, if you need such things like line numbering, bracket matching >and such. >Ciao, > Emmanuele. Hi, Gtk2::SourceView works great. It gives syntax highlighting too. Very nice. Where were you yesterday. :-) -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Progress bar help
On Fri, 20 Jan 2006 10:05:06 -0600 Daniel Davidson <[EMAIL PROTECTED]> wrote: >Can someone also explain to me what pluse does? I think I know but I am >not sure. Here is a simple pulse snippet. #!/usr/bin/perl use warnings; use strict; use Gtk2; Gtk2->init(); my $window = new Gtk2::Window; my $pbar = new Gtk2::ProgressBar; $pbar->set_pulse_step(.1); # set_text not allowed in pulser # ! $pbar->set_text('foobar'); my $vb = new Gtk2::VBox(0, 0); my $b = new Gtk2::Button('Quit'); $window->add($vb); $vb->add($pbar); $vb->add($b); $b->signal_connect('clicked', sub {Gtk2->main_quit}); $window->signal_connect('destroy', sub {Gtk2->main_quit}); $window->show_all(); my $timer = Glib::Timeout->add (100,\&show_progress); # timer will run until callback returns false Gtk2->main; # sub show_progress{ $pbar->pulse(); return 1; } __END__ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: gtk2-perl on path to world domination
On Fri, 20 Jan 2006 22:56:40 -0500 muppet <[EMAIL PROTECTED]> wrote: >http://news.com.com/HP+to+sell+Linux+PCs+across+Latin+America/ >2100-7344_3-6028325.html > > >Mandriva ships Gtk2-Perl in their default install. (somebody correct >me if i'm wrong...) World domination? Well then, that makes muppet our "glorious leader". :-) -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
2 different text styles in same program
Hi, I trying some different ways to set different styles in the same script. The following script has 2 textboxes. One on the left is for line numbers, and the one on the right is for the lines. Now I can set the color for the right box with Gtk2::Rc->parse_string but the method I use with the left textview is $textview_l->modify_bg('GTK_STATE_NORMAL', $black); and dosn't work. Anyone know why? #!/usr/bin/perl use warnings; use strict; use Glib qw(FALSE TRUE); use Gtk2 -init; #- 1 way works--- Gtk2::Rc->parse_string(<<__); style "bg_text_blue" { base[NORMAL] = "#FF" GtkTextView::cursor-color = "white" } widget "*my_name*" style "bg_text_blue" __ ##-- my $black = Gtk2::Gdk::Color->new (0,0,0); # create a window with linked scrolled text views. my $window = Gtk2::Window->new; $window->signal_connect (destroy => sub {Gtk2->main_quit;return FALSE}); $window->set_size_request(500,300); my $hbox = Gtk2::HBox->new(); $hbox->set( "border_width" => 0 ); $window->add($hbox); my $scroll = Gtk2::ScrolledWindow->new; my $vadj = $scroll->get_vadjustment; my $scroll_l = Gtk2::ScrolledWindow->new(undef,$vadj); $scroll_l->set_policy ('never', 'never'); my $textview_l = Gtk2::TextView->new; ##--- way 2 dosn't work--- $textview_l->modify_bg('GTK_STATE_NORMAL', $black); ## my $buffer_l = $textview_l->get_buffer; create_tags($buffer_l); $scroll_l->add($textview_l); $hbox->pack_start($scroll_l,0, 0, 1 ); # expand?, fill?, padding; #$$ my $textview = Gtk2::TextView->new; $textview->set_name("my_name1"); $scroll->add($textview); $hbox->pack_start($scroll,1, 1, 1 ); # expand?, fill?, padding; my $buffer = $textview->get_buffer; create_tags($buffer); $window->show_all; #insert some text my @lines = `ps auxww`; insert_w_lines([EMAIL PROTECTED]); Gtk2->main; ##3 sub insert_w_lines{ my $aref = shift; my @lines = @{$aref}; my $lcount = 0; foreach my $line (@lines){ $lcount++; my $lineI = sprintf "%03d\n", $lcount; $buffer_l->insert_with_tags_by_name ($buffer_l->get_end_iter, $lineI, 'col'); $buffer->insert_with_tags_by_name($buffer->get_end_iter, " $line",'blue'); } } 3 sub create_tags{ my $buffer = shift; $buffer->create_tag('blue', foreground => 'lightblue', ); $buffer->create_tag('col', foreground => 'green', ); } # __END__ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
linked scrolled text inaccuraccies
Hi again, Thanks muppet,for your good example. It works, but in the intervening time I tried to hack a linked scrollbar, and it didn't work as described below. I will mention that if I use set_default_size instead of set_size_request the window expands with the widget's size. I guess I have to think about it more. I'm sorry to pester you with these textview questions, but I'm finding some weird inconsistencies. I hope someone can explain this. I link the 2 textviews below, with a vertical adjustment. At the line: my $scroll_l = Gtk2::ScrolledWindow->new(undef,$vadj); when I link the $vadj scroll, the scrolled window WILL NOT goto the end mark at line 500, it ends up at around line 482. If I make it my $scroll_l = Gtk2::ScrolledWindow->new(undef,undef); It will go to the end mark, but of course they won't be linked. Further examination shows that if I drag the window, so that it is the full size of my monitor, the scrolled window does show the end line. What's wrong? I would like to know since linking vadjustments is something I might want to do. Or is this just something to avoid? P.S. I modified your example to insert 500 lines, and it does not scroll to the end mark either. Does it work for you? Is this a window manager problem? # #!/usr/bin/perl use warnings; use strict; use Glib qw(FALSE TRUE); use Gtk2 -init; #- 1 way works--- Gtk2::Rc->parse_string(<<__); style "bg_text_blue" { base[NORMAL] = "#FF" GtkTextView::cursor-color = "white" } style "bg_text_black" { base[NORMAL] = "#00" base[INSENSITIVE] = "#00" GtkTextView::cursor-color = "white" } widget "*my_normal*" style "bg_text_blue" widget "*my_line*" style "bg_text_black" __ ##-- # create a window with linked scrolled text views. my $window = Gtk2::Window->new; $window->signal_connect (destroy => sub {Gtk2->main_quit;return FALSE}); $window->set_size_request(500,300); my $hbox = Gtk2::HBox->new(); $hbox->set( "border_width" => 0 ); $window->add($hbox); ###-- column numbers textview my $scroll = Gtk2::ScrolledWindow->new; my $vadj = $scroll->get_vadjustment; ### ## ## problem lines here (undef,undef) works, but when ## I link them, scroll to end comes up short by 18 lines my $scroll_l = Gtk2::ScrolledWindow->new(undef,$vadj); #my $scroll_l = Gtk2::ScrolledWindow->new(undef,undef); ## # ## $scroll_l->set_policy ('never', 'never'); my $textview_l = Gtk2::TextView->new; $textview_l->set_name("my_line1"); $textview_l->set_cursor_visible(0); $textview_l->set_editable(0); $textview_l->set_sensitive(0); my $buffer_l = $textview_l->get_buffer; create_tags($buffer_l); $scroll_l->add($textview_l); $hbox->pack_start($scroll_l,0, 0, 1 ); # expand?, fill?, padding; #---main text view--- my $textview = Gtk2::TextView->new; $textview->set_name("my_normal1"); $textview->set_wrap_mode('none'); $scroll->add($textview); $hbox->pack_start($scroll,1, 1, 1 ); # expand?, fill?, padding; my $buffer = $textview->get_buffer; create_tags($buffer); #insert some lines insert_w_lines(); $window->show_all; Gtk2->main; ##3 sub insert_w_lines{ my @lines = (1..500); my $lcount = 0; foreach my $line (@lines){ $lcount++; my $lineI = sprintf "%03d\n", $lcount; $buffer_l->insert_with_tags_by_name ($buffer_l->get_end_iter, $lineI, 'col'); $buffer->insert_with_tags_by_name($buffer->get_end_iter, " $line\n",'blue'); } my $end_mark = $buffer->create_mark( 'end', $buffer->get_end_iter, FALSE ); $textview->scroll_to_mark( $end_mark, 0.0, FALSE, 0.0, 1.0 ); return FALSE; } 3 sub create_tags{ my $buffer = shift; $buffer->create_tag('blue', foreground => 'lightblue', ); $buffer->create_tag('col', foreground => 'green', ); } # -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: trouble with reading from pipes
On Wed, 25 Jan 2006 12:42:31 -0600 Daniel Davidson <[EMAIL PROTECTED]> wrote: >This may be a problem with my understanding of perl and not with GTK, >but here goes anyway. > >In my program I create three pairs of pipes: > >pipe($fractread,$fractwrite); >pipe($progread,$progwrite); >pipe($statusread,$statuswrite); > >which I plan to use to get information from forked functions. > >I also set up a watcher to notice when one of these pipes are written to >by the child process. > >$tag = Gtk2::Helper->add_watch(fileno($fractread), 'in', \&setstatus); >sub setstatus{ > $progressbar->set_text(<$progread>); > $progressbar->set_fraction(<$fractread>); > Gtk2->main_iteration while Gtk2->events_pending; > print "in status\n"; return 1; #so callback continues >} > >And finally in the child process I print to the pipe. > print $fractwrite $count/$totaldays; > print $statuswrite "Populating Database $count of $totaldays >".int($count/$totaldays*100)."%"; > >Only problem is that nothing ever happens, even though I know the child >process is running. Any ideas what I am screwing up? It just so happens today I was studying the Chapter cover Gtk2::Helper. Get this great tutorial at: http://forge.novell.com/modules/xfcontent/downloads.php/exam/documentation/ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: trouble with reading from pipes
On Wed, 25 Jan 2006 16:21:02 -0500 (EST) "muppet" <[EMAIL PROTECTED]> wrote: >Actually, it's a subtle interaction of various pieces. > >Watch out -- you're implicitly returning nonzero here because the print is >your block's last statement. HOwever, the return value of the callback is >supposed to be a boolean indicating whether the callback is to stay installed. > >Note lack of a newline to flush the output buffer. >> Only problem is that nothing ever happens, even though I know the child >> process is running. Any ideas what I am screwing up? > >Don't use buffered IO and blocking reads with IO watches. The IO watch fires >when *real* input arrives, and using buffered IO with that messes with your >mind. Also, the <> operator will attempt to read up to a $/, and will block >until it does. By default, $/ is "\n", and you're not writing a "\n" to your >output stream. > >So, your callback is being invoked once, and is hanging on the read, waiting >for a newline to show up. >Set $|=1 (autoflush) in the child, and use sysread() in your IO watch >callbacks. By the way, when using sysread(), you must be prepared to handle >partial line reads. >This is another FAQ; i believe the solution in the FAQ contains misleading >code. Any volunteers to update that? I'll help you out, if no one better qualified cares to do it. :-) There is an excellent example showing the sysread and autoflushing of pipes at http://forge.novell.com/modules/xfcontent/file.php/exam/documentation/study-14-09-05.tar.gz in the sample program "count_down.pl" and it is explained in x3545.html -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: widget subclassing problem
On Thu, 26 Jan 2006 12:45:02 -0500 (EST) "muppet" <[EMAIL PROTECTED]> wrote: >Two problems here: first, $my_text is not defined (i presume you have a >global in your copy), and second, the properties have not yet been set in >INIT_INSTANCE. Instantiation is basically a sequence of INSTANCE_INIT and a >bunch of SET_PROPERTYs. You'll have to create the Label with no string, and >then provide a property setter or SET_PROPERTY that puts the text into the >label with set_text(). I know this is a hack, but what do you think of just building the widgets in the SET_PROPERTY, once the options are known? sub INIT_INSTANCE { my $self = shift; } sub SET_PROPERTY { my ($self, $pspec, $val) = @_; #print Dumper([EMAIL PROTECTED]),"\n"; print "$self\n"; print $pspec->get_name,"\n"; print "$val\n"; if ($pspec->get_name eq 'my_text') { $self->{my_text} = $val; } my $label = Gtk2::Label->new ( $self->{my_text} ); $label->set_alignment (0.0, 0.5); # set left horizontal alignment and middle $label->set_text ( $self->{my_text} ); my $entry = Gtk2::Entry->new(); $self->pack_start($label, FALSE, FALSE, 2); $self->pack_start($entry, FALSE, FALSE, 2); $label->show(); $enrty->show(); $self->{label} = $label; $self->{entry} = $entry; } -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: trouble with reading from pipes
On Thu, 26 Jan 2006 13:30:22 -0600 Daniel Davidson <[EMAIL PROTECTED]> wrote: >Thanks everyone for the help yesterday. > >I now have a question about how to handle the partial line reads. Right >now I am guessing that the best way to do this is to keep a copy of the >last buffer read laying around, and attach that to the next read in case >the data needed is split on last previous, first next boundary. Then I >can just to a =~/\n(.*?)\n.*?$/ and the last full line will be in $1. >Is there another (better?) preferred way to do this. Seems like sysseek >should be useful, but I cannot get it to work. You can't seek on a pipe. You will have to save previous output in a buffer. > >Is there also a way to monitor if any new information has been passed to >a readable filehandle. You can read "perldoc -q filehandle" and look for the section "How can I tell if a character is waiting on a filehandle?" It tells of a method to detect if there is any unsent pipe data. You can find the amount, then sysread that amount.. sort of the opposite of flushing.you are sucking :-) > >Dan > >___ >gtk-perl-list mailing list >gtk-perl-list@gnome.org >http://mail.gnome.org/mailman/listinfo/gtk-perl-list > > -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
base64 encoded images as styles
Hi, This is just something I was looking at, in case I wanted to put small base64 encoded images in a self-contained script. Is it somehow possible to setup a style, with the data from the base64 encoded string? If I write the png out to a tmp file, and have a .gtkrc file to load, it works, but I would like to avoid making a temp file. #!/usr/bin/perl use warnings; use strict; use Gtk2 -init; use MIME::Base64 qw( decode_base64 ); #a base64 encoded small png my $bg64 = 'iVBORw0KGgoNSUhEUgEYCAIAAAC0rgCNBmJLR0QA+QD4AOZO2ex2CXBI WXMAAAsOAAALDgFAvuFBB3RJTUUH1AUICxwUuNc1xwAAAENJREFUeNptyaENgEAQAMHP7vWv 6IdgqICcJQR3oYXnEQgMdqYt89RG31ofN/uxclUhooEKSiBEvP5zGuDnIlUnmfkAnDYTH2CoCOEA SUVORK5CYII='; my $image_data = decode_base64($bg64); # if you want to create the file bg.png # open (FH,"> bg.png"); # print FH $image_data ; # close FH; my $loader = Gtk2::Gdk::PixbufLoader->new; $loader->write ($image_data); $loader->close; my $pixbuf = $loader->get_pixbuf; my $image = Gtk2::Image->new_from_pixbuf ($pixbuf); my $pb = $image->get_pixbuf; #this works when the style string below #is put in ./gtkrc #Gtk2::Rc->parse ('gtkrc'); #this won't work with any variable #=head Gtk2::Rc->parse_string(<<__); style "default" { bg_pixmap[NORMAL] = $image_data } class "*" style "default" __ #=cut my $window = Gtk2::Window->new('toplevel'); $window->signal_connect('delete_event' => sub { exit;}); $window->set_border_width(5); $window->set_position('center_always'); $window->set_default_size(500,500); $window->show(); Gtk2->main(); ### __END__ Thanks, -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Ending up with Zombie process
On Mon, 30 Jan 2006 11:08:12 +0100 "Eisenknapp, Josef" <[EMAIL PROTECTED]> wrote: >Hello again >The more complex my program is, the more questions i have :-) I know what you mean. :-) >sub watch_callback{ > >print "callback called\n"; >my ($fh) = @_; > >my $line; >$fh->sysread($line,1000); >chomp $line; >if($line){ > print $line. "\n"; >} >else{ 1 while wait != -1 ; # avoid zombies > print "remove helper\n"; > Gtk2::Helper->remove_watch($helper_tag); >} > >return TRUE; >} >This works pretty fine, but when the process "write_to_fff.pl" >terminates it becomes a ZOMBI. > >Can anyone tell me how to avoid this? Add 1 while wait != -1 ; # avoid zombies at the point indicated above. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Resizing the mainwindow and displaying SVG's
Hi, I've been playing around with the recently announced Gnome2::Rsvg module, and tried to make a script that would automatically resize the svg after the mainwindow is resized. I've come up with the following script, which I need to somehow speed up. The script works, but it seems to hesitate as the configure event goes through each of it's calls as the window is resized with a corner drag. Is there some way, to detect when the resize has finished? So that I can only do the reloading of the svg after the corner-drag has ended? P.S. An interesting effect of auto-expansion occurs if you don't take a fraction < 1 on the size request. $vp->set_size_request(.9*$x,.9*$y); #!/usr/bin/perl use warnings; use strict; use Glib qw(TRUE FALSE); use Gnome2::Rsvg; Gtk2->init; my $file = shift || die "Need an svg file $!\n"; my $img; my $mw = Gtk2::Window->new; $mw->signal_connect (delete_event => sub { Gtk2->main_quit }); my $vbox = Gtk2::VBox->new (FALSE, 4); $vbox->set_border_width (4); $vbox->show; # Create the main box my $vp = Gtk2::Viewport->new(undef, undef); # Layout the stuff $vbox->pack_start ($vp, TRUE, TRUE, 0); $vp->show; $mw->add( $vbox ); get_svg(400,400); $mw->signal_connect (event_after => \&event_after); $mw->show; Gtk2->main; 3 sub get_svg { my ($x,$y) = @_; $vp->remove($img) if defined $img; #use the max specs to resize to window size, so make zoom huge my $pb = Gnome2::Rsvg->pixbuf_from_file_at_zoom_with_max($file,15,15,$x,$y); # ($file, x_zoom, y_zoom, max_x, max_y ) $img = Gtk2::Image->new_from_pixbuf($pb); $vp->add($img); $img->show; #will auto expand #$vp->set_size_request($x,$y); $vp->set_size_request(.9*$x,.9*$y); $vp->show; } # sub event_after { my ($mw, $event) = @_; return FALSE unless $event->type eq 'configure'; my ($x, $y) = $mw->get_size; print "$x $y\n"; get_svg($x,$y); return FALSE; } __END__ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
intuitive concept of iter
Hi, Can anyone explain what an "iter" is? I see it used in the docs for TextView, TreView, etc, indifferent contexts, as if it is some basic entity. Can someone define what an iter is, and why is it so intertwined in the workings of Gtk2? Are there any real-world analogies? Thanks -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: intuitive concept of iter
On Thu, 2 Feb 2006 13:29:11 -0500 zentara <[EMAIL PROTECTED]> wrote: >Hi, >Can anyone explain what an "iter" is? Thanks everyone, the little iter is starting to make sense :-) -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Move the focus along ( Tab keypress? )
On Fri, 03 Feb 2006 12:03:50 +1100 Daniel Kasak <[EMAIL PROTECTED]> wrote: >Greetings. > >I'm trying to trap an Enter keypress and create a Tab keypress ( or >otherwise move the focus along ). Try this: $window->child_focus('tab-forward'); #!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; use Gtk2::Gdk::Keysyms; my $window = Gtk2::Window->new('toplevel'); $window->signal_connect( 'key_press_event' => \&process_entry_keypress ); $window->signal_connect( 'destroy' => sub { Gtk2->main_quit } ); $window->set_border_width(10); #->set_size_request(300,200); $window->set_default_size(300,200); my $vbox = Gtk2::VBox->new( FALSE, 6 ); $vbox->set_size_request(0,0); $window->add($vbox); $vbox->set_border_width(2); my $hbox= Gtk2::HBox->new( FALSE, 6 ); $vbox->pack_end($hbox,FALSE,FALSE,0); $hbox->set_border_width(2); $vbox->pack_end (Gtk2::HSeparator->new, FALSE, FALSE, 0); my $button = Gtk2::Button->new_from_stock('gtk-quit'); $hbox->pack_end( $button, FALSE, FALSE, 0 ); $button->signal_connect( clicked => sub { Gtk2->main_quit } ); for(1..3){ my $button = Gtk2::Button->new ("Action$_"); $vbox->pack_start($button,0,0,0); } $window->show_all(); Gtk2->main; # sub process_entry_keypress { my ( $widget, $event ) = @_; if ( $event->keyval == $Gtk2::Gdk::Keysyms{ Return } || $event->keyval == $Gtk2::Gdk::Keysyms{ KP_Enter } ) { my $new_event = Gtk2::Gdk::Event::Key->new('key-press'); $event->keyval($Gtk2::Gdk::Keysyms{'Tab'}); $window->propagate_key_event($new_event); $window->child_focus('tab-forward'); return TRUE;#prevents the Exit button from triggering } if ( $event->keyval == $Gtk2::Gdk::Keysyms{ Tab } ){ print "An Tab key has been pressed!\n"; } return FALSE; } __END__ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
treeview and column indices
Hi, I've been trying to get the complex TreeView model into my head, and ran into a little roadblock, which I can't seem to find the answer to. The script below is from the novell-study-guide examples, modified to have some child indices and a second column. My problem comes when editing column 1. In the original script's callback &cell_edited, he derived the column from the $cell. my $column = $cell->get_data('column'); This works for column 0 and it's descendants, but when I click on column 1, it always returns 0. So I had to resort to adding a data-rider to the cellrenderer, to mark it as column 0 or column 1. $renderer1->{ 'column' } = 1; So is this the way to go in this type of situation, or am I missing the way to get the right indices when I click on column 1 ? The $cell being passed to the callback is different for column 0 and column 1, so why would my $column = $cell->get_data('column'); return 0 for column1 ? #! /usr/bin/perl -w use strict; use Gtk2 '-init'; use Glib qw/TRUE FALSE/; use Data::Dumper; my $window = Gtk2::Window->new( 'toplevel' ); $window->signal_connect( 'delete_event' => sub { Gtk2->main_quit; } ); $window->set_border_width( 5 ); $window->set_position( 'center_always' ); #this vbox will geturn the bulk of the gui my $vbox = &ret_vbox(); #add and show the vbox $window->add( $vbox ); $window->show(); #our main event-loop Gtk2->main(); sub ret_vbox { my $vbox = Gtk2::VBox->new( FALSE, 5 ); my $sw = Gtk2::ScrolledWindow->new( undef, undef ); $sw->set_shadow_type( 'etched-out' ); $sw->set_policy( 'automatic', 'automatic' ); $sw->set_size_request( 300, 300 ); $sw->set_border_width( 5 ); my $tree_store = Gtk2::TreeStore->new( qw/Glib::String Glib::String / ); #fill it with arbitry data foreach ( 1 .. 30 ) { my $parent_nr = $_; #the iter is a pointer in the treestore. We #use to add data. my $iter = $tree_store->append( undef ); $tree_store->set( $iter, 0 => "Parent $parent_nr" ); $tree_store->set( $iter, 1 => "--" ); foreach ( 1 .. 3 ) { my $iter_child = $tree_store->append( $iter ); $tree_store->set( $iter_child, 0 => "Child $_ of Parent $parent_nr" ); } } my $tree_view = Gtk2::TreeView->new( $tree_store ); $tree_view->set_reorderable( 1 );#drag and drop reordering my $tree_column = Gtk2::TreeViewColumn->new(); $tree_column->set_title( "Click to sort" ); my $renderer = Gtk2::CellRendererText->new; #add a data rider to store column $renderer->{ 'column' } = 0; $renderer->set_property( 'editable', TRUE ); $renderer->signal_connect( edited => \&cell_edited, $tree_store ); $tree_column->pack_start( $renderer, FALSE ); $tree_column->add_attribute( $renderer, text => 0 ); $tree_view->append_column( $tree_column ); #second column my $tree_column1 = Gtk2::TreeViewColumn->new(); $tree_column1->set_title( "-" ); my $renderer1 = Gtk2::CellRendererText->new; #add a data rider to store column $renderer1->{ 'column' } = 1; $renderer1->set_property( 'editable', TRUE ); $renderer1->signal_connect( edited => \&cell_edited, $tree_store ); $tree_column1->pack_end( $renderer1, FALSE ); $tree_column1->add_attribute( $renderer1, text => 1 ); $tree_view->append_column( $tree_column1 ); $tree_view->set_search_column( 0 ); $tree_column1->set_sort_column_id( 0 ); $tree_view->set_reorderable( TRUE ); $sw->add( $tree_view ); $vbox->pack_start( $sw, TRUE, TRUE, 0 ); $vbox->show_all(); return $vbox; } ### sub cell_edited { print "@_\n"; my ( $cell, $path_string, $new_text, $model ) = @_; # print Dumper( [ \$cell ] ), "\n"; # my @props = $cell->list_properties; # print join "\n",@props; # print "@props\n\n"; # foreach my $prop( @props ){ # print Dumper([\$prop]),"\n"; # } my $path = Gtk2::TreePath->new_from_string( $path_string ); print "$path_string\n"; my @indices = $path->get_indices; print "indices->@indices\n"; # the original get column, which returns 0 for column 1 #my $column = $cell->get_data('column'); # this is what I did to get the column number my $column = $cell->{ 'column' }; print "column->$column\n"; my $iter = $model->get_iter( $path ); $model->set_value( $iter, $column, $new_text ); return FALSE; } __END__ Thanks. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
outputting pdf with Cairo 0.3
Hi, Does anyone have an example of outputting pdf from Cairo? It says in the docs it supports pdf output, but I can only find png output. Thanks -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: outputting pdf with Cairo 0.3
On Fri, 10 Feb 2006 12:26:48 -0500 zentara <[EMAIL PROTECTED]> wrote: >Hi, > >Does anyone have an example of outputting pdf >from Cairo? It says in the docs it supports pdf >output, but I can only find png output. > >Thanks I figured it out. Well having to figure these things out, is good for me. ;-) First you need the latest Cairo built with --enable-pdf Then here is a modified version of the Cairo-0.3 example script, that outputs pdf instead of png. #!/usr/bin/perl use strict; use warnings; use Cairo; use constant { IMG_WIDTH => 640, IMG_HEIGHT => 480, M_PI => 3.14159265, }; die "pdf backend not supported" unless (Cairo::HAS_PDF_SURFACE); my $pdf_out = "$0.pdf"; my $surf = Cairo::PdfSurface->create ($pdf_out, IMG_WIDTH, IMG_HEIGHT); my $cr = Cairo::Context->create ($surf); $cr->rectangle (0, 0, IMG_WIDTH, IMG_HEIGHT); $cr->set_source_rgba (1, 1, 1, 0.5); $cr->fill; # black $cr->save; $cr->set_source_rgba (0, 0, 0, 0.5); $cr->translate (IMG_WIDTH / 2, IMG_HEIGHT - (IMG_HEIGHT / 4)); do_star (); $cr->restore; # red $cr->save; $cr->set_source_rgba (1, 0, 0, 0.5); $cr->translate (IMG_WIDTH / 2, IMG_HEIGHT / 4); do_star (); $cr->restore; # green $cr->save; $cr->set_source_rgba (0, 1, 0, 0.5); $cr->translate (IMG_WIDTH / 4, IMG_HEIGHT / 2); do_star (); $cr->restore; # blue $cr->save; $cr->set_source_rgba (0, 0, 1, 0.5); $cr->translate (IMG_WIDTH - (IMG_WIDTH / 4), IMG_HEIGHT / 2); do_star (); $cr->restore; $cr->show_page; ### sub do_star { my $mx = IMG_WIDTH / 3.0; my $count = 100; foreach (0..$count-1) { $cr->new_path; $cr->move_to (0, 0); $cr->rel_line_to (-$mx, 0); $cr->stroke; $cr->rotate ((M_PI * 2) / $count); } } __END__ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: outputting pdf with Cairo 0.3
On Fri, 10 Feb 2006 20:15:45 +0100 Torsten Schoenfeld <[EMAIL PROTECTED]> wrote: >(Keep in mind that the text rendering functionality cairo provides is >called a "toy API" for a reason. Use pango's cairo glue to get better >results should you need them.) Where would I look for pango's cairo glue, for Perl, in the pango markup stuff? And do you ever think the Gnome::Canvas will have ps output, like Tk? zentara -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Gtk2::FileChooser - hour and minute stats
Hi, I saw this question on the newsgroups today, and it made me think about this shortcoming in the FileChooser. It only shows the day of last modification, which makes it tricky to file files all made on the same day. So is there a gtkrc setting, or some widget setting to add extended times to the FileChooser? Or would we have to make a custom widget to display the extra file time info? I know that mozilla (gtk based ) will display a more informative time string. Thanks, zentara -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Gtk2::FileChooser - hour and minute stats
On Sun, 12 Feb 2006 08:22:45 -0500 zentara <[EMAIL PROTECTED]> wrote: >Hi, >I saw this question on the newsgroups today, >and it made me think about this shortcoming >in the FileChooser. > >It only shows the day of last modification, >which makes it tricky to file files all made >on the same day. I dug in a little into the gtk+ code for gtkfilechooserdefault.c at around line 7093 where it sets up this value. Would it be possible to patch this file? -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Thanks muppet, Thorsten my subscripttion finally went thru.
Hi, I finally tried to send the mail to [EMAIL PROTECTED] and did it manually. The web form still fails for me. Maybe it's the javascript settings I'm using? -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
CellRendererSpinButton in a List
Hi, I've been beating my head against a wall for awhile, so I better ask muppetwhere the buck stops. :-) I'm trying to setup a basic example for myself, putting different cellrenderers into a list. I have the text, combos, and toggle setup ok, but the spinbutton is giving me fits. I've used the basic CellRendererSpinButton package which has been mentioned here before. The problem is that I can't seem to get the spin box to update to it's new value in the list. I can spin them up and down, and when I set them, with a click or enter, they revert to 0. If I manually edit the cell, and press enter, the liststore seems to get the value, but it does not appear in the spinbox cell, which remains 0.00. In the interest of simplicity, I put a super simple example below. #!/usr/bin/perl -w use strict; use Gtk2 -init; use Gtk2::Gdk::Keysyms; package Gtk2::CellRendererSpinButton; use POSIX qw(DBL_MAX UINT_MAX); use constant x_padding => 2; use constant y_padding => 3; use Glib::Object::Subclass "Gtk2::CellRenderer", signals => { edited => { flags => [ qw(run-last) ], param_types => [ qw(Glib::String Glib::Double) ], }, }, properties => [ Glib::ParamSpec->double( "xalign", "Horizontal Alignment", "Where am i?", 0.0, 1.0, 1.0, [ qw(readable writable) ] ), Glib::ParamSpec->boolean( "editable", "Editable", "Can I change that?", 0, [ qw(readable writable) ] ), Glib::ParamSpec->uint( "digits", "Digits", "How picky are you?", 0, UINT_MAX, 2, [ qw(readable writable) ] ), map { Glib::ParamSpec->double( $_->[ 0 ], $_->[ 1 ], $_->[ 2 ], 0.0, DBL_MAX, $_->[ 3 ], [ qw(readable writable) ] ) } ( [ "value", "Value", "How much is the fish?",0.0 ], [ "min", "Min", "No way, I have to live!", 0.0 ], [ "max", "Max", "Ah, you're too generous.", 100.0 ], [ "step", "Step", "Okay.",5.0 ] ) ]; sub INIT_INSTANCE { my $self = shift; $self->{ editable } = 0; $self->{ digits } = 2; $self->{ value }= 0.0; $self->{ min } = 0.0; $self->{ max } = 100.0; $self->{ step } = 5.0; $self->{ xalign } = 1.0; } sub calc_size { my ( $cell, $layout, $area ) = @_; my ( $width, $height ) = $layout->get_pixel_size(); return ( $area ? $cell->{ xalign } * ( $area->width - ( $width + 3 * x_padding ) ) : 0, 0, $width + x_padding * 2, $height + y_padding * 2 ); } sub format_text { my $cell = shift; my $format = sprintf '%%.%df', $cell->{ digits }; sprintf $format, $cell->{ value }; } sub GET_SIZE { my ( $cell, $widget, $area ) = @_; my $layout = $cell->get_layout( $widget ); $layout->set_text( $cell->format_text ); return $cell->calc_size( $layout, $area ); } sub get_layout { my ( $cell, $widget ) = @_; return $widget->create_pango_layout( "" ); } sub RENDER { my ( $cell, $window, $widget, $background_area, $cell_area, $expose_area, $flags ) = @_; my $state; if ( $flags & 'selected' ) { $state = $widget->has_focus() ? 'selected' : 'active'; } else { $state = $widget->state() eq 'insensitive' ? 'insensitive' : 'normal'; } my $layout = $cell->get_layout( $widget ); $layout->set_text( $cell->format_text ); my ( $x_offset, $y_offset, $width, $height ) = $cell->calc_size( $layout, $cell_area ); $widget->get_style->paint_layout( $window, $state, 1, $cell_area, $widget, "cellrenderertext", $cell_area->x() + $x_offset + x_padding, $cell_area->y() + $y_offset + y_padding, $layout ); } sub START_EDITING { my ( $cell, $event, $view, $path, $background_area, $cell_area, $flags ) = @_; my $spin_button = Gtk2::SpinButton->new_with_range( $cell->get( qw(min max step) ) ); $spin_button->set_value( $cell->get( "value" ) ); $spin_button->set_digits( $cell->get( "digits" ) ); $spin_button->grab_focus(); $spin_button->signal_connect( key_press_event => sub { my ( $event_box, $event ) = @_; if ( $event->keyval == $Gtk2::Gdk::Keysyms{ Return } || $event->keyval == $Gtk2::Gdk::Keysyms{ KP_Enter } ) { $spin_button->update(); $cell->signal_emit( edited => $path, $spin_button->get_value() ); $spin_button->destroy(); return 1; } elsif ( $event->keyval == $Gtk2::Gdk::Keysyms{ Up } ) { $spin_button->spin( 'step-forward', ( $spin_button->get_increments() )[ 0 ] ); return 1; } elsif ( $event->keyval == $Gtk2::Gdk::Keysyms{ Down } ) { $spin_button->spin( 'step-backward', ( $spin_button->get_increments() )[ 0 ] ); return 1; } return 0; } );
Re: CellRendererSpinButton in a List
On Sun, 5 Mar 2006 22:35:54 -0500 muppet <[EMAIL PROTECTED]> wrote: >You've answered your own question add code to your START_EDITING >to hook up a handler to the new editable's "focus-out-event" signal. Yeah, I'm starting to play around with signals in the SpinCellRenderer and am getting results. But I still cannot alter the text which appears in the column after the Spin Button disaappears. I can get the value which I want to set there, but I can't get it in. Is there a way I can keep the spincell widget displayed constantly? That would be preferable for me anyways, I like seeing that widget sitting there. Thanks. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: CellRendererSpinButton in a List
On Mon, 6 Mar 2006 12:34:55 -0500 zentara <[EMAIL PROTECTED]> wrote: >On Sun, 5 Mar 2006 22:35:54 -0500 >muppet <[EMAIL PROTECTED]> wrote: > >>You've answered your own question add code to your START_EDITING >>to hook up a handler to the new editable's "focus-out-event" signal. > >Yeah, I'm starting to play around with signals in the SpinCellRenderer >and am getting results. >But I still cannot alter the text which appears in the column after >the Spin Button disaappears. I can get the value which I want to set there, >but I can't get it in. > >Is there a way I can keep the spincell widget displayed constantly? >That would be preferable for me anyways, I like seeing that widget >sitting there. > Well sorry Muppet, I don't want to waste your time, but I think I found the problem. It's only preliminary, but I'm sure I have a handle on it. The problem seems to be related to the CellRendererSpinButton package needs a section like sub SET_PROPERTY { my ($self, $pspec, $val) = @_; if ($pspec->get_name eq 'value') { $self->{value} = $val; } } That lets the initial value set in the ListStore's cells when you load the list store with initial values. I have to work out the exact details of the SET_PROPERTY sub, to let all the settings thru, but I'm sure the problem is solved. I'll have an example soon. :-) zentara -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Gtk2::CellRendererSpinButton-Z
Hi, Here is a working package, for the Gtk2::CellRendererSpinButton. It sets initial value, updates itself, and sets new initial value at each edit. I use a package global to hold the current value, and if anyone knows a better way, my ears are open. :-) #!/usr/bin/perl -w use strict; use Gtk2 -init; # package Gtk2::CellRendererSpinButtonZ; # # with a simple example usage # #this package is based on the Mup::CellRendererSpinButton #by muppet, but added # # 1. SET_PROPERTY sub to load and show initial values # 2. an extra signal handler for the focus-out to set # the spinbox, when going out of focus # 3. a global $cur_val to maintain the initial editing # start point package Gtk2::CellRendererSpinButtonZ; use POSIX qw(DBL_MAX UINT_MAX); use constant x_padding => 2; use constant y_padding => 3; use Gtk2::Gdk::Keysyms; #global to hold current value to load when start editing my $cur_val; use Glib::Object::Subclass "Gtk2::CellRenderer", signals => { edited => { flags => [ qw(run-last) ], param_types => [ qw(Glib::String Glib::Double) ], }, }, properties => [ Glib::ParamSpec->double( "xalign", "Horizontal Alignment", "Where am i?", 0.0, 1.0, 1.0, [ qw(readable writable) ] ), Glib::ParamSpec->boolean( "editable", "Editable", "Can I change that?", 0, [ qw(readable writable) ] ), Glib::ParamSpec->uint( "digits", "Digits", "How picky are you?", 0, UINT_MAX, 2, [ qw(readable writable) ] ), map { Glib::ParamSpec->double( $_->[ 0 ], $_->[ 1 ], $_->[ 2 ], 0.0, DBL_MAX, $_->[ 3 ], [ qw(readable writable) ] ) } ( [ "value", "Value", "How much is the fish?",0.0 ], [ "min", "Min", "No way, I have to live!", 0.0 ], [ "max", "Max", "Ah, you're too generous.", 100.0 ], [ "step", "Step", "Okay.",5.0 ] ) ]; sub INIT_INSTANCE { my $self = shift; $self->{ editable } = 0; $self->{ digits } = 2; $self->{ value }= 0.0; $self->{ min } = 0.0; $self->{ max } = 100.0; $self->{ step } = 5.0; $self->{ xalign } = 1.0; } sub SET_PROPERTY { my ($self, $pspec, $val) = @_; $self->{ $pspec->get_name } = $val; # set the initial editing value if ($pspec->get_name eq 'value') { $cur_val = $val; } } sub calc_size { my ( $cell, $layout, $area ) = @_; my ( $width, $height ) = $layout->get_pixel_size(); return ( $area ? $cell->{ xalign } * ( $area->width - ( $width + 3 * x_padding ) ) : 0, 0, $width + x_padding * 2, $height + y_padding * 2 ); } sub format_text { my $cell = shift; my $format = sprintf '%%.%df', $cell->{ digits }; sprintf $format, $cell->{ value }; } sub GET_SIZE { my ( $cell, $widget, $area ) = @_; my $layout = $cell->get_layout( $widget ); $layout->set_text( $cell->format_text ); return $cell->calc_size( $layout, $area ); } sub get_layout { my ( $cell, $widget ) = @_; return $widget->create_pango_layout( "" ); } sub RENDER { my ( $cell, $window, $widget, $background_area, $cell_area, $expose_area, $flags ) = @_; my $state; if ( $flags & 'selected' ) { $state = $widget->has_focus() ? 'selected' : 'active'; } else { $state = $widget->state() eq 'insensitive' ? 'insensitive' : 'normal'; } my $layout = $cell->get_layout( $widget ); $layout->set_text( $cell->format_text ); my ( $x_offset, $y_offset, $width, $height ) = $cell->calc_size( $layout, $cell_area ); $widget->get_style->paint_layout( $window, $state, 1, $cell_area, $widget, "cellrenderertext", $cell_area->x() + $x_offset + x_padding, $cell_area->y() + $y_offset + y_padding, $layout ); } sub START_EDITING { my ( $cell, $event, $view, $path, $background_area, $cell_area, $flags ) = @_; my $spin_button = Gtk2::SpinButton->new_with_range( $cell->get( qw(min max step) ) ); $spin_button->set_value( $cell->get( "value" ) ); $spin_button->set_digits( $cell->get( "digits" ) ); #set initial point for editing $spin_button->set_value( $cur_val ); $spin_button->grab_focus(); $spin_button->signal_connect( key_press_event => sub { my ( $event_box, $event ) = @_; if ( $event->keyval == $Gtk2::Gdk::Keysyms{ Return } || $event->keyval == $Gtk2::Gdk::Keysyms{ KP_Enter } ) { $spin_button->update(); $cell->signal_emit( edited => $path, $spin_button->get_value() ); $spin_button->destroy(); return 1; } elsif ( $event->keyval == $Gtk2::Gdk::Keysyms{ Up } ) { $spin_button->spin( 'step-forward', ( $spin_button->get_increments()
another easy fix for Mup::CellRendererProgress;
Hi, After seeing that I needed an SET_PROPERTY in the custom cell renderer for spinboxes, I checked out the Mup::CellRendererProgress; in the examples directory of the Gtk2-1.115 release. The example cellrenderer_progress.pl , never really worked right, but I never looked into it. The text progress would display, but the bar had no motion. Anyways, I looked at the package, and muppet had written # we'll use the default new, GET_PROPERTY and SET_PROPERTY provided by # Glib::Object::Subclass. Apparently that dosn't do the trick for the bar, only the text field worked. So I added sub SET_PROPERTY { my ( $self, $pspec, $val ) = @_; $self->{ $pspec->get_name } = $val; } and voila, the bar worked too. Maybe you could update the example, or figure out why? As always you know more than me, :-) zentara -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Is the cellrenderer_date.pl working for anyone?
Hi, I've been looking at the custom cellrenderers in the example subdir of the Gtk-1.115 module. Is the cellrenderer_date.pl working correctly for anyone? I get this weird flicker, of the cell text appearring and disappearing, as I move the mouse over the list; and the columns seem to get values confused and changing. I was wondering if it is due to me using a recent Gtk++ lib, or whether the thing is broken? I'm currently using glib-2.9.5 gtk+-2.8.11 and was wondering if they screw up the cell renderer examples. I recently posted that I needed to add a SET_PROPERTY sub to a couple of the packages, to make them work, and now the date renderer is acting funny. How are they working for others? If they work, what lib levels are you using? Thanks. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Is the cellrenderer_date.pl working for anyone?
On Wed, 08 Mar 2006 08:34:38 +1100 Daniel Kasak <[EMAIL PROTECTED]> wrote: >zentara wrote: >> Is the cellrenderer_date.pl working correctly for anyone? >> I get this weird flicker, of the cell text appearring and disappearing, >> as I move the mouse over the list; and the columns seem to >> get values confused and changing. >> >I posted about this type of issue a couple of days back ( Custom Cell >Renderer broken after update ). >You need to either downgrade to Perl 5.8.7 or update your Gtk2 Perl >bindings to the very latest ( unstable ). > >-- >Daniel Kasak Thanks, that did it. Gtk2-1.116 and Glib-1.118 seems to work. Glad I asked :-) otherwise I would have really been messing the renderers up. :-) I must have read your earlier post, but it didn't sink in. But I do see it now. Thanks -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Gtk2::CellRendererSpinButton-Z
On Mon, 6 Mar 2006 22:32:57 -0500 muppet <[EMAIL PROTECTED]> wrote: > >On Mar 6, 2006, at 3:57 PM, zentara wrote: > >> Hi, >> Here is a working package, for the >> Gtk2::CellRendererSpinButton. >> >> It sets initial value, updates itself, and sets >> new initial value at each edit. >> >> I use a package global to hold the current value, >> and if anyone knows a better way, my ears are open. :-) > >You don't need the global at all. You pass the new value through >the "new value" parameter of the edited signal. The cell renderer > >> sub SET_PROPERTY { >> my ($self, $pspec, $val) = @_; >> $self->{ $pspec->get_name } = $val; >> >> # set the initial editing value >> if ($pspec->get_name eq 'value') { >> $cur_val = $val; >> } >> } > >After you remove the global, you have a SET_PROPERTY which is merely >a perl implementation of what the XS code already does. Yes, I am humbled. :-) I caused all these problems for myself, by upgrading to Perl 5.8.8 , while not getting the latest Glib and Gtk-1.116 perl modules. I should have read more closely the post by Daniel Kasak a few days ago concerning this. So all of the above module hacking... is just BS caused by me not noticing the upgrade problems. Sorry I wasted your time, but I sure learned alot. :-) zentara -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
setting line dash on Gnome2::Canvas
Hi, Does anyone know how to make dashed lines on the Gnome2::Canvas? I saw some mention of it on the C maillist, but don't seem to be able to make it work on Perl. #!/usr/bin/perl use warnings; use strict; use Gtk2 -init; use Gnome2::Canvas; my $window = Gtk2::Window->new; $window ->signal_connect( 'destroy' => sub{Gtk2->main_quit } ); my $scroller = Gtk2::ScrolledWindow->new; my $canvas = Gnome2::Canvas->new_aa; $scroller->add ($canvas); $window->add ($scroller); $window->set_default_size (350, 350); $canvas->set_scroll_region (0, 0, 700, 700); $window->show_all; my $black = Gtk2::Gdk::Color->new (0x,0x,0x); $canvas->modify_bg('normal',$black); my $line1= Gnome2::Canvas::Item->new ($canvas->root, 'Gnome2::Canvas::Line', points => [0,20,130,150], fill_color => "red", width_units => 8.0, line_style => 'GDK_LINE_ON_OFF_DASH', ); # feeble attempt dosn't work #$line1->set_dashes( {0,0xff,0,0xff} ); # some stuff from the c mail list #you can give a line pattern to the function in this way #gchar list[]={ 0, 0xff, 0, 0xff } #gdk_gc_set_dashes( gc, 0, list, sizeof(list) / sizeof( gchar) ); #this produces a line like this: - - - - - - - - - #The offset controls the starting point of the pattern. #Elements of dash_list give the length (in pixels) of dash segments. n is the #number of elements in dash_list. dash_offset is the distance (in pixels) to #start in dash_list. #Example: #gdk_gc_set_dashes( gc, 3, { 6, 3 }, 2 ); #Draws a line which is on for 6 pixels, then off for 3, then on for 6, etc. An #offset of half the first segments helps lines to match up more cleanly when #they join. Dash patterns look best with an even number of elements in #dash_list (obviously). #Use gdk_gc_set_line_attributes() to turn on GDK_LINE_ON_OFF_DASH or #GDK_LINE_DOUBLE_DASH to see your pattern. Gtk2->main; __END__ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Glib::Object::Subclass bug? or Misunderstanding?
On Mon, 20 Mar 2006 22:18:30 -0500 James Muir <[EMAIL PROTECTED]> wrote: >>> fails, though I wouldn't have expected it to do so. If I uncomment >>> the GET_PROPERTY in the example below all is well, but I would have >>> expected the example below to work without it. >>> >>> I'm using libgnomecanvas 2.10.2 and Gtk+2 2.8.11 >>> >>> Thanks for any help you can offer on this matter. Jaap Karssenberg >>> has reported problems to me with the software I sent him after he >>> upgraded his machine. So it's not just me that's having troubles >>> after an upgrade. I'm trying to understand what's going wrong so I >>> can fix this problem. >> >> What upgrade was it? Was glib-2.0 upgraded without rebuilding Glib? >> There was a rash of "bugs" recently related to botched upgrades... < 2 cents> This rings a bell for me. I recently was confused why I needed to use SET_PROPERTY in some of the custom_cell_renderers after I upgraded my Perl version to 5.8.8. Then it was pointed out to me, by Daniel Kasak, that you need the latest Gtk-Perl module ( Gtk-1.116 ) for the sub-classing properties to work right in Perl-5.8.8 So if your Perl is 5.8.8 , try Gtk-Perl module ( Gtk-1.116 ) or later. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: treeview clearing
On Tue, 21 Mar 2006 17:48:40 +0100 (CET) Szabó Géza <[EMAIL PROTECTED]> wrote: >and I just want to simply clear all the whole treeview. >I tried with $treestore->clear; but nothing happens. >How can this be fixed? Your $treestore may be out of scope? Do you have warnings and strict enabled? This works. #! /usr/bin/perl -w use strict; use Gtk2 '-init'; use Glib qw/TRUE FALSE/; my $window = Gtk2::Window->new('toplevel'); $window->signal_connect('delete_event' => sub { Gtk2->main_quit; }); $window->set_border_width(5); $window->set_position('center_always'); my $vbox = &ret_vbox(); $window->add($vbox); $window->show(); Gtk2->main(); sub ret_vbox { my $vbox = Gtk2::VBox->new(FALSE,5); my $sw = Gtk2::ScrolledWindow->new (undef, undef); $sw->set_shadow_type ('etched-out'); $sw->set_policy ('automatic', 'automatic'); $sw->set_size_request (300, 300); $sw->set_border_width(5); my $tree_store = Gtk2::TreeStore->new(qw/Glib::String/); foreach (1..30) { my $parent_nr = $_; my $iter = $tree_store->append(undef); $tree_store->set ($iter,0 => "Parent $parent_nr"); foreach (1..3){ my $iter_child = $tree_store->append($iter); $tree_store->set ($iter_child,0 => "Child $_ of Parent $parent_nr"); } } my $tree_view = Gtk2::TreeView->new($tree_store); my $tree_column = Gtk2::TreeViewColumn->new(); $tree_column->set_title ("Click to sort"); my $renderer = Gtk2::CellRendererText->new; $tree_column->pack_start ($renderer, FALSE); $tree_column->add_attribute($renderer, text => 0); $tree_view->append_column ($tree_column); $sw->add($tree_view); $vbox->pack_start($sw,TRUE,TRUE,0); my $button = Gtk2::Button->new('Clear'); $vbox->pack_end( $button, FALSE, FALSE, 0 ); $button->signal_connect( clicked => sub{ $tree_store->clear; } ); $vbox->show_all(); return $vbox; } __END__ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Date and Time Entry Boxes
On Tue, 28 Mar 2006 22:33:24 +0500 "A.R. Nasir Qureshi" <[EMAIL PROTECTED]> wrote: > >I have made these two Widget, each under Gtk2::Entry. I want to release >them for the benefit of the community, but have no experience in making >the Installation Package, Man page etc. They also require a lot of work, >which I will do soon, but the provide basic functionality now. > >The have to be placed under /usr/lib/perl5/site_perl/5.8.4/Gtk2/Ex/ > >I would appreciate the guidance on the the gurus. > Read perldoc -q create a module Basically h2xs -XA -n My::Module then put your code in and write the perldoc. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: drawing shapes with color
On Thu, 30 Mar 2006 13:33:28 +0200 "Dov Grobgeld" <[EMAIL PROTECTED]> wrote: >Here's what I use: > >#!/usr/bin/perl >use Gtk2 '-init'; Also: I just discovered the theme setting for DrawingArea. You need to specify NONE for bg_pixmap because the drawing area will use the default bg pixmap if defined. style "drawingarea" { # if you want to use bg colors, specify none # for bg_pixmap # bg_pixmap[NORMAL] = "bg.png" bg_pixmap[NORMAL] = "" bg[NORMAL] = { 1.0, 1.0, 1.0 }#white }class "GtkDrawingArea" style "drawingarea" I'm trying to collect as many theme modification syntax statements as I can, if you have any for unusual widgets, let me know pleae. :-) My theme derived from Bumblebee can be had at http://www.zentara.net/gtk2-theme -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Announce Gtk2-Ex-MindMapView
On Sun, 02 Apr 2006 16:51:19 -0400 James Muir <[EMAIL PROTECTED]> wrote: >Hi Everybody, > >I managed to get the alpha test version of Gtk2-Ex-MindMapView uploaded >to CPAN. > >Gtk2-Ex-MindMapView displays an outline or mind map on a Gnome2::Canvas. >This module is an extension of the Gnome2::Canvas. It depends on the >Gnome2::Canvas and Graph modules. > >There are five example programs you can run to get an idea of how it >works and what it's limitations currently are. Any and all feedback is >welcome. > >-James Works here. :-) and looks nice. I was looking for a good example to follow on sub classing a Gnome2::Canvas, and this fits the bill. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Announce Gtk2-Ex-MindMapView
On Mon, 3 Apr 2006 21:34:41 +0200 Nadim Khemir <[EMAIL PROTECTED]> wrote: >On Monday 03 April 2006 20.11, muppet wrote: >> These failures certainly sound like they may be related to the bugs fixed >> in 1.105 and 1.200 as compared to 1.101. Definitely try to resolve the old >> version problem. It works here fine, on linux with Glib-1.120 Gtk2-1.116 Gnome2-Canvas-1.002 -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Was: Video in window NOW: window Black
On Sun, 09 Apr 2006 13:15:49 -0400 José Luis Regalado <[EMAIL PROTECTED]> wrote: >-BEGIN PGP SIGNED MESSAGE- >Hash: SHA1 > >José Luis Regalado escribió: > >> use Gtk2 -init; >> use Gtk2::Ex::MPlayerEmbed; >NOW WORK, but the window is black. I not see the video. > >some advice?. >Thanks. Hi, I've yet to get Ex::MPlayerEmbed to work for me. It just dosn't show up on the screen. I have been able to do it manually, but it is a bit clunky. In the script below, the init.mpg is just a blank mpg I have and it is used to start mplayer in slave mode. Since I don't want to include it in this email, I just made the init the same as the mpg to be played. Like I said, this is only an experimental script, which I have not done much work on, so don't expect it to work right, except to play the mpg. There may be useless code statements in it. I've yet to find a way to get any of the key bindings to work in Gtk2 embedded windows. Anyways.. here it is #!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2; use Gtk2 '-init'; my $mpg = shift; my $pid; #global for killing on exit my $window = Gtk2::Window->new('toplevel'); $window->set_title('Embed test'); $window ->signal_connect( 'destroy' => \&delete_event ); $window->set_border_width(10); $window->set_size_request(600,600); my $vbox = Gtk2::VBox->new( FALSE, 6 ); $window->add($vbox); $vbox->set_border_width(2); my $hbox= Gtk2::HBox->new( FALSE, 6 ); $vbox->pack_end($hbox,FALSE,FALSE,0); $hbox->set_border_width(2); $vbox->pack_end (Gtk2::HSeparator->new, FALSE, FALSE, 0); my $vbox1 = Gtk2::VBox->new( FALSE, 6 ); $vbox1->set_size_request(600,500); $vbox->pack_end($vbox1,FALSE,FALSE,0); $vbox1->set_border_width(2); my $button = Gtk2::Button->new_from_stock('gtk-quit'); $hbox->pack_end( $button, FALSE, FALSE, 0 ); $button->signal_connect( clicked => \&delete_event ); my $button1 = Gtk2::Button->new('Mplayer'); $hbox->pack_end( $button1, FALSE, FALSE, 0 ); $button1->signal_connect( clicked => \&do_mplayer ); $window->show_all(); Gtk2->main; # sub delete_event { kill 9, $pid; Gtk2->main_quit; return FALSE; } ## sub do_mplayer{ my $gdkwindow = $window->window; print "gdkwin->$gdkwindow\n"; my $gdkwindow1 = $vbox1->window; print "gdkvbox->$gdkwindow1\n"; my $xid = $gdkwindow1->XWINDOW; print "xid->$xid\n"; my $url =''; my @options = ( '-slave','-loop 0', '-zoom', "-x 600", "-y 450", '-really-quiet', "-wid $xid", ); my $init = $mpg; my $pid = open(MP, "| mplayer @options $init >/dev/null 2>&1 "); syswrite(MP, "loadfile $mpg\n"); } __END__ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
subclassed anti-alias canvas, and disappearing text
Hi, I made a little Tk directory subtree browser, and now I want to make a Gtk2 version. The basic idea is to make it look like a Gtk2 treeview, with a background image. In case you want to see what I'm trying to emulate, see http://zentara.net/perlplay/modules/Tk-CanvasDirTree-0.04.tar.gz Anyways the conversion is going pretty well, except I've run into a bug with text not showing on the anti-alias canvas. I've made the code text code, the same as in the Gnome2::Canvas demo. It works when I use the plain subclassed canvas, but when I use aa=>1 , I get a slew of errors Pango-CRITICAL **: pango_renderer_draw_layout: assertion `PANGO_IS_RENDERER (renderer)' failed at ./zz-Gtk-CanvasTest line 215. GLib-GObject-WARNING **: invalid cast from `PangoCairoFcFontMap' to `PangoFT2FontMap' at ./zz-Gtk-CanvasTest line 215. GLib-GObject-WARNING **: invalid uninstantiatable type `(null)' in cast to `PangoFT2Renderer' at ./zz-Gtk-CanvasTest line 215. I remember reading a post by muppet, about needing a special syntax when making a subclassed anti-alias canvas, where you need to use ->new(aa=>1) rather than ->new_aa. So I'm thinking that this may be a similar problem. So if you run this in a directory containing a few subdirectories, you should see the problem. The main package code is at the bottom. How do I get the aa canvas to display the text ? Thanks for looking. zentara #!/usr/bin/perl use warnings; use strict; package CanvasDirTree; our $VERSION = '0.01'; use warnings; use strict; use Gnome2::Canvas; use File::Spec; use POSIX qw(DBL_MAX); use Glib ':constants'; use Glib::Object::Subclass Gnome2::Canvas::, signals => { # currently no signals defined }, properties => [ { pspec => Glib::ParamSpec->string ('ztree', 'Ztree', 'subdir tree', "", # default [qw/readable writable/]), get => sub { my ($self) = @_; }, set => sub { my ($self, $newval) = @_; }, }, ], ; sub INIT_INSTANCE { my $self = shift; $self->{color_blue} = Gtk2::Gdk::Color->parse('blue'); $self->{color_red} = Gtk2::Gdk::Color->parse('red'); $self->make_trunk('.', 0); return $self; } sub SET_PROPERTY { my ($self, $pspec, $newval) = @_; my $param_name = $pspec->get_name(); print "$param_name\n"; return; } ## sub get_subdirs{ my ($self, $dir) = @_; my @subdirs; opendir my $dh, $dir or warn $!; while ( my $file = readdir($dh) ) { next if $file =~ m[^\.{1,2}$]; if(-d "$dir/$file"){ push @subdirs, $file; }else{ next } } return @subdirs; } ### sub check_depth_2{ my ($self, $abs_path) = @_; my $put_ind = 0; opendir my $dh, $abs_path or warn $!; while ( my $file = readdir($dh) ) { next if $file =~ m[^\.{1,2}$]; if(-d "$abs_path/$file"){ $put_ind = 1; last; } } return $put_ind; } # sub make_trunk{ my ($self, $dir, $level) = @_; my $x = 5; my $y = 15; my @subdirs = $self->get_subdirs( $dir ); my $abs_root = File::Spec->rel2abs( $dir ); #for windows compat $abs_root =~ tr#\\#/#; #handle special case when toplevel is / or C:/, D:/, etc if($abs_root eq '/'){$abs_root = ''} #for windows compat if ( $abs_root =~ m#^([ABCDEFGHIJKLMNOPQRSTUVWXYZ])\:\/$# ) {$abs_root = "$1:"} #add a static entry for the topdir my $root_tag; if($abs_root eq ''){$root_tag = '/'}else{ $root_tag = $abs_root } my $root = $self->root(); $self->{'f_width'} = 15; $self->{'f_height'} = 15; my $topline = Gnome2::Canvas::Item->new ($root, 'Gnome2::Canvas::Line', points => [ $x , $y - .8 * $self->{'f_height'}, $x + $self->{'f_height'}, $y - .8 * $self->{'f_height'}, $x + $self->{'f_height'}, $y - .4 * $self->{'f_height'}, ], width_pixels => 2, first_arrowhead => FALSE, last_arrowhead => TRUE, arrow_shape_a => 6.0, arrow_shape_b => 6.0,
Re: subclassed anti-alias canvas, and disappearing text
On Fri, 14 Apr 2006 16:06:15 -0400 zentara <[EMAIL PROTECTED]> wrote: >I've made the code text code, the same as in the Gnome2::Canvas demo. >It works when I use the plain subclassed canvas, but when I use >aa=>1 , I get a slew of errors > >Pango-CRITICAL **: pango_renderer_draw_layout: assertion `PANGO_IS_RENDERER >(renderer)' failed at ./zz->Gtk-CanvasTest line 215. >I remember reading a post by muppet, about needing a special syntax >when making a subclassed anti-alias canvas, where you need to use >->new(aa=>1) rather than ->new_aa. So I'm thinking that this may be a >similar >problem. > Hello again, I found an answer by simplifying the example to it's simplest form. It seems that when you you sub-class an anti-alias canvas, you cannot do anything with text until the INIT_INSTANCE is finished. In the following example, if you run it , as shown, with no anti-aliasing, the text appears behind the ellipse. If you turn on aa=>1, the text disappears, and an error is issued Pango-CRITICAL **: pango_renderer_draw_layout: assertion `PANGO_IS_RENDERER (renderer)' failed at ./canvas-as-subclassed-objects2a line 62. If you then uncomment the GLib::Timeout statement, in the INIT_INSTANCE sub, to let INIT_INSTANCE finish before trying to write the text, it works. Now, muppet reported to me privately, that he was not seeing this problem, on his versions. I'm using the latest announced versions of everything. c glib-2.10.2 gtk+-2.8.17 pango-1.12.1 libgnomecanvas-2.14.0 Perl. Glib-1.120 Gnome2-Canvas-1.002 Gtk2-1.121 Anyways, this brings up an interesting question for me. Is using the timer hack the only way of launching something from INIT_INSTANCE? I have a more complex package, where I set a bunch of non-canvas pspecs, and I need the timer from INIT_INSTANCE to launch a sub from INIT_INSTANCE on package startup, and have the new values set properly. If I don't wait for the INIT_INSTANCE to finish first, my extra settings don't get seen on the first run. This affects both the aa and non-aa canvas. Thanks. ### #!/usr/bin/perl package can; use strict; use Gtk2; use Gnome2::Canvas; use Glib::Object::Subclass Gnome2::Canvas::, properties => [ ] ; sub INIT_INSTANCE { my $self = shift(@_); print "INIT_INSTANCE\n"; #Glib::Timeout->add (1, sub { my $text = Gnome2::Canvas::Item->new($self->root, 'Gnome2::Canvas::Text', font=>'Arial Bold 18', fill_color=>'black', x=>20, y=>20, text=>'hello', ); # return 0; # }); } 1; ## package main; use strict; use Gtk2 '-init'; use Gnome2::Canvas; my $window = Gtk2::Window->new(); my $scroller = Gtk2::ScrolledWindow->new(); #my $canvas = can->new( aa=>1 ); my $canvas = can->new(); $scroller->add($canvas); $window->add($scroller); my $root = $canvas->root(); my $ellipse = Gnome2::Canvas::Item->new($root,'Gnome2::Canvas::Ellipse', x1=>10,y1=>10,x2=>40,y2=>40, fill_color=>'red'); $window->signal_connect('destroy'=>sub { Gtk2->main_quit(); } ); $window->show_all(); Gtk2->main(); __END__ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
linux, alot of fonts and slow window startups
Hi, This is just a general question. Recently I tried to get my homemade American linux system to run utf-8. So I changed the required lines in .bashrc and installed a bunch of fonts (which were suggested in the various unicode setup tutorials). Well after installing the fonts, my Perl/Gtk2 windows seemed to take alot longer to come onto the screen. Like "a fraction of a second before" to "3 or 4 seconds after". My Perl/Tk programs were not affected. What would cause this? P.S. I backed up before doing this, and I put the old font dirs back in, so everything is back to normal speed. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
treeview style setting
Hi, I'm trying to adjust some of the style settings in a treeview, like the expander size and vertical spacing. I can get the list of styles, but I can't see where to set them. Anyone know? #! /usr/bin/perl -w use strict; use Gtk2 '-init'; use Glib qw/TRUE FALSE/; my $window = Gtk2::Window->new('toplevel'); $window->signal_connect('delete_event' => sub { Gtk2->main_quit; }); $window->set_border_width(5); $window->set_position('center_always'); my $vbox = &ret_vbox(); $window->add($vbox); $window->show(); Gtk2->main(); sub ret_vbox { my $vbox = Gtk2::VBox->new(FALSE,5); my $sw = Gtk2::ScrolledWindow->new (undef, undef); $sw->set_shadow_type ('etched-out'); $sw->set_policy ('automatic', 'automatic'); $sw->set_size_request (300, 300); $sw->set_border_width(5); my $tree_store = Gtk2::TreeStore->new(qw/Glib::String/); foreach (1..30) { my $parent_nr = $_; my $iter = $tree_store->append(undef); $tree_store->set ($iter,0 => "Parent $parent_nr"); foreach (1..3){ my $iter_child = $tree_store->append($iter); $tree_store->set ($iter_child,0 => "Child $_ of Parent $parent_nr"); } } my $tree_view = Gtk2::TreeView->new($tree_store); my $tree_column = Gtk2::TreeViewColumn->new(); $tree_column->set_title ("Click to sort"); my $renderer = Gtk2::CellRendererText->new; $tree_column->pack_start ($renderer, FALSE); $tree_column->add_attribute($renderer, text => 0); $tree_view->append_column ($tree_column); ### my @list = $tree_view->style_get("vertical-separator", "even-row-color","odd-row-color", "expander-size","horizontal-separator", "indent-expanders" ); print "@list\n"; my $style = $tree_view->get_style; print "$style\n"; my $new_style = $style->copy(); $new_style->{'expander-size'} = 20; $tree_view->set_style($style); ### $sw->add($tree_view); $vbox->pack_start($sw,TRUE,TRUE,0); $vbox->show_all(); return $vbox; } __END__ Thanks -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: TreeViews, IconViews, and images
On Mon, 29 May 2006 17:57:42 +0200 Wouter Verhelst <[EMAIL PROTECTED]> wrote: >Hi, > >I've been looking over the C API docs and the Perl examples, but I can't >seem to figure out how one is supposed to set up a TreeStore (or a >ListStore) so that it would be possible to show an image in a TreeView >or an IconView. Could someone point me towards a simple example? >Also, while I'm at it, I would like to set up a TreeView so that >optionally, the user can choose to not display the 'leaf' items in a >TreeStore; those would be shown in the IconView that is going to be >right next to the TreeView, with the icons in the iconview being >changed when the selection on the TreeView changes. Is that possible >without building two TreeStore objects? If so, how? > >Wouter Verhelst Hi, someone else may have a better example for you, but I think you may be looking for a custom-cell-renderer. There are some examples that come with the Perl Gtk+ module. Attached is a script which I worked up for my own testing. There is an checkbox which controls whether the icon (pixbuf) appears. Just use an image instead of an icon to create the pixbuf. Hope it helps you I know it is confusing to everyone except muppet. :-) zentara -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html cellrenderercombo_test4a-date Description: Binary data ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Changing background color for a box widget
On Mon, 5 Jun 2006 14:23:29 +0100 "Mike Martin" <[EMAIL PROTECTED]> wrote: >Is it possible to alter the background color for a box widget. I am >not having a lot of luck > >To explain I have a dynamically created hbox added to a vbox inside a frame. > >In this hbox I have two widgets a label frame (a file name) and a remove >button. > >I would like the background to be white so there is some contrast. > >I have tried with rc files and modify_bg but it doesn't seem to take. > >Any ideas? I ran into a similar problem when using themes which set a default pixmap background. You need to set the style to "" to override the pixmap styles from a default theme you may have going. In the following, if I comment out the lines bg_pixmap[NORMAL] = "" bg_pixmap[INSENSITIVE] = "" bg_pixmap[ACTIVE] = "" bg_pixmap[PRELIGHT] = "" The colors will not be set. In the example, it defaults to white, with a line below for a dark grey. You also can use an event box to set the background colors, as shown in the label. #!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; Gtk2::Rc->parse_string(<<__); style "default" { bg_pixmap[NORMAL] = "" bg_pixmap[INSENSITIVE] = "" bg_pixmap[ACTIVE] = "" bg_pixmap[PRELIGHT] = "" bg[NORMAL] = { 1.0, 1.0, 1.0 } }class "GtkWidget" style "default" __ my $greyl = Gtk2::Gdk::Color->new (0x,0x,0x); my $bluel = Gtk2::Gdk::Color->new (0,0x,0x); my $red = Gtk2::Gdk::Color->new (0x,0,0); my $white = Gtk2::Gdk::Color->new (0x,0x,0x); my $window = Gtk2::Window->new('toplevel'); $window->signal_connect( destroy => sub { Gtk2->main_quit; } ); $window->set_title("Label"); my $vbox = Gtk2::VBox->new( FALSE, 5 ); $window->add($vbox); $window->set_border_width(5); $window->set_size_request(300,200); #$window->modify_bg('normal',$greyl); my $frame = Gtk2::Frame->new("Colored Label"); my $label = Gtk2::Label->new("This is a Colored Label"); $label->modify_fg('normal', $white); $frame->modify_bg('normal', $red); $vbox->pack_start( $frame, FALSE, FALSE, 0 ); #used for coloring background my $coleventb0 = Gtk2::EventBox->new(); $coleventb0->modify_bg ('normal', $bluel); $coleventb0->set_border_width(2); $frame->add($coleventb0); $coleventb0->add($label); $window->show_all; Gtk2->main; __END__ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Handling Gnome::Canvas data
On Fri, 23 Jun 2006 11:14:44 -0500 "Chris Bartak" <[EMAIL PROTECTED]> wrote: >I've been trying to render a Gnome::Canvas to a pixbuf, without any luck. I >read that in Perl you must use the pack() function to pack the pixel data >from the Gdk::Window into a scalar. Unfortunately, I'm not sure how to get >the pixel data, or how to pack it properly. Could anyone provide a quick >demo of how this is done? Here is a little demo which captures the entire mainwindow. Just change $window to $canvas in the sub, to get the canvas only. One little glitch, the screen shot only gets created if you hit the Exit button, Not if you hit the window manager destroy icon. I'm not sure why, but I'm a bit rusty. :-) #!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; use Gnome2::Canvas; my $window = Gtk2::Window->new('toplevel'); $window->set_title('Screenshot'); $window ->signal_connect( 'destroy' => \&delete_event ); $window->set_border_width(10); #->set_size_request(300,200); $window->set_default_size(250,400); my $vbox = Gtk2::VBox->new( FALSE, 6 ); $vbox->set_size_request(0,0); $window->add($vbox); $vbox->set_border_width(2); my $hbox= Gtk2::HBox->new( FALSE, 6 ); $vbox->pack_end($hbox,FALSE,FALSE,0); $hbox->set_border_width(2); $vbox->pack_end (Gtk2::HSeparator->new, FALSE, FALSE, 0); my $button = Gtk2::Button->new_from_stock('gtk-quit'); $hbox->pack_end( $button, FALSE, FALSE, 0 ); $button->signal_connect( clicked => \&delete_event ); my $button1 = Gtk2::Button->new_from_stock('Screenshot'); $vbox->pack_start( $button1, FALSE, FALSE, 0 ); $button->signal_connect( clicked => \&screenshot ); my $canvas = Gnome2::Canvas->new(); $canvas->set_size_request(256,256); $canvas->set_scroll_region(0,0,256,256); my $root = $canvas->root(); my $item = Gnome2::Canvas::Item->new($root, "Gnome2::Canvas::Ellipse", x1 => 0, y1 => 0, x2 => 200, y2 => 180, fill_color=>"red", outline_color=>"black" ); $vbox->pack_start( $canvas, FALSE, FALSE, 0 ); $window->show_all(); Gtk2->main; # sub delete_event { Gtk2->main_quit; return FALSE; } # sub screenshot{ #we are going to save the entire mainwindow my ($width, $height) = $window->window->get_size; # create blank pixbuf to hold the image my $gdkpixbuf = Gtk2::Gdk::Pixbuf->new ('rgb', 0, 8, $width, $height); $gdkpixbuf->get_from_drawable ($window->window, undef, 0, 0, 0, 0, $width, $height); #only jpeg and png is supported it's 'jpeg', not 'jpg' $gdkpixbuf->save ("$0.jpg", 'jpeg', quality => 100); return FALSE; } #$pixbuf->save ($filename, 'jpeg', quality => '100'); # Currently only a few parameters exist. JPEG images can be saved # with a "quality" parameter; its value should be in the range # [0,100]. Text chunks can be attached to PNG images by specifying # parameters of the form "tEXt::key", where key is an ASCII string of # length 1-79. The values are UTF-8 encoded strings. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list