def __init__(self):

        user_id = os.getuid()
        username = pwd.getpwuid(user_id).pw_name
        home_dir = pwd.getpwuid(user_id).pw_dir

        self.builder = Gtk.Builder()
        self.builder.add_from_file("/usr/share/cinnamon/cinnamon-screensaver-lock-dialog/cinnamon-screensaver-lock-dialog.ui")

        self.window = self.builder.get_object("main_dialog")
        self.button_cancel = self.builder.get_object("button_cancel")
        self.button_ok = self.builder.get_object("button_ok")
        self.entry = self.builder.get_object("entry_away_message")
        self.image = self.builder.get_object("image_face")

        self.window.set_title(_("Screen Locker"))
        XApp.set_window_icon_name(self.window, "cs-screensaver")

        self.builder.get_object("label_description").set_markup("<i>%s</i>" % _("Please type an away message for the lock screen"))

        if os.path.exists("%s/.face" % home_dir):
            self.image.set_from_file("%s/.face" % home_dir)
        else:
            self.image.set_from_icon_name("cs-screensaver", Gtk.IconSize.DIALOG)

        self.window.connect("destroy", Gtk.main_quit)
        self.button_cancel.connect("clicked", Gtk.main_quit)
        self.button_ok.connect('clicked', self.lock_screen)
        self.entry.connect('activate', self.lock_screen)

        self.builder.get_object("dialog-action_area1").set_focus_chain((self.button_ok, self.button_cancel))

        self.window.show()
Exemplo n.º 2
0
 def _get_dialog(self, dialog_type, summary, msg="",
                 buttons=Gtk.ButtonsType.CLOSE):
     " internal helper for dialog construction "
     d = Gtk.MessageDialog(parent=self.dia,
                           flags=Gtk.DialogFlags.MODAL,
                           type=dialog_type,
                           buttons=buttons)
     d.set_title("")
     d.set_markup("<big><b>%s</b></big>\n\n%s" % (summary, msg))
     XApp.set_window_icon_name(d, "package-x-generic")
     d.set_keep_above(True)
     d.realize()
     d.get_window().set_functions(Gdk.WMFunction.MOVE)
     return d
Exemplo n.º 3
0
 def _get_dialog(self, dialog_type, summary, msg="",
                 buttons=Gtk.ButtonsType.CLOSE):
     " internal helper for dialog construction "
     d = Gtk.MessageDialog(parent=self.dia,
                           flags=Gtk.DialogFlags.MODAL,
                           type=dialog_type,
                           buttons=buttons)
     d.set_title("")
     d.set_markup("<big><b>%s</b></big>\n\n%s" % (summary, msg))
     XApp.set_window_icon_name(d, "package-x-generic")
     d.set_keep_above(True)
     d.realize()
     d.get_window().set_functions(Gdk.WMFunction.MOVE)
     return d
