Example #1
0
    def __init__(self):
        super(Window, self).__init__()
        self.set_size_request(350, -1)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_resizable(False)
        self.connect("focus-out-event", self.focus_out_event)
        self.connect("key-press-event", self.key_press_event)

        self.headerbar = Gtk.HeaderBar()
        self.headerbar.set_title(GLib.get_real_name())
        self.headerbar.set_show_close_button(True)
        self.headerbar.set_decoration_layout(":close")
        self.set_titlebar(self.headerbar)

        listbox = Gtk.ListBox()
        listbox.add(ListBoxRow("Hibernate", "systemctl hibernate"))
        listbox.add(ListBoxRow("Restart", "systemctl reboot"))
        listbox.add(ListBoxRow("Shutdown", "systemctl poweroff"))
        listbox.add(
            ListBoxRow("Preferences", "gnome-control-center --overview"))
        listbox.connect("row-activated", self.row_activated)

        self.add(listbox)
        self.show_all()
        self.present()
Example #2
0
 def get_glib_data(self):
     name = GLib.get_real_name()
     name = self.split_name(name)
     data = {'first_name': name['first'], 'last_name': name['last'],
             'home_phone': '', 'office_phone': '',
             'initials': name['initials'], 'email': '', 'fax': ''}
     return data
Example #3
0
    def __init__(self, iface, ips, port, auth_port):
        threading.Thread.__init__(self, name="server-thread")
        super(Server, self).__init__()
        GObject.Object.__init__(self)

        self.service_name = None
        self.service_ident = None

        self.ips = ips
        self.port = port
        self.auth_port = auth_port
        self.iface = iface

        self.untrusted_remote_machines = {}
        self.remote_machines = {}
        self.remote_registrar = None

        self.server_thread_keepalive = threading.Event()

        self.netmon = networkmonitor.get_network_monitor()

        self.server = None
        self.browser = None
        self.zeroconf = None
        self.info = None

        self.display_name = GLib.get_real_name()
        self.start()
Example #4
0
def get_local_name(hostname=get_hostname()):
    local_name = "%s@%s" % (GLib.get_user_name(), hostname)
    real_name = GLib.get_real_name()
    if real_name is not None and real_name != "" and real_name != "Unknown":
        # according to glib's doc, it can actually return "Unknown"
        local_name = "%s - %s" % (real_name, local_name)
    return local_name
Example #5
0
 def _check_game_over(self):
     """Add score if the game is over."""
     if game.is_game_over(self.game_grid) and not self.submitted_score:
         self.submitted_score = True
         self.score_dialog.show_and_add_score(
             GLib.get_real_name(), int(time.time()), self.clicks,
             int(time.time() - self.start_time))
Example #6
0
File: ffs.py Project: jku/ffs
 def reply_request(self, message, status, form_info):
     try:
         basename = GLib.path_get_basename(self.shared_file)
     except:
         basename = None
     form = get_form(self.allow_upload, form_info, self.archive_state, basename, GLib.get_real_name())
     message.set_response("text/html", Soup.MemoryUse.COPY, form)
     message.set_status(status)
Example #7
0
def get_user_display_name():
    name = GLib.get_real_name()

    if not name or name == "Unknown":
        name = get_user_name()

    utf8_name = None

    if name:
        utf8_name = nofail_locale_to_utf8(name)

    return utf8_name
Example #8
0
def get_user_display_name():
    name = GLib.get_real_name()

    if not name or name == "Unknown":
        name = get_user_name()

    utf8_name = None

    if name:
        utf8_name = nofail_locale_to_utf8(name)

    return utf8_name
Example #9
0
File: ffs.py Project: jku/ffs
    def __init__(self, port=0, allow_uploads=False, change_callback=None):

        # This should be a call to Soup.Server.__init__(), see note in __getattr__
        self._obj = GObject.new(Soup.Server, port=port, server_header="friendly-file-server")

        self.allow_upload = allow_uploads
        self.change_callback = change_callback
        self.shared_file = None
        self.archive_state = ArchiveState.NA
        self.igd = None
        try:
            self.zipper = FriendlyZipper()
        except:
            self.zipper = None

        self.upload_count = 0
        self.upload_bytes = 0
        self.upload_dir = None

        self.local_ip = find_ip()
        self.local_ip_state = IPState.UNKNOWN

        self.add_handler(None, self.on_soup_request, None)
        print ("Server starting, guessed uri http://%s:%d" % (self.local_ip, self.get_port()))
        self.run_async()

        # Is URI really available (at least from this machine)?
        self.confirm_uri(self.local_ip, self.get_port(), False)

        self.upnp_ip = None
        self.upnp_port = None
        self.upnp_ip_state = IPState.UNAVAILABLE
        try:
            self.igd = GUPnPIgd.SimpleIgd()
            self.igd.connect("mapped-external-port", self.on_igd_mapped_port)
            # FAILED: python/GI can't cope with signals with GError
            # self.igd.connect ("error-mapping-port", self.on_igd_error)
            self.igd.add_port(
                "TCP", self.get_port(), self.local_ip, self.get_port(), 0, FFS_APP_NAME  # remote port really
            )
        except:
            self.igd = None
            self.upnp_ip_state = IPState.UNKNOWN

        try:
            name = GLib.get_real_name() + "'s " + FFS_APP_NAME
            self.zeroconf = FriendlyZeroconfService(name, self.get_port())
        except:
            self.zeroconf = None
Example #10
0
File: ops.py Project: sahwar/warp
    def __init__(self, sender):
        super(ReceiveOp, self).__init__(TransferDirection.FROM_REMOTE_MACHINE,
                                        sender)
        self.sender_name = self.sender
        self.receiver_name = GLib.get_real_name()

        # If there's insufficient disk space, always ask for permission
        # If we're overwriting, there's a preference to check whether we need to ask or not.
        self.have_space = False
        self.existing = False

        # This is set when a transfer starts - it's a grpc.Future that we can cancel() if the user
        # wants the transfer to stop.
        self.file_iterator = None
        self.current_progress_report = None
        # These are the first-level base names (no path, just the filename) that we'll send to the server
        # to check for pre-existence.  We know that if these files/folders don't exist, none of their children
        # will.  This is a bit simple, but until we need more, it's fine.
        self.top_dir_basenames = []
Example #11
0
    def __init__(self):
        self.service_name = "warp.__%s__.__%s__._http._tcp.local." % (
            util.get_ip(), util.get_hostname())
        super(LocalMachine, self).__init__()
        GObject.Object.__init__(self)

        self.ip_address = util.get_ip()
        self.port = prefs.get_port()

        self.remote_machines = {}
        self.server_runlock = threading.Condition()

        self.browser = None
        self.zeroconf = None
        self.zeroconf = None
        self.info = None

        self.display_name = GLib.get_real_name()

        self.start_server()
