summaryrefslogtreecommitdiff
path: root/src/skins/main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/skins/main.cc')
-rw-r--r--src/skins/main.cc44
1 files changed, 23 insertions, 21 deletions
diff --git a/src/skins/main.cc b/src/skins/main.cc
index 8a93e16..38e6357 100644
--- a/src/skins/main.cc
+++ b/src/skins/main.cc
@@ -49,7 +49,7 @@
#include "equalizer.h"
#include "main.h"
#include "vis-callbacks.h"
-#include "playlist.h"
+#include "playlistwin.h"
#include "button.h"
#include "hslider.h"
#include "menurow.h"
@@ -60,7 +60,7 @@
#include "textbox.h"
#include "window.h"
#include "vis.h"
-#include "util.h"
+#include "skins_util.h"
#include "view.h"
#include "../ui-common/menu-ops.h"
@@ -126,7 +126,8 @@ static void mainwin_position_motion_cb ();
static void mainwin_position_release_cb ();
static void seek_timeout (void * rewind);
-static void format_time (char buf[7], int time, int length)
+/* always returns a 6-character string */
+static StringBuf format_time (int time, int length)
{
bool zero = aud_get_bool (nullptr, "leading_zero");
bool remaining = aud_get_bool ("skins", "show_remaining_time");
@@ -137,11 +138,11 @@ static void format_time (char buf[7], int time, int length)
time = aud::clamp(0, time, 359999); // 99:59:59
if (time < 60)
- snprintf (buf, 7, zero ? "-00:%02d" : " -0:%02d", time);
+ return str_printf (zero ? "-00:%02d" : " -0:%02d", time);
else if (time < 6000)
- snprintf (buf, 7, zero ? "%03d:%02d" : "%3d:%02d", -time / 60, time % 60);
+ return str_printf (zero ? "%03d:%02d" : "%3d:%02d", -time / 60, time % 60);
else
- snprintf (buf, 7, "%3d:%02d", -time / 3600, time / 60 % 60);
+ return str_printf ("%3d:%02d", -time / 3600, time / 60 % 60);
}
else
{
@@ -149,11 +150,11 @@ static void format_time (char buf[7], int time, int length)
time = aud::clamp(0, time, 3599999); // 999:59:59
if (time < 6000)
- snprintf (buf, 7, zero ? " %02d:%02d" : " %2d:%02d", time / 60, time % 60);
+ return str_printf (zero ? " %02d:%02d" : " %2d:%02d", time / 60, time % 60);
else if (time < 60000)
- snprintf (buf, 7, "%3d:%02d", time / 60, time % 60);
+ return str_printf ("%3d:%02d", time / 60, time % 60);
else
- snprintf (buf, 7, "%3d:%02d", time / 3600, time / 60 % 60);
+ return str_printf ("%3d:%02d", time / 3600, time / 60 % 60);
}
}
@@ -218,13 +219,13 @@ static void mainwin_set_song_title (const char * title)
StringBuf buf;
if (title)
- buf.steal (str_printf (_("%s - Audacious"), title));
+ buf = str_printf (_("%s - Audacious"), title);
else
- buf.steal (str_copy (_("Audacious")));
+ buf = str_copy (_("Audacious"));
int instance = aud_get_instance ();
if (instance != 1)
- buf.combine (str_printf (" (%d)", instance));
+ str_append_printf (buf, " (%d)", instance);
mainwin->setWindowTitle ((const char *) buf);
mainwin_set_info_text (title ? title : "");
@@ -441,9 +442,12 @@ static void mainwin_playback_stop ()
static void record_toggled ()
{
if (aud_drct_get_record_enabled ())
- mainwin_show_status_message (_("Recording on"));
- else
- mainwin_show_status_message (_("Recording off"));
+ {
+ if (aud_get_bool (nullptr, "record"))
+ mainwin_show_status_message (_("Recording on"));
+ else
+ mainwin_show_status_message (_("Recording off"));
+ }
}
static void repeat_toggled ()
@@ -681,8 +685,7 @@ static void mainwin_spos_motion_cb ()
int length = aud_drct_get_length ();
int time = (pos - 1) * length / 12;
- char buf[7];
- format_time (buf, time, length);
+ StringBuf buf = format_time (time, length);
mainwin_stime_min->set_text (buf);
mainwin_stime_sec->set_text (buf + 4);
@@ -1134,7 +1137,7 @@ static void mainwin_create_window ()
hook_associate ("playback unpause", (HookFunction) playback_unpause, nullptr);
hook_associate ("title change", (HookFunction) title_change, nullptr);
hook_associate ("info change", (HookFunction) info_change, nullptr);
- hook_associate ("enable record", (HookFunction) record_toggled, nullptr);
+ hook_associate ("set record", (HookFunction) record_toggled, nullptr);
hook_associate ("set repeat", (HookFunction) repeat_toggled, nullptr);
hook_associate ("set shuffle", (HookFunction) shuffle_toggled, nullptr);
hook_associate ("set no_playlist_advance", (HookFunction) no_advance_toggled, nullptr);
@@ -1157,7 +1160,7 @@ void mainwin_unhook ()
hook_dissociate ("playback unpause", (HookFunction) playback_unpause);
hook_dissociate ("title change", (HookFunction) title_change);
hook_dissociate ("info change", (HookFunction) info_change);
- hook_dissociate ("enable record", (HookFunction) record_toggled);
+ hook_dissociate ("set record", (HookFunction) record_toggled);
hook_dissociate ("set repeat", (HookFunction) repeat_toggled);
hook_dissociate ("set shuffle", (HookFunction) shuffle_toggled);
hook_dissociate ("set no_playlist_advance", (HookFunction) no_advance_toggled);
@@ -1189,8 +1192,7 @@ static void mainwin_update_volume ()
static void mainwin_update_time_display (int time, int length)
{
- char scratch[7];
- format_time (scratch, time, length);
+ StringBuf scratch = format_time (time, length);
mainwin_minus_num->set (scratch[0]);
mainwin_10min_num->set (scratch[1]);