1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
GtkWidget* create_admin_info_frame(){
GtkWidget *info_frame;
info_frame = gtk_frame_markup_new(_("<b>Information</b>"));
if (is_admin){
gtk_container_add(GTK_CONTAINER(info_frame), gtk_label_new(g_strdup_printf(_("You are logged in as %s.\nYou are administrator."), g_get_user_name())));
}
else gtk_container_add(GTK_CONTAINER(info_frame), gtk_label_new(g_strdup_printf(_("You are logged in as %s.\nYou are NOT administrator, so you can't use root on clients."), g_get_user_name())));
return(info_frame);
}
GtkWidget* create_admin_options_frame(){
GtkWidget *options_frame, *options_vbox, *user_label, *user_radiobutton, *root_radiobutton, *screen_label, *thisscreen_radiobutton, *remotescreen_radiobutton, *user_hbox, *screen_hbox;
options_frame = gtk_frame_markup_new(_("<b>Options for admin actions</b>"));
options_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
user_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
user_label = gtk_label_leftaligned_new(_("on client use user"));
gtk_container_add(GTK_CONTAINER(user_hbox), user_label);
user_radiobutton = gtk_radio_button_new_with_label_from_widget(NULL, get_user_name_on_clients());
g_signal_connect(user_radiobutton, "toggled", G_CALLBACK(set_admin_as_root), NULL);
root_radiobutton = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(user_radiobutton), "root");
gtk_container_add(GTK_CONTAINER(user_hbox), user_radiobutton);
gtk_container_add(GTK_CONTAINER(user_hbox), root_radiobutton);
gtk_widget_set_hexpand(user_label, TRUE);
gtk_widget_set_hexpand(user_radiobutton, TRUE);
gtk_widget_set_hexpand(root_radiobutton, TRUE);
gtk_container_add(GTK_CONTAINER(options_vbox), user_hbox);
if (!is_admin) {
gtk_widget_set_sensitive(user_hbox, FALSE);
}
screen_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
screen_label = gtk_label_leftaligned_new(_("if applicable show windows on"));
gtk_container_add(GTK_CONTAINER(screen_hbox), screen_label);
thisscreen_radiobutton = gtk_radio_button_new_with_label_from_widget(NULL, _("this screen"));
g_signal_connect(thisscreen_radiobutton, "toggled", G_CALLBACK(set_admin_this_screen), NULL);
gtk_container_add(GTK_CONTAINER(screen_hbox), thisscreen_radiobutton);
remotescreen_radiobutton = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(thisscreen_radiobutton), _("client's screen"));
gtk_container_add(GTK_CONTAINER(screen_hbox), remotescreen_radiobutton);
gtk_widget_set_hexpand(screen_label, TRUE);
gtk_widget_set_hexpand(thisscreen_radiobutton, TRUE);
gtk_widget_set_hexpand(remotescreen_radiobutton, TRUE);
gtk_container_add(GTK_CONTAINER(options_vbox), screen_hbox);
gtk_container_add(GTK_CONTAINER(options_frame), options_vbox);
// if (!is_admin()) gtk_widget_set_sensitive(options_frame, FALSE);
return(options_frame);
}
GtkWidget* create_admin_actions_frame(){
GtkWidget *actions_hbox, *actions_frame, *terminal_button, *nautilus_button;
actions_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
terminal_button = gtk_button_new_with_label_and_callback(_("open Terminal"), admin_client_start_terminal);
nautilus_button = gtk_button_new_with_label_and_callback(_("open Filesystem in Nautilus"), admin_client_open_nautilus);
gtk_widget_set_hexpand(terminal_button, TRUE);
gtk_widget_set_hexpand(nautilus_button, TRUE);
gtk_container_add(GTK_CONTAINER(actions_hbox), terminal_button);
gtk_container_add(GTK_CONTAINER(actions_hbox), nautilus_button);
actions_frame = gtk_frame_markup_new(_("<b>Actions with selected clients</b>"));
gtk_container_add(GTK_CONTAINER(actions_frame), actions_hbox);
// if (!is_admin()) gtk_widget_set_sensitive(actions_frame, FALSE);
return(actions_frame);
}
GtkWidget* create_admin_execute_frame(){
GtkWidget *command_comboboxentry, *execute_vbox, *execute_frame;
execute_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add(GTK_CONTAINER(execute_vbox), gtk_label_leftaligned_new(_("command")));
command_comboboxentry = gtk_combo_box_text_new_with_entry();
g_signal_connect(command_comboboxentry, "changed", G_CALLBACK(set_admin_command), NULL);
gchar **default_commands;
default_commands = g_settings_get_strv (gsettings_user_conf, "execute-on-every-client-commands");
for (guint i=0; i<g_strv_length (default_commands); i++) {
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(command_comboboxentry), default_commands[i]);
}
gtk_combo_box_set_active(GTK_COMBO_BOX(command_comboboxentry), 0); // set first entry as active
gtk_container_add(GTK_CONTAINER(execute_vbox), command_comboboxentry);
gtk_container_add(GTK_CONTAINER(execute_vbox), gtk_button_new_with_label_and_callback(_("Execute!"), admin_execute_on_every_client));
execute_frame = gtk_frame_markup_new(_("<b>Execute on every client</b>"));
gtk_container_add(GTK_CONTAINER(execute_frame), execute_vbox);
// if (!is_admin()) gtk_widget_set_sensitive(execute_frame, FALSE);
return(execute_frame);
}
GtkWidget* create_admin_beam_frame(){
GtkWidget *target_comboboxentry, *file_filechooserbutton, *beam_vbox, *beam_frame;
beam_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add(GTK_CONTAINER(beam_vbox), gtk_label_leftaligned_new(_("local file:")));
file_filechooserbutton = gtk_file_chooser_button_new(_("File to beam"), GTK_FILE_CHOOSER_ACTION_OPEN);
g_signal_connect(file_filechooserbutton, "selection_changed", G_CALLBACK(set_beam_localfile), NULL);
gtk_container_add(GTK_CONTAINER(beam_vbox), file_filechooserbutton);
gtk_container_add(GTK_CONTAINER(beam_vbox), gtk_label_leftaligned_new(_("target folder (must end with a slash):")));
target_comboboxentry = gtk_combo_box_text_new_with_entry();
g_signal_connect(target_comboboxentry, "changed", G_CALLBACK(set_beam_targetfolder), NULL);
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(target_comboboxentry), "");
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(target_comboboxentry), "/boot/grub/");
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(target_comboboxentry), "/etc/");
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(target_comboboxentry), "/opt/");
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(target_comboboxentry), g_strdup_printf("/home/%s/", get_user_name_on_clients()));
gtk_combo_box_set_active(GTK_COMBO_BOX(target_comboboxentry), 0); // set first entry as active
gtk_container_add(GTK_CONTAINER(beam_vbox), target_comboboxentry);
gtk_container_add(GTK_CONTAINER(beam_vbox), gtk_button_new_with_label_and_callback(_("Beam File!"), beam_file));
beam_frame = gtk_frame_markup_new(_("<b>Beam File</b>"));
gtk_container_add(GTK_CONTAINER(beam_frame), beam_vbox);
// if (!is_admin()) gtk_widget_set_sensitive(beam_frame, FALSE);
return(beam_frame);
}
GtkWidget* create_admin_install_expander(){
GtkWidget *install_label, *install_frame, *install_expander;
install_label = gtk_label_new(_("Simply copy ztree.exe, zleaf.exe, riched20.dll and riched32.dll to the new directory /opt/zTree_<version> and execute mkdir /home/<user>/zTree_<version> on every client to create the folder. Then beam all files from the /opt/zTree_<version> to the new directory on the clients. After a restart of labcontrol the new version will be detected and will be useable."));
gtk_label_set_line_wrap(GTK_LABEL(install_label), TRUE);
gtk_label_set_justify(GTK_LABEL(install_label), GTK_JUSTIFY_FILL);
install_frame = gtk_frame_new(NULL);
gtk_container_add(GTK_CONTAINER(install_frame), install_label);
install_expander = gtk_expander_markup_new(_("<b>Install new zTree version</b>"));
gtk_container_add(GTK_CONTAINER(install_expander), install_frame);
if (!is_admin) gtk_widget_set_sensitive(install_expander, FALSE);
return(install_expander);
}
GtkWidget* create_admin_tab(){
GtkWidget *admin_inner_vbox, *admin_vbox;
admin_inner_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add(GTK_CONTAINER(admin_inner_vbox), create_admin_info_frame());
gtk_container_add(GTK_CONTAINER(admin_inner_vbox), create_admin_options_frame());
gtk_container_add(GTK_CONTAINER(admin_inner_vbox), create_admin_actions_frame());
gtk_container_add(GTK_CONTAINER(admin_inner_vbox), create_admin_execute_frame());
gtk_container_add(GTK_CONTAINER(admin_inner_vbox), create_admin_beam_frame());
gtk_container_add(GTK_CONTAINER(admin_inner_vbox), create_admin_install_expander());
admin_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add(GTK_CONTAINER(admin_vbox), admin_inner_vbox);
gtk_box_set_child_packing(GTK_BOX(admin_vbox), admin_inner_vbox, FALSE, TRUE, 0, GTK_PACK_START);
return(admin_vbox);
}
|