diff options
Diffstat (limited to '')
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | configure.ac | 40 | ||||
-rw-r--r-- | po/POTFILES.in | 1 | ||||
-rw-r--r-- | po/ncmpc.pot | 325 | ||||
-rw-r--r-- | po/sv.po | 338 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/command.c | 9 | ||||
-rw-r--r-- | src/command.h | 1 | ||||
-rw-r--r-- | src/conf.c | 5 | ||||
-rw-r--r-- | src/mpdclient.c | 34 | ||||
-rw-r--r-- | src/mpdclient.h | 3 | ||||
-rw-r--r-- | src/ncmpc.h | 10 | ||||
-rw-r--r-- | src/options.c | 6 | ||||
-rw-r--r-- | src/options.h | 1 | ||||
-rw-r--r-- | src/screen.c | 17 | ||||
-rw-r--r-- | src/screen_browse.h | 30 | ||||
-rw-r--r-- | src/screen_clock.c | 2 | ||||
-rw-r--r-- | src/screen_file.c | 81 | ||||
-rw-r--r-- | src/screen_help.c | 20 | ||||
-rw-r--r-- | src/screen_keydef.c | 4 | ||||
-rw-r--r-- | src/screen_play.c | 2 | ||||
-rw-r--r-- | src/screen_search.c | 305 | ||||
-rw-r--r-- | src/screen_utils.c | 7 | ||||
-rw-r--r-- | src/screen_utils.h | 3 |
24 files changed, 946 insertions, 305 deletions
@@ -1,3 +1,8 @@ +2004-11-14 Kalle Wallin <kaw@linux.se> + * Added a search screen + * screen_browse.c: added enqueue and play feature + * configure.ac: made mouse support and search screen optional + 2004-07-21 Kalle Wallin <kaw@linux.se> * Added Spanish translations from Jose Cedeno * command.c: dont lookup key if key==0 in find_key_command() diff --git a/configure.ac b/configure.ac index 60c9e0e0a..dee7d43f0 100644 --- a/configure.ac +++ b/configure.ac @@ -56,11 +56,6 @@ AC_CHECK_LIB([ncurses], [initscr], [LIBS="$LIBS -lncurses"], [AC_MSG_ERROR(ncurses library is required)]) -AC_CHECK_LIB([ncurses], - [getmouse], - [AC_DEFINE([HAVE_GETMOUSE], [1], [ncurses - getmouse()])], - []) - dnl Check for glib-2.4 @@ -149,6 +144,33 @@ dnl Optional screen - browse screen # AC_DEFINE(ENABLE_BROWSE_SCREEN, 1, [Enable the browse screen]) #fi +dnl Optional - curses getmouse support +AC_MSG_CHECKING([whether to include mouse support]) +AC_ARG_ENABLE([mouse], + AC_HELP_STRING([--enable-mouse], + [Enable curses getmouse support @<:@default=yes@:>@]), + [getmouse="$enableval"], + [getmouse=yes]) +AC_MSG_RESULT([$getmouse]) +if test "x$getmouse" = "xyes" ; then + AC_CHECK_LIB([ncurses], + [getmouse], + [AC_DEFINE([HAVE_GETMOUSE], [1], [ncurses - getmouse()])], + []) +fi + +dnl search screen +AC_MSG_CHECKING([whether to include the search screen]) +AC_ARG_ENABLE([search-screen], + AC_HELP_STRING([--enable-search-screen], + [Enable search screen @<:@default=yes@:>@]), + [search_screen="$enableval"], + [search_screen=yes]) +AC_MSG_RESULT([$search_screen]) +if test "x$search_screen" != "xyes" ; then + AC_DEFINE(DISABLE_SEARCH_SCREEN, 1, [Disable search screen]) +fi + dnl Optional screen - key editor AC_MSG_CHECKING([whether to include the key editor screen]) AC_ARG_ENABLE([key-screen], @@ -157,8 +179,8 @@ AC_ARG_ENABLE([key-screen], [keydef_screen="$enableval"], [keydef_screen=yes]) AC_MSG_RESULT([$keydef_screen]) -if test "x$keydef_screen" = "xyes" ; then - AC_DEFINE(ENABLE_KEYDEF_SCREEN, 1, [Enable key editor screen]) +if test "x$keydef_screen" != "xyes" ; then + AC_DEFINE(DISABLE_KEYDEF_SCREEN, 1, [Disable key editor screen]) fi dnl Optional screen - clock @@ -169,8 +191,8 @@ AC_ARG_ENABLE([clock-screen], [clock_screen="$enableval"], [clock_screen=no]) AC_MSG_RESULT([$clock_screen]) -if test "x$clock_screen" = "xyes" ; then - AC_DEFINE(ENABLE_CLOCK_SCREEN, 1, [Enable clock screen]) +if test "x$clock_screen" != "xyes" ; then + AC_DEFINE(DISABLE_CLOCK_SCREEN, 1, [Disable clock screen]) fi dnl Default host diff --git a/po/POTFILES.in b/po/POTFILES.in index c4c58ba98..6a29351e0 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -6,6 +6,7 @@ src/screen.c src/screen_utils.c src/screen_play.c src/screen_file.c +src/screen_search.c src/screen_keydef.c src/screen_clock.c src/screen_help.c diff --git a/po/ncmpc.pot b/po/ncmpc.pot index 0c54f93a0..def7ac430 100644 --- a/po/ncmpc.pot +++ b/po/ncmpc.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2004-07-03 19:36+0200\n" +"POT-Creation-Date: 2004-11-14 22:38+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -16,120 +16,125 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: src/ncmpc.h:26 +#: src/ncmpc.h:36 msgid "y" msgstr "" -#: src/ncmpc.h:27 +#: src/ncmpc.h:37 msgid "n" msgstr "" -#: src/main.c:132 +#: src/main.c:133 msgid "Exiting..." msgstr "" -#: src/main.c:237 +#: src/main.c:266 #, c-format msgid "Error: MPD version %d.%d.%d is to old (0.11.0 needed).\n" msgstr "" -#: src/main.c:289 +#: src/main.c:318 #, c-format msgid "Connecting to %s... [Press %s to abort]" msgstr "" -#: src/main.c:301 +#: src/main.c:330 #, c-format msgid "Connected to %s!" msgstr "" -#: src/screen.c:149 +#: src/screen.c:170 msgid ":Help " msgstr "" -#: src/screen.c:153 +#: src/screen.c:174 msgid ":Playlist " msgstr "" -#: src/screen.c:157 -msgid ":Browse" +#: src/screen.c:178 +msgid ":Browse " msgstr "" -#: src/screen.c:161 +#: src/screen.c:183 +msgid ":Search " +msgstr "" + +#: src/screen.c:188 msgid "Volume n/a " msgstr "" -#: src/screen.c:165 +#: src/screen.c:192 #, c-format msgid " Volume %d%%" msgstr "" -#: src/screen.c:245 +#: src/screen.c:271 msgid "Playing:" msgstr "" -#: src/screen.c:248 +#: src/screen.c:274 msgid "[Paused]" msgstr "" -#: src/screen.c:380 src/screen.c:484 +#: src/screen.c:390 src/screen.c:499 +#, c-format msgid "Error: Screen to small!\n" msgstr "" -#: src/screen.c:640 +#: src/screen.c:644 msgid "Repeat is on" msgstr "" -#: src/screen.c:641 +#: src/screen.c:645 msgid "Repeat is off" msgstr "" -#: src/screen.c:644 +#: src/screen.c:648 msgid "Random is on" msgstr "" -#: src/screen.c:645 +#: src/screen.c:649 msgid "Random is off" msgstr "" -#: src/screen.c:648 +#: src/screen.c:652 #, c-format msgid "Crossfade %d seconds" msgstr "" -#: src/screen.c:651 +#: src/screen.c:655 msgid "Database updated!" msgstr "" -#: src/screen.c:815 +#: src/screen.c:817 msgid "Shuffled playlist!" msgstr "" -#: src/screen.c:819 +#: src/screen.c:821 msgid "Cleared playlist!" msgstr "" -#: src/screen.c:834 +#: src/screen.c:839 msgid "Database update started!" msgstr "" -#: src/screen.c:837 src/screen_file.c:626 +#: src/screen.c:842 src/screen_file.c:662 msgid "Database update running..." msgstr "" -#: src/screen.c:850 +#: src/screen.c:855 msgid "Find mode: Wrapped" msgstr "" -#: src/screen.c:851 +#: src/screen.c:856 msgid "Find mode: Normal" msgstr "" -#: src/screen.c:856 +#: src/screen.c:861 msgid "Auto center mode: On" msgstr "" -#: src/screen.c:857 +#: src/screen.c:862 msgid "Auto center mode: Off" msgstr "" @@ -141,7 +146,7 @@ msgstr "" msgid "Find backward: " msgstr "" -#: src/screen_utils.c:169 +#: src/screen_utils.c:165 #, c-format msgid "Unable to find '%s'" msgstr "" @@ -155,71 +160,111 @@ msgstr "" msgid "Replace %s [%s/%s] ? " msgstr "" -#: src/screen_play.c:197 src/screen_file.c:317 src/screen_keydef.c:161 +#: src/screen_play.c:198 src/screen_file.c:319 src/screen_keydef.c:162 msgid "Aborted!" msgstr "" #. success -#: src/screen_play.c:203 +#: src/screen_play.c:204 #, c-format msgid "Saved %s" msgstr "" -#: src/screen_play.c:267 +#: src/screen_play.c:268 msgid "Add: " msgstr "" -#: src/screen_play.c:322 +#: src/screen_play.c:323 msgid "Playlist" msgstr "" -#: src/screen_play.c:324 +#: src/screen_play.c:325 #, c-format msgid "Playlist on %s" msgstr "" -#: src/screen_file.c:281 +#: src/screen_file.c:282 #, c-format msgid "Loading playlist %s..." msgstr "" -#: src/screen_file.c:303 +#: src/screen_file.c:304 msgid "You can only delete playlists!" msgstr "" -#: src/screen_file.c:310 +#: src/screen_file.c:311 #, c-format msgid "Delete playlist %s [%s/%s] ? " msgstr "" -#: src/screen_file.c:325 +#: src/screen_file.c:327 msgid "Playlist deleted!" msgstr "" -#: src/screen_file.c:362 +#: src/screen_file.c:345 src/screen_file.c:462 src/screen_file.c:488 #, c-format -msgid "Adding directory %s...\n" +msgid "Adding '%s' to playlist\n" msgstr "" -#: src/screen_file.c:427 src/screen_file.c:453 +#: src/screen_file.c:394 #, c-format -msgid "Adding '%s' to playlist\n" +msgid "Adding directory %s...\n" msgstr "" -#: src/screen_file.c:529 +#: src/screen_file.c:564 #, c-format msgid "Browse: %s" msgstr "" -#: src/screen_file.c:611 +#: src/screen_file.c:647 msgid "Screen updated!" msgstr "" -#: src/screen_file.c:618 +#: src/screen_file.c:654 #, c-format msgid "Database update of %s started!" msgstr "" +#: src/screen_search.c:50 +msgid "Title" +msgstr "" + +#: src/screen_search.c:51 +msgid "Artist" +msgstr "" + +#: src/screen_search.c:52 +msgid "Album" +msgstr "" + +#: src/screen_search.c:53 +msgid "Filename" +msgstr "" + +#: src/screen_search.c:114 +msgid "Search: " +msgstr "" + +#: src/screen_search.c:162 +#, c-format +msgid "Press %s for a new search" +msgstr "" + +#: src/screen_search.c:214 +#, c-format +msgid "Search: Results for %s [%s]" +msgstr "" + +#: src/screen_search.c:218 +#, c-format +msgid "Search: Press %s for a new search [%s]" +msgstr "" + +#: src/screen_search.c:252 +#, c-format +msgid "Search mode: %s" +msgstr "" + #: src/screen_keydef.c:46 msgid "===> Apply & Save key bindings " msgstr "" @@ -260,34 +305,34 @@ msgstr "" msgid "Enter new key for %s: " msgstr "" -#: src/screen_keydef.c:167 +#: src/screen_keydef.c:168 #, c-format msgid "Error: key %s is already used for %s" msgstr "" -#: src/screen_keydef.c:176 +#: src/screen_keydef.c:177 #, c-format msgid "Assigned %s to %s" msgstr "" -#: src/screen_keydef.c:219 +#: src/screen_keydef.c:220 #, c-format msgid "%d. Add new key " msgstr "" -#: src/screen_keydef.c:266 +#: src/screen_keydef.c:267 msgid "Welcome to the key editor!" msgstr "" -#: src/screen_keydef.c:282 +#: src/screen_keydef.c:283 msgid "Note: Did you forget to 'Apply' your changes?" msgstr "" -#: src/screen_keydef.c:289 +#: src/screen_keydef.c:290 msgid "Edit key bindings" msgstr "" -#: src/screen_keydef.c:291 +#: src/screen_keydef.c:292 #, c-format msgid "Edit keys for %s" msgstr "" @@ -300,284 +345,308 @@ msgstr "" msgid "Keys - Movement" msgstr "" -#: src/screen_help.c:65 +#: src/screen_help.c:68 msgid "Keys - Global" msgstr "" -#: src/screen_help.c:92 +#: src/screen_help.c:95 msgid "Keys - Playlist screen" msgstr "" -#: src/screen_help.c:94 +#: src/screen_help.c:97 msgid "Play" msgstr "" -#: src/screen_help.c:97 +#: src/screen_help.c:100 msgid "Move song up" msgstr "" -#: src/screen_help.c:98 +#: src/screen_help.c:101 msgid "Move song down" msgstr "" -#: src/screen_help.c:101 +#: src/screen_help.c:104 msgid "Center" msgstr "" -#: src/screen_help.c:106 +#: src/screen_help.c:109 msgid "Keys - Browse screen" msgstr "" -#: src/screen_help.c:108 -msgid "Enter directory" +#: src/screen_help.c:111 +msgid "Enter directory/Select and play song" +msgstr "" + +#: src/screen_help.c:113 +msgid "Delete playlist" +msgstr "" + +#: src/screen_help.c:119 +msgid "Keys - Search screen" msgstr "" -#: src/screen_help.c:210 +#: src/screen_help.c:121 +msgid "Search" +msgstr "" + +#: src/screen_help.c:122 +msgid "Select and play" +msgstr "" + +#: src/screen_help.c:209 msgid "Help" msgstr "" -#: src/command.c:68 +#: src/command.c:70 msgid "Key configuration screen" msgstr "" -#: src/command.c:71 +#: src/command.c:73 msgid "Quit" msgstr "" -#: src/command.c:75 +#: src/command.c:77 msgid "Move cursor up" msgstr "" -#: src/command.c:77 +#: src/command.c:79 msgid "Move cursor down" msgstr "" -#: src/command.c:79 +#: src/command.c:81 msgid "Home " msgstr "" -#: src/command.c:81 +#: src/command.c:83 msgid "End " msgstr "" -#: src/command.c:83 +#: src/command.c:85 msgid "Page up" msgstr "" -#: src/command.c:85 +#: src/command.c:87 msgid "Page down" msgstr "" -#: src/command.c:90 +#: src/command.c:92 msgid "Help screen" msgstr "" -#: src/command.c:92 +#: src/command.c:94 msgid "Playlist screen" msgstr "" -#: src/command.c:94 +#: src/command.c:96 msgid "Browse screen" msgstr "" -#: src/command.c:99 +#: src/command.c:101 msgid "Play/Enter directory" msgstr "" -#: src/command.c:101 +#: src/command.c:103 msgid "Pause" msgstr "" -#: src/command.c:103 +#: src/command.c:105 msgid "Stop" msgstr "" -#: src/command.c:105 +#: src/command.c:107 msgid "Next track" msgstr "" -#: src/command.c:107 +#: src/command.c:109 msgid "Previous track" msgstr "" -#: src/command.c:109 +#: src/command.c:111 msgid "Seek forward" msgstr "" -#: src/command.c:111 +#: src/command.c:113 msgid "Seek backward" msgstr "" -#: src/command.c:113 +#: src/command.c:115 msgid "Increase volume" msgstr "" -#: src/command.c:115 +#: src/command.c:117 msgid "Decrease volume" msgstr "" -#: src/command.c:117 +#: src/command.c:119 msgid "Select/deselect song in playlist" msgstr "" -#: src/command.c:119 +#: src/command.c:121 msgid "Delete song from playlist" msgstr "" -#: src/command.c:121 +#: src/command.c:123 msgid "Shuffle playlist" msgstr "" -#: src/command.c:123 +#: src/command.c:125 msgid "Clear playlist" msgstr "" -#: src/command.c:125 +#: src/command.c:127 msgid "Toggle repeat mode" msgstr "" -#: src/command.c:127 +#: src/command.c:129 msgid "Toggle random mode" msgstr "" -#: src/command.c:129 +#: src/command.c:131 msgid "Toggle crossfade mode" msgstr "" -#: src/command.c:131 +#: src/command.c:133 msgid "Start a music database update" msgstr "" -#: src/command.c:133 +#: src/command.c:135 msgid "Save playlist" msgstr "" -#: src/command.c:135 +#: src/command.c:137 msgid "Add url/file to playlist" msgstr "" -#: src/command.c:140 +#: src/command.c:142 msgid "Move item up" msgstr "" -#: src/command.c:142 +#: src/command.c:144 msgid "Move item down" msgstr "" -#: src/command.c:144 +#: src/command.c:146 msgid "Update screen" msgstr "" -#: src/command.c:149 +#: src/command.c:151 msgid "Toggle find mode" msgstr "" -#: src/command.c:151 +#: src/command.c:153 msgid "Toggle auto center mode" msgstr "" -#: src/command.c:156 +#: src/command.c:158 msgid "Next screen" msgstr "" -#: src/command.c:158 +#: src/command.c:160 msgid "Previous screen" msgstr "" -#: src/command.c:163 +#: src/command.c:165 msgid "Forward find" msgstr "" -#: src/command.c:165 +#: src/command.c:167 msgid "Forward find next" msgstr "" -#: src/command.c:167 +#: src/command.c:169 msgid "Backward find" msgstr "" -#: src/command.c:169 +#: src/command.c:171 msgid "Backward find previous" msgstr "" -#: src/command.c:175 +#: src/command.c:177 +msgid "Search screen" +msgstr "" + +#: src/command.c:179 +msgid "Change search mode" +msgstr "" + +#: src/command.c:184 msgid "Clock screen" msgstr "" -#: src/command.c:197 +#: src/command.c:206 msgid "Undefined" msgstr "" -#: src/command.c:199 +#: src/command.c:208 msgid "Space" msgstr "" -#: src/command.c:201 +#: src/command.c:210 msgid "Enter" msgstr "" -#: src/command.c:203 +#: src/command.c:212 msgid "Backspace" msgstr "" -#: src/command.c:205 +#: src/command.c:214 msgid "Delete" msgstr "" -#: src/command.c:207 +#: src/command.c:216 msgid "Up" msgstr "" -#: src/command.c:209 +#: src/command.c:218 msgid "Down" msgstr "" -#: src/command.c:211 +#: src/command.c:220 msgid "Left" msgstr "" -#: src/command.c:213 +#: src/command.c:222 msgid "Right" msgstr "" -#: src/command.c:215 +#: src/command.c:224 msgid "Home" msgstr "" -#: src/command.c:217 +#: src/command.c:226 msgid "End" msgstr "" -#: src/command.c:219 +#: src/command.c:228 msgid "PageDown" msgstr "" -#: src/command.c:221 +#: src/command.c:230 msgid "PageUp" msgstr "" -#: src/command.c:223 +#: src/command.c:232 msgid "Tab" msgstr "" -#: src/command.c:225 +#: src/command.c:234 msgid "Shift+Tab" msgstr "" -#: src/command.c:227 +#: src/command.c:236 msgid "Esc" msgstr "" -#: src/command.c:229 +#: src/command.c:238 msgid "Insert" msgstr "" -#: src/command.c:459 +#: src/command.c:488 #, c-format msgid "Key %s assigned to %s and %s (press %s for the key editor)" msgstr "" -#: src/command.c:466 src/command.c:473 +#: src/command.c:495 src/command.c:502 #, c-format msgid "Error: Key %s assigned to %s and %s !!!\n" msgstr "" @@ -593,18 +662,20 @@ msgid "Warning: Unknown color field - %s\n" msgstr "" #: src/colors.c:267 +#, c-format msgid "Terminal lacks support for changing colors!\n" msgstr "" #: src/colors.c:284 +#, c-format msgid "Terminal lacks color capabilities!\n" msgstr "" -#: src/support.c:166 +#: src/support.c:168 #, c-format msgid "Error: Unable to convert characters to %s" msgstr "" -#: src/support.c:195 +#: src/support.c:197 msgid "Error: Unable to convert characters to UTF-8" msgstr "" @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: ncmpc 0.11.0\n" -"Report-Msgid-Bugs-To: Kalle Wallin <kaw@linux.se>\n" -"POT-Creation-Date: 2004-07-03 19:36+0200\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2004-11-14 22:38+0100\n" "PO-Revision-Date: 2004-06-05 18:16+0200\n" "Last-Translator: Kalle Wallin <kaw@linux.se>\n" "Language-Team: sv <sv@li.org>\n" @@ -16,120 +16,125 @@ msgstr "" "Content-Type: text/plain; charset=ISO-8859-1\n" "Content-Transfer-Encoding: 8bit\n" -#: src/ncmpc.h:26 +#: src/ncmpc.h:36 msgid "y" msgstr "j" -#: src/ncmpc.h:27 +#: src/ncmpc.h:37 msgid "n" msgstr "" -#: src/main.c:132 +#: src/main.c:133 msgid "Exiting..." msgstr "Avslutar..." -#: src/main.c:237 +#: src/main.c:266 #, c-format msgid "Error: MPD version %d.%d.%d is to old (0.11.0 needed).\n" msgstr "MPD version %d.%d.%d är för gammal - uppgradera till version 0.11.x \n" -#: src/main.c:289 +#: src/main.c:318 #, c-format msgid "Connecting to %s... [Press %s to abort]" msgstr "Ansluter till %s... [Tryck %s för att avbryta]" -#: src/main.c:301 +#: src/main.c:330 #, c-format msgid "Connected to %s!" msgstr "Ansluten till %s!" -#: src/screen.c:149 +#: src/screen.c:170 msgid ":Help " msgstr ":Hjälp " -#: src/screen.c:153 +#: src/screen.c:174 msgid ":Playlist " msgstr ":Spellista " -#: src/screen.c:157 -msgid ":Browse" +#: src/screen.c:178 +msgid ":Browse " msgstr ":Filer " -#: src/screen.c:161 +#: src/screen.c:183 +msgid ":Search " +msgstr ":Sök " + +#: src/screen.c:188 msgid "Volume n/a " msgstr "Volym: n/a " -#: src/screen.c:165 +#: src/screen.c:192 #, c-format msgid " Volume %d%%" msgstr " Volym: %d%%" -#: src/screen.c:245 +#: src/screen.c:271 msgid "Playing:" msgstr "Spelar:" -#: src/screen.c:248 +#: src/screen.c:274 msgid "[Paused]" msgstr "[Pausad]" -#: src/screen.c:380 src/screen.c:484 +#: src/screen.c:390 src/screen.c:499 +#, c-format msgid "Error: Screen to small!\n" msgstr "Fel: Terminal är för liten!\n" -#: src/screen.c:640 +#: src/screen.c:644 msgid "Repeat is on" msgstr "Repeat är på" -#: src/screen.c:641 +#: src/screen.c:645 msgid "Repeat is off" msgstr "Repeat är av" -#: src/screen.c:644 +#: src/screen.c:648 msgid "Random is on" msgstr "Random är på" -#: src/screen.c:645 +#: src/screen.c:649 msgid "Random is off" msgstr "Random är av" -#: src/screen.c:648 +#: src/screen.c:652 #, c-format msgid "Crossfade %d seconds" msgstr "Crossfade %d sekunder" -#: src/screen.c:651 +#: src/screen.c:655 msgid "Database updated!" msgstr "Databasen är uppdaterad!" -#: src/screen.c:815 +#: src/screen.c:817 msgid "Shuffled playlist!" msgstr "Slumpsorterat spellistan!" -#: src/screen.c:819 +#: src/screen.c:821 msgid "Cleared playlist!" msgstr "Rensar spellistan!" -#: src/screen.c:834 +#: src/screen.c:839 msgid "Database update started!" msgstr "Uppdaterar databasen!" -#: src/screen.c:837 src/screen_file.c:626 +#: src/screen.c:842 src/screen_file.c:662 msgid "Database update running..." msgstr "Databasen uppdateras..." -#: src/screen.c:850 +#: src/screen.c:855 msgid "Find mode: Wrapped" msgstr "Sök runt (börja om)" -#: src/screen.c:851 +#: src/screen.c:856 msgid "Find mode: Normal" msgstr "Sök normalt (till slut/början)" -#: src/screen.c:856 +#: src/screen.c:861 msgid "Auto center mode: On" msgstr "Automatisk centrering är på" -#: src/screen.c:857 +#: src/screen.c:862 msgid "Auto center mode: Off" msgstr "Automatisk centrering är av" @@ -141,7 +146,7 @@ msgstr "Sök: " msgid "Find backward: " msgstr "Sök (bakåt): " -#: src/screen_utils.c:169 +#: src/screen_utils.c:165 #, c-format msgid "Unable to find '%s'" msgstr "Hittar inte '%s'" @@ -155,71 +160,111 @@ msgstr "Spara spellistan som: " msgid "Replace %s [%s/%s] ? " msgstr "Ersätt '%s' [%s/%s] ? " -#: src/screen_play.c:197 src/screen_file.c:317 src/screen_keydef.c:161 +#: src/screen_play.c:198 src/screen_file.c:319 src/screen_keydef.c:162 msgid "Aborted!" msgstr "Avbröt!" #. success -#: src/screen_play.c:203 +#: src/screen_play.c:204 #, c-format msgid "Saved %s" msgstr "Sparat %s" -#: src/screen_play.c:267 +#: src/screen_play.c:268 msgid "Add: " msgstr "Lägg till: " -#: src/screen_play.c:322 +#: src/screen_play.c:323 msgid "Playlist" msgstr "Spellista" -#: src/screen_play.c:324 +#: src/screen_play.c:325 #, c-format msgid "Playlist on %s" msgstr "Spellista på %s" -#: src/screen_file.c:281 +#: src/screen_file.c:282 #, c-format msgid "Loading playlist %s..." msgstr "Laddar %s..." -#: src/screen_file.c:303 +#: src/screen_file.c:304 msgid "You can only delete playlists!" msgstr "Du kan endast radera spellistor!" -#: src/screen_file.c:310 +#: src/screen_file.c:311 #, c-format msgid "Delete playlist %s [%s/%s] ? " msgstr "Radera '%s' [%s/%s] ? " -#: src/screen_file.c:325 +#: src/screen_file.c:327 msgid "Playlist deleted!" msgstr "Spellistan raderad!" -#: src/screen_file.c:362 -#, c-format -msgid "Adding directory %s...\n" -msgstr "Lägger till alla filer i %s...\n" - -#: src/screen_file.c:427 src/screen_file.c:453 +#: src/screen_file.c:345 src/screen_file.c:462 src/screen_file.c:488 #, c-format msgid "Adding '%s' to playlist\n" msgstr "Lägger till '%s'...\n" -#: src/screen_file.c:529 +#: src/screen_file.c:394 +#, c-format +msgid "Adding directory %s...\n" +msgstr "Lägger till alla filer i %s...\n" + +#: src/screen_file.c:564 #, c-format msgid "Browse: %s" msgstr "Filer: %s" -#: src/screen_file.c:611 +#: src/screen_file.c:647 msgid "Screen updated!" msgstr "Uppdaterat!" -#: src/screen_file.c:618 +#: src/screen_file.c:654 #, c-format msgid "Database update of %s started!" msgstr "Uppdaterar databasen ifrån %s!" +#: src/screen_search.c:50 +msgid "Title" +msgstr "Titel" + +#: src/screen_search.c:51 +msgid "Artist" +msgstr "" + +#: src/screen_search.c:52 +msgid "Album" +msgstr "" + +#: src/screen_search.c:53 +msgid "Filename" +msgstr "Filnamn" + +#: src/screen_search.c:114 +msgid "Search: " +msgstr "Sök: " + +#: src/screen_search.c:162 +#, c-format +msgid "Press %s for a new search" +msgstr "Tryck på %s för en ny sökning" + +#: src/screen_search.c:214 +#, c-format +msgid "Search: Results for %s [%s]" +msgstr "Sök: %s [%s]" + +#: src/screen_search.c:218 +#, c-format +msgid "Search: Press %s for a new search [%s]" +msgstr "Tryck ppå %s för en ny sökning [%s]" + +#: src/screen_search.c:252 +#, c-format +msgid "Search mode: %s" +msgstr "Sök efter: %s" + #: src/screen_keydef.c:46 msgid "===> Apply & Save key bindings " msgstr "==> Verkställ och Spara" @@ -260,34 +305,34 @@ msgstr "Raderad" msgid "Enter new key for %s: " msgstr "Ny tangent för %s: " -#: src/screen_keydef.c:167 +#: src/screen_keydef.c:168 #, c-format msgid "Error: key %s is already used for %s" msgstr "Tangenten %s används redan för %s" -#: src/screen_keydef.c:176 +#: src/screen_keydef.c:177 #, c-format msgid "Assigned %s to %s" msgstr "%s = %s" -#: src/screen_keydef.c:219 +#: src/screen_keydef.c:220 #, c-format msgid "%d. Add new key " msgstr "%d. Lägg till ny tangent" -#: src/screen_keydef.c:266 +#: src/screen_keydef.c:267 msgid "Welcome to the key editor!" msgstr "Här kan du ändra tangentdefinitioner" -#: src/screen_keydef.c:282 +#: src/screen_keydef.c:283 msgid "Note: Did you forget to 'Apply' your changes?" msgstr "OBS! Du glömde väl inte att Verkställa?" -#: src/screen_keydef.c:289 +#: src/screen_keydef.c:290 msgid "Edit key bindings" msgstr "Ändra tangentdefinitioner" -#: src/screen_keydef.c:291 +#: src/screen_keydef.c:292 #, c-format msgid "Edit keys for %s" msgstr "Ändra tangenter för kommandot '%s'" @@ -300,284 +345,308 @@ msgstr "Klocka" msgid "Keys - Movement" msgstr "Tangenter - Navigation" -#: src/screen_help.c:65 +#: src/screen_help.c:68 msgid "Keys - Global" msgstr "Tangenter - Globala" -#: src/screen_help.c:92 +#: src/screen_help.c:95 msgid "Keys - Playlist screen" msgstr "Tangenter - Spellista" -#: src/screen_help.c:94 +#: src/screen_help.c:97 msgid "Play" msgstr "Starta/Spela markerad" -#: src/screen_help.c:97 +#: src/screen_help.c:100 msgid "Move song up" msgstr "Flytta markerad uppåt i spellistan" -#: src/screen_help.c:98 +#: src/screen_help.c:101 msgid "Move song down" msgstr "Flytta markerad nedåt i spellistan" -#: src/screen_help.c:101 +#: src/screen_help.c:104 msgid "Center" msgstr "Centrera" -#: src/screen_help.c:106 +#: src/screen_help.c:109 msgid "Keys - Browse screen" msgstr "Tangenter - Filer" -#: src/screen_help.c:108 -msgid "Enter directory" -msgstr "Välj bibliotek" +#: src/screen_help.c:111 +msgid "Enter directory/Select and play song" +msgstr "Välj bibliotek/Lägg till spellistan och spela" + +#: src/screen_help.c:113 +msgid "Delete playlist" +msgstr "Radera spellista" + +#: src/screen_help.c:119 +msgid "Keys - Search screen" +msgstr "Tangenter - Databas sökning" + +#: src/screen_help.c:121 +msgid "Search" +msgstr "Sök" + +#: src/screen_help.c:122 +msgid "Select and play" +msgstr "Lägg till spellistan och spela" -#: src/screen_help.c:210 +#: src/screen_help.c:209 msgid "Help" msgstr "Hjälp" -#: src/command.c:68 +#: src/command.c:70 msgid "Key configuration screen" msgstr "Tangentdefinitioner" -#: src/command.c:71 +#: src/command.c:73 msgid "Quit" msgstr "Avsluta" -#: src/command.c:75 +#: src/command.c:77 msgid "Move cursor up" msgstr "Markör nedåt" -#: src/command.c:77 +#: src/command.c:79 msgid "Move cursor down" msgstr "Markör uppåt" -#: src/command.c:79 +#: src/command.c:81 msgid "Home " msgstr "Markören till den första raden" -#: src/command.c:81 +#: src/command.c:83 msgid "End " msgstr "Markören till den sista raden" -#: src/command.c:83 +#: src/command.c:85 msgid "Page up" msgstr "Markören en skärm uppåt" -#: src/command.c:85 +#: src/command.c:87 msgid "Page down" msgstr "Markören en skärm nedåt" -#: src/command.c:90 +#: src/command.c:92 msgid "Help screen" msgstr "Hjälp" -#: src/command.c:92 +#: src/command.c:94 msgid "Playlist screen" msgstr "Spellista" -#: src/command.c:94 +#: src/command.c:96 msgid "Browse screen" msgstr "Filer" -#: src/command.c:99 +#: src/command.c:101 msgid "Play/Enter directory" msgstr "Spela/Välj" -#: src/command.c:101 +#: src/command.c:103 msgid "Pause" msgstr "Paus" -#: src/command.c:103 +#: src/command.c:105 msgid "Stop" msgstr "Stopp" -#: src/command.c:105 +#: src/command.c:107 msgid "Next track" msgstr "Nästa" -#: src/command.c:107 +#: src/command.c:109 msgid "Previous track" msgstr "Föregånde" -#: src/command.c:109 +#: src/command.c:111 msgid "Seek forward" msgstr "Spola/Sök framåt" -#: src/command.c:111 +#: src/command.c:113 msgid "Seek backward" msgstr "Spola/Sök tillbaka" -#: src/command.c:113 +#: src/command.c:115 msgid "Increase volume" msgstr "Öka volymen" -#: src/command.c:115 +#: src/command.c:117 msgid "Decrease volume" msgstr "Minska volymen" -#: src/command.c:117 +#: src/command.c:119 msgid "Select/deselect song in playlist" -msgstr "Lägg till/Ta bort" +msgstr "Lägg till/Ta bort ifrån spellistan" -#: src/command.c:119 +#: src/command.c:121 msgid "Delete song from playlist" msgstr "Ta bort/Radera" -#: src/command.c:121 +#: src/command.c:123 msgid "Shuffle playlist" msgstr "Slumpsportera spellista" -#: src/command.c:123 +#: src/command.c:125 msgid "Clear playlist" msgstr "Rensa spellistan" -#: src/command.c:125 +#: src/command.c:127 msgid "Toggle repeat mode" msgstr "Repeat På/Av" -#: src/command.c:127 +#: src/command.c:129 msgid "Toggle random mode" msgstr "Random På/Av" -#: src/command.c:129 +#: src/command.c:131 msgid "Toggle crossfade mode" msgstr "Crossfade På/Av" -#: src/command.c:131 +#: src/command.c:133 msgid "Start a music database update" msgstr "Updatera databasen" -#: src/command.c:133 +#: src/command.c:135 msgid "Save playlist" msgstr "Spara spellista" -#: src/command.c:135 +#: src/command.c:137 msgid "Add url/file to playlist" msgstr "Lägger till url eller fil till spellistan" -#: src/command.c:140 +#: src/command.c:142 msgid "Move item up" msgstr "Flytta upp" -#: src/command.c:142 +#: src/command.c:144 msgid "Move item down" msgstr "Flytta ner" -#: src/command.c:144 +#: src/command.c:146 msgid "Update screen" msgstr "Updatera" -#: src/command.c:149 +#: src/command.c:151 msgid "Toggle find mode" msgstr "Ändra sök inställningar" -#: src/command.c:151 +#: src/command.c:153 msgid "Toggle auto center mode" msgstr "Automatisk centrering På/Av" -#: src/command.c:156 +#: src/command.c:158 msgid "Next screen" msgstr "Nästa skärm" -#: src/command.c:158 +#: src/command.c:160 msgid "Previous screen" msgstr "Tidigare skärm" -#: src/command.c:163 +#: src/command.c:165 msgid "Forward find" msgstr "Sök" -#: src/command.c:165 +#: src/command.c:167 msgid "Forward find next" msgstr "Upprepa Sökning" -#: src/command.c:167 +#: src/command.c:169 msgid "Backward find" msgstr "Sök bakåt" -#: src/command.c:169 +#: src/command.c:171 msgid "Backward find previous" msgstr "Upprepa Sökning bakåt" -#: src/command.c:175 +#: src/command.c:177 +msgid "Search screen" +msgstr "Databas sökning" + +#: src/command.c:179 +msgid "Change search mode" +msgstr "Ändra måltyp för databas sökning" + +#: src/command.c:184 msgid "Clock screen" msgstr "Klocka" -#: src/command.c:197 +#: src/command.c:206 msgid "Undefined" msgstr "Ej definerad" -#: src/command.c:199 +#: src/command.c:208 msgid "Space" msgstr "Mellanslag" -#: src/command.c:201 +#: src/command.c:210 msgid "Enter" msgstr "" -#: src/command.c:203 +#: src/command.c:212 msgid "Backspace" msgstr "" -#: src/command.c:205 +#: src/command.c:214 msgid "Delete" msgstr "Del" -#: src/command.c:207 +#: src/command.c:216 msgid "Up" msgstr "Uppåtpil" -#: src/command.c:209 +#: src/command.c:218 msgid "Down" msgstr "Nedåtpil" -#: src/command.c:211 +#: src/command.c:220 msgid "Left" msgstr "Vänsterpil" -#: src/command.c:213 +#: src/command.c:222 msgid "Right" msgstr "Högerpil" -#: src/command.c:215 +#: src/command.c:224 msgid "Home" msgstr "" -#: src/command.c:217 +#: src/command.c:226 msgid "End" msgstr "" -#: src/command.c:219 +#: src/command.c:228 msgid "PageDown" msgstr "" -#: src/command.c:221 +#: src/command.c:230 msgid "PageUp" msgstr "" -#: src/command.c:223 +#: src/command.c:232 msgid "Tab" msgstr "" -#: src/command.c:225 +#: src/command.c:234 msgid "Shift+Tab" msgstr "" -#: src/command.c:227 +#: src/command.c:236 msgid "Esc" msgstr "" -#: src/command.c:229 +#: src/command.c:238 msgid "Insert" msgstr "Ins" -#: src/command.c:459 +#: src/command.c:488 #, c-format msgid "Key %s assigned to %s and %s (press %s for the key editor)" msgstr "%s tilldelat kommandona %s och %s (tryck på %s och korrigera)" -#: src/command.c:466 src/command.c:473 +#: src/command.c:495 src/command.c:502 #, c-format msgid "Error: Key %s assigned to %s and %s !!!\n" msgstr "Fel: Tangenten %s är tilldelad både %s och %s !!!\n" @@ -593,18 +662,23 @@ msgid "Warning: Unknown color field - %s\n" msgstr "Varning: %s ej definerad.\n" #: src/colors.c:267 +#, c-format msgid "Terminal lacks support for changing colors!\n" msgstr "Terminalen saknar stöd för omdefinition av färger!\n" #: src/colors.c:284 +#, c-format msgid "Terminal lacks color capabilities!\n" msgstr "Terminalen saknar stöd för färger!\n" -#: src/support.c:166 +#: src/support.c:168 #, c-format msgid "Error: Unable to convert characters to %s" msgstr "Fel vid konvertering av tecken från UTF-8 till %s" -#: src/support.c:195 +#: src/support.c:197 msgid "Error: Unable to convert characters to UTF-8" msgstr "Fel vid konvertering av tecken till UTF-8" + +#~ msgid "Enter directory" +#~ msgstr "Välj bibliotek" diff --git a/src/Makefile.am b/src/Makefile.am index fc81ed9b9..796ac8d9d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,7 +11,7 @@ AM_CPPFLAGS = $(GLIB_CFLAGS) -DLOCALE_DIR=\""$(datadir)/locale"\" -DSYSCONFDIR=\ ncmpc_headers = libmpdclient.h mpdclient.h options.h conf.h command.h \ screen.h screen_utils.h list_window.h colors.h support.h \ - wreadln.h strfsong.h utils.h ncmpc.h + wreadln.h strfsong.h utils.h ncmpc.h screen_browse.h ncmpc_SOURCES = libmpdclient.c main.c mpdclient.c options.c conf.c command.c \ screen.c screen_utils.c screen_play.c screen_file.c \ diff --git a/src/command.c b/src/command.c index aecf31ab7..5b235e678 100644 --- a/src/command.c +++ b/src/command.c @@ -172,8 +172,15 @@ static command_definition_t cmds[] = /* extra screens */ +#ifdef ENABLE_SEARCH_SCREEN + { {'4', F4, 0 }, 0, CMD_SCREEN_SEARCH, "screen-search", + N_("Search screen") }, + { {'m', 0, 0 }, 0, CMD_SEARCH_MODE, "search-mode", + N_("Change search mode") }, +#endif + #ifdef ENABLE_CLOCK_SCREEN - { {'4', F4, 0 }, 0, CMD_SCREEN_CLOCK, "screen-clock", + { {'5', F5, 0 }, 0, CMD_SCREEN_CLOCK, "screen-clock", N_("Clock screen") }, #endif diff --git a/src/command.h b/src/command.h index fc436a443..29e6a0637 100644 --- a/src/command.h +++ b/src/command.h @@ -28,6 +28,7 @@ typedef enum CMD_SAVE_PLAYLIST, CMD_TOGGLE_FIND_WRAP, CMD_TOGGLE_AUTOCENTER, + CMD_SEARCH_MODE, CMD_LIST_PREVIOUS, CMD_LIST_NEXT, CMD_LIST_FIRST, diff --git a/src/conf.c b/src/conf.c index 740939d10..11dba9993 100644 --- a/src/conf.c +++ b/src/conf.c @@ -59,6 +59,7 @@ #define CONF_XTERM_TITLE "set-xterm-title" #define CONF_ENABLE_MOUSE "enable-mouse" #define CONF_CROSSFADE_TIME "crossfade-time" +#define CONF_SEARCH_MODE "search-mode" typedef enum { KEY_PARSER_UNKNOWN, @@ -472,6 +473,10 @@ read_rc_file(char *filename, options_t *options) { options->crossfade_time = atoi(value); } + else if( !strcasecmp(CONF_SEARCH_MODE, name) ) + { + options->search_mode = atoi(value); + } else { match_found = 0; diff --git a/src/mpdclient.c b/src/mpdclient.c index 1f7c73790..7cec3c967 100644 --- a/src/mpdclient.c +++ b/src/mpdclient.c @@ -819,6 +819,8 @@ mpdclient_filelist_free(mpdclient_filelist_t *filelist) GList *list = g_list_first(filelist->list); D("mpdclient_filelist_free()\n"); + if( list == NULL ) + return NULL; while( list!=NULL ) { filelist_entry_t *entry = list->data; @@ -881,6 +883,38 @@ mpdclient_filelist_get(mpdclient_t *c, gchar *path) } mpdclient_filelist_t * +mpdclient_filelist_search(mpdclient_t *c, int table, gchar *filter) +{ + mpdclient_filelist_t *filelist; + mpd_InfoEntity *entity; + gchar *filter_utf8 = locale_to_utf8(filter); + + D("mpdclient_filelist_filter(%s)\n", filter); + mpd_sendSearchCommand(c->connection, table, filter_utf8); + filelist = g_malloc0(sizeof(mpdclient_filelist_t)); + + while( (entity=mpd_getNextInfoEntity(c->connection)) ) + { + filelist_entry_t *entry = g_malloc0(sizeof(filelist_entry_t)); + + entry->entity = entity; + filelist->list = g_list_append(filelist->list, (gpointer) entry); + filelist->length++; + } + + if( mpdclient_finish_command(c) ) + { + g_free(filter_utf8); + return mpdclient_filelist_free(filelist); + } + + g_free(filter_utf8); + filelist->updated = TRUE; + + return filelist; +} + +mpdclient_filelist_t * mpdclient_filelist_update(mpdclient_t *c, mpdclient_filelist_t *filelist) { if( filelist != NULL ) diff --git a/src/mpdclient.h b/src/mpdclient.h index 016d1ba1b..89a2e6327 100644 --- a/src/mpdclient.h +++ b/src/mpdclient.h @@ -158,6 +158,9 @@ void mpdclient_playlist_callback(mpdclient_t *c, int event, gpointer data); /*** filelist functions ***************************************************/ mpdclient_filelist_t *mpdclient_filelist_free(mpdclient_filelist_t *filelist); mpdclient_filelist_t *mpdclient_filelist_get(mpdclient_t *c, gchar *path); +mpdclient_filelist_t *mpdclient_filelist_search(mpdclient_t *c, + int table, + gchar *path); mpdclient_filelist_t *mpdclient_filelist_update(mpdclient_t *c, mpdclient_filelist_t *flist); diff --git a/src/ncmpc.h b/src/ncmpc.h index 75fbf8e4a..0c72a099f 100644 --- a/src/ncmpc.h +++ b/src/ncmpc.h @@ -5,6 +5,16 @@ #include "config.h" #endif +#ifndef DISABLE_SEARCH_SCREEN +#define ENABLE_SEARCH_SCREEN 1 +#endif +#ifndef DISABLE_KEYDEF_SCREEN +#define ENABLE_KEYDEF_SCREEN 1 +#endif +#ifndef DISABLE_CLOCK_SCREEN +#define ENABLE_CLOCK_SCREEN 1 +#endif + #ifdef DEBUG void D(char *format, ...); #else diff --git a/src/options.c b/src/options.c index 4f1100f9d..a5289105b 100644 --- a/src/options.c +++ b/src/options.c @@ -160,6 +160,12 @@ handle_option(int c, char *arg) #ifdef ENABLE_NLS printf(" nls"); #endif +#ifdef HAVE_GETMOUSE + printf(" getmouse"); +#endif +#ifdef ENABLE_SEARCH_SCREEN + printf(" search-screen"); +#endif #ifdef ENABLE_KEYDEF_SCREEN printf(" key-screen"); #endif diff --git a/src/options.h b/src/options.h index e4d61e878..d264dd1fa 100644 --- a/src/options.h +++ b/src/options.h @@ -14,6 +14,7 @@ typedef struct char *xterm_title_format; int port; int crossfade_time; + int search_mode; gboolean reconnect; gboolean debug; gboolean find_wrap; diff --git a/src/screen.c b/src/screen.c index e390720b8..be4865f04 100644 --- a/src/screen.c +++ b/src/screen.c @@ -47,11 +47,14 @@ #define SCREEN_HELP_ID 100 #define SCREEN_KEYDEF_ID 101 #define SCREEN_CLOCK_ID 102 +#define SCREEN_SEARCH_ID 103 + /* screens */ extern screen_functions_t *get_screen_playlist(void); extern screen_functions_t *get_screen_browse(void); extern screen_functions_t *get_screen_help(void); +extern screen_functions_t *get_screen_search(void); extern screen_functions_t *get_screen_keydef(void); extern screen_functions_t *get_screen_clock(void); @@ -69,6 +72,9 @@ static screen_mode_info_t screens[] = { { SCREEN_PLAYLIST_ID, "playlist", get_screen_playlist }, { SCREEN_BROWSE_ID, "browse", get_screen_browse }, { SCREEN_HELP_ID, "help", get_screen_help }, +#ifdef ENABLE_SEARCH_SCREEN + { SCREEN_SEARCH_ID, "search", get_screen_search }, +#endif #ifdef ENABLE_KEYDEF_SCREEN { SCREEN_KEYDEF_ID, "keydef", get_screen_keydef }, #endif @@ -169,7 +175,13 @@ paint_top_window(char *header, mpdclient_t *c, int clear) colors_use(w, COLOR_TITLE_BOLD); waddstr(w, get_key_names(CMD_SCREEN_FILE, FALSE)); colors_use(w, COLOR_TITLE); - waddstr(w, _(":Browse")); + waddstr(w, _(":Browse ")); +#ifdef ENABLE_SEARCH_SCREEN + colors_use(w, COLOR_TITLE_BOLD); + waddstr(w, get_key_names(CMD_SCREEN_SEARCH, FALSE)); + colors_use(w, COLOR_TITLE); + waddstr(w, _(":Search ")); +#endif } if( c->status->volume==MPD_STATUS_NO_VOLUME ) { @@ -873,6 +885,9 @@ screen_cmd(mpdclient_t *c, command_t cmd) case CMD_SCREEN_HELP: switch_screen_mode(SCREEN_HELP_ID, c); break; + case CMD_SCREEN_SEARCH: + switch_screen_mode(SCREEN_SEARCH_ID, c); + break; case CMD_SCREEN_KEYDEF: switch_screen_mode(SCREEN_KEYDEF_ID, c); break; diff --git a/src/screen_browse.h b/src/screen_browse.h new file mode 100644 index 000000000..ddb3f21b0 --- /dev/null +++ b/src/screen_browse.h @@ -0,0 +1,30 @@ + +void clear_highlights(mpdclient_filelist_t *filelist); +void sync_highlights(mpdclient_t *c, mpdclient_filelist_t *filelist); +void set_highlight(mpdclient_filelist_t *filelist, + mpd_Song *song, + int highlight); + + +char *browse_lw_callback(int index, int *highlight, void *filelist); + +int browse_handle_select(screen_t *screen, + mpdclient_t *c, + list_window_t *lw, + mpdclient_filelist_t *filelist); +int browse_handle_enter(screen_t *screen, + mpdclient_t *c, + list_window_t *lw, + mpdclient_filelist_t *filelist); + +#ifdef HAVE_GETMOUSE +int browse_handle_mouse_event(screen_t *screen, + mpdclient_t *c, + list_window_t *lw, + mpdclient_filelist_t *filelist); +#else +#define browse_handle_mouse_event(s,c,lw,filelist) (0) +#endif + + + diff --git a/src/screen_clock.c b/src/screen_clock.c index d3d492559..c996c1924 100644 --- a/src/screen_clock.c +++ b/src/screen_clock.c @@ -13,7 +13,7 @@ #include "config.h" -#ifdef ENABLE_CLOCK_SCREEN +#ifndef DISABLE_CLOCK_SCREEN #include "ncmpc.h" #include "mpdclient.h" #include "options.h" diff --git a/src/screen_file.c b/src/screen_file.c index d25229d1e..75095db9a 100644 --- a/src/screen_file.c +++ b/src/screen_file.c @@ -33,6 +33,7 @@ #include "command.h" #include "screen.h" #include "screen_utils.h" +#include "screen_browse.h" #define USE_OLD_LAYOUT @@ -50,7 +51,7 @@ static mpdclient_filelist_t *filelist = NULL; /* clear the highlight flag for all items in the filelist */ -static void +void clear_highlights(mpdclient_filelist_t *filelist) { GList *list = g_list_first(filelist->list); @@ -65,7 +66,7 @@ clear_highlights(mpdclient_filelist_t *filelist) } /* change the highlight flag for a song */ -static void +void set_highlight(mpdclient_filelist_t *filelist, mpd_Song *song, int highlight) { GList *list = g_list_first(filelist->list); @@ -95,7 +96,7 @@ set_highlight(mpdclient_filelist_t *filelist, mpd_Song *song, int highlight) } /* sync highlight flags with playlist */ -static void +void sync_highlights(mpdclient_t *c, mpdclient_filelist_t *filelist) { GList *list = g_list_first(filelist->list); @@ -178,11 +179,11 @@ pop_lw_state(void) } /* list_window callback */ -static char * -list_callback(int index, int *highlight, void *data) +char * +browse_lw_callback(int index, int *highlight, void *data) { static char buf[BUFSIZE]; - /*mpdclient_t *c = (mpdclient_t *) data;*/ + mpdclient_filelist_t *filelist = (mpdclient_filelist_t *) data; filelist_entry_t *entry; mpd_InfoEntity *entity; @@ -327,9 +328,37 @@ handle_delete(screen_t *screen, mpdclient_t *c) return 0; } - static int -handle_enter(screen_t *screen, mpdclient_t *c) +enqueue_and_play(screen_t *screen, mpdclient_t *c, filelist_entry_t *entry) +{ + mpd_InfoEntity *entity = entry->entity; + mpd_Song *song = entity->info.song; + + if(!( entry->flags & HIGHLIGHT )) + { + if( mpdclient_cmd_add(c, song) == 0 ) + { + char buf[BUFSIZE]; + + entry->flags |= HIGHLIGHT; + strfsong(buf, BUFSIZE, LIST_FORMAT, song); + screen_status_printf(_("Adding \'%s\' to playlist\n"), buf); + mpdclient_update(c); /* get song id */ + } + else + return -1; + } + + int index = playlist_get_index_from_file(c, song->file); + mpdclient_cmd_play(c, index); + return 0; +} + +int +browse_handle_enter(screen_t *screen, + mpdclient_t *c, + list_window_t *lw, + mpdclient_filelist_t *filelist) { filelist_entry_t *entry; mpd_InfoEntity *entity; @@ -343,6 +372,8 @@ handle_enter(screen_t *screen, mpdclient_t *c) return change_directory(screen, c, entry); else if( entity->type==MPD_INFO_ENTITY_TYPE_PLAYLISTFILE ) return load_playlist(screen, c, entry); + else if( entity->type==MPD_INFO_ENTITY_TYPE_SONG ) + return enqueue_and_play(screen, c, entry); return -1; } @@ -403,8 +434,11 @@ add_directory(mpdclient_t *c, char *dir) } #endif -static int -handle_select(screen_t *screen, mpdclient_t *c) +int +browse_handle_select(screen_t *screen, + mpdclient_t *c, + list_window_t *lw, + mpdclient_filelist_t *filelist) { filelist_entry_t *entry; @@ -536,7 +570,7 @@ browse_paint(screen_t *screen, mpdclient_t *c) { lw->clear = 1; - list_window_paint(lw, list_callback, (void *) c); + list_window_paint(lw, browse_lw_callback, (void *) filelist); wnoutrefresh(lw->w); } @@ -549,14 +583,17 @@ browse_update(screen_t *screen, mpdclient_t *c) filelist->updated = FALSE; return; } - list_window_paint(lw, list_callback, (void *) c); + list_window_paint(lw, browse_lw_callback, (void *) filelist); wnoutrefresh(lw->w); } #ifdef HAVE_GETMOUSE -static int -handle_mouse_event(screen_t *screen, mpdclient_t *c) +int +browse_handle_mouse_event(screen_t *screen, + mpdclient_t *c, + list_window_t *lw, + mpdclient_filelist_t *filelist) { int row; int prev_selected = lw->selected; @@ -571,19 +608,17 @@ handle_mouse_event(screen_t *screen, mpdclient_t *c) if( bstate & BUTTON1_CLICKED ) { if( prev_selected == lw->selected ) - handle_enter(screen, c); + browse_handle_enter(screen, c, lw, filelist); } else if( bstate & BUTTON3_CLICKED ) { if( prev_selected == lw->selected ) - handle_select(screen, c); + browse_handle_select(screen, c, lw, filelist); } return 1; } -#else -#define handle_mouse_event(s,c) (0) -#endif +#endif static int browse_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) @@ -591,10 +626,10 @@ browse_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) switch(cmd) { case CMD_PLAY: - handle_enter(screen, c); + browse_handle_enter(screen, c, lw, filelist); return 1; case CMD_SELECT: - if( handle_select(screen, c) == 0 ) + if( browse_handle_select(screen, c, lw, filelist) == 0 ) { /* continue and select next item... */ cmd = CMD_LIST_NEXT; @@ -632,9 +667,9 @@ browse_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) case CMD_LIST_RFIND_NEXT: return screen_find(screen, c, lw, filelist->length, - cmd, list_callback); + cmd, browse_lw_callback, (void *) filelist); case CMD_MOUSE_EVENT: - return handle_mouse_event(screen,c); + return browse_handle_mouse_event(screen,c,lw,filelist); default: break; } diff --git a/src/screen_help.c b/src/screen_help.c index 73ccd6743..66acc3d87 100644 --- a/src/screen_help.c +++ b/src/screen_help.c @@ -53,6 +53,9 @@ static help_text_row_t help_text[] = { 0, CMD_SCREEN_HELP, NULL }, { 0, CMD_SCREEN_PLAY, NULL }, { 0, CMD_SCREEN_FILE, NULL }, +#ifdef ENABLE_SEARCH_SCREEN + { 0, CMD_SCREEN_SEARCH, NULL }, +#endif #ifdef ENABLE_CLOCK_SCREEN { 0, CMD_SCREEN_CLOCK, NULL }, #endif @@ -105,11 +108,22 @@ static help_text_row_t help_text[] = { 0, CMD_NONE, NULL }, { 1, CMD_NONE, N_("Keys - Browse screen") }, { 2, CMD_NONE, NULL }, - { 0, CMD_PLAY, N_("Enter directory") }, + { 0, CMD_PLAY, N_("Enter directory/Select and play song") }, { 0, CMD_SELECT, NULL }, - { 0, CMD_DELETE, NULL }, + { 0, CMD_DELETE, N_("Delete playlist") }, { 0, CMD_SCREEN_UPDATE, NULL }, +#ifdef ENABLE_SEARCH_SCREEN + { 0, CMD_NONE, NULL }, + { 0, CMD_NONE, NULL }, + { 1, CMD_NONE, N_("Keys - Search screen") }, + { 2, CMD_NONE, NULL }, + { 0, CMD_SCREEN_SEARCH, N_("Search") }, + { 0, CMD_PLAY, N_("Select and play") }, + { 0, CMD_SELECT, NULL }, + { 0, CMD_SEARCH_MODE, NULL }, +#endif + { 0, CMD_NONE, NULL }, {-1, CMD_NONE, NULL } }; @@ -255,7 +269,7 @@ help_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) lw->selected = lw->start+lw->rows; if( screen_find(screen, c, lw, help_text_rows, - cmd, list_callback) ) + cmd, list_callback, NULL) ) { /* center the row */ lw->start = lw->selected-(lw->rows/2); diff --git a/src/screen_keydef.c b/src/screen_keydef.c index 3451dd2ed..081b6ec39 100644 --- a/src/screen_keydef.c +++ b/src/screen_keydef.c @@ -26,7 +26,7 @@ #include "config.h" -#ifdef ENABLE_KEYDEF_SCREEN +#ifndef DISABLE_KEYDEF_SCREEN #include "ncmpc.h" #include "mpdclient.h" #include "options.h" @@ -369,7 +369,7 @@ keydef_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) case CMD_LIST_RFIND_NEXT: return screen_find(screen, c, lw, length, - cmd, list_callback); + cmd, list_callback, NULL); default: break; diff --git a/src/screen_play.c b/src/screen_play.c index 307471f2c..a86ab0128 100644 --- a/src/screen_play.c +++ b/src/screen_play.c @@ -444,7 +444,7 @@ play_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) case CMD_LIST_RFIND_NEXT: return screen_find(screen, c, lw, c->playlist.length, - cmd, list_callback); + cmd, list_callback, (void *) c); case CMD_MOUSE_EVENT: return handle_mouse_event(screen,c); default: diff --git a/src/screen_search.c b/src/screen_search.c index d82a049ef..95c3830c1 100644 --- a/src/screen_search.c +++ b/src/screen_search.c @@ -1,10 +1,315 @@ +/* + * $Id$ + * + * (c) 2004 by Kalle Wallin <kaw@linux.se> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include <ctype.h> #include <stdlib.h> #include <string.h> #include <glib.h> #include <ncurses.h> #include "config.h" +#ifndef DISABLE_SEARCH_SCREEN +#include "ncmpc.h" +#include "options.h" +#include "support.h" #include "mpdclient.h" +#include "strfsong.h" #include "command.h" #include "screen.h" +#include "screen_utils.h" +#include "screen_browse.h" + +#define SEARCH_TITLE 0 +#define SEARCH_ARTIST 1 +#define SEARCH_ALBUM 2 +#define SEARCH_FILE 3 + +typedef struct { + int table; + char *label; +} search_type_t; + +static search_type_t mode[] = { + { MPD_TABLE_TITLE, N_("Title") }, + { MPD_TABLE_ARTIST, N_("Artist") }, + { MPD_TABLE_ALBUM, N_("Album") }, + { MPD_TABLE_FILENAME, N_("Filename") }, + { 0, NULL } +}; + +static list_window_t *lw = NULL; +static mpdclient_filelist_t *filelist = NULL; +static gchar *pattern = NULL; + +/* the playlist have been updated -> fix highlights */ +static void +playlist_changed_callback(mpdclient_t *c, int event, gpointer data) +{ + if( filelist==NULL ) + return; + D("screen_search.c> playlist_callback() [%d]\n", event); + switch(event) + { + case PLAYLIST_EVENT_CLEAR: + clear_highlights(filelist); + break; + default: + sync_highlights(c, filelist); + break; + } +} + +/* sanity check search mode value */ +static void +search_check_mode(void) +{ + int max = 0; + + while( mode[max].label != NULL ) + max++; + if( options.search_mode<0 ) + options.search_mode = 0; + else if( options.search_mode>=max ) + options.search_mode = max-1; +} + +static void +search_clear(screen_t *screen, mpdclient_t *c, gboolean clear_pattern) +{ + if( filelist ) + { + mpdclient_remove_playlist_callback(c, playlist_changed_callback); + filelist = mpdclient_filelist_free(filelist); + } + if( clear_pattern && pattern ) + { + g_free(pattern); + pattern = NULL; + } +} + +static void +search_new(screen_t *screen, mpdclient_t *c) +{ + search_clear(screen, c, TRUE); + + pattern = screen_readln(screen->status_window.w, + _("Search: "), + NULL, + NULL, + NULL); + + if( pattern && strcmp(pattern,"")==0 ) + { + g_free(pattern); + pattern=NULL; + } + + if( pattern==NULL ) + { + list_window_reset(lw); + return; + } + + filelist = mpdclient_filelist_search(c, + mode[options.search_mode].table, + pattern); + sync_highlights(c, filelist); + mpdclient_install_playlist_callback(c, playlist_changed_callback); + list_window_check_selected(lw, filelist->length); +} + +static void +init(WINDOW *w, int cols, int rows) +{ + lw = list_window_init(w, cols, rows); +} + +static void +quit(void) +{ + if( filelist ) + filelist = mpdclient_filelist_free(filelist); + list_window_free(lw); + if( pattern ) + g_free(pattern); + pattern = NULL; +} + +static void +open(screen_t *screen, mpdclient_t *c) +{ + if( pattern==NULL ) + search_new(screen, c); + else + screen_status_printf(_("Press %s for a new search"), + get_key_names(CMD_SCREEN_SEARCH,0)); + search_check_mode(); +} + +static void +resize(int cols, int rows) +{ + lw->cols = cols; + lw->rows = rows; +} + +static void +close(void) +{ +} + +static void +paint(screen_t *screen, mpdclient_t *c) +{ + lw->clear = 1; + + if( filelist ) + { + list_window_paint(lw, browse_lw_callback, (void *) filelist); + filelist->updated = FALSE; + } + else + { + wmove(lw->w, 0, 0); + wclrtobot(lw->w); + } + wnoutrefresh(lw->w); +} + +void +update(screen_t *screen, mpdclient_t *c) +{ + if( filelist==NULL || filelist->updated ) + { + paint(screen, c); + return; + } + list_window_paint(lw, browse_lw_callback, (void *) filelist); + wnoutrefresh(lw->w); +} + +static char * +get_title(char *str, size_t size) +{ + if( pattern ) + g_snprintf(str, size, + _("Search: Results for %s [%s]"), + pattern, + _(mode[options.search_mode].label)); + else + g_snprintf(str, size, _("Search: Press %s for a new search [%s]"), + get_key_names(CMD_SCREEN_SEARCH,0), + _(mode[options.search_mode].label)); + + return str; +} + +static list_window_t * +get_filelist_window() +{ + return lw; +} + +static int +search_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) +{ + switch(cmd) + { + case CMD_PLAY: + browse_handle_enter(screen, c, lw, filelist); + return 1; + + case CMD_SELECT: + if( browse_handle_select(screen, c, lw, filelist) == 0 ) + { + /* continue and select next item... */ + cmd = CMD_LIST_NEXT; + } + return 1; + + case CMD_SEARCH_MODE: + options.search_mode++; + if( mode[options.search_mode].label == NULL ) + options.search_mode = 0; + screen_status_printf(_("Search mode: %s"), + _(mode[options.search_mode].label)); + /* continue and update... */ + case CMD_SCREEN_UPDATE: + if( pattern ) + { + search_clear(screen, c, FALSE); + filelist = mpdclient_filelist_search(c, + mode[options.search_mode].table, + pattern); + sync_highlights(c, filelist); + } + return 1; + + case CMD_SCREEN_SEARCH: + search_new(screen, c); + return 1; + + case CMD_CLEAR: + search_clear(screen, c, TRUE); + list_window_reset(lw); + return 1; + + case CMD_LIST_FIND: + case CMD_LIST_RFIND: + case CMD_LIST_FIND_NEXT: + case CMD_LIST_RFIND_NEXT: + if( filelist ) + return screen_find(screen, c, + lw, filelist->length, + cmd, browse_lw_callback, (void *) filelist); + case CMD_MOUSE_EVENT: + return browse_handle_mouse_event(screen,c,lw,filelist); + + default: + if( filelist ) + return list_window_cmd(lw, filelist->length, cmd); + } + + return 0; +} + +screen_functions_t * +get_screen_search(void) +{ + static screen_functions_t functions; + + memset(&functions, 0, sizeof(screen_functions_t)); + functions.init = init; + functions.exit = quit; + functions.open = open; + functions.close = close; + functions.resize = resize; + functions.paint = paint; + functions.update = update; + functions.cmd = search_cmd; + functions.get_lw = get_filelist_window; + functions.get_title = get_title; + + return &functions; +} + +#endif /* ENABLE_SEARCH_SCREEN */ diff --git a/src/screen_utils.c b/src/screen_utils.c index baa371be1..09ce85787 100644 --- a/src/screen_utils.c +++ b/src/screen_utils.c @@ -110,7 +110,8 @@ screen_find(screen_t *screen, list_window_t *lw, int rows, command_t findcmd, - list_window_callback_fn_t callback_fn) + list_window_callback_fn_t callback_fn, + void *callback_data) { int reversed = 0; int retval = 0; @@ -145,14 +146,14 @@ screen_find(screen_t *screen, if( reversed ) retval = list_window_rfind(lw, callback_fn, - c, + callback_data, screen->findbuf, options.find_wrap, rows); else retval = list_window_find(lw, callback_fn, - c, + callback_data, screen->findbuf, options.find_wrap); if( retval == 0 ) diff --git a/src/screen_utils.h b/src/screen_utils.h index 56e44d533..d68867a46 100644 --- a/src/screen_utils.h +++ b/src/screen_utils.h @@ -18,7 +18,8 @@ int screen_find(screen_t *screen, list_window_t *lw, int rows, command_t findcmd, - list_window_callback_fn_t callback_fn); + list_window_callback_fn_t callback_fn, + void *callback_data); void screen_display_completion_list(screen_t *screen, GList *list); |