Mercurial > audlegacy-plugins
changeset 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 | ccca9906abd0 |
children | dd78327f5747 |
files | src/lirc/common.h src/lirc/lirc.c src/lirc/lirc_cfg.c |
diffstat | 3 files changed, 33 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lirc/common.h Sat Jan 12 18:43:12 2008 +0100 +++ b/src/lirc/common.h Sat Jan 12 13:09:10 2008 -0600 @@ -2,6 +2,7 @@ extern gint b_enable_reconnect; extern gint reconnect_timeout; +extern gchar *aosd_font; void load_cfg(void); void save_cfg(void);
--- 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); }
--- a/src/lirc/lirc_cfg.c Sat Jan 12 18:43:12 2008 +0100 +++ b/src/lirc/lirc_cfg.c Sat Jan 12 13:09:10 2008 -0600 @@ -11,6 +11,7 @@ gint b_enable_reconnect; gint reconnect_timeout; +gchar *aosd_font = NULL; void load_cfg(void) { @@ -18,6 +19,8 @@ db = aud_cfg_db_open(); aud_cfg_db_get_int(db, "lirc", "enable_reconnect", &b_enable_reconnect); aud_cfg_db_get_int(db, "lirc", "reconnect_timeout", &reconnect_timeout); + if (!aud_cfg_db_get_string(db, "aosd", "text_fonts_name_0", &aosd_font)) + aosd_font = g_strdup("Sans 26"); if (!reconnect_timeout) reconnect_timeout = 5; aud_cfg_db_close(db); }