Python gi.repository.Gtk 模块,CssProvider() 实例源码

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

项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def start_app(datadir):
    global splash_win
    if not options.no_splash:
        solfege.splash_win = splash_win = SplashWin()
        time.sleep(0.1)
        Gdk.flush()
        while Gtk.events_pending():
            Gtk.main_iteration()

    else:
        solfege.splash_win = splash_win = None
    style_provider = Gtk.CssProvider()
    with open("solfege.css", "r") as f:
        css = f.read()
    try:
        style_provider.load_from_data(css)
    except GObject.GError, e:
        print e
        pass
    Gtk.StyleContext.add_provider_for_screen(
        Gdk.Screen.get_default(), style_provider,
        Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
    GObject.timeout_add(1, start_gui, datadir)
    Gtk.main()
项目:pedro    作者:saandial    | 项目源码 | 文件源码
def gtk_style():
        css = b"""

#button {
    color: #ffffff;
    background: #e80606;
}
#servo {
    color: #ffffff;
    background: #d80606;
}

        """
        style_provider = Gtk.CssProvider()
        style_provider.load_from_data(css)

        Gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(),
            style_provider,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
        )
项目:pedro    作者:saandial    | 项目源码 | 文件源码
def gtk_style():
        css = b"""

#button {
    color: #ffffff;
    background: #e80606;
}
#servo {
    color: #ffffff;
    background: #d80606;
}

        """
        style_provider = Gtk.CssProvider()
        style_provider.load_from_data(css)

        Gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(),
            style_provider,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
        )
项目:ez_gpg    作者:sgnn7    | 项目源码 | 文件源码
def do_activate(self):
        print("Activating...")
        if not self._window:
            current_dir = os.path.dirname(os.path.abspath(__file__))
            css_provider = Gtk.CssProvider()
            css_provider.load_from_path(pkg_resources.resource_filename('ez_gpg',
                                                                        'data/application.css'))

            screen = Gdk.Screen.get_default()
            style_context = Gtk.StyleContext()
            style_context.add_provider_for_screen(screen,
                                                  css_provider,
                                                  Gtk.STYLE_PROVIDER_PRIORITY_USER)

            self._window = MainWindow(self)
            self._window.show_all()

        self.add_window(self._window)

        self._window.present()
项目:apart-gtk    作者:alexheretic    | 项目源码 | 文件源码
def main():
    win = Window()
    # allow keyboard interrupt / nodemon to end program cleanly
    for sig in [signal.SIGINT, signal.SIGTERM, signal.SIGUSR2]:
        signal.signal(sig, lambda _s, _f: win.on_delete())

    style_provider = Gtk.CssProvider()
    style_provider.load_from_path(os.path.dirname(os.path.realpath(__file__)) + "/apart.css")
    Gtk.StyleContext.add_provider_for_screen(
        Gdk.Screen.get_default(),
        style_provider,
        Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
    )

    win.show_all()
    Gtk.main()
项目:Icon-Requests    作者:bil-elmoussaoui    | 项目源码 | 文件源码
def __init__(self):
        Gtk.Application.__init__(self,
                                 application_id="org.gnome.IconRequests",
                                 flags=Gio.ApplicationFlags.FLAGS_NONE)
        GLib.set_application_name(_("Icon Requests"))
        GLib.set_prgname("Icon Requests")


        Gtk.Settings.get_default().set_property(
            "gtk-application-prefer-dark-theme", settings.get_is_night_mode())

        self.menu = Gio.Menu()
        cssProviderFile = Gio.File.new_for_uri(
            'resource:///org/gnome/IconRequests/css/style.css')
        cssProvider = Gtk.CssProvider()
        screen = Gdk.Screen.get_default()
        styleContext = Gtk.StyleContext()
        try:
            cssProvider.load_from_file(cssProviderFile)
            styleContext.add_provider_for_screen(screen, cssProvider,
                                                 Gtk.STYLE_PROVIDER_PRIORITY_USER)
            logging.debug("Loading css file ")
        except Exception as e:
            logging.error("Error message %s" % str(e))
项目:gpt    作者:encarsia    | 项目源码 | 文件源码
def __init__(self):
        self.builder = Gtk.Builder()
        self.builder.set_translation_domain(cli.appname)

        #load tlcalculator and subordinated window glade files
        self.builder.add_from_file(cli.gladefile[0])
        self.builder.add_from_file(cli.gladefile[1])

        #initiate custom css
        #...encode() is needed because CssProvider expects byte type input

        with open(cli.stylesheet,"r") as f:
            css = f.read().encode()

        style_provider = Gtk.CssProvider()
        style_provider.load_from_data(css)

        Gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(),
            style_provider,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
        )
