source: n4dgtklogin/trunk/fuentes/README.md @ 7506

Last change on this file since 7506 was 6386, checked in by Juanma, 2 years ago

Changed API

File size: 4.7 KB
Line 
1# n4dGtkLogincomponent
2This is a Lliurex specific login component for Gtk apps. 
3### API 
4###### set_allowed_groups(groups=[])
5        Login only will be succesfull if user belongs to any of this groups.
6###### set_mw_proportion_ratio(columns_left,columns_right) 
7        Sets the portion of screen reserved to each component (info and login form). It works splitting the main window in (columns_left+columns_right) columns and asigning to each part the desired number of columns. By default the proportion is set to 2:1
8###### set_mw_background(image=None,cover=False,from_color=None,to_color=None,gradient='linear') 
9        Sets the background for the login box. It can be a system's image or gradient going "from_color" to "to_color". By default all fields are "None" and only radial and linear gradients are supported. If we set a background image and set cover=True then the image will cover all the box area.
10###### set_login_background(image=None,cover=False,from_color=None,to_color=None,gradient='linear') 
11        Sets the background for the login box. It can be a system's image or gradient going "from_color" to "to_color". By default all fields are "None" and only radial and linear gradients are supported. If we set a background image and set cover=True then the image will cover all the box area.
12###### set_default_username(default_username) 
13        Sets the placeholder of the "username" entry to "default_username" 
14###### set_default_server(default_server) 
15        Sets the placeholder of the "server" entry to "default_server" 
16###### set_login_banner(image) 
17        Sets the user's image for the login form, by default is "llx-avatar"
18        If the image isn't a full path then is searched in the default theme. 
19###### set_info_banner(image,resx=72,resy=72) 
20        Sets the info box banner, by default is "None". The resolution is set to 72X72 by default.
21###### set_info_background(image=None,cover=False,from_color=None,to_color=None,gradient='linear') 
22        Sets the background for the info box. It can be a system's image or gradient going "from_color" to "to_color". By default all fields are "None" and only radial and linear gradients are supported. If we set a background image and set cover=True then the image will cover all the box area.
23###### set_info_text(title,subtitle,text) 
24        Sets the information to show in the info box. 
25        It must have a title, a subtitle and a text as arguments and supports markup language.
26###### hide_server_entry() 
27        Hides the entry field of the login form
28###### hide_info_box() 
29        Hides the info box form
30###### get_action_area() 
31        Returns the info box so we can add any widget to it. 
32###### after_validation_goto() 
33        Sets the function that the loginComponent will launch after a correct user's validation. User, password and server will be passed as arguments to that function.
34 
35### Examples 
36```python 
37#!/usr/bin/env python3 
38import gi 
39gi.require_version('Gtk', '3.0') 
40from gi.repository import Gtk 
41from edupals.ui.n4dgtklogin import * 
42 
43def _signin(): 
44        print("OK") 
45        print("Now hide the login component and make things") 
46 
47def start_gui(): 
48        mw=Gtk.Window() 
49        loginComponent=N4dGtkLogin() #Init the login component 
50        loginComponent.set_info_text("<span foreground='black'>Title</span>","Subtitle","Text text text.\nText text text:\n<sub>* text with sub tag</sub>") 
51        #Uncomment and comment...
52        ##Change the proportion ratio
53        #loginComponent.set_mw_proportion_ratio(2,1)
54        #loginComponent.set_mw_proportion_ratio(1,2)
55        #loginComponent.set_mw_proportion_ratio(3,9)
56        #loginComponent.set_mw_proportion_ratio(8,5)
57        ##- Setting a background for the component
58        #loginComponent.set_mw_background(image='/usr/share/backgrounds/ubuntu-mate-xenial/The_MATErix.png') 
59        ##- Setting a background for the form
60        #loginComponent.set_form_background(from_color='grey',to_color='white',gradient='radial') 
61        ##- Adding a widget to the info box
62        #infobox=loginComponent.get_action_area() 
63        #infobox.add(Gtk.Label("Add widget")) 
64        ##- Changing the background for the info box
65        #loginComponent.set_info_background(from_color='#000000',to_color='white',gradient='linear') 
66        #loginComponent.set_info_background(image='/usr/share/backgrounds/ubuntu-mate-xenial/The_MATErix.png') 
67        ##- Changing default values for entries
68        #loginComponent.set_default_username("Put your name") 
69        #loginComponent.set_default_server("Put your server") 
70        ##- Changing banners
71        #loginComponent.set_login_banner('/usr/share/filezilla/resources/flatzilla/48x48/uploadadd.png') 
72        #loginComponent.set_info_banner('/usr/share/filezilla/resources/flatzilla/24x24/folder.png') 
73        ##- Function that will be launched after a succesfull validation
74        loginComponent.after_validation_goto(_signin) 
75        ##
76        mw.add(loginComponent)
77        mw.connect("delete-event",Gtk.main_quit) 
78        mw.show_all() 
79 
80start_gui() 
81Gtk.main() 
82```
Note: See TracBrowser for help on using the repository browser.