tint2conf: force refresh fix
o9000 mrovi9000@gmail.com
3 files changed,
41 insertions(+),
5 deletions(-)
M
src/tint2conf/main.c
→
src/tint2conf/main.c
@@ -167,6 +167,7 @@ static void viewRowActivated(GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data);
static void select_first_theme(); static void load_all_themes(); +static void reload_all_themes(); // ====== Globals ======@@ -256,7 +257,7 @@ {"ThemeReset", GTK_STOCK_REVERT_TO_SAVED, _("_Reset"), NULL, _("Reset the selected theme to default"), G_CALLBACK(menuReset)},
{"ThemeEdit", GTK_STOCK_PROPERTIES, _("_Edit theme..."), NULL, _("Edit the selected theme"), G_CALLBACK(edit_theme)}, {"ThemeMakeDefault", GTK_STOCK_APPLY, _("_Make default"), NULL, _("Replace the default theme with the selected one"), G_CALLBACK(make_selected_theme_default)}, {"ThemeRefresh", GTK_STOCK_REFRESH, _("Refresh"), NULL, _("Redraw the selected theme"), G_CALLBACK(refresh_current_theme)}, - {"RefreshAll", GTK_STOCK_REFRESH, _("Refresh all"), NULL, _("Redraw all themes"), G_CALLBACK(load_all_themes)}, + {"RefreshAll", GTK_STOCK_REFRESH, _("Refresh all"), NULL, _("Redraw all themes"), G_CALLBACK(reload_all_themes)}, {"Quit", GTK_STOCK_QUIT, _("_Quit"), "<control>Q", _("Quit"), G_CALLBACK(gtk_main_quit)}, {"HelpMenu", NULL, _("_Help"), NULL, NULL, NULL}, {"HelpAbout", GTK_STOCK_ABOUT, _("_About"), "<Control>A", _("About"), G_CALLBACK(menuAbout)}};@@ -830,6 +831,37 @@ model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view));
have_iter = gtk_tree_model_get_iter_first(model, &iter); while (have_iter) { gtk_list_store_set(theme_list_store, &iter, COL_SNAPSHOT, NULL, -1); + have_iter = gtk_tree_model_iter_next(model, &iter); + } + + g_timeout_add(SNAPSHOT_TICK, (GSourceFunc)update_snapshot, NULL); + } +} + +static void reload_all_themes() +{ + ensure_default_theme_exists(); + + gtk_list_store_clear(GTK_LIST_STORE(theme_list_store)); + theme_selection_changed(NULL, NULL); + + gboolean found_themes = FALSE; + if (load_user_themes()) + found_themes = TRUE; + if (load_system_themes()) + found_themes = TRUE; + + if (found_themes) { + select_first_theme(); + + GtkTreeIter iter; + GtkTreeModel *model; + gboolean have_iter; + + model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view)); + have_iter = gtk_tree_model_get_iter_first(model, &iter); + while (have_iter) { + gtk_list_store_set(theme_list_store, &iter, COL_SNAPSHOT, NULL, COL_FORCE_REFRESH, TRUE, -1); have_iter = gtk_tree_model_iter_next(model, &iter); }
M
src/tint2conf/theme_view.c
→
src/tint2conf/theme_view.c
@@ -38,7 +38,7 @@ GtkTreeViewColumn *col;
GtkCellRenderer *renderer; theme_list_store = - gtk_list_store_new(NB_COL, G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_INT, G_TYPE_INT); + gtk_list_store_new(NB_COL, G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_INT, G_TYPE_INT, G_TYPE_BOOLEAN); GtkWidget *view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(theme_list_store)); gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE);@@ -148,7 +148,7 @@ 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); + gtk_list_store_set(theme_list_store, &iter, COL_THEME_FILE, path, COL_THEME_NAME, display_name, COL_FORCE_REFRESH, FALSE, -1); g_free(display_name); g_free(suffix); }@@ -183,14 +183,15 @@ continue;
} gchar *path; - gtk_tree_model_get(model, &iter, COL_THEME_FILE, &path, -1); + gboolean force_refresh; + gtk_tree_model_get(model, &iter, COL_THEME_FILE, &path, COL_FORCE_REFRESH, &force_refresh, -1); char hash[MD4_HEX_SIZE + 4]; md4hexf(path, hash); strcat(hash, ".png"); gchar *snap = g_build_filename(g_get_user_cache_dir(), "tint2", hash, NULL); - pixbuf = gdk_pixbuf_new_from_file(snap, NULL); + pixbuf = force_refresh ? NULL : gdk_pixbuf_new_from_file(snap, NULL); if (!pixbuf) { gchar *cmd = g_strdup_printf("tint2 -c \'%s\' -s \'%s\' 1>/dev/null 2>/dev/null", path, snap); num_updates++;@@ -216,6 +217,8 @@ COL_WIDTH,
gdk_pixbuf_get_width(pixbuf) + PADDING, COL_HEIGHT, gdk_pixbuf_get_height(pixbuf) + PADDING, + COL_FORCE_REFRESH, + FALSE, -1); if (pixbuf) g_object_unref(pixbuf);
M
src/tint2conf/theme_view.h
→
src/tint2conf/theme_view.h
@@ -10,6 +10,7 @@ COL_THEME_NAME,
COL_SNAPSHOT, COL_WIDTH, COL_HEIGHT, + COL_FORCE_REFRESH, NB_COL, }; GtkWidget *create_view();