changeset 2642:c2603047a1a3

add few more config items
author Tomasz Mon <desowin@gmail.com>
date Fri, 23 May 2008 17:17:16 +0200
parents ba91ea50f214
children 45ef6d7c0174
files src/skins/skins_cfg.c src/skins/skins_cfg.h src/skins/ui_main.c src/skins/ui_playlist.c src/skins/ui_skin.c src/skins/ui_skinned_playlist.c src/skins/ui_svis.c src/skins/ui_vis.c
diffstat 8 files changed, 75 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/src/skins/skins_cfg.c	Fri May 23 15:38:38 2008 +0200
+++ b/src/skins/skins_cfg.c	Fri May 23 17:17:16 2008 +0200
@@ -22,6 +22,8 @@
 #include "skins_cfg.h"
 #include "ui_skin.h"
 #include "ui_vis.h"
+#include "ui_main.h"
+#include "ui_playlist.h"
 #include <glib.h>
 #include <stdlib.h>
 #include <audacious/plugin.h>
@@ -84,6 +86,10 @@
     .use_xmms_style_fileselector = FALSE,
     .show_numbers_in_pl = TRUE,
     .show_separator_in_pl = TRUE,
+    .playlist_font = NULL,
+    .mainwin_font = NULL,
+    .show_filepopup_for_tuple = TRUE,
+    .filepopup_delay = 20,             /* delay until the filepopup comes up */
 };
 
 typedef struct skins_cfg_boolent_t {
@@ -120,6 +126,7 @@
     {"eq_scaled_linked", &config.eq_scaled_linked, TRUE},
     {"show_numbers_in_pl", &config.show_numbers_in_pl, TRUE},
     {"show_separator_in_pl", &config.show_separator_in_pl, TRUE},
+    {"show_filepopup_for_tuple", &config.show_filepopup_for_tuple, TRUE},
 };
 
 static gint ncfgbent = G_N_ELEMENTS(skins_boolents);
@@ -156,12 +163,33 @@
     {"colorize_g", &config.colorize_g, TRUE},
     {"colorize_b", &config.colorize_b, TRUE},
     {"snap_distance", &config.snap_distance, TRUE},
+    {"filepopup_delay", &config.filepopup_delay, TRUE},
 };
 
 static gint ncfgient = G_N_ELEMENTS(skins_numents);
 
+typedef struct skins_cfg_strent_t {
+    char const *se_vname;
+    char **se_vloc;
+    gboolean se_wrt;
+} skins_cfg_strent;
+
+static skins_cfg_strent skins_strents[] = {
+    {"playlist_font", &config.playlist_font, TRUE},
+    {"mainwin_font", &config.mainwin_font, TRUE},
+    {"skin", &config.skin, FALSE},
+};
+
+static gint ncfgsent = G_N_ELEMENTS(skins_strents);
+
 void skins_cfg_free() {
-    if (config.skin) { g_free(config.skin); config.skin = NULL; }
+    gint i;
+    for (i = 0; i < ncfgsent; ++i) {
+        if (*(skins_strents[i].se_vloc) != NULL) {
+            g_free( *(skins_strents[i].se_vloc) );
+            *(skins_strents[i].se_vloc) = NULL;
+        }
+    }
 }
 
 void skins_cfg_load() {
@@ -182,8 +210,17 @@
                            skins_numents[i].ie_vloc);
     }
 
-    if (!aud_cfg_db_get_string(cfgfile, "skins", "skin", &(config.skin)))
-        config.skin = g_strdup(BMP_DEFAULT_SKIN_PATH);
+    for (i = 0; i < ncfgsent; ++i) {
+        aud_cfg_db_get_string(cfgfile, "skins",
+                              skins_strents[i].se_vname,
+                              skins_strents[i].se_vloc);
+    }
+
+    if (!config.mainwin_font)
+        config.mainwin_font = g_strdup(MAINWIN_DEFAULT_FONT);
+
+    if (!config.playlist_font)
+        config.playlist_font = g_strdup(PLAYLISTWIN_DEFAULT_FONT);
 
     if (!aud_cfg_db_get_float(cfgfile, "skins", "scale_factor", &(config.scale_factor)))
         config.scale_factor = 2.0;
