Merge pull request 'Fixes and updates' (#33) from YanTheKaller/ubl-settings-system:master into master

Reviewed-on: #33
pull/69/head^2 v2.8
Dmitry Razumov 2 years ago
commit 2bbc87a115

@ -297,6 +297,21 @@ void yon_config_custom_save(){
template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_CUSTOM,config_get_command("system"),NULL);
}
void on_domain_address_save(GtkEntry *self){
char *adress = (char*)gtk_entry_get_text(self);
if (!yon_char_is_empty(adress)){
yon_config_register(DOMAIN,DOMAIN_get_command,adress);
}
}
void yon_gtk_windget_set_sensitive_from_entry_emptiness(GtkEntry *self, GtkWidget *target){
if (yon_char_is_empty(gtk_entry_get_text(self))){
gtk_widget_set_sensitive(target,0);
} else {
gtk_widget_set_sensitive(target,1);
}
}
void on_locale_toggle(GtkCellRendererToggle *self,GtkTreePath* path,GtkTreeViewColumn* column,locals_window *window){
GtkTreeIter iter;
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(window->MainTree));
@ -443,6 +458,7 @@ domain_info_window *yon_information_window_new(){
domain_info_window *window = malloc(sizeof(domain_info_window));
window->Window = yon_gtk_builder_get_widget(builder,"MainWindow");
window->HeadLabel = yon_gtk_builder_get_widget(builder,"HeadLabel");
window->ExecuteTerminal = yon_gtk_builder_get_widget(builder,"ExecuteTerminal");
window->TerminalScroll = yon_gtk_builder_get_widget(builder,"TerminalScroll");
yon_gtk_widget_set_scroll_window_for_scroll(window->Window,GTK_SCROLLBAR(window->TerminalScroll));
@ -476,6 +492,8 @@ void on_domain_connect(GtkWidget *self, dictionary *dict){
int size;
domain_info_window *dialog = yon_information_window_new();
gtk_window_set_title(GTK_WINDOW(dialog->Window),DOMAIN_CONNECTING_LABEL);
gtk_label_set_text(GTK_LABEL(dialog->HeadLabel),DOMAIN_CONNECTING_LABEL);
yon_terminal_integrated_start(dialog->ExecuteTerminal,domain_connect_command(adress,login,password,final),NULL,NULL);
gtk_entry_set_text(GTK_ENTRY(widgets->DomainEntry),adress);
gtk_widget_show(dialog->Window);
@ -484,7 +502,10 @@ void on_domain_connect(GtkWidget *self, dictionary *dict){
void on_status_clicked(GtkWidget *self, connection_window *window){
domain_info_window *dialog = yon_information_window_new();
// yon_terminal_integrated_start(dialog->ExecuteTerminal,domain_connect_command(adress,login,password,final),NULL,NULL);
char *target = (char*)gtk_entry_get_text(GTK_ENTRY(window->AdressEntry));
if (!yon_char_is_empty(target)){
yon_terminal_integrated_start(dialog->ExecuteTerminal,domain_info(target),NULL,NULL);
}
gtk_widget_show(dialog->Window);
}
@ -501,7 +522,7 @@ void on_main_window_domain_status_clicked(GtkWidget *self, GtkEntryIconPosition
if (!yon_char_is_empty(target)){
domain_info_window *window = yon_information_window_new();
gtk_widget_show(window->Window);
yon_terminal_integrated_start(window->ExecuteTerminal,domain_info(target),NULL,NULL);
yon_terminal_integrated_start(window->ExecuteTerminal,get_domain_info_command,NULL,NULL);
}
}
}
@ -521,6 +542,12 @@ gboolean on_main_window_domain_status_update(connection_window *window){
return 1;
}
gboolean yon_update_thread(connection_window *window){
pthread_t thread_id;
pthread_create(&thread_id, NULL, (void *)on_main_window_domain_status_update,window);
return 1;
}
connection_window *yon_connection_window_new(){
GtkBuilder *builder = gtk_builder_new_from_resource(glade_connection_path);
connection_window *window = malloc(sizeof(connection_window));
@ -654,9 +681,11 @@ void config_init(){
void on_check_domain_connected(main_window *widgets){
if (!system(domain_connect_check)){
gtk_entry_set_icon_from_icon_name(GTK_ENTRY(widgets->DomainEntry),GTK_ENTRY_ICON_SECONDARY,domain_connected_icon);
gtk_button_set_label(GTK_BUTTON(widgets->DomainButton),DOMAIN_DISCONNECT_LABEL);
main_config.domain_connected=1;
} else {
gtk_entry_set_icon_from_icon_name(GTK_ENTRY(widgets->DomainEntry),GTK_ENTRY_ICON_SECONDARY,domain_disconnected_icon);
gtk_button_set_label(GTK_BUTTON(widgets->DomainButton),DOMAIN_CONNECT_LABEL);
main_config.domain_connected=0;
}
}
@ -719,6 +748,10 @@ main_window *yon_main_window_complete(main_window *widgets){
g_signal_connect(G_OBJECT(widgets->DomainButton),"clicked",G_CALLBACK(on_domain_opened),widgets);
g_signal_connect(G_OBJECT(widgets->DomainEntry),"icon-press",G_CALLBACK(on_main_window_domain_status_clicked),widgets);
g_signal_connect(G_OBJECT(widgets->DomainEntry),"changed",G_CALLBACK(yon_gtk_windget_set_sensitive_from_entry_emptiness),widgets->DomainButton);
g_signal_connect(G_OBJECT(widgets->DomainEntry),"focus-out-event",G_CALLBACK(on_domain_address_save),NULL);
g_timeout_add(1000,(GSourceFunc)on_check_domain_connected,widgets);
gtk_widget_set_size_request(widgets->Window,800,-1);

@ -64,22 +64,22 @@
#define DOMAIN_get_command "ubconfig --source global get [network] DOMAIN"
#define check_domain_access_command(targeet) yon_char_append("adcli info --domain ",target)
#define get_domain_info_command(target) yon_char_append("ubdomain-client list ",target)
#define get_domain_info_command "ubdomain-client list "
#define domains_seek_command "ubdomain-client discover"
#define domain_connect_command(target,user,password, addition) yon_char_unite("ubdomain-client join",!yon_char_is_empty(user)?" --user \"":"",!yon_char_is_empty(user)?user:"",!yon_char_is_empty(user)?"\"":"",!yon_char_is_empty(password)?" --password \"":"",!yon_char_is_empty(password)?password:"",!yon_char_is_empty(password)?"\"":""," --domain \"",target,"\"", addition,NULL)
#define domain_disconnect_command(target,user,password) yon_char_unite("ubdomain-client join",!yon_char_is_empty(user)?" --user \"":"",!yon_char_is_empty(user)?user:"",!yon_char_is_empty(user)?"\"":"",!yon_char_is_empty(password)?" --password \"":"",!yon_char_is_empty(password)?password:"",!yon_char_is_empty(password)?"\"":""," --domain \"",target,"\"",NULL)
#define kerberos_addition_command(target) yon_char_unite("--domain_server \"",target,"\"",NULL)
#define dns_addition_command(target) yon_char_unite("--dns \"",target,"\"",NULL)
#define client_addition_command(target) yon_char_unite("--domain_client \"",target,"\"",NULL)
#define domain_disconnect_command(target,user,password) yon_char_unite("ubdomain-client leave",!yon_char_is_empty(user)?" --user \"":"",!yon_char_is_empty(user)?user:"",!yon_char_is_empty(user)?"\"":"",!yon_char_is_empty(password)?" --password \"":"",!yon_char_is_empty(password)?password:"",!yon_char_is_empty(password)?"\"":""," --domain \"",target,"\"",NULL)
#define kerberos_addition_command(target) yon_char_unite(" --domain_server \"",target,"\"",NULL)
#define dns_addition_command(target) yon_char_unite(" --dns \"",target,"\"",NULL)
#define client_addition_command(target) yon_char_unite(" --domain_client \"",target,"\"",NULL)
#define domain_info(target) yon_char_append("ubdomain-client discover --domain ",target)
#define domain_info(target) yon_char_unite("ubdomain-client discover --domain \"",target,"\"",NULL)
#define domain_connected_icon "com.ublinux.ubl-settings-system.plug-connected-symbolic"
#define domain_disconnected_icon "com.ublinux.ubl-settings-system.plug-disconnected-symbolic"
#define domain_connect_check "ubdomain-client list|grep -q \"configured\""
#define domain_check_alive(target) yon_char_unite("dig +time=1 +tries=1 -t SRV _ldap.tcp.",target," @",target," &>/dev/null",NULL)
#define domain_check_alive(target) yon_char_unite("timeout --kill-after=0.1 2 dig +time=1 +tries=1 +noall -t SRV _ldap._tcp.",target," @",target," &>/dev/null",NULL)
#define DOMAIN "DOMAIN"
#define DOMAIN_ADMANGER "DOMAIN[admanger]"
@ -180,6 +180,8 @@ typedef struct {
typedef struct {
GtkWidget *Window;
GtkWidget *HeadLabel;
GtkWidget *ExecuteTerminal;
GtkWidget *TerminalScroll;
} domain_info_window;

@ -49,3 +49,7 @@
#define CONNECTION_LABEL _("Domain connection")
#define CHECK_NAME_LABEL _("Check domain name")
#define LIST_ALL_LABEL _("List all domains")
#define DOMAIN_CONNECTING_LABEL _("Connecting to domain")
#define DOMAIN_CONNECT_LABEL _("Connect to domain")
#define DOMAIN_DISCONNECT_LABEL _("Disconnect from domain")

@ -131,10 +131,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<property name="can-focus">False</property>
<property name="spacing">5</property>
<child>
<object class="GtkLabel">
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Domain address:</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
@ -156,14 +157,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
</child>
<child>
<object class="GtkButton" id="DomainButton">
<property name="label" translatable="yes">Connect to domain</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Domain connection</property>
<property name="image">image3</property>
<style>
<class name="thin"/>
</style>
</object>
<packing>
<property name="expand">False</property>
@ -505,6 +504,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<widget name="label6"/>
<widget name="label3"/>
<widget name="label6"/>
<widget name="label5"/>
</widgets>
</object>
<object class="GtkMenu" id="menu1">

@ -166,7 +166,7 @@ msgid "Samba client"
msgstr ""
#: source/ubl-strings.h:47
msgid "Switch client off or autometically"
msgid "Switch client off or automatically"
msgstr ""
#: source/ubl-strings.h:48
@ -184,3 +184,15 @@ msgstr ""
#: source/ubl-strings.h:51
msgid "List all domains"
msgstr ""
#: source/ubl-strings.h:53
msgid "Connecting to domain"
msgstr ""
#: source/ubl-strings.h:54
msgid "Connect to domain"
msgstr ""
#: source/ubl-strings.h:55
msgid "Disconnect from domain"
msgstr ""

@ -186,6 +186,18 @@ msgstr "Проверить домен"
msgid "List all domains"
msgstr "Показать все домены"
#: source/ubl-strings.h:53
msgid "Connecting to domain"
msgstr "Подключение к домену"
#: source/ubl-strings.h:54
msgid "Connect to domain"
msgstr "Войти в домен"
#: source/ubl-strings.h:55
msgid "Disconnect from domain"
msgstr "Выйти из домена"
msgid "Version:"
msgstr "Версия:"

Loading…
Cancel
Save