#include "libublsettings-gtk3.h" #ifdef __GTK_H__ static render_data render; #ifdef VTE_INCLUDE static void child_ready(VteTerminal *terminal, GPid pid, GError *error, gpointer user_data) { if (!terminal) return; if (pid == -1) printf("Error\n\n\n"); else vte_terminal_feed_child(VTE_TERMINAL(terminal),(char*)user_data,strlen((char*)user_data)); } void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, void *endwork_function, void* endwork_function_argument){ char **commands=new_arr(char*,2); gchar **envp = g_get_environ(); commands[0]=(gchar *)g_strdup(g_environ_getenv(envp, "SHELL")); commands[1]=NULL; char **env=new_arr(char*,2); env[0]=""; env[1]=NULL; GtkWidget *terminal = vte_terminal_new(); vte_terminal_set_size(VTE_TERMINAL(terminal),10,15); VtePty *pty = vte_pty_new_sync(VTE_PTY_DEFAULT,NULL,NULL); vte_terminal_set_pty(VTE_TERMINAL(terminal),pty); gtk_container_add(GTK_CONTAINER(place_to_show),terminal); char *install_command=yon_char_unite("clear;tput cup 0 0 && tput ed; ",command," ; sleep 5;exit 0","\n",NULL); if(endwork_function) g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(endwork_function), endwork_function_argument); vte_terminal_spawn_async(VTE_TERMINAL(terminal), VTE_PTY_DEFAULT, NULL, commands, NULL, 0, NULL, NULL, NULL, -1, NULL, child_ready, install_command); vte_pty_spawn_async(pty, NULL, commands, NULL, 0, NULL, NULL, NULL, -1, NULL, NULL, NULL); vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), -1); vte_terminal_set_scroll_on_output(VTE_TERMINAL(terminal), TRUE); vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(terminal), TRUE); gtk_widget_show_all(terminal); } void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument){ char **commands=new_arr(char*,2); gchar **envp = g_get_environ(); commands[0]=(gchar *)g_strdup(g_environ_getenv(envp, "SHELL")); commands[1]=NULL; char **env=new_arr(char*,2); env[0]=""; env[1]=NULL; vte_terminal_set_size(VTE_TERMINAL(terminal),10,15); VtePty *pty = vte_pty_new_sync(VTE_PTY_DEFAULT,NULL,NULL); vte_terminal_set_pty(VTE_TERMINAL(terminal),pty); char *install_command=yon_char_unite("clear;tput cup 0 0 && tput ed; ",command," ; sleep 5; stty -echo; unset PS1","\n",NULL); if(endwork_function) g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(endwork_function), endwork_function_argument); vte_terminal_spawn_async(VTE_TERMINAL(terminal), VTE_PTY_DEFAULT, NULL, commands, NULL, 0, NULL, NULL, NULL, -1, NULL, child_ready, install_command); vte_pty_spawn_async(pty, NULL, commands, NULL, 0, NULL, NULL, NULL, -1, NULL, NULL, NULL); vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), -1); vte_terminal_set_scroll_on_output(VTE_TERMINAL(terminal), TRUE); vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(terminal), TRUE); gtk_widget_show_all(terminal); } #endif // Window config functions #define check_window_config_setup if(__yon_window_config_target_window) typedef struct { char *parameter_name; enum YON_TYPE containing_type; GtkWidget *track_widget; char *property_name; } __yon_listener_parameter; typedef struct { char *parameter_name; char *section; enum YON_TYPE containing_type; void *property; } __yon_custom_parameter; struct { int x; int y; int width; int height; int fullscreen; dictionary *custom_listeners; dictionary *custom_parameters; dictionary *deleted_parameters; } __yon_main_window_config; static GtkWindow *__yon_window_config_target_window = NULL; static GKeyFile *__yon_window_config_file = NULL; static char *__yon_window_config_path = NULL; void yon_window_config_save(){ g_key_file_set_integer(__yon_window_config_file,"window","WindowPosX",__yon_main_window_config.x); g_key_file_set_integer(__yon_window_config_file,"window","WindowPosY",__yon_main_window_config.y); g_key_file_set_integer(__yon_window_config_file,"window","WindowWidth",__yon_main_window_config.width); g_key_file_set_integer(__yon_window_config_file,"window","WindowHeight",__yon_main_window_config.height); g_key_file_set_integer(__yon_window_config_file,"window","fullscreen",__yon_main_window_config.fullscreen); dictionary *dict=NULL; if (__yon_main_window_config.deleted_parameters) for_dictionaries(dict,__yon_main_window_config.deleted_parameters){ __yon_custom_parameter *param = yon_dictionary_get_data(dict,__yon_custom_parameter*); g_key_file_remove_key(__yon_window_config_file,param->section,param->parameter_name,NULL); } if (__yon_main_window_config.custom_listeners) for_dictionaries(dict,__yon_main_window_config.custom_listeners){ __yon_listener_parameter *param = yon_dictionary_get_data(dict,__yon_listener_parameter*); GValue *val = g_malloc0(sizeof(GValue)); g_object_get_property(G_OBJECT(param->track_widget),param->property_name,val); switch(param->containing_type){ case YON_TYPE_STRING: g_key_file_set_string(__yon_window_config_file,"window",param->parameter_name, g_value_get_string(val)); break; case YON_TYPE_INT: g_key_file_set_integer(__yon_window_config_file,"window",param->parameter_name, g_value_get_int(val)); break; case YON_TYPE_BOOLEAN: g_key_file_set_boolean(__yon_window_config_file,"window",param->parameter_name, g_value_get_boolean(val)); break; case YON_TYPE_OTHER:printf("\033[0;31mCannot save %s property with %s key\033[0m\n",param->property_name,param->parameter_name);break; } } if (__yon_main_window_config.custom_parameters) for_dictionaries(dict,__yon_main_window_config.custom_parameters){ __yon_custom_parameter *param = yon_dictionary_get_data(dict,__yon_custom_parameter*); switch (param->containing_type){ case YON_TYPE_STRING: g_key_file_set_string(__yon_window_config_file,param->section,param->parameter_name, (char*)param->property); break; case YON_TYPE_INT: g_key_file_set_integer(__yon_window_config_file,param->section,param->parameter_name, *(int*)param->property); break; case YON_TYPE_BOOLEAN: g_key_file_set_boolean(__yon_window_config_file,param->section,param->parameter_name, *(gboolean*)param->property); break; default: break; } } g_key_file_save_to_file(__yon_window_config_file,__yon_window_config_path,NULL); } void yon_get_is_fullscreen(){ gtk_window_is_maximized(__yon_window_config_target_window); __yon_main_window_config.fullscreen = gtk_window_is_maximized(__yon_window_config_target_window); if (!__yon_main_window_config.fullscreen) gtk_window_get_position(__yon_window_config_target_window,&__yon_main_window_config.x,&__yon_main_window_config.y); } /**yon_on_configured_window_destroy(GtkWidget* self,GdkEvent* event) * [EN] * * [RU] * Сохраняет настройки основного окна. Вызывается когда основное окно уничтожается. */ void yon_on_configured_window_destroy(GtkWidget* self,GdkEvent* event){ check_window_config_setup{ yon_get_is_fullscreen(); yon_window_config_save(); } gtk_main_quit(); } void __yon_window_config_on_resize(){ int max=0; max=gtk_window_is_maximized(__yon_window_config_target_window); if(max==0){ gtk_window_get_size(__yon_window_config_target_window,&__yon_main_window_config.width,&__yon_main_window_config.height); gtk_window_get_position(__yon_window_config_target_window,&__yon_main_window_config.x,&__yon_main_window_config.y); } } void yon_window_config_setup(GtkWindow *window){ __yon_window_config_target_window = window; g_signal_connect(G_OBJECT(window),"delete-event",G_CALLBACK(yon_on_configured_window_destroy),NULL); g_signal_connect(G_OBJECT(window),"check-resize"/*"configure-event"*/,G_CALLBACK(__yon_window_config_on_resize),NULL); } void _yon_maximize(void *data){ g_usleep(G_USEC_PER_SEC/10); if(__yon_main_window_config.fullscreen ==1) gtk_window_maximize(__yon_window_config_target_window); } int yon_window_config_load(char *path){ __yon_window_config_file = g_key_file_new(); __yon_window_config_path=yon_char_new(path); 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); __yon_main_window_config.y = g_key_file_get_integer(__yon_window_config_file,"window","WindowPosY",NULL); __yon_main_window_config.width = g_key_file_get_integer(__yon_window_config_file,"window","WindowWidth",NULL); __yon_main_window_config.height = g_key_file_get_integer(__yon_window_config_file,"window","WindowHeight",NULL); __yon_main_window_config.fullscreen = g_key_file_get_integer(__yon_window_config_file,"window","fullscreen",NULL); dictionary *dict=NULL; if (__yon_main_window_config.custom_listeners) for_dictionaries(dict,__yon_main_window_config.custom_listeners){ __yon_listener_parameter *param = yon_dictionary_get_data(dict,__yon_listener_parameter*); GValue *val = g_malloc0(sizeof(GValue)); g_object_get_property(G_OBJECT(param->track_widget),param->property_name,val); switch(param->containing_type){ case YON_TYPE_STRING: g_value_set_string(val,g_key_file_get_string(__yon_window_config_file,"window",param->parameter_name, NULL)); break; case YON_TYPE_INT: g_value_set_int(val,g_key_file_get_integer(__yon_window_config_file,"window",param->parameter_name, NULL)); break; case YON_TYPE_BOOLEAN: gboolean res = g_key_file_get_boolean(__yon_window_config_file,"window",param->parameter_name, NULL); g_value_set_boolean(val,res); break; default:printf("\033[0;31mCannot load %s property with %s key\033[0m\n",param->property_name,param->parameter_name);break; } g_object_set_property(G_OBJECT(param->track_widget),param->property_name,val); } if (__yon_main_window_config.width==0) __yon_main_window_config.width=800; if (__yon_main_window_config.height==0) __yon_main_window_config.height=600; gtk_window_resize(__yon_window_config_target_window,__yon_main_window_config.width,__yon_main_window_config.height); gtk_window_move(__yon_window_config_target_window,__yon_main_window_config.x,__yon_main_window_config.y); pthread_t tid; pthread_create(&tid,NULL,(void *)_yon_maximize,NULL); return 1; } void yon_window_config_apply(){ dictionary *dict=NULL; gtk_window_move(__yon_window_config_target_window,__yon_main_window_config.x,__yon_main_window_config.y); gtk_window_resize(__yon_window_config_target_window,__yon_main_window_config.width,__yon_main_window_config.height); } config_str yon_window_config_get_section(char *section, gsize *size){ config_str key = g_key_file_get_keys(__yon_window_config_file,section,size,NULL); return key; } void yon_window_config_add_listener(GtkWidget *widget, char *param_name, char *widget_property, enum YON_TYPE val_type){ __yon_listener_parameter *param = NULL; param = yon_remalloc(param,sizeof(__yon_listener_parameter)); param->parameter_name = yon_char_new(param_name); param->track_widget = widget; param->property_name = yon_char_new(widget_property); param->containing_type = val_type; yon_dictionary_add_or_create_if_exists_with_data(__yon_main_window_config.custom_listeners,param->parameter_name,param); } void yon_window_config_add_custom_parameter(char *param_name, char *section, void *tracked_value, enum YON_TYPE val_type){ __yon_custom_parameter *param = NULL; param = yon_remalloc(param,sizeof(__yon_custom_parameter)); param->parameter_name = yon_char_new(param_name); param->section=section; param->property = tracked_value; param->containing_type = val_type; yon_dictionary_add_or_create_if_exists_with_data(__yon_main_window_config.custom_parameters,param->parameter_name,param); dictionary *dict=NULL; if (__yon_main_window_config.deleted_parameters) for_dictionaries(dict,__yon_main_window_config.deleted_parameters){ if (strcmp(dict->key,param->parameter_name)) yon_dictionary_rip(dict); } } void yon_window_config_add_instant_parameter(char *param_name, char *section, void *tracked_value, enum YON_TYPE val_type){ switch (val_type){ case YON_TYPE_BOOLEAN: g_key_file_set_boolean(__yon_window_config_file,section,param_name,*((gboolean*)tracked_value)); break; case YON_TYPE_INT: g_key_file_set_integer(__yon_window_config_file,section,param_name,*((int*)tracked_value)); break; case YON_TYPE_STRING: g_key_file_set_string(__yon_window_config_file,section,param_name,(char*)tracked_value); break; } } void yon_window_config_erase_custom_parameter(char *param_name, char *section){ __yon_custom_parameter *param = NULL; param = yon_remalloc(param,sizeof(__yon_custom_parameter)); param->parameter_name=param_name; param->section=section; yon_dictionary_add_or_create_if_exists_with_data(__yon_main_window_config.deleted_parameters,param->parameter_name,param); } int yon_window_config_get_parameter(char *section, char *config_parameter, void *return_value, enum YON_TYPE type){ GError *err=NULL; switch (type){ case YON_TYPE_BOOLEAN: *((int*)return_value) = g_key_file_get_boolean(__yon_window_config_file,section,config_parameter,&err); if (err) return 0; else return 1; break; case YON_TYPE_INT: *((int*)return_value) = g_key_file_get_integer(__yon_window_config_file,section,config_parameter,&err); if (err) return 0; else return 1; break; case YON_TYPE_STRING: *((char**)return_value) = g_key_file_get_string(__yon_window_config_file,section,config_parameter,&err); if (err) return 0; else return 1; break; case YON_TYPE_STRING_LIST: gsize size=0; *((char***)return_value) = g_key_file_get_string_list(__yon_window_config_file,section,config_parameter,&size,&err); *((char***)return_value)=yon_remalloc(return_value,size+1); *((char***)return_value)[size]=NULL; if (err) return 0; else return 1; break; } } void yon_on_window_config_custom_window_destroy(GtkWindow *window, GdkEvent* event, char *window_name){ if (!gtk_window_is_maximized(window)){ int height=0; int width=0; int X=0; int Y=0; gtk_window_get_position(window,&X,&Y); yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosX"),"window",&X,YON_TYPE_INT); yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosY"),"window",&Y,YON_TYPE_INT); } } void yon_on_window_config_custom_window_resize(GtkWindow *window, char *window_name){ if (!gtk_window_is_maximized(window)){ int height=0; int width=0; int X=0; int Y=0; gtk_window_get_size(window,&width,&height); gtk_window_get_position(window,&X,&Y); yon_window_config_add_instant_parameter(yon_char_append(window_name,"Width"),"window",&width,YON_TYPE_INT); yon_window_config_add_instant_parameter(yon_char_append(window_name,"Height"),"window",&height,YON_TYPE_INT); yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosX"),"window",&X,YON_TYPE_INT); yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosY"),"window",&Y,YON_TYPE_INT); } } void yon_window_config_custom_window_setup(GtkWindow *window, char *window_name){ int height=0; int width=0; int X=0; int Y=0; yon_window_config_get_parameter("window",yon_char_append(window_name,"Width"),&width,YON_TYPE_INT); yon_window_config_get_parameter("window",yon_char_append(window_name,"Height"),&height,YON_TYPE_INT); yon_window_config_get_parameter("window",yon_char_append(window_name,"PosX"),&X,YON_TYPE_INT); yon_window_config_get_parameter("window",yon_char_append(window_name,"PosY"),&Y,YON_TYPE_INT); if (width&&height) gtk_window_resize(window,width,height); if (X&&Y) gtk_window_move(window,X,Y); char *signals_window_name = yon_char_new(window_name); g_signal_connect(G_OBJECT(window),"check-resize",G_CALLBACK(yon_on_window_config_custom_window_resize),signals_window_name); g_signal_connect(G_OBJECT(window),"delete-event",G_CALLBACK(yon_on_window_config_custom_window_destroy),signals_window_name); } void yon_window_config_custom_window_get(GtkWindow *window, char *window_name){ int height=0; int width=0; int X=0; int Y=0; yon_window_config_get_parameter("window",yon_char_append(window_name,"Width"),&width,YON_TYPE_INT); yon_window_config_get_parameter("window",yon_char_append(window_name,"Height"),&height,YON_TYPE_INT); yon_window_config_get_parameter("window",yon_char_append(window_name,"PosX"),&X,YON_TYPE_INT); yon_window_config_get_parameter("window",yon_char_append(window_name,"PosY"),&Y,YON_TYPE_INT); if (width&&height) gtk_window_resize(window,width,height); if (X&&Y) gtk_window_move(window,X,Y); } void yon_window_config_custom_window_set(GtkWindow *window, char *window_name){ int height=0; int width=0; int X=0; int Y=0; gtk_window_get_size(window,&width,&height); gtk_window_get_position(window,&X,&Y); yon_window_config_add_instant_parameter(yon_char_append(window_name,"Width"),"window",&width,YON_TYPE_INT); yon_window_config_add_instant_parameter(yon_char_append(window_name,"Height"),"window",&height,YON_TYPE_INT); yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosX"),"window",&X,YON_TYPE_INT); yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosY"),"window",&Y,YON_TYPE_INT); } GtkWidget *yon_ubl_menu_item_about_new(char *buttonname){ GtkWidget *menu_item = gtk_menu_item_new(); gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitembottom"); GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); GtkWidget *label = gtk_label_new(buttonname); GtkWidget *image = gtk_image_new_from_icon_name("dialog-information-symbolic",GTK_ICON_SIZE_BUTTON); gtk_label_set_xalign(GTK_LABEL(label),0.0); gtk_box_pack_start(GTK_BOX(box),image,0,0,5); gtk_box_pack_start(GTK_BOX(box),label,0,0,5); gtk_container_add(GTK_CONTAINER(menu_item),box); gtk_widget_show_all(menu_item); return menu_item; } GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname){ GtkWidget *menu_item = gtk_menu_item_new(); gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitemmiddle"); GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); GtkWidget *label = gtk_label_new(buttonname); GtkWidget *image = gtk_image_new_from_icon_name("dialog-question-symbolic",GTK_ICON_SIZE_BUTTON); gtk_label_set_xalign(GTK_LABEL(label),0.0); gtk_box_pack_start(GTK_BOX(box),image,0,0,5); gtk_box_pack_start(GTK_BOX(box),label,0,0,5); gtk_container_add(GTK_CONTAINER(menu_item),box); gtk_widget_show_all(menu_item); return menu_item; } // other Gtk functions int yon_gtk_combo_box_fill(GtkWidget *combo, config_str parameters,int size){ if (combo&¶meters){ for (int i=0;i0 ? 1 : 0); } void yon_gtk_widget_set_sensitive_from_combo_box_inversed(GtkComboBox *toggle, GtkWidget *target){ gtk_widget_set_sensitive(target,!gtk_combo_box_get_active(toggle)>0 ? 0 : 1); } void yon_gtk_toggle_button_set_inactive_from_toggle_button_inversed(GtkToggleButton *self, GtkToggleButton *target){ if (gtk_toggle_button_get_active(self)){ gtk_toggle_button_set_active(target,0); } } void yon_gtk_toggle_button_set_inactive_from_toggle_button(GtkToggleButton *self, GtkToggleButton *target){ if (!gtk_toggle_button_get_active(self)){ gtk_toggle_button_set_active(target,0); } } void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path) { gtk_overlay_add_overlay(GTK_OVERLAY(Overlay), Head); gtk_image_set_from_file(GTK_IMAGE(Image), image_path); } void _yon_ubl_header_setup_resource(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path) { gtk_overlay_add_overlay(GTK_OVERLAY(Overlay), Head); gtk_image_set_from_resource(GTK_IMAGE(Image), image_path); } int yon_ubl_status_box_setup(GtkWidget *icon, GtkWidget *box, GtkWidget *label) { if(icon&&box&&label){ render.icon=icon; render.box=box; render.label=label; return 1; } else return 0; } void yon_ubl_status_box_set(BACKGROUND_IMAGE_TYPE type, GtkWidget *box, GtkImage *icon){ GtkIconTheme *ictheme = gtk_icon_theme_get_default(); switch (type){ case BACKGROUND_IMAGE_SUCCESS_TYPE: { gtk_style_context_remove_class(gtk_widget_get_style_context(box), "boxInfoMessError"); gtk_style_context_add_class(gtk_widget_get_style_context(box), "boxInfoMessOK"); gtk_image_set_from_pixbuf(GTK_IMAGE(icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.libublsettingsui-gtk3.checked", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, NULL)); } break; case BACKGROUND_IMAGE_FAIL_TYPE: { gtk_style_context_remove_class(gtk_widget_get_style_context(box), "boxInfoMessOK"); gtk_style_context_add_class(gtk_widget_get_style_context(box), "boxInfoMessError"); gtk_image_set_from_pixbuf(GTK_IMAGE(icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.libublsettingsui-gtk3.warning", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, NULL)); } break; case BACKGROUND_IMAGE_INFO_TYPE: { gtk_style_context_remove_class(gtk_widget_get_style_context(box), "boxInfoMessError"); gtk_style_context_add_class(gtk_widget_get_style_context(box), "boxInfoMessOK"); gtk_image_set_from_pixbuf(GTK_IMAGE(icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.libublsettingsui-gtk3.important", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, NULL)); } break; } } void _yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type) { render_data data = render; yon_ubl_status_box_set(type,data.box,GTK_IMAGE(data.icon)); if (text) gtk_label_set_text(GTK_LABEL(data.label), text); } void yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type){ _yon_ubl_status_box_render(text,type); } void _yon_ubl_status_highlight_incorrect(GtkWidget *widget){ gtk_style_context_add_class(gtk_widget_get_style_context(widget),"errorBox"); sleep(5); gtk_style_context_remove_class(gtk_widget_get_style_context(widget),"errorBox"); } void yon_ubl_status_highlight_incorrect(GtkWidget *widget){ GThread *thread = g_thread_new(NULL,(GThreadFunc)_yon_ubl_status_highlight_incorrect,widget); } void _yon_ubl_status_list_store_highlight_incorrect(GtkWidget **widget_pack){ GtkListStore *list = (GtkListStore*)widget_pack[0]; GtkTreeIter *iter = (GtkTreeIter*)widget_pack[1]; GdkRGBA rgba,rgba2; rgba.alpha=1; rgba.blue=153.0/255.0; rgba.green=153.0/255.0; rgba.red=234.0/255.0; rgba2.alpha=1; rgba2.blue=0; rgba2.green=0; rgba2.red=0; gtk_list_store_set(list,iter,1,gdk_rgba_to_string(&rgba2),2,gdk_rgba_to_string(&rgba),-1); sleep(5); gtk_list_store_set(list,iter,1,NULL,2,NULL,-1); } void yon_ubl_status_list_store_highlight_incorrect(GtkListStore *list, GtkTreeIter *iter){ GtkWidget **pack = malloc(sizeof(GtkWidget *)*2); pack[0]=(GtkWidget*)list; pack[1]=(GtkWidget*)iter; GThread *thread = g_thread_new(NULL,(GThreadFunc)_yon_ubl_status_list_store_highlight_incorrect,pack); } struct temp_statusbox { int times; GtkWidget *revealer; }; static char *yon_status_thread_id=NULL; void _yon_ubl_status_box_timed_remove(struct temp_statusbox *statusstruct){ sleep(statusstruct->times); if (status_thread_busy){ gtk_revealer_set_reveal_child(GTK_REVEALER(statusstruct->revealer),0); sleep(1); gtk_widget_destroy(statusstruct->revealer); } status_thread_busy=0; } void __yon_ubl_status_box_destroyed(){ status_thread_busy=0; } void yon_status_box_destroyed(){ if (yon_status_thread_id){ free(yon_status_thread_id); yon_status_thread_id=NULL; } } int yon_ubl_status_box_spawn_infinite(GtkContainer *container, char *status_id, char *display_text, BACKGROUND_IMAGE_TYPE type){ if (!status_thread_busy){ if (yon_status_thread_id){ if (!strcmp(yon_status_thread_id,status_id)){ return 0; } free(yon_status_thread_id); yon_status_thread_id=NULL; GList *list = gtk_container_get_children(container); for (int i=0;irevealer = revealer; } } int _yon_ubl_status_box_despawn_infinite(GtkContainer *container){ if (yon_status_thread_id){ free(yon_status_thread_id); yon_status_thread_id=NULL; } GList *list = gtk_container_get_children(container); for (int i=0; irevealer = revealer; statusstruct->times = timeout; GThread *thread = g_thread_new("StatusThread",(GThreadFunc)_yon_ubl_status_box_timed_remove,statusstruct); status_thread_busy=1; } } void yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWidget *right_window, int socket_main_id, int socket_left_id, int socket_right_id){ if (main_window&&socket_main_id>-1){ gtk_widget_hide(gtk_widget_get_toplevel(main_window)); GtkWidget *plug_main=gtk_plug_new(socket_main_id); GtkWidget *plug_left=NULL; GtkWidget *plug_right=NULL; GtkWidget *box=NULL; g_signal_connect(G_OBJECT(plug_main), "destroy", G_CALLBACK(gtk_main_quit),NULL); if (socket_left_id>-1&&left_window){ plug_left=gtk_plug_new(socket_left_id); g_object_ref(left_window); gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(left_window)),left_window); gtk_container_add(GTK_CONTAINER(plug_left),left_window); gtk_style_context_add_class(gtk_widget_get_style_context(plug_left),"primary-toolbar"); gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"button"); gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"opacited"); gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"color"); gtk_style_context_add_class(gtk_widget_get_style_context(plug_left),"noborder"); gtk_widget_show(plug_left); } else if (left_window){ if (box==NULL){ box=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); gtk_box_pack_start(GTK_BOX(main_window),box,0,0,5); gtk_box_reorder_child(GTK_BOX(main_window),box,0); gtk_widget_show(box); } gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"inherited"); gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(left_window)),left_window); gtk_box_pack_end(GTK_BOX(box),left_window,0,0,5); } if (socket_right_id>-1&&right_window){ plug_right=gtk_plug_new(socket_right_id); g_object_ref(right_window); gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(right_window)),right_window); gtk_container_add(GTK_CONTAINER(plug_right),right_window); gtk_style_context_add_class(gtk_widget_get_style_context(plug_right),"primary-toolbar"); gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"button"); gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"opacited"); gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"color"); gtk_style_context_add_class(gtk_widget_get_style_context(plug_right),"noborder"); gtk_widget_show(plug_right); } else if (right_window){ if (box==NULL){ box=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); gtk_box_pack_start(GTK_BOX(main_window),box,0,0,5); gtk_box_reorder_child(GTK_BOX(main_window),box,0); gtk_widget_show(box); } gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"inherited"); gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(right_window)),right_window); gtk_box_pack_start(GTK_BOX(box),right_window,0,0,5); } g_object_ref(main_window); gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(main_window)),main_window); gtk_container_add(GTK_CONTAINER(plug_main),main_window); gtk_widget_show(plug_main); } } #ifdef WEBKIT_INCLUDE void yon_ubl_browser_window_open(char *link, char *browser_window_name){ GtkWidget *browser=gtk_window_new(GTK_WINDOW_TOPLEVEL); GtkWidget *web_place=gtk_box_new(GTK_ORIENTATION_VERTICAL,0); GtkWidget *header=gtk_header_bar_new(); GtkWidget *header_label=gtk_label_new(browser_window_name); GtkWidget *WebView=webkit_web_view_new(); gtk_container_add(GTK_CONTAINER(browser),web_place); gtk_window_set_titlebar(GTK_WINDOW(browser),header); gtk_window_set_title(GTK_WINDOW(browser),browser_window_name); gtk_widget_set_size_request(browser,800,600); gtk_header_bar_set_custom_title(GTK_HEADER_BAR(header),header_label); gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(header),1); webkit_web_view_load_uri(WEBKIT_WEB_VIEW(WebView),link); gtk_box_pack_start(GTK_BOX(web_place),WebView,1,1,0); gtk_widget_show_all(browser); } #else void yon_ubl_browser_window_open(char *link, char *browser_window_name){ char *user=getenv("SUDO_USER"); if (!user) user=getlogin(); char *command=yon_char_unite("sudo -u ",user," xdg-open ", link,NULL); yon_launch_app(command); } #endif #endif