tint2conf: force refresh fix
This commit is contained in:
parent
e833b27533
commit
3c9642c5fc
3 changed files with 41 additions and 5 deletions
|
@ -167,6 +167,7 @@ static void viewRowActivated(GtkTreeView *tree_view, GtkTreePath *path, GtkTreeV
|
|||
|
||||
static void select_first_theme();
|
||||
static void load_all_themes();
|
||||
static void reload_all_themes();
|
||||
|
||||
// ====== Globals ======
|
||||
|
||||
|
@ -256,7 +257,7 @@ int main(int argc, char **argv)
|
|||
{"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)}};
|
||||
|
@ -837,6 +838,37 @@ static void load_all_themes()
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
g_timeout_add(SNAPSHOT_TICK, (GSourceFunc)update_snapshot, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void load_specific_themes(char **paths, int count)
|
||||
{
|
||||
ensure_default_theme_exists();
|
||||
|
|
|
@ -38,7 +38,7 @@ GtkWidget *create_view()
|
|||
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 @@ void theme_list_append(const gchar *path)
|
|||
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 @@ gboolean update_snapshot()
|
|||
}
|
||||
|
||||
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 @@ gboolean update_snapshot()
|
|||
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);
|
||||
|
|
|
@ -10,6 +10,7 @@ enum { COL_THEME_FILE = 0,
|
|||
COL_SNAPSHOT,
|
||||
COL_WIDTH,
|
||||
COL_HEIGHT,
|
||||
COL_FORCE_REFRESH,
|
||||
NB_COL, };
|
||||
|
||||
GtkWidget *create_view();
|
||||
|
|
Loading…
Reference in a new issue