项目:MTTT    作者:roxana-lafuente    | 项目源码 | 文件源码
def gtk_change_visuals(self, light_option="unchanged", theme="unchanged"):
        if Gtk.MAJOR_VERSION >= 3 and Gtk.MINOR_VERSION >= 14:
            css_filename = "gtk"
            filename = ""
            if theme == "metro" or theme == "paper":
                self.gtk_theme = theme
            if light_option == "gtk" or light_option == "gtk-dark":
                self.lightsOption = light_option
            filename = 'gui/' + self.gtk_theme + '/'+ self.lightsOption + '.css'
            css = open(filename, 'r')

            style_provider = Gtk.CssProvider()
            css_data = css.read()
            css.close()

            style_provider.load_from_data(css_data)

            Gtk.StyleContext.add_provider_for_screen(
                Gdk.Screen.get_default(),
                style_provider,
                Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
            )
项目:cozy    作者:geigi    | 项目源码 | 文件源码
def __init_css(self):
        """
        Initialize the main css files and providers.
        Add css classes to the default screen style context.
        """
        if Gtk.get_minor_version() > 18:
            log.debug("Fanciest design possible")
            cssProviderFile = Gio.File.new_for_uri(
                "resource:///de/geigi/cozy/application.css")
        else:
            log.debug("Using legacy css file")
            cssProviderFile = Gio.File.new_for_uri(
                "resource:///de/geigi/cozy/application_legacy.css")
        cssProvider = Gtk.CssProvider()
        cssProvider.load_from_file(cssProviderFile)

        # add the bordered css class to the default screen for the borders around album art
        screen = Gdk.Screen.get_default()
        styleContext = Gtk.StyleContext()
        styleContext.add_provider_for_screen(
            screen, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
        styleContext.add_class("bordered")
项目:SafeEyes    作者:slgobinath    | 项目源码 | 文件源码
def __init__(self, context, on_skip, on_postpone, style_sheet_path):
        self.context = context
        self.count_labels = []
        self.display = Display()
        self.enable_postpone = False
        self.enable_shortcut = False
        self.is_pretified = False
        self.keycode_shortcut_postpone = 65
        self.keycode_shortcut_skip = 9
        self.on_postpone = on_postpone
        self.on_skip = on_skip
        self.shortcut_disable_time = 2
        self.strict_break = False
        self.windows = []

        # Initialize the theme
        css_provider = Gtk.CssProvider()
        css_provider.load_from_path(style_sheet_path)
        Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
项目:Gnome-Authenticator    作者:bil-elmoussaoui    | 项目源码 | 文件源码
def __init__(self):
        Gtk.Application.__init__(self,
                                 application_id="org.gnome.Authenticator",
                                 flags=Gio.ApplicationFlags.FLAGS_NONE)
        GLib.set_application_name(_("Gnome Authenticator"))
        GLib.set_prgname("Gnome Authenticator")

        self.observable = ApplicaitonObservable()

        self.menu = Gio.Menu()
        self.db = Database()

        result = GK.unlock_sync("org.gnome.Authenticator", None)
        if result == GK.Result.CANCELLED:
            self.quit()

        Gtk.Settings.get_default().set_property(
            "gtk-application-prefer-dark-theme", settings.get_is_night_mode())

        if Gtk.get_major_version() >= 3 and Gtk.get_minor_version() >= 20:
            cssFileName = "org.gnome.Authenticator-post3.20.css"
        else:
            cssFileName = "org.gnome.Authenticator-pre3.20.css"
        cssProviderFile = Gio.File.new_for_uri(
            'resource:///org/gnome/Authenticator/%s' % cssFileName)
        cssProvider = Gtk.CssProvider()
        screen = Gdk.Screen.get_default()
        styleContext = Gtk.StyleContext()
        try:
            cssProvider.load_from_file(cssProviderFile)
            styleContext.add_provider_for_screen(screen, cssProvider,
                                                 Gtk.STYLE_PROVIDER_PRIORITY_USER)
            logging.debug("Loading css file ")
        except Exception as e:
            logging.error("Error message %s" % str(e))
项目:sc-controller    作者:kozec    | 项目源码 | 文件源码
def _apply_css(config):
        if OSDWindow.css_provider:
            Gtk.StyleContext.remove_provider_for_screen(
                Gdk.Screen.get_default(), OSDWindow.css_provider)

        colors = {}
        for x in config['osk_colors'] : colors["osk_%s" % (x,)] = config['osk_colors'][x]
        for x in config['osd_colors'] : colors[x] = config['osd_colors'][x]
        colors = OSDCssMagic(colors)
        try:
            css_file = os.path.join(get_share_path(), "osd_styles", config["osd_style"])
            css = file(css_file, "r").read()
            if ((Gtk.get_major_version(), Gtk.get_minor_version()) > (3, 20)):
                css += OSDWindow.CSS_3_20
            OSDWindow.css_provider = Gtk.CssProvider()
            OSDWindow.css_provider.load_from_data((css % colors).encode("utf-8"))
            Gtk.StyleContext.add_provider_for_screen(
                    Gdk.Screen.get_default(),
                    OSDWindow.css_provider,
                    Gtk.STYLE_PROVIDER_PRIORITY_USER)
        except GLib.Error, e:
            log.error("Failed to apply css with user settings:")
            log.error(e)
            log.error("Retrying with default values")

            OSDWindow.css_provider = Gtk.CssProvider()
            css_file = os.path.join(get_share_path(), "osd_styles", "Classic.gtkstyle.css")
            css = file(css_file, "r").read()
            if ((Gtk.get_major_version(), Gtk.get_minor_version()) > (3, 20)):
                css += OSDWindow.CSS_3_20
            OSDWindow.css_provider.load_from_data((css % colors).encode("utf-8"))
            Gtk.StyleContext.add_provider_for_screen(
                    Gdk.Screen.get_default(),
                    OSDWindow.css_provider,
                    Gtk.STYLE_PROVIDER_PRIORITY_USER)
项目:sc-controller    作者:kozec    | 项目源码 | 文件源码
def install_error_css():
        if Editor._error_css_provider is None:
            Editor._error_css_provider = Gtk.CssProvider()
            Editor._error_css_provider.load_from_data(str(Editor.ERROR_CSS))
            Gtk.StyleContext.add_provider_for_screen(
                    Gdk.Screen.get_default(),
                    Editor._error_css_provider,
                    Gtk.STYLE_PROVIDER_PRIORITY_USER)
项目:mcg    作者:coderkun    | 项目源码 | 文件源码
def _load_css(self):
        styleProvider = Gtk.CssProvider()
        styleProvider.load_from_resource(self._get_resource_path('gtk.css'))
        Gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(),
            styleProvider,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
        )
