Mercurial > audlegacy-plugins
diff src/lirc/lirc.c @ 2305:738914331374
Add ability to enter track number using remote. (Bugzilla #115)
| author | Andrew O. Shadoura <bugzilla@tut.by> |
|---|---|
| date | Sat, 12 Jan 2008 13:09:10 -0600 |
| parents | 5e54ffc4f46f |
| children | 8d4db9a04cd2 |
line wrap: on
line diff
--- a/src/lirc/lirc.c Sat Jan 12 18:43:12 2008 +0100 +++ b/src/lirc/lirc.c Sat Jan 12 13:09:10 2008 -0600 @@ -69,6 +69,11 @@ gint input_tag; +char track_no[64]; +int track_no_pos; + +gint tid; + void init_lirc(void) { int flags; @@ -104,6 +109,8 @@ { load_cfg(); init_lirc(); + track_no_pos=0; + tid=0; } gboolean reconnect_lirc(gpointer data) @@ -113,6 +120,13 @@ return (lirc_fd==-1); } +gboolean jump_to(gpointer data) +{ + audacious_drct_pl_set_pos(atoi(track_no)-1); + track_no_pos=0; + return FALSE; +} + void lirc_input_callback(gpointer data,gint source, GdkInputCondition condition) { @@ -124,6 +138,7 @@ gint balance; gboolean show_pl; int n; + gchar *utf8_title_markup; while((ret=lirc_nextcode(&code))==0 && code!=NULL) { @@ -305,6 +320,19 @@ /* This is to refresh window content */ audacious_drct_pl_win_toggle(pl_visible); } + else if((strlen(c)==1) && ((*c>='0') || (*c<='9'))) + { + if (track_no_pos<63) + { + if (tid) g_source_remove(tid); + track_no[track_no_pos++]=*c; + track_no[track_no_pos]=0; + tid=g_timeout_add(1500, jump_to, NULL); + utf8_title_markup = g_markup_printf_escaped( + "<span font_desc='%s'>%s</span>", aosd_font, track_no); + aud_hook_call("aosd toggle", utf8_title_markup); + } + } else { fprintf(stderr,_("%s: unknown command \"%s\"\n"), @@ -341,4 +369,5 @@ lirc_deinit(); lirc_fd=-1; } + g_free(aosd_font); }
