Beispiel #1
0
def install_locally_required_files():
    source_share_folder = resources.get_data_file_path()
    if not source_share_folder:
        logger.warning(
            "Cannot find repository required for installation of icons and gtksourceview styles"
        )

    for folder in ["gtksourceview-3.0", "icons"]:
        try:
            logger.info("Copying '{}' files...".format(folder))
            copy_tree(join(source_share_folder, folder),
                      join(resources.xdg_user_data_folder, folder),
                      update=1)
        except IOError as e:
            logger.error("Could not copy '{}' files: {}".format(
                folder, str(e)))

    if is_custom_design_enabled():
        try:
            logger.info(
                "Copying custom design files '{}' files...".format(folder))
            copy_tree(
                global_design_config.get_config_value("SOURCE_VIEW_FOLDER"),
                join(resources.xdg_user_data_folder, "gtksourceview-3.0"),
                update=1)
            copy_tree(global_design_config.get_config_value("ICONS_FOLDER"),
                      join(resources.xdg_user_data_folder, "icons"),
                      update=1)
        except IOError as e:
            logger.error("Could not copy '{}' files: {}".format(
                folder, str(e)))
Beispiel #2
0
def create_splash_screen():
    if is_custom_design_enabled:
        splash_screen_width = global_design_config.get_config_value("SPLASH_SCREEN_RESOLUTION_WIDTH")
        splash_screen_height = global_design_config.get_config_value("SPLASH_SCREEN_RESOLUTION_HEIGHT")
    else:
        splash_screen_width = 530
        splash_screen_height = 350
    splash_screen = SplashScreen(contains_image=True, width=splash_screen_width, height=splash_screen_height)
    splash_screen.rotate_image(random_=True)
    splash_screen.set_text(_("Starting RAFCON..."))
    return splash_screen
Beispiel #3
0
    def new_buffer(self):
        style_scheme_manager = GtkSource.StyleSchemeManager()
        b = GtkSource.Buffer()
        b.set_language(self.language_manager.get_language(self.language))
        b.set_highlight_syntax(True)

        user_editor_style = global_gui_config.get_config_value(
            self.editor_style, "classic")
        if user_editor_style.startswith("rafcon"):
            user_editor_style = "rafcon"
            dark_theme = global_gui_config.get_config_value(
                'THEME_DARK_VARIANT', True)
            if dark_theme:
                user_editor_style = "rafcon-dark"
        if is_custom_design_enabled():
            user_editor_style = global_design_config.get_config_value(
                "SOURCE_VIEW_THEME")
        scheme = style_scheme_manager.get_scheme(user_editor_style)
        if scheme:
            self.style_scheme = scheme
        else:
            logger.debug(
                "The editor style '{}' is not supported. Using the default 'classic'"
                .format(user_editor_style))
            self.style_scheme = style_scheme_manager.get_scheme('classic')
        b.set_style_scheme(self.style_scheme)
        return b
Beispiel #4
0
def setup_mvc_configuration(core_config_path, gui_config_path, runtime_config_path, design_config):
    """ Loads all configurations from disk

    :param core_config_path: the path to the core configuration file
    :param gui_config_path:  the path to the gui configuration file
    :param runtime_config_path:  the path to the runtime configuration file
    :param design_config:  the path to the design configuration file
    :return:
    """
    setup_configuration(core_config_path)
    # the design config has to be loaded before loading the gui config as it is used by the gui config
    if design_config:
        design_config_path, design_config_file = filesystem.separate_folder_path_and_file_name(design_config)
        global_design_config.load(design_config_file, design_config_path)
        # the constant has to be overwritten here,
        # as the singleton was already loaded that hus the wrong INTERFACE_FONT was chosen
        from rafcon.gui.utils import constants
        constants.INTERFACE_FONT = global_design_config.get_config_value("PRIMARY_FONT")
    else:
        # no design config file specified => check environment variable
        if os.environ.get('RAFCON_CUSTOM_DESIGN'):
            design_config = os.environ.get('RAFCON_CUSTOM_DESIGN')
            design_config_path, design_config_file = filesystem.separate_folder_path_and_file_name(design_config)
            global_design_config.load(design_config_file, design_config_path)
    gui_config_path, gui_config_file = filesystem.separate_folder_path_and_file_name(gui_config_path)
    global_gui_config.load(gui_config_file, gui_config_path)
    runtime_config_path, runtime_config_file = filesystem.separate_folder_path_and_file_name(runtime_config_path)
    global_runtime_config.load(runtime_config_file, runtime_config_path)
Beispiel #5
0
 def set_text(self, text):
     if is_custom_design_enabled() and not global_design_config.get_config_value("SPLASH_SCREEN_SHOW_TEXT", True):
         return
     logger.info(text)
     self.label.set_text(text)
     while Gtk.events_pending():
         Gtk.main_iteration_do(False)
     return
Beispiel #6
0
    def get_images(self):
        images = list()
        if is_custom_design_enabled():
            splash_screen_path = global_design_config.get_config_value("SPLASH_SCREEN_FOLDER")
            for image_filename in os.listdir(splash_screen_path):
                images.append(os.path.join(splash_screen_path, image_filename))
        else:
            for image_filename in resource_listdir(rafcon.gui.__name__, os.path.join("assets", "splashscreens")):
                images.append(resource_filename(rafcon.gui.__name__, os.path.join(
                    "assets", "splashscreens", image_filename)))

        return images
Beispiel #7
0
 def load_image(self, image_path):
     if image_path:
         horizontal_spacing = 50
         if is_custom_design_enabled():
             horizontal_spacing = global_design_config.get_config_value("SPLASH_SCREEN_HORIZONTAL_SPACING")
         pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(image_path, self.get_size()[0] - horizontal_spacing,
                                                         self.get_size()[1] - horizontal_spacing)
         self.image.set_from_pixbuf(pixbuf)
         while Gtk.events_pending():
             Gtk.main_iteration_do(False)
     else:
         logger.debug("Splash screen image path is None")