项目:gedit-scroll-past    作者:hardpixel    | 项目源码 | 文件源码
def do_activate(self):
    self._style_provider = Gtk.CssProvider()
    self._current_screen = Gdk.Screen.get_default()

    css = b""".gedit-view { padding-bottom: 400px }"""
    self._style_provider.load_from_data(css)

    Gtk.StyleContext.add_provider_for_screen(
      self._current_screen,
      self._style_provider,
      Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
    )
项目:MTodo    作者:mortezaipo    | 项目源码 | 文件源码
def load_style(self):
        """Load CSS theme."""
        style = Gtk.CssProvider()
        style.load_from_path(self.__config.software_style_file)

        Gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(),
            style,
            Gtk.STYLE_PROVIDER_PRIORITY_USER
        )

        if self.__config.software_is_dark_style == "true":
            settings = Gtk.Settings.get_default()
            settings.set_property("gtk-application-prefer-dark-theme", True)
项目:input-paste    作者:RPing    | 项目源码 | 文件源码
def __init__(self):
        # create a new window
        window = Gtk.Window()
        window.set_position(Gtk.WindowPosition.CENTER)
        window.set_name('window')
        window.set_title("Input Helper")
        window.set_decorated(False)

        window.set_default_size(300, 40)
        window.connect("destroy", self.destroy)

        self.entry = Gtk.Entry()
        self.entry.set_name('entry')
        self.entry.connect("key_press_event", self.on_key_press)

        self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)

        style_provider = Gtk.CssProvider()
        base_dir = os.path.abspath(os.path.dirname(__file__))
        css_path = os.path.join(base_dir, 'input_paste.css')
        style_provider.load_from_file(Gio.File.new_for_path(css_path))
        Gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(),
            style_provider,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
        )

        window.add(self.entry)
        window.show_all()
