Gtk2::Ex::PathBar.3pm

Langue: en

Autres versions - même langue

Version: 2009-03-16 (fedora - 05/07/09)

Section: 3 (Bibliothèques de fonctions)

NAME

Gtk2::Ex::PathBar - A button path bar widget

SYNOPSIS

         use Gtk2;
         use Gtk2::Ex::PathBar;
         use File::Spec;
         
         my $pathbar = Gtk2::Ex::PathBar->new(spacing => 3);
         $pathbar->show;
         
         # show a path
         my $name = '/foo/bar/baz';
         my ($vol, $dir, $file) = File::Spec->splitpath($name);
         my @path = (($vol || '/'), File::Spec->splitdir($dir), $file);
         $pathbar->set_path(grep length($_), @path);
         $pathbar->signal_connect(path_clicked => \&load_dir);
 
         # or show a history
         my @hist = qw(/foo/bar /tmp/baz /home/pardus);
         $pathbar->set_path(map [basename($_), $_], @hist);
         $pathbar->signal_connect(path_clicked => \&load_dir);
 
         sub load_dir {
                 my ($button, @path) = @_;
                 # ...
         }
 
 

DESCRIPTION

This widget is intended as a look-a-like for the ``button path bar'' used in the gtk file dialog. Each part of the path is represented by a button. If the button row gets to long sliders are shown left and right to scroll the bar.

It can be used to display a path to a file or directory or to display similar data like a history (trace) or a namespace.

HIERARCHY

   Glib::Object
   +----Gtk2::Object
         +----Gtk2::Widget
               +----Gtk2::Container
                    +----Gtk2::Box
                         +----Gtk2::Ex::PathBar
 
 

METHODS

"new(spacing => $spacing, ..)"
Simple constructor, takes pairs of properties.
"start_scrolling(DIRECTION)"
Start continuous scrolling. DIRECTION can be either 'left' or 'right'.
"stop_scrolling()"
Stop continuous scrolling.
"hide_sliders(BOOLEAN)"
By default the sliders are made insensitive if you are displaying multiple items but you scrolled to one end of the list. After setting this method sliders are hidden instead of showing insensitive.
"scroll_back(INT)"
Scrolls the path bar one or more items back. This is to the left for left-to-right oriented environements.
"scroll_forw(INT)"
Scrolls the path bar one or more items forward. This is to the right for left-to-right oriented environements.
"set_path(PART, PART, ..)"
This method fills the path bar with a button for each part of the path. When one of theses buttons is clicked the 'path_clicked' signal is emitted with as argument an array reference holding the path elements to that button.

You can also use array references instead of strings for the parts of the path. In this case the first element of these arrays is the string to display on the button. All other parts of the array are passed as a array reference to the 'path_clicked' signal. This can be used if the data you want to display is not really a path.

"set_items(WIDGET, WIDGET, ..)"
Low level method used by "set_path()" to fill the path bar with buttons. You can use this method to fill the path bar with your own buttons or other widgets. Of course widgets added with this method will not automaticly trigger the "path_clicked" signal.
"get_items()"
Returns a list of widgets coresponding to the items in the path bar. Notice that this differs from "get_children()" which will also give you the widgets for the sliders.
"clear_items()"
Removes all buttons from the path bar.
"select_item(INDEX)"
Selects the button associated with path part number INDEX in the array given to "set_path()" or "set_items()". This will have the same visual effect as when the user clicked the button in question.

If you used "set_items()" to add your own widgets you can also use an object ref instead of INDEX here.

SIGNALS

"path_clicked(PATH, INDEX)"
Emitted when one of the buttons in the path is clicked. PATH is an array reference containing the path coresponding to the button clicked. INDEX is the list index of the button in the path.

AUTHOR

Jaap Karssenberg || Pardus [Larus] <pardus@cpan.org>

Copyright (c) 2005 Jaap G Karssenberg. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.