@@ -204,6 +241,13 @@
 
     int i;
 
+    for (i = 0; i < ncfgsent; ++i) {
+        if (skins_strents[i].se_wrt)
+            aud_cfg_db_set_string(cfgfile, "skins",
+                                  skins_strents[i].se_vname,
+                                  *skins_strents[i].se_vloc);
+    }
+
     for (i = 0; i < ncfgbent; ++i)
         if (skins_boolents[i].be_wrt)
             aud_cfg_db_set_bool(cfgfile, "skins",
--- a/src/skins/skins_cfg.h	Fri May 23 15:38:38 2008 +0200
+++ b/src/skins/skins_cfg.h	Fri May 23 17:17:16 2008 +0200
@@ -74,6 +74,9 @@
     gboolean eq_scaled_linked;
     gboolean use_xmms_style_fileselector;
     gboolean show_numbers_in_pl, show_separator_in_pl;
+    gchar *playlist_font, *mainwin_font;
+    gboolean show_filepopup_for_tuple;
+    gint filepopup_delay;
 } skins_cfg_t;
 
 extern skins_cfg_t config;
--- a/src/skins/ui_main.c	Fri May 23 15:38:38 2008 +0200
+++ b/src/skins/ui_main.c	Fri May 23 17:17:16 2008 +0200
@@ -1071,8 +1071,8 @@
         if (decoded == NULL)
             return;
 
-        aud_cfg->playlist_font = g_strconcat(decoded, strrchr(aud_cfg->playlist_font, ' '), NULL);
-        ui_skinned_playlist_set_font(aud_cfg->playlist_font);
+        config.playlist_font = g_strconcat(decoded, strrchr(config.playlist_font, ' '), NULL);
+        ui_skinned_playlist_set_font(config.playlist_font);
         playlistwin_update_list(playlist);
 
         g_free(decoded);
@@ -2315,7 +2315,7 @@
 
     mainwin_info = ui_skinned_textbox_new(SKINNED_WINDOW(mainwin)->fixed, 112, 27, 153, 1, SKIN_TEXT);
     ui_skinned_textbox_set_scroll(mainwin_info, config.autoscroll);
-    ui_skinned_textbox_set_xfont(mainwin_info, !config.mainwin_use_bitmapfont, aud_cfg->mainwin_font);
+    ui_skinned_textbox_set_xfont(mainwin_info, !config.mainwin_use_bitmapfont, config.mainwin_font);
     g_signal_connect(mainwin_info, "double-clicked", mainwin_info_double_clicked_cb, NULL);
     g_signal_connect(mainwin_info, "right-clicked", G_CALLBACK(mainwin_info_right_clicked_cb), NULL);
 