Example #12
0
def add_simulated_widgets(app):
    local_machine = app.server

    for entry in TEST_REMOTES:
        display_name, name, user_name, hostname, ip, port, status, num_ops = entry
        machine = machines.RemoteMachine(name, hostname, ip, port, local_machine.service_name)

        local_machine.remote_machines[name] = machine
        machine.connect("ops-changed", local_machine.remote_ops_changed)
        app.window.add_remote_button(machine, simulated=True)

        if status == RemoteStatus.ONLINE:
            machine.display_name = display_name
            machine.user_name = user_name
            machine.emit("machine-info-changed")
            machine.set_remote_status(RemoteStatus.ONLINE)

            if name == "test2":
                add_ops(machine)

        elif status == RemoteStatus.OFFLINE:
            machine.display_name = display_name
            machine.user_name = user_name
            machine.emit("machine-info-changed")
            machine.set_remote_status(RemoteStatus.OFFLINE)
        elif status == RemoteStatus.UNREACHABLE:
            machine.display_name = display_name
            machine.user_name = user_name
            machine.emit("machine-info-changed")
            machine.set_remote_status(RemoteStatus.UNREACHABLE)
        elif status == RemoteStatus.INIT_CONNECTING:
            machine.set_remote_status(RemoteStatus.INIT_CONNECTING)
            machine.emit("machine-info-changed")
        elif status == "new_op":
            machine.display_name = display_name
            machine.user_name = user_name
            machine.set_remote_status(RemoteStatus.ONLINE)
            machine.emit("machine-info-changed")
            for i in range(num_ops):
                op = ops.ReceiveOp(name)
                op.receiver_name = GLib.get_real_name()
Example #13
0
    def __init__(self):
        super(Server, self).__init__()
        GObject.Object.__init__(self)

        self.service_name = None
        self.service_ident = None

        self.ip_address = util.get_ip()
        self.port = prefs.get_port()

        self.remote_machines = {}
        self.server_runlock = threading.Condition()

        self.server = None
        self.browser = None
        self.zeroconf = None
        self.zeroconf = None
        self.info = None

        self.display_name = GLib.get_real_name()

        self.start_server()
Example #14
0
File: ops.py Project: sahwar/warp
    def __init__(self,
                 sender=None,
                 receiver=None,
                 receiver_name=None,
                 uris=None):
        super(SendOp, self).__init__(TransferDirection.TO_REMOTE_MACHINE,
                                     sender, uris)
        self.receiver = receiver
        self.sender_name = GLib.get_real_name()
        self.receiver_name = receiver_name

        self.resolved_files = []
        self.first_missing_file = None

        self.file_send_cancellable = None

        self.current_progress_report = None

        # These are the first-level base names (no path, just the filename) that we'll send to the server
        # to check for pre-existence.  We know that if these files/folders don't exist, none of their children
        # will.  This is a bit simple, but until we need more, it's fine.
        self.top_dir_basenames = []
Example #15
0
    def __init__(self):
        threading.Thread.__init__(self, name="server-thread")
        super(Server, self).__init__()
        GObject.Object.__init__(self)

        self.service_name = None
        self.service_ident = None

        self.ip_address = util.get_ip()
        self.port = prefs.get_port()

        self.remote_machines = {}

        self.server_thread_keepalive = threading.Event()

        self.server = None
        self.browser = None
        self.zeroconf = None
        self.zeroconf = None
        self.info = None

        self.display_name = GLib.get_real_name()
        self.start()
Example #16
0
    def __init__(self):
        super(Window, self).__init__()
        self.set_size_request(350, -1)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_resizable(False)
        self.connect("focus-out-event", self.focus_out_event)
        self.connect("key-press-event", self.key_press_event)

        self.headerbar = Gtk.HeaderBar()
        self.headerbar.set_title(GLib.get_real_name())
        self.headerbar.set_show_close_button(True)
        self.headerbar.set_decoration_layout(":close")
        self.set_titlebar(self.headerbar)

        listbox = Gtk.ListBox()
        listbox.add(ListBoxRow("Hibernate"  , "systemctl hibernate"))
        listbox.add(ListBoxRow("Restart"    , "systemctl reboot"))
        listbox.add(ListBoxRow("Shutdown"   , "systemctl poweroff"))
        listbox.add(ListBoxRow("Preferences", "gnome-control-center --overview"))
        listbox.connect("row-activated", self.row_activated)

        self.add(listbox)
        self.show_all()
        self.present()
