Gtk.PlacesSidebar
Gtk.PlacesSidebar是一个部件。用来显示位于文件系统中的如用户的主目录,用户的书签,和卷和驱动器等。这个widget用作Gtk.FileChooser一个工具,并且可以通过文件管理器和类似的程序中使用
继承关系
Gtk.PlacesSidebar是Gtk.ScrolledWindow的直接子类
Methods
方法修饰词 | 方法名及参数 |
---|---|
static | new () |
add_shortcut (location) | |
get_local_only () | |
get_location () | |
get_nth_bookmark (n) | |
get_open_flags () | |
get_show_connect_to_server () | |
get_show_desktop () | |
get_show_enter_location () | |
get_show_other_locations () | |
get_show_recent () | |
get_show_trash () | |
list_shortcuts () | |
remove_shortcut (location) | |
set_drop_targets_visible (visible, context) | |
set_local_only (local_only) | |
set_location (location) | |
set_open_flags (flags) | |
set_show_connect_to_server (show_connect_to_server) | |
set_show_desktop (show_desktop) | |
set_show_enter_location (show_enter_location) | |
set_show_other_locations (show_other_locations) | |
set_show_recent (show_recent) | |
set_show_trash (show_trash) |
Virtual Methods
Properties
Name | Type | Flags | Short Description |
---|---|---|---|
local-only | bool | r/w | Whether the sidebar only includes local files |
location | Gio.File | r/w | The location to highlight in the sidebar |
open-flags | Gtk.PlacesOpenFlags | r/w | Modes in which the calling application can open locations selected in the sidebar |
populate-all | bool | r/w | Whether to emit ::populate-popup for popups that are not menus |
show-connect-to-server | bool | d/r/w | Whether the sidebar includes a builtin shortcut to a ‘Connect to server’ dialog deprecated |
show-desktop | bool | r/w | Whether the sidebar includes a builtin shortcut to the Desktop folder |
show-enter-location | bool | r/w | Whether the sidebar includes a builtin shortcut to manually enter a location |
show-other-locations | bool | r/w | Whether the sidebar includes an item to show external locations |
show-recent | bool | r/w | Whether the sidebar includes a builtin shortcut for recent files |
show-trash | bool | r/w | Whether the sidebar includes a builtin shortcut to the Trash location |
Signals
Name | Short Description |
---|---|
drag-action-ask | The places sidebar emits this signal when it needs to ask the application to pop up a menu to ask the user for which drag action to perform. |
drag-action-requested | When the user starts a drag-and-drop operation and the sidebar needs to ask the application for which drag action to perform, then the sidebar will emit this signal. |
drag-perform-drop | The places sidebar emits this signal when the user completes a drag-and-drop operation and one of the sidebar’s items is the destination. |
mount | The places sidebar emits this signal when it starts a new operation because the user clicked on some location that needs mounting. |
open-location | The places sidebar emits this signal when the user selects a location in it. |
populate-popup | The places sidebar emits this signal when the user invokes a contextual popup on one of its items. |
show-connect-to-server | The places sidebar emits this signal when it needs the calling application to present an way to connect directly to a network server. deprecated |
show-enter-location | The places sidebar emits this signal when it needs the calling application to present an way to directly enter a location. |
show-error-message | The places sidebar emits this signal when it needs the calling application to present an error message. |
show-other-locations | The places sidebar emits this signal when it needs the calling application to present a way to show other locations e.g. deprecated |
show-other-locations-with-flags | The places sidebar emits this signal when it needs the calling application to present a way to show other locations e.g. |
unmount | The places sidebar emits this signal when it starts a new operation because the user for example ejected some drive or unmounted a mount. |
例子
代码:
#!/usr/bin/env python3
# Created by xiaosanyu at 16/7/11
# section 056
#
# author: xiaosanyu
# website: yuxiaosan.tk \
# http://blog.youkuaiyun.com/a87b01c14
# created: 16/7/11
TITLE = "PlacesSidebar"
DESCRIPTION = """
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
"""
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class PlacesSidebarWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="PlacesSidebar Demo")
self.set_size_request(200, 200)
widget = Gtk.PlacesSidebar()
widget.props.show_enter_location = True
widget.props.show_other_locations = True
widget.props.populate_all = True
self.add(widget)
def main():
win = PlacesSidebarWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
if __name__ == "__main__":
main()
代码解析
代码下载地址:http://download.youkuaiyun.com/detail/a87b01c14/9594728