You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
194 lines
9.9 KiB
194 lines
9.9 KiB
#include "ubinstall-gtk.h"
|
|
|
|
int yon_configuration_hub_save(main_window *){
|
|
|
|
if (!main_config.configure_mode){
|
|
int size;
|
|
config_str parameters = yon_config_get_save_parameters_by_key(&size,modules_parameter,
|
|
modules_extra_parameter,
|
|
root_password_parameter,
|
|
autologin_parameter,
|
|
xkbmodel_parameter,
|
|
xkblayout_parameter,
|
|
xkbvariant_parameter,
|
|
xkboptions_parameter,
|
|
hostname_parameter,
|
|
zone_parameter,
|
|
lang_parameter,
|
|
locale_parameter,
|
|
num_lock_boot_parameter,
|
|
swap_parameter,
|
|
swap_size_parameter,
|
|
boot_parameter,
|
|
packages_parameter,
|
|
device_typevfs_parameter,
|
|
NTPSERVERS_parameter,
|
|
DOMAIN_parameter,
|
|
DOMAIN_admanger_parameter,
|
|
KERNEL_BOOT_parameter,
|
|
SERVICES_ENABLE_parameter,
|
|
GRUB_SUPERUSERS_parameter,
|
|
GRUB_TIMEOUT_parameter,
|
|
GRUB_DEFAULT_parameter,
|
|
AUTOLOGINUSER_parameter,
|
|
NULL);
|
|
if (parameters){
|
|
char *command_parameters = yon_char_parsed_to_string(parameters,size," -- ");
|
|
char *command = yon_char_unite(ubconfig_dull_command,"--target system ",command_parameters,NULL);
|
|
if (!system(yon_debug_output("%s\n",command))){}
|
|
free(command);
|
|
yon_char_parsed_free(parameters,size);
|
|
}
|
|
|
|
int users_size, save_size;
|
|
config_str users = yon_config_find_keys(NETWORK_parameter_search,&users_size);
|
|
parameters = yon_config_get_save_parameters_by_list(&save_size,users,users_size);
|
|
if (parameters){
|
|
char *command_parameters = yon_char_parsed_to_string(parameters,save_size," -- ");
|
|
char *command = yon_char_unite(ubconfig_dull_command,"--target system ",command_parameters,NULL);
|
|
if (!system(yon_debug_output("%s\n",command))){}
|
|
free(command);
|
|
yon_char_parsed_free(parameters,save_size);
|
|
}
|
|
if (users)yon_char_parsed_free(users,users_size);
|
|
|
|
users = yon_config_find_keys(USERADD_parameter_search,&users_size);
|
|
parameters = yon_config_get_save_parameters_by_list(&save_size,users,users_size);
|
|
if (parameters){
|
|
char *command_parameters = yon_char_parsed_to_string(parameters,size," -- ");
|
|
char *command = yon_char_unite(ubconfig_dull_command,"--target system ",command_parameters,NULL);
|
|
if (!system(yon_debug_output("%s\n",command))){}
|
|
free(command);
|
|
yon_char_parsed_free(parameters,save_size);
|
|
}
|
|
if (users)yon_char_parsed_free(users,users_size);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
void on_configuration_hub_selected(GtkWidget* self, main_window *widgets){
|
|
GList *list = NULL;
|
|
list = g_list_prepend(list,widgets->HubPackagesListBox);
|
|
list = g_list_prepend(list,widgets->HubSystemListBox);
|
|
list = g_list_prepend(list,widgets->HubHardwareListBox);
|
|
list = g_list_prepend(list,widgets->HubPersonalListBox);
|
|
list = g_list_reverse(list);
|
|
GList *iter;
|
|
for (iter=list;iter;iter=iter->next){
|
|
if (iter->data!=self){
|
|
g_signal_handlers_block_by_func(G_OBJECT(iter->data),G_CALLBACK(on_configuration_hub_selected),widgets);
|
|
GList *flowlist = gtk_flow_box_get_selected_children(GTK_FLOW_BOX(iter->data));
|
|
if (flowlist){
|
|
gtk_flow_box_unselect_child(GTK_FLOW_BOX(iter->data),GTK_FLOW_BOX_CHILD(flowlist->data));
|
|
g_list_free(flowlist);
|
|
}
|
|
g_signal_handlers_unblock_by_func(G_OBJECT(iter->data),G_CALLBACK(on_configuration_hub_selected),widgets);
|
|
}
|
|
}
|
|
}
|
|
|
|
void yon_configuration_hub_section_get_max_size(GtkFlowBox *target, int *ret_width, int *ret_height){
|
|
GList *list = gtk_container_get_children(GTK_CONTAINER(target));
|
|
GList *iter;
|
|
for (iter=list;iter;iter=iter->next){
|
|
config_hub_icon *section = g_object_get_data(G_OBJECT(iter->data),"config_hub_icon");
|
|
gtk_widget_realize(GTK_WIDGET(iter->data));
|
|
gtk_widget_realize(GTK_WIDGET(section->Label));
|
|
int width;
|
|
int height;
|
|
|
|
gtk_widget_get_preferred_width(section->Label,NULL,&width);
|
|
gtk_widget_get_preferred_height(section->Label,NULL,&height);
|
|
if ((*ret_width)<width) (*ret_width) = width;
|
|
if ((*ret_height)<height) (*ret_height) = height;
|
|
}
|
|
}
|
|
|
|
void yon_configuration_hub_section_set_max_size(GtkFlowBox *target, int width, int height){
|
|
GList *list = gtk_container_get_children(GTK_CONTAINER(target));
|
|
GList *iter;
|
|
for (iter=list;iter;iter=iter->next){
|
|
config_hub_icon *section = g_object_get_data(G_OBJECT(iter->data),"config_hub_icon");
|
|
gtk_widget_set_size_request(section->Label,width,height);
|
|
|
|
}
|
|
}
|
|
|
|
void yon_configuration_hub_resize(main_window *widgets){
|
|
int max_width=0;
|
|
int max_height=0;
|
|
yon_configuration_hub_section_get_max_size(GTK_FLOW_BOX(widgets->HubPersonalListBox),&max_width,&max_height);
|
|
yon_configuration_hub_section_get_max_size(GTK_FLOW_BOX(widgets->HubHardwareListBox),&max_width,&max_height);
|
|
yon_configuration_hub_section_get_max_size(GTK_FLOW_BOX(widgets->HubSystemListBox),&max_width,&max_height);
|
|
yon_configuration_hub_section_get_max_size(GTK_FLOW_BOX(widgets->HubPackagesListBox),&max_width,&max_height);
|
|
yon_configuration_hub_section_set_max_size(GTK_FLOW_BOX(widgets->HubPersonalListBox),max_width,max_height);
|
|
yon_configuration_hub_section_set_max_size(GTK_FLOW_BOX(widgets->HubHardwareListBox),max_width,max_height);
|
|
yon_configuration_hub_section_set_max_size(GTK_FLOW_BOX(widgets->HubSystemListBox),max_width,max_height);
|
|
yon_configuration_hub_section_set_max_size(GTK_FLOW_BOX(widgets->HubPackagesListBox),max_width,max_height);
|
|
}
|
|
|
|
void on_configuration_hub_open(GtkFlowBox *,GtkFlowBoxChild *child, main_window *widgets){
|
|
config_hub_icon *cur_icon = g_object_get_data(G_OBJECT(child),"config_hub_icon");
|
|
|
|
gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),cur_icon->page);
|
|
yon_page_init(widgets,cur_icon->page);
|
|
yon_page_update(widgets);
|
|
}
|
|
|
|
void yon_configuration_hub_add(GtkFlowBox *target, char *name, char *icon, enum YON_PAGES page){
|
|
g_return_if_fail(GTK_IS_FLOW_BOX(target));
|
|
config_hub_icon *cur_icon = malloc(sizeof(config_hub_icon));
|
|
memset(cur_icon,0,sizeof(config_hub_icon));
|
|
|
|
GtkIconInfo *info = gtk_icon_theme_lookup_icon_for_scale(gtk_icon_theme_get_default(),icon,54,1,GTK_ICON_LOOKUP_FORCE_SIZE);
|
|
|
|
char *name_wrapped = yon_char_wrap_to_length_str(name,10);
|
|
cur_icon->MainBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5);
|
|
cur_icon->Label = gtk_label_new(name_wrapped);
|
|
cur_icon->Image = gtk_image_new_from_pixbuf(gtk_icon_info_load_icon(info,NULL));
|
|
cur_icon->page = page;
|
|
GtkWidget *flow = gtk_flow_box_child_new();
|
|
gtk_style_context_add_class(gtk_widget_get_style_context(flow),"bggrey");
|
|
|
|
gtk_label_set_xalign(GTK_LABEL(cur_icon->Label),0);
|
|
g_object_set_data(G_OBJECT(flow),"config_hub_icon",cur_icon);
|
|
gtk_container_add(GTK_CONTAINER(flow),cur_icon->MainBox);
|
|
gtk_box_pack_start(GTK_BOX(cur_icon->MainBox),cur_icon->Image,0,0,0);
|
|
gtk_box_pack_start(GTK_BOX(cur_icon->MainBox),cur_icon->Label,0,0,0);
|
|
gtk_widget_set_margin_bottom(cur_icon->MainBox,5);
|
|
gtk_widget_set_margin_top(cur_icon->MainBox,5);
|
|
gtk_widget_set_margin_start(cur_icon->MainBox,5);
|
|
gtk_widget_set_margin_end(cur_icon->MainBox,5);
|
|
gtk_flow_box_insert(target,flow,-1);
|
|
gtk_widget_show_all(flow);
|
|
free(name_wrapped);
|
|
}
|
|
|
|
void yon_flow_box_clear(GtkFlowBox *target){
|
|
GList *list = gtk_container_get_children(GTK_CONTAINER(target));
|
|
GList *iter;
|
|
for (iter=list;iter;iter=iter->next){
|
|
gtk_widget_destroy(GTK_WIDGET(iter->data));
|
|
}
|
|
}
|
|
|
|
void yon_configuration_hub_init(main_window *widgets){
|
|
yon_flow_box_clear(GTK_FLOW_BOX(widgets->HubPersonalListBox));
|
|
yon_flow_box_clear(GTK_FLOW_BOX(widgets->HubSystemListBox));
|
|
yon_flow_box_clear(GTK_FLOW_BOX(widgets->HubHardwareListBox));
|
|
yon_flow_box_clear(GTK_FLOW_BOX(widgets->HubPackagesListBox));
|
|
yon_configuration_hub_add(GTK_FLOW_BOX(widgets->HubPackagesListBox),KERNEL_LABEL,kernel_icon_path,YON_PAGE_KERNEL);
|
|
yon_configuration_hub_add(GTK_FLOW_BOX(widgets->HubPackagesListBox),KERNEL_ADDON_LABEL,kernel_icon_path,YON_PAGE_KERNEL_ADDON);
|
|
yon_configuration_hub_add(GTK_FLOW_BOX(widgets->HubPackagesListBox),SOFTWARE_LABEL,"com.ublinux.ubl-settings-update",YON_PAGE_SOFTWARE);
|
|
yon_configuration_hub_add(GTK_FLOW_BOX(widgets->HubPackagesListBox),PACMAN_SOFTWARE_LABEL,"com.ublinux.ubl-settings-repomanager",YON_PAGE_PACMAN_SOFTWARE);
|
|
yon_configuration_hub_add(GTK_FLOW_BOX(widgets->HubPackagesListBox),PACKAGES_SECTION_LABEL,"com.ublinux.ubl-settings-repomanager",YON_PAGE_PACKAGES);
|
|
// yon_configuration_hub_add(GTK_FLOW_BOX(widgets->HubPackagesListBox),KERNEL_ADDON_LABEL,icon_path,YON_PAGE_KERNEL_ADDON);
|
|
yon_configuration_hub_add(GTK_FLOW_BOX(widgets->HubPersonalListBox),REGION_ICON_LABEL,"com.ublinux.ubl-settings-system",YON_PAGE_REGION);
|
|
yon_configuration_hub_add(GTK_FLOW_BOX(widgets->HubPersonalListBox),LOCALE_LANGUAGE_LABEL,"com.ublinux.ubl-settings-system",YON_PAGE_LANGUAGE);
|
|
yon_configuration_hub_add(GTK_FLOW_BOX(widgets->HubPersonalListBox),KEYBOARD_TAB_LABEL,"com.ublinux.ubl-settings-keyboard",YON_PAGE_KEYBOARD);
|
|
yon_configuration_hub_add(GTK_FLOW_BOX(widgets->HubSystemListBox),USERS_TAB_LABEL,"com.ublinux.ubl-settings-usergroups",YON_PAGE_USERS);
|
|
yon_configuration_hub_add(GTK_FLOW_BOX(widgets->HubSystemListBox),STARTUP_LABEL,"com.ublinux.ubl-settings-info",YON_PAGE_STARTUP);
|
|
yon_configuration_hub_add(GTK_FLOW_BOX(widgets->HubSystemListBox),BOOTLOADER_LABEL,"com.ublinux.ubl-settings-bootloader",YON_PAGE_BOOTLOADER);
|
|
yon_configuration_hub_add(GTK_FLOW_BOX(widgets->HubSystemListBox),NETWORK_LABEL,"com.ublinux.ubl-settings-multiseat",YON_PAGE_NETWORK);
|
|
yon_configuration_hub_resize(widgets);
|
|
} |