Example #17
0
    def do_expand_async(self, params, cancellable, callback, data):
        self.reset()

        task = Ide.Task.new(self, cancellable, callback)

        if 'language' in params:
            self.language = params['language'].get_string().lower()
        else:
            self.language = 'c'

        if self.language not in ('c', 'c♯', 'c++', 'javascript', 'python', 'vala', 'rust'):
            task.return_error(GLib.Error('Language %s not supported' % self.language))
            return

        if 'versioning' in params:
            self.versioning = params['versioning'].get_string()
        else:
            self.versioning = ''

        if 'author' in params:
            author_name = params['author'].get_string()
        else:
            author_name = GLib.get_real_name()

        scope = Template.Scope.new()
        scope.get('template').assign_string(self.id)

        name = params['name'].get_string().lower()
        name_ = ''.join([c if c.isalnum() else '_' for c in name])
        scope.get('name').assign_string(name)
        scope.get('name_').assign_string(name_)
        scope.get('NAME').assign_string(name_.upper())

        if 'app-id' in params:
            appid = params['app-id'].get_string()
        else:
            appid = 'org.example.App'
        appid_path = '/' + appid.replace('.', '/')
        scope.get('appid').assign_string(appid)
        scope.get('appid_path').assign_string(appid_path)

        prefix = name_ if not name_.endswith('_glib') else name_[:-5]
        PREFIX = prefix.upper()
        prefix_ = prefix.lower()
        PreFix = ''.join([word.capitalize() for word in prefix.lower().split('_')])

        scope.get('prefix').assign_string(prefix)
        scope.get('Prefix').assign_string(prefix.capitalize())
        scope.get('PreFix').assign_string(PreFix)
        scope.get('prefix_').assign_string(prefix_)
        scope.get('PREFIX').assign_string(PREFIX)


        enable_gnome = isinstance(self, GnomeProjectTemplate)
        scope.get('project_version').assign_string('0.1.0')
        scope.get('enable_i18n').assign_boolean(enable_gnome)
        scope.get('enable_gnome').assign_boolean(enable_gnome)
        scope.get('language').assign_string(self.language)
        scope.get('author').assign_string(author_name)

        # Just avoiding dealing with template bugs
        if self.language in ('c', 'c++'):
            ui_file = prefix + '-window.ui'
        elif self.language in ('c♯',):
            ui_file = ""
        else:
            ui_file = 'window.ui'
        scope.get('ui_file').assign_string(ui_file)

        exec_name = appid if self.language == 'javascript' else name
        scope.get('exec_name').assign_string(exec_name)

        modes = {
            'resources/src/hello.js.in': 0o750,
            'resources/src/hello.py.in': 0o750,
            'resources/src/application.in': 0o750,
            'resources/build-aux/meson/postinstall.py': 0o750,
        }

        expands = {
            'prefix': prefix,
            'appid': appid,
            'name_': name_,
            'name': name,
            'exec_name': exec_name,
        }

        files = {
            # Build files
            'resources/meson.build': 'meson.build',

        }
        self.prepare_files(files)

        # No explicit license == proprietary
        spdx_license = 'LicenseRef-proprietary'

        # https://spdx.org/licenses/
        LICENSE_TO_SPDX = {
            'agpl_3': 'AGPL-3.0-or-later',
            'gpl_3': 'GPL-3.0-or-later',
            'lgpl_2_1': 'LGPL-2.1-or-later',
            'lgpl_3': 'LGPL-3.0-or-later',
            'mit_x11': 'MIT',
        }

        if 'license_full' in params:
            license_full_path = params['license_full'].get_string()
            files[license_full_path] = 'COPYING'

        if 'license_short' in params:
            license_short_path = params['license_short'].get_string()
            license_base = Gio.resources_lookup_data(license_short_path[11:], 0).get_data().decode()
            self.locator.license = license_base
            license_name = license_short_path.rsplit('/', 1)[1]
            spdx_license = LICENSE_TO_SPDX.get(license_name, '')

        scope.get('project_license').assign_string(spdx_license)

        if 'path' in params:
            dir_path = params['path'].get_string()
        else:
            dir_path = name
        directory = Gio.File.new_for_path(dir_path)
        scope.get('project_path').assign_string(directory.get_path())

        for src, dst in files.items():
            destination = directory.get_child(dst % expands)
            if src.startswith('resource://'):
                self.add_resource(src[11:], destination, scope, modes.get(src, 0))
            else:
                path = os.path.join('/plugins/meson_templates', src)
                self.add_resource(path, destination, scope, modes.get(src, 0))

        self.expand_all_async(cancellable, self.expand_all_cb, task)
    def do_save_file(self, buffer, file):
        """
        If there is a copyright block within the file and we find the users
        name within it, we might want to update the year to include the
        current year.
        """
        # Stop if we aren't enabled
        if not self.settings.get_boolean('update-on-save'):
            return

        # Stop if we can't discover the user's real name
        name = GLib.get_real_name()
        if name == 'Unknown':
            return

        year = time.strftime('%Y')
        iter = buffer.get_start_iter()
        limit = buffer.get_iter_at_line(_MAX_LINE)

        while True:
            # Stop if we've past our limit
            if iter.compare(limit) >= 0:
                break

            # Stop If we don't find the user's full name
            ret = iter.forward_search(name, Gtk.TextSearchFlags.TEXT_ONLY,
                                      limit)
            if not ret:
                break

            # Get the whole line text
            match_begin, match_end = ret
            match_begin.set_line_offset(0)
            if not match_end.ends_line():
                match_end.forward_to_line_end()
            text = match_begin.get_slice(match_end)

            # Split based on 4-digit years
            parts = _YEAR_REGEX.split(text)

            # Ignore if this year is already represented
            if year in parts:
                break

            # If we have at least 2 years, we can update them
            if len(parts) >= 2:
                if '-' in parts:
                    parts[parts.index('-') + 1] = year
                else:
                    parts.insert(2, '-')
                    parts.insert(3, year)

                text = ''.join(parts)

                # Replace the line text in a single undo action
                buffer.begin_user_action()
                buffer.delete(match_begin, match_end)
                buffer.insert(match_begin, text)
                buffer.end_user_action()

                break

            # Move to the end of the line
            iter = match_end
Example #19
0
    def do_expand_async(self, params, cancellable, callback, data):
        self.reset()

        task = Gio.Task.new(self, cancellable, callback)

        if 'language' in params:
            self.language = params['language'].get_string().lower()
        else:
            self.language = 'c'

        if self.language not in ('c', 'c++'):
            task.return_error(
                GLib.Error('Language %s not supported' % self.language))
            return

        if 'versioning' in params:
            self.versioning = params['versioning'].get_string()
        else:
            self.versioning = ''

        if 'author' in params:
            author_name = params['author'].get_string()
        else:
            author_name = GLib.get_real_name()

        scope = Template.Scope.new()
        scope.get('template').assign_string(self.id)

        name = params['name'].get_string().lower()
        name_ = name.lower().replace('-', '_')
        scope.get('name').assign_string(name)
        scope.get('name_').assign_string(name_)

        scope.get('project_version').assign_string('0.1.0')
        scope.get('enable_i18n').assign_boolean(True)
        scope.get('language').assign_string(LANGUAGE_MAP[self.language])
        scope.get('author').assign_string(author_name)

        modes = {}

        expands = {}

        files = {
            'resources/meson.build': 'meson.build',
            'resources/src/meson.build': 'src/meson.build',

            # Translations
            'resources/po/LINGUAS': 'po/LINGUAS',
            'resources/po/meson.build': 'po/meson.build',
            'resources/po/POTFILES': 'po/POTFILES',
        }

        if self.language == 'c':
            files['resources/src/main.c'] = 'src/main.c'
        elif self.language == 'c++':
            files['resources/src/main.c'] = 'src/main.cpp'

        if 'license_full' in params:
            license_full_path = params['license_full'].get_string()
            files[license_full_path] = 'COPYING'

        if 'license_short' in params:
            license_short_path = params['license_short'].get_string()
            license_base = Gio.resources_lookup_data(license_short_path[11:],
                                                     0).get_data().decode()
            self.locator.license = license_base

        if 'path' in params:
            dir_path = params['path'].get_string()
        else:
            dir_path = name
        directory = Gio.File.new_for_path(dir_path)
        scope.get('project_path').assign_string(directory.get_path())

        for src, dst in files.items():
            destination = directory.get_child(dst % expands)
            if src.startswith("resource://"):
                self.add_resource(src[11:], destination, scope,
                                  modes.get(src, 0))
            else:
                path = get_module_data_path(src)
                self.add_path(path, destination, scope, modes.get(src, 0))

        self.expand_all_async(cancellable, self.expand_all_cb, task)
