diff options
author | hwspeedy <ns@bigbear.dk> | 2024-04-25 15:41:26 +0200 |
---|---|---|
committer | hwspeedy <ns@bigbear.dk> | 2024-04-25 15:41:26 +0200 |
commit | bbfa669af189ff2ad46df44715e9e824b251d9b7 (patch) | |
tree | 419474ea4cb613892db66f841142d5d2791e1417 /shell | |
parent | b2ad27df69befa570e53973dfcc63c9bfa040b38 (diff) |
FIX Added more Themes
Diffstat (limited to 'shell')
-rw-r--r-- | shell/callbacks.c | 67 | ||||
-rw-r--r-- | shell/menu.c | 19 | ||||
-rw-r--r-- | shell/shell.c | 47 |
3 files changed, 108 insertions, 25 deletions
diff --git a/shell/callbacks.c b/shell/callbacks.c index 78aee700..2892be2c 100644 --- a/shell/callbacks.c +++ b/shell/callbacks.c @@ -62,11 +62,56 @@ gboolean g2_key_file_save_to_file (GKeyFile *key_file, } #endif +void cb_theme1() +{ + if(shell_action_get_active("Theme1Action")){ + params.theme=1; + if(shell_action_get_active("DisableThemeAction")) shell_action_set_active("DisableThemeAction",FALSE); + if(shell_action_get_active("Theme2Action")) shell_action_set_active("Theme2Action",FALSE); + if(shell_action_get_active("Theme3Action")) shell_action_set_active("Theme3Action",FALSE); + if(shell_action_get_active("Theme4Action")) shell_action_set_active("Theme4Action",FALSE); + } + cb_disable_theme(); +} +void cb_theme2() +{ + if(shell_action_get_active("Theme2Action")){ + params.theme=2; + if(shell_action_get_active("DisableThemeAction")) shell_action_set_active("DisableThemeAction",FALSE); + if(shell_action_get_active("Theme1Action")) shell_action_set_active("Theme1Action",FALSE); + if(shell_action_get_active("Theme3Action")) shell_action_set_active("Theme3Action",FALSE); + if(shell_action_get_active("Theme4Action")) shell_action_set_active("Theme4Action",FALSE); + } + cb_disable_theme(); +} +void cb_theme3() +{ + if(shell_action_get_active("Theme3Action")){ + params.theme=3; + if(shell_action_get_active("DisableThemeAction")) shell_action_set_active("DisableThemeAction",FALSE); + if(shell_action_get_active("Theme1Action")) shell_action_set_active("Theme1Action",FALSE); + if(shell_action_get_active("Theme2Action")) shell_action_set_active("Theme2Action",FALSE); + if(shell_action_get_active("Theme4Action")) shell_action_set_active("Theme4Action",FALSE); + } + cb_disable_theme(); +} +void cb_theme4() +{ + if(shell_action_get_active("Theme4Action")){ + params.theme=4; + if(shell_action_get_active("DisableThemeAction")) shell_action_set_active("DisableThemeAction",FALSE); + if(shell_action_get_active("Theme1Action")) shell_action_set_active("Theme1Action",FALSE); + if(shell_action_get_active("Theme2Action")) shell_action_set_active("Theme2Action",FALSE); + if(shell_action_get_active("Theme3Action")) shell_action_set_active("Theme3Action",FALSE); + } + cb_disable_theme(); +} + void cb_disable_theme() { Shell *shell = shell_get_main_shell(); // *shelltree=shell->tree; - gboolean setting = shell_action_get_active("DisableThemeAction"); + char theme_st[200]; GKeyFile *key_file = g_key_file_new(); #if GTK_CHECK_VERSION(3, 0, 0) GtkCssProvider *provider; @@ -77,16 +122,21 @@ void cb_disable_theme() provider3 = gtk_css_provider_new(); #endif + if(shell_action_get_active("DisableThemeAction")){ + params.theme=-1; + if(shell_action_get_active("Theme1Action")) shell_action_set_active("Theme1Action",FALSE); + if(shell_action_get_active("Theme2Action")) shell_action_set_active("Theme2Action",FALSE); + if(shell_action_get_active("Theme3Action")) shell_action_set_active("Theme3Action",FALSE); + } + g_mkdir(g_get_user_config_dir(),0755); g_mkdir(g_build_filename(g_get_user_config_dir(), "hardinfo2", NULL),0755); - - gchar *conf_path = g_build_filename(g_get_user_config_dir(), "hardinfo2", - "settings.ini", NULL); + gchar *conf_path = g_build_filename(g_get_user_config_dir(), "hardinfo2", "settings.ini", NULL); g_key_file_load_from_file( key_file, conf_path, G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, NULL); - g_key_file_set_boolean(key_file, "Theme", "DisableTheme", setting); + g_key_file_set_integer(key_file, "Theme", "ThemeNumber", params.theme); #if GLIB_CHECK_VERSION(2,40,0) g_key_file_save_to_file(key_file, conf_path, NULL); #else @@ -98,12 +148,13 @@ void cb_disable_theme() #if GTK_CHECK_VERSION(3, 0, 0) gboolean darkmode; g_object_get(gtk_settings_get_default(), "gtk-application-prefer-dark-theme", &darkmode, NULL); - if(!setting){//enable + if(params.theme>0){//enable if(darkmode){ - gtk_css_provider_load_from_data(provider, "window.background {background-image: url(\"/usr/share/hardinfo2/pixmaps/bg_dark.jpg\"); background-repeat: no-repeat; background-size:100% 100%; }", -1, NULL); + sprintf(theme_st,"window.background {background-image: url(\"/usr/share/hardinfo2/pixmaps/bg%d_dark.jpg\"); background-repeat: no-repeat; background-size:100%% 100%%; }",params.theme); }else{ - gtk_css_provider_load_from_data(provider, "window.background {background-image: url(\"/usr/share/hardinfo2/pixmaps/bg_light.jpg\"); background-repeat: no-repeat; background-size:100% 100%; }", -1, NULL); + sprintf(theme_st,"window.background {background-image: url(\"/usr/share/hardinfo2/pixmaps/bg%d_light.jpg\"); background-repeat: no-repeat; background-size:100%% 100%%; }",params.theme); } + gtk_css_provider_load_from_data(provider, theme_st, -1, NULL); if(shell->window) gtk_style_context_add_provider(gtk_widget_get_style_context(shell->window), GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); //menubar gtk_css_provider_load_from_data(provider2, "* { background-color: rgba(0x60, 0x60, 0x60, 0.1); } * text { background-color: rgba(1, 1, 1, 1); }", -1, NULL); diff --git a/shell/menu.c b/shell/menu.c index e56ef925..2d5e0874 100644 --- a/shell/menu.c +++ b/shell/menu.c @@ -42,6 +42,9 @@ static GtkActionEntry entries[] = { {"InformationMenuAction", NULL, N_("_Information")}, /* name, stock id, label */ {"ViewMenuAction", NULL, N_("_View")}, +#if GTK_CHECK_VERSION(3, 0, 0) + {"ThemeMenuAction", NULL, N_("_Theme")}, +#endif {"HelpMenuAction", NULL, N_("_Help")}, {"MainMenuBarAction", NULL, ""}, @@ -109,6 +112,22 @@ static GtkToggleActionEntry toggle_entries[] = { N_("Disable Theme"), NULL, NULL, G_CALLBACK(cb_disable_theme)}, + {"Theme1Action", NULL, + N_("Theme Motherboard"), NULL, + NULL, + G_CALLBACK(cb_theme1)}, + {"Theme2Action", NULL, + N_("Theme Graffiti PC"), NULL, + NULL, + G_CALLBACK(cb_theme2)}, + {"Theme3Action", NULL, + N_("Theme Anime PC"), NULL, + NULL, + G_CALLBACK(cb_theme3)}, + {"Theme4Action", NULL, + N_("Theme Tux Star"), NULL, + NULL, + G_CALLBACK(cb_theme4)}, #endif }; diff --git a/shell/shell.c b/shell/shell.c index 0d56cef7..f3225783 100644 --- a/shell/shell.c +++ b/shell/shell.c @@ -72,7 +72,6 @@ static GSList *update_sfusrc = NULL; gchar *lginterval = NULL; gboolean darkmode; -gboolean disabletheme; /* * Code :) ******************************************************************** */ @@ -427,6 +426,7 @@ void shell_set_title(Shell *shell, gchar *subtitle) static void create_window(void) { GtkWidget *vbox, *hbox; + char theme_st[200]; #if GTK_CHECK_VERSION(3, 0, 0) GtkCssProvider *provider; provider = gtk_css_provider_new(); @@ -440,7 +440,7 @@ static void create_window(void) gtk_window_set_icon(GTK_WINDOW(shell->window), icon_cache_get_pixbuf("hardinfo2.png")); shell_set_title(shell, NULL); - gtk_window_set_default_size(GTK_WINDOW(shell->window), 1024, 800); + gtk_window_set_default_size(GTK_WINDOW(shell->window), 1280, 800); g_signal_connect(G_OBJECT(shell->window), "destroy", destroy_me, NULL); #if GTK_CHECK_VERSION(3, 0, 0) @@ -511,18 +511,27 @@ static void create_window(void) GKeyFile *key_file = g_key_file_new(); gchar *conf_path = g_build_filename(g_get_user_config_dir(), "hardinfo2","settings.ini", NULL); g_key_file_load_from_file(key_file, conf_path, G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, NULL); - disabletheme = g_key_file_get_boolean(key_file, "Theme", "DisableTheme", NULL); + params.theme = g_key_file_get_integer(key_file, "Theme", "ThemeNumber", NULL); + if(params.theme==0) params.theme=1; + if(params.theme<-1) params.theme=-1; + if(params.theme>4) params.theme=-1; + g_free(conf_path); g_key_file_free(key_file); - shell_action_set_active("DisableThemeAction", disabletheme); + if(params.theme==-1) shell_action_set_active("DisableThemeAction", TRUE); + if(params.theme==1) shell_action_set_active("Theme1Action", TRUE); + if(params.theme==2) shell_action_set_active("Theme2Action", TRUE); + if(params.theme==3) shell_action_set_active("Theme3Action", TRUE); + if(params.theme==4) shell_action_set_active("Theme4Action", TRUE); #if GTK_CHECK_VERSION(3, 0, 0) - if(!disabletheme){ + if(params.theme>0){ if(darkmode){ - gtk_css_provider_load_from_data(provider, "window.background {background-image: url(\"/usr/share/hardinfo2/pixmaps/bg_dark.jpg\"); background-repeat: no-repeat; background-size:100% 100%; }", -1, NULL); + sprintf(theme_st,"window.background {background-image: url(\"/usr/share/hardinfo2/pixmaps/bg%d_dark.jpg\"); background-repeat: no-repeat; background-size:100%% 100%%; }",params.theme); }else{ - gtk_css_provider_load_from_data(provider, "window.background {background-image: url(\"/usr/share/hardinfo2/pixmaps/bg_light.jpg\"); background-repeat: no-repeat; background-size:100% 100%; }", -1, NULL); + sprintf(theme_st,"window.background {background-image: url(\"/usr/share/hardinfo2/pixmaps/bg%d_light.jpg\"); background-repeat: no-repeat; background-size:100%% 100%%; }",params.theme); } + gtk_css_provider_load_from_data(provider, theme_st, -1, NULL); gtk_style_context_add_provider(gtk_widget_get_style_context(shell->window), GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); gtk_css_provider_load_from_data(provider2, "* { background-color: rgba(0x60, 0x60, 0x60, 0.1); } * text { background-color: rgba(1, 1, 1, 1); }", -1, NULL); @@ -765,13 +774,17 @@ void shell_init(GSList * modules) create_window(); - shell_action_set_property("ConnectToAction", "is-important", TRUE); shell_action_set_property("CopyAction", "is-important", TRUE); shell_action_set_property("RefreshAction", "is-important", TRUE); shell_action_set_property("ReportAction", "is-important", TRUE); - shell_action_set_property("ReportBugAction", "is-important", TRUE); shell_action_set_property("SyncManagerAction", "is-important", TRUE); + shell_action_set_property("DisableThemeAction", "draw-as-radio", TRUE); + shell_action_set_property("Theme1Action", "draw-as-radio", TRUE); + shell_action_set_property("Theme2Action", "draw-as-radio", TRUE); + shell_action_set_property("Theme3Action", "draw-as-radio", TRUE); + shell_action_set_property("Theme4Action", "draw-as-radio", TRUE); + shell->tree = tree_new(); shell->info_tree = info_tree_new(); shell->loadgraph = load_graph_new(75); @@ -1534,7 +1547,7 @@ static void module_selected_show_info_list(GKeyFile *key_file, gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(shell->info_tree->view), FALSE); #if GTK_CHECK_VERSION(3, 0, 0) - if(!disabletheme){ + if(params.theme>0){ gtk_css_provider_load_from_data(provider, "treeview { background-color: rgba(0x60, 0x60, 0x60, 0.1); } treeview:selected { background-color: rgba(0x40, 0x60, 0xff, 1); } ", -1, NULL); gtk_style_context_add_provider(gtk_widget_get_style_context(shell->info_tree->view), GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } @@ -2132,17 +2145,17 @@ static ShellInfoTree *info_tree_new(void) gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(treeview), TRUE); -#if GTK_CHECK_VERSION(3, 0, 0) - if(!disabletheme){ +/*#if GTK_CHECK_VERSION(3, 0, 0) + if(params.theme>0){ //GdkRGBA info_default_text_color = { .red = 0.2, .green = 0.3, .blue = 1.0, .alpha = 1.0 }; //gtk_widget_override_color(treeview, GTK_STATE_FLAG_SELECTED, &info_default_text_color); } #else - if(!disabletheme){ + if(params.theme>0){ //GdkColor info_default_text_color = { 0, 0x4fff, 0x6fff, 0xffff }; //gtk_widget_modify_fg(treeview, GTK_STATE_SELECTED, &info_default_text_color); } -#endif +#endif*/ info->col_progress = column = gtk_tree_view_column_new(); gtk_tree_view_column_set_visible(column, FALSE); @@ -2253,12 +2266,12 @@ static ShellTree *tree_new() #endif /*#if GTK_CHECK_VERSION(3, 0, 0) - if(!disabletheme){ + if(params.theme>0){ GdkRGBA info_default_text_color = { .red = 0.2, .green = 0.3, .blue = 1.0, .alpha = 1.0 }; gtk_widget_override_color(treeview, GTK_STATE_FLAG_SELECTED, &info_default_text_color); } #else - if(!disabletheme){ + if(params.theme>0){ GdkColor info_default_text_color = { 0, 0x4fff, 0x6fff, 0xffff }; gtk_widget_modify_fg(treeview, GTK_STATE_SELECTED, &info_default_text_color); } @@ -2284,7 +2297,7 @@ static ShellTree *tree_new() gtk_container_add(GTK_CONTAINER(scroll), treeview); #if GTK_CHECK_VERSION(3, 0, 0) - if(!disabletheme){ + if(params.theme>0){ gtk_css_provider_load_from_data(provider, "treeview { background-color: rgba(0x60, 0x60, 0x60, 0.1); } treeview:selected { background-color: rgba(0x40, 0x60, 0xff, 1); } ", -1, NULL); gtk_style_context_add_provider(gtk_widget_get_style_context(treeview), GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } |