Search code examples
monowidgetgtk#filechooser

Features and Events in FileChooserWidget GTK#


I'm using GTK#(Newbie) on Xamarin Studio Community version 6.3, on Windows. Recently, I was trying to build a Total Commander application. During the construction, I used the File Chooser Widget and found some issue that I can't solve:

1- When I click on a folder in Places box, a few buttons will appear: \ <icon button with a pen and a paper> enter image description here. When I click on the Icon Button, a Location Entry will show up. However, I don't know how to use that entry like opening a folder, folder path will show up on Location entry or enter folder path, folder will open on the widget. My temporary solution is create a entry:

FileChooserWidget fcw1 = new global::Gtk.FileChooserWidget(((global::Gtk.FileChooserAction)(0)));
Entry e1 = new Entry();

e1.Text = fcw1.CurrentFolder;

I hope to find the way to capture that Location Entry and use it.

2- On the workplace I have a problem in open a file by using Double-Click Event. My code:

[GLib.ConnectBefore]    
protected void OnFcw1ButtonPressEvent(object o, ButtonPressEventArgs args)
        {
            if (((Gdk.EventButton)args.Event).Type == Gdk.EventType.TwoButtonPress)
                 {
                     entry1.Text = fcw1.Filename;
                     if (File.Exists(fcw1.Filename))
                         Process.Start(fcw1.Filename);
                 }
        }

3- The same problem of find The use of the Search and Recently Used that Could not start the search process The program was not able to create a connection to the indexer daemon. Please make sure it is running.

Please help me find the solution and teach me how to find the name of all these widgets. Thank you very much!


Solution

  • To answer #1 there's a Action property on the FileChooser widget which will allow you to set it up for what you want it to do (Open, Create, Select Folder etc). The Location field contains the filename (that you select if browsing, or can type in if creating a new file).

    On #2, default behaviour for double-clicks on FCW is to drill-through on folders and select for files. Because you've got a Glib.ConnectBefore attribute your event handler will run before the default handler. Maybe whatever problem you have in #2 is related to the handlers?

    On #3 sounds like an issue on your dev machine. The FCW will allow you to search the file system so long as it can connect to the daemon so it looks like that's not running. I've not had an issue with that in Windows, Mac OSX, Ubuntu or RHEL on other machines.