/* Copyright (C) 2013 The gtkmm Development Team * * 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, see . */ #include #include #include #include #include _DEFS(gtkmm,gtk) _PINCLUDE(gtkmm/private/scrolledwindow_p.h) namespace Gio { class GTKMM_API MountOperation; } namespace Gtk { /** Sidebar that displays frequently-used places in the file system. * * Gtk::PlacesSidebar is a widget that displays a list of frequently-used places in the * file system: the user's home directory, the user's bookmarks, and volumes and drives. * This widget is used as a sidebar in Gtk::FileChooser and may be used by file managers * and similar programs. * * The places sidebar displays drives and volumes, and will automatically mount * or unmount them when the user selects them. * * Applications can hook to various signals in the places sidebar to customize * its behavior. For example, they can add extra commands to the context menu * of the sidebar. * * While bookmarks are completely in control of the user, the places sidebar also * allows individual applications to provide extra shortcut folders that are unique * to each application. For example, a Paint program may want to add a shortcut * for a Clipart folder. You can do this with Gtk::PlacesSidebar::add_shortcut(). * * To make use of the places sidebar, an application at least needs to connect * to the Gtk::PlacesSidebar::open-location signal. This is emitted when the * user selects in the sidebar a location to open. The application should also * call Gtk::PlacesSidebar::set_location() when it changes the currently-viewed * location. * * @ingroup Widgets * @newin{3,10} */ class GTKMM_API PlacesSidebar : public ScrolledWindow { _CLASS_GTKOBJECT(PlacesSidebar, GtkPlacesSidebar, GTK_PLACES_SIDEBAR, Gtk::ScrolledWindow, GtkScrolledWindow, , , GTKMM_API) public: /** Creates a new Gtk::PlacesSidebar widget. * * The application should connect to at least the "open-location" signal * to be notified when the user makes a selection in the sidebar. */ _CTOR_DEFAULT _WRAP_METHOD(void set_open_flags(PlacesOpenFlags flags = PLACES_OPEN_NORMAL), gtk_places_sidebar_set_open_flags) _WRAP_METHOD(PlacesOpenFlags get_open_flags() const, gtk_places_sidebar_get_open_flags) _WRAP_METHOD(void set_location(const Glib::RefPtr& location), gtk_places_sidebar_set_location) // transfer full // get_location returns a new Gio::File; modifiying the returned value does not modify the places sidebar _WRAP_METHOD(Glib::RefPtr get_location() const, gtk_places_sidebar_get_location) _WRAP_METHOD(void set_show_desktop(bool show_desktop = true), gtk_places_sidebar_set_show_desktop) _WRAP_METHOD(bool get_show_desktop() const, gtk_places_sidebar_get_show_desktop) _WRAP_METHOD(void add_shortcut(const Glib::RefPtr& location), gtk_places_sidebar_add_shortcut) _WRAP_METHOD(void remove_shortcut(const Glib::RefPtr& location), gtk_places_sidebar_remove_shortcut) // transfer full // list_shortcuts returns a copy of the list and its elements; modifiying the returned value does not modify the places sidebar #m4 _CONVERSION(`GSList*',`std::vector< Glib::RefPtr >',`Glib::SListHandler< Glib::RefPtr >::slist_to_vector($3, Glib::OWNERSHIP_DEEP)') _WRAP_METHOD(std::vector< Glib::RefPtr > list_shortcuts() const, gtk_places_sidebar_list_shortcuts) // transfer full // get_nth_bookmark returns a new Gio::File; modifiying the returned value does not modify the places sidebar _WRAP_METHOD(Glib::RefPtr get_nth_bookmark(int n) const, gtk_places_sidebar_get_nth_bookmark) _WRAP_METHOD(void set_show_connect_to_server(bool show_connect_to_server = true), gtk_places_sidebar_set_show_connect_to_server, deprecated "It is recommended to group this functionality with the drives and network location under the new 'Other Location' item.") _WRAP_METHOD(bool get_show_connect_to_server() const, gtk_places_sidebar_get_show_connect_to_server, deprecated "It is recommended to group this functionality with the drives and network location under the new 'Other Location' item.") _WRAP_METHOD(void set_local_only(bool local_only = true), gtk_places_sidebar_set_local_only) _WRAP_METHOD(bool get_local_only() const, gtk_places_sidebar_get_local_only) _WRAP_METHOD(void set_show_enter_location(bool show_enter_location = true), gtk_places_sidebar_set_show_enter_location) _WRAP_METHOD(bool get_show_enter_location() const, gtk_places_sidebar_get_show_enter_location) _WRAP_METHOD(void set_show_recent(bool show_recent = true), gtk_places_sidebar_set_show_recent) _WRAP_METHOD(bool get_show_recent() const, gtk_places_sidebar_get_show_recent) _WRAP_METHOD(void set_show_trash(bool show_trash = true), gtk_places_sidebar_set_show_trash) _WRAP_METHOD(bool get_show_trash() const, gtk_places_sidebar_get_show_trash) _WRAP_METHOD(void set_show_other_locations(bool show_other_locations = true), gtk_places_sidebar_set_show_other_locations) _WRAP_METHOD(bool get_show_other_locations() const, gtk_places_sidebar_get_show_other_locations) // Gtk+ does not guarantee that context can be a nullptr, not even when visible is false. // See https://bugzilla.gnome.org/show_bug.cgi?id=752633#c3. _WRAP_METHOD(void set_drop_targets_visible(bool visible, const Glib::RefPtr& context), gtk_places_sidebar_set_drop_targets_visible) // We use no_default_handler with _WRAP_SIGNAL because the C *Class struct is hidden for GtkPlacesSidebar. #m4 _CONVERSION(`GFile*',`const Glib::RefPtr&', `Glib::wrap($3, true)') #m4 _CONVERSION(`GdkDragContext*',`const Glib::RefPtr&',Glib::wrap($3, true)) #m4 _CONVERSION(`GList*',`const std::vector< Glib::RefPtr >&',`Glib::ListHandler< Glib::RefPtr >::list_to_vector($3, Glib::OWNERSHIP_NONE)') _WRAP_SIGNAL(int drag_action_requested(const Glib::RefPtr& context, const Glib::RefPtr& dest_file, const std::vector< Glib::RefPtr >& source_file_list), "drag_action_requested", no_default_handler) _WRAP_SIGNAL(void drag_perform_drop(const Glib::RefPtr& dest_file, const std::vector< Glib::RefPtr >& source_file_list, int action), "drag_perform_drop", no_default_handler) _WRAP_SIGNAL(int drag_action_ask(int actions), "drag_action_ask", no_default_handler) _WRAP_SIGNAL(void open_location(const Glib::RefPtr& location, PlacesOpenFlags open_flags), "open_location", no_default_handler) //TODO: From gtk+ 3.18 the first parameter in populate_popup does not have to be a GtkMenu*. //When be can break ABI, change to Container* container. Also change in gtk_signals.defs.patch. #m4 _CONVERSION(`GVolume*',`const Glib::RefPtr&', `Glib::wrap($3, true)') _WRAP_SIGNAL(void populate_popup(Menu* menu, const Glib::RefPtr& selected_item, const Glib::RefPtr& selected_volume), "populate_popup", no_default_handler) _WRAP_SIGNAL(void show_connect_to_server(), "show_connect_to_server", no_default_handler, deprecated "Use signal_show_other_locations() to connect to network servers.") _WRAP_SIGNAL(void show_error_message(const Glib::ustring& primary, const Glib::ustring& secondary), "show_error_message", no_default_handler) _WRAP_SIGNAL(void show_enter_location(), "show_enter_location", no_default_handler) _WRAP_SIGNAL(void show_other_locations(), "show_other_locations", no_default_handler, deprecated "Use signal_show_other_locations_with_flags() instead.") _WRAP_SIGNAL(void show_other_locations_with_flags(PlacesOpenFlags open_flags), "show_other_locations_with_flags", no_default_handler) #m4 _CONVERSION(`GMountOperation*',`const Glib::RefPtr&',`Glib::wrap($3, true)') _WRAP_SIGNAL(void mount(const Glib::RefPtr& mount_operation), "mount", no_default_handler) _WRAP_SIGNAL(void unmount(const Glib::RefPtr& mount_operation), "unmount", no_default_handler) _WRAP_PROPERTY("local-only", bool) _WRAP_PROPERTY("location", Glib::RefPtr) _WRAP_PROPERTY("open-flags", PlacesOpenFlags) _WRAP_PROPERTY("show-connect-to-server", bool, deprecated "Use property_show_other_locations() instead.") _WRAP_PROPERTY("show-desktop", bool) _WRAP_PROPERTY("show-enter-location", bool) _WRAP_PROPERTY("show-recent", bool) _WRAP_PROPERTY("show-trash", bool) _WRAP_PROPERTY("show-other-locations", bool) _WRAP_PROPERTY("populate-all", bool) }; } // namespace Gtk