Exemplo n.º 4
0
    def __init__(self):

        # Determine path to system locale-config
        self.locale_path=''

        if os.path.exists('/etc/default/locale'):
            self.locale_path='/etc/default/locale'
        else:
            self.locale_path='/etc/locale.conf'

        # Prepare the APT cache
        self.cache = apt.Cache()
        self.cache_updated = False

        # load our glade ui file in
        self.builder = Gtk.Builder()
        self.builder.set_translation_domain("mintlocale")
        self.builder.add_from_file('/usr/share/linuxmint/mintlocale/im.ui')

        self.window = self.builder.get_object("main_window")
        self.window.set_title(_("Input Method"))
        XApp.set_window_icon_name(self.window, "mintlocale-im")
        self.window.connect("destroy", Gtk.main_quit)

        self.im_combo = self.builder.get_object("im_combo")
        model = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING)
        cell = Gtk.CellRendererText()
        self.im_combo.pack_start(cell, True)
        self.im_combo.add_attribute(cell, 'text', IM_NAME)
        self.im_combo.set_model(model)

        self.ImConfig = ImConfig()

        self.im_languages = []
        self.im_languages.append(IMLanguage("zh-hans", "fcitx:ibus", self.builder.get_object("button_szh"), self))
        self.im_languages.append(IMLanguage("zh-hant", "fcitx:ibus", self.builder.get_object("button_tzh"), self))
        self.im_languages.append(IMLanguage("ja", "fcitx:ibus", self.builder.get_object("button_ja"), self))
        self.im_languages.append(IMLanguage("th", "fcitx:ibus", self.builder.get_object("button_th"), self))
        self.im_languages.append(IMLanguage("vi", "fcitx:ibus", self.builder.get_object("button_vi"), self))
        self.im_languages.append(IMLanguage("ko", "fcitx:ibus", self.builder.get_object("button_ko"), self))
        self.im_languages.append(IMLanguage("te", "ibus", self.builder.get_object("button_te"), self))

        self.im_loaded = False  # don't react to im changes until we're fully loaded (we're loading that combo asynchronously)
        self.im_combo.connect("changed", self.on_combobox_input_method_changed)

        self.lock_ui()
        self.check_input_methods()

        self.window.show_all()
    def __init__(self):

        user_id = os.getuid()
        username = pwd.getpwuid(user_id).pw_name
        real_name = pwd.getpwuid(user_id).pw_gecos
        home_dir = pwd.getpwuid(user_id).pw_dir

        real_name = real_name.replace(",", "")
        if real_name == "":
            real_name = username

        self.builder = Gtk.Builder()
        self.builder.add_from_file("/usr/share/cinnamon/cinnamon-screensaver-lock-dialog/cinnamon-screensaver-lock-dialog.ui")

        self.window = self.builder.get_object("main_dialog")
        self.button_cancel = self.builder.get_object("button_cancel")
        self.button_ok = self.builder.get_object("button_ok")
        self.entry = self.builder.get_object("entry_away_message")
        self.image = self.builder.get_object("image_face")

        self.window.set_title(_("Screen Locker"))
        XApp.set_window_icon_name(self.window, "cs-screensaver")

        self.builder.get_object("label_description").set_markup("<i>%s</i>" % _("Please type an away message for the lock screen"))
        self.builder.get_object("label_away_message").set_markup("<b>%s: </b>" % real_name)

        if os.path.exists("%s/.face" % home_dir):
            self.image.set_from_file("%s/.face" % home_dir)
        else:
            self.image.set_from_icon_name("cs-screensaver", Gtk.IconSize.DIALOG)

        self.window.connect("destroy", Gtk.main_quit)
        self.button_cancel.connect("clicked", Gtk.main_quit)
        self.button_ok.connect('clicked', self.lock_screen)
        self.entry.connect('activate', self.lock_screen)

        self.builder.get_object("dialog-action_area1").set_focus_chain((self.button_ok, self.button_cancel))

        self.window.show()
Exemplo n.º 6
0
    def askInstallPackage(self, package, summary, description, homepage):
        # populate the dialog
        dia = self.dia
        dia_xml = self.dia_xml
        header = _("Install additional software?")
        body = _("Do you want to install package '%s'?") % package
        dia.set_title(package)
        header_label = dia_xml.get_object('header_label')
        header_label.set_markup("<b><big>%s</big></b>" % header)
        body_label = dia_xml.get_object('body_label')
        body_label.set_label(body)
        description_text_view = dia_xml.get_object('description_text_view')
        tbuf = Gtk.TextBuffer()
        desc = "%s\n\n%s" % (summary, Helpers.format_description(description))
        tbuf.set_text(desc)
        description_text_view.set_buffer(tbuf)
        XApp.set_window_icon_name(dia, "package-x-generic")

        # check if another package manager is already running
        # FIXME: just checking for the existance of the file is
        #        not sufficient, it need to be tested if it can
        #        be locked via apt_pkg.get_lock()
        #        - but that needs to run as root
        #        - a dbus helper might be the best answer here
        #args = (update_button_status, dia_xml.get_object("yes_button"),
        #    dia_xml.get_object("infolabel"))
        #args[0](*args[1:])
        #timer_id = GObject.timeout_add(750, *args )

        # show the dialog
        res = dia.run()
        #GObject.source_remove(timer_id)
        if res != Gtk.ResponseType.YES:
            dia.hide()
            return False

        return True