项目:poseidon    作者:sidus-dev    | 项目源码 | 文件源码
def apply_css():

    # Tested on Gtk 3.18/3.20

    alpha = "popover, .popover { opacity: 0.95; }"

    theme = "#notebook header { background: url('"\
    + theme_file + "') no-repeat center; background-size: cover; }"

    css = """

    #notebook tab { padding: 5px 10px 5px 10px; }
    #frame_main border, #frame_find border, #frame_vte border, #frame_status border,
    #frame_permission border, #frame_cert border, #frame_cookies border { border-style: none; }
    #frame_main, #frame_find, #frame_vte, #frame_status, #frame_permission, #frame_cert, #frame_cookies,
    #frame_mime border, #frame_mime { padding: 5px; }
    #notebook header { background: none; }
    #entry border { border-style: solid; }
    #label_x509 { padding: 10px; }
    #frame_x509 border { border-width: 0px 0px 1px 0px; }

    """

    if trans_pop: css += alpha

    if os.path.exists(theme_file):
        if is_image_valid(theme_file): css += theme

    cssprovider = Gtk.CssProvider()
    cssprovider.load_from_data(bytes(css.encode()))
    screen = Gdk.Screen.get_default()
    stylecontext = Gtk.StyleContext()
    stylecontext.add_provider_for_screen(screen, cssprovider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
项目:revolt    作者:aperezdc    | 项目源码 | 文件源码
def __on_startup(self, app):
        gtk_settings = Gtk.Settings.get_default()
        gtk_settings.set_property("gtk-dialogs-use-header",
                                  self.settings.get_boolean("use-header-bar"))
        css_provider = Gtk.CssProvider()
        css_provider.load_from_resource(self.get_resource_base_path() + "/gtk/custom.css")
        Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), css_provider,
                                                 Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
        self.statusicon = StatusIcon(self)
        self.__action("quit", lambda *arg: self.quit())
        self.__action("about", self.__on_app_about)
        self.__action("preferences", self.__on_app_preferences)
        self.__action("riot-settings", self.__on__riot_settings)
项目:ACYLS    作者:worron    | 项目源码 | 文件源码
def load_gtk_css(file_):
    """Set custom CSS for Gtk theme"""
    style_provider = Gtk.CssProvider()
    style_provider.load_from_path(file_)

    Gtk.StyleContext.add_provider_for_screen(
        Gdk.Screen.get_default(),
        style_provider,
        Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
    )
项目:KTV    作者:RainMark    | 项目源码 | 文件源码
def UI_apply_css(self):
        self.style_provider = Gtk.CssProvider()
        self.font = 'SourceCodePro'
        self.font_size = '16px'
        self.font_update()
项目:hubangl    作者:soonum    | 项目源码 | 文件源码
def _load_custom_css(self):
        css_filepath = pathlib.Path(__file__).parent.joinpath("gui_style.css")
        with css_filepath.open("rb") as css_file:
            css_data = css_file.read()

        style_provider = Gtk.CssProvider()
        style_provider.load_from_data(css_data)

        Gtk.StyleContext.add_provider_for_screen(
                Gdk.Screen.get_default(), style_provider,
                Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
        )
