Changed dialogs titles

pull/46/head
parent 5410ab25f6
commit 0b65d8b05c

@ -508,6 +508,62 @@ void on_package_install_accept(GtkWidget *, dictionary *dict){
on_subwindow_close(window->Window);
}
void on_module_remove_accept(GtkWidget *, dictionary *dict){
main_window *widgets = yon_dictionary_get_data(dict->first,main_window*);
kernels_tab *tab = yon_dictionary_get_data(dict->first->next,kernels_tab*);
dialog_window *window = yon_dictionary_get_data(dict->first->next->next,dialog_window*);
free(dict->first->next->next);
dict->first->next->next = NULL;
char *module_formated = yon_package_string_set(tab->module);
char *modules_to_install = module_formated;
if (gtk_widget_get_visible(window->DependencesFrame)){
GtkTreeIter iter;
for_iter (GTK_TREE_MODEL(window->liststore1),&iter){
int status;
char *package;
gtk_tree_model_get(GTK_TREE_MODEL(window->liststore1),&iter,0,&status,1,&package,-1);
if (status){
char *temp = yon_char_unite(modules_to_install," ", package, NULL);
if (strcmp(modules_to_install,module_formated)) free(modules_to_install);
modules_to_install = temp;
}
}
}
char *command = remove_command(modules_to_install);
yon_command_execute_async(command,widgets);
tab->module_installed=0;
on_subwindow_close(window->Window);
}
void on_package_remove_accept(GtkWidget *, dictionary *dict){
main_window *widgets = yon_dictionary_get_data(dict->first,main_window*);
kernels_tab *tab = yon_dictionary_get_data(dict->first->next,kernels_tab*);
dialog_window *window = yon_dictionary_get_data(dict->first->next->next,dialog_window*);
free(dict->first->next->next);
dict->first->next->next = NULL;
char *module_formated = yon_package_string_set(tab->package);
char *modules_to_install = module_formated;
if (gtk_widget_get_visible(window->DependencesFrame)){
GtkTreeIter iter;
for_iter (GTK_TREE_MODEL(window->liststore1),&iter){
int status;
char *package;
gtk_tree_model_get(GTK_TREE_MODEL(window->liststore1),&iter,0,&status,1,&package,-1);
if (status){
char *temp = yon_char_unite(modules_to_install," ", package, NULL);
if (strcmp(modules_to_install,module_formated)) free(modules_to_install);
modules_to_install = temp;
}
}
}
char *command = remove_command(modules_to_install);
yon_command_execute_async(command,widgets);
tab->package_installed=0;
on_subwindow_close(window->Window);
}
dialog_window *yon_dialog_window_new(){
GtkBuilder *builder = gtk_builder_new_from_resource(glade_dialog_path);
dialog_window *window = malloc(sizeof(dialog_window));
@ -517,6 +573,7 @@ dialog_window *yon_dialog_window_new(){
window->DependencesTree = yon_gtk_builder_get_widget(builder,"DependencesTree");
window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton");
window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton");
window->DependencesFrame = yon_gtk_builder_get_widget(builder,"DependencesFrame");
window->ChooseCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"ChooseCell"));
window->liststore1 = GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore1"));
g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL);
@ -528,48 +585,52 @@ void on_module_install_clicked(GtkWidget *self,dictionary *dict){
main_window *widgets = yon_dictionary_get_data(dict->first,main_window*);
kernels_tab *tab = yon_dictionary_get_data(dict->first->next,kernels_tab*);
char *action_text = NULL;
if (self == tab->update_module_button)
action_text = KERNEL_MODULE_UPDATE_CONFIRMATION_LABEL(tab->name);
else
action_text = KERNEL_MODULE_INSTALL_CONFIRMATION_LABEL(tab->name);
if (!gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->MainNotebook))){
dialog_window *window = yon_dialog_window_new();
yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),self==tab->update_package_button?UPDATE_MODULE_TITLE_LABEL:INSTALL_MODULE_TITLE_LABEL,icon_path,"dialog");
yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window);
g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_module_install_accept),dict);
if (self == tab->update_module_button){
if (!gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->MainNotebook))){
action_text = KERNEL_MODULE_UPDATE_CONFIRMATION_LABEL(tab->name);
gtk_label_set_text(GTK_LABEL(window->HeadLabel),UPDATE_MODULE_TITLE_LABEL);
} else {
action_text = ADDITION_MODULE_UPDATE_CONFIRMATION_LABEL(tab->name);
gtk_label_set_text(GTK_LABEL(window->HeadLabel),UPDATE_ADDITION_MODULE_TITLE_LABEL);
}
} else {
if (!gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->MainNotebook))){
action_text = KERNEL_MODULE_INSTALL_CONFIRMATION_LABEL(tab->name);
gtk_label_set_text(GTK_LABEL(window->HeadLabel),INSTALL_MODULE_TITLE_LABEL);
} else {
action_text = ADDITION_MODULE_INSTALL_CONFIRMATION_LABEL(tab->name);
gtk_label_set_text(GTK_LABEL(window->HeadLabel),INSTALL_ADDITION_MODULE_TITLE_LABEL);
}
}
gtk_label_set_text(GTK_LABEL(window->TopicLabel),action_text);
gtk_widget_show(window->Window);
yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window);
int size;
config_str additions = yon_resource_open_file(kernels_addon_path,&size);
GtkTreeIter iter;
for (int i=0;i<tab->module_requirements_size;i++){
gtk_list_store_append(window->liststore1,&iter);
for (int j=1;j<size;j++){
int cur_size;
config_str parsed = yon_char_parse(additions[j],&cur_size,";");
if (!strcmp(parsed[1],tab->module_requirements[i]))
gtk_list_store_set(window->liststore1,&iter,2,parsed[3],-1);
yon_char_parsed_free(parsed,cur_size);
}
gtk_list_store_set(window->liststore1,&iter,0,1,1,tab->module_requirements[i],-1);
}
yon_char_parsed_free(additions,size);
if (gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->MainNotebook))){
gtk_widget_hide(window->DependencesFrame);
gtk_box_set_child_packing(GTK_BOX(gtk_widget_get_parent(window->DependencesFrame)),gtk_widget_get_parent(gtk_widget_get_parent(window->TopicLabel)),1,1,0,GTK_PACK_START);
} else {
dialog_confirmation_data *data = malloc(sizeof(dialog_confirmation_data));
if (self == tab->update_module_button)
data->action_text = ADDITION_MODULE_UPDATE_CONFIRMATION_LABEL(tab->name);
else
data->action_text = ADDITION_MODULE_INSTALL_CONFIRMATION_LABEL(tab->name);
data->function = NULL;
data->data = NULL;
if (yon_confirmation_dialog_call(self,data) == GTK_RESPONSE_ACCEPT){
char *target = yon_package_string_set(tab->module);
char *command = install_command(target);
yon_command_execute_async(command,widgets);
tab->module_installed=1;
int size;
config_str additions = yon_resource_open_file(kernels_addon_path,&size);
GtkTreeIter iter;
for (int i=0;i<tab->module_requirements_size;i++){
gtk_list_store_append(window->liststore1,&iter);
for (int j=1;j<size;j++){
int cur_size;
config_str parsed = yon_char_parse(additions[j],&cur_size,";");
if (!strcmp(parsed[1],tab->module_requirements[i]))
gtk_list_store_set(window->liststore1,&iter,2,parsed[3],-1);
yon_char_parsed_free(parsed,cur_size);
}
gtk_list_store_set(window->liststore1,&iter,0,1,1,tab->module_requirements[i],-1);
}
yon_char_parsed_free(additions,size);
}
}
@ -577,18 +638,36 @@ void on_package_install_clicked(GtkWidget *self,dictionary *dict){
main_window *widgets = yon_dictionary_get_data(dict->first,main_window*);
kernels_tab *tab = yon_dictionary_get_data(dict->first->next,kernels_tab*);
char *action_text = NULL;
if (self == tab->update_module_button)
action_text = KERNEL_PACKAGE_UPDATE_CONFIRMATION_LABEL(tab->name);
else
action_text = KERNEL_PACKAGE_INSTALL_CONFIRMATION_LABEL(tab->name);
if (!gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->MainNotebook))){
dialog_window *window = yon_dialog_window_new();
yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),self==tab->update_package_button?UPDATE_PACKAGE_TITLE_LABEL:INSTALL_PACKAGE_TITLE_LABEL,icon_path,"dialog");
g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_package_install_accept),dict);
if (self == tab->update_module_button){
if (!gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->MainNotebook))){
action_text = KERNEL_PACKAGE_UPDATE_CONFIRMATION_LABEL(tab->name);
gtk_label_set_text(GTK_LABEL(window->HeadLabel),UPDATE_PACKAGE_TITLE_LABEL);
} else {
action_text = ADDITION_PACKAGE_UPDATE_CONFIRMATION_LABEL(tab->name);
gtk_label_set_text(GTK_LABEL(window->HeadLabel),UPDATE_ADDITION_PACKAGE_TITLE_LABEL);
}
}else{
if (!gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->MainNotebook))){
action_text = KERNEL_PACKAGE_INSTALL_CONFIRMATION_LABEL(tab->name);
gtk_label_set_text(GTK_LABEL(window->HeadLabel),INSTALL_PACKAGE_TITLE_LABEL);
} else {
action_text = ADDITION_PACKAGE_INSTALL_CONFIRMATION_LABEL(tab->name);
gtk_label_set_text(GTK_LABEL(window->HeadLabel),INSTALL_ADDITION_PACKAGE_TITLE_LABEL);
}
}
gtk_label_set_text(GTK_LABEL(window->TopicLabel),action_text);
gtk_widget_show(window->Window);
yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window);
if (gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->MainNotebook))){
gtk_widget_hide(window->DependencesFrame);
gtk_box_set_child_packing(GTK_BOX(gtk_widget_get_parent(window->DependencesFrame)),gtk_widget_get_parent(gtk_widget_get_parent(window->TopicLabel)),1,1,0,GTK_PACK_START);
} else {
int size;
config_str additions = yon_resource_open_file(kernels_addon_path,&size);
GtkTreeIter iter;
@ -604,21 +683,7 @@ void on_package_install_clicked(GtkWidget *self,dictionary *dict){
gtk_list_store_set(window->liststore1,&iter,0,1,1,tab->package_requirements[i],-1);
}
yon_char_parsed_free(additions,size);
} else {
dialog_confirmation_data *data = malloc(sizeof(dialog_confirmation_data));
if (self == tab->update_package_button)
data->action_text = ADDITION_PACKAGE_UPDATE_CONFIRMATION_LABEL(tab->name);
else
data->action_text = ADDITION_PACKAGE_INSTALL_CONFIRMATION_LABEL(tab->name);
data->function = NULL;
data->data = NULL;
if (yon_confirmation_dialog_call(self,data) == GTK_RESPONSE_ACCEPT){
char *target = yon_package_string_set(tab->package);
char *command = install_command(target);
yon_command_execute_async(command,widgets);
tab->package_installed=1;
}
}
}
@ -654,23 +719,46 @@ void on_module_remove_clicked(GtkWidget *self,dictionary *dict){
} break;
}
}
dialog_confirmation_data *data = malloc(sizeof(dialog_confirmation_data));
char *action_text = NULL;
dialog_window *window = yon_dialog_window_new();
yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),self==tab->update_package_button?UPDATE_MODULE_TITLE_LABEL:INSTALL_MODULE_TITLE_LABEL,icon_path,"dialog");
yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window);
g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_module_remove_accept),dict);
gtk_widget_show(window->Window);
yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window);
if (gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->MainNotebook))){
action_text = KERNEL_MODULE_REMOVE_CONFIRMATION_LABEL(tab->name);
gtk_widget_hide(window->DependencesFrame);
gtk_box_set_child_packing(GTK_BOX(gtk_widget_get_parent(window->DependencesFrame)),gtk_widget_get_parent(gtk_widget_get_parent(window->TopicLabel)),1,1,0,GTK_PACK_START);
gtk_label_set_text(GTK_LABEL(window->HeadLabel),INSTALL_ADDITION_MODULE_TITLE_LABEL);
} else {
gtk_label_set_text(GTK_LABEL(window->HeadLabel),REMOVE_MODULE_TITLE_LABEL);
action_text = ADDITION_MODULE_REMOVE_CONFIRMATION_LABEL(tab->name);
if (installed_kernels>1){
data->action_text = KERNEL_MODULE_REMOVE_CONFIRMATION_LABEL(tab->name);
action_text = KERNEL_MODULE_REMOVE_CONFIRMATION_LABEL(tab->name);
} else if (installed_kernels==1){
data->action_text = KERNEL_REMOVE_LAST_CONFIRMATION_LABEL(tab->name);
action_text = KERNEL_REMOVE_LAST_CONFIRMATION_LABEL(tab->name);
}
data->function = NULL;
data->data = NULL;
if (yon_confirmation_dialog_call(self,data) == GTK_RESPONSE_ACCEPT){
char *target = yon_package_string_set(tab->module);
char *command = remove_command(target);
char *command_unload = unload_command(target);
if (system(yon_debug_output("%s\n",command_unload))){};
g_signal_connect(G_OBJECT(widgets->InstallTerminal),"child-exited",G_CALLBACK(on_module_remove_done),tab);
yon_command_execute_async(command,widgets);
tab->module_installed=0;
int size;
config_str additions = yon_resource_open_file(kernels_addon_path,&size);
GtkTreeIter iter;
for (int i=0;i<tab->module_requirements_size;i++){
if (system(get_package_is_installed_command(tab->module))){
gtk_list_store_append(window->liststore1,&iter);
for (int j=1;j<size;j++){
int cur_size;
config_str parsed = yon_char_parse(additions[j],&cur_size,";");
if (!strcmp(parsed[1],tab->module_requirements[i]))
gtk_list_store_set(window->liststore1,&iter,2,parsed[3],-1);
yon_char_parsed_free(parsed,cur_size);
}
gtk_list_store_set(window->liststore1,&iter,0,1,1,tab->module_requirements[i],-1);
}
}
yon_char_parsed_free(additions,size);
}
gtk_label_set_text(GTK_LABEL(window->TopicLabel),action_text);
}
@ -698,21 +786,47 @@ void on_package_remove_clicked(GtkWidget *self,dictionary *dict){
} break;
}
}
dialog_confirmation_data *data = malloc(sizeof(dialog_confirmation_data));
dialog_window *window = yon_dialog_window_new();
yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),self==tab->update_package_button?UPDATE_MODULE_TITLE_LABEL:INSTALL_MODULE_TITLE_LABEL,icon_path,"dialog");
yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window);
g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_package_remove_accept),dict);
char *action_text = "";
gtk_widget_show(window->Window);
yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window);
if (gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->MainNotebook))){
action_text = KERNEL_PACKAGE_REMOVE_CONFIRMATION_LABEL(tab->name);
gtk_label_set_text(GTK_LABEL(window->HeadLabel),REMOVE_ADDITION_PACKAGE_TITLE_LABEL);
gtk_widget_hide(window->DependencesFrame);
gtk_box_set_child_packing(GTK_BOX(gtk_widget_get_parent(window->DependencesFrame)),gtk_widget_get_parent(gtk_widget_get_parent(window->TopicLabel)),1,1,0,GTK_PACK_START);
} else {
if (installed_kernels>1){
data->action_text = KERNEL_PACKAGE_REMOVE_CONFIRMATION_LABEL(tab->name);
action_text = ADDITION_PACKAGE_REMOVE_CONFIRMATION_LABEL(tab->name);
} else if (installed_kernels==1){
data->action_text = KERNEL_REMOVE_LAST_CONFIRMATION_LABEL(tab->name);
action_text = KERNEL_REMOVE_LAST_CONFIRMATION_LABEL(tab->name);
}
data->function = NULL;
data->data = NULL;
int resp = yon_confirmation_dialog_call(self,data);
if (resp == GTK_RESPONSE_ACCEPT){
char *target = yon_package_string_set(tab->package);
char *command = remove_command(target);
yon_command_execute_async(command,widgets);
tab->package_installed=0;
gtk_label_set_text(GTK_LABEL(window->HeadLabel),REMOVE_PACKAGE_TITLE_LABEL);
int size;
config_str additions = yon_resource_open_file(kernels_addon_path,&size);
GtkTreeIter iter;
for (int i=0;i<tab->module_requirements_size;i++){
if (system(get_package_is_installed_command(tab->package))){
gtk_list_store_append(window->liststore1,&iter);
for (int j=1;j<size;j++){
int cur_size;
config_str parsed = yon_char_parse(additions[j],&cur_size,";");
if (!strcmp(parsed[1],tab->module_requirements[i]))
gtk_list_store_set(window->liststore1,&iter,2,parsed[3],-1);
yon_char_parsed_free(parsed,cur_size);
}
gtk_list_store_set(window->liststore1,&iter,0,1,1,tab->module_requirements[i],-1);
}
}
yon_char_parsed_free(additions,size);
}
gtk_label_set_text(GTK_LABEL(window->TopicLabel),action_text);
}

@ -210,6 +210,7 @@ typedef struct {
GtkWidget *DependencesTree;
GtkWidget *CancelButton;
GtkWidget *AcceptButton;
GtkWidget *DependencesFrame;
GtkCellRenderer *ChooseCell;
GtkListStore *liststore1;
@ -246,6 +247,8 @@ dialog_window *yon_dialog_window_new();
void on_module_install_accept(GtkWidget *, dictionary *dict);
void on_package_install_accept(GtkWidget *, dictionary *dict);
void on_module_remove_accept(GtkWidget *, dictionary *dict);
void on_package_remove_accept(GtkWidget *, dictionary *dict);
void on_module_remove_done(GtkWidget *self, int state, kernels_tab *tab);
void on_module_install_clicked(GtkWidget *,dictionary *dict);

@ -77,4 +77,16 @@
#define LAUNCH_CONFIRMATION_LABEL(target) yon_char_unite(_("Are you sure want to launch")," ",target," ",_("for boot?\n\nChanges will be applied after system restart"),NULL)
#define UPDATE_MODULE_LABEL _("Update module")
#define UPDATE_PACKAGE_LABEL _("Update package")
#define UPDATE_PACKAGE_LABEL _("Update package")
#define INSTALL_MODULE_TITLE_LABEL _("Install kernel module")
#define INSTALL_PACKAGE_TITLE_LABEL _("Install kernel package")
#define REMOVE_MODULE_TITLE_LABEL _("Remove kernel module")
#define REMOVE_PACKAGE_TITLE_LABEL _("Remove kernel package")
#define UPDATE_MODULE_TITLE_LABEL _("Update kernel module")
#define UPDATE_PACKAGE_TITLE_LABEL _("Update kernel package")
#define INSTALL_ADDITION_MODULE_TITLE_LABEL _("Install addition module")
#define INSTALL_ADDITION_PACKAGE_TITLE_LABEL _("Install addition package")
#define REMOVE_ADDITION_MODULE_TITLE_LABEL _("Remove addition module")
#define REMOVE_ADDITION_PACKAGE_TITLE_LABEL _("Remove addition package")
#define UPDATE_ADDITION_MODULE_TITLE_LABEL _("Update addition module")
#define UPDATE_ADDITION_PACKAGE_TITLE_LABEL _("Update addition package")

@ -15,7 +15,6 @@
</object>
<object class="GtkApplicationWindow" id="MainWindow">
<property name="width-request">400</property>
<property name="height-request">200</property>
<property name="can-focus">False</property>
<property name="modal">True</property>
<property name="icon-name">com.ublinux.ubl-settings-repomanager</property>
@ -57,6 +56,7 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">label</property>
<property name="wrap">True</property>
<property name="xalign">0</property>
</object>
<packing>
@ -67,7 +67,7 @@
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
@ -80,7 +80,7 @@
</packing>
</child>
<child>
<object class="GtkFrame">
<object class="GtkFrame" id="DependencesFrame">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label-xalign">0.019999999552965164</property>
@ -166,7 +166,6 @@
<object class="GtkHeaderBar" id="SettingsBar2">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="show-close-button">True</property>
<child type="title">
<object class="GtkLabel" id="HeadLabel">
<property name="visible">True</property>

Loading…
Cancel
Save