Exemplo n.º 7
0
    def askInstallPackage(self, package, summary, description, homepage):
        # populate the dialog
        dia = self.dia
        dia_xml = self.dia_xml
        header = _("Install additional software?")
        body = _("Do you want to install package '%s'?") % package
        dia.set_title(package)
        header_label = dia_xml.get_object('header_label')
        header_label.set_markup("<b><big>%s</big></b>" % header)
        body_label = dia_xml.get_object('body_label')
        body_label.set_label(body)
        description_text_view = dia_xml.get_object('description_text_view')
        tbuf = Gtk.TextBuffer()
        desc = "%s\n\n%s" % (summary, Helpers.format_description(description))
        tbuf.set_text(desc)
        description_text_view.set_buffer(tbuf)
        XApp.set_window_icon_name(dia, "package-x-generic")

        # check if another package manager is already running
        # FIXME: just checking for the existance of the file is
        #        not sufficient, it need to be tested if it can
        #        be locked via apt_pkg.get_lock()
        #        - but that needs to run as root
        #        - a dbus helper might be the best answer here
        #args = (update_button_status, dia_xml.get_object("yes_button"),
        #    dia_xml.get_object("infolabel"))
        #args[0](*args[1:])
        #timer_id = GObject.timeout_add(750, *args )

        # show the dialog
        res = dia.run()
        #GObject.source_remove(timer_id)
        if res != Gtk.ResponseType.YES:
            dia.hide()
            return False

        return True
Exemplo n.º 8
0
    def __init__(self):

        # Determine path to system locale-config
        self.locale_path = ''

        if os.path.exists('/etc/default/locale'):
            self.locale_path = '/etc/default/locale'
        else:
            self.locale_path = '/etc/locale.conf'

        # Prepare the APT cache
        self.cache = apt.Cache()
        self.cache_updated = False

        # load our glade ui file in
        self.builder = Gtk.Builder()
        self.builder.set_translation_domain("mintlocale")
        self.builder.add_from_file('/usr/share/linuxmint/mintlocale/im.ui')

        self.window = self.builder.get_object("main_window")
        self.window.set_title(_("Input Method"))
        XApp.set_window_icon_name(self.window, "preferences-desktop-keyboard")
        self.window.connect("destroy", Gtk.main_quit)

        self.im_combo = self.builder.get_object("im_combo")
        model = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING)
        cell = Gtk.CellRendererText()
        self.im_combo.pack_start(cell, True)
        self.im_combo.add_attribute(cell, 'text', IM_NAME)
        self.im_combo.set_model(model)

        self.ImConfig = ImConfig()

        self.im_languages = []
        self.im_languages.append(
            IMLanguage("zh-hans", "fcitx:ibus",
                       self.builder.get_object("button_szh"), self))
        self.im_languages.append(
            IMLanguage("zh-hant", "fcitx:ibus",
                       self.builder.get_object("button_tzh"), self))
        self.im_languages.append(
            IMLanguage("ja", "fcitx:ibus",
                       self.builder.get_object("button_ja"), self))
        self.im_languages.append(
            IMLanguage("th", "fcitx:ibus",
                       self.builder.get_object("button_th"), self))
        self.im_languages.append(
            IMLanguage("vi", "fcitx:ibus",
                       self.builder.get_object("button_vi"), self))
        self.im_languages.append(
            IMLanguage("ko", "fcitx:ibus",
                       self.builder.get_object("button_ko"), self))
        self.im_languages.append(
            IMLanguage("te", "ibus", self.builder.get_object("button_te"),
                       self))

        self.im_loaded = False  # don't react to im changes until we're fully loaded (we're loading that combo asynchronously)
        self.im_combo.connect("changed", self.on_combobox_input_method_changed)

        self.lock_ui()
        self.check_input_methods()

        self.window.show_all()