项目:lightdm-settings    作者:linuxmint    | 项目源码 | 文件源码
def __init__(self, title):
        Gtk.Frame.__init__(self)
        self.set_shadow_type(Gtk.ShadowType.IN)
        frame_style = self.get_style_context()
        frame_style.add_class("view")
        self.size_group = Gtk.SizeGroup()
        self.size_group.set_mode(Gtk.SizeGroupMode.VERTICAL)

        self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.add(self.box)

        toolbar = Gtk.Toolbar.new()
        toolbar_context = toolbar.get_style_context()
        Gtk.StyleContext.add_class(Gtk.Widget.get_style_context(toolbar), "cs-header")

        label = Gtk.Label.new()
        label.set_markup("<b>%s</b>" % title)
        title_holder = Gtk.ToolItem()
        title_holder.add(label)
        toolbar.add(title_holder)
        self.box.add(toolbar)

        toolbar_separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)
        self.box.add(toolbar_separator)
        separator_context = toolbar_separator.get_style_context()
        frame_color = frame_style.get_border_color(Gtk.StateFlags.NORMAL).to_string()
        # css_provider = Gtk.CssProvider()
        # css_provider.load_from_data(".separator { -GtkWidget-wide-separators: 0; \
        #                                            color: %s;                    \
        #                                         }" % frame_color)
        # separator_context.add_provider(css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

        self.list_box = Gtk.ListBox()
        self.list_box.set_selection_mode(Gtk.SelectionMode.NONE)
        self.list_box.set_header_func(list_header_func, None)
        self.box.add(self.list_box)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def init_sc_css_provider(toplevel, settings, screen, datadir):
    context = toplevel.get_style_context()
    theme_name = settings.get_property("gtk-theme-name").lower()

    if hasattr(toplevel, '_css_provider'):
        # check old provider, see if we can skip setting or remove old
        # style provider
        if toplevel._css_provider._theme_name == theme_name:
            return
        else:  # clean up old css provider if exixts
            context.remove_provider_for_screen(screen, toplevel._css_provider)

    # munge css path for theme-name
    css_path = os.path.join(datadir,
                            "ui/gtk3/css/softwarecenter.%s.css" % \
                            theme_name)

    # if no css for theme-name try fallback css
    if not os.path.exists(css_path):
        css_path = os.path.join(datadir, "ui/gtk3/css/softwarecenter.css")

    if not os.path.exists(css_path):
        # check fallback exists as well... if not return None but warn
        # its not the end of the world if there is no fallback, just some
        # styling will be derived from the plain ol' Gtk theme
        msg = ("Could not set software-center CSS provider. File '%s' does "
            "not exist!")
        LOG.warn(msg % css_path)
        return

    # things seem ok, now set the css provider for softwarecenter
    msg = "Softwarecenter style provider for %s Gtk theme: %s"
    LOG.debug(msg % (theme_name, css_path))

    provider = Gtk.CssProvider()
    provider._theme_name = theme_name
    toplevel._css_provider = provider

    provider.load_from_path(css_path)
    context.add_provider_for_screen(screen, provider, 800)
    return css_path
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def init_sc_css_provider(toplevel, settings, screen, datadir):
    context = toplevel.get_style_context()
    theme_name = settings.get_property("gtk-theme-name").lower()

    if hasattr(toplevel, '_css_provider'):
        # check old provider, see if we can skip setting or remove old
        # style provider
        if toplevel._css_provider._theme_name == theme_name:
            return
        else:  # clean up old css provider if exixts
            context.remove_provider_for_screen(screen, toplevel._css_provider)

    # munge css path for theme-name
    css_path = os.path.join(datadir,
                            "ui/gtk3/css/softwarecenter.%s.css" % \
                            theme_name)

    # if no css for theme-name try fallback css
    if not os.path.exists(css_path):
        css_path = os.path.join(datadir, "ui/gtk3/css/softwarecenter.css")

    if not os.path.exists(css_path):
        # check fallback exists as well... if not return None but warn
        # its not the end of the world if there is no fallback, just some
        # styling will be derived from the plain ol' Gtk theme
        msg = ("Could not set software-center CSS provider. File '%s' does "
            "not exist!")
        LOG.warn(msg % css_path)
        return

    # things seem ok, now set the css provider for softwarecenter
    msg = "Softwarecenter style provider for %s Gtk theme: %s"
    LOG.debug(msg % (theme_name, css_path))

    provider = Gtk.CssProvider()
    provider._theme_name = theme_name
    toplevel._css_provider = provider

    provider.load_from_path(css_path)
    context.add_provider_for_screen(screen, provider, 800)
    return css_path
项目:kickoff-player    作者:jonian    | 项目源码 | 文件源码
def add_widget_custom_css(widget, style):
  priority = Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
  provider = Gtk.CssProvider()
  context  = widget.get_style_context()
  filename = relative_path(style)

  if os.path.exists(filename):
    provider.load_from_path(filename)
  else:
    provider.load_from_data(style.encode())

  context.add_provider(provider, priority)
项目:kickoff-player    作者:jonian    | 项目源码 | 文件源码
def add_custom_css(style):
  screen   = Gdk.Screen.get_default()
  priority = Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
  provider = Gtk.CssProvider()
  filename = relative_path(style)

  if os.path.exists(filename):
    provider.load_from_path(filename)
  else:
    provider.load_from_data(style.encode())

  Gtk.StyleContext.add_provider_for_screen(screen, provider, priority)