Example #20
0
def _make_installconfig(script, osobj, unattended_data, arch, hostname, url):
    """
    Build a Libosinfo.InstallConfig instance
    """
    def get_timezone():
        TZ_FILE = "/etc/localtime"
        localtime = Gio.File.new_for_path(TZ_FILE)
        if not localtime.query_exists():
            return None
        info = localtime.query_info(Gio.FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET,
                                    Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS)
        if not info:
            return None
        target = info.get_symlink_target()
        if not target:
            return None
        tokens = target.split("zoneinfo/")
        if not tokens or len(tokens) < 2:
            return None
        return tokens[1]

    def get_language():
        names = GLib.get_language_names()
        if not names or len(names) < 2:
            return None
        return names[1]

    config = Libosinfo.InstallConfig()

    # Set user login and name based on the one from the system
    config.set_user_login(GLib.get_user_name())
    config.set_user_realname(GLib.get_real_name())

    # Set user-password.
    # In case it's required and not passed, just raise a RuntimeError.
    if script.requires_user_password() and not unattended_data.user_password:
        raise RuntimeError(
            _("%s requires the user-password to be set.") % osobj.name)
    config.set_user_password(
        unattended_data.user_password if unattended_data.user_password else "")

    # Set the admin-password:
    # In case it's required and not passed, just raise a RuntimeError.
    if script.requires_admin_password() and not unattended_data.admin_password:
        raise RuntimeError(
            _("%s requires the admin-password to be set.") % osobj.name)
    config.set_admin_password(unattended_data.admin_password
                              if unattended_data.admin_password else "")

    # Set the target disk.
    # virtiodisk is the preferred way, in case it's supported, otherwise
    # just fallback to scsi.
    #
    # Note: this is linux specific and will require some changes whenever
    # support for Windows will be added.
    tgt = "/dev/vda" if osobj.supports_virtiodisk() else "/dev/sda"
    config.set_target_disk(tgt)

    # Set hardware architecture and hostname
    config.set_hardware_arch(arch)
    config.set_hostname(hostname)

    # Try to guess the timezone from '/etc/localtime', in case it's not
    # possible 'America/New_York' will be used.
    timezone = get_timezone()
    if timezone:
        config.set_l10n_timezone(timezone)
    else:
        logging.warning(
            _("'America/New_York' timezone will be used for this "
              "unattended installation."))

    # Try to guess to language and keyboard layout from the system's
    # language.
    #
    # This method has flows as it's quite common to have language and
    # keyboard layout not matching. Otherwise, there's no easy way to guess
    # the keyboard layout without relying on a set of APIs of an specific
    # Desktop Environment.
    language = get_language()
    if language:
        config.set_l10n_language(language)
        config.set_l10n_keyboard(language)
    else:
        logging.warning(
            _("'en_US' will be used as both language and keyboard layout "
              "for unattended installation."))

    if url:
        config.set_installation_url(url)  # pylint: disable=no-member

    logging.debug("InstallScriptConfig created with the following params:")
    logging.debug("username: %s", config.get_user_login())
    logging.debug("realname: %s", config.get_user_realname())
    logging.debug("user password: %s", config.get_user_password())
    logging.debug("admin password: %s", config.get_admin_password())
    logging.debug("target disk: %s", config.get_target_disk())
    logging.debug("hardware arch: %s", config.get_hardware_arch())
    logging.debug("hostname: %s", config.get_hostname())
    logging.debug("timezone: %s", config.get_l10n_timezone())
    logging.debug("language: %s", config.get_l10n_language())
    logging.debug("keyboard: %s", config.get_l10n_keyboard())
    logging.debug("url: %s", config.get_installation_url())  # pylint: disable=no-member

    return config
Example #21
0
def get_user_name():
    name = GLib.get_real_name()
    if name == "":
        name = GLib.get_user_name()
    return name
Example #22
0
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Strings to be used in UI.

import gettext
from gettext import gettext as _
from gi.repository import GLib

gettext.textdomain("gmailwatcher")

# String constants
icon_name = 'gmailwatcher'

# Messages Tuple of (Title, Description)
username = GLib.get_real_name().split()[0]
username = username == 'Unknown' and GLib.get_user_name() or username

no_account = (
        _("Add an account"),
        _("Hey %s, I don't have any accounts to watch over right now."
           "Please add a gmail or google apps account and I'll let you "
           "know about any new messages.") % username
        )

quit = (
        _("ZZZzzzz..."),
        _("If you need me again, you can find me by clicking "
          "the messaging icon in the top panel.")
        )