Exemplo n.º 9
0
    def __init__(self, task, parent=None):
        Gtk.Dialog.__init__(self, parent=parent)

        self.task = task
        self.finished = False

        # Progress goes directly to this window
        task.client_progress_cb = self.window_client_progress_cb

        # finished callbacks route thru the installer
        # but we want to see them in this window also.
        self.final_finished_cb = task.client_finished_cb
        task.client_finished_cb = self.window_client_finished_cb

        self.pulse_timer = 0
        self.active_task_state = task.progress_state

        self.real_progress_text = None
        self.num_dots = 0

        # Setup the dialog
        self.set_border_width(6)
        self.set_resizable(False)
        self.get_content_area().set_spacing(6)
        # Setup the cancel button
        self.button = Gtk.Button.new_from_stock(Gtk.STOCK_CANCEL)
        self.button.set_use_stock(True)
        self.get_action_area().pack_start(self.button, False, False, 0)
        self.button.connect("clicked", self.on_button_clicked)
        self.button.show()

        # labels and progressbar
        hbox = Gtk.HBox()
        hbox.set_spacing(12)
        hbox.set_border_width(6)
        vbox = Gtk.VBox()
        vbox.set_spacing(12)

        self.phase_label = Gtk.Label()
        vbox.pack_start(self.phase_label, False, False, 0)
        self.phase_label.set_halign(Gtk.Align.START)

        vbox_progress = Gtk.VBox()
        vbox_progress.set_spacing(6)
        self.progress = Gtk.ProgressBar()
        vbox_progress.pack_start(self.progress, False, True, 0)

        self.progress_label = Gtk.Label()
        vbox_progress.pack_start(self.progress_label, False, False, 0)
        self.progress_label.set_halign(Gtk.Align.START)
        self.progress_label.set_line_wrap(True)
        self.progress_label.set_max_width_chars(60)

        vbox.pack_start(vbox_progress, False, True, 0)
        hbox.pack_start(vbox, True, True, 0)

        self.get_content_area().pack_start(hbox, True, True, 0)

        self.set_title(_("Flatpak Progress"))
        XApp.set_window_icon_name(self, "system-software-installer")

        hbox.show_all()
        self.realize()

        self.progress.set_size_request(350, -1)
        functions = Gdk.WMFunction.MOVE | Gdk.WMFunction.RESIZE
        try:
            self.get_window().set_functions(functions)
        except TypeError:
            # workaround for older and broken GTK typelibs
            self.get_window().set_functions(Gdk.WMFunction(functions))

        self.update_labels()

        # catch ESC and behave as if cancel was clicked
        self.connect("delete-event", self._on_dialog_delete_event)
