Beispiel #1
0
def apply_gtk_css(theme):
    gtk_version = "%s.%s.%s" % (Gtk.get_major_version(),
                                Gtk.get_minor_version(),
                                Gtk.get_micro_version())
    if Gtk.get_major_version() == 3 and Gtk.get_minor_version() >= 22:
        print("Gtk version is " + gtk_version +
              ", Flowblade theme is available.")
    else:
        print("Gtk version is " + gtk_version +
              ", Flowblade theme only available for Gtk >= 3.22")
        editorpersistance.prefs.theme = appconsts.LIGHT_THEME
        editorpersistance.save()
        return False

    provider = Gtk.CssProvider.new()
    display = Gdk.Display.get_default()
    screen = display.get_default_screen()
    Gtk.StyleContext.add_provider_for_screen(
        screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
    if theme == appconsts.FLOWBLADE_THEME:
        css_path = "/res/css/gtk-flowblade-dark.css"
    elif theme == appconsts.FLOWBLADE_THEME_NEUTRAL:
        css_path = "/res/css3/gtk-flowblade-dark.css"
    else:  # appconsts.FLOWBLADE_THEME_GRAY
        css_path = "/res/css2/gtk-flowblade-dark.css"
    provider.load_from_path(respaths.ROOT_PATH + css_path)

    return True
Beispiel #2
0
 def send_bugreport(self):
     """
     Return None if successful. Return the urllib2 execption if failure.
     """
     try:
         windowsversion = str(sys.getwindowsversion())
     except AttributeError:
         windowsversion = "(not running ms windows)"
     buf = self.g_tw.get_buffer()
     description = buf.get_text(buf.get_start_iter(), buf.get_end_iter(),
                                False)
     data = urllib.urlencode({
         'email': self.g_email.get_text(),
         'version': buildinfo.VERSION_STRING,
         'revision_id': buildinfo.REVISION_ID,
         #'pygtk_version': "pygi",
         'gtk': "(%s.%s.%s)" % (Gtk.get_major_version(),
                                      Gtk.get_minor_version(),
                                      Gtk.get_micro_version()),
         'sys.version': sys.version,
         'sys.platform': sys.platform,
         'windowsversion': windowsversion,
         'short_description': self.g_description.get_text(),
         'description': description,
         'traceback': self.m_error_text,
     })
     try:
         urllib2.urlopen("http://www.solfege.org/crashreport/", data)
     except urllib2.HTTPError, e:
         print "HTTPError:", e
    def _get_sys_information(self):
        """
        Get relevant system information.
        """
        distribution = "" # print nothing if there's nothing to print
        if hasattr(os, "uname"):
            distribution = "Distribution: %s\n" % os.uname()[2]

        sqlite = "sqlite version: %s (%s) \n" % (sqlite3_version_str,
                                                 sqlite3_py_version_str)

        return "Gramps version: %s \n"\
               "Python version: %s \n"\
               "BSDDB version: %s \n"\
               "%s"\
               "LANG: %s\n"\
               "OS: %s\n"\
               "%s\n"\
               "GTK version    : %s\n"\
               "gobject version: %s\n"\
               "cairo version  : %s"\
               % (str(VERSION),
                  str(sys.version).replace('\n',''),
                  BSDDB_STR,
                  sqlite,
                  get_env_var('LANG',''),
                  platform.system(),
                  distribution,
                  '%d.%d.%d' % (Gtk.get_major_version(),
                                Gtk.get_minor_version(),
                                Gtk.get_micro_version()),
                  '%d.%d.%d' % GObject.pygobject_version,
                  cairo.version_info)
Beispiel #4
0
def check_gtk_version():
    """ Check GTK version """
    # Check desired GTK Version
    major_needed = int(GTK_VERSION_NEEDED.split(".")[0])
    minor_needed = int(GTK_VERSION_NEEDED.split(".")[1])
    micro_needed = int(GTK_VERSION_NEEDED.split(".")[2])

    # Check system GTK Version
    major = Gtk.get_major_version()
    minor = Gtk.get_minor_version()
    micro = Gtk.get_micro_version()

    # Thus will be called from our liveCD that already
    # has the latest GTK version. This is here just to
    # help testing Thus in our environment.
    wrong_gtk_version = False
    if major_needed > major:
        wrong_gtk_version = True
    if major_needed == major and minor_needed > minor:
        wrong_gtk_version = True
    if major_needed == major and minor_needed == minor and micro_needed > micro:
        wrong_gtk_version = True

    if wrong_gtk_version:
        text = "Detected GTK version {0}.{1}.{2} but version {3} is needed."
        text = text.format(major, minor, micro, GTK_VERSION_NEEDED)
        logging.info(text)
        return False
    else:
        logging.info("Using GTK v{0}.{1}.{2}".format(major, minor, micro))

    return True
Beispiel #5
0
def get_platform_info():
    from gi.repository import GObject
    from gi.repository import Gtk
    import yaml

    functions = [
        platform.machine,
        platform.platform,
        platform.processor,
        platform.python_version,
        platform.release,
        platform.system,
    ]
    names_values = [(func.__name__, func()) for func in functions]

    names_values.extend(
        [
            (
                "GTK",
                (
                    Gtk.get_major_version(),
                    Gtk.get_minor_version(),
                    Gtk.get_micro_version(),
                ),
            ),
            ("Glib", GObject.glib_version),
            ("PyGObject", GObject.pygobject_version),
            ("YAML", yaml.__version__),
        ]
    )

    vals = ["{}: {}".format(name, val) for name, val in names_values]
    return "System info: " + ", ".join(vals)
Beispiel #6
0
def print_platform_info():
    import platform
    from gi.repository import GObject
    from gi.repository import Gtk
    from gi.repository import Gst
    import mutagen
    import PIL

    functions = [
        platform.machine, platform.platform, platform.processor,
        platform.python_version, platform.release, platform.system
    ]
    names_values = [(func.__name__, func()) for func in functions]

    names_values.extend([
        ('GTK', (Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version())),
        ('Glib', GObject.glib_version),
        ('PyGObject', GObject.pygobject_version),
        ('GST', Gst.version_string()),
        ('Mutagen', mutagen.version),
        ('PIL', PIL.VERSION),
        ])

    values = ['%s: %s' % (name, val) for name, val in names_values]
    logging.info('System info: ' + ', '.join(values))
Beispiel #7
0
    def about_cb(self, action, parameter):
        aboutdialog = Gtk.AboutDialog(modal=True, transient_for=self.win)
        aboutdialog.set_program_name(aboutdialog.get_program_name() +
                                     " %s" % VERSION)

        _shell = GnomeShellFactory().get_shell()
        if _shell is not None:
            if _shell.mode == "user":
                about_comment = _("GNOME Shell") + " %s" % _shell.version
            else:
                about_comment = (_("GNOME Shell") + " %s " + _("(%s mode)")) % \
                    (_shell.version, _shell.mode)
        else:
            about_comment = _("GNOME Shell is not running")

        about_comment += "\n" + _("GTK") + " %d.%d.%d" % \
            (Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version())
        aboutdialog.set_comments(about_comment)

        aboutdialog.set_copyright("Copyright © 2011 - 2013 John Stowers.")
        aboutdialog.set_logo_icon_name("org.gnome.tweaks")
        aboutdialog.set_website("https://wiki.gnome.org/Apps/Tweaks")
        aboutdialog.set_website_label(_("Homepage"))
        aboutdialog.set_license_type(Gtk.License.GPL_3_0)

        AUTHORS = ["John Stowers <*****@*****.**>"]

        aboutdialog.set_authors(AUTHORS)
        aboutdialog.connect("response", lambda w, r: aboutdialog.destroy())
        aboutdialog.show()
Beispiel #8
0
def main():
    """
    Main function that starts everything
    """
    if is_wayland() and gdk_backend().lower() != 'x11' and not is_wayland_compatibility_on():
        warn = """
                    [!]
        Looks like you are in Wayland session
        Please run Ulauncher with env var
        GDK_BACKEND set to 'x11' like this:

        GDK_BACKEND=x11 ulauncher
        """
        print(warn, file=sys.stderr)
        sys.exit(1)

    # start DBus loop
    DBusGMainLoop(set_as_default=True)
    bus = dbus.SessionBus()
    instance = bus.request_name(DBUS_SERVICE)

    if instance != dbus.bus.REQUEST_NAME_REPLY_PRIMARY_OWNER:
        toggle_window = dbus.SessionBus().get_object(DBUS_SERVICE, DBUS_PATH).get_dbus_method("toggle_window")
        toggle_window()
        return

    _create_dirs()

    options = get_options()
    setup_logging(options)
    logger = logging.getLogger('ulauncher')
    logger.info('Ulauncher version %s' % get_version())
    logger.info("GTK+ %s.%s.%s" % (Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version()))
    logger.info("Is Wayland: %s" % is_wayland())
    logger.info("Wayland compatibility: %s" % ('on' if is_wayland_compatibility_on() else 'off'))

    # log uncaught exceptions
    def except_hook(exctype, value, tb):
        logger.error("Uncaught exception", exc_info=(exctype, value, tb))

    sys.excepthook = except_hook

    window = UlauncherWindow.get_instance()
    UlauncherDbusService(window)
    if not options.hide_window:
        window.show()

    if Settings.get_instance().get_property('show-indicator-icon'):
        AppIndicator.get_instance().show()

    # workaround to make Ctrl+C quiting the app
    signal_handler = SignalHandler(window)
    gtk_thread = run_async(Gtk.main)()
    try:
        while gtk_thread.is_alive() and not signal_handler.killed():
            time.sleep(0.5)
    except KeyboardInterrupt:
        logger.warn('On KeyboardInterrupt')
    finally:
        Gtk.main_quit()
Beispiel #9
0
    def do_startup(self):
        Gtk.Application.do_startup(self)

        if self.purge_recent:
            items = recent_manager.get_items()
            for item in items:
                uri = item.get_uri()
                if item.get_application_info("pychess"):
                    recent_manager.remove_item(uri)

        self.git_rev = ""

        self.initGlade(self.log_viewer)
        self.addPerspectives()
        self.handleArgs(self.chess_file)
        create_task(checkversion())

        self.loaded_cids = {}
        self.saved_cids = {}
        self.terminated_cids = {}

        log.info("PyChess %s %s git %s" % (VERSION_NAME, VERSION, self.git_rev))
        log.info("Command line args: '%s'" % self.chess_file)
        log.info("Platform: %s" % platform.platform())
        log.info("Python version: %s.%s.%s" % sys.version_info[0:3])
        log.info("Pyglib version: %s.%s.%s" % GLib.pyglib_version)
        log.info("Gtk version: %s.%s.%s" % (Gtk.get_major_version(),
                                            Gtk.get_minor_version(),
                                            Gtk.get_micro_version()))
Beispiel #10
0
 def __init__(self, config_file=None):
     super(KingPhisherClientApplication, self).__init__()
     self.logger = logging.getLogger('KingPhisher.Client.Application')
     # log version information for debugging purposes
     self.logger.debug("gi.repository GLib version: {0}".format('.'.join(
         map(str, GLib.glib_version))))
     self.logger.debug("gi.repository GObject version: {0}".format('.'.join(
         map(str, GObject.pygobject_version))))
     self.logger.debug("gi.repository Gtk version: {0}.{1}.{2}".format(
         Gtk.get_major_version(), Gtk.get_minor_version(),
         Gtk.get_micro_version()))
     if tools.has_vte:
         self.logger.debug("gi.repository VTE version: {0}".format(
             tools.Vte._version))
     if graphs.has_matplotlib:
         self.logger.debug("matplotlib version: {0}".format(
             graphs.matplotlib.__version__))
     self.set_property('application-id', 'org.king-phisher.client')
     self.set_property('register-session', True)
     self.config_file = (config_file or CONFIG_FILE_PATH)
     """The file containing the King Phisher client configuration."""
     self.config = None
     """The main King Phisher client configuration."""
     try:
         self.load_config(load_defaults=True)
     except IOError:
         self.logger.critical('failed to load the client configuration')
         raise
Beispiel #11
0
    def __init__(self, app):
        """Create the necessary objects and settings.

        Args:
            app: The main vimiv application to interact with.
        """
        datadir = os.path.join(get_user_data_dir(), "vimiv")
        os.makedirs(datadir, exist_ok=True)
        self._filename = os.path.join(datadir, "vimiv.log")
        self._terminal = sys.stderr
        # Redirect stderr in debug mode so it is written to the log file as well
        if app.debug:
            sys.stderr = self
        # Create a new log file at startup
        with open(self._filename, "w") as f:
            f.write("Vimiv log written to " +
                    self._filename.replace(os.getenv("HOME"), "~") + "\n")
        self._write_separator()
        # Header containing version and Gtk version
        self.write_message("Version", app["information"].get_version())
        self.write_message("Python", sys.version.split()[0])
        gtk_version = str(Gtk.get_major_version()) + "." \
            + str(Gtk.get_minor_version()) + "." \
            + str(Gtk.get_micro_version())
        self.write_message("GTK", gtk_version)
        self._write_separator()
        # Start time
        self.write_message("Started", "time")
Beispiel #12
0
    def _get_sys_information(self):
        """
        Get relevant system information.
        """
        distribution = ""  # print nothing if there's nothing to print
        if hasattr(os, "uname"):
            distribution = "Distribution: %s\n" % os.uname()[2]

        sqlite = "sqlite version: %s (%s) \n" % (sqlite3_version_str,
                                                 sqlite3_py_version_str)

        return "Gramps version: %s \n"\
               "Python version: %s \n"\
               "BSDDB version: %s \n"\
               "%s"\
               "LANG: %s\n"\
               "OS: %s\n"\
               "%s\n"\
               "GTK version    : %s\n"\
               "gobject version: %s\n"\
               "cairo version  : %s"\
               % (str(VERSION),
                  str(sys.version).replace('\n',''),
                  BSDDB_STR,
                  sqlite,
                  get_env_var('LANG',''),
                  platform.system(),
                  distribution,
                  '%d.%d.%d' % (Gtk.get_major_version(),
                                Gtk.get_minor_version(),
                                Gtk.get_micro_version()),
                  '%d.%d.%d' % GObject.pygobject_version,
                  cairo.version_info)
Beispiel #13
0
    def _get_sys_information(self):
        """
        Get relevant system information.
        """
        if hasattr(os, "uname"):
            operatingsystem = os.uname()[0]
            distribution = os.uname()[2]
        else:
            operatingsystem = sys.platform
            distribution = " "

        return "Python version: %s \n"\
               "BSDDB version: %s \n"\
               "sqlite version: %s (%s) \n"\
               "Gramps version: %s \n"\
               "LANG: %s\n"\
               "OS: %s\n"\
               "Distribution: %s\n\n"\
               "GTK version    : %s\n"\
               "gobject version: %s\n"\
               "cairo version  : %s"\
               % (str(sys.version).replace('\n',''),
                  BSDDB_STR,
                  sqlite3_version_str,
                  sqlite3_py_version_str,
                  str(VERSION),
                  get_env_var('LANG',''),
                  operatingsystem,
                  distribution,
                  '%d.%d.%d' % (Gtk.get_major_version(),
                            Gtk.get_minor_version(), Gtk.get_micro_version()),
                  '%d.%d.%d' % GObject.pygobject_version,
                  cairo.version_info)
Beispiel #14
0
def main(root_path, filename):
    gtk_version = "%s.%s.%s" % (Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version())
    print "GTK+ version:", gtk_version
    editorstate.gtk_version = gtk_version
    try:
        editorstate.mlt_version = mlt.LIBMLT_VERSION
    except:
        editorstate.mlt_version = "0.0.99" # magic string for "not found"

    # Create user folders if need and determine if were using xdg or dotfile userf folders.
    userfolders.init()

    # Set paths.
    respaths.set_paths(root_path)

    # Load editor prefs and list of recent projects
    editorpersistance.load()
    
    # Init translations module with translations data
    translations.init_languages()
    translations.load_filters_translations()
    mlttransitions.init_module()

    # Init gtk threads
    Gdk.threads_init()
    Gdk.threads_enter()

    # Themes
    if editorpersistance.prefs.theme != appconsts.LIGHT_THEME:
        Gtk.Settings.get_default().set_property("gtk-application-prefer-dark-theme", True)
        if editorpersistance.prefs.theme == appconsts.FLOWBLADE_THEME:
            gui.apply_gtk_css()

    repo = mlt.Factory().init()
    processutils.prepare_mlt_repo(repo)
    
    # Set numeric locale to use "." as radix, MLT initilizes this to OS locale and this causes bugs 
    locale.setlocale(locale.LC_NUMERIC, 'C')

    # Check for codecs and formats on the system
    mltenv.check_available_features(repo)
    renderconsumer.load_render_profiles()

    # Load filter and compositor descriptions from xml files.
    mltfilters.load_filters_xml(mltenv.services)
    mlttransitions.load_compositors_xml(mltenv.transitions)

    # Create list of available mlt profiles
    mltprofiles.load_profile_list()

    appconsts.SAVEFILE_VERSION = projectdata.SAVEFILE_VERSION

    global linker_window
    linker_window = MediaLinkerWindow()

    if filename != NO_PROJECT_AT_LAUNCH:
        linker_window.load_project(filename)

    Gtk.main()
    Gdk.threads_leave()
Beispiel #15
0
def main(root_path, filename):
    gtk_version = "%s.%s.%s" % (Gtk.get_major_version(),
                                Gtk.get_minor_version(),
                                Gtk.get_micro_version())
    print "GTK+ version:", gtk_version
    editorstate.gtk_version = gtk_version
    try:
        editorstate.mlt_version = mlt.LIBMLT_VERSION
    except:
        editorstate.mlt_version = "0.0.99"  # magic string for "not found"

    # Set paths.
    respaths.set_paths(root_path)

    # Load editor prefs and list of recent projects
    editorpersistance.load()

    # Init translations module with translations data
    translations.init_languages()
    translations.load_filters_translations()
    mlttransitions.init_module()

    # Init gtk threads
    Gdk.threads_init()
    Gdk.threads_enter()

    # Themes
    if editorpersistance.prefs.theme != appconsts.LIGHT_THEME:
        Gtk.Settings.get_default().set_property(
            "gtk-application-prefer-dark-theme", True)
        if editorpersistance.prefs.theme == appconsts.FLOWBLADE_THEME:
            gui.apply_gtk_css()

    repo = mlt.Factory().init()
    processutils.prepare_mlt_repo(repo)

    # Set numeric locale to use "." as radix, MLT initilizes this to OS locale and this causes bugs
    locale.setlocale(locale.LC_NUMERIC, 'C')

    # Check for codecs and formats on the system
    mltenv.check_available_features(repo)
    renderconsumer.load_render_profiles()

    # Load filter and compositor descriptions from xml files.
    mltfilters.load_filters_xml(mltenv.services)
    mlttransitions.load_compositors_xml(mltenv.transitions)

    # Create list of available mlt profiles
    mltprofiles.load_profile_list()

    appconsts.SAVEFILE_VERSION = projectdata.SAVEFILE_VERSION

    global linker_window
    linker_window = MediaLinkerWindow()

    if filename != NO_PROJECT_AT_LAUNCH:
        linker_window.load_project(filename)

    Gtk.main()
    Gdk.threads_leave()
Beispiel #16
0
def main(root_path, filename):
    # This the main for launched process, this is reached via 'flowblademediaimport' laucher file
    gtk_version = "%s.%s.%s" % (Gtk.get_major_version(),
                                Gtk.get_minor_version(),
                                Gtk.get_micro_version())
    print("GTK+ version:", gtk_version)
    editorstate.gtk_version = gtk_version
    try:
        editorstate.mlt_version = mlt.LIBMLT_VERSION
    except:
        editorstate.mlt_version = "0.0.99"  # magic string for "not found"

    # Read the XDG_* variables etc.
    userfolders.init()

    # Set paths.
    respaths.set_paths(root_path)

    # Load editor prefs and list of recent projects
    editorpersistance.load()

    # Init translations module with translations data
    translations.init_languages()
    translations.load_filters_translations()
    mlttransitions.init_module()

    # Init gtk threads
    Gdk.threads_init()
    Gdk.threads_enter()

    # Themes
    if editorpersistance.prefs.theme != appconsts.LIGHT_THEME:
        Gtk.Settings.get_default().set_property(
            "gtk-application-prefer-dark-theme", True)
        if editorpersistance.prefs.theme == appconsts.FLOWBLADE_THEME \
            or editorpersistance.prefs.theme == appconsts.FLOWBLADE_THEME_GRAY \
            or editorpersistance.prefs.theme == appconsts.FLOWBLADE_THEME_NEUTRAL:
            gui.apply_gtk_css(editorpersistance.prefs.theme)

    repo = mlt.Factory().init()
    processutils.prepare_mlt_repo(repo)

    # Set numeric locale to use "." as radix, MLT initilizes this to OS locale and this causes bugs
    locale.setlocale(locale.LC_NUMERIC, 'C')

    # Check for codecs and formats on the system
    mltenv.check_available_features(repo)
    renderconsumer.load_render_profiles()

    # Load filter and compositor descriptions from xml files.
    mltfilters.load_filters_xml(mltenv.services)
    mlttransitions.load_compositors_xml(mltenv.transitions)

    # Create list of available mlt profiles
    mltprofiles.load_profile_list()

    GLib.idle_add(_do_assets_write, filename)

    Gtk.main()
    Gdk.threads_leave()
Beispiel #17
0
def check_gtk_version():
    """ Check GTK version """
    # Check desired GTK Version
    major_needed = int(GTK_VERSION_NEEDED.split(".")[0])
    minor_needed = int(GTK_VERSION_NEEDED.split(".")[1])
    micro_needed = int(GTK_VERSION_NEEDED.split(".")[2])

    # Check system GTK Version
    major = Gtk.get_major_version()
    minor = Gtk.get_minor_version()
    micro = Gtk.get_micro_version()

    # Cnchi will be called from our liveCD that already
    # has the latest GTK version. This is here just to
    # help testing Cnchi in our environment.
    wrong_gtk_version = False
    if major_needed > major:
        wrong_gtk_version = True
    if major_needed == major and minor_needed > minor:
        wrong_gtk_version = True
    if major_needed == major and minor_needed == minor and micro_needed > micro:
        wrong_gtk_version = True

    if wrong_gtk_version:
        text = "Detected GTK version {0}.{1}.{2} but version>={3} is needed."
        text = text.format(major, minor, micro, GTK_VERSION_NEEDED)
        logging.info(text)
        return False
    else:
        logging.info("Using GTK v{0}.{1}.{2}".format(major, minor, micro))

    return True
Beispiel #18
0
def get_libs_version_string():
    """Get a string describing the versions of important libs.

    >>> type(get_libs_version_string()) == str
    True

    """
    versions = [
        ("Python", "{major}.{minor}.{micro}".format(
            major = sys.version_info.major,
            minor = sys.version_info.minor,
            micro = sys.version_info.micro,
        )),
        ("GTK", "{major}.{minor}.{micro}".format(
            major = Gtk.get_major_version(),
            minor = Gtk.get_minor_version(),
            micro = Gtk.get_micro_version(),
        )),
        ("GdkPixbuf", GdkPixbuf.PIXBUF_VERSION),
        ("Cairo", cairo.cairo_version_string()),  # NOT cairo.version
        ("GLib", "{major}.{minor}.{micro}".format(
            major = GLib.MAJOR_VERSION,
            minor = GLib.MINOR_VERSION,
            micro = GLib.MICRO_VERSION,
        )),
    ]
    return ", ".join([" ".join(t) for t in versions])
Beispiel #19
0
    def do_startup(self):
        Gtk.Application.do_startup(self)

        if self.purge_recent:
            items = recent_manager.get_items()
            for item in items:
                uri = item.get_uri()
                if item.get_application_info("pychess"):
                    recent_manager.remove_item(uri)

        self.git_rev = ""

        self.initGlade(self.log_viewer)
        self.addPerspectives()
        self.handleArgs(self.chess_file)
        if self.version_check:
            create_task(checkversion())

        self.loaded_cids = {}
        self.saved_cids = {}
        self.terminated_cids = {}

        log.info("PyChess %s %s git %s" %
                 (VERSION_NAME, VERSION, self.git_rev))
        log.info("Command line args: '%s'" % self.chess_file)
        log.info("Platform: %s" % platform.platform())
        log.info("Python version: %s.%s.%s" % sys.version_info[0:3])
        log.info("Pyglib version: %s.%s.%s" % GLib.pyglib_version)
        log.info("Gtk version: %s.%s.%s" %
                 (Gtk.get_major_version(), Gtk.get_minor_version(),
                  Gtk.get_micro_version()))
    def _get_sys_information(self):
        """
        Get relevant system information.
        """
        if hasattr(os, "uname"):
            operatingsystem = os.uname()[0]
            distribution = os.uname()[2]
        else:
            operatingsystem = sys.platform
            distribution = " "

        return "Python version: %s \n"\
               "BSDDB version: %s \n"\
               "Gramps version: %s \n"\
               "LANG: %s\n"\
               "OS: %s\n"\
               "Distribution: %s\n\n"\
               "GTK version    : %s\n"\
               "gobject version: %s\n"\
               "cairo version  : %s"\
               % (str(sys.version).replace('\n',''),
                  BSDDB_STR,
                  str(VERSION),
                  get_env_var('LANG',''),
                  operatingsystem,
                  distribution,
                  '%d.%d.%d' % (Gtk.get_major_version(), 
                            Gtk.get_minor_version(), Gtk.get_micro_version()),
                  '%d.%d.%d' % GObject.pygobject_version,
                  cairo.version_info)
Beispiel #21
0
    def __init__(self, config_file=None, use_plugins=True, use_style=True):
        super(KingPhisherClientApplication, self).__init__()
        if use_style:
            gtk_version = (Gtk.get_major_version(), Gtk.get_minor_version())
            if gtk_version > (3, 18):
                self._theme_file = 'theme.v2.css'
            else:
                self._theme_file = 'theme.v1.css'
        else:
            self._theme_file = DISABLED
        self.logger = logging.getLogger('KingPhisher.Client.Application')
        # log version information for debugging purposes
        self.logger.debug("gi.repository GLib version: {0}".format('.'.join(
            map(str, GLib.glib_version))))
        self.logger.debug("gi.repository GObject version: {0}".format('.'.join(
            map(str, GObject.pygobject_version))))
        self.logger.debug("gi.repository Gtk version: {0}.{1}.{2}".format(
            Gtk.get_major_version(), Gtk.get_minor_version(),
            Gtk.get_micro_version()))
        if rpc_terminal.has_vte:
            self.logger.debug("gi.repository VTE version: {0}".format(
                rpc_terminal.Vte._version))
        if graphs.has_matplotlib:
            self.logger.debug("matplotlib version: {0}".format(
                graphs.matplotlib.__version__))
        self.set_property('application-id', 'org.king-phisher.client')
        self.set_property('register-session', True)
        self.config_file = config_file or os.path.join(USER_DATA_PATH,
                                                       'config.json')
        """The file containing the King Phisher client configuration."""
        if not os.path.isfile(self.config_file):
            self._create_config()
        self.config = None
        """The primary King Phisher client configuration."""
        self.main_window = None
        """The primary top-level :py:class:`~.MainAppWindow` instance."""
        self.rpc = None
        """The :py:class:`~.KingPhisherRPCClient` instance for the application."""
        self._ssh_forwarder = None
        """The SSH forwarder responsible for tunneling RPC communications."""
        self.style_provider = None
        try:
            self.emit('config-load', True)
        except IOError:
            self.logger.critical('failed to load the client configuration')
            raise

        self.connect('window-added', self.signal_window_added)
        self.actions = {}
        self._create_actions()

        if not use_plugins:
            self.logger.info('disabling all plugins')
            self.config['plugins.enabled'] = []
        self.plugin_manager = plugins.ClientPluginManager([
            os.path.join(USER_DATA_PATH, 'plugins'),
            find.find_data_directory('plugins')
        ], self)
        if use_plugins:
            self.plugin_manager.load_all()
Beispiel #22
0
def _init_gtk():
    import gi
    gi.require_version('GLib', '2.0')
    gi.require_version('Gio', '2.0')
    gi.require_version('Gtk', '3.0')
    gi.require_version('Gdk', '3.0')
    gi.require_version('GObject', '2.0')
    gi.require_version('Pango', '1.0')

    from gi.repository import Gtk
    gtk_ver = '%s.%s.%s' % (Gtk.get_major_version(),
                            Gtk.get_minor_version(),
                            Gtk.get_micro_version())
    if V(gtk_ver) < V(_MIN_GTK_VER):
        print('Gajim needs GTK >= %s to run. '
              'Quitting...' % _MIN_GTK_VER)
        sys.exit(1)

    from gajim.gtk import exception
    exception.init()

    i18n.initialize_direction_mark()

    from gajim.application import GajimApplication

    # Fix bug in 3.24.1 with flickering tooltips
    if sys.platform in ('darwin', 'win32'):
        settings = Gtk.Settings.get_default()
        settings.set_property('gtk-cursor-theme-size', 16)

    application = GajimApplication()
    _install_sginal_handlers(application)
    application.run(sys.argv)
Beispiel #23
0
def get_libs_version_string():
    """Get a string describing the versions of important libs.

    >>> type(get_libs_version_string()) == str
    True

    """
    versions = [
        ("Python", "{major}.{minor}.{micro}".format(
            major=sys.version_info.major,
            minor=sys.version_info.minor,
            micro=sys.version_info.micro,
        )),
        ("GTK", "{major}.{minor}.{micro}".format(
            major=Gtk.get_major_version(),
            minor=Gtk.get_minor_version(),
            micro=Gtk.get_micro_version(),
        )),
        ("GdkPixbuf", GdkPixbuf.PIXBUF_VERSION),
        ("Cairo", cairo.cairo_version_string()),  # NOT cairo.version
        ("GLib", "{major}.{minor}.{micro}".format(
            major=GLib.MAJOR_VERSION,
            minor=GLib.MINOR_VERSION,
            micro=GLib.MICRO_VERSION,
        )),
    ]
    return ", ".join([" ".join(t) for t in versions])
Beispiel #24
0
def _init_gtk():
    import gi
    gi.require_version('GLib', '2.0')
    gi.require_version('Gio', '2.0')
    gi.require_version('Gtk', '3.0')
    gi.require_version('Gdk', '3.0')
    gi.require_version('GObject', '2.0')
    gi.require_version('Pango', '1.0')

    from gi.repository import Gtk
    gtk_ver = '%s.%s.%s' % (Gtk.get_major_version(),
                            Gtk.get_minor_version(),
                            Gtk.get_micro_version())
    if V(gtk_ver) < V(_MIN_GTK_VER):
        print('Gajim needs GTK+ >= %s to run. '
              'Quitting...' % _MIN_GTK_VER)
        sys.exit(1)

    from gajim import gtkexcepthook
    gtkexcepthook.init()

    i18n.initialize_direction_mark()

    from gajim.application import GajimApplication

    application = GajimApplication()
    _install_sginal_handlers(application)
    application.run(sys.argv)
Beispiel #25
0
def main(root_path, force_launch=False):
    init_dirs_if_needed()
    
    gtk_version = "%s.%s.%s" % (Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version())
    editorstate.gtk_version = gtk_version
    try:
        editorstate.mlt_version = mlt.LIBMLT_VERSION
    except:
        editorstate.mlt_version = "0.0.99" # magic string for "not found"
        
    # Set paths.
    respaths.set_paths(root_path)

    # Load editor prefs and list of recent projects
    editorpersistance.load()
    
    # Init translations module with translations data
    translations.init_languages()
    translations.load_filters_translations()
    mlttransitions.init_module()

    # Init gtk threads
    Gdk.threads_init()
    Gdk.threads_enter()

    repo = mlt.Factory().init()

    # Set numeric locale to use "." as radix, MLT initilizes this to OS locale and this causes bugs 
    locale.setlocale(locale.LC_NUMERIC, 'C')

    # Check for codecs and formats on the system
    mltenv.check_available_features(repo)
    renderconsumer.load_render_profiles()

    # Load filter and compositor descriptions from xml files.
    mltfilters.load_filters_xml(mltenv.services)
    mlttransitions.load_compositors_xml(mltenv.transitions)

    # Create list of available mlt profiles
    mltprofiles.load_profile_list()

    global render_queue
    render_queue = RenderQueue()
    render_queue.load_render_items()

    global batch_window
    batch_window = BatchRenderWindow()

    if render_queue.error_status != None:
        primary_txt = _("Error loading render queue items!")
        secondary_txt = _("Message:\n") + render_queue.get_error_status_message()
        dialogutils.warning_message(primary_txt, secondary_txt, batch_window.window)

    DBusGMainLoop(set_as_default=True)
    global _dbus_service
    _dbus_service = BatchRenderDBUSService()

    Gtk.main()
    Gdk.threads_leave()
Beispiel #26
0
def gtk_version_newer_than(major=3, minor=0, micro=0):
    _major = Gtk.get_major_version()
    _minor = Gtk.get_minor_version()
    _micro = Gtk.get_micro_version()

    return (_major > major) or \
           (_major == major and _minor > minor) or \
           (_major == major and _minor == minor and _micro >= micro)
Beispiel #27
0
    def get_issue_text(self, traceback_text):
        gtk_ver = '%i.%i.%i' % (Gtk.get_major_version(),
                                Gtk.get_minor_version(),
                                Gtk.get_micro_version())
        gobject_ver = '.'.join(map(str, GObject.pygobject_version))

        return ISSUE_TEXT.format(get_os_info(), gtk_ver, gobject_ver,
                                 nbxmpp.__version__, gajim_version,
                                 traceback_text)
Beispiel #28
0
def format_exception_details(exc_type, exc_value, exc_traceback, error_uid=None):
	"""
	Format exception details to be show to a human. This should include enough
	information about the type of error that occurred and the system on which
	it was triggered to allow someone to attempt to debug and fix it. The first
	three parameters to this function directly correspond to the values
	returned from the :py:func:`sys.exc_info` function.

	:param exc_type: The type of the exception.
	:param exc_value: The exception instance.
	:param exc_traceback: The traceback object corresponding to the exception.
	:param error_uid: A unique identifier for this exception.
	:type error_uid: str, :py:class:`uuid.UUID`
	:return: A formatted message containing the details about the exception and environment.
	:rtype: str
	"""
	if isinstance(error_uid, uuid.UUID):
		error_uid = str(error_uid)
	elif error_uid is None:
		error_uid = 'N/A'
	elif not isinstance(error_uid, str):
		raise TypeError('error_uid must be an instance of either str, uuid.UUID or None')
	pversion = 'UNKNOWN'
	if its.on_linux:
		pversion = 'Linux: ' + ' '.join(platform.linux_distribution())
	elif its.on_windows:
		pversion = 'Windows: ' + ' '.join(platform.win32_ver())
		if its.frozen:
			pversion += ' (Frozen=True)'
		else:
			pversion += ' (Frozen=False)'
	exc_name = format_exception_name(exc_type)
	rpc_error_details = 'N/A (Not a remote RPC error)'
	if isinstance(exc_value, advancedhttpserver.RPCError) and exc_value.is_remote_exception:
		rpc_error_details = "Name: {0}".format(exc_value.remote_exception['name'])
		if exc_value.remote_exception.get('message'):
			rpc_error_details += " Message: '{0}'".format(exc_value.remote_exception['message'])
	current_tid = threading.current_thread().ident
	thread_info = (
		"{0: >4}{1} (alive={2} daemon={3})".format(('=> ' if thread.ident == current_tid else ''), thread.name, thread.is_alive(), thread.daemon) for thread in threading.enumerate()
	)
	thread_info = '\n'.join(thread_info)
	details = EXCEPTION_DETAILS_TEMPLATE.format(
		error_details=repr(exc_value),
		error_type=exc_name,
		error_uid=error_uid,
		rpc_error_details=rpc_error_details,
		king_phisher_version=version.version,
		platform_version=pversion,
		python_version="{0}.{1}.{2}".format(*sys.version_info),
		gtk_version="{0}.{1}.{2}".format(Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version()),
		stack_trace=''.join(traceback.format_exception(exc_type, exc_value, exc_traceback)),
		thread_info=thread_info,
		timezone=tzlocal.get_localzone().zone
	)
	details = details.strip() + '\n'
	return details
Beispiel #29
0
def format_exception_details(exc_type, exc_value, exc_traceback, error_uid=None):
	"""
	Format exception details to be show to a human. This should include enough
	information about the type of error that occurred and the system on which
	it was triggered to allow someone to attempt to debug and fix it. The first
	three parameters to this function directly correspond to the values
	returned from the :py:func:`sys.exc_info` function.

	:param exc_type: The type of the exception.
	:param exc_value: The exception instance.
	:param exc_traceback: The traceback object corresponding to the exception.
	:param error_uid: A unique identifier for this exception.
	:type error_uid: str, :py:class:`uuid.UUID`
	:return: A formatted message containing the details about the exception and environment.
	:rtype: str
	"""
	if isinstance(error_uid, uuid.UUID):
		error_uid = str(error_uid)
	elif error_uid is None:
		error_uid = 'N/A'
	elif not isinstance(error_uid, str):
		raise TypeError('error_uid must be an instance of either str, uuid.UUID or None')
	pversion = 'UNKNOWN'
	if its.on_linux:
		pversion = 'Linux: ' + ' '.join(platform.linux_distribution())
	elif its.on_windows:
		pversion = 'Windows: ' + ' '.join(platform.win32_ver())
		if its.frozen:
			pversion += ' (Frozen=True)'
		else:
			pversion += ' (Frozen=False)'
	exc_name = format_exception_name(exc_type)
	rpc_error_details = 'N/A (Not a remote RPC error)'
	if isinstance(exc_value, advancedhttpserver.RPCError) and exc_value.is_remote_exception:
		rpc_error_details = "Name: {0}".format(exc_value.remote_exception['name'])
		if exc_value.remote_exception.get('message'):
			rpc_error_details += " Message: '{0}'".format(exc_value.remote_exception['message'])
	current_tid = threading.current_thread().ident
	thread_info = (
		"{0: >4}{1} (alive={2} daemon={3})".format(('=> ' if thread.ident == current_tid else ''), thread.name, thread.is_alive(), thread.daemon) for thread in threading.enumerate()
	)
	thread_info = '\n'.join(thread_info)
	details = EXCEPTION_DETAILS_TEMPLATE.format(
		error_details=repr(exc_value),
		error_type=exc_name,
		error_uid=error_uid,
		rpc_error_details=rpc_error_details,
		king_phisher_version=version.version,
		platform_version=pversion,
		python_version="{0}.{1}.{2}".format(*sys.version_info),
		gtk_version="{0}.{1}.{2}".format(Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version()),
		stack_trace=''.join(traceback.format_exception(exc_type, exc_value, exc_traceback)),
		thread_info=thread_info,
		timezone=tzlocal.get_localzone().zone
	)
	details = details.strip() + '\n'
	return details
Beispiel #30
0
def main(argv=sys.argv[1:]):
    """ Entry point of pympress. Parse command line arguments, instantiate the UI, and start the main loop.
    """
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    # prefere X11 on posix systems because Wayland still has some shortcomings for us,
    # specifically libVLC and the ability to disable screensavers
    if util.IS_POSIX:
        Gdk.set_allowed_backends('x11,*')
    Gtk.init(argv)

    pympress_meta = util.get_pympress_meta()['version']
    logger.info(' '.join([
        'Pympress:', pympress_meta, '; Python:',
        platform.python_version(), '; OS:',
        platform.system(),
        platform.release(),
        platform.version(), '; Gtk {}.{}.{}'.format(Gtk.get_major_version(),
                                                    Gtk.get_minor_version(),
                                                    Gtk.get_micro_version()),
        '; GLib {}.{}.{}'.format(GLib.MAJOR_VERSION, GLib.MINOR_VERSION,
                                 GLib.MICRO_VERSION), '; Poppler',
        document.Poppler.get_version(),
        document.Poppler.get_backend().value_nick, '; Cairo',
        ui.cairo.cairo_version_string(), ', pycairo', ui.cairo.version,
        '; Media:',
        extras.Media.backend_version()
    ]))

    try:
        opts, args = getopt.getopt(argv, "hn:t:",
                                   ["help", "notes=", "talk-time=", "log="])
        opts = dict(opts)
    except getopt.GetoptError:
        usage()
        sys.exit(2)

    ett, log_level, notes_pos = parse_opts(opts)
    logger.setLevel(log_level)

    # Create windows
    gui = ui.UI()

    # Connect proper exit function to interrupt
    signal.signal(signal.SIGINT, gui.save_and_quit)

    # pass command line args
    if ett:
        gui.est_time.set_time(ett)

    gui.swap_document(os.path.abspath(args[0])) if args else gui.pick_file()

    if notes_pos is not None:
        gui.change_notes_pos(notes_pos, force_change=True)

    gui.run()
Beispiel #31
0
def main():
    """
    Main function that starts everything
    """

    # start DBus loop
    DBusGMainLoop(set_as_default=True)
    bus = dbus.SessionBus()
    instance = bus.request_name(DBUS_SERVICE)

    if instance != dbus.bus.REQUEST_NAME_REPLY_PRIMARY_OWNER:
        print(
            "DBus name already taken. Ulauncher is probably backgrounded. Did you mean `ulauncher-toggle`?",
            file=sys.stderr)
        toggle_window = dbus.SessionBus().get_object(
            DBUS_SERVICE, DBUS_PATH).get_dbus_method("toggle_window")
        toggle_window()
        return

    _create_dirs()

    options = get_options()
    setup_logging(options)
    logger = logging.getLogger('ulauncher')
    logger.info('Ulauncher version %s', get_version())
    logger.info('Extension API version %s', api_version)
    logger.info("GTK+ %s.%s.%s", Gtk.get_major_version(),
                Gtk.get_minor_version(), Gtk.get_micro_version())
    logger.info("Is Wayland: %s", is_wayland())
    logger.info("Wayland compatibility: %s",
                ('on' if is_wayland_compatibility_on() else 'off'))

    # log uncaught exceptions
    def except_hook(exctype, value, tb):
        logger.error("Uncaught exception", exc_info=(exctype, value, tb))

    sys.excepthook = except_hook

    window = UlauncherWindow.get_instance()
    UlauncherDbusService(window)
    if not options.hide_window:
        window.show()

    if Settings.get_instance().get_property('show-indicator-icon'):
        AppIndicator.get_instance().show()

    # workaround to make Ctrl+C quitting the app
    signal_handler = SignalHandler(window)
    gtk_thread = run_async(Gtk.main)()
    try:
        while gtk_thread.is_alive() and not signal_handler.killed():
            time.sleep(0.5)
    except KeyboardInterrupt:
        logger.warning('On KeyboardInterrupt')
    finally:
        Gtk.main_quit()
Beispiel #32
0
def backend_gtk3agg_internal_check(x):
    try:
        from gi.repository import Gtk, Gdk, GObject
    except ImportError:
        return (False, "Requires pygobject to be installed.")

    if sys.version_info[0] >= 3:
        return (False, "gtk3agg does not work on Python 3")

    return (True, "version %s.%s.%s" % (Gtk.get_major_version(), Gtk.get_micro_version(), Gtk.get_minor_version()))
def main(root_path, filename):
    # This the main for launched process, this is reached via 'flowblademediaimport' laucher file
    gtk_version = "%s.%s.%s" % (Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version())
    print "GTK+ version:", gtk_version
    editorstate.gtk_version = gtk_version
    try:
        editorstate.mlt_version = mlt.LIBMLT_VERSION
    except:
        editorstate.mlt_version = "0.0.99" # magic string for "not found"

    # Read the XDG_* variables etc.
    userfolders.init()
    
    # Set paths.
    respaths.set_paths(root_path)

    # Load editor prefs and list of recent projects
    editorpersistance.load()
    
    # Init translations module with translations data
    translations.init_languages()
    translations.load_filters_translations()
    mlttransitions.init_module()

    # Init gtk threads
    Gdk.threads_init()
    Gdk.threads_enter()

    # Themes
    if editorpersistance.prefs.theme != appconsts.LIGHT_THEME:
        Gtk.Settings.get_default().set_property("gtk-application-prefer-dark-theme", True)
        if editorpersistance.prefs.theme == appconsts.FLOWBLADE_THEME:
            gui.apply_gtk_css()
            
    repo = mlt.Factory().init()
    processutils.prepare_mlt_repo(repo)
    
    # Set numeric locale to use "." as radix, MLT initilizes this to OS locale and this causes bugs 
    locale.setlocale(locale.LC_NUMERIC, 'C')

    # Check for codecs and formats on the system
    mltenv.check_available_features(repo)
    renderconsumer.load_render_profiles()

    # Load filter and compositor descriptions from xml files.
    mltfilters.load_filters_xml(mltenv.services)
    mlttransitions.load_compositors_xml(mltenv.transitions)

    # Create list of available mlt profiles
    mltprofiles.load_profile_list()

    GLib.idle_add(_do_assets_write, filename)
    
    Gtk.main()
    Gdk.threads_leave()
Beispiel #34
0
    def interact(self):
        exc_type, exc_value, exc_traceback = self.exc_info
        pversion = 'UNKNOWN'
        if its.on_linux:
            pversion = 'Linux: ' + ' '.join(platform.linux_distribution())
        elif its.on_windows:
            pversion = 'Windows: ' + ' '.join(platform.win32_ver())
            if its.frozen:
                pversion += ' (Frozen=True)'
            else:
                pversion += ' (Frozen=False)'
        exc_name = "{0}.{1}".format(exc_type.__module__, exc_type.__name__)
        rpc_error_details = 'N/A (Not a remote RPC error)'
        if isinstance(
                exc_value,
                advancedhttpserver.RPCError) and exc_value.is_remote_exception:
            rpc_error_details = "Name: {0}".format(
                exc_value.remote_exception['name'])
            if exc_value.remote_exception.get('message'):
                rpc_error_details += " Message: '{0}'".format(
                    exc_value.remote_exception['message'])
        current_tid = threading.current_thread().ident
        thread_info = ("{0: >4}{1} (alive={2} daemon={3})".format(
            ('=> ' if thread.ident == current_tid else ''), thread.name,
            thread.is_alive(), thread.daemon)
                       for thread in threading.enumerate())
        thread_info = '\n'.join(thread_info)
        details = EXCEPTION_DETAILS_TEMPLATE.format(
            error_details=repr(exc_value),
            error_type=exc_name,
            error_uid=(self.error_uid or 'N/A'),
            rpc_error_details=rpc_error_details,
            king_phisher_version=version.version,
            platform_version=pversion,
            python_version="{0}.{1}.{2}".format(*sys.version_info),
            gtk_version="{0}.{1}.{2}".format(Gtk.get_major_version(),
                                             Gtk.get_minor_version(),
                                             Gtk.get_micro_version()),
            stack_trace=''.join(
                traceback.format_exception(exc_type, exc_value,
                                           exc_traceback)),
            thread_info=thread_info,
            timezone=tzlocal.get_localzone().zone)
        details = details.strip() + '\n'

        if exc_name.startswith('king_phisher.third_party.'):
            exc_name = exc_name[25:]
        self.error_description.set_text("Error type: {0}".format(exc_name))
        self.error_details.get_buffer().set_text(details)

        self.dialog.show_all()
        self.dialog.run()
        self.dialog.destroy()
        return
    def _check_gui(self):
        if int(self.config.get("gui", "", "gtk_major", "0")) == int(Gtk.get_major_version()) \
                and int(self.config.get("gui", "", "gtk_minor", "0")) == int(Gtk.get_minor_version()) \
                and int(self.config.get("gui", "", "gtk_micro", "0")) == int(Gtk.get_micro_version()):
            log.debug("Рабочая версия GTK.")

            IGUI.ResourceChecker(self)

            return

        log.critical("Warning: GTK version mistmatch!")
        log.critical("Current GTK version is: {0}.{1}.{2}".format(
            Gtk.get_major_version(), Gtk.get_minor_version(),
            Gtk.get_micro_version()))
        log.critical("Need GTK version is: {0}.{1}.{2}".format(
            self.config.get("gui", "", "gtk_major", "0"),
            self.config.get("gui", "", "gtk_minor", "0"),
            self.config.get("gui", "", "gtk_micro", "0")))

        self.quit()
Beispiel #36
0
 def run(self, etype, evalue, etraceback):
     text = "".join(traceback.format_exception(etype, evalue, etraceback))
     gtk_version = "%s.%s.%s" % (Gtk.get_major_version(),
                                 Gtk.get_minor_version(),
                                 Gtk.get_micro_version())
     info = "\n\nPlatform: %s\nPython: %s\nGTK+:%s\n\n" % (
         platform.platform(), platform.python_version(), gtk_version)
     self._textview.get_buffer().set_text(text)
     clipboard = Gtk.Clipboard.get_for_display(Gdk.Display.get_default(),
                                               Gdk.SELECTION_CLIPBOARD)
     clipboard.set_text(text + info, -1)
     Gtk.MessageDialog.run(self)
Beispiel #37
0
def backend_gtk3cairo_internal_check(x):
    try:
        import cairo
    except ImportError:
        return (False, "Requires cairo to be installed.")

    try:
        from gi.repository import Gtk, Gdk, GObject
    except ImportError:
        return (False, "Requires pygobject to be installed.")

    return (True, "version %s.%s.%s" % (Gtk.get_major_version(), Gtk.get_micro_version(), Gtk.get_minor_version()))
Beispiel #38
0
def about(self2):

    dialog = Gtk.AboutDialog()
    dialog.set_name(pedconfig.conf.progname + " - Python Editor ")

    dialog.set_version(str(pedconfig.conf.version))
    gver = (Gtk.get_major_version(), \
                        Gtk.get_minor_version(), \
                            Gtk.get_micro_version())

    dialog.set_position(Gtk.WindowPosition.CENTER)
    dialog.set_transient_for(pedconfig.conf.pedwin.mywin)

    #"\nRunning PyGObject %d.%d.%d" % GObject.pygobject_version +\

    ddd = os.path.join(os.path.dirname(__file__), "../", "../")

    # GLib.pyglib_version
    vvv = gi.version_info
    comm = "Python based easily configurable editor\n"\
        "with time accounting module, spell "\
        "check \n and macro recording.\n"\
        "\nRunning PyGtk %d.%d.%d" % vvv +\
        "\non GTK %d.%d.%d\n" % gver +\
        "\nRunning Python %s" % platform.python_version() +\
        "\non %s %s\n" % (platform.system(), platform.release()) +\
        "\nPyedPro Build Date: %s\n" % pedconfig.conf.build_date +\
        "Exe Path:\n%s\n" % os.path.realpath(ddd)

    dialog.set_comments(comm)
    dialog.set_copyright(pedconfig.conf.progname + " Created by Peter Glen.\n"
                         "Project is in the Public Domain.")
    dialog.set_program_name(pedconfig.conf.progname)
    img_dir = os.path.join(os.path.dirname(__file__), 'images')
    #img_path = os.path.join(img_dir, 'gtk-logo-rgb.gif')
    img_path = os.path.join(img_dir, 'pyedpro.png')

    try:
        pixbuf = GdkPixbuf.Pixbuf.new_from_file(img_path)
        #print "loaded pixbuf"
        dialog.set_logo(pixbuf)

    except:
        print("Cannot load logo for about dialog", img_path)
        print(sys.exc_info())

    #dialog.set_website("")

    ## Close dialog on user response
    dialog.connect("response", lambda d, r: d.destroy())
    dialog.connect("key-press-event", about_key)

    dialog.show()
Beispiel #39
0
def single_render_main(root_path):
    # called from .../launch/flowbladesinglerender script
    gtk_version = "%s.%s.%s" % (Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version())
    editorstate.gtk_version = gtk_version
    try:
        editorstate.mlt_version = mlt.LIBMLT_VERSION
    except:
        editorstate.mlt_version = "0.0.99" # magic string for "not found"
        
    # Set paths.
    respaths.set_paths(root_path)

    # Load editor prefs and list of recent projects
    editorpersistance.load()
    
    # Init translations module with translations data
    translations.init_languages()
    translations.load_filters_translations()
    mlttransitions.init_module()

    # Init gtk threads
    Gdk.threads_init()
    Gdk.threads_enter()

    # Request dark them if so desired
    if editorpersistance.prefs.dark_theme == True:
        Gtk.Settings.get_default().set_property("gtk-application-prefer-dark-theme", True)

    repo = mlt.Factory().init()

    # Set numeric locale to use "." as radix, MLT initilizes this to OS locale and this causes bugs 
    locale.setlocale(locale.LC_NUMERIC, 'C')

    # Check for codecs and formats on the system
    mltenv.check_available_features(repo)
    renderconsumer.load_render_profiles()

    # Load filter and compositor descriptions from xml files.
    mltfilters.load_filters_xml(mltenv.services)
    mlttransitions.load_compositors_xml(mltenv.transitions)

    # Create list of available mlt profiles
    mltprofiles.load_profile_list()

    global single_render_window
    single_render_window = SingleRenderWindow()

    global single_render_thread
    single_render_thread = SingleRenderThread()
    single_render_thread.start()

    Gtk.main()
    Gdk.threads_leave()
Beispiel #40
0
    def get_issue_text(traceback_text):
        gtk_ver = '%i.%i.%i' % (Gtk.get_major_version(),
                                Gtk.get_minor_version(),
                                Gtk.get_micro_version())
        gobject_ver = '.'.join(map(str, GObject.pygobject_version))
        glib_ver = '.'.join(
            map(str,
                [GLib.MAJOR_VERSION, GLib.MINOR_VERSION, GLib.MICRO_VERSION]))

        return ISSUE_TEXT.format(get_os_info(), gtk_ver, gobject_ver, glib_ver,
                                 nbxmpp.__version__, gajim.__version__,
                                 traceback_text)
Beispiel #41
0
    def __init__(self):
        Gtk.Window.__init__(self, title='Hello, world!')

        self.set_default_size(250, 100)

        text = 'Gtk v' + str(Gtk.get_major_version()) + '.' \
        + str(Gtk.get_minor_version()) + '.' + str(Gtk.get_micro_version()) \
        + ' is installed and\nworking correctly' \
        + '\n\nClick here to close the window'

        self.button = Gtk.Button(label=text)
        self.button.connect('clicked', self.on_button_clicked)
        self.add(self.button)
 def run(self, etype, evalue, etraceback):
     text = "".join(traceback.format_exception(etype, evalue, etraceback))
     gtk_version = "%s.%s.%s" % (Gtk.get_major_version(),
                                 Gtk.get_minor_version(),
                                 Gtk.get_micro_version())
     info = "\n\nPlatform: %s\nPython: %s\nGTK+:%s\n\n" % (platform.platform(),
                                                           platform.python_version(),
                                                           gtk_version)
     self._textview.get_buffer().set_text(text)
     clipboard = Gtk.Clipboard.get_for_display(Gdk.Display.get_default(), 
                                               Gdk.SELECTION_CLIPBOARD)
     clipboard.set_text(text+info, -1)
     Gtk.MessageDialog.run(self)
Beispiel #43
0
def main():
    """
    Main function that starts everything
    """

    # start DBus loop
    DBusGMainLoop(set_as_default=True)
    bus = dbus.SessionBus()
    instance = bus.request_name(DBUS_SERVICE)

    if instance != dbus.bus.REQUEST_NAME_REPLY_PRIMARY_OWNER:
        print("Ulauncher is already running")
        show_window = dbus.SessionBus().get_object(
            DBUS_SERVICE, DBUS_PATH).get_dbus_method("show_window")
        show_window()
        return

    _create_dirs()

    options = get_options()
    setup_logging(options)
    logger = logging.getLogger('ulauncher')
    logger.info('Ulauncher version %s' % get_version())
    logger.info("GTK+ %s.%s.%s" %
                (Gtk.get_major_version(), Gtk.get_minor_version(),
                 Gtk.get_micro_version()))

    # log uncaught exceptions
    def except_hook(exctype, value, tb):
        logger.error("Uncaught exception", exc_info=(exctype, value, tb))

    sys.excepthook = except_hook

    window = UlauncherWindow.get_instance()
    UlauncherDbusService(window)
    if not options.hide_window:
        window.show()

    if Settings.get_instance().get_property('show-indicator-icon'):
        AppIndicator.get_instance().show()

    # workaround to make Ctrl+C quiting the app
    app_killer = GracefulAppKiller()
    gtk_thread = run_async(Gtk.main)()
    try:
        while gtk_thread.is_alive() and not app_killer.killed():
            time.sleep(0.5)
    except KeyboardInterrupt:
        logger.warn('On KeyboardInterrupt')
    finally:
        Gtk.main_quit()
Beispiel #44
0
def main(strarr):

    if(pyedlib.pedconfig.conf.verbose):
        print("pydepro running on", "'" + os.name + "'", \
            "GTK", Gtk._version, "PyGtk", \
               "%d.%d.%d" % (Gtk.get_major_version(), \
                    Gtk.get_minor_version(), \
                        Gtk.get_micro_version()))

    signal.signal(signal.SIGTERM, terminate)
    mainwin = pyedlib.pedwin.EdMainWindow(None, None, strarr)
    pyedlib.pedconfig.conf.pedwin = mainwin

    Gtk.main()
Beispiel #45
0
def apply_gtk_css():
    gtk_version = "%s.%s.%s" % (Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version())
    if Gtk.get_major_version() == 3 and Gtk.get_minor_version() == 22:
        print "Gtk version is " + gtk_version + ", Flowblade theme is available."
    else:
        print "Gtk version is " + gtk_version + ", Flowblade theme only available for Gtk 3.22"
        return
        
    provider = Gtk.CssProvider.new()
    display = Gdk.Display.get_default()
    screen = display.get_default_screen()
    Gtk.StyleContext.add_provider_for_screen (screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
    
    provider.load_from_path(respaths.ROOT_PATH + "/res/css/gtk-dark-fix.css")
Beispiel #46
0
    def _insert_library_versions(self):
        """Insert version numbers of libraries."""
        dotjoin = lambda seq: ".".join(map(str, seq))
        python_version = dotjoin(sys.version_info[:3])
        gtk_version = dotjoin((Gtk.get_major_version(),
                               Gtk.get_minor_version(),
                               Gtk.get_micro_version()))

        pygobject_version = dotjoin(GObject.pygobject_version)
        gst_version = gaupol.util.get_gst_version()
        self._insert_text("Python: {}\n".format(python_version))
        self._insert_text("GTK+: {}\n".format(gtk_version))
        self._insert_text("PyGObject: {}\n".format(pygobject_version))
        self._insert_text("GStreamer: {}\n\n".format(gst_version))
Beispiel #47
0
    def __init_dialogs(self):
        dialog = self.get_object("aboutdialog")
        try:
            with open('doc/LICENSE') as lfile:
                dialog.set_license(lfile.read().replace('\x0c', ''))
        except IOError:
            dialog.set_license("License file is missing")        

        dialog = self.get_object("infodialog")
        python = '.'.join(map(str, sys.version_info[:3]))
        gtk = '{}.{}.{}'.format(Gtk.get_major_version(),
                                Gtk.get_minor_version(),
                                Gtk.get_micro_version())
        
        text = "You are using <b>Python v{}</b> and <b>GTK v{}</b>".format(python, gtk)
        dialog.set_markup(text)
Beispiel #48
0
def main(root_path, force_launch=False):
    gtk_version = "%s.%s.%s" % (Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version())
    print "GTK+ version:", gtk_version
    editorstate.gtk_version = gtk_version
    try:
        editorstate.mlt_version = mlt.LIBMLT_VERSION
    except:
        editorstate.mlt_version = "0.0.99" # magic string for "not found"

    # Set paths.
    respaths.set_paths(root_path)

    # Load editor prefs and list of recent projects
    editorpersistance.load()
    
    # Init translations module with translations data
    translations.init_languages()
    translations.load_filters_translations()
    mlttransitions.init_module()

    # Init gtk threads
    Gdk.threads_init()
    Gdk.threads_enter()

    repo = mlt.Factory().init()

    # Set numeric locale to use "." as radix, MLT initilizes this to OS locale and this causes bugs 
    locale.setlocale(locale.LC_NUMERIC, 'C')

    # Check for codecs and formats on the system
    mltenv.check_available_features(repo)
    renderconsumer.load_render_profiles()

    # Load filter and compositor descriptions from xml files.
    mltfilters.load_filters_xml(mltenv.services)
    mlttransitions.load_compositors_xml(mltenv.transitions)

    # Create list of available mlt profiles
    mltprofiles.load_profile_list()

    appconsts.SAVEFILE_VERSION = projectdata.SAVEFILE_VERSION

    global linker_window
    linker_window = MediaLinkerWindow()

    Gtk.main()
    Gdk.threads_leave()
Beispiel #49
0
def apply_gtk_css():
    gtk_version = "%s.%s.%s" % (Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version())
    if Gtk.get_major_version() == 3 and Gtk.get_minor_version() >= 22:
        print "Gtk version is " + gtk_version + ", Flowblade theme is available."
    else:
        print "Gtk version is " + gtk_version + ", Flowblade theme only available for Gtk >= 3.22"
        editorpersistance.prefs.theme = appconsts.LIGHT_THEME
        editorpersistance.save()
        return False
        
    provider = Gtk.CssProvider.new()
    display = Gdk.Display.get_default()
    screen = display.get_default_screen()
    Gtk.StyleContext.add_provider_for_screen (screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
    provider.load_from_path(respaths.ROOT_PATH + "/res/css/gtk-flowblade-dark.css")

    return True
Beispiel #50
0
def get_platform_info():
    from gi.repository import GObject
    from gi.repository import Gtk
    import yaml

    functions = [
        platform.machine, platform.platform, platform.processor,
        platform.python_version, platform.release, platform.system
    ]
    names_values = [(func.__name__, func()) for func in functions]

    names_values.extend([
        ('GTK', (Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version())),
        ('Glib', GObject.glib_version),
        ('PyGObject', GObject.pygobject_version),
        ('YAML', yaml.__version__),
        ])

    vals = ['%s: %s' % (name, val) for name, val in names_values]
    return 'System info: ' + ', '.join(vals)
Beispiel #51
0
 def _insert_dependencies(self):
     """Insert version numbers of selected dependencies."""
     dotjoin = lambda x: ".".join(map(str, x))
     chardet_version = aeidon.util.get_chardet_version()
     enchant_version = aeidon.util.get_enchant_version()
     gst_version = gaupol.util.get_gst_version()
     gtk_version = dotjoin((
         Gtk.get_major_version(),
         Gtk.get_minor_version(),
         Gtk.get_micro_version(),
     ))
     pygobject_version = dotjoin(GObject.pygobject_version)
     python_version = dotjoin(sys.version_info[:3])
     self._insert_text("aeidon: {}\n".format(aeidon.__version__))
     self._insert_text("chardet: {}\n".format(chardet_version))
     self._insert_text("enchant: {}\n".format(enchant_version))
     self._insert_text("gaupol: {}\n".format(gaupol.__version__))
     self._insert_text("gstreamer: {}\n".format(gst_version))
     self._insert_text("gtk+: {}\n".format(gtk_version))
     self._insert_text("pygobject: {}\n".format(pygobject_version))
     self._insert_text("python: {}\n".format(python_version))
Beispiel #52
0
def install_compat():
    from gi.repository import Gtk
    from gi.repository import Gdk
    from gi.repository import GdkPixbuf
    sys.modules['gtk'] = Gtk
    sys.modules['gtk.gdk'] = Gdk
    Gtk.gdk = Gdk
    Gtk.keysyms = Gdk
    Gdk.Pixbuf = GdkPixbuf.Pixbuf

    def pixbuf_new_from_file(filename):
        return GdkPixbuf.Pixbuf()
    Gdk.pixbuf_new_from_file = pixbuf_new_from_file

    Gtk.gtk_version = (Gtk.get_major_version(),
                       Gtk.get_minor_version(),
                       Gtk.get_micro_version())

    Gtk.widget_get_default_direction = Gtk.Widget.get_default_direction

    class GenericCellRenderer(Gtk.CellRenderer):
        pass
    Gtk.GenericCellRenderer = GenericCellRenderer

    # Enums
    Gtk.ICON_SIZE_MENU = Gtk.IconSize.MENU
    Gtk.JUSTIFY_LEFT = Gtk.Justification.LEFT
    Gtk.JUSTIFY_RIGHT = Gtk.Justification.RIGHT
    Gtk.POS_RIGHT = Gtk.PositionType.RIGHT
    Gtk.POLICY_AUTOMATIC = Gtk.PolicyType.AUTOMATIC
    Gtk.POLICY_ALWAYS = Gtk.PolicyType.ALWAYS
    Gtk.SELECTION_BROWSE = Gtk.SelectionMode.BROWSE
    Gtk.SELECTION_NONE = Gtk.SelectionMode.NONE
    Gtk.SORT_ASCENDING = Gtk.SortType.ASCENDING
    Gtk.SHADOW_ETCHED_IN = Gtk.ShadowType.ETCHED_IN
    Gtk.STATE_NORMAL = Gtk.StateType.NORMAL
    Gdk.BUTTON_PRESS = Gdk.EventType.BUTTON_PRESS
    Gtk.TEXT_DIR_RTL = Gtk.TextDirection.RTL
Beispiel #53
0
def check_gtk_version():
    """ Check GTK version """
    # Check desired GTK Version
    major_needed = int(_gtk_version_needed.split(".")[0])
    minor_needed = int(_gtk_version_needed.split(".")[1])
    micro_needed = int(_gtk_version_needed.split(".")[2])

    # Check system GTK Version
    major = Gtk.get_major_version()
    minor = Gtk.get_minor_version()
    micro = Gtk.get_micro_version()

    # Thus will be called from our liveCD that already has the latest GTK version
    # This is here just to help testing Thus in our environment.
    if major_needed > major or (major_needed == major and minor_needed > minor) or \
      (major_needed == major and minor_needed == minor and micro_needed > micro):
        print("Detected GTK %d.%d.%d but %s is needed. Can't run this installer." %
              (major, minor, micro, _gtk_version_needed))
        return False
    else:
        print("Using GTK v%d.%d.%d" % (major, minor, micro))

    return True
Beispiel #54
0
def init(core):
  "Do init specific for this widget toolkit"
  # mapping between the real widget and the wal widget
  core['avccd'].widget_map = { \
  Gtk.Button:			core['Button'], \
  Gtk.Calendar:	    		core['Calendar'], \
  Gtk.CheckButton:		core['ToggleButton'], \
  Gtk.ComboBoxText:		core['ComboBox'],\
  Gtk.ColorChooserWidget:	core['ColorChooser'],\
  Gtk.Entry:    		core['Entry'], \
  Gtk.Label:	    		core['Label'], \
  Gtk.ProgressBar:		core['ProgressBar'], \
  Gtk.RadioButton:  		core['RadioButton'], \
  Gtk.HScale:			core['Slider'], \
  Gtk.SpinButton:		core['SpinButton'], \
  Gtk.Statusbar:    		core['StatusBar'], \
  Gtk.TextView:			core['TextView'], \
  Gtk.ToggleButton:		core['ToggleButton'], \
  Gtk.TreeView:			core['listtreeview'], \
  Gtk.VScale:			core['Slider']}
  # get toolkit version
  core['avccd'].toolkit_version = str(Gtk.get_major_version()) + '.' + \
    str(Gtk.get_minor_version()) + '.' + str(Gtk.get_micro_version())
Beispiel #55
0
def threads_init():
    """
    For applications that wish to use Python threads to interact with the GNOME platform,
    GObject.threads_init() must be called prior to running or creating threads and starting
    main loops (see notes below for PyGObject 3.10 and greater). Generally, this should be done
    in the first stages of an applications main entry point or right after importing GObject.
    For multi-threaded GUI applications Gdk.threads_init() must also be called prior to running
    Gtk.main() or Gio/Gtk.Application.run().
    """
    minor = Gtk.get_minor_version()
    micro = Gtk.get_micro_version()

    if minor == 10 and micro < 2:
        # Unfortunately these versions of PyGObject suffer a bug
        # which require a workaround to get threading working properly.
        # Workaround: Force GIL creation
        import threading
        threading.Thread(target=lambda: None).start()

    # Since version 3.10.2, calling threads_init is no longer needed.
    # See: https://wiki.gnome.org/PyGObject/Threading
    if minor < 10 or (minor == 10 and micro < 2):
        GObject.threads_init()
Beispiel #56
0
try:
    # :raises ValueError: If module/version is already loaded, already
    # required, or unavailable.
    gi.require_version("Gtk", "3.0")
except ValueError as e:
    # in this case we want to re-raise as ImportError so the
    # auto-backend selection logic correctly skips.
    raise ImportError from e

from gi.repository import GLib, GObject, Gtk, Gdk


_log = logging.getLogger(__name__)

backend_version = "%s.%s.%s" % (
    Gtk.get_major_version(), Gtk.get_micro_version(), Gtk.get_minor_version())

# the true dots per inch on the screen; should be display dependent
# see http://groups.google.com/groups?q=screen+dpi+x11&hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&selm=7077.26e81ad5%40swift.cs.tcd.ie&rnum=5 for some info about screen dpi
PIXELS_PER_INCH = 96

try:
    cursord = {
        cursors.MOVE          : Gdk.Cursor.new(Gdk.CursorType.FLEUR),
        cursors.HAND          : Gdk.Cursor.new(Gdk.CursorType.HAND2),
        cursors.POINTER       : Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR),
        cursors.SELECT_REGION : Gdk.Cursor.new(Gdk.CursorType.TCROSS),
        cursors.WAIT          : Gdk.Cursor.new(Gdk.CursorType.WATCH),
    }
except TypeError as exc:
    # Happens when running headless.  Convert to ImportError to cooperate with
Beispiel #57
0
def show_settings():
    """
    Shows settings of all of the major components.
    """
    py_str = '%d.%d.%d' % sys.version_info[:3]
    try:
        from gi.repository import Gtk
        try:
            gtkver_str = '%d.%d.%d' % (Gtk.get_major_version(), 
                        Gtk.get_minor_version(), Gtk.get_micro_version())
        except : # any failure to 'get' the version
            gtkver_str = 'unknown version'
    except ImportError:
        gtkver_str = 'not found'
    # no DISPLAY is a RuntimeError in an older pygtk (e.g. 2.17 in Fedora 14)
    except RuntimeError:
        gtkver_str = 'DISPLAY not set'
    #exept TypeError: To handle back formatting on version split

    try:
        from gi.repository import GObject
        try:
            pygobjectver_str = '%d.%d.%d' % GObject.pygobject_version
        except :# any failure to 'get' the version
            pygobjectver_str = 'unknown version'

    except ImportError:
        pygobjectver_str = 'not found'

    try:
        from gi.repository import Pango
        try:
            pangover_str = Pango.version_string()
        except :# any failure to 'get' the version
            pangover_str = 'unknown version'

    except ImportError:
        pangover_str = 'not found'

    try:
        import cairo
        try:
            pycairover_str = '%d.%d.%d' % cairo.version_info 
            cairover_str = cairo.cairo_version_string()
        except :# any failure to 'get' the version
            pycairover_str = 'unknown version'
            cairover_str = 'unknown version'

    except ImportError:
        pycairover_str = 'not found'
        cairover_str = 'not found'

    try:
        from gi import Repository
        repository = Repository.get_default()
        if repository.enumerate_versions("OsmGpsMap"):
            from gi.repository import OsmGpsMap as osmgpsmap
            try:
                osmgpsmap_str = osmgpsmap._version
            except :# any failure to 'get' the version
                osmgpsmap_str = 'unknown version'
        else:
            osmgpsmap_str = 'not found'

    except ImportError:
        osmgpsmap_str = 'not found'

    try:
        from gi import Repository
        repository = Repository.get_default()
        if repository.enumerate_versions("GExiv2"):
            from gi.repository import GExiv2
            try:
                gexiv2_str = GExiv2._version
            except: # any failure to 'get' the version
                gexiv2_str = 'unknown version'
        else:
            gexiv2_str = 'not found'

    except ImportError:
        gexiv2_str = 'not found'

    try:
        import PyICU
        try:
            pyicu_str = PyICU.VERSION
            icu_str = PyICU.ICU_VERSION
        except: # any failure to 'get' the version
            pyicu_str = 'unknown version'
            icu_str = 'unknown version'

    except ImportError:
        pyicu_str = 'not found'
        icu_str = 'not found'

    try:
        import bsddb3 as bsddb
        bsddb_str = bsddb.__version__
        bsddb_db_str = str(bsddb.db.version()).replace(', ', '.')\
                                        .replace('(', '').replace(')', '')
    except:
        bsddb_str = 'not found'
        bsddb_db_str = 'not found'

    try: 
        from .gen.const import VERSION
        gramps_str = VERSION
    except:
        gramps_str = 'not found'

    if hasattr(os, "uname"):
        kernel = os.uname()[2]
    else:
        kernel = None

    lang_str = get_env_var('LANG','not set')
    language_str = get_env_var('LANGUAGE','not set')
    grampsi18n_str = get_env_var('GRAMPSI18N','not set')
    grampshome_str = get_env_var('GRAMPSHOME','not set')
    grampsdir_str = get_env_var('GRAMPSDIR','not set')

    try:
        dotversion_str = Popen(['dot', '-V'], stderr=PIPE).communicate(input=None)[1]
        if isinstance(dotversion_str, bytes) and sys.stdin.encoding:
            dotversion_str = dotversion_str.decode(sys.stdin.encoding)
        if dotversion_str:
            dotversion_str = dotversion_str.replace('\n','')[23:27]
    except:
        dotversion_str = 'Graphviz not in system PATH'

    try:
        if win():
            gsversion_str = Popen(['gswin32c', '--version'], stdout=PIPE).communicate(input=None)[0]
        else:
            gsversion_str = Popen(['gs', '--version'], stdout=PIPE).communicate(input=None)[0]
        if isinstance(gsversion_str, bytes) and sys.stdin.encoding:
            gsversion_str = gsversion_str.decode(sys.stdin.encoding)
        if gsversion_str:
            gsversion_str = gsversion_str.replace('\n', '')
    except:
        gsversion_str = 'Ghostscript not in system PATH'

    os_path = get_env_var('PATH','not set')
    os_path = os_path.split(os.pathsep)
    
    print ("Gramps Settings:")
    print ("----------------")
    print (' python    : %s' % py_str)
    print (' gramps    : %s' % gramps_str)
    print (' gtk++     : %s' % gtkver_str)
    print (' pygobject : %s' % pygobjectver_str)
    print (' pango     : %s' % pangover_str)
    print (' bsddb     : %s' % bsddb_str)
    print (' bsddb.db  : %s' % bsddb_db_str)
    print (' cairo     : %s' % cairover_str)
    print (' pycairo   : %s' % pycairover_str)
    print (' osmgpsmap : %s' % osmgpsmap_str)
    print (' GExiv2    : %s' % gexiv2_str)
    print (' ICU       : %s' % icu_str)
    print (' PyICU     : %s' % pyicu_str)
    print (' o.s.      : %s' % sys.platform)
    if kernel:
        print (' kernel    : %s' % kernel)
    print ('')
    print ("Environment settings:")
    print ("---------------------")
    print (' LANG      : %s' % lang_str)
    print (' LANGUAGE  : %s' % language_str)
    print (' GRAMPSI18N: %s' % grampsi18n_str)
    print (' GRAMPSHOME: %s' % grampshome_str)
    print (' GRAMPSDIR : %s' % grampsdir_str)
    print (' PYTHONPATH:')
    for folder in sys.path:
        print ("   ", folder)
    print ('')
    print ("Non-python dependencies:")
    print ("------------------------")
    print (' Graphviz  : %s' % dotversion_str)
    print (' Ghostscr. : %s' % gsversion_str)
    print ('')
    print ("System PATH env variable:")
    print ("-------------------------")
    for folder in os_path:
        print ("    ", folder)
    print ('')
	def __init__(self, config_file=None, use_plugins=True, use_style=True):
		super(KingPhisherClientApplication, self).__init__()
		if use_style:
			self._theme_file = 'theme.css'
		else:
			self._theme_file = DISABLED
		self.logger = logging.getLogger('KingPhisher.Client.Application')
		# log version information for debugging purposes
		self.logger.debug("gi.repository GLib version: {0}".format('.'.join(map(str, GLib.glib_version))))
		self.logger.debug("gi.repository GObject version: {0}".format('.'.join(map(str, GObject.pygobject_version))))
		self.logger.debug("gi.repository Gtk version: {0}.{1}.{2}".format(Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version()))
		if rpc_terminal.has_vte:
			self.logger.debug("gi.repository VTE version: {0}".format(rpc_terminal.Vte._version))
		if graphs.has_matplotlib:
			self.logger.debug("matplotlib version: {0}".format(graphs.matplotlib.__version__))
		self.set_property('application-id', 'org.king-phisher.client')
		self.set_property('register-session', True)
		self.config_file = config_file or os.path.join(USER_DATA_PATH, 'config.json')
		"""The file containing the King Phisher client configuration."""
		if not os.path.isfile(self.config_file):
			self._create_config()
		self.config = None
		"""The primary King Phisher client configuration."""
		self.main_window = None
		"""The primary top-level :py:class:`~.MainAppWindow` instance."""
		self.rpc = None
		"""The :py:class:`~.KingPhisherRPCClient` instance for the application."""
		self._ssh_forwarder = None
		"""The SSH forwarder responsible for tunneling RPC communications."""
		self.style_provider = None
		try:
			self.emit('config-load', True)
		except IOError:
			self.logger.critical('failed to load the client configuration')
			raise

		self.connect('window-added', self.signal_window_added)
		self.actions = {}
		self._create_actions()

		if not use_plugins:
			self.logger.info('disabling all plugins')
			self.config['plugins.enabled'] = []
		self.plugin_manager = plugins.ClientPluginManager(
			[os.path.join(USER_DATA_PATH, 'plugins'), find.find_data_directory('plugins')],
			self
		)
		if use_plugins:
			self.plugin_manager.load_all()
Beispiel #59
0
from matplotlib._pylab_helpers import Gcf
from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \
     FigureManagerBase, FigureCanvasBase, NavigationToolbar2, cursors, TimerBase
from matplotlib.backend_bases import ShowBase

from matplotlib.cbook import is_string_like, is_writable_file_like
from matplotlib.colors import colorConverter
from matplotlib.figure import Figure
from matplotlib.widgets import SubplotTool

from matplotlib import lines
from matplotlib import cbook
from matplotlib import verbose
from matplotlib import rcParams

backend_version = "%s.%s.%s" % (Gtk.get_major_version(), Gtk.get_micro_version(), Gtk.get_minor_version())

_debug = False
#_debug = True

# the true dots per inch on the screen; should be display dependent
# see http://groups.google.com/groups?q=screen+dpi+x11&hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&selm=7077.26e81ad5%40swift.cs.tcd.ie&rnum=5 for some info about screen dpi
PIXELS_PER_INCH = 96

cursord = {
    cursors.MOVE          : Gdk.Cursor.new(Gdk.CursorType.FLEUR),
    cursors.HAND          : Gdk.Cursor.new(Gdk.CursorType.HAND2),
    cursors.POINTER       : Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR),
    cursors.SELECT_REGION : Gdk.Cursor.new(Gdk.CursorType.TCROSS),
    }