项目:mate-menu    作者:ubuntu-mate    | 项目源码 | 文件源码
def SetupMateMenuBorder(self):
        style = self.window.get_style_context()
        styleProvider = Gtk.CssProvider()
        styleProvider.load_from_data(".background { border-width: %dpt; }" % self.borderwidth)
        style.add_provider(styleProvider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

        self.border.set_margin_top(self.borderwidth)
        self.border.set_margin_bottom(self.borderwidth)
        self.border.set_margin_start(self.borderwidth)
        self.border.set_margin_end(self.borderwidth)
项目:MokaPlayer    作者:vedard    | 项目源码 | 文件源码
def __init__(self, appconfig, userconfig, player):
        super().__init__(title="MokaPlayer", default_width=1366, default_height=768)

        self.logger = logging.getLogger('MainWindow')
        self.appconfig = appconfig
        self.userconfig = userconfig
        self.player = player
        self.current_playlist = SongsPlaylist()
        self.set_icon_from_file(self.ICON_FILE)
        self.has_flowbox_album_loaded = False
        self.has_flowbox_artist_loaded = False
        self.is_fullscreen = False

        style_provider = Gtk.CssProvider()
        style_provider.load_from_path(self.CSS_FILE)
        Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

        if self.userconfig['gtk']['darktheme']:
            settings = Gtk.Settings.get_default()
            settings.set_property("gtk-application-prefer-dark-theme", True)

        self.connect("destroy", self.on_window_destroy)
        self.connect("key-press-event", self.on_window_key_press)
        self.connect("window-state-event", self.on_window_state_event)

        self.builder = Gtk.Builder()
        self.builder.add_from_file(self.GLADE_FILE)
        self.__get_object()
        self.__init_sort_radio()
        self.__init_gridview_columns()
        self.__init_sidebar()
        self.__init_txt_goto()
        self.__init_cmb_visualiser()

        self.builder.connect_signals(self)
        self.player.state_changed.subscribe(self.on_player_state_changed)
        self.player.audio_changed.subscribe(self.on_audio_changed)
        self.player.volume_changed.subscribe(self.on_volume_changed)

        self.__set_current_song_info()
        self.on_volume_changed()

        self.__show_current_playlist()

        GObject.timeout_add(750, self.on_tick, None)
        self.logger.info('Window loaded')

        if not self.player.library.is_musics_folder_valid():
            self.__ask_for_music_folder()
项目:pytimetrack    作者:fhackerz    | 项目源码 | 文件源码
def do_startup(self):
        mark_time("in app startup")

        self.check_schema()
        self.create_data_directory()

        Gtk.Application.do_startup(self)

        mark_time("basic app startup done")

        css = Gtk.CssProvider()
        css.load_from_path(CSS_FILE)
        screen = Gdk.Screen.get_default()
        Gtk.StyleContext.add_provider_for_screen(
            screen, css, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
        mark_time("CSS loaded")

        builder = Gtk.Builder.new_from_file(MENUS_UI_FILE)
        self.set_app_menu(builder.get_object('app_menu'))
        mark_time("menus loaded")

        self.actions = self.Actions(self)

        if not hasattr(self, 'set_accels_for_action'):
            self.set_accels_for_action = self.fallback_set_accels

        self.set_accels_for_action("win.detail-level::chronological", ["<Alt>1"])
        self.set_accels_for_action("win.detail-level::grouped", ["<Alt>2"])
        self.set_accels_for_action("win.detail-level::summary", ["<Alt>3"])
        self.set_accels_for_action("win.time-range::day", ["<Alt>4"])
        self.set_accels_for_action("win.time-range::week", ["<Alt>5"])
        self.set_accels_for_action("win.time-range::month", ["<Alt>6"])
        self.set_accels_for_action("win.show-task-pane", ["F9"])
        self.set_accels_for_action("win.show-menu", ["F10"])
        self.set_accels_for_action("win.show-search-bar", ["<Primary>F"])
        self.set_accels_for_action("win.go-back", ["<Alt>Left"])
        self.set_accels_for_action("win.go-forward", ["<Alt>Right"])
        self.set_accels_for_action("win.go-home", ["<Alt>Home"])
        self.set_accels_for_action("app.edit-log", ["<Primary>E"])
        self.set_accels_for_action("app.edit-tasks", ["<Primary>T"])
        self.set_accels_for_action("app.help", ["F1"])
        self.set_accels_for_action("app.preferences", ["<Primary>P"])
        self.set_accels_for_action("app.quit", ["<Primary>Q"])
        self.set_accels_for_action("win.report", ["<Primary>D"])
        self.set_accels_for_action("win.cancel-report", ["Escape"])
        self.set_accels_for_action("win.send-report", ["<Primary>Return"])

        mark_time("app startup done")