From 3e03e81dbf3beeef3ccf564a896d65feba3e5900 Mon Sep 17 00:00:00 2001 From: o9000 Date: Thu, 24 Mar 2016 23:20:00 +0100 Subject: [PATCH] tint2conf: Display themes consistently --- ChangeLog | 6 +++++- src/tint2conf/main.c | 8 ++++---- src/tint2conf/theme_view.c | 16 +++++++++------- src/tint2conf/theme_view.h | 2 +- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4a5bdac..23e80c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,7 +5,11 @@ - Tint2conf GUI improvements - Config options with changed behavior: - The launcher now also allows launcher_item_app entries without a full path. - In this case the .desktop file is searched in the standard application directories. + In this case the .desktop file is searched in the standard application directories (issue #565). + - If the panel size is given as a percentage and a non-zero margin is also specified, + the size is now computed as a fraction of the available size (i.e. monitor size - margin). + Before it was computed as a fraction of the monitor size first, then the margin was subtracted from the value, which + was not intuitive (issue #559). - Fixes: - Taskbar icons are now resized correctly for certain geometries (issue #560) - Fix get_version.sh so that it returns the correct version when .git is missing diff --git a/src/tint2conf/main.c b/src/tint2conf/main.c index 5d26d8e..1a29498 100644 --- a/src/tint2conf/main.c +++ b/src/tint2conf/main.c @@ -117,7 +117,7 @@ gchar *import_no_overwrite(const char *filepath) gchar *newpath = g_build_filename(g_get_user_config_dir(), "tint2", filename, NULL); if (!g_file_test(newpath, G_FILE_TEST_EXISTS)) { copy_file(filepath, newpath); - theme_list_append(newpath, NULL); + theme_list_append(newpath); g_timeout_add(SNAPSHOT_TICK, (GSourceFunc)update_snapshot, NULL); } @@ -136,7 +136,7 @@ void import_with_overwrite(const char *filepath, const char *newpath) if (theme_is_editable(newpath)) { if (!theme_existed) { - theme_list_append(newpath, NULL); + theme_list_append(newpath); g_timeout_add(SNAPSHOT_TICK, (GSourceFunc)update_snapshot, NULL); } else { int unused = system("killall -SIGUSR1 tint2 || pkill -SIGUSR1 -x tint2"); @@ -708,7 +708,7 @@ static gboolean load_user_themes() !strstr(file_name, "~") && (endswith(file_name, "tint2rc") || endswith(file_name, ".conf"))) { found_theme = TRUE; gchar *path = g_build_filename(tint2_config_dir, file_name, NULL); - theme_list_append(path, NULL); + theme_list_append(path); g_free(path); } } @@ -732,7 +732,7 @@ static gboolean load_themes_from_dirs(const gchar *const *dirs) (endswith(file_name, "tint2rc") || endswith(file_name, ".conf"))) { found_theme = TRUE; gchar *path = g_build_filename(path_tint2, file_name, NULL); - theme_list_append(path, dirs[i]); + theme_list_append(path); g_free(path); } } diff --git a/src/tint2conf/theme_view.c b/src/tint2conf/theme_view.c index 5c0d5d2..5f7e2c8 100644 --- a/src/tint2conf/theme_view.c +++ b/src/tint2conf/theme_view.c @@ -20,6 +20,7 @@ #include "main.h" #include "strnatcmp.h" #include "theme_view.h" +#include "common.h" // The data columns that we export via the tree model interface GtkWidget *g_theme_view; @@ -136,7 +137,7 @@ gboolean theme_list_contains(const char *given_path) return FALSE; } -void theme_list_append(const gchar *path, const gchar *suffix) +void theme_list_append(const gchar *path) { if (theme_list_contains(path)) return; @@ -146,14 +147,15 @@ void theme_list_append(const gchar *path, const gchar *suffix) gchar *name = strrchr(path, '/') + 1; - gchar *display_name; - if (suffix) { - display_name = g_strdup_printf("%s\n(%s)", name, suffix); - } else { - display_name = g_strdup(name); - } + gchar *dir = g_strdup(path); + strrchr(dir, '/')[0] = 0; + char *suffix = contract_tilde(dir); + g_free(dir); + + gchar *display_name = g_strdup_printf("%s\n(%s)", name, suffix); gtk_list_store_set(theme_list_store, &iter, COL_THEME_FILE, path, COL_THEME_NAME, display_name, -1); g_free(display_name); + g_free(suffix); } diff --git a/src/tint2conf/theme_view.h b/src/tint2conf/theme_view.h index 674f29e..9b61790 100644 --- a/src/tint2conf/theme_view.h +++ b/src/tint2conf/theme_view.h @@ -9,6 +9,6 @@ enum { COL_THEME_FILE = 0, COL_THEME_NAME, COL_SNAPSHOT, NB_COL, }; GtkWidget *create_view(); -void theme_list_append(const gchar *path, const gchar *suffix); +void theme_list_append(const gchar *path); #endif