Mercurial > audlegacy
changeset 837:7d998597254e trunk
[svn] - initial work on skin.hints support (the first step to modernizing our
skin format :D)
author | nenolod |
---|---|
date | Fri, 17 Mar 2006 18:21:50 -0800 |
parents | 1125fdc111c2 |
children | 90a8a5e47d7f |
files | audacious/mainwin.c audacious/skin.c audacious/skin.h |
diffstat | 3 files changed, 93 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/audacious/mainwin.c Fri Mar 17 10:25:25 2006 -0800 +++ b/audacious/mainwin.c Fri Mar 17 18:21:50 2006 -0800 @@ -192,7 +192,8 @@ TextBox *mainwin_info; TextBox *mainwin_stime_min, *mainwin_stime_sec; -static TextBox *mainwin_rate_text, *mainwin_freq_text; +static TextBox *mainwin_rate_text, *mainwin_freq_text, + *mainwin_othertext; PlayStatus *mainwin_playstatus; @@ -441,6 +442,8 @@ static void set_timer_mode_menu_cb(TimerMode mode); static void set_timer_mode(TimerMode mode); +static void mainwin_refresh_hints(void); + void mainwin_position_motion_cb(gint pos); void mainwin_position_release_cb(gint pos); @@ -713,6 +716,9 @@ if (!cfg.player_visible) return; + if (force) + mainwin_refresh_hints(); + widget_list_lock(mainwin_wlist); if (force) { @@ -801,12 +807,31 @@ G_UNLOCK(mainwin_title); } +static void +mainwin_refresh_hints(void) +{ + if (bmp_active_skin->properties.mainwin_othertext == TRUE) + { + widget_hide(WIDGET(mainwin_rate_text)); + widget_hide(WIDGET(mainwin_freq_text)); + widget_hide(WIDGET(mainwin_monostereo)); + widget_show(WIDGET(mainwin_othertext)); + } + else + { + widget_show(WIDGET(mainwin_rate_text)); + widget_show(WIDGET(mainwin_freq_text)); + widget_show(WIDGET(mainwin_monostereo)); + widget_hide(WIDGET(mainwin_othertext)); + } +} + void mainwin_set_song_info(gint bitrate, gint frequency, gint n_channels) { - gchar text[10]; + gchar text[512]; gchar *title; playback_set_sample_params(bitrate, frequency, n_channels); @@ -861,6 +886,27 @@ mainwin_force_redraw = TRUE; } + if (bmp_active_skin->properties.mainwin_othertext == TRUE) + { + g_snprintf(text, 512, "%d kbps, %0.1f khz, %s", + bitrate < 1000 ? bitrate : bitrate / 100, + (gfloat) frequency / 1000, + (n_channels > 1) ? _("stereo") : _("mono")); + textbox_set_text(mainwin_othertext, text); + + widget_hide(WIDGET(mainwin_rate_text)); + widget_hide(WIDGET(mainwin_freq_text)); + widget_hide(WIDGET(mainwin_monostereo)); + widget_show(WIDGET(mainwin_othertext)); + } + else + { + widget_show(WIDGET(mainwin_rate_text)); + widget_show(WIDGET(mainwin_freq_text)); + widget_show(WIDGET(mainwin_monostereo)); + widget_hide(WIDGET(mainwin_othertext)); + } + title = playlist_get_info_text(); mainwin_set_song_title(title); g_free(title); @@ -904,6 +950,8 @@ widget_hide(WIDGET(mainwin_position)); widget_hide(WIDGET(mainwin_sposition)); + widget_hide(WIDGET(mainwin_othertext)); + playlistwin_hide_timer(); draw_main_window(TRUE); @@ -3050,6 +3098,11 @@ 153, 1, SKIN_TEXT); textbox_set_scroll(mainwin_info, cfg.autoscroll); textbox_set_xfont(mainwin_info, cfg.mainwin_use_xfont, cfg.mainwin_font); + + mainwin_othertext = + create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 112, 43, + 153, 1, SKIN_TEXT); + mainwin_rate_text = create_textbox(&mainwin_wlist, mainwin_bg, mainwin_gc, 111, 43, 15, 0, SKIN_TEXT);
--- a/audacious/skin.c Fri Mar 17 10:25:25 2006 -0800 +++ b/audacious/skin.c Fri Mar 17 18:21:50 2006 -0800 @@ -158,9 +158,14 @@ { g_return_val_if_fail(bmp_active_skin != NULL, FALSE); + memset(&bmp_active_skin->properties, 0, sizeof(SkinProperties)); + if (!skin_load(bmp_active_skin, path)) return FALSE; + /* Parse the hints for this skin. */ + skin_parse_hints(bmp_active_skin, NULL); + skin_setup_masks(bmp_active_skin); draw_main_window(TRUE); draw_playlist_window(TRUE); @@ -501,6 +506,33 @@ return TRUE; } +/* + * Opens and parses a skin's hints file. + * Hints files are somewhat like "scripts" in Winamp3/5. + * We'll probably add scripts to it next. + */ +void +skin_parse_hints(Skin * skin, gchar *path_p) +{ + gchar *filename, *tmp; + + path_p = path_p ? path_p : skin->path; + + filename = find_file_recursively(path_p, "skin.hints"); + + if (filename == NULL) + return; + +#if 0 + skin->description = read_ini_string(filename, "skin", "skinDescription"); +#endif + + tmp = read_ini_string(filename, "skin", "mainwinOthertext"); + + if (tmp != NULL) + skin->properties.mainwin_othertext = atoi(tmp); +} + static guint hex_chars_to_int(gchar hi, gchar lo) { @@ -797,7 +829,6 @@ skin->path = g_strdup(path); - if (!file_is_archive(path)) { skin_load_pixmaps(skin, path); skin_load_cursor(skin, path);
--- a/audacious/skin.h Fri Mar 17 10:25:25 2006 -0800 +++ b/audacious/skin.h Fri Mar 17 18:21:50 2006 -0800 @@ -67,6 +67,9 @@ SKIN_COLOR_COUNT } SkinColorId; +typedef struct _SkinProperties { + gboolean mainwin_othertext; +} SkinProperties; #define SKIN_PIXMAP(x) ((SkinPixmap *)(x)) typedef struct _SkinPixmap { @@ -93,9 +96,9 @@ GdkColor *colors[SKIN_COLOR_COUNT]; guchar vis_color[24][3]; GdkBitmap *masks[SKIN_MASK_COUNT]; + SkinProperties properties; } Skin; - extern Skin *bmp_active_skin; gboolean init_skins(const gchar * path); @@ -133,6 +136,8 @@ gboolean shaded, gboolean focus); +void skin_parse_hints(Skin * skin, gchar *path_p); + gboolean skin_reload_forced(void);