--- a/src/skins/ui_playlist.c	Fri May 23 15:38:38 2008 +0200
+++ b/src/skins/ui_playlist.c	Fri May 23 17:17:16 2008 +0200
@@ -340,7 +340,7 @@
     config.playlist_shaded = shaded;
 
     if (shaded) {
-        playlistwin_set_sinfo_font(aud_cfg->playlist_font);
+        playlistwin_set_sinfo_font(config.playlist_font);
         playlistwin_set_sinfo_scroll(config.autoscroll);
         gtk_widget_show(playlistwin_sinfo);
         ui_skinned_set_push_button_data(playlistwin_shade, 128, 45, 150, 42);
@@ -1379,7 +1379,7 @@
     playlistwin_sinfo = ui_skinned_textbox_new(SKINNED_WINDOW(playlistwin)->fixed,
                                                4, 4, playlistwin_get_width() - 35, TRUE, SKIN_TEXT);
 
-    playlistwin_set_sinfo_font(aud_cfg->playlist_font);
+    playlistwin_set_sinfo_font(config.playlist_font);
 
     playlistwin_shade = ui_skinned_button_new();
     /* shade/unshade window push button */
@@ -1407,7 +1407,7 @@
     playlistwin_list = ui_skinned_playlist_new(SKINNED_WINDOW(playlistwin)->fixed, 12, 20,
                              playlistwin_get_width() - 31,
                              config.playlist_height - 58);
-    ui_skinned_playlist_set_font(aud_cfg->playlist_font);
+    ui_skinned_playlist_set_font(config.playlist_font);
 
     /* playlist list box slider */
     playlistwin_slider = ui_skinned_playlist_slider_new(SKINNED_WINDOW(playlistwin)->fixed, playlistwin_get_width() - 15,
--- a/src/skins/ui_skin.c	Fri May 23 15:38:38 2008 +0200
+++ b/src/skins/ui_skin.c	Fri May 23 17:17:16 2008 +0200
@@ -406,7 +406,7 @@
 
     pm = &skin->pixmaps[id];
     GdkPixbuf *pix = gdk_pixbuf_new_from_file(filename, NULL);
-    pm->pixbuf = audacious_create_colorized_pixbuf(pix, config.colorize_r, aud_cfg->colorize_g, aud_cfg->colorize_b);
+    pm->pixbuf = audacious_create_colorized_pixbuf(pix, config.colorize_r, config.colorize_g, config.colorize_b);
     g_object_unref(pix);
     pm->width = gdk_pixbuf_get_width(pm->pixbuf);
     pm->height = gdk_pixbuf_get_height(pm->pixbuf);
@@ -2053,8 +2053,8 @@
     g_return_if_fail(obj != NULL);
 
     if (scale) {
-        GdkPixbuf *image = gdk_pixbuf_scale_simple(obj, width * config.scale_factor, height* aud_cfg->scale_factor, GDK_INTERP_NEAREST);
-        gdk_draw_pixbuf(widget->window, NULL, image, 0, 0, 0, 0, width * config.scale_factor , height * aud_cfg->scale_factor, GDK_RGB_DITHER_NONE, 0, 0);
+        GdkPixbuf *image = gdk_pixbuf_scale_simple(obj, width * config.scale_factor, height* config.scale_factor, GDK_INTERP_NEAREST);
+        gdk_draw_pixbuf(widget->window, NULL, image, 0, 0, 0, 0, width * config.scale_factor , height * config.scale_factor, GDK_RGB_DITHER_NONE, 0, 0);
         g_object_unref(image);
     } else {
         gdk_draw_pixbuf(widget->window, NULL, obj, 0, 0, 0, 0, width, height, GDK_RGB_DITHER_NONE, 0, 0);
--- a/src/skins/ui_skinned_playlist.c	Fri May 23 15:38:38 2008 +0200
+++ b/src/skins/ui_skinned_playlist.c	Fri May 23 17:17:16 2008 +0200
@@ -969,7 +969,7 @@
             playlistwin_update_list(aud_playlist_get_active());
         }
         priv->drag_pos = nr;
-    } else if (aud_cfg->show_filepopup_for_tuple) {
+    } else if (config.show_filepopup_for_tuple) {
         gint pos = ui_skinned_playlist_get_position(widget, event->x, event->y);
         gint cur_pos = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "popup_position"));
         if (pos != cur_pos) {
@@ -1087,7 +1087,7 @@
 }
 
 static void ui_skinned_playlist_popup_timer_start(GtkWidget *widget) {
-    gint timer_id = g_timeout_add(aud_cfg->filepopup_delay*100, ui_skinned_playlist_popup_show, widget);
+    gint timer_id = g_timeout_add(config.filepopup_delay*100, ui_skinned_playlist_popup_show, widget);
     g_object_set_data(G_OBJECT(widget), "timer_id", GINT_TO_POINTER(timer_id));
     g_object_set_data(G_OBJECT(widget), "timer_active", GINT_TO_POINTER(1));
 }
