Gtk2::E...rectory(3)

πŸ“¦
version 0.11 Β· 2 versions
, in fedora 43

πŸ’– Gtk2::Ex::Dialogs::ChooseDirectory πŸ’–

okay bestie, welcome to the Gtk2::Ex::Dialogs::ChooseDirectory page from the User Contributed Perl Documentation manual πŸ’… this one's a little Perl module that pops up a directory picker, and honestly? she's iconic for it.


✨ NAME ✨

Gtk2::Ex::Dialogs::ChooseDirectory β€” Provides a file selection dialog. (yes bestie, a file selection dialog, that's literally what the original says, no I will not be editing the official description, that's a crime 🫢)


🌸 SYNOPSIS 🌸

 use Gtk2::Ex::Dialogs::ChooseDirectory ( destroy_with_parent => TRUE,
                                          modal => TRUE );

 # do some stuff like creating your app's main $window then,
 # to ensure that all messages use the right parent, set it:
 $Gtk2::Ex::Dialogs::ChooseDirectory::parent_window = $window;

 # now popup a new dialog for selecting an existing directory
 my $dir = select Gtk2::Ex::Dialogs::ChooseDirectory ( "/path/to/somewhere" );

 # ok, now we need to create a new directory (doesn't actually make
 # the directory), returns a dir that does not exist.
 my $dir = create Gtk2::Ex::Dialogs::ChooseDirectory ( "/path/to/somewhere" );

no cap, that's the whole vibe right there. you use it with your options, you set the parent window so all your dialogs know who their mother is, then you select or create. that's it. slay. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so this module gives you a simple file chooser api that wraps Gtk2::FileChooser objectively. the whole mission statement β€” the ~objective~, if you will β€” is a simple way to prompt a user to open or save a file. periodt. πŸŽ€

it's giving "I'm the friend who handles the boring GTK2 boilerplate so you don't have to." lowkey obsessed.


✨ OPTIONS ✨

bestie, listen. all public methods (and like, the entire class too, she's generous like that) support the following options:

  • title => STRING β€” the text string that becomes the title of the dialog window. defaults to either "Select" or "Create" depending on the action context β€” she picks based on the vibe of what you're doing ✨
  • path => STRING β€” the path to a file or directory you wanna initialize the dialog with. defaults to the current working directory, which honestly is a very reasonable default, we respect her for it.
  • parent_window => Gtk2::Window β€” a reference to your main application window. the mother of the operation, if you will πŸ‘‘
  • destroy_with_parent => BOOL β€” so when the parent_window gets destroyed... what do we do? defaults to FALSE. that's the whole description, bestie, the manpage is not elaborating and neither am I 😭
  • modal => BOOL β€” does this dialog make the parent_window freeze while the dialog exists? defaults to FALSE. (frozen parent window is giving "girl you are NOT going anywhere until you pick a directory") 🧊
  • must_exist => BOOL β€” the end-user must supply a path to an existing file or directory. and if they hand over a non-existant path? the dialog gets respawned until an existing file is chosen. she will not let it go. defaults to FALSE. πŸ’€
side note: non-existant is spelled exactly like that in the original and I am NOT touching it, that's a relic, that's history, that's protected πŸ’–

🌈 PUBLIC METHODS 🌈

OBJECT = new ( OPTIONS | PATH )

create a Gtk2::FileChooserDialog with the options you gave her and show it to the end-user. once the user has selected a directory, return only the path to the directoy and clean up. 🧚

and in the special case of being passed only one argument? all options get set to defaults and that one lonely argument gets used as the path argument. main character energy for a single string fr fr.

directoy is also spelled exactly like that in the original. we love her, typos and all. 🫢

RESPONSE = ask_to_select ( OPTIONS | PATH )

supports all the same arguments as new(). this creates a new Gtk2::Ex::Dialogs::ChooseDirectory with some specific defaults, and returns the user's response. and if you give her only one argument, it gets used as the path option. same deal as always, bestie. ⭐

RESPONSE = ask_to_create ( OPTIONS | PATH )

supports all the same arguments as new() too. creates a new Gtk2::Ex::Dialogs::ChooseDirectory with some specific defaults, and returns the user's response. one argument only? guess what β€” path option. πŸŽ€


πŸ’œ SEE ALSO πŸ’œ

go read these, they're her friends and they're all slaying in their own lanes:

  • Gtk2::FileChooser
  • Gtk2::FileChooserDialog
  • Gtk2::Ex::Dialogs
  • Gtk2::Ex::Dialogs::ChooseDirectory
  • Gtk2::Ex::Dialogs::ChooseFile
  • Gtk2::Ex::Dialogs::ChoosePreviewFile
  • Gtk2::Ex::Dialogs::ErrorMsg
  • Gtk2::Ex::Dialogs::Message
  • Gtk2::Ex::Dialogs::Question

😭 BUGS 😭

found a bug? please report any bugs to the mailing list. that's it, that's the instruction, go tell the list, they're lovely, they'll listen 🫢


πŸ’Œ MAILING LIST πŸ’Œ

 http://opendoorsoftware.com/lists/gtk2-ex-list
 gtk2-ex-list@opendoorsoftware.com

the group chat, essentially. πŸ’¬


πŸ‘‘ AUTHORS πŸ‘‘

  • Kevin C. Krinke, <kckrinke@opendoorsoftware.com>
  • James Greenhalgh, <jgreenhalgh@opendoorsoftware.com>

two icons. we stan. 🌟


 Gtk2::Ex::Dialogs::ChooseDirectory - Provides a directory selection dialog.
 Copyright (C) 2005 Open Door Software Inc. <ods@opendoorsoftware.com>

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.

 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
important bestie warning: that WITHOUT ANY WARRANTY line is not a joke, it is literally the license talking. no warranty, no promises, no "it'll definitely work," that's the deal. read your licenses, they're doing numbers for a reason πŸ’…

and that's the page!! this one came out of the perl v5.42.0 manual, dated 2025-07-25, and yes she's still serving directory-picker realness all this time later. go pick a folder, bestie, you've earned it πŸŽ€βœ¨πŸ¦‹πŸ’–

πŸ“¦ where this page comes from