Debian Codegraph @

gtk/src/placessidebar.hg

raw
1 /* Copyright (C) 2013 The gtkmm Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
15 */
16
17 #include <vector>
18
19 #include <gtkmm/scrolledwindow.h>
20 #include <gtkmm/menu.h>
21 #include <giomm/file.h>
22 #include <giomm/volume.h>
23
24 _DEFS(gtkmm,gtk)
25 _PINCLUDE(gtkmm/private/scrolledwindow_p.h)
26
27 namespace Gio
28 {
29 class GTKMM_API MountOperation;
30 }
31
32 namespace Gtk
33 {
34
35 /** Sidebar that displays frequently-used places in the file system.
36 *
37 * Gtk::PlacesSidebar is a widget that displays a list of frequently-used places in the
38 * file system: the user's home directory, the user's bookmarks, and volumes and drives.
39 * This widget is used as a sidebar in Gtk::FileChooser and may be used by file managers
40 * and similar programs.
41 *
42 * The places sidebar displays drives and volumes, and will automatically mount
43 * or unmount them when the user selects them.
44 *
45 * Applications can hook to various signals in the places sidebar to customize
46 * its behavior. For example, they can add extra commands to the context menu
47 * of the sidebar.
48 *
49 * While bookmarks are completely in control of the user, the places sidebar also
50 * allows individual applications to provide extra shortcut folders that are unique
51 * to each application. For example, a Paint program may want to add a shortcut
52 * for a Clipart folder. You can do this with Gtk::PlacesSidebar::add_shortcut().
53 *
54 * To make use of the places sidebar, an application at least needs to connect
55 * to the Gtk::PlacesSidebar::open-location signal. This is emitted when the
56 * user selects in the sidebar a location to open. The application should also
57 * call Gtk::PlacesSidebar::set_location() when it changes the currently-viewed
58 * location.
59 *
60 * @ingroup Widgets
61 * @newin{3,10}
62 */
63
64 class GTKMM_API PlacesSidebar
65 : public ScrolledWindow
66 {
67 _CLASS_GTKOBJECT(PlacesSidebar, GtkPlacesSidebar, GTK_PLACES_SIDEBAR, Gtk::ScrolledWindow, GtkScrolledWindow, , , GTKMM_API)
68 public:
69
70 /** Creates a new Gtk::PlacesSidebar widget.
71 *
72 * The application should connect to at least the "open-location" signal
73 * to be notified when the user makes a selection in the sidebar.
74 */
75 _CTOR_DEFAULT
76
77
78 _WRAP_METHOD(void set_open_flags(PlacesOpenFlags flags = PLACES_OPEN_NORMAL), gtk_places_sidebar_set_open_flags)
79 _WRAP_METHOD(PlacesOpenFlags get_open_flags() const, gtk_places_sidebar_get_open_flags)
80
81 _WRAP_METHOD(void set_location(const Glib::RefPtr<const Gio::File>& location), gtk_places_sidebar_set_location)
82
83 // transfer full
84 // get_location returns a new Gio::File; modifiying the returned value does not modify the places sidebar
85 _WRAP_METHOD(Glib::RefPtr<Gio::File> get_location() const, gtk_places_sidebar_get_location)
86
87 _WRAP_METHOD(void set_show_desktop(bool show_desktop = true), gtk_places_sidebar_set_show_desktop)
88 _WRAP_METHOD(bool get_show_desktop() const, gtk_places_sidebar_get_show_desktop)
89
90 _WRAP_METHOD(void add_shortcut(const Glib::RefPtr<Gio::File>& location), gtk_places_sidebar_add_shortcut)
91 _WRAP_METHOD(void remove_shortcut(const Glib::RefPtr<Gio::File>& location), gtk_places_sidebar_remove_shortcut)
92
93 // transfer full
94 // list_shortcuts returns a copy of the list and its elements; modifiying the returned value does not modify the places sidebar
95 #m4 _CONVERSION(`GSList*',`std::vector< Glib::RefPtr<Gio::File> >',`Glib::SListHandler< Glib::RefPtr<Gio::File> >::slist_to_vector($3, Glib::OWNERSHIP_DEEP)')
96 _WRAP_METHOD(std::vector< Glib::RefPtr<Gio::File> > list_shortcuts() const, gtk_places_sidebar_list_shortcuts)
97
98 // transfer full
99 // get_nth_bookmark returns a new Gio::File; modifiying the returned value does not modify the places sidebar
100 _WRAP_METHOD(Glib::RefPtr<Gio::File> get_nth_bookmark(int n) const, gtk_places_sidebar_get_nth_bookmark)
101
102 _WRAP_METHOD(void set_show_connect_to_server(bool show_connect_to_server = true), gtk_places_sidebar_set_show_connect_to_server,
103 deprecated "It is recommended to group this functionality with the drives and network location under the new 'Other Location' item.")
104 _WRAP_METHOD(bool get_show_connect_to_server() const, gtk_places_sidebar_get_show_connect_to_server,
105 deprecated "It is recommended to group this functionality with the drives and network location under the new 'Other Location' item.")
106
107 _WRAP_METHOD(void set_local_only(bool local_only = true), gtk_places_sidebar_set_local_only)
108 _WRAP_METHOD(bool get_local_only() const, gtk_places_sidebar_get_local_only)
109
110 _WRAP_METHOD(void set_show_enter_location(bool show_enter_location = true), gtk_places_sidebar_set_show_enter_location)
111 _WRAP_METHOD(bool get_show_enter_location() const, gtk_places_sidebar_get_show_enter_location)
112
113 _WRAP_METHOD(void set_show_recent(bool show_recent = true), gtk_places_sidebar_set_show_recent)
114 _WRAP_METHOD(bool get_show_recent() const, gtk_places_sidebar_get_show_recent)
115
116 _WRAP_METHOD(void set_show_trash(bool show_trash = true), gtk_places_sidebar_set_show_trash)
117 _WRAP_METHOD(bool get_show_trash() const, gtk_places_sidebar_get_show_trash)
118
119 _WRAP_METHOD(void set_show_other_locations(bool show_other_locations = true), gtk_places_sidebar_set_show_other_locations)
120 _WRAP_METHOD(bool get_show_other_locations() const, gtk_places_sidebar_get_show_other_locations)
121
122 // Gtk+ does not guarantee that context can be a nullptr, not even when visible is false.
123 // See https://bugzilla.gnome.org/show_bug.cgi?id=752633#c3.
124 _WRAP_METHOD(void set_drop_targets_visible(bool visible, const Glib::RefPtr<Gdk::DragContext>& context), gtk_places_sidebar_set_drop_targets_visible)
125
126
127 // We use no_default_handler with _WRAP_SIGNAL because the C *Class struct is hidden for GtkPlacesSidebar.
128 #m4 _CONVERSION(`GFile*',`const Glib::RefPtr<Gio::File>&', `Glib::wrap($3, true)')
129 #m4 _CONVERSION(`GdkDragContext*',`const Glib::RefPtr<Gdk::DragContext>&',Glib::wrap($3, true))
130 #m4 _CONVERSION(`GList*',`const std::vector< Glib::RefPtr<Gio::File> >&',`Glib::ListHandler< Glib::RefPtr<Gio::File> >::list_to_vector($3, Glib::OWNERSHIP_NONE)')
131 _WRAP_SIGNAL(int drag_action_requested(const Glib::RefPtr<Gdk::DragContext>& context, const Glib::RefPtr<Gio::File>& dest_file, const std::vector< Glib::RefPtr<Gio::File> >& source_file_list), "drag_action_requested", no_default_handler)
132 _WRAP_SIGNAL(void drag_perform_drop(const Glib::RefPtr<Gio::File>& dest_file, const std::vector< Glib::RefPtr<Gio::File> >& source_file_list, int action), "drag_perform_drop", no_default_handler)
133
134 _WRAP_SIGNAL(int drag_action_ask(int actions), "drag_action_ask", no_default_handler)
135 _WRAP_SIGNAL(void open_location(const Glib::RefPtr<Gio::File>& location, PlacesOpenFlags open_flags), "open_location", no_default_handler)
136
137 //TODO: From gtk+ 3.18 the first parameter in populate_popup does not have to be a GtkMenu*.
138 //When be can break ABI, change to Container* container. Also change in gtk_signals.defs.patch.
139 #m4 _CONVERSION(`GVolume*',`const Glib::RefPtr<Gio::Volume>&', `Glib::wrap($3, true)')
140 _WRAP_SIGNAL(void populate_popup(Menu* menu, const Glib::RefPtr<Gio::File>& selected_item, const Glib::RefPtr<Gio::Volume>& selected_volume), "populate_popup", no_default_handler)
141
142 _WRAP_SIGNAL(void show_connect_to_server(), "show_connect_to_server", no_default_handler,
143 deprecated "Use signal_show_other_locations() to connect to network servers.")
144 _WRAP_SIGNAL(void show_error_message(const Glib::ustring& primary, const Glib::ustring& secondary), "show_error_message", no_default_handler)
145 _WRAP_SIGNAL(void show_enter_location(), "show_enter_location", no_default_handler)
146 _WRAP_SIGNAL(void show_other_locations(), "show_other_locations", no_default_handler,
147 deprecated "Use signal_show_other_locations_with_flags() instead.")
148 _WRAP_SIGNAL(void show_other_locations_with_flags(PlacesOpenFlags open_flags), "show_other_locations_with_flags", no_default_handler)
149
150 #m4 _CONVERSION(`GMountOperation*',`const Glib::RefPtr<Gio::MountOperation>&',`Glib::wrap($3, true)')
151 _WRAP_SIGNAL(void mount(const Glib::RefPtr<Gio::MountOperation>& mount_operation), "mount", no_default_handler)
152 _WRAP_SIGNAL(void unmount(const Glib::RefPtr<Gio::MountOperation>& mount_operation), "unmount", no_default_handler)
153
154 _WRAP_PROPERTY("local-only", bool)
155 _WRAP_PROPERTY("location", Glib::RefPtr<Gio::File>)
156 _WRAP_PROPERTY("open-flags", PlacesOpenFlags)
157 _WRAP_PROPERTY("show-connect-to-server", bool, deprecated "Use property_show_other_locations() instead.")
158 _WRAP_PROPERTY("show-desktop", bool)
159 _WRAP_PROPERTY("show-enter-location", bool)
160 _WRAP_PROPERTY("show-recent", bool)
161 _WRAP_PROPERTY("show-trash", bool)
162 _WRAP_PROPERTY("show-other-locations", bool)
163 _WRAP_PROPERTY("populate-all", bool)
164 };
165
166 } // namespace Gtk