Beispiel #8
0
    def __init__(self, width=530, height=350, contains_image=False):
        # init Gtk.Window with type popup
        super(SplashScreen, self).__init__(type=Gtk.WindowType.POPUP)

        # index for the image rotator
        self.image_index = 0

        # Set the title to rafcon so it is detectable in taskbars
        # set width and height to parameter values and position the window in the center
        self.set_title('RAFCON')
        self.set_default_size(width, height)
        self.set_position(Gtk.WindowPosition.CENTER)

        main_vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
        self.add(main_vbox)
        self.image = Gtk.Image()
        # If an img path was defined, create a gtk img and fill it from a pixelbuffer which is created from the
        # set file path
        if contains_image:
            main_vbox.pack_start(self.image, True, True, 0)

        if is_custom_design_enabled() and not global_design_config.get_config_value("SPLASH_SCREEN_SHOW_TEXT", True):
            pass
        else:
            # add label to display text, the text can be changed by the text() method.
            # Align it in the middle of the gtk window
            self.label = Gtk.Label(label="")
            self.label.set_xalign(0.5)
            self.label.set_yalign(0.5)
            main_vbox.pack_start(self.label, False, True, 10)
            main_vbox.set_spacing(0)
            label_height = 40
            if is_custom_design_enabled():
                label_height = global_design_config.get_config_value("SPLASH_SCREEN_LABEL_HEIGHT")
            self.label.set_size_request(-1, label_height)

        if not os.getenv("RAFCON_START_MINIMIZED", False):
            self.show_all()
Beispiel #9
0
def install_fonts(restart=False):
    # do not import from rafcon.gui.constants, as this script can be used standalone
    font_names_to_be_installed = [
        "SourceSansPro", "FontAwesome5Free", "RAFCON"
    ]

    custom_fonts = list(
    )  # support a list in case we also support secondary or tertiary fonts
    if is_custom_design_enabled():
        custom_fonts.append(
            global_design_config.get_config_value("PRIMARY_FONT"))
    font_names_to_be_installed += custom_fonts

    user_otf_fonts_folder = join(resources.xdg_user_data_folder, "fonts")

    font_installed = False
    try:
        for font_name in font_names_to_be_installed:
            # A font is a folder one or more font faces
            rel_font_folder = join("type1", font_name)
            fonts_folder = resources.get_data_file_path(
                "fonts", rel_font_folder)
            if not os.path.exists(
                    fonts_folder):  # this is the case for a custom font
                fonts_folder = join(
                    global_design_config.get_config_value("FONTS_FOLDER"),
                    rel_font_folder)
                assert os.path.exists(
                    fonts_folder), "Custom font path does not exist"
            num_faces_to_be_installed = len([
                name for name in os.listdir(fonts_folder)
                if name.endswith(".otf")
            ])
            num_faces_installed = installed_font_faces_for_font(font_name)
            if num_faces_to_be_installed <= num_faces_installed:
                logger.debug("Font '{0}' already installed".format(font_name))
                continue
            specific_user_otf_fonts_folder = join(user_otf_fonts_folder,
                                                  rel_font_folder)
            logger.info("Installing font '{0}' to {1}".format(
                font_name, specific_user_otf_fonts_folder))
            copy_tree(fonts_folder, specific_user_otf_fonts_folder, update=1)
            font_installed = True
    except IOError as e:
        logger.error("Could not install fonts, IOError: {}".format(e))
        return

    if font_installed:
        logger.info("Running font detection ...")
        if not update_font_cache(user_otf_fonts_folder):
            logger.warning(
                "Could not run font detection using 'fc-cache'. RAFCON might not find the correct fonts."
            )
        if restart:
            python = sys.executable
            environ = dict(**os.environ)
            # Passing this to the new RAFCON environment will prevent further checks and thus restarts
            environ["RAFCON_CHECK_INSTALLATION"] = "False"
            args_and_env = list(sys.argv)
            args_and_env.append(environ)
            logger.info("Restarting RAFCON ...")
            os.execle(python, python, *args_and_env)
Beispiel #10
0
 def _get_custom_theme_path(self):
     return os.path.join(global_design_config.get_config_value("THEMES_FOLDER"),
                         global_design_config.get_config_value("THEME_NAME"))
Beispiel #11
0
from gi.repository import Gdk

from rafcon.utils.constants import RAFCON_TEMP_PATH_BASE
from rafcon.gui.design_config import global_design_config, is_custom_design_enabled


def get_glade_path(glade_file):
    from os import path
    mvc_dir = path.dirname(path.dirname(__file__))
    return path.join(mvc_dir, "glade", glade_file)


INTERFACE_FONT = "Source Sans Pro"
if is_custom_design_enabled():
    # this statement has no effect if the design_config is loaded after this module is imported the first time
    INTERFACE_FONT = global_design_config.get_config_value("PRIMARY_FONT")

ICON_FONT_FONTAWESOME = "FontAwesome5Free"
ICON_FONT_RAFCON = "RAFCON"
FONTS = [INTERFACE_FONT, ICON_FONT_FONTAWESOME, ICON_FONT_RAFCON]

FONT_SIZE_SMALL = "9"
FONT_SIZE_NORMAL = "10"
FONT_SIZE_BIG = "13"
FONT_SIZE_HUGE = "17"

LETTER_SPACING_NONE = "0"
LETTER_SPACING_05PT = "512"
LETTER_SPACING_075PT = "756"
LETTER_SPACING_1PT = "1024"
LETTER_SPACING_2PT = "2048"