Merge branch 'libadwaita-rewrite' of https://github.com/crystal-linux/jade_gui into libadwaita-rewrite
commit
18acf9f8c3
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 0 16 16" width="16px"><path d="m 8 1 c -2.199219 0 -4 1.800781 -4 4 v 2 c -1.109375 0 -2 0.890625 -2 2 v 5 c 0 0.554688 0.445312 1 1 1 h 10 c 0.554688 0 1 -0.445312 1 -1 v -5 c 0 -1.109375 -0.890625 -2 -2 -2 v -2 c 0 -2.199219 -1.800781 -4 -4 -4 z m 0 2 c 1.125 0 2 0.875 2 2 v 2 h -4 v -2 c 0 -1.125 0.875 -2 2 -2 z m 0 0" fill="#2e3436"/></svg>
|
After Width: | Height: | Size: 451 B |
@ -0,0 +1,78 @@
|
|||||||
|
# user_screen.py
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright 2022 user
|
||||||
|
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
from gi.repository import Gtk, Adw
|
||||||
|
from gettext import gettext as _
|
||||||
|
import re
|
||||||
|
|
||||||
|
@Gtk.Template(resource_path='/al/getcyrst/jadegui/pages/user_screen.ui')
|
||||||
|
class UserScreen(Adw.Bin):
|
||||||
|
__gtype_name__ = "UserScreen"
|
||||||
|
|
||||||
|
username_entry = Gtk.Template.Child()
|
||||||
|
password_entry = Gtk.Template.Child()
|
||||||
|
password_confirmation = Gtk.Template.Child()
|
||||||
|
enable_sudo_switch = Gtk.Template.Child()
|
||||||
|
enable_root_switch = Gtk.Template.Child()
|
||||||
|
|
||||||
|
def __init__(self, window, main_carousel, next_page, application, **kwargs):
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
self.window = window
|
||||||
|
self.carousel = main_carousel
|
||||||
|
self.sudo_enabled = True
|
||||||
|
self.root_enabled = True
|
||||||
|
self.next_page = next_page
|
||||||
|
self.enable_root_switch.set_active(self.root_enabled)
|
||||||
|
self.enable_sudo_switch.set_active(self.sudo_enabled)
|
||||||
|
self.username_entry.connect('changed', self.username_passes_regex)
|
||||||
|
self.enable_root_switch.connect('state-set', self.enable_root_user)
|
||||||
|
self.enable_sudo_switch.connect('state-set', self.enable_sudo)
|
||||||
|
|
||||||
|
def username_passes_regex(self, widget):
|
||||||
|
input = self.username_entry.get_text()
|
||||||
|
print(input)
|
||||||
|
if not re.search("^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$", input):
|
||||||
|
print("Invalid username!")
|
||||||
|
else:
|
||||||
|
print("Valid username!")
|
||||||
|
|
||||||
|
def enable_root_user(self, widget, switch_state):
|
||||||
|
print("root")
|
||||||
|
print(self.root_enabled)
|
||||||
|
print(switch_state)
|
||||||
|
if switch_state == False and not self.sudo_enabled:
|
||||||
|
self.root_enabled = switch_state
|
||||||
|
self.sudo_enabled = not switch_state
|
||||||
|
self.enable_sudo_switch.set_active(not switch_state)
|
||||||
|
else:
|
||||||
|
self.root_enabled = switch_state
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def enable_sudo(self, widget, switch_state):
|
||||||
|
print("sudo")
|
||||||
|
print(self.root_enabled)
|
||||||
|
print(switch_state)
|
||||||
|
if switch_state == False and not self.root_enabled:
|
||||||
|
self.sudo_enabled = switch_state
|
||||||
|
self.root_enabled = not switch_state
|
||||||
|
self.enable_root_switch.set_active(not switch_state)
|
||||||
|
else:
|
||||||
|
self.sudo_enabled = switch_state
|
@ -0,0 +1,68 @@
|
|||||||
|
using Gtk 4.0;
|
||||||
|
using Adw 1;
|
||||||
|
|
||||||
|
template UserScreen : Adw.Bin {
|
||||||
|
hexpand: true;
|
||||||
|
vexpand: true;
|
||||||
|
Gtk.Box {
|
||||||
|
vexpand: true;
|
||||||
|
hexpand: true;
|
||||||
|
Adw.StatusPage {
|
||||||
|
hexpand: true;
|
||||||
|
vexpand: true;
|
||||||
|
title: "Create your user";
|
||||||
|
description: "You can add more users in the settings on the installed system";
|
||||||
|
Adw.PreferencesPage {
|
||||||
|
Adw.PreferencesGroup {
|
||||||
|
Gtk.Entry username_entry {
|
||||||
|
margin-bottom: 7;
|
||||||
|
primary-icon-name: "avatar-default-symbolic";
|
||||||
|
primary-icon-activatable: false;
|
||||||
|
secondary-icon-name: "edit-clear";
|
||||||
|
secondary-icon-activatable: true;
|
||||||
|
placeholder-text: "Enter your username";
|
||||||
|
}
|
||||||
|
Gtk.Entry password_entry {
|
||||||
|
margin-top: 7;
|
||||||
|
margin-bottom: 7;
|
||||||
|
primary-icon-name: "system-lock-screen-symbolic";
|
||||||
|
primary-icon-activatable: false;
|
||||||
|
secondary-icon-name: "edit-clear";
|
||||||
|
secondary-icon-activatable: true;
|
||||||
|
placeholder-text: "Enter your password";
|
||||||
|
}
|
||||||
|
Gtk.Entry password_confirmation {
|
||||||
|
margin-top: 7;
|
||||||
|
margin-bottom: 7;
|
||||||
|
primary-icon-name: "system-lock-screen-symbolic";
|
||||||
|
primary-icon-activatable: false;
|
||||||
|
secondary-icon-name: "edit-clear";
|
||||||
|
secondary-icon-activatable: true;
|
||||||
|
placeholder-text: "Repeat your password";
|
||||||
|
styles ["big"]
|
||||||
|
}
|
||||||
|
Gtk.ListBox { // TODO: MOVE TO ADVANCED/MISC SECTION???
|
||||||
|
margin-top: 7;
|
||||||
|
styles ["boxed-list"]
|
||||||
|
Adw.ActionRow {
|
||||||
|
title: "Enable administrative rights for user";
|
||||||
|
subtitle: "Allows the user to use sudo";
|
||||||
|
Gtk.Switch enable_sudo_switch {
|
||||||
|
valign: center;
|
||||||
|
state: true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Adw.ActionRow {
|
||||||
|
title: "Enable superuser account";
|
||||||
|
subtitle: "Allows using the root user";
|
||||||
|
Gtk.Switch enable_root_switch {
|
||||||
|
valign: center;
|
||||||
|
state: false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<gresources>
|
||||||
|
<gresource prefix="/org/gtk/example/icons/scalable/actions/">
|
||||||
|
<file preprocess="xml-stripblanks">../data/icons/padlock2-symbolic.svg</file>
|
||||||
|
</gresource>
|
||||||
|
</gresources>
|
Loading…
Reference in New Issue