Add icon for dark theme

This commit is contained in:
daleclack 2024-02-07 12:45:48 +08:00
parent affd165efa
commit 831d4cc9fd
9 changed files with 96 additions and 20 deletions

View File

@ -55,6 +55,10 @@ set(RESOURCE_LIST
icons/16x16/actions/finder-battery.svg icons/16x16/actions/finder-battery.svg
icons/16x16/actions/finder-computer.svg icons/16x16/actions/finder-computer.svg
icons/16x16/actions/finder-wifi.svg icons/16x16/actions/finder-wifi.svg
icons/16x16/actions/finder_audio-dark.svg
icons/16x16/actions/finder-battery-dark.svg
icons/16x16/actions/finder-computer-dark.svg
icons/16x16/actions/finder-wifi-dark.svg
icons/16x16/actions/folder-images.svg icons/16x16/actions/folder-images.svg
icons/16x16/actions/My_GtkUI.png icons/16x16/actions/My_GtkUI.png
icons/16x16/actions/open-menu.svg icons/16x16/actions/open-menu.svg
@ -87,6 +91,7 @@ set(RESOURCE_LIST
icons/scalable/status/drawing_app.svg icons/scalable/status/drawing_app.svg
icons/scalable/status/drawing_app_running.svg icons/scalable/status/drawing_app_running.svg
icons/scalable/status/finder-find.svg icons/scalable/status/finder-find.svg
icons/scalable/status/finder-find-dark.svg
icons/scalable/status/file-app.svg icons/scalable/status/file-app.svg
icons/scalable/status/file-app_running.svg icons/scalable/status/file-app_running.svg
icons/scalable/status/display_prefs.svg icons/scalable/status/display_prefs.svg

View File

@ -0,0 +1,10 @@
<svg width="16" height="16" version="1.1" xmlns="http://www.w3.org/2000/svg">
<defs>
<style id="current-color-scheme" type="text/css">.ColorScheme-Text { color:#dedede; } .ColorScheme-Highlight { color:#5294e2; }</style>
</defs>
<g style="fill:currentColor" class="ColorScheme-Text">
<path d="m15 6.5879v2.8242a1.5 1.5 0 0 0 1-1.4121 1.5 1.5 0 0 0-1-1.4121z"/>
<rect x="2" y="6" width="10" height="4" ry="0"/>
<path d="m2 4c-1.108 0-2 0.892-2 2v4c0 1.108 0.892 2 2 2h10c1.108 0 2-0.892 2-2v-4c0-1.108-0.892-2-2-2h-10zm0 1h10c0.554 0 1 0.446 1 1v4c0 0.554-0.446 1-1 1h-10c-0.554 0-1-0.446-1-1v-4c0-0.554 0.446-1 1-1z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 643 B

View File

@ -0,0 +1,7 @@
<svg width="16" height="16" version="1.1">
<defs>
<style id="current-color-scheme" type="text/css">.ColorScheme-Text { color:#dedede; } .ColorScheme-Highlight { color:#5294e2; }</style>
</defs>
<path d="m4.5 14h7c0.277 0 0.5 0.223 0.5 0.5s-0.223 0.5-0.5 0.5h-7c-0.277 0-0.5-0.223-0.5-0.5s0.223-0.5 0.5-0.5z" style="fill:currentColor" class="ColorScheme-Text"/>
<path d="m2 2c-1.108 0-2 0.892-2 2v7c0 1.108 0.892 2 2 2h12c1.108 0 2-0.892 2-2v-7c0-1.108-0.892-2-2-2zm0 1h12c0.554 0 1 0.446 1 1v7c0 0.554-0.446 1-1 1h-12c-0.554 0-1-0.446-1-1v-7c0-0.554 0.446-1 1-1z" style="fill:currentColor" class="ColorScheme-Text"/>
</svg>

After

Width:  |  Height:  |  Size: 630 B

View File

@ -0,0 +1,6 @@
<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
<defs>
<style id="current-color-scheme" type="text/css">.ColorScheme-Text { color:#dedede; }</style>
</defs>
<path d="m7.9996 3.0212c-2.6432 0-5.1397 1.1665-6.85 3.2009a0.63845 0.63845 0 0 0 0.49005 1.0491c0.18222 0 0.36305-0.077304 0.48971-0.22742 1.4657-1.7438 3.6057-2.7446 5.8703-2.7446s4.4046 1.0012 5.8703 2.7446c0.12631 0.15116 0.30714 0.22777 0.48971 0.22777a0.63776 0.63776 0 0 0 0.4897-1.0495c-1.7097-2.0344-4.2068-3.2009-6.8504-3.2009zm0 2.707c-1.8877 0-3.6709 0.83378-4.8922 2.2863a0.63894 0.63894 0 1 0 0.97838 0.82204 5.1055 5.1055 0 0 1 3.9135-1.8301c1.5102 0 2.9369 0.66744 3.9142 1.8301 0.12631 0.15116 0.30784 0.22777 0.48971 0.22777a0.63845 0.63845 0 0 0 0.48833-1.0495c-1.2217-1.4529-3.0038-2.2867-4.8922-2.2867zm0 2.8126a3.8272 3.8272 0 0 0-2.9358 1.3704 0.63845 0.63845 0 0 0 0.079374 0.90038 0.63603 0.63603 0 0 0 0.90038-0.07765 2.5507 2.5507 0 0 1 1.9561-0.91453c0.75475 0 1.4677 0.33303 1.9568 0.91453a0.63707 0.63707 0 0 0 0.90004 0.07765 0.63845 0.63845 0 0 0 0.07937-0.90038 3.8272 3.8272 0 0 0-2.9362-1.3704zm-0.054524 2.4264c-0.49971 0.04832-0.98079 0.42172-0.99736 0.97838a1.0522 1.0522 0 0 0 2.1041 0c-0.088692-0.74716-0.6067-1.026-1.1068-0.97838z" style="fill:currentColor" class="ColorScheme-Text"/>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,16 @@
<svg version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
<defs>
<style id="current-color-scheme" type="text/css">.ColorScheme-Text {
color:#dedede
}</style>
</defs>
<g style="fill:currentColor" class="ColorScheme-Text">
<rect y="6" width="5" height="4" ry="1" style="fill:currentColor" class="ColorScheme-Text"/>
<path d="m6 3-3 3v4l3 3z" style="fill:currentColor" class="ColorScheme-Text"/>
<g style="fill:currentColor" class="ColorScheme-Text">
<path d="m13.139 1.4277c-0.54546-0.42773-1.1387 0.22461-0.68359 0.73242 1.6202 1.5104 2.5416 3.6249 2.5449 5.8398-0.0026 2.2205-0.92793 4.3401-2.5547 5.8516-0.44531 0.47165 0.18064 1.1484 0.67774 0.72852 1.8304-1.6992 2.8725-4.0825 2.877-6.5801-0.0026-2.4925-1.0386-4.8722-2.8613-6.5723z" style="fill:currentColor" class="ColorScheme-Text"/>
<path d="m10.775 2.8887c-0.58741-0.53488-1.1988 0.22518-0.68359 0.73242 1.2147 1.1326 1.9056 2.7181 1.9082 4.3789-0.0019 1.6654-0.69594 3.2551-1.916 4.3887-0.46835 0.44623 0.17346 1.1467 0.67969 0.72852 1.423-1.3216 2.233-3.1751 2.2363-5.1172-0.0019-1.9383-0.80739-3.789-2.2246-5.1113z" style="fill:currentColor" class="ColorScheme-Text"/>
<path d="m8.4102 4.3496c-0.52095-0.49369-1.1551 0.22003-0.68359 0.73047 0.81045 0.75501 1.2715 1.8123 1.2734 2.9199-0.00128 1.1103-0.46396 2.1701-1.2773 2.9258-0.47259 0.42993 0.13957 1.1522 0.67969 0.73047 1.0168-0.94425 1.5955-2.2686 1.5977-3.6562-0.00172-1.3844-0.57738-2.7062-1.5898-3.6504z" style="fill:currentColor" class="ColorScheme-Text"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -0,0 +1,8 @@
<svg version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
<defs>
<style id="current-color-scheme" type="text/css">.ColorScheme-Text {
color:#dedede;
}</style>
</defs>
<path class="ColorScheme-Text" d="m6.5 1c-3.0376 0-5.5 2.4624-5.5 5.5s2.4624 5.5 5.5 5.5c1.1132-3e-5 2.2001-0.33783 3.1172-0.96875l3.6855 3.6855c0.9585 1.0092 2.4356-0.50284 1.4043-1.4375l-2.3496-2.3477-1.3203-1.3203-0.0098-0.00977c0.62778-0.91289 0.97013-1.9924 0.97266-3.1016 0-3.0376-2.4624-5.5-5.5-5.5zm0 1c2.4853 0 4.5 2.0147 4.5 4.5s-2.0147 4.5-4.5 4.5-4.5-2.0147-4.5-4.5 2.0147-4.5 4.5-4.5z" fill="currentColor"/>
</svg>

After

Width:  |  Height:  |  Size: 631 B

View File

@ -1,7 +1,6 @@
#include "MyDock.h" #include "MyDock.h"
#include "MyFinder.h" #include "MyFinder.h"
#include "AppView.h" #include "AppView.h"
#include <string>
enum PadPage enum PadPage
{ {
@ -288,19 +287,7 @@ static void my_dock_init(MyDock *self)
// Create Css Provider for styling // Create Css Provider for styling
GtkCssProvider *provider = gtk_css_provider_new(); GtkCssProvider *provider = gtk_css_provider_new();
GtkIconTheme *theme = gtk_icon_theme_get_for_display( if (get_dark_mode(self))
gtk_widget_get_display(GTK_WIDGET(self)));
char *theme_name = gtk_icon_theme_get_theme_name(theme);
// Get Last 4 chars
char tmp_str[5] = {0};
for(int i = 0; i < 4; i++)
{
tmp_str[i] = tolower(theme_name[strlen(theme_name) - 4 + i]);
}
g_print("%s", tmp_str);
if (strncmp(tmp_str, "dark", 4) == 0)
{ {
gtk_css_provider_load_from_resource(provider, "/org/gtk/daleclack/style_dark.css"); gtk_css_provider_load_from_resource(provider, "/org/gtk/daleclack/style_dark.css");
} }
@ -308,7 +295,6 @@ static void my_dock_init(MyDock *self)
{ {
gtk_css_provider_load_from_resource(provider, "/org/gtk/daleclack/style.css"); gtk_css_provider_load_from_resource(provider, "/org/gtk/daleclack/style.css");
} }
g_free(theme_name);
// Add Style for finder // Add Style for finder
my_finder_add_style(MY_FINDER(self->finder), provider); my_finder_add_style(MY_FINDER(self->finder), provider);

View File

@ -1,6 +1,7 @@
#include "MyFinder.h" #include "MyFinder.h"
#include <cstdio> #include <cstdio>
#include <ctime> #include <ctime>
#include <string>
struct _MyFinder struct _MyFinder
{ {
@ -67,11 +68,22 @@ static void my_finder_init(MyFinder *self)
self->labelhelp = gtk_label_new("Help"); self->labelhelp = gtk_label_new("Help");
self->time_label = gtk_label_new("2023/6/9 22:29:00"); self->time_label = gtk_label_new("2023/6/9 22:29:00");
self->separator = gtk_label_new(" "); self->separator = gtk_label_new(" ");
self->find_button = gtk_button_new_from_icon_name("finder-find"); if (get_dark_mode(self))
self->screen_button = gtk_button_new_from_icon_name("finder-computer"); {
self->battery_button = gtk_button_new_from_icon_name("finder-battery"); self->find_button = gtk_button_new_from_icon_name("finder-find-dark");
self->audio_button = gtk_button_new_from_icon_name("finder_audio"); self->screen_button = gtk_button_new_from_icon_name("finder-computer-dark");
self->network_button = gtk_button_new_from_icon_name("finder-wifi"); self->battery_button = gtk_button_new_from_icon_name("finder-battery-dark");
self->audio_button = gtk_button_new_from_icon_name("finder_audio-dark");
self->network_button = gtk_button_new_from_icon_name("finder-wifi-dark");
}
else
{
self->find_button = gtk_button_new_from_icon_name("finder-find");
self->screen_button = gtk_button_new_from_icon_name("finder-computer");
self->battery_button = gtk_button_new_from_icon_name("finder-battery");
self->audio_button = gtk_button_new_from_icon_name("finder_audio");
self->network_button = gtk_button_new_from_icon_name("finder-wifi");
}
self->menu_button = gtk_button_new_from_icon_name("open-menu"); self->menu_button = gtk_button_new_from_icon_name("open-menu");
gtk_widget_set_hexpand(self->separator, TRUE); gtk_widget_set_hexpand(self->separator, TRUE);
gtk_widget_set_halign(self->separator, GTK_ALIGN_FILL); gtk_widget_set_halign(self->separator, GTK_ALIGN_FILL);
@ -157,3 +169,27 @@ GtkWidget *my_finder_new(GtkOrientation orientation, int spacing)
return GTK_WIDGET(g_object_new(my_finder_get_type(), return GTK_WIDGET(g_object_new(my_finder_get_type(),
"orientation", orientation, "spacing", spacing, NULL)); "orientation", orientation, "spacing", spacing, NULL));
} }
gboolean get_dark_mode(gpointer self)
{
GtkIconTheme *theme = gtk_icon_theme_get_for_display(
gtk_widget_get_display(GTK_WIDGET(self)));
char *theme_name = gtk_icon_theme_get_theme_name(theme);
// Get Last 4 chars
char tmp_str[5] = {0};
for (int i = 0; i < 4; i++)
{
tmp_str[i] = tolower(theme_name[strlen(theme_name) - 4 + i]);
}
g_free(theme_name);
// g_print("%s", tmp_str);
if (strncmp(tmp_str, "dark", 4) == 0)
{
return TRUE;
}
else
{
return FALSE;
}
}

View File

@ -7,3 +7,5 @@ G_DECLARE_FINAL_TYPE(MyFinder, my_finder, MY, FINDER, GtkBox)
GtkWidget *my_finder_new(GtkOrientation orientation, int spacing); GtkWidget *my_finder_new(GtkOrientation orientation, int spacing);
void my_finder_add_style(MyFinder *finder, GtkCssProvider *provider); void my_finder_add_style(MyFinder *finder, GtkCssProvider *provider);
gboolean get_dark_mode(gpointer self);