start = (
        _("Gmail Watcher"),
Example #23
0
    def do_expand_async(self, params, cancellable, callback, data):
        self.reset()

        task = Gio.Task.new(self, cancellable, callback)

        name = params['name'].get_string().lower()

        if 'path' in params:
            dir_path = params['path'].get_string()
        else:
            dir_path = name

        self.language = 'c'
        if 'language' in params:
            self.language = params['language'].get_string().lower()

        if self.language not in ('c', 'c++', 'vala', 'python'):
            task.return_error(
                GLib.Error("Language %s not supported" % self.language))
            return

        self.versioning = ''
        if 'versioning' in params:
            self.versioning = params['versioning'].get_string()

        if 'author' in params:
            author_name = params['author'].get_string()
        else:
            author_name = GLib.get_real_name()

        directory = Gio.File.new_for_path(dir_path)

        scope = Template.Scope.new()

        scope.get('template').assign_string(self.id)

        prefix = name if not name.endswith('-glib') else name[:-5]
        PREFIX = prefix.upper().replace('-', '_')
        prefix_ = prefix.lower().replace('-', '_')
        PreFix = ''.join(
            [word.capitalize() for word in prefix.lower().split('-')])

        name_ = name.lower().replace('-', '_')

        scope.get('name').assign_string(name)
        scope.get('name_').assign_string(name_)
        scope.get('NAME').assign_string(name.upper().replace('-', '_'))

        scope.get('prefix').assign_string(prefix)
        scope.get('Prefix').assign_string(prefix.capitalize())
        scope.get('PreFix').assign_string(PreFix)
        scope.get('prefix_').assign_string(prefix_)
        scope.get('PREFIX').assign_string(PREFIX)

        scope.get('project_path').assign_string(directory.get_path())
        scope.get('packages').assign_string(self.get_packages())
        scope.get('major_version').assign_string('0')
        scope.get('minor_version').assign_string('1')
        scope.get('micro_version').assign_string('0')
        scope.get('enable_c').assign_boolean(self.language in ('c', 'vala',
                                                               'c++'))
        scope.get('enable_python').assign_boolean(self.language == 'python')
        scope.get('enable_cplusplus').assign_boolean(self.language == 'c++')
        scope.get('enable_i18n').assign_boolean(True)
        scope.get('enable_gtk_doc').assign_boolean(False)
        scope.get('enable_gobject_introspection').assign_boolean(
            self.language in ('c', 'vala', 'c++'))
        scope.get('enable_vapi').assign_boolean(self.language == 'c')
        scope.get('enable_vala').assign_boolean(self.language == 'vala')
        scope.get('translation_copyright').assign_string(
            'Translation copyright holder')
        scope.get('language').assign_string(self.language)

        scope.get('author').assign_string(author_name)

        self.prepare_scope(scope)

        expands = {
            'name': name,
            'name_': name_,
            'prefix': prefix,
            'PreFix': PreFix,
        }

        files = {
            'resources/CONTRIBUTING.md': 'CONTRIBUTING.md',
            'resources/Makefile.am': 'Makefile.am',
            'resources/NEWS': 'NEWS',
            'resources/README.md': 'README.md',
            'resources/autogen.sh': 'autogen.sh',
            'resources/configure.ac': 'configure.ac',
            'resources/git.mk': 'git.mk',
            'resources/m4/Makefile.am': 'm4/Makefile.am',
            'resources/m4/appstream-xml.m4': 'm4/appstream-xml.m4',
            'resources/m4/ax_append_compile_flags.m4':
            'm4/ax_append_compile_flags.m4',
            'resources/m4/ax_append_flag.m4': 'm4/ax_append_flag.m4',
            'resources/m4/ax_check_compile_flag.m4':
            'm4/ax_check_compile_flag.m4',
            'resources/m4/ax_check_link_flag.m4': 'm4/ax_check_link_flag.m4',
            'resources/m4/ax_compiler_vendor.m4': 'm4/ax_compiler_vendor.m4',
            'resources/m4/ax_compiler_flags_cxxflags.m4':
            'm4/ax_compiler_flags_cxxflags.m4',
            'resources/m4/ax_cxx_compile_stdcxx_11.m4':
            'm4/ax_cxx_compile_stdcxx_11.m4',
            'resources/m4/ax_require_defined.m4': 'm4/ax_require_defined.m4',
            'resources/m4/glib-gettext.m4': 'm4/glib-gettext.m4',
            'resources/m4/gsettings.m4': 'm4/gsettings.m4',
            'resources/m4/intltool.m4': 'm4/intltool.m4',
            'resources/m4/introspection.m4': 'm4/introspection.m4',
            'resources/m4/libtool.m4': 'm4/libtool.m4',
            'resources/m4/pkg.m4': 'm4/pkg.m4',
            'resources/m4/vala.m4': 'm4/vala.m4',
            'resources/m4/vapigen.m4': 'm4/vapigen.m4',
            'resources/data/Makefile.am': 'data/Makefile.am',
            'resources/po/LINGUAS': 'po/LINGUAS',
            'resources/po/Makevars': 'po/Makevars',
            'resources/po/POTFILES.in': 'po/POTFILES.in',
        }

        if 'license_full' in params:
            license_full_path = params['license_full'].get_string()
            files[license_full_path] = 'COPYING'

        if 'license_short' in params:
            license_short_path = params['license_short'].get_string()
            license_base = Gio.resources_lookup_data(license_short_path[11:],
                                                     0).get_data().decode()
            self.locator.license = license_base

        self.prepare_files(files)

        modes = {'resources/autogen.sh': 0o750}
        self.prepare_file_modes(modes)

        for src, dst in files.items():
            destination = directory.get_child(dst % expands)
            if src.startswith("resource://"):
                self.add_resource(src[11:], destination, scope,
                                  modes.get(src, 0))
            else:
                path = get_module_data_path(src)
                self.add_path(path, destination, scope, modes.get(src, 0))

        self.expand_all_async(cancellable, self.expand_all_cb, task)
Example #24
0
    def do_expand_async(self, params, cancellable, callback, data):
        self.reset()

        task = Gio.Task.new(self, cancellable, callback)

        if 'language' in params:
            self.language = params['language'].get_string().lower()
        else:
            self.language = 'c'

        if self.language not in ('c', 'c++', 'javascript', 'python', 'vala'):
            task.return_error(GLib.Error('Language %s not supported' %
                                         self.language))
            return

        if 'versioning' in params:
            self.versioning = params['versioning'].get_string()
        else:
            self.versioning = ''

        if 'author' in params:
            author_name = params['author'].get_string()
        else:
            author_name = GLib.get_real_name()

        scope = Template.Scope.new()
        scope.get('template').assign_string(self.id)

        name = params['name'].get_string().lower()
        name_ = name.lower().replace('-', '_')
        scope.get('name').assign_string(name)
        scope.get('name_').assign_string(name_)
        scope.get('NAME').assign_string(name.upper().replace('-','_'))

        # TODO: Support setting app id
        appid = 'org.gnome.' + name.title()
        appid_path = '/' + appid.replace('.', '/')
        scope.get('appid').assign_string(appid)
        scope.get('appid_path').assign_string(appid_path)

        prefix = name if not name.endswith('-glib') else name[:-5]
        PREFIX = prefix.upper().replace('-','_')
        prefix_ = prefix.lower().replace('-','_')
        PreFix = ''.join([word.capitalize() for word in prefix.lower().split('-')])

        scope.get('prefix').assign_string(prefix)
        scope.get('Prefix').assign_string(prefix.capitalize())
        scope.get('PreFix').assign_string(PreFix)
        scope.get('prefix_').assign_string(prefix_)
        scope.get('PREFIX').assign_string(PREFIX)


        enable_gnome = isinstance(self, GnomeProjectTemplate)
        scope.get('project_version').assign_string('0.1.0')
        scope.get('enable_i18n').assign_boolean(enable_gnome)
        scope.get('enable_gnome').assign_boolean(enable_gnome)
        scope.get('language').assign_string(self.language)
        scope.get('author').assign_string(author_name)

        # Just avoiding dealing with template bugs
        if self.language == 'c':
            ui_file = prefix + '-window.ui'
        else:
            ui_file = 'window.ui'
        scope.get('ui_file').assign_string(ui_file)

        exec_name = appid if self.language == 'javascript' else name
        scope.get('exec_name').assign_string(exec_name)

        modes = {
            'resources/src/hello.js.in': 0o750,
            'resources/src/hello.py.in': 0o750,
            'resources/build-aux/meson/postinstall.py': 0o750,
        }

        expands = {
            'prefix': prefix,
            'appid': appid,
            'name_': name_,
            'name': name,
        }

        files = {
            # Build files
            'resources/meson.build': 'meson.build',

        }
        self.prepare_files(files)

        if 'license_full' in params:
            license_full_path = params['license_full'].get_string()
            files[license_full_path] = 'COPYING'

        if 'license_short' in params:
            license_short_path = params['license_short'].get_string()
            license_base = Gio.resources_lookup_data(license_short_path[11:], 0).get_data().decode()
            self.locator.license = license_base

        if 'path' in params:
            dir_path = params['path'].get_string()
        else:
            dir_path = name
        directory = Gio.File.new_for_path(dir_path)
        scope.get('project_path').assign_string(directory.get_path())

        for src, dst in files.items():
            destination = directory.get_child(dst % expands)
            if src.startswith('resource://'):
                self.add_resource(src[11:], destination, scope, modes.get(src, 0))
            else:
                path = os.path.join('/org/gnome/builder/plugins/meson_templates', src)
                self.add_resource(path, destination, scope, modes.get(src, 0))

        self.expand_all_async(cancellable, self.expand_all_cb, task)
Example #25
0
 def GetRemoteMachineInfo(self, request, context):
     return warp_pb2.RemoteMachineInfo(display_name=GLib.get_real_name(),
                                       user_name=GLib.get_user_name())
Example #26
0
    def do_expand_async(self, params, cancellable, callback, data):
        self.reset()

        task = Gio.Task.new(self, cancellable, callback)

        name = params['name'].get_string().lower()

        if 'path' in params:
            dir_path = params['path'].get_string()
        else:
            dir_path = name

        self.language = 'c'
        if 'language' in params:
            self.language = params['language'].get_string().lower()

        if self.language not in ('c', 'c++', 'vala', 'python'):
            task.return_error(GLib.Error("Language %s not supported" %
                                         self.language))
            return

        self.versioning = ''
        if 'versioning' in params:
            self.versioning = params['versioning'].get_string()

        if 'author' in params:
            author_name = params['author'].get_string()
        else:
            author_name = GLib.get_real_name()

        directory = Gio.File.new_for_path(dir_path)

        scope = Template.Scope.new()

        scope.get('template').assign_string(self.id)

        prefix = name if not name.endswith('-glib') else name[:-5]
        PREFIX = prefix.upper().replace('-','_')
        prefix_ = prefix.lower().replace('-','_')
        PreFix = ''.join([word.capitalize() for word in prefix.lower().split('-')])

        name_ = name.lower().replace('-','_')

        scope.get('name').assign_string(name)
        scope.get('name_').assign_string(name_)
        scope.get('NAME').assign_string(name.upper().replace('-','_'))

        scope.get('prefix').assign_string(prefix)
        scope.get('Prefix').assign_string(prefix.capitalize())
        scope.get('PreFix').assign_string(PreFix)
        scope.get('prefix_').assign_string(prefix_)
        scope.get('PREFIX').assign_string(PREFIX)

        scope.get('project_path').assign_string(directory.get_path())
        scope.get('packages').assign_string(self.get_packages())
        scope.get('major_version').assign_string('0')
        scope.get('minor_version').assign_string('1')
        scope.get('micro_version').assign_string('0')
        scope.get('enable_c').assign_boolean(self.language in ('c', 'vala', 'c++'))
        scope.get('enable_python').assign_boolean(self.language == 'python')
        scope.get('enable_cplusplus').assign_boolean(self.language == 'c++')
        scope.get('enable_i18n').assign_boolean(True)
        scope.get('enable_gtk_doc').assign_boolean(False)
        scope.get('enable_gobject_introspection').assign_boolean(self.language in ('c', 'vala', 'c++'))
        scope.get('enable_vapi').assign_boolean(self.language == 'c')
        scope.get('enable_vala').assign_boolean(self.language == 'vala')
        scope.get('translation_copyright').assign_string('Translation copyright holder')
        scope.get('language').assign_string(self.language)

        scope.get('author').assign_string(author_name)

        self.prepare_scope(scope)

        expands = {
            'name': name,
            'name_': name_,
            'prefix': prefix,
            'PreFix': PreFix,
        }

        files = {
            'resources/CONTRIBUTING.md':                'CONTRIBUTING.md',
            'resources/Makefile.am':                    'Makefile.am',
            'resources/NEWS':                           'NEWS',
            'resources/README.md':                      'README.md',
            'resources/autogen.sh':                     'autogen.sh',
            'resources/configure.ac':                   'configure.ac',
            'resources/git.mk':                         'git.mk',

            'resources/m4/Makefile.am':                 'm4/Makefile.am',
            'resources/m4/appstream-xml.m4':            'm4/appstream-xml.m4',
            'resources/m4/ax_append_compile_flags.m4':  'm4/ax_append_compile_flags.m4',
            'resources/m4/ax_append_flag.m4':           'm4/ax_append_flag.m4',
            'resources/m4/ax_check_compile_flag.m4':    'm4/ax_check_compile_flag.m4',
            'resources/m4/ax_check_link_flag.m4':       'm4/ax_check_link_flag.m4',
            'resources/m4/ax_compiler_vendor.m4':       'm4/ax_compiler_vendor.m4',
            'resources/m4/ax_compiler_flags_cxxflags.m4':'m4/ax_compiler_flags_cxxflags.m4',
            'resources/m4/ax_cxx_compile_stdcxx_11.m4': 'm4/ax_cxx_compile_stdcxx_11.m4',
            'resources/m4/ax_require_defined.m4':       'm4/ax_require_defined.m4',
            'resources/m4/glib-gettext.m4':             'm4/glib-gettext.m4',
            'resources/m4/gsettings.m4':                'm4/gsettings.m4',
            'resources/m4/intltool.m4':                 'm4/intltool.m4',
            'resources/m4/introspection.m4':            'm4/introspection.m4',
            'resources/m4/libtool.m4':                  'm4/libtool.m4',
            'resources/m4/pkg.m4':                      'm4/pkg.m4',
            'resources/m4/vala.m4':                     'm4/vala.m4',
            'resources/m4/vapigen.m4':                  'm4/vapigen.m4',

            'resources/data/Makefile.am':               'data/Makefile.am',

            'resources/po/LINGUAS':                     'po/LINGUAS',
            'resources/po/Makevars':                    'po/Makevars',
            'resources/po/POTFILES.in':                 'po/POTFILES.in',
        }

        if 'license_full' in params:
            license_full_path = params['license_full'].get_string()
            files[license_full_path] = 'COPYING'

        if 'license_short' in params:
            license_short_path = params['license_short'].get_string()
            license_base = Gio.resources_lookup_data(license_short_path[11:], 0).get_data().decode()
            self.locator.license = license_base

        self.prepare_files(files)

        modes = { 'resources/autogen.sh': 0o750 }
        self.prepare_file_modes(modes)

        for src,dst in files.items():
            destination = directory.get_child(dst % expands)
            if src.startswith("resource://"):
                self.add_resource(src[11:], destination, scope, modes.get(src, 0))
            else:
                path = get_module_data_path(src)
                self.add_path(path, destination, scope, modes.get(src, 0))

        self.expand_all_async(cancellable, self.expand_all_cb, task)
Example #27
0
    def do_expand_async(self, params, cancellable, callback, data):
        self.reset()

        task = Gio.Task.new(self, cancellable, callback)

        if 'language' in params:
            self.language = params['language'].get_string().lower()
        else:
            self.language = 'c'

        if self.language not in ('c', 'c++'):
            task.return_error(GLib.Error('Language %s not supported' % self.language))
            return

        if 'versioning' in params:
            self.versioning = params['versioning'].get_string()
        else:
            self.versioning = ''

        if 'author' in params:
            author_name = params['author'].get_string()
        else:
            author_name = GLib.get_real_name()

        scope = Template.Scope.new()
        scope.get('template').assign_string(self.id)

        name = params['name'].get_string().lower()
        name_ = name.lower().replace('-', '_')
        scope.get('name').assign_string(name)
        scope.get('name_').assign_string(name_)
        scope.get('NAME').assign_string(name.upper().replace('-','_'))

        prefix = name if not name.endswith('-glib') else name[:-5]
        PREFIX = prefix.upper().replace('-','_')
        prefix_ = prefix.lower().replace('-','_')
        PreFix = ''.join([word.capitalize() for word in prefix.lower().split('-')])

        scope.get('prefix').assign_string(prefix)
        scope.get('Prefix').assign_string(prefix.capitalize())
        scope.get('PreFix').assign_string(PreFix)
        scope.get('prefix_').assign_string(prefix_)
        scope.get('PREFIX').assign_string(PREFIX)

        scope.get('language').assign_string(self.language)
        scope.get('author').assign_string(author_name)
        scope.get('exec_name').assign_string(name)

        expands = {
            'prefix': prefix,
            'name_': name_,
            'name': name,
            'exec_name': name,
        }

        files = {
            'resources/.gitignore': '.gitignore',
            'resources/Makefile': 'Makefile',
            'resources/main.c': '%(exec_name)s.c',
        }
        self.prepare_files(files)

        modes = {}

        if 'license_full' in params:
            license_full_path = params['license_full'].get_string()
            files[license_full_path] = 'COPYING'

        if 'license_short' in params:
            license_short_path = params['license_short'].get_string()
            license_base = Gio.resources_lookup_data(license_short_path[11:], 0).get_data().decode()
            self.locator.license = license_base

        if 'path' in params:
            dir_path = params['path'].get_string()
        else:
            dir_path = name
        directory = Gio.File.new_for_path(dir_path)
        scope.get('project_path').assign_string(directory.get_path())

        for src, dst in files.items():
            destination = directory.get_child(dst % expands)
            if src.startswith('resource://'):
                self.add_resource(src[11:], destination, scope, modes.get(src, 0))
            else:
                path = os.path.join('/plugins/make_plugin', src)
                self.add_resource(path, destination, scope, modes.get(src, 0))

        self.expand_all_async(cancellable, self.expand_all_cb, task)
Example #28
0
    def do_expand_async(self, params, cancellable, callback, data):
        self.reset()

        task = Gio.Task.new(self, cancellable, callback)

        if 'language' in params:
            self.language = params['language'].get_string().lower()
        else:
            self.language = 'c'

        if self.language not in ('c', 'c++'):
            task.return_error(
                GLib.Error('Language %s not supported' % self.language))
            return

        if 'versioning' in params:
            self.versioning = params['versioning'].get_string()
        else:
            self.versioning = ''

        if 'author' in params:
            author_name = params['author'].get_string()
        else:
            author_name = GLib.get_real_name()

        scope = Template.Scope.new()
        scope.get('template').assign_string(self.id)

        name = params['name'].get_string().lower()
        name_ = name.lower().replace('-', '_')
        scope.get('name').assign_string(name)
        scope.get('name_').assign_string(name_)
        scope.get('NAME').assign_string(name.upper().replace('-', '_'))

        prefix = name if not name.endswith('-glib') else name[:-5]
        PREFIX = prefix.upper().replace('-', '_')
        prefix_ = prefix.lower().replace('-', '_')
        PreFix = ''.join(
            [word.capitalize() for word in prefix.lower().split('-')])

        scope.get('prefix').assign_string(prefix)
        scope.get('Prefix').assign_string(prefix.capitalize())
        scope.get('PreFix').assign_string(PreFix)
        scope.get('prefix_').assign_string(prefix_)
        scope.get('PREFIX').assign_string(PREFIX)

        scope.get('language').assign_string(self.language)
        scope.get('author').assign_string(author_name)
        scope.get('exec_name').assign_string(name)

        expands = {
            'prefix': prefix,
            'name_': name_,
            'name': name,
            'exec_name': name,
        }

        files = {
            'resources/.gitignore': '.gitignore',
            'resources/Makefile': 'Makefile',
            'resources/main.c': '%(exec_name)s.c',
        }
        self.prepare_files(files)

        modes = {}

        if 'license_full' in params:
            license_full_path = params['license_full'].get_string()
            files[license_full_path] = 'COPYING'

        if 'license_short' in params:
            license_short_path = params['license_short'].get_string()
            license_base = Gio.resources_lookup_data(license_short_path[11:],
                                                     0).get_data().decode()
            self.locator.license = license_base

        if 'path' in params:
            dir_path = params['path'].get_string()
        else:
            dir_path = name
        directory = Gio.File.new_for_path(dir_path)
        scope.get('project_path').assign_string(directory.get_path())

        for src, dst in files.items():
            destination = directory.get_child(dst % expands)
            if src.startswith('resource://'):
                self.add_resource(src[11:], destination, scope,
                                  modes.get(src, 0))
            else:
                path = os.path.join('/plugins/make_plugin', src)
                self.add_resource(path, destination, scope, modes.get(src, 0))

        self.expand_all_async(cancellable, self.expand_all_cb, task)
Example #29
0
    def GetRemoteMachineInfo(self, request, context):
        logging.debug("Server RPC: GetRemoteMachineInfo from '%s'" %
                      request.readable_name)

        return warp_pb2.RemoteMachineInfo(display_name=GLib.get_real_name(),
                                          user_name=GLib.get_user_name())
Example #30
0
    def do_expand_async(self, params, cancellable, callback, data):
        self.reset()

        task = Gio.Task.new(self, cancellable, callback)

        if 'language' in params:
            self.language = params['language'].get_string().lower()
        else:
            self.language = 'c'

        if self.language not in ('c', 'c++'):
            task.return_error(GLib.Error('Language %s not supported' %
                                         self.language))
            return

        if 'versioning' in params:
            self.versioning = params['versioning'].get_string()
        else:
            self.versioning = ''

        if 'author' in params:
            author_name = params['author'].get_string()
        else:
            author_name = GLib.get_real_name()

        scope = Template.Scope.new()
        scope.get('template').assign_string(self.id)

        name = params['name'].get_string().lower()
        name_ = name.lower().replace('-','_')
        scope.get('name').assign_string(name)
        scope.get('name_').assign_string(name_)

        scope.get('project_version').assign_string('0.1.0')
        scope.get('enable_i18n').assign_boolean(True)
        scope.get('language').assign_string(LANGUAGE_MAP[self.language])
        scope.get('author').assign_string(author_name)

        modes = {
        }

        expands = {
        }

        files = {
            'resources/meson.build': 'meson.build',
            'resources/src/meson.build': 'src/meson.build',

            # Translations
            'resources/po/LINGUAS': 'po/LINGUAS',
            'resources/po/meson.build': 'po/meson.build',
            'resources/po/POTFILES': 'po/POTFILES',
        }

        if self.language == 'c':
            files['resources/src/main.c'] = 'src/main.c'
        elif self.language == 'c++':
            files['resources/src/main.c'] = 'src/main.cpp'

        if 'license_full' in params:
            license_full_path = params['license_full'].get_string()
            files[license_full_path] = 'COPYING'

        if 'license_short' in params:
            license_short_path = params['license_short'].get_string()
            license_base = Gio.resources_lookup_data(license_short_path[11:], 0).get_data().decode()
            self.locator.license = license_base

        if 'path' in params:
            dir_path = params['path'].get_string()
        else:
            dir_path = name
        directory = Gio.File.new_for_path(dir_path)
        scope.get('project_path').assign_string(directory.get_path())

        for src, dst in files.items():
            destination = directory.get_child(dst % expands)
            if src.startswith("resource://"):
                self.add_resource(src[11:], destination, scope, modes.get(src, 0))
            else:
                path = get_module_data_path(src)
                self.add_path(path, destination, scope, modes.get(src, 0))

        self.expand_all_async(cancellable, self.expand_all_cb, task)
Example #31
0
    def do_expand_async(self, params, cancellable, callback, data):
        self.reset()

        task = Gio.Task.new(self, cancellable, callback)

        if 'language' in params:
            self.language = params['language'].get_string().lower()
        else:
            self.language = 'c'

        if self.language not in ('c', 'c++', 'javascript', 'python', 'vala'):
            task.return_error(
                GLib.Error('Language %s not supported' % self.language))
            return

        if 'versioning' in params:
            self.versioning = params['versioning'].get_string()
        else:
            self.versioning = ''

        if 'author' in params:
            author_name = params['author'].get_string()
        else:
            author_name = GLib.get_real_name()

        scope = Template.Scope.new()
        scope.get('template').assign_string(self.id)

        name = params['name'].get_string().lower()
        name_ = name.lower().replace('-', '_')
        scope.get('name').assign_string(name)
        scope.get('name_').assign_string(name_)
        scope.get('NAME').assign_string(name.upper().replace('-', '_'))

        # TODO: Support setting app id
        appid = 'org.gnome.' + name.title()
        appid_path = '/' + appid.replace('.', '/')
        scope.get('appid').assign_string(appid)
        scope.get('appid_path').assign_string(appid_path)

        prefix = name if not name.endswith('-glib') else name[:-5]
        PREFIX = prefix.upper().replace('-', '_')
        prefix_ = prefix.lower().replace('-', '_')
        PreFix = ''.join(
            [word.capitalize() for word in prefix.lower().split('-')])

        scope.get('prefix').assign_string(prefix)
        scope.get('Prefix').assign_string(prefix.capitalize())
        scope.get('PreFix').assign_string(PreFix)
        scope.get('prefix_').assign_string(prefix_)
        scope.get('PREFIX').assign_string(PREFIX)

        enable_gnome = isinstance(self, GnomeProjectTemplate)
        scope.get('project_version').assign_string('0.1.0')
        scope.get('enable_i18n').assign_boolean(enable_gnome)
        scope.get('enable_gnome').assign_boolean(enable_gnome)
        scope.get('language').assign_string(self.language)
        scope.get('author').assign_string(author_name)

        # Just avoiding dealing with template bugs
        if self.language == 'c':
            ui_file = prefix + '-window.ui'
        else:
            ui_file = 'window.ui'
        scope.get('ui_file').assign_string(ui_file)

        exec_name = appid if self.language == 'javascript' else name
        scope.get('exec_name').assign_string(exec_name)

        modes = {
            'resources/src/hello.js.in': 0o750,
            'resources/src/hello.py.in': 0o750,
            'resources/build-aux/meson/postinstall.py': 0o750,
        }

        expands = {
            'prefix': prefix,
            'appid': appid,
            'name_': name_,
            'name': name,
        }

        files = {
            # Build files
            'resources/meson.build': 'meson.build',
        }
        self.prepare_files(files)

        if 'license_full' in params:
            license_full_path = params['license_full'].get_string()
            files[license_full_path] = 'COPYING'

        if 'license_short' in params:
            license_short_path = params['license_short'].get_string()
            license_base = Gio.resources_lookup_data(license_short_path[11:],
                                                     0).get_data().decode()
            self.locator.license = license_base

        if 'path' in params:
            dir_path = params['path'].get_string()
        else:
            dir_path = name
        directory = Gio.File.new_for_path(dir_path)
        scope.get('project_path').assign_string(directory.get_path())

        for src, dst in files.items():
            destination = directory.get_child(dst % expands)
            if src.startswith('resource://'):
                self.add_resource(src[11:], destination, scope,
                                  modes.get(src, 0))
            else:
                path = os.path.join(
                    '/org/gnome/builder/plugins/meson_templates', src)
                self.add_resource(path, destination, scope, modes.get(src, 0))

        self.expand_all_async(cancellable, self.expand_all_cb, task)