--- a/src/skins/ui_svis.c	Fri May 23 15:38:38 2008 +0200
+++ b/src/skins/ui_svis.c	Fri May 23 17:17:16 2008 +0200
@@ -353,7 +353,7 @@
     }
     else {            /*svis scaling, this needs some work, since a lot of stuff is hardcoded --majeru*/
 
-      memset(rgb_data, 0, SVIS_WIDTH * config.scale_factor * SVIS_HEIGHT * aud_cfg->scale_factor);
+      memset(rgb_data, 0, SVIS_WIDTH * config.scale_factor * SVIS_HEIGHT * config.scale_factor);
       if (config.vis_type == VIS_ANALYZER && !audacious_drct_get_paused() && audacious_drct_get_playing()){
 	  for(y=0; y < SVIS_HEIGHT; y++){
             if (config.analyzer_type == ANALYZER_BARS){
@@ -452,7 +452,7 @@
     GtkWidget *widget = GTK_WIDGET (svis);
     svis->scaled = !svis->scaled;
 
-    gtk_widget_set_size_request(widget, svis->width* config.scale_factor, svis->height * aud_cfg->scale_factor);
+    gtk_widget_set_size_request(widget, svis->width* config.scale_factor, svis->height * config.scale_factor);
 
     gtk_widget_queue_draw(widget);
 }
--- a/src/skins/ui_vis.c	Fri May 23 15:38:38 2008 +0200
+++ b/src/skins/ui_vis.c	Fri May 23 17:17:16 2008 +0200
@@ -278,7 +278,7 @@
     cmap = gdk_rgb_cmap_new(colors, 24);
 
     if (!vis->scaled) {
-      if(config.vis_type == VIS_VOICEPRINT /*&& aud_cfg->voiceprint_mode != VOICEPRINT_NORMAL*/){
+      if(config.vis_type == VIS_VOICEPRINT /*&& config.voiceprint_mode != VOICEPRINT_NORMAL*/){
 	memset(rgb_data, 0, 76 * 16 * 3);
       }
       else{
@@ -291,7 +291,7 @@
       }
     }
     else{
-      if(config.vis_type == VIS_VOICEPRINT /*&& aud_cfg->voiceprint_mode != VOICEPRINT_NORMAL*/){
+      if(config.vis_type == VIS_VOICEPRINT /*&& config.voiceprint_mode != VOICEPRINT_NORMAL*/){
 	memset(rgb_data, 0, 3 * 4 * 16 * 76);
       }
       else{
@@ -333,7 +333,7 @@
 	    }
 	  }
 	  else{
-	    ptr = rgb_data + ((16 - h) * (guint)(76 * 4 * config.scale_factor)) + (guint)(x * aud_cfg->scale_factor);
+	    ptr = rgb_data + ((16 - h) * (guint)(76 * 4 * config.scale_factor)) + (guint)(x * config.scale_factor);
 	    switch (config.analyzer_mode) {
 	    case ANALYZER_NORMAL:
 	      for (y = 0; y < h; y++, ptr += (guint)(76 * 4 * config.scale_factor)) {
@@ -376,7 +376,7 @@
 	      rgb_data[(16 - h) * 76 + x] = 23;
 	    }
 	    else{
-	      ptr = rgb_data + (16 - h) * (guint)(76 * 4 * config.scale_factor) + (guint)(x * aud_cfg->scale_factor);
+	      ptr = rgb_data + (16 - h) * (guint)(76 * 4 * config.scale_factor) + (guint)(x * config.scale_factor);
 	      *ptr = 23;
 	      *(ptr + 1) = 23;
 	      *(ptr + (guint)(76 * config.scale_factor)) = 23;
@@ -450,7 +450,7 @@
 		rgb_data[x * 3 + y * 76*3+n] = voice_c[n];
 	    }
 	    else{
-	      ptr = rgb_data + (guint)(x * 3 * config.scale_factor) + (guint) (y * 76 * 3 * aud_cfg->scale_factor);
+	      ptr = rgb_data + (guint)(x * 3 * config.scale_factor) + (guint) (y * 76 * 3 * config.scale_factor);
 	      for(n=0;n<3;n++)
 		{
 		  *(ptr + n) = voice_c[n];
@@ -472,7 +472,7 @@
 	  ptr = rgb_data + ((14 - h) * 76) + x;
 	    *ptr = vis_scope_colors[h + 1];
 	  }else{
-	    ptr = rgb_data + ((14 - h) * (guint)(76 * 4 * config.scale_factor)) + (guint)(x * aud_cfg->scale_factor);
+	    ptr = rgb_data + ((14 - h) * (guint)(76 * 4 * config.scale_factor)) + (guint)(x * config.scale_factor);
 	    *ptr = vis_scope_colors[h + 1];
 	    *(ptr + 1) = vis_scope_colors[h + 1];
 	    *(ptr + (guint)(76 * config.scale_factor)) = vis_scope_colors[h + 1];
@@ -494,7 +494,7 @@
 	      *ptr = vis_scope_colors[y - 2];
 	    }
 	    else{
-	      ptr = rgb_data + (h * (guint)(76 * 4 * config.scale_factor)) + (guint)(x * aud_cfg->scale_factor);
+	      ptr = rgb_data + (h * (guint)(76 * 4 * config.scale_factor)) + (guint)(x * config.scale_factor);
 	      for (y = h; y <= h2; y++, ptr += (guint)(76 * 4 * config.scale_factor)) {
 		*ptr = vis_scope_colors[y - 2];
 		*(ptr + 1) = vis_scope_colors[y - 2];
@@ -509,7 +509,7 @@
 	      ptr = rgb_data + (h * 76) + x;
 	      *ptr = vis_scope_colors[h + 1];
 	    }else{
-	      ptr = rgb_data + (h * (guint)(76 * 4 * config.scale_factor)) + (guint)(x * aud_cfg->scale_factor);
+	      ptr = rgb_data + (h * (guint)(76 * 4 * config.scale_factor)) + (guint)(x * config.scale_factor);
 	      *ptr = vis_scope_colors[h + 1];
 	      *(ptr + 1) = vis_scope_colors[h + 1];
 	      *(ptr + (guint)(76 * config.scale_factor)) = vis_scope_colors[h + 1];
@@ -531,7 +531,7 @@
 	    for (y = h; y <= h2; y++, ptr += 76)
 	      *ptr = c;
 	  }else{
-	    ptr = rgb_data + (h * (guint)(76 * 4 * config.scale_factor)) + (guint)(x * aud_cfg->scale_factor);
+	    ptr = rgb_data + (h * (guint)(76 * 4 * config.scale_factor)) + (guint)(x * config.scale_factor);
 	    for (y = h; y <= h2; y++, ptr += (guint)(76 * 4 * config.scale_factor)) {
 	      *ptr = c;
 	      *(ptr + 1) = c;
@@ -546,7 +546,7 @@
 
     GdkPixmap *obj = NULL;
     GdkGC *gc;
-    obj = gdk_pixmap_new(NULL, vis->width*(vis->scaled ? config.scale_factor : 1), vis->height*(vis->scaled ? aud_cfg->scale_factor : 1), gdk_rgb_get_visual()->depth);
+    obj = gdk_pixmap_new(NULL, vis->width*(vis->scaled ? config.scale_factor : 1), vis->height*(vis->scaled ? config.scale_factor : 1), gdk_rgb_get_visual()->depth);
     gc = gdk_gc_new(obj);
 
     if (!vis->scaled) {
@@ -574,7 +574,7 @@
     }
 
     gdk_draw_drawable (widget->window, gc, obj, 0, 0, 0, 0,
-                       vis->width*(vis->scaled ? config.scale_factor : 1), vis->height*(vis->scaled ? aud_cfg->scale_factor : 1));
+                       vis->width*(vis->scaled ? config.scale_factor : 1), vis->height*(vis->scaled ? config.scale_factor : 1));
     g_object_unref(obj);
     g_object_unref(gc);
     gdk_rgb_cmap_free(cmap);
@@ -585,7 +585,7 @@
     GtkWidget *widget = GTK_WIDGET (vis);
     vis->scaled = !vis->scaled;
 
-    gtk_widget_set_size_request(widget, vis->width*(vis->scaled ? config.scale_factor : 1), vis->height*(vis->scaled ? aud_cfg->scale_factor : 1));
+    gtk_widget_set_size_request(widget, vis->width*(vis->scaled ? config.scale_factor : 1), vis->height*(vis->scaled ? config.scale_factor : 1));
 
     gtk_widget_queue_draw(GTK_WIDGET(vis));
 }