Exemplo n.º 10
0
    def __init__(self):

        # Determine path to system locale-config
        self.locale_path = ''

        if os.path.exists('/etc/default/locale'):
            self.locale_path = '/etc/default/locale'
        else:
            self.locale_path = '/etc/locale.conf'

        # Prepare the APT cache
        if IS_DEBIAN:
            self.cache = apt.Cache()
        self.cache_updated = False

        # load our glade ui file in
        self.builder = Gtk.Builder()
        self.builder.set_translation_domain("mintlocale")
        self.builder.add_from_file(
            '/usr/share/linuxmint/mintlocale/mintlocale.ui')

        self.window = self.builder.get_object("main_window")
        self.window.set_title(_("Language Settings"))
        self.window.connect("destroy", Gtk.main_quit)
        XApp.set_window_icon_name(self.window, "preferences-desktop-locale")

        self.scale = self.window.get_scale_factor()

        self.toolbar = Gtk.Toolbar()
        self.toolbar.get_style_context().add_class("primary-toolbar")
        self.builder.get_object("box1").pack_start(self.toolbar, False, False,
                                                   0)

        size_group = Gtk.SizeGroup.new(Gtk.SizeGroupMode.HORIZONTAL)

        self.locale_button = PictureChooserButton(num_cols=2,
                                                  has_button_label=True,
                                                  scale=self.scale)
        size_group.add_widget(self.locale_button)
        self.region_button = PictureChooserButton(num_cols=2,
                                                  has_button_label=True,
                                                  scale=self.scale)
        size_group.add_widget(self.region_button)
        self.time_button = PictureChooserButton(num_cols=2,
                                                has_button_label=True,
                                                scale=self.scale)
        size_group.add_widget(self.time_button)

        self.locale_system_wide_button = Gtk.Button()
        self.locale_system_wide_button.set_label(_("Apply System-Wide"))
        self.locale_system_wide_button.connect(
            "clicked", self.button_system_language_clicked)
        size_group.add_widget(self.locale_system_wide_button)

        self.locale_install_button = Gtk.Button()
        self.locale_install_button.set_label(
            _("Install / Remove Languages..."))
        self.locale_install_button.connect("clicked",
                                           self.button_install_remove_clicked)
        size_group.add_widget(self.locale_install_button)

        self.system_label = Gtk.Label()
        self.install_label = Gtk.Label()

        page = SettingsPage()
        self.builder.get_object("box1").pack_start(page, True, True, 0)

        language_settings = page.add_section()

        label = Gtk.Label.new()
        label.set_markup("<b>%s</b>\n<small>%s</small>" %
                         (_("Language"), _("Language, interface...")))
        row = SettingsRow(label, self.locale_button)
        language_settings.add_row(row)

        label = Gtk.Label.new()
        label.set_markup(
            "<b>%s</b>\n<small>%s</small>" %
            (_("Region"), _("Numbers, currency, addresses, measurement...")))
        row = SettingsRow(label, self.region_button)
        language_settings.add_row(row)

        label = Gtk.Label.new()
        label.set_markup("<b>%s</b>\n<small>%s</small>" %
                         (_("Time format"), _("Date and time...")))
        row = SettingsRow(label, self.time_button)
        language_settings.add_row(row)

        self.system_row = SettingsRow(self.system_label,
                                      self.locale_system_wide_button)
        self.system_row.set_no_show_all(True)
        language_settings.add_row(self.system_row)

        self.install_row = SettingsRow(self.install_label,
                                       self.locale_install_button)
        self.install_row.set_no_show_all(True)
        if IS_DEBIAN:
            language_settings.add_row(self.install_row)

        self.pam_environment_path = os.path.join(GLib.get_home_dir(),
                                                 ".pam_environment")
        self.xsessionrc_path = os.path.join(GLib.get_home_dir(), ".xsessionrc")
        self.dmrc_path = os.path.join(GLib.get_home_dir(), ".dmrc")
        self.dmrc = configparser.ConfigParser()
        self.dmrc.optionxform = str  # force case sensitivity on ConfigParser
        self.dmrc.read(self.dmrc_path)
        if not self.dmrc.has_section('Desktop'):
            self.dmrc.add_section('Desktop')

        current_user = GLib.get_user_name()

        self.current_language = None
        dmrc_language = None
        env_language = os.environ['LANG']

        if self.dmrc.has_option('Desktop', 'Language'):
            dmrc_language = self.dmrc.get('Desktop', 'Language')

        if dmrc_language is not None:
            self.current_language = dmrc_language
        else:
            self.current_language = env_language

        print("User language in .dmrc: %s" % dmrc_language)
        print("User language in $LANG: %s" % env_language)
        print("Current language: %s" % self.current_language)

        if 'LC_NUMERIC' in os.environ:
            self.current_region = os.environ['LC_NUMERIC']
        else:
            self.current_region = self.current_language

        if 'LC_TIME' in os.environ:
            self.current_time = os.environ['LC_TIME']
        else:
            self.current_time = self.current_language

        if os.path.exists(self.pam_environment_path):
            with codecs.open(self.pam_environment_path, 'r',
                             encoding='UTF-8') as pam_file:
                for line in pam_file:
                    line = line.strip()
                    if line.startswith("LC_NUMERIC="):
                        self.current_region = line.split("=")[1].replace(
                            "\"", "").replace("'", "").strip()
                    if line.startswith("LC_TIME="):
                        self.current_time = line.split("=")[1].replace(
                            "\"", "").replace("'", "").strip()

        print("Current region: %s" % self.current_region)
        print("Current time: %s" % self.current_time)

        # Replace utf8 with UTF-8 (lightDM GTK greeter messes that up)
        self.current_language = self.current_language.replace(
            ".utf8", ".UTF-8")
        self.current_region = self.current_region.replace(".utf8", ".UTF-8")
        self.current_time = self.current_time.replace(".utf8", ".UTF-8")

        self.build_lang_list()
        self.set_system_locale()
        self.set_num_installed()

        self.accountService = AccountsService.UserManager.get_default(
        ).get_user(current_user)
        self.accountService.connect('notify::is-loaded',
                                    self.accountservice_ready)

        groups = grp.getgrall()
        for group in groups:
            (name, pw, gid, mem) = group
            if name in ("adm", "sudo", "wheel", "root"):
                for user in mem:
                    if current_user == user:
                        self.system_row.set_no_show_all(False)
                        self.install_row.set_no_show_all(False)
                        language_settings.show_all()
                        break

        self.window.show_all()
