diff options
-rw-r--r-- | preload.c | 5 | ||||
-rw-r--r-- | preload.h | 2 | ||||
-rw-r--r-- | wallpapers.c | 7 | ||||
-rw-r--r-- | wallpapers.h | 2 | ||||
-rw-r--r-- | walls_conf.c | 12 | ||||
-rw-r--r-- | walls_conf.h | 11 | ||||
-rw-r--r-- | window_config.c | 20 | ||||
-rw-r--r-- | window_main.c | 3 |
8 files changed, 33 insertions, 29 deletions
@@ -6,8 +6,6 @@ #include "wallpapers.h" #include "walls_conf.h" -guint preload_max = 2; - static gboolean preload_thread_exit = FALSE; static GHashTable *hashtable = NULL; static GMutex *preload_hashtable_mutex = NULL, *preload_thread_mutex = NULL; @@ -34,7 +32,6 @@ static void preload_hash_table_free(gpointer data) { } void preload_init() { - preload_max = conf_get_int("walls", "max_preload", 2); preload_hashtable_mutex = g_mutex_new(); preload_thread_mutex = g_mutex_new(); @@ -106,7 +103,7 @@ static GArray *preload_prepare_data(GtkWidget *thumbview) { g_array_append_val(array, filename); } - for(gint i = 0; i < preload_max; i++) { + for(gint i = 0; i < config.max_preload; i++) { /* Make sure the selected pixbuf is also preloaded. */ if(array->len == 0 && gtk_tree_model_get_iter(model, &iter, sel_path)) { gtk_tree_model_get_value(model, &iter, 1, &value); @@ -18,6 +18,4 @@ void preload_clear(); void preload_clear_sized(); gpointer preload_get(const gchar*); -extern guint preload_max; - #endif diff --git a/wallpapers.c b/wallpapers.c index bc907d5..b5c7994 100644 --- a/wallpapers.c +++ b/wallpapers.c @@ -12,8 +12,7 @@ #include <gdk-pixbuf/gdk-pixbuf.h> #include "wallpapers.h" - -GdkInterpType interp_type = GDK_INTERP_NEAREST; +#include "walls_conf.h" gboolean wallpapers_add_dir(const gchar *path, sqlite_uint64 parent, GtkStatusbar *statusbar, gboolean recursive ) { static guint context_id = 0; @@ -212,7 +211,7 @@ GdkPixbuf *resize_pixbuf(GdkPixbuf *orig, gint win_width, gint win_height, gint } if(width == 0 || height == 0) return NULL; pb = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height); - gdk_pixbuf_scale(orig, pb, 0, 0, width, height, 0, 0, scalex, scaley, interp_type); + gdk_pixbuf_scale(orig, pb, 0, 0, width, height, 0, 0, scalex, scaley, config.interp_type); } else { width = img_width; height = img_height; @@ -237,6 +236,6 @@ GdkPixbuf *zoom_pixbuf(GdkPixbuf *orig, gdouble zoom) { height = img_height * zoom; pb = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height); gdk_pixbuf_scale(orig, pb, 0, 0, width, height, 0, 0, - (gdouble)width / (gdouble)img_width, (gdouble)height / (gdouble)img_height, interp_type); + (gdouble)width / (gdouble)img_width, (gdouble)height / (gdouble)img_height, config.interp_type); return pb; } diff --git a/wallpapers.h b/wallpapers.h index 38384a0..fc575b3 100644 --- a/wallpapers.h +++ b/wallpapers.h @@ -11,6 +11,4 @@ void wallpapers_remove_missing(struct directory_t*, GtkStatusbar*, gboolean); GdkPixbuf *resize_pixbuf(GdkPixbuf*, gint, gint, gint*, gint*, gdouble*); GdkPixbuf *zoom_pixbuf(GdkPixbuf*, gdouble); -extern GdkInterpType interp_type; - #endif diff --git a/walls_conf.c b/walls_conf.c index 7b31d13..812fe98 100644 --- a/walls_conf.c +++ b/walls_conf.c @@ -3,6 +3,8 @@ #include <glib/gstdio.h> #include "walls_conf.h" +struct walls_config_t config; + GKeyFile *keyfile = NULL; void conf_open() { @@ -63,3 +65,13 @@ void conf_close() { keyfile = NULL; } } + +void conf_load() { + config.interp_type = conf_get_int("walls", "interpolation_mode", GDK_INTERP_NEAREST); + config.max_preload = conf_get_int("walls", "max_preload", 2); +} + +void conf_save() { + g_key_file_set_integer(keyfile, "walls", "interpolation_mode", config.interp_type); + g_key_file_set_integer(keyfile, "walls", "max_preload", config.max_preload); +} diff --git a/walls_conf.h b/walls_conf.h index f0f7859..59f6af4 100644 --- a/walls_conf.h +++ b/walls_conf.h @@ -2,11 +2,22 @@ #define _WALLS_CONF_H_ #include <glib.h> +#include <gdk-pixbuf/gdk-pixbuf.h> + +struct walls_config_t { + GdkInterpType interp_type; + gint max_preload; +}; + +extern struct walls_config_t config; void conf_open(); void conf_close(); gint conf_get_int(const gchar*, const gchar*, gint); +void conf_load(); +void conf_save(); + extern GKeyFile *keyfile; #endif diff --git a/window_config.c b/window_config.c index a8de897..ba3f6b2 100644 --- a/window_config.c +++ b/window_config.c @@ -15,9 +15,6 @@ struct window_config_t *window_config_new(GtkWindow *parent) { GtkCellRenderer *cell; struct window_config_t *wct; - int interp_mode = conf_get_int("walls", "interpolation_mode", GDK_INTERP_NEAREST); - int max_preload = conf_get_int("walls", "max_preload", 2); - builder = gtk_builder_new(); if(!gtk_builder_add_from_string(builder, config_ui_string, -1, &error)) { g_warning("%s", error->message); @@ -47,7 +44,7 @@ struct window_config_t *window_config_new(GtkWindow *parent) { gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(interp_combo), cell, TRUE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(interp_combo), cell, "text", 0, NULL); - switch(interp_mode) { + switch(config.interp_type) { case GDK_INTERP_TILES: gtk_combo_box_set_active(interp_combo, 1); break; @@ -62,7 +59,7 @@ struct window_config_t *window_config_new(GtkWindow *parent) { } preload_scale = GTK_HSCALE(gtk_builder_get_object(builder, "preload_scale")); - gtk_range_set_value(GTK_RANGE(preload_scale), max_preload); + gtk_range_set_value(GTK_RANGE(preload_scale), config.max_preload); dialog = GTK_DIALOG(gtk_builder_get_object(builder, "config_dialog")); gtk_window_set_transient_for(GTK_WINDOW(dialog), parent); @@ -80,21 +77,14 @@ struct window_config_t *window_config_new(GtkWindow *parent) { void window_config_save(struct window_config_t *wct) { GValue value = {0}; - int interp_mode = GDK_INTERP_NEAREST; - int max_preload = 2; - GtkListStore *liststore = GTK_LIST_STORE(gtk_combo_box_get_model(wct->interp_combo)); GtkTreeIter iter; gtk_combo_box_get_active_iter(wct->interp_combo, &iter); gtk_tree_model_get_value(GTK_TREE_MODEL(liststore), &iter, 1, &value); - interp_mode = g_value_get_int(&value); + config.interp_type = g_value_get_int(&value); g_value_unset(&value); - max_preload = gtk_range_get_value(wct->preload_scale); - - g_key_file_set_integer(keyfile, "walls", "interpolation_mode", interp_mode); - interp_type = interp_mode; + config.max_preload = gtk_range_get_value(wct->preload_scale); - g_key_file_set_integer(keyfile, "walls", "max_preload", max_preload); - preload_max = max_preload; + conf_save(); } diff --git a/window_main.c b/window_main.c index 3262ba9..e5cd3b7 100644 --- a/window_main.c +++ b/window_main.c @@ -1086,8 +1086,6 @@ static void set_sizes() { gtk_paned_set_position(GTK_PANED(window_hpane), hpane_pos); gtk_paned_set_position(GTK_PANED(window_vpane), vpane_pos); - - interp_type = conf_get_int("walls", "interpolation_mode", interp_type); } int gui_main(int argc, char **argv) { @@ -1151,6 +1149,7 @@ int gui_main(int argc, char **argv) { gtk_widget_show_all(GTK_WIDGET(window)); preload_init(); + conf_load(); gdk_threads_enter(); gtk_main(); |