From fd39c4052a9b6476967cf34767d2a0e13c71c02c Mon Sep 17 00:00:00 2001 From: jszczerbinsky Date: Sat, 17 Feb 2024 13:49:00 +0000 Subject: [PATCH] New window template --- src/core/main.c | 38 +- src/core/windowHandlers.c | 4 +- .../assets/cross-close-svgrepo-com.svg | 7 + .../assets/github-svgrepo-com.svg | 7 + .../assets/image-photo-svgrepo-com.svg | 7 + .../assets/question-svgrepo-com.svg | 7 + .../assets/screen-monitor-svgrepo-com.svg | 7 + .../assets/settings-svgrepo-com.svg | 10 + src/window_templates/main.glade | 446 ++++++++++++++---- 9 files changed, 445 insertions(+), 88 deletions(-) create mode 100644 src/window_templates/assets/cross-close-svgrepo-com.svg create mode 100644 src/window_templates/assets/github-svgrepo-com.svg create mode 100644 src/window_templates/assets/image-photo-svgrepo-com.svg create mode 100644 src/window_templates/assets/question-svgrepo-com.svg create mode 100644 src/window_templates/assets/screen-monitor-svgrepo-com.svg create mode 100644 src/window_templates/assets/settings-svgrepo-com.svg diff --git a/src/core/main.c b/src/core/main.c index e50d34f..8121afb 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -40,6 +40,17 @@ static void reloadMonitorListBox() g_list_free(rows); + char iconPath[PATH_MAX]; + getAppDir(iconPath, APP_DIR_SHARE); +#ifdef __WIN32 + const char *format = "%s\\%s\\%s\\%s"; +#else + const char *format = "%s/%s/%s/%s"; +#endif + sprintf( + iconPath, format, iconPath, "window_templates", "assets", "screen-monitor-svgrepo-com.svg" + ); + int monitorsCount; MonitorInfo *monitors; @@ -47,11 +58,32 @@ static void reloadMonitorListBox() for (int i = 0; i < monitorsCount; i++) { - GtkWidget *label = gtk_label_new(monitors[i].name); - GtkWidget *row = gtk_list_box_row_new(); - gtk_container_add(GTK_CONTAINER(row), label); + char resStr[12]; + sprintf(resStr, "%dx%d", monitors[i].bounds.w, monitors[i].bounds.h); + + GtkWidget *nameLabel = gtk_label_new(monitors[i].name); + GtkWidget *resLabel = gtk_label_new(resStr); + GtkWidget *icon = gtk_image_new_from_file(iconPath); + + GtkWidget *labelBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + gtk_container_add(GTK_CONTAINER(labelBox), nameLabel); + gtk_container_add(GTK_CONTAINER(labelBox), resLabel); + gtk_box_set_child_packing(GTK_BOX(labelBox), nameLabel, 1, 1, 0, GTK_PACK_START); + + GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_container_add(GTK_CONTAINER(box), icon); + gtk_container_add(GTK_CONTAINER(box), labelBox); + gtk_box_set_child_packing(GTK_BOX(box), labelBox, 1, 1, 0, GTK_PACK_START); + + GtkWidget *row = gtk_list_box_row_new(); + gtk_container_add(GTK_CONTAINER(row), box); gtk_list_box_insert(GTK_LIST_BOX(monitorListBox), row, 0); + + char *nameBuff = malloc(sizeof(strlen(monitors[i].name))); + strcpy(nameBuff, monitors[i].name); + g_object_set_data(G_OBJECT(row), "monitor_name", (gpointer)nameBuff); + gtk_widget_show_all(row); } } diff --git a/src/core/windowHandlers.c b/src/core/windowHandlers.c index bba23ab..4e58732 100644 --- a/src/core/windowHandlers.c +++ b/src/core/windowHandlers.c @@ -71,10 +71,8 @@ G_MODULE_EXPORT void MonitorWindowShow() // Find selected monitor name GtkListBoxRow *listBoxRow = gtk_list_box_get_selected_row(GTK_LIST_BOX(monitorListBox)); - GList *children = gtk_container_get_children(GTK_CONTAINER(listBoxRow)); - const char *monitorName = gtk_label_get_label(GTK_LABEL(children->data)); + const char *monitorName = g_object_get_data(G_OBJECT(listBoxRow), "monitor_name"); gtk_label_set_text(GTK_LABEL(monitorNameLabel), monitorName); - g_list_free(children); // Read configuration from config file MonitorConfig mc; diff --git a/src/window_templates/assets/cross-close-svgrepo-com.svg b/src/window_templates/assets/cross-close-svgrepo-com.svg new file mode 100644 index 0000000..a2846fe --- /dev/null +++ b/src/window_templates/assets/cross-close-svgrepo-com.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/window_templates/assets/github-svgrepo-com.svg b/src/window_templates/assets/github-svgrepo-com.svg new file mode 100644 index 0000000..c0a813f --- /dev/null +++ b/src/window_templates/assets/github-svgrepo-com.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/window_templates/assets/image-photo-svgrepo-com.svg b/src/window_templates/assets/image-photo-svgrepo-com.svg new file mode 100644 index 0000000..a924c43 --- /dev/null +++ b/src/window_templates/assets/image-photo-svgrepo-com.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/window_templates/assets/question-svgrepo-com.svg b/src/window_templates/assets/question-svgrepo-com.svg new file mode 100644 index 0000000..b29ae56 --- /dev/null +++ b/src/window_templates/assets/question-svgrepo-com.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/window_templates/assets/screen-monitor-svgrepo-com.svg b/src/window_templates/assets/screen-monitor-svgrepo-com.svg new file mode 100644 index 0000000..439637c --- /dev/null +++ b/src/window_templates/assets/screen-monitor-svgrepo-com.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/window_templates/assets/settings-svgrepo-com.svg b/src/window_templates/assets/settings-svgrepo-com.svg new file mode 100644 index 0000000..be067f1 --- /dev/null +++ b/src/window_templates/assets/settings-svgrepo-com.svg @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/window_templates/main.glade b/src/window_templates/main.glade index e91fcd9..c7c666d 100644 --- a/src/window_templates/main.glade +++ b/src/window_templates/main.glade @@ -2,9 +2,14 @@ + False + Closing Layered WallPaper False + 480 + 100 + assets/question-svgrepo-com.svg dialog False @@ -53,13 +58,36 @@ - + True False - Are you sure, you want to exit Layered WallPaper? + + + True + False + assets/question-svgrepo-com.svg + + + False + True + 0 + + + + + True + False + Are you sure, you want to close Layered WallPaper? + + + False + True + 1 + + - False + True True 1 @@ -74,6 +102,7 @@ False + Layered WallPaper Settings False 800 600 @@ -82,6 +111,8 @@ True False + 40 + 40 vertical @@ -98,6 +129,7 @@ center + @@ -112,6 +144,9 @@ False Enhance your desktop experiance center + + + False @@ -130,54 +165,306 @@ True False - 120 - 120 - 8 - vertical + 30 - + True False - 5 - 5 - Setup your monitors - - - + 40 + 40 + vertical + + + True + False + 5 + 15 + Setup your monitors + + + + + + False + True + 0 + + + + + True + False + + + True + True + + + True + False + + + True + False + 10 + assets/screen-monitor-svgrepo-com.svg + 6 + + + False + True + 0 + + + + + True + False + vertical + + + True + False + HDMI-1 + + + True + True + 0 + + + + + True + False + 1920x1080 + + + False + True + 1 + + + + + True + True + 1 + + + + + + + + + True + True + + + True + False + + + True + False + 10 + assets/screen-monitor-svgrepo-com.svg + 6 + + + False + True + 0 + + + + + True + False + vertical + + + True + False + HDMI-1 + + + + + + True + True + 0 + + + + + True + False + 1920x1080 + + + False + True + 1 + + + + + True + True + 1 + + + + + + + + + False + True + 1 + + + + + Edit settings + True + True + True + 10 + + + + False + True + 2 + + - False + True True 0 - + True False - 40 - 40 + center + vertical + 10 + + + True + True + True + + + + True + False + vertical + True + + + True + False + 20 + assets/image-photo-svgrepo-com.svg + 6 + + + True + True + 0 + + + + + True + False + Manage +wallpapers + center + + + False + True + end + 1 + + + + + + + False + True + 0 + + + + + True + True + True + + + + True + False + vertical + True + + + True + False + 20 + assets/cross-close-svgrepo-com.svg + 6 + + + True + True + 0 + + + + + True + False + Turn off +Layered WallPaper + center + + + False + True + end + 1 + + + + + + + False + True + 1 + + False True + end 1 - - - Edit settings - True - True - True - - - - False - True - 2 - - True @@ -189,6 +476,7 @@ True False + 20 True @@ -215,7 +503,7 @@ False True end - 2 + 1 @@ -226,52 +514,15 @@ 2 - - - True - False - center - - - Manage wallpapers - True - True - True - - - - False - True - 0 - - - - - Exit - True - True - True - - - - False - True - end - 1 - - - - - False - True - 3 - - False + Wallpaper Manager + 800 + 600 + assets/image-photo-svgrepo-com.svg @@ -368,6 +619,10 @@ False + Monitor Settings + 600 + 260 + assets/settings-svgrepo-com.svg @@ -376,16 +631,40 @@ False vertical - + True False - 10 - 10 - Monitor name - center - - - + center + + + True + False + assets/screen-monitor-svgrepo-com.svg + + + False + True + 0 + + + + + True + False + 10 + 10 + Monitor name + center + + + + + + False + True + 1 + + False @@ -538,6 +817,9 @@ False center 20 + 20 + 50 + True Apply