#include "ubl-settings-manager.h" void on_gnome_activate(){ } void on_gnome_socket_add(){ } typedef struct { GtkWidget *expander; GtkWidget *AppsList; app_section *section; } gnome_section; gnome_section *yon_gnome_section_new(){ gnome_section *cur_section = malloc(sizeof(gnome_section)); memset(cur_section,0,sizeof(cur_section)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_gnome_section); cur_section->expander = yon_gtk_builder_get_widget(builder,"MainExpander"); cur_section->AppsList = yon_gtk_builder_get_widget(builder,"AppsList"); return cur_section; } void yon_gnome_section_setup_apps(gnome_section *cur_section, const char *target){ apps *cur_app = yon_apps_get((char*)target); GtkWidget *Image = gtk_image_new_from_icon_name(cur_app->Icon,GTK_ICON_SIZE_BUTTON); GtkWidget *Label = gtk_label_new(cur_app->Name); GtkWidget *Row = gtk_list_box_row_new(); GtkWidget *Box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); // g_signal_connect(G_OBJECT(theme->AppsTree),"row-activated",G_CALLBACK(on_gnome_activate),theme); g_object_set_data(G_OBJECT(Row),"gnome_section",cur_section); gtk_container_add(GTK_CONTAINER(Row),Box); gtk_box_pack_start(GTK_BOX(Box),Image,0,0,0); gtk_box_pack_start(GTK_BOX(Box),Label,0,0,0); gtk_label_set_xalign(GTK_LABEL(Label),0); gtk_list_box_insert(GTK_LIST_BOX(cur_section->AppsList),Row,-1); gtk_widget_show_all(Row); } void yon_gnome_section_setup(GtkBox *target,app_section *section){ gnome_section *cur_section = yon_gnome_section_new(); cur_section->section = section; gtk_expander_set_label(GTK_EXPANDER(cur_section->expander),section->name); int app_size; config_str app_list = yon_apps_get_by_categories(section->categories,section->categories_size,&app_size); for(int i=0;iexpander,0,0,0); } int yon_gnome_update(gnome_theme_struct *theme){ if (!main_config.sections) return 0; GList *list = gtk_container_get_children(GTK_CONTAINER(theme->AppsTree)); GList *iter; for (iter=list;iter;iter=iter->next){ gnome_section *cur_section = g_object_get_data(G_OBJECT(iter->data),"gnome_section"); gtk_widget_destroy(cur_section->expander); free(cur_section); } int size; dictionary *cur; for_dictionaries(cur,main_config.sections){ app_section *section_data = yon_dictionary_get_data(cur,app_section*); yon_gnome_section_setup(GTK_BOX(theme->AppsTree),section_data); } return 1; } gnome_theme_struct *yon_gnome_theme_new(){ gnome_theme_struct *theme = malloc(sizeof(gnome_theme_struct)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_gnome_theme); theme->MainBox = yon_gtk_builder_get_widget(builder,"MainBox"); theme->AppsTree = yon_gtk_builder_get_widget(builder,"AppsTree"); theme->SocketBox = yon_gtk_builder_get_widget(builder,"SocketBox"); theme->GnomePaned = yon_gtk_builder_get_widget(builder,"GnomePaned"); theme->GnomeInfoLogoImage = yon_gtk_builder_get_widget(builder,"GnomeInfoLogoImage"); theme->IconCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"IconCell")); theme->Socket = NULL; theme->get_command_func = NULL; theme->list_update_func = (int(*)(struct gnome_theme_struct*))yon_gnome_update; theme->set_sections_func = NULL; g_signal_connect(G_OBJECT(theme->SocketBox),"add",G_CALLBACK(on_gnome_socket_add),theme); // gtk_cell_renderer_set_fixed_size(theme->IconCell,main_config.apps_icon_size,main_config.apps_icon_size); return theme; }