summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhwspeedy <ns@bigbear.dk>2024-04-24 01:16:57 +0200
committerhwspeedy <ns@bigbear.dk>2024-04-24 01:16:57 +0200
commit791912482ff618cd6ca08224db01b243d7186215 (patch)
tree58c71400b28400b8d5f7149b1516f76e33da314b
parentabf8fabf4df677a1fbf58e4955d1cc08eace48d2 (diff)
FIX Added theme background - copyright crstrbrt - mentioned but not needed.
-rw-r--r--CMakeLists.txt2
-rw-r--r--includes/callbacks.h1
-rw-r--r--includes/uidefs.h3
-rwxr-xr-xpixmaps/bg_dark.jpgbin0 -> 112326 bytes
-rwxr-xr-xpixmaps/bg_light.jpgbin0 -> 175756 bytes
-rw-r--r--shell/callbacks.c28
-rw-r--r--shell/menu.c8
-rw-r--r--shell/shell.c88
8 files changed, 123 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f644ce12..5c3e1758 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -480,7 +480,7 @@ install(FILES ${HARDINFO2_RESOURCES}
)
install(DIRECTORY pixmaps
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/hardinfo2
- PATTERN "*.{png,svg}"
+ PATTERN "*.{png,svg,jpg}"
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
install(FILES ${HARDINFO2_MANPAGES}
diff --git a/includes/callbacks.h b/includes/callbacks.h
index 421cff5e..a689ecb4 100644
--- a/includes/callbacks.h
+++ b/includes/callbacks.h
@@ -41,5 +41,6 @@ void cb_connect_host(GtkAction * action);
void cb_local_computer();
void cb_act_as_server();
void cb_sync_on_startup();
+void cb_disable_theme();
#endif /* __CALLBACKS_H__ */
diff --git a/includes/uidefs.h b/includes/uidefs.h
index c3042492..41adedb8 100644
--- a/includes/uidefs.h
+++ b/includes/uidefs.h
@@ -15,7 +15,8 @@
"<separator/>" \
"<menuitem name=\"SyncManager\" action=\"SyncManagerAction\" " \
"always-show-image=\"true\"/>" \
- "<menuitem name=\"SyncOnStartup\" action=\"SyncOnStartupAction\"/>"
+ "<menuitem name=\"SyncOnStartup\" action=\"SyncOnStartupAction\"/>" \
+ "<menuitem name=\"DisableTheme\" action=\"DisableThemeAction\"/>"
#define SYNC_MANAGER_TOOL_ITEMS \
"<toolitem name=\"SyncManager\" action=\"SyncManagerAction\"/>"
diff --git a/pixmaps/bg_dark.jpg b/pixmaps/bg_dark.jpg
new file mode 100755
index 00000000..e0ef0dab
--- /dev/null
+++ b/pixmaps/bg_dark.jpg
Binary files differ
diff --git a/pixmaps/bg_light.jpg b/pixmaps/bg_light.jpg
new file mode 100755
index 00000000..7d577714
--- /dev/null
+++ b/pixmaps/bg_light.jpg
Binary files differ
diff --git a/shell/callbacks.c b/shell/callbacks.c
index 006cbe11..1ff0a585 100644
--- a/shell/callbacks.c
+++ b/shell/callbacks.c
@@ -62,6 +62,31 @@ gboolean g2_key_file_save_to_file (GKeyFile *key_file,
}
#endif
+void cb_disable_theme()
+{
+ gboolean setting = shell_action_get_active("DisableThemeAction");
+ GKeyFile *key_file = g_key_file_new();
+
+ 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);
+
+ 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);
+#if GLIB_CHECK_VERSION(2,40,0)
+ g_key_file_save_to_file(key_file, conf_path, NULL);
+#else
+ g2_key_file_save_to_file(key_file, conf_path, NULL);
+#endif
+ g_free(conf_path);
+ g_key_file_free(key_file);
+}
+
+
void cb_sync_on_startup()
{
gboolean setting = shell_action_get_active("SyncOnStartupAction");
@@ -206,11 +231,12 @@ void cb_about()
"The GNOME Project",
"epicbard",
"Roundicons",
+ "crstrbrt",
"",
"Packaging by:",
"Topazus (Fedora/Redhat branches)",
"Yochananmargos (Arch branches)",
- "lucascastro/tsimonq2 (Debian/Ubuntu branches)",
+ "lucascastro (Debian/Ubuntu branches)",
"",
NULL
};
diff --git a/shell/menu.c b/shell/menu.c
index 83bd8144..b9e62664 100644
--- a/shell/menu.c
+++ b/shell/menu.c
@@ -41,10 +41,8 @@
static GtkActionEntry entries[] = {
{"InformationMenuAction", NULL, N_("_Information")}, /* name, stock id, label */
- // {"RemoteMenuAction", NULL, N_("_Remote")},
{"ViewMenuAction", NULL, N_("_View")},
{"HelpMenuAction", NULL, N_("_Help")},
- // {"HelpMenuModulesAction", HI_STOCK_ABOUT_MODULES, N_("About _Modules")},
{"MainMenuBarAction", NULL, ""},
{"ReportAction", HI_STOCK_REPORT, /* name, stock id */
@@ -106,6 +104,12 @@ static GtkToggleActionEntry toggle_entries[] = {
N_("Synchronize on startup"), NULL,
NULL,
G_CALLBACK(cb_sync_on_startup)},
+#if GTK_CHECK_VERSION(3, 0, 0)
+ {"DisableThemeAction", NULL,
+ N_("Disable Theme at startup"), NULL,
+ NULL,
+ G_CALLBACK(cb_disable_theme)},
+#endif
};
/* Implement a handler for GtkUIManager's "add_widget" signal. The UI manager
diff --git a/shell/shell.c b/shell/shell.c
index 36d89b75..0d56cef7 100644
--- a/shell/shell.c
+++ b/shell/shell.c
@@ -71,6 +71,8 @@ static GSList *update_sfusrc = NULL;
gchar *lginterval = NULL;
+gboolean darkmode;
+gboolean disabletheme;
/*
* Code :) ********************************************************************
*/
@@ -425,6 +427,12 @@ void shell_set_title(Shell *shell, gchar *subtitle)
static void create_window(void)
{
GtkWidget *vbox, *hbox;
+#if GTK_CHECK_VERSION(3, 0, 0)
+ GtkCssProvider *provider;
+ provider = gtk_css_provider_new();
+ GtkCssProvider *provider2;
+ provider2 = gtk_css_provider_new();
+#endif
shell = g_new0(Shell, 1);
@@ -498,6 +506,30 @@ static void create_window(void)
shell->notebook = gtk_notebook_new();
gtk_paned_add2(GTK_PANED(shell->vpaned), shell->notebook);
+ g_object_get(gtk_settings_get_default(), "gtk-application-prefer-dark-theme", &darkmode, NULL);
+
+ 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);
+ g_free(conf_path);
+ g_key_file_free(key_file);
+ shell_action_set_active("DisableThemeAction", disabletheme);
+
+#if GTK_CHECK_VERSION(3, 0, 0)
+ if(!disabletheme){
+ 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);
+ }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);
+ }
+ 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);
+ gtk_style_context_add_provider(gtk_widget_get_style_context(gtk_ui_manager_get_widget(shell->ui_manager,"/MainMenuBarAction")), GTK_STYLE_PROVIDER(provider2), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ }
+#endif
+
gtk_widget_show(shell->window);
while (gtk_events_pending())
gtk_main_iteration();
@@ -657,6 +689,7 @@ DetailView *detail_view_new(void)
gtk_scrolled_window_add_with_viewport(
GTK_SCROLLED_WINDOW(detail_view->scroll), detail_view->view);
#endif
+
gtk_widget_show_all(detail_view->scroll);
return detail_view;
@@ -1486,6 +1519,10 @@ static void module_selected_show_info_list(GKeyFile *key_file,
gchar **groups,
gsize ngroups)
{
+#if GTK_CHECK_VERSION(3, 0, 0)
+ GtkCssProvider *provider;
+ provider = gtk_css_provider_new();
+#endif
GtkTreeStore *store = GTK_TREE_STORE(shell->info_tree->model);
gint i;
@@ -1496,6 +1533,12 @@ 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){
+ 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);
+ }
+#endif
for (i = 0; groups[i]; i++) {
gchar **keys = g_key_file_get_keys(key_file, groups[i], NULL, NULL);
@@ -1609,8 +1652,11 @@ static void module_selected_show_info_detail(GKeyFile *key_file,
gboolean has_ven = key_value_has_vendor_string(flags);
const Vendor *v = has_ven ? vendor_match(value, NULL) : NULL;
- key_markup =
- g_strdup_printf("<span color=\"#666\">%s</span>", label);
+ if(darkmode){
+ key_markup = g_strdup_printf("<span color=\"#46f\">%s</span>", label);
+ } else {
+ key_markup = g_strdup_printf("<span color=\"#46f\">%s</span>", label);
+ }
GtkWidget *key_label = gtk_label_new(key_markup);
gtk_label_set_use_markup(GTK_LABEL(key_label), TRUE);
@@ -2069,6 +2115,7 @@ static ShellInfoTree *info_tree_new(void)
info = g_new0(ShellInfoTree, 1);
scroll = gtk_scrolled_window_new(NULL, NULL);
+
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW
(scroll), GTK_SHADOW_IN);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
@@ -2081,9 +2128,22 @@ static ShellInfoTree *info_tree_new(void)
G_TYPE_STRING, G_TYPE_STRING);
model = GTK_TREE_MODEL(store);
treeview = gtk_tree_view_new_with_model(model);
+
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){
+ //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){
+ //GdkColor info_default_text_color = { 0, 0x4fff, 0x6fff, 0xffff };
+ //gtk_widget_modify_fg(treeview, GTK_STATE_SELECTED, &info_default_text_color);
+ }
+#endif
+
info->col_progress = column = gtk_tree_view_column_new();
gtk_tree_view_column_set_visible(column, FALSE);
gtk_tree_view_column_set_min_width(column, 240);
@@ -2166,6 +2226,10 @@ static ShellTree *tree_new()
GtkCellRenderer *cr_text, *cr_pbuf;
GtkTreeViewColumn *column;
GtkTreeSelection *sel;
+#if GTK_CHECK_VERSION(3, 0, 0)
+ GtkCssProvider *provider;
+ provider = gtk_css_provider_new();
+#endif
shelltree = g_new0(ShellTree, 1);
@@ -2176,6 +2240,7 @@ static ShellTree *tree_new()
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
+
store = gtk_tree_store_new(TREE_NCOL, GDK_TYPE_PIXBUF, G_TYPE_STRING,
G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_BOOLEAN);
model = GTK_TREE_MODEL(store);
@@ -2187,6 +2252,18 @@ static ShellTree *tree_new()
gtk_tree_view_set_level_indentation(GTK_TREE_VIEW(treeview), 24);
#endif
+/*#if GTK_CHECK_VERSION(3, 0, 0)
+ if(!disabletheme){
+ 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){
+ GdkColor info_default_text_color = { 0, 0x4fff, 0x6fff, 0xffff };
+ gtk_widget_modify_fg(treeview, GTK_STATE_SELECTED, &info_default_text_color);
+ }
+#endif*/
+
column = gtk_tree_view_column_new();
gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
@@ -2206,6 +2283,13 @@ static ShellTree *tree_new()
gtk_container_add(GTK_CONTAINER(scroll), treeview);
+#if GTK_CHECK_VERSION(3, 0, 0)
+ if(!disabletheme){
+ 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);
+ }
+#endif
+
shelltree->scroll = scroll;
shelltree->view = treeview;
shelltree->model = model;