Exemplo n.º 11
0
    def __init__(self):

        # Determine path to system locale-config
        self.locale_path=''

        if os.path.exists('/etc/default/locale'):
            self.locale_path='/etc/default/locale'
        else:
            self.locale_path='/etc/locale.conf'

        # Prepare the APT cache
        if IS_DEBIAN:
            self.cache = apt.Cache()
        self.cache_updated = False

        # load our glade ui file in
        self.builder = Gtk.Builder()
        self.builder.set_translation_domain("mintlocale")
        self.builder.add_from_file('/usr/share/linuxmint/mintlocale/mintlocale.ui')

        self.window = self.builder.get_object("main_window")
        self.window.set_title(_("Language Settings"))
        self.window.connect("destroy", Gtk.main_quit)
        XApp.set_window_icon_name(self.window, "preferences-desktop-locale")

        self.toolbar = Gtk.Toolbar()
        self.toolbar.get_style_context().add_class("primary-toolbar")
        self.builder.get_object("box1").pack_start(self.toolbar, False, False, 0)


        size_group = Gtk.SizeGroup.new(Gtk.SizeGroupMode.HORIZONTAL)

        self.locale_button = PictureChooserButton(num_cols=2, button_picture_size=BUTTON_FLAG_SIZE, has_button_label=True)
        size_group.add_widget(self.locale_button)
        self.region_button = PictureChooserButton(num_cols=2, button_picture_size=BUTTON_FLAG_SIZE, has_button_label=True)
        size_group.add_widget(self.region_button)

        self.locale_system_wide_button = Gtk.Button()
        self.locale_system_wide_button.set_label(_("Apply System-Wide"))
        self.locale_system_wide_button.connect("clicked", self.button_system_language_clicked)
        size_group.add_widget(self.locale_system_wide_button)

        self.locale_install_button = Gtk.Button()
        self.locale_install_button.set_label(_("Install / Remove Languages..."))
        self.locale_install_button.connect("clicked", self.button_install_remove_clicked)
        size_group.add_widget(self.locale_install_button)

        self.system_label = Gtk.Label()
        self.install_label = Gtk.Label()

        page = SettingsPage()
        self.builder.get_object("box1").pack_start(page, True, True, 0)

        language_settings = page.add_section()

        label = Gtk.Label.new()
        label.set_markup("<b>%s</b>\n<small>%s</small>" % (_("Language"), _("Language, interface, date and time...")))
        row = SettingsRow(label, self.locale_button)
        language_settings.add_row(row)

        label = Gtk.Label.new()
        label.set_markup("<b>%s</b>\n<small>%s</small>" % (_("Region"), _("Numbers, currency, addresses, measurement...")))
        row = SettingsRow(label, self.region_button)
        language_settings.add_row(row)

        self.system_row = SettingsRow(self.system_label, self.locale_system_wide_button)
        self.system_row.set_no_show_all(True)
        language_settings.add_row(self.system_row)

        self.install_row = SettingsRow(self.install_label, self.locale_install_button)
        self.install_row.set_no_show_all(True)
        if IS_DEBIAN:
            language_settings.add_row(self.install_row)

        self.pam_environment_path = os.path.join(GLib.get_home_dir(), ".pam_environment")
        self.dmrc_path = os.path.join(GLib.get_home_dir(), ".dmrc")
        self.dmrc = configparser.ConfigParser()
        self.dmrc.optionxform = str  # force case sensitivity on ConfigParser
        self.dmrc.read(self.dmrc_path)
        if not self.dmrc.has_section('Desktop'):
            self.dmrc.add_section('Desktop')

        current_user = GLib.get_user_name()

        self.current_language = None
        dmrc_language = None
        env_language = os.environ['LANG']

        if self.dmrc.has_option('Desktop', 'Language'):
            dmrc_language = self.dmrc.get('Desktop', 'Language')

        if dmrc_language is not None:
            self.current_language = dmrc_language
        else:
            self.current_language = env_language

        print("User language in .dmrc: %s" % dmrc_language)
        print("User language in $LANG: %s" % env_language)
        print("Current language: %s" % self.current_language)

        if 'LC_NUMERIC' in os.environ:
            self.current_region = os.environ['LC_NUMERIC']
        else:
            self.current_region = self.current_language

        if os.path.exists(self.pam_environment_path):
            with codecs.open(self.pam_environment_path, 'r', encoding='UTF-8') as pam_file:
                for line in pam_file:
                    line = line.strip()
                    if line.startswith("LC_NUMERIC="):
                        self.current_region = line.split("=")[1].replace("\"", "").replace("'", "").strip()

        print("Current region: %s" % self.current_region)

        # Replace utf8 with UTF-8 (lightDM GTK greeter messes that up)
        self.current_language = self.current_language.replace(".utf8", ".UTF-8")
        self.current_region = self.current_region.replace(".utf8", ".UTF-8")

        self.build_lang_list()
        self.set_system_locale()
        self.set_num_installed()

        self.accountService = AccountsService.UserManager.get_default().get_user(current_user)
        self.accountService.connect('notify::is-loaded', self.accountservice_ready)
        self.accountService.connect('changed::', self.accountservice_changed)

        groups = grp.getgrall()
        for group in groups:
            (name, pw, gid, mem) = group
            if name in ("adm", "sudo", "wheel", "root"):
                for user in mem:
                    if current_user == user:
                        self.system_row.set_no_show_all(False)
                        self.install_row.set_no_show_all(False)
                        language_settings.show_all()
                        break

        self.window.show_all()
Exemplo n.º 12
0
    def __init__(self, task, parent=None):
        Gtk.Dialog.__init__(self, parent=parent)

        self.task = task
        self.finished = False

        # Progress goes directly to this window
        task.client_progress_cb = self.window_client_progress_cb

        # finished callbacks route thru the installer
        # but we want to see them in this window also.
        self.final_finished_cb = task.client_finished_cb
        task.client_finished_cb = self.window_client_finished_cb

        self.pulse_timer = 0
        self.active_task_state = task.progress_state

        self.real_progress_text = None
        self.num_dots = 0

        # Setup the dialog
        self.set_border_width(6)
        self.set_resizable(False)
        self.get_content_area().set_spacing(6)
        # Setup the cancel button
        self.button = Gtk.Button.new_from_stock(Gtk.STOCK_CANCEL)
        self.button.set_use_stock(True)
        self.get_action_area().pack_start(self.button, False, False, 0)
        self.button.connect("clicked", self.on_button_clicked)
        self.button.show()

        # labels and progressbar
        hbox = Gtk.HBox()
        hbox.set_spacing(12)
        hbox.set_border_width(6)
        vbox = Gtk.VBox()
        vbox.set_spacing(12)

        self.phase_label = Gtk.Label()
        vbox.pack_start(self.phase_label, False, False, 0)
        self.phase_label.set_halign(Gtk.Align.START)

        vbox_progress = Gtk.VBox()
        vbox_progress.set_spacing(6)
        self.progress = Gtk.ProgressBar()
        vbox_progress.pack_start(self.progress, False, True, 0)

        self.progress_label = Gtk.Label()
        vbox_progress.pack_start(self.progress_label, False, False, 0)
        self.progress_label.set_halign(Gtk.Align.START)
        self.progress_label.set_line_wrap(True)
        self.progress_label.set_max_width_chars(60)

        vbox.pack_start(vbox_progress, False, True, 0)
        hbox.pack_start(vbox, True, True, 0)

        self.get_content_area().pack_start(hbox, True, True, 0)

        self.set_title(_("Flatpak Progress"))
        XApp.set_window_icon_name(self, "system-software-installer")

        hbox.show_all()
        self.realize()

        self.progress.set_size_request(350, -1)
        functions = Gdk.WMFunction.MOVE | Gdk.WMFunction.RESIZE
        try:
            self.get_window().set_functions(functions)
        except TypeError:
            # workaround for older and broken GTK typelibs
            self.get_window().set_functions(Gdk.WMFunction(functions))

        self.update_labels()

        # catch ESC and behave as if cancel was clicked
        self.connect("delete-event", self._on_dialog_delete_event)