Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

is there a way to embed nautilus file browser inside a gtk2 widget? i wanted to do this so that i can have a file browser on my perl program.

Replies are listed 'Best First'.
Re: perl Gtk2 embed nautilus as widget
by Anonymous Monk on Jan 06, 2011 at 08:31 UTC
Re: perl Gtk2 embed nautilus as widget
by zentara (Cardinal) on Jan 06, 2011 at 15:52 UTC
    I would not hold your hopes up, but there is a way if Nautilus supports the xid option. Type "nautilus --help" and see if there is an option to run it in a socketid. Look for words like: xid, socketid, etc.

    Even IF nautilus supports the option, it may not work to your satisfaction after it is embedded. It may not have mouse or keyboard sensitivity, or some other weird behavior.

    Here is a simple way to embed an mc filebrowser into a urxvt terminal. Google for Gtk2::Socket and Gtk2::Plug...... it's still all experimental.

    #!/usr/bin/perl use warnings; use strict; use Gtk2; init Gtk2; my $window = new Gtk2::Window 'toplevel'; $window ->signal_connect( 'destroy' => sub{ Gtk2->main_quit; return 0; } ); my $frame = new Gtk2::Frame "embedded rxvt-unicode terminal"; $window->add ($frame); my $rxvt = new Gtk2::Socket; $frame->add ($rxvt); $frame->set_size_request (700, 400); $window->show_all; my $xid = $rxvt->window->get_xid; # works with rxvt but xterm loses keyboard focus #system "xterm -into $xid &"; system "urxvt -embed $xid -e mc &"; $window->show_all; $rxvt->add_events([ qw( all_events_mask key_press_mask ) ]); #needs 0 not 1 for second arg #my $rc = Gtk2::Gdk->keyboard_grab($rxvt->window, 0 ,Gtk2->get_current +_event_time); #warn "keyboard grab failed ($rc)\n" unless $rc eq 'success'; #print "$rc\n"; main Gtk2;

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh