Mercurial > audlegacy-plugins
changeset 2583:294232665cb0
more work on config
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Tue, 20 May 2008 16:34:06 +0200 |
parents | 9b4dfc007b87 |
children | c9e40418a74c |
files | src/skins/skins_cfg.c src/skins/skins_cfg.h src/skins/ui_dock.c |
diffstat | 3 files changed, 117 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/skins/skins_cfg.c Tue May 20 15:36:47 2008 +0200 +++ b/src/skins/skins_cfg.c Tue May 20 16:34:06 2008 +0200 @@ -21,6 +21,7 @@ #include "skins_cfg.h" #include "ui_skin.h" +#include "ui_vis.h" #include <glib.h> #include <stdlib.h> #include <audacious/plugin.h> @@ -39,6 +40,31 @@ .dim_titlebar = TRUE, .show_wm_decorations = FALSE, .easy_move = TRUE, + .timer_mode = 0, + .vis_type = VIS_ANALYZER, + .analyzer_mode = ANALYZER_NORMAL, + .analyzer_type = ANALYZER_BARS, + .scope_mode = SCOPE_DOT, + .voiceprint_mode = VOICEPRINT_NORMAL, + .vu_mode = VU_SMOOTH, + .vis_refresh = REFRESH_FULL, + .analyzer_falloff = FALLOFF_FAST, + .peaks_falloff = FALLOFF_SLOW, + .player_x = MAINWIN_DEFAULT_POS_X, + .player_y = MAINWIN_DEFAULT_POS_Y, + .equalizer_x = EQUALIZER_DEFAULT_POS_X, + .equalizer_y = EQUALIZER_DEFAULT_POS_Y, + .playlist_x = PLAYLISTWIN_DEFAULT_POS_X, + .playlist_y = PLAYLISTWIN_DEFAULT_POS_Y, + .playlist_width = PLAYLISTWIN_DEFAULT_WIDTH, + .playlist_height = PLAYLISTWIN_DEFAULT_HEIGHT, + .playlist_position = 0, + .mouse_change = 8, /* mouse wheel scroll step */ + .scroll_pl_by = 3, + .colorize_r = 255, .colorize_g = 255, .colorize_b = 255, + .snap_distance = 10, + .snap_windows = TRUE, + .save_window_position = TRUE, }; typedef struct skins_cfg_boolent_t { @@ -58,10 +84,48 @@ {"dim_titlebar", &config.dim_titlebar, TRUE}, {"show_wm_decorations", &config.show_wm_decorations, TRUE}, {"easy_move", &config.easy_move, TRUE}, + {"snap_windows", &config.snap_windows, TRUE}, + {"save_window_positions", &config.save_window_position, TRUE}, }; static gint ncfgbent = G_N_ELEMENTS(skins_boolents); +typedef struct skins_cfg_nument_t { + char const *ie_vname; + gint *ie_vloc; + gboolean ie_wrt; +} skins_cfg_nument; + +static skins_cfg_nument skins_numents[] = { + {"player_x", &config.player_x, TRUE}, + {"player_y", &config.player_y, TRUE}, + {"timer_mode", &config.timer_mode, TRUE}, + {"vis_type", &config.vis_type, TRUE}, + {"analyzer_mode", &config.analyzer_mode, TRUE}, + {"analyzer_type", &config.analyzer_type, TRUE}, + {"scope_mode", &config.scope_mode, TRUE}, + {"vu_mode", &config.vu_mode, TRUE}, + {"voiceprint_mode", &config.voiceprint_mode, TRUE}, + {"vis_refresh_rate", &config.vis_refresh, TRUE}, + {"analyzer_falloff", &config.analyzer_falloff, TRUE}, + {"peaks_falloff", &config.peaks_falloff, TRUE}, + {"playlist_x", &config.playlist_x, TRUE}, + {"playlist_y", &config.playlist_y, TRUE}, + {"playlist_width", &config.playlist_width, TRUE}, + {"playlist_height", &config.playlist_height, TRUE}, + {"playlist_position", &config.playlist_position, TRUE}, + {"equalizer_x", &config.equalizer_x, TRUE}, + {"equalizer_y", &config.equalizer_y, TRUE}, + {"mouse_wheel_change", &config.mouse_change, TRUE}, + {"scroll_pl_by", &config.scroll_pl_by, TRUE}, + {"colorize_r", &config.colorize_r, TRUE}, + {"colorize_g", &config.colorize_g, TRUE}, + {"colorize_b", &config.colorize_b, TRUE}, + {"snap_distance", &config.snap_distance, TRUE}, +}; + +static gint ncfgient = G_N_ELEMENTS(skins_numents); + void skins_cfg_free() { if (config.skin) { g_free(config.skin); config.skin = NULL; } } @@ -85,6 +149,12 @@ skins_boolents[i].be_vname, skins_boolents[i].be_vloc); } + + for (i = 0; i < ncfgient; ++i) { + aud_cfg_db_get_int(cfgfile, "skins", + skins_numents[i].ie_vname, + skins_numents[i].ie_vloc); + } if (!aud_cfg_db_get_string(cfgfile, "skins", "skin", &(config.skin))) config.skin = g_strdup(BMP_DEFAULT_SKIN_PATH); @@ -114,5 +184,11 @@ skins_boolents[i].be_vname, *skins_boolents[i].be_vloc); + for (i = 0; i < ncfgient; ++i) + if (skins_numents[i].ie_wrt) + aud_cfg_db_set_int(cfgfile, "skins", + skins_numents[i].ie_vname, + *skins_numents[i].ie_vloc); + aud_cfg_db_close(cfgfile); }
--- a/src/skins/skins_cfg.h Tue May 20 15:36:47 2008 +0200 +++ b/src/skins/skins_cfg.h Tue May 20 16:34:06 2008 +0200 @@ -23,8 +23,23 @@ #include <glib.h> +#define MAINWIN_DEFAULT_POS_X 20 +#define MAINWIN_DEFAULT_POS_Y 20 +#define EQUALIZER_DEFAULT_POS_X 20 +#define EQUALIZER_DEFAULT_POS_Y 136 +#define PLAYLISTWIN_DEFAULT_WIDTH 275 +#define PLAYLISTWIN_DEFAULT_HEIGHT 232 +#define PLAYLISTWIN_DEFAULT_POS_X 295 +#define PLAYLISTWIN_DEFAULT_POS_Y 20 + typedef struct { + gint player_x, player_y; + gint equalizer_x, equalizer_y; + gint playlist_x, playlist_y; + gint playlist_width, playlist_height; + gint snap_distance; + gboolean snap_windows, save_window_position; gboolean scaled; gboolean always_on_top; gfloat scale_factor; @@ -34,6 +49,17 @@ gboolean dim_titlebar; gboolean show_wm_decorations; gboolean easy_move; + gint timer_mode; + gint vis_type; + gint analyzer_mode, analyzer_type; + gint scope_mode; + gint voiceprint_mode; + gint vu_mode, vis_refresh; + gint analyzer_falloff, peaks_falloff; + gint playlist_position; + gint mouse_change; + gint colorize_r; gint colorize_g; gint colorize_b; + gint scroll_pl_by; } skins_cfg_t; extern skins_cfg_t config;
--- a/src/skins/ui_dock.c Tue May 20 15:36:47 2008 +0200 +++ b/src/skins/ui_dock.c Tue May 20 16:34:06 2008 +0200 @@ -24,7 +24,7 @@ */ #include "ui_dock.h" - +#include "skins_cfg.h" #include <gdk/gdk.h> #include <stdlib.h> #include <audacious/plugin.h> @@ -54,7 +54,7 @@ snap_edge(gint * x, gint * y, gint w, gint h, gint bx, gint by, gint bw, gint bh) { - gint sd = aud_cfg->snap_distance; + gint sd = config.snap_distance; if ((*x + w > bx - sd) && (*x + w < bx + sd) && (*y > by - h - sd) && (*y < by + bh + sd)) { @@ -94,7 +94,7 @@ *off_x = 0; *off_y = 0; - if (!aud_cfg->snap_windows) + if (!config.snap_windows) return; /* @@ -109,13 +109,13 @@ ny = dw->offset_y + *off_y + y; /* Snap to screen edges */ - if (abs(nx) < aud_cfg->snap_distance) + if (abs(nx) < config.snap_distance) *off_x -= nx; - if (abs(ny) < aud_cfg->snap_distance) + if (abs(ny) < config.snap_distance) *off_y -= ny; - if (abs(nx + nw - gdk_screen_width()) < aud_cfg->snap_distance) + if (abs(nx + nw - gdk_screen_width()) < config.snap_distance) *off_x -= nx + nw - gdk_screen_width(); - if (abs(ny + nh - gdk_screen_height()) < aud_cfg->snap_distance) + if (abs(ny + nh - gdk_screen_height()) < config.snap_distance) *off_y -= ny + nh - gdk_screen_height(); /* Snap to other windows */ @@ -233,16 +233,16 @@ switch(window->type) { case WINDOW_MAIN: - aud_cfg->player_x = x + dw->offset_x; - aud_cfg->player_y = y + dw->offset_y; + config.player_x = x + dw->offset_x; + config.player_y = y + dw->offset_y; break; case WINDOW_EQ: - aud_cfg->equalizer_x = x + dw->offset_x; - aud_cfg->equalizer_y = y + dw->offset_y; + config.equalizer_x = x + dw->offset_x; + config.equalizer_y = y + dw->offset_y; break; case WINDOW_PLAYLIST: - aud_cfg->playlist_x = x + dw->offset_x; - aud_cfg->playlist_y = y + dw->offset_y; + config.playlist_x = x + dw->offset_x; + config.playlist_y = y + dw->offset_y; break; } @@ -338,7 +338,7 @@ gtk_window_get_position(widget, &x, &y); gtk_window_get_size(widget, &w, &h); - if (aud_cfg->show_wm_decorations) { + if (config.show_wm_decorations) { dock_window_resize(widget, w, new_h, w, h); return; } @@ -422,7 +422,7 @@ gint mx, my; DockedWindow *dwin; - if (aud_cfg->show_wm_decorations) + if (config.show_wm_decorations) return; gtk_window_present(w);