Python gi.repository.GLib 模块,get_user_config_dir() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用gi.repository.GLib.get_user_config_dir()

项目:nvim-pygtk3    作者:rliang    | 项目源码 | 文件源码
def __init__(self, name, path, *args, **kwargs):
        super().__init__(*args,
                         application_id=f'org.{name}',
                         flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE,
                         **kwargs)
        self.runtime = ','.join(os.path.join(p, 'runtime') for p in path)
        self.scripts = os.path.join(GLib.get_user_config_dir(), name, '*.py')
        self.scripts = [compile(open(script).read(), script, 'exec')
                        for script in glob(self.scripts)]
项目:gedit-jshint    作者:Meseira    | 项目源码 | 文件源码
def get_config_dir():
    return os.path.join(GLib.get_user_config_dir(), 'gedit/jshint')
项目:ukui-menu    作者:ukui    | 项目源码 | 文件源码
def __init__( self ):
        GObject.GObject.__init__( self )
        self.icons = { }
        self.count = 0

        # Some apps don't put a default icon in the default theme folder, so we will search all themes
        def createTheme( d ):
            theme = Gtk.IconTheme()
            theme.set_custom_theme( d )
            return theme

        # This takes to much time and there are only a very few applications that use icons from different themes
        #self.themes = map(  createTheme, [ d for d in os.listdir( "/usr/share/icons" ) if os.path.isdir( os.path.join( "/usr/share/icons", d ) ) ] )

        self.defaultTheme = Gtk.IconTheme.get_default()

        # Setup and clean up the temp icon dir
        configDir = GLib.get_user_config_dir()
        self.iconDir = os.path.join(configDir, "ukui-menu")
        if not os.path.exists(self.iconDir):
            os.makedirs(self.iconDir)
        # Skip over files and dirs belonging to the applications plugin
        contents = frozenset(os.listdir(self.iconDir)) - frozenset(('applications', 'applications.list'))
        for fn in contents:
            if os.path.isfile(os.path.join(self.iconDir, fn)):
                print (("Removing file : " + os.path.join(self.iconDir, fn)))
                os.remove(os.path.join(self.iconDir, fn))
            else:
                print ((os.path.join(self.iconDir, fn) + " is not a file, skipping delete."))

        self.defaultTheme.append_search_path(self.iconDir)

        # Themes with the same content as the default them aren't needed
        #self.themes = [ theme for theme in self.themes if  theme.list_icons() != defaultTheme.list_icons() ]

        self.themes = [ self.defaultTheme ]

        # Listen for changes in the themes
        for theme in self.themes:
            theme.connect("changed", self.themeChanged )
项目:mate-menu    作者:ubuntu-mate    | 项目源码 | 文件源码
def __init__( self ):
        GObject.GObject.__init__( self )
        self.icons = { }
        self.count = 0

        # Some apps don't put a default icon in the default theme folder, so we will search all themes
        def createTheme( d ):
            theme = Gtk.IconTheme()
            theme.set_custom_theme( d )
            return theme

        # This takes to much time and there are only a very few applications that use icons from different themes
        #self.themes = map(  createTheme, [ d for d in os.listdir( "/usr/share/icons" ) if os.path.isdir( os.path.join( "/usr/share/icons", d ) ) ] )

        self.defaultTheme = Gtk.IconTheme.get_default()

        # Setup and clean up the temp icon dir
        configDir = GLib.get_user_config_dir()
        self.iconDir = os.path.join(configDir, "mate-menu")
        if not os.path.exists(self.iconDir):
            os.makedirs(self.iconDir)
        # Skip over files and dirs belonging to the applications plugin
        contents = frozenset(os.listdir(self.iconDir)) - frozenset(('applications', 'applications.list'))
        for fn in contents:
            if os.path.isfile(os.path.join(self.iconDir, fn)):
                print "Removing file : " + os.path.join(self.iconDir, fn)
                os.remove(os.path.join(self.iconDir, fn))
            else:
                print os.path.join(self.iconDir, fn) + " is not a file, skipping delete."

        self.defaultTheme.append_search_path(self.iconDir)

        # Themes with the same content as the default them aren't needed
        #self.themes = [ theme for theme in self.themes if  theme.list_icons() != defaultTheme.list_icons() ]

        self.themes = [ self.defaultTheme ]

        # Listen for changes in the themes
        for theme in self.themes:
            theme.connect("changed", self.themeChanged )
项目:mate-menu    作者:ubuntu-mate    | 项目源码 | 文件源码
def do_gtk_bookmarks( self ):
        if self.showGtkBookmarks:
            bookmarksFile = os.path.join(GLib.get_user_config_dir(), "gtk-3.0", "bookmarks")
            if not os.path.exists(bookmarksFile):
                bookmarksFile = os.path.join(GLib.get_home_dir(), ".gtk-bookmarks")
            if not os.path.exists(bookmarksFile):
                return
            bookmarks = []
            with open(bookmarksFile, "r") as f:
                for line in f:
                    #line = line.replace('file://', '')
                    line = line.rstrip()
                    if not line:
                        continue
                    parts = line.split(' ', 1)

                    if len(parts) == 2:
                        path, name = parts
                    elif len(parts) == 1:
                        path = parts[0]
                        name = os.path.basename(os.path.normpath(path))
                    bookmarks.append((name, path))

            for name, path in bookmarks:
                name = unquote(name)
                currentbutton = easyButton( "folder", self.iconsize, [name], -1, -1 )
                currentbutton.connect( "clicked", self.launch_gtk_bookmark, path )
                currentbutton.show()
                self.placesBtnHolder.pack_start( currentbutton, False, False, 0)