aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhwspeedy <ns@bigbear.dk>2024-04-25 15:41:26 +0200
committerhwspeedy <ns@bigbear.dk>2024-04-25 15:41:26 +0200
commitbbfa669af189ff2ad46df44715e9e824b251d9b7 (patch)
tree419474ea4cb613892db66f841142d5d2791e1417
parentb2ad27df69befa570e53973dfcc63c9bfa040b38 (diff)
FIX Added more Themes
-rw-r--r--includes/callbacks.h4
-rw-r--r--includes/hardinfo.h1
-rw-r--r--includes/uidefs.h8
-rwxr-xr-xpixmaps/bg1_dark.jpg (renamed from pixmaps/bg_dark.jpg)bin112326 -> 112326 bytes
-rwxr-xr-xpixmaps/bg1_light.jpg (renamed from pixmaps/bg_light.jpg)bin175756 -> 175756 bytes
-rwxr-xr-xpixmaps/bg2_dark.jpgbin0 -> 186637 bytes
-rwxr-xr-xpixmaps/bg2_light.jpgbin0 -> 196171 bytes
-rwxr-xr-xpixmaps/bg3_dark.jpgbin0 -> 75697 bytes
-rwxr-xr-xpixmaps/bg3_light.jpgbin0 -> 74598 bytes
-rwxr-xr-xpixmaps/bg4_dark.jpgbin0 -> 117445 bytes
-rwxr-xr-xpixmaps/bg4_light.jpgbin0 -> 105590 bytes
-rw-r--r--shell/callbacks.c67
-rw-r--r--shell/menu.c19
-rw-r--r--shell/shell.c47
14 files changed, 120 insertions, 26 deletions
diff --git a/includes/callbacks.h b/includes/callbacks.h
index a689ecb4..4ecfa58c 100644
--- a/includes/callbacks.h
+++ b/includes/callbacks.h
@@ -42,5 +42,9 @@ void cb_local_computer();
void cb_act_as_server();
void cb_sync_on_startup();
void cb_disable_theme();
+void cb_theme1();
+void cb_theme2();
+void cb_theme3();
+void cb_theme4();
#endif /* __CALLBACKS_H__ */
diff --git a/includes/hardinfo.h b/includes/hardinfo.h
index 9c229289..b4d70de0 100644
--- a/includes/hardinfo.h
+++ b/includes/hardinfo.h
@@ -56,6 +56,7 @@ struct _ProgramParameters {
gint gui_running;
gint skip_benchmarks;
gint quiet;
+ gint theme;
/*
* OK to use the common parts of HTML(4.0) and Pango Markup
diff --git a/includes/uidefs.h b/includes/uidefs.h
index 216a811e..d8b12143 100644
--- a/includes/uidefs.h
+++ b/includes/uidefs.h
@@ -32,7 +32,13 @@ char *uidefs_str =
" <menu name=\"ViewMenu\" action=\"ViewMenuAction\">"
" <menuitem name=\"SidePane\" action=\"SidePaneAction\"/>"
" <menuitem name=\"Toolbar\" action=\"ToolbarAction\"/>"
- "<menuitem name=\"DisableTheme\" action=\"DisableThemeAction\"/>"
+ " <menu name=\"ThemeMenu\" action=\"ThemeMenuAction\">"
+ " <menuitem name=\"DisableTheme\" action=\"DisableThemeAction\"/>"
+ " <menuitem name=\"Theme1\" action=\"Theme1Action\"/>"
+ " <menuitem name=\"Theme2\" action=\"Theme2Action\"/>"
+ " <menuitem name=\"Theme3\" action=\"Theme3Action\"/>"
+ " <menuitem name=\"Theme4\" action=\"Theme4Action\"/>"
+ " </menu>"
" <separator/>"
" <separator name=\"LastSep\"/>"
" <menuitem name=\"Refresh\" action=\"RefreshAction\"/>"
diff --git a/pixmaps/bg_dark.jpg b/pixmaps/bg1_dark.jpg
index e0ef0dab..e0ef0dab 100755
--- a/pixmaps/bg_dark.jpg
+++ b/pixmaps/bg1_dark.jpg
Binary files differ
diff --git a/pixmaps/bg_light.jpg b/pixmaps/bg1_light.jpg
index 7d577714..7d577714 100755
--- a/pixmaps/bg_light.jpg
+++ b/pixmaps/bg1_light.jpg
Binary files differ
diff --git a/pixmaps/bg2_dark.jpg b/pixmaps/bg2_dark.jpg
new file mode 100755
index 00000000..8d2c408f
--- /dev/null
+++ b/pixmaps/bg2_dark.jpg
Binary files differ
diff --git a/pixmaps/bg2_light.jpg b/pixmaps/bg2_light.jpg
new file mode 100755
index 00000000..a48b2415
--- /dev/null
+++ b/pixmaps/bg2_light.jpg
Binary files differ
diff --git a/pixmaps/bg3_dark.jpg b/pixmaps/bg3_dark.jpg
new file mode 100755
index 00000000..2c3ca28a
--- /dev/null
+++ b/pixmaps/bg3_dark.jpg
Binary files differ
diff --git a/pixmaps/bg3_light.jpg b/pixmaps/bg3_light.jpg
new file mode 100755
index 00000000..fe739a94
--- /dev/null
+++ b/pixmaps/bg3_light.jpg
Binary files differ
diff --git a/pixmaps/bg4_dark.jpg b/pixmaps/bg4_dark.jpg
new file mode 100755
index 00000000..7a1f4253
--- /dev/null
+++ b/pixmaps/bg4_dark.jpg
Binary files differ
diff --git a/pixmaps/bg4_light.jpg b/pixmaps/bg4_light.jpg
new file mode 100755
index 00000000..86acaa25
--- /dev/null
+++ b/pixmaps/bg4_light.jpg
Binary files differ
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);
}