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.
ubl-settings-info/source/ubl-settings-info.c

76 lines
3.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include "ubl-settings-info.h"
config main_config;
void yon_terminal_style_update(VteTerminal *, main_window *widgets){
GdkRGBA *bg_color = NULL, *color=NULL;
gtk_style_context_get(gtk_widget_get_style_context(widgets->TerminalTemplateLabel),GTK_STATE_FLAG_NORMAL,GTK_STYLE_PROPERTY_BACKGROUND_COLOR,&bg_color,GTK_STYLE_PROPERTY_COLOR,&color,NULL);
vte_terminal_set_color_background(VTE_TERMINAL(widgets->InfoTerminal),bg_color);
vte_terminal_set_color_foreground(VTE_TERMINAL(widgets->InfoTerminal),color);
vte_terminal_set_color_cursor_foreground(VTE_TERMINAL(widgets->InfoTerminal),bg_color);
vte_terminal_set_color_cursor(VTE_TERMINAL(widgets->InfoTerminal),bg_color);
if (bg_color->blue>0.5&&bg_color->green>0.5&&bg_color->red>0.5){
gtk_image_set_from_file(GTK_IMAGE(widgets->InfoIcon),logo_icon_path);
gtk_image_set_pixel_size(GTK_IMAGE(widgets->InfoIcon),255);
} else if (bg_color->blue<0.5&&bg_color->green<0.5&&bg_color->red<0.5){
gtk_image_set_from_file(GTK_IMAGE(widgets->InfoIcon),logo_dark_icon_path);
gtk_image_set_pixel_size(GTK_IMAGE(widgets->InfoIcon),255);
}
}
void on_theme_changed(GSettings *, char *, main_window *widgets){
yon_terminal_style_update(NULL, widgets);
}
/**yon_main_window_complete(main_window *widgets)
* [EN]
*
* [RU]
* Функция настройки основного окна приложения. [widgets] - структура со стандартным интерфейсом.
*/
void yon_main_window_complete(main_window *widgets){
widgets = yon_remalloc(widgets,sizeof(main_window));
GtkBuilder *builder = gtk_builder_new_from_resource(glade_path);
gtk_box_pack_start(GTK_BOX(widgets->InterfaceBox),yon_gtk_builder_get_widget(builder,"BoxMain"),1,1,0);
// Custom widgets configuration
{
widgets->InfoIcon = yon_gtk_builder_get_widget(builder,"InfoIcon");
widgets->InfoTerminal = yon_gtk_builder_get_widget(builder,"InfoTerminal");
widgets->TerminalTemplateLabel = yon_gtk_builder_get_widget(builder,"TerminalTemplateLabel");
}
{
yon_terminal_integrated_start(widgets->InfoTerminal,main_command);
yon_terminal_style_update(NULL, widgets);
GSettings *settings = g_settings_new("org.gnome.desktop.interface");
g_signal_connect(G_OBJECT(settings), "changed",G_CALLBACK(on_theme_changed),widgets);
}
GList *children = gtk_container_get_children(GTK_CONTAINER(widgets->RightBox));
gtk_widget_hide(GTK_WIDGET(g_list_nth_data(children,0)));
gtk_widget_hide(widgets->LeftBox);
gtk_widget_hide(widgets->StatusBox);
g_list_free(children);
}
int main(int argc, char *argv[]){
setlocale(LC_ALL, "");
textdomain (LocaleName);
yon_ubl_connect_config((_template_config*)&main_config);
yon_ubl_window_init(TITLE_LABEL,TITLE_INFO_LABEL,LocaleName,CssPath,LocaleName,version_application,WIKI_LINK);
config_str unfound = NULL;
int size=0;
yon_ubl_setup_arguments(argc,argv,&unfound,&size,NULL);
gtk_init(&argc,&argv);
template_main_window *widgets = yon_ubl_window_setup();
//turn off if custom presented
yon_main_window_complete((main_window*)widgets);
char *path = yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL);
yon_window_config_load(path);
gtk_main();
return 0;
}