diff --git a/source/libublsettings-gtk3.c b/source/libublsettings-gtk3.c index cdd8dfe..9c8ff61 100644 --- a/source/libublsettings-gtk3.c +++ b/source/libublsettings-gtk3.c @@ -290,22 +290,14 @@ void yon_terminal_integrated_start_shell(GtkWidget *terminal, char* command, voi int yon_window_config_load(char *path){ if(__yon_window_config_target_window){ - if (!access(path,0)){ + if (access(path,0)){ + yon_file_create_full_path(path,0644); + } __yon_window_config_file = g_key_file_new(); __yon_window_config_path=yon_char_new(path); - chmod(__yon_window_config_path,0777); if (!g_key_file_load_from_file(__yon_window_config_file,__yon_window_config_path,G_KEY_FILE_NONE,NULL)){ struct stat st; int size; - config_str conf = yon_char_parse(yon_char_new(__yon_window_config_path),&size,"/"); - char *path = yon_char_unite(conf[0],"/",conf[1],"/",conf[2],"/",conf[3],"/",conf[4],"/",NULL); - if (stat(path, &st) == -1) { - mkdir(path, 0777); - } - FILE *fp; - fp=fopen(__yon_window_config_path,"w"); - chmod(__yon_window_config_path,0777); - fclose(fp); g_key_file_load_from_file(__yon_window_config_file,__yon_window_config_path,G_KEY_FILE_NONE,NULL); } __yon_main_window_config.x = g_key_file_get_integer(__yon_window_config_file,"window","WindowPosX",NULL); @@ -344,9 +336,6 @@ void yon_terminal_integrated_start_shell(GtkWidget *terminal, char* command, voi pthread_create(&tid,NULL,(void *)_yon_maximize,NULL); return 1; } - } else { - // g_warning("config file were not loaded properly"); - } return 0; } @@ -695,6 +684,22 @@ int yon_gtk_list_store_find_text(GtkListStore *list, GtkTreeIter *iter, int seek } return 0; } +void yon_on_cell_renderer_toggle_toggled_for_list_store(GtkWidget *self, gchar *path,GtkWidget *tree){ + GtkTreePath *path_converted = gtk_tree_path_new_from_string(path); + GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree)); + GtkTreeIter iter; + gtk_tree_model_get_iter(model,&iter,path_converted); + int last = yon_char_find_last(path,':'); + char *col = path+last+1; + int status; + gtk_tree_model_get(model,&iter,atoi(col),&status,-1); + gtk_list_store_set(GTK_LIST_STORE(model),&iter,atoi(col),!status,-1); +} + +void yon_cell_renderer_toggle_set_toggle(GtkCellRendererToggle *target,GtkWidget *tree){ + g_return_if_fail(GTK_IS_CELL_RENDERER_TOGGLE(target)); + g_signal_connect(G_OBJECT(target),"toggled",G_CALLBACK(yon_on_cell_renderer_toggle_toggled_for_list_store),tree); +} void yon_gtk_toggle_button_set_inactive_from_toggle(GtkToggleButton *self, GtkToggleButton *target){ if (gtk_toggle_button_get_active(self)){ diff --git a/source/libublsettings-gtk3.h b/source/libublsettings-gtk3.h index e15ad98..7c1f9c9 100644 --- a/source/libublsettings-gtk3.h +++ b/source/libublsettings-gtk3.h @@ -252,6 +252,8 @@ int yon_dictionary_gtk_pack_end_multiple_widgets(GtkBox *destination, gboolean e int yon_gtk_list_store_find_text(GtkListStore *list, GtkTreeIter *iter, int seek_column, char *value); +void yon_cell_renderer_toggle_set_toggle(GtkCellRendererToggle *target,GtkWidget *tree); + void yon_gtk_toggle_button_set_inactive_from_toggle(GtkToggleButton *self, GtkToggleButton *target); void yon_gtk_toggle_button_set_inactive_from_entry(GtkEntry *self, GtkToggleButton *target);