Mercurial > audlegacy
comparison src/audtool/audtool_handlers_vitals.c @ 2931:b36261c942f8 trunk
Transition to audtool_report()/audtool_whine().
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Fri, 29 Jun 2007 08:26:19 -0500 |
parents | f5ce83fdbf3e |
children | 964413953abd |
comparison
equal
deleted
inserted
replaced
2930:d1198fb765c6 | 2931:b36261c942f8 |
---|---|
42 gint playpos = audacious_remote_get_playlist_pos(dbus_proxy); | 42 gint playpos = audacious_remote_get_playlist_pos(dbus_proxy); |
43 gchar *song = audacious_remote_get_playlist_title(dbus_proxy, playpos); | 43 gchar *song = audacious_remote_get_playlist_title(dbus_proxy, playpos); |
44 | 44 |
45 if (!song) | 45 if (!song) |
46 { | 46 { |
47 g_print("No song playing.\n"); | 47 audtool_report("No song playing."); |
48 return; | 48 return; |
49 } | 49 } |
50 | 50 |
51 g_print("%s\n", song); | 51 audtool_report("%s", song); |
52 } | 52 } |
53 | 53 |
54 void get_current_song_filename(gint argc, gchar **argv) | 54 void get_current_song_filename(gint argc, gchar **argv) |
55 { | 55 { |
56 gint playpos = audacious_remote_get_playlist_pos(dbus_proxy); | 56 gint playpos = audacious_remote_get_playlist_pos(dbus_proxy); |
57 gchar *file = audacious_remote_get_playlist_file(dbus_proxy, playpos); | 57 gchar *file = audacious_remote_get_playlist_file(dbus_proxy, playpos); |
58 | 58 |
59 if (!file) | 59 if (!file) |
60 { | 60 { |
61 g_print("No song playing.\n"); | 61 audtool_report("No song playing."); |
62 return; | 62 return; |
63 } | 63 } |
64 | 64 |
65 g_print("%s\n", file); | 65 audtool_report("%s", file); |
66 } | 66 } |
67 | 67 |
68 void get_current_song_output_length(gint argc, gchar **argv) | 68 void get_current_song_output_length(gint argc, gchar **argv) |
69 { | 69 { |
70 gint frames = audacious_remote_get_output_time(dbus_proxy); | 70 gint frames = audacious_remote_get_output_time(dbus_proxy); |
71 gint length = frames / 1000; | 71 gint length = frames / 1000; |
72 | 72 |
73 g_print("%d:%.2d\n", length / 60, length % 60); | 73 audtool_report("%d:%.2d", length / 60, length % 60); |
74 } | 74 } |
75 | 75 |
76 void get_current_song_output_length_seconds(gint argc, gchar **argv) | 76 void get_current_song_output_length_seconds(gint argc, gchar **argv) |
77 { | 77 { |
78 gint frames = audacious_remote_get_output_time(dbus_proxy); | 78 gint frames = audacious_remote_get_output_time(dbus_proxy); |
79 gint length = frames / 1000; | 79 gint length = frames / 1000; |
80 | 80 |
81 g_print("%d\n", length); | 81 audtool_report("%d", length); |
82 } | 82 } |
83 | 83 |
84 void get_current_song_output_length_frames(gint argc, gchar **argv) | 84 void get_current_song_output_length_frames(gint argc, gchar **argv) |
85 { | 85 { |
86 gint frames = audacious_remote_get_output_time(dbus_proxy); | 86 gint frames = audacious_remote_get_output_time(dbus_proxy); |
87 | 87 |
88 g_print("%d\n", frames); | 88 audtool_report("%d", frames); |
89 } | 89 } |
90 | 90 |
91 void get_current_song_length(gint argc, gchar **argv) | 91 void get_current_song_length(gint argc, gchar **argv) |
92 { | 92 { |
93 gint playpos = audacious_remote_get_playlist_pos(dbus_proxy); | 93 gint playpos = audacious_remote_get_playlist_pos(dbus_proxy); |
94 gint frames = audacious_remote_get_playlist_time(dbus_proxy, playpos); | 94 gint frames = audacious_remote_get_playlist_time(dbus_proxy, playpos); |
95 gint length = frames / 1000; | 95 gint length = frames / 1000; |
96 | 96 |
97 g_print("%d:%.2d\n", length / 60, length % 60); | 97 audtool_report("%d:%.2d", length / 60, length % 60); |
98 } | 98 } |
99 | 99 |
100 void get_current_song_length_seconds(gint argc, gchar **argv) | 100 void get_current_song_length_seconds(gint argc, gchar **argv) |
101 { | 101 { |
102 gint playpos = audacious_remote_get_playlist_pos(dbus_proxy); | 102 gint playpos = audacious_remote_get_playlist_pos(dbus_proxy); |
103 gint frames = audacious_remote_get_playlist_time(dbus_proxy, playpos); | 103 gint frames = audacious_remote_get_playlist_time(dbus_proxy, playpos); |
104 gint length = frames / 1000; | 104 gint length = frames / 1000; |
105 | 105 |
106 g_print("%d\n", length); | 106 audtool_report("%d", length); |
107 } | 107 } |
108 | 108 |
109 void get_current_song_length_frames(gint argc, gchar **argv) | 109 void get_current_song_length_frames(gint argc, gchar **argv) |
110 { | 110 { |
111 gint playpos = audacious_remote_get_playlist_pos(dbus_proxy); | 111 gint playpos = audacious_remote_get_playlist_pos(dbus_proxy); |
112 gint frames = audacious_remote_get_playlist_time(dbus_proxy, playpos); | 112 gint frames = audacious_remote_get_playlist_time(dbus_proxy, playpos); |
113 | 113 |
114 g_print("%d\n", frames); | 114 audtool_report("%d", frames); |
115 } | 115 } |
116 | 116 |
117 void get_current_song_bitrate(gint argc, gchar **argv) | 117 void get_current_song_bitrate(gint argc, gchar **argv) |
118 { | 118 { |
119 gint rate, freq, nch; | 119 gint rate, freq, nch; |
120 | 120 |
121 audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch); | 121 audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch); |
122 | 122 |
123 g_print("%d\n", rate); | 123 audtool_report("%d", rate); |
124 } | 124 } |
125 | 125 |
126 void get_current_song_bitrate_kbps(gint argc, gchar **argv) | 126 void get_current_song_bitrate_kbps(gint argc, gchar **argv) |
127 { | 127 { |
128 gint rate, freq, nch; | 128 gint rate, freq, nch; |
129 | 129 |
130 audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch); | 130 audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch); |
131 | 131 |
132 g_print("%d\n", rate / 1000); | 132 audtool_report("%d", rate / 1000); |
133 } | 133 } |
134 | 134 |
135 void get_current_song_frequency(gint argc, gchar **argv) | 135 void get_current_song_frequency(gint argc, gchar **argv) |
136 { | 136 { |
137 gint rate, freq, nch; | 137 gint rate, freq, nch; |
138 | 138 |
139 audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch); | 139 audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch); |
140 | 140 |
141 g_print("%d\n", freq); | 141 audtool_report("%d", freq); |
142 } | 142 } |
143 | 143 |
144 void get_current_song_frequency_khz(gint argc, gchar **argv) | 144 void get_current_song_frequency_khz(gint argc, gchar **argv) |
145 { | 145 { |
146 gint rate, freq, nch; | 146 gint rate, freq, nch; |
147 | 147 |
148 audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch); | 148 audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch); |
149 | 149 |
150 g_print("%0.1f\n", (gfloat) freq / 1000); | 150 audtool_report("%0.1f", (gfloat) freq / 1000); |
151 } | 151 } |
152 | 152 |
153 void get_current_song_channels(gint argc, gchar **argv) | 153 void get_current_song_channels(gint argc, gchar **argv) |
154 { | 154 { |
155 gint rate, freq, nch; | 155 gint rate, freq, nch; |
156 | 156 |
157 audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch); | 157 audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch); |
158 | 158 |
159 g_print("%d\n", nch); | 159 audtool_report("%d", nch); |
160 } | 160 } |
161 | 161 |
162 void get_current_song_tuple_field_data(gint argc, gchar **argv) | 162 void get_current_song_tuple_field_data(gint argc, gchar **argv) |
163 { | 163 { |
164 gpointer data; | 164 gpointer data; |
165 | 165 |
166 if (argc < 2) | 166 if (argc < 2) |
167 { | 167 { |
168 g_print("%s: invalid parameters for current-song-tuple-data.\n", argv[0]); | 168 audtool_whine("invalid parameters for %s.", argv[0]); |
169 g_print("%s: syntax: %s current-song-tuple-data <fieldname>\n", argv[0], argv[0]); | 169 audtool_whine("syntax: %s <fieldname>", argv[0]); |
170 g_print("%s: - fieldname example choices: performer, album_name,\n", argv[0]); | 170 audtool_whine(" - fieldname example choices: performer, album_name,"); |
171 g_print("%s: track_name, track_number, year, date, genre, comment,\n", argv[0]); | 171 audtool_whine(" track_name, track_number, year, date, genre, comment,"); |
172 g_print("%s: file_name, file_ext, file_path, length, formatter,\n", argv[0]); | 172 audtool_whine(" file_name, file_ext, file_path, length, formatter,"); |
173 g_print("%s: custom, mtime\n", argv[0]); | 173 audtool_whine(" custom, mtime"); |
174 return; | 174 return; |
175 } | 175 } |
176 | 176 |
177 if (!(data = audacious_get_tuple_field_data(dbus_proxy, argv[1], audacious_remote_get_playlist_pos(dbus_proxy)))) | 177 if (!(data = audacious_get_tuple_field_data(dbus_proxy, argv[1], audacious_remote_get_playlist_pos(dbus_proxy)))) |
178 { | 178 { |
181 | 181 |
182 if (!strcasecmp(argv[1], "track_number") || !strcasecmp(argv[1], "year") || !strcasecmp(argv[1], "length") || !strcasecmp(argv[1], "mtime")) | 182 if (!strcasecmp(argv[1], "track_number") || !strcasecmp(argv[1], "year") || !strcasecmp(argv[1], "length") || !strcasecmp(argv[1], "mtime")) |
183 { | 183 { |
184 if (*(gint *)data > 0) | 184 if (*(gint *)data > 0) |
185 { | 185 { |
186 g_print("%d\n", *(gint *)data); | 186 audtool_report("%d", *(gint *)data); |
187 } | 187 } |
188 return; | 188 return; |
189 } | 189 } |
190 | 190 |
191 g_print("%s\n", (gchar *)data); | 191 audtool_report("%s", (gchar *)data); |
192 } | 192 } |