Mercurial > audlegacy
changeset 156:23726a5a74bc trunk
[svn] Add LIRC general plugin.
author | chainsaw |
---|---|
date | Sat, 12 Nov 2005 17:11:46 -0800 |
parents | 2746c4cadd07 |
children | 8238f6aa0f09 |
files | Plugins/General/lirc/Makefile.am Plugins/General/lirc/about.c Plugins/General/lirc/lirc.c Plugins/General/lirc/lirc.h Plugins/General/lirc/lirc_image.h Plugins/General/lirc/lirc_mini.xpm |
diffstat | 6 files changed, 1341 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Plugins/General/lirc/Makefile.am Sat Nov 12 17:11:46 2005 -0800 @@ -0,0 +1,10 @@ +lib_LTLIBRARIES = liblirc.la + +libdir = $(plugindir)/$(GENERAL_PLUGIN_DIR) + +liblirc_la_LDFLAGS = -llirc_client $(PLUGIN_LDFLAGS) +liblirc_la_SOURCES = about.c lirc.c lirc.h lirc_image.h + +EXTRA_DIST = lirc_mini.xpm +INCLUDES = $(GTK_CFLAGS) -I$(top_builddir)/intl -I$(top_srcdir) +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Plugins/General/lirc/about.c Sat Nov 12 17:11:46 2005 -0800 @@ -0,0 +1,135 @@ +/* LIRC Plugin + + Copyright (C) 2005 Audacious development team + + Copyright (c) 1998-1999 Carl van Schaik (carl@leg.uct.ac.za) + code from gtuner lirc plugin + cRadio, kTuner, gtuner (c) 1998-1999 Carl van Schaik + + Copyright (C) 2000 Christoph Bartelmus (xmms@bartelmus.de) + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <gtk/gtk.h> + +#include "lirc.h" +#include "lirc_image.h" +#include "lirc_mini.xpm" + +#include <gdk/gdkx.h> + +static void win_set_icon (GtkWidget *win, char** image); + +static GtkWidget *dialog = NULL; +static GdkPixmap *icon; +static GdkBitmap *icon_mask; + +void about_close_cb(GtkWidget *w,gpointer data) +{ + gtk_widget_destroy(dialog); + gdk_pixmap_unref(icon); + gdk_bitmap_unref(icon_mask); +} + +void about(void) +{ + GdkPixmap *pixmap; + GtkWidget *bbox,*about_credits_logo_box,*about_credits_logo_frame; + GtkWidget *about_credits_logo; + GtkWidget *button,*label; + + if(dialog) return; + + dialog=gtk_dialog_new(); + gtk_window_set_title(GTK_WINDOW(dialog), + "About LIRC xmms-plugin " VERSION); + g_signal_connect(G_OBJECT(dialog),"destroy", + G_CALLBACK(gtk_widget_destroyed), + &dialog); + gtk_widget_realize(dialog); + + pixmap=gdk_pixmap_create_from_xpm_d(dialog->window, + NULL, NULL, lirc_image); + + about_credits_logo_box = gtk_hbox_new(TRUE, 0); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), + about_credits_logo_box, FALSE, FALSE, 0); + about_credits_logo_frame = gtk_frame_new(NULL); + gtk_frame_set_shadow_type(GTK_FRAME(about_credits_logo_frame), + GTK_SHADOW_OUT); + gtk_box_pack_start(GTK_BOX(about_credits_logo_box), + about_credits_logo_frame, FALSE, FALSE, 0); + + about_credits_logo = gtk_pixmap_new(pixmap, NULL); + gdk_pixmap_unref(pixmap); + + gtk_container_add(GTK_CONTAINER(about_credits_logo_frame), + about_credits_logo); + + gtk_container_border_width(GTK_CONTAINER(dialog),5); + + label=gtk_label_new("LIRC Plugin " VERSION "\n\ +A simple plugin that lets you control\n\ +audacious using the LIRC remote control daemon\n\n\ +Adapted for audacious usage by Tony Vroon <chainsaw@gentoo.org>\n\ +from the XMMS LIRC plugin by:\n\ +Carl van Schaik <carl@leg.uct.ac.za>\n\ +Christoph Bartelmus <xmms@bartelmus.de>\n\ +You can get LIRC information at:\n\ +http://fsinfo.cs.uni-sb.de/~columbus/lirc/index.html" + ); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),label, + TRUE,TRUE,10); + + bbox = gtk_hbutton_box_new(); + gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); + gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), + bbox, FALSE, FALSE, 0); + + button = gtk_button_new_with_label(("Close")); + g_signal_connect_object(G_OBJECT(button), "clicked", + G_CALLBACK(about_close_cb), NULL,G_CONNECT_SWAPPED) ; + + GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); + gtk_box_pack_start(GTK_BOX(bbox), button, TRUE, TRUE, 0); + gtk_widget_grab_default(button); + gtk_widget_grab_focus(button); + + win_set_icon(dialog, lirc_mini_xpm); + + gtk_widget_show_all(dialog); +} + +static void win_set_icon (GtkWidget *win, char** image) +{ + Atom icon_atom; + glong data[2]; + + icon=gdk_pixmap_create_from_xpm_d(win->window, &icon_mask, + &win->style->bg[GTK_STATE_NORMAL], + image); + data[0] = GDK_WINDOW_XWINDOW(icon); + data[1] = GDK_WINDOW_XWINDOW(icon_mask); + + icon_atom = gdk_atom_intern ("KWM_WIN_ICON", FALSE); + gdk_property_change (win->window, icon_atom, icon_atom, 32, + GDK_PROP_MODE_REPLACE, (guchar *)data, 2); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Plugins/General/lirc/lirc.c Sat Nov 12 17:11:46 2005 -0800 @@ -0,0 +1,991 @@ +/* Lirc plugin + + Copyright (C) 2005 Audacious development team + + Copyright (c) 1998-1999 Carl van Schaik (carl@leg.uct.ac.za) + + Copyright (C) 2000 Christoph Bartelmus (xmms@bartelmus.de) + + some code was stolen from: + IRman plugin for xmms by Charles Sielski (stray@teklabs.net) + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <stdio.h> +#include <unistd.h> +#include <fcntl.h> +#include <string.h> +#include <signal.h> +#include <stdlib.h> +#include <ctype.h> + +#include <gtk/gtk.h> + +#include <glib.h> + +#include "audacious/plugin.h" +#include "libaudacious/configfile.h" +#include "libaudacious/beepctrl.h" + +#include <lirc/lirc_client.h> + +#include "lirc.h" + +const char *plugin_name="LIRC Plugin " VERSION; + +GeneralPlugin lirc_plugin = { + NULL, + NULL, + -1, + NULL, + init, + about, + configure, + cleanup, +}; + +GeneralPlugin *get_gplugin_info(void) +{ + lirc_plugin.description = g_strdup_printf("LIRC Plugin"); + return(&lirc_plugin); +} + +int lirc_fd=-1; +struct lirc_config *config=NULL; +gint tracknr=0; +gint mute=0; /* mute flag */ +gint mute_vol=0; /* holds volume before mute */ + +gint input_tag; + +int select_tag=0; +GtkWidget *select_popup=NULL; +GtkStyle *popup_style=NULL; +GList *select_list=NULL; +GtkWidget *fsd; +gchar *fontname; + +struct select_info +{ + char *s; + size_t common; +}; + +struct title_info +{ + char *s; + int pos; +}; + +void clear_select_list(GList **list) +{ + GList *l; + + l=*list; + while(l!=NULL) + { + free(((struct select_info *) (l->data))->s); + free(l->data); + l=g_list_remove_link(l,l); + } + *list=NULL; +} + +void clear_title_list(GList **list) +{ + GList *l; + + l=*list; + while(l!=NULL) + { + free(((struct title_info *) (l->data))->s); + free(l->data); + l=g_list_remove_link(l,l); + } + *list=NULL; +} + +gchar *get_title_postfix(gchar *title) +{ + gchar *match; + GList *scan_list; + struct select_info *si; + size_t skip; + + match=title; + scan_list=select_list; + si=(struct select_info *) (scan_list->data); + while(*match) + { + if(!isalnum(*match)) + { + match++; + } + else + { + if(strchr(si->s,toupper(*match))!=NULL) + { + skip=si->common; + while(skip>0) + { + if(isalnum(*match)) + { + skip--; + } + match++; + if(!*match) + { + break; + } + } + scan_list=g_list_next(scan_list); + if(scan_list==NULL) + { + while(!isalnum(*match) && *match) + { + match++; + } + return(match); + } + si=(struct select_info *) (scan_list->data); + } + else + { + break; + } + } + } + return(NULL); +} + +#define SELECT_BORDER 8 + +gint remove_select_popup(GtkWidget **select_popup) +{ + gtk_widget_destroy(*select_popup); + *select_popup=NULL; + select_tag=0; + return(FALSE); +} + +/*void select_title(char *s,int num) +{ + GdkFont *font; + GtkStyle *style; + int gap,baseline_skip; + int width,height,x,y; + GList *new_list,*scan_list; + GList *title_list=NULL; + int length,i; + gchar *title; + struct select_info *si; + struct title_info *ti; + + if(select_tag!=0) + { + gtk_timeout_remove(select_tag); + remove_select_popup(&select_popup); + } + if(s!=NULL) + { + si=malloc(sizeof(*si)); + if(si==NULL) + { + return; + } + si->s=strdup(s); + si->common=1; + if(si->s==NULL) + { + free(si); + return; + } + new_list=g_list_append(select_list,si); + if(new_list==NULL) + { + free(si->s); + free(si); + return; + } + + select_list=new_list; + } + + scan_list=select_list; + while(scan_list) + { + scan_list=g_list_next(scan_list); + } + + length=xmms_remote_get_playlist_length + (lirc_plugin.xmms_session); + for(i=0;i<length;i++) + { + title=xmms_remote_get_playlist_title + (lirc_plugin.xmms_session,i); + if(get_title_postfix(title)!=NULL) + { + ti=malloc(sizeof(*ti)); + if(ti==NULL) break; + ti->s=strdup(title); + if(ti->s==NULL) + { + free(ti); + break; + } + ti->pos=i; + new_list=g_list_append(title_list,ti); + if(new_list==NULL) + { + free(ti->s); + free(ti); + break; + } + title_list=new_list; + } + } + select_popup=gtk_window_new(GTK_WINDOW_POPUP); + if(popup_style) + { + if(fontname!=NULL) + { + font=gdk_font_load(fontname); + } + else + { + font=gdk_font_load + ("-xxl-*-medium-r-semicondensed-*-*-*-75-75-*-*-*-*"); + } + if(font) popup_style->font=font; + gtk_widget_set_style(select_popup,popup_style); + } + gtk_widget_set_app_paintable(select_popup,TRUE); + gtk_window_set_policy(GTK_WINDOW(select_popup),FALSE,FALSE,TRUE); + gtk_widget_set_name(select_popup,"LIRC select list"); + style=select_popup->style; + font=style->font; + gap=(font->ascent+font->descent)/4; + if(gap<2) gap=2; + baseline_skip=font->ascent+font->descent+gap; + + if(title_list==NULL) + { + gchar *text="No match."; + + x=gdk_string_width(font,text); + width=SELECT_BORDER*2+x; + height=SELECT_BORDER*2+baseline_skip-gap; + gtk_widget_set_usize(select_popup,width,height); + x=(gdk_screen_width()-width)/2; + if(x<0) x=0; + y=(gdk_screen_height()-height)/2; + if(y<0) y=0; + gtk_widget_popup(select_popup,x,y); + gtk_paint_box(select_popup->style,select_popup->window, + GTK_STATE_NORMAL,GTK_SHADOW_OUT, + NULL,GTK_WIDGET(select_popup), + "LIRC select list",0,0,-1,-1); + + gtk_paint_string(style,select_popup->window, + GTK_STATE_NORMAL,NULL, + GTK_WIDGET(select_popup), + "LIRC select item", + SELECT_BORDER, + SELECT_BORDER+font->ascent, + "No match."); + + clear_select_list(&select_list); + } + else + { + int count; + int common; + int pass; + int x1,x2,x3; + + if(s==NULL && num>0) + { + scan_list=title_list; + while(scan_list!=NULL) + { + num--; + if(num==0) + { + clear_select_list(&select_list); + xmms_remote_set_playlist_pos + (lirc_plugin.xmms_session, + ((struct title_info *) (scan_list->data))->pos); + break; + } + scan_list=g_list_next(scan_list); + } + clear_title_list(&title_list); + return; + } + + check how many chars are common + scan_list=title_list; + title=get_title_postfix + (((struct title_info *) scan_list->data)->s); + common=0; + count=strlen(title); + for(i=0;i<count;i++) + { + if(isalnum(title[i])) common++; + } + scan_list=g_list_next(scan_list); + while(scan_list!=NULL) + { + gchar *title1,*title2; + + count=0; + title1=title; + title2=get_title_postfix + (((struct title_info *) scan_list->data)->s); + while(*title1 && *title2) + { + if(!isalnum(*title1)) {title1++;continue;} + if(!isalnum(*title2)) {title2++;continue;} + if(toupper(*title1)==toupper(*title2)) + { + count++; + title1++; + title2++; + } + else + { + break; + } + } + if(count<common) common=count; + scan_list=g_list_next(scan_list); + } + scan_list=select_list; + while(g_list_next(scan_list)!=NULL) + { + scan_list=g_list_next(scan_list); + } + ((struct select_info *) (scan_list->data))->common=common+1; + + print out selected titles + x1=x2=x3=0; + count=0; + pass=1; + scan_list=title_list; + while(scan_list!=NULL || pass==1) + { + gchar *title,*postfix,help; + char buffer[20]; + + count++; + title=((struct title_info *) scan_list->data)->s; + postfix=get_title_postfix(title); + help=postfix[0]; + postfix[0]=0; + + snprintf(buffer,20,"%2d:",count); + if(pass==1) + { + x=gdk_string_width + (select_popup->style->font,buffer); + if(x>x1) x1=x; + x2=gdk_string_width + (select_popup->style->font,title); + postfix[0]=help; + x=gdk_string_width(select_popup->style->font, + postfix); + if(x>x3) x3=x; + } + else + { + gtk_paint_string(style,select_popup->window, + GTK_STATE_NORMAL,NULL, + GTK_WIDGET(select_popup), + "LIRC select item", + SELECT_BORDER, + SELECT_BORDER+font->ascent+ + (count-1)*baseline_skip, + buffer); + gtk_paint_string(style,select_popup->window, + GTK_STATE_NORMAL,NULL, + GTK_WIDGET(select_popup), + "LIRC select item", + SELECT_BORDER+x1, + SELECT_BORDER+font->ascent+ + (count-1)*baseline_skip, + title); + postfix[0]=help; + gtk_paint_string(style,select_popup->window, + GTK_STATE_NORMAL,NULL, + GTK_WIDGET(select_popup), + "LIRC select item", + SELECT_BORDER+x1+x2+10, + SELECT_BORDER+font->ascent+ + (count-1)*baseline_skip, + postfix); + + } + scan_list=g_list_next(scan_list); + if(scan_list==NULL) + { + if(pass==1) + { + int x,y; + + width=SELECT_BORDER*2+x1+x2+10+x3; + height=SELECT_BORDER*2+count*baseline_skip-gap; + + gtk_widget_set_usize(select_popup, + width, + height); + x=(gdk_screen_width()-width)/2; + if(x<0) x=0; + y=(gdk_screen_height()-height)/2; + if(y<0) y=0; + gtk_widget_popup(select_popup,x,y); + gtk_paint_box(style,select_popup->window, + GTK_STATE_NORMAL, + GTK_SHADOW_OUT, + NULL,GTK_WIDGET(select_popup), + "LIRC select list", + 0,0,-1,-1); + scan_list=title_list; + count=0; + } + pass++; + } + } + if(count==1) + { + clear_select_list(&select_list); + xmms_remote_set_playlist_pos + (lirc_plugin.xmms_session, + ((struct title_info *) title_list->data) + ->pos); + } + clear_title_list(&title_list); + + } + select_tag=gtk_timeout_add(3000,(GtkFunction) remove_select_popup, + (gpointer) &select_popup); +} +*/ +void init(void) +{ + int flags; + ConfigFile *cfg; + + if((lirc_fd=lirc_init("audacious",1))==-1) + { + fprintf(stderr,"%s: could not init LIRC support\n", + plugin_name); + return; + } + if(lirc_readconfig(NULL,&config,NULL)==-1) + { + lirc_deinit(); + fprintf(stderr, + "%s: could not read LIRC config file\n" + "%s: please read the documentation of LIRC \n" + "%s: how to create a proper config file\n", + plugin_name,plugin_name,plugin_name); + return; + } + input_tag=gdk_input_add(lirc_fd,GDK_INPUT_READ, + lirc_input_callback,NULL); + fcntl(lirc_fd,F_SETOWN,getpid()); + flags=fcntl(lirc_fd,F_GETFL,0); + if(flags!=-1) + { + fcntl(lirc_fd,F_SETFL,flags|O_NONBLOCK); + } + fflush(stdout); + cfg=xmms_cfg_open_default_file(); + if(cfg) + { + xmms_cfg_read_string(cfg,"LIRC","font",&fontname); + xmms_cfg_free(cfg); + } + popup_style=gtk_style_new(); +} + +void lirc_input_callback(gpointer data,gint source, + GdkInputCondition condition) +{ + char *code; + char *c; + gint playlist_time,playlist_pos,output_time,v; + int ret; + char *ptr; + gint balance; + gboolean show_pl; + int n; + + while((ret=lirc_nextcode(&code))==0 && code!=NULL) + { + while((ret=lirc_code2char(config,code,&c))==0 && c!=NULL) + { + if(strcasecmp("PLAY",c)==0) + { + xmms_remote_play(lirc_plugin.xmms_session); + } + else if(strcasecmp("STOP",c)==0) + { + xmms_remote_stop(lirc_plugin.xmms_session); + } + else if(strcasecmp("PAUSE",c)==0) + { + xmms_remote_pause(lirc_plugin.xmms_session); + } + else if(strcasecmp("PLAYPAUSE",c) == 0) + { + if(xmms_remote_is_playing(lirc_plugin. + xmms_session)) + xmms_remote_pause + (lirc_plugin.xmms_session); + else + xmms_remote_play + (lirc_plugin.xmms_session); + } + else if(strncasecmp("NEXT",c,4)==0) + { + ptr=c+4; + while(isspace(*ptr)) ptr++; + n=atoi(ptr); + + if(n<=0) n=1; + for(;n>0;n--) + { + xmms_remote_playlist_next + (lirc_plugin.xmms_session); + } + } + else if(strncasecmp("PREV",c,4)==0) + { + ptr=c+4; + while(isspace(*ptr)) ptr++; + n=atoi(ptr); + + if(n<=0) n=1; + for(;n>0;n--) + { + xmms_remote_playlist_prev + (lirc_plugin.xmms_session); + } + } + else if(strcasecmp("SHUFFLE",c)==0) + { + xmms_remote_toggle_shuffle(lirc_plugin.xmms_session); + } + else if(strcasecmp("REPEAT",c)==0) + { + xmms_remote_toggle_repeat(lirc_plugin.xmms_session); + } + else if(strncasecmp("FWD",c,3)==0) + { + ptr=c+3; + while(isspace(*ptr)) ptr++; + n=atoi(ptr)*1000; + + if(n<=0) n=5000; + output_time=xmms_remote_get_output_time + (lirc_plugin.xmms_session); + playlist_pos=xmms_remote_get_playlist_pos + (lirc_plugin.xmms_session); + playlist_time=xmms_remote_get_playlist_time + (lirc_plugin.xmms_session, + playlist_pos); + if(playlist_time-output_time<n) + output_time=playlist_time-n; + xmms_remote_jump_to_time + (lirc_plugin.xmms_session, + output_time+n); + } + else if(strncasecmp("BWD",c,3)==0) + { + ptr=c+3; + while(isspace(*ptr)) ptr++; + n=atoi(ptr)*1000; + + if(n<=0) n=5000; + output_time=xmms_remote_get_output_time + (lirc_plugin.xmms_session); + if(output_time<n) + output_time=n; + xmms_remote_jump_to_time + (lirc_plugin.xmms_session, + output_time-n); + } + else if(strncasecmp("VOL_UP",c,6)==0) + { + ptr=c+6; + while(isspace(*ptr)) ptr++; + n=atoi(ptr); + if(n<=0) n=5; + + v = xmms_remote_get_main_volume + (lirc_plugin.xmms_session); + if(v > (100-n)) v=100-n; + xmms_remote_set_main_volume + (lirc_plugin.xmms_session,v+n); + } + else if(strncasecmp("VOL_DOWN",c,8)==0) + { + ptr=c+8; + while (isspace(*ptr)) ptr++; + n=atoi(ptr); + if(n<=0) n=5; + + v = xmms_remote_get_main_volume + (lirc_plugin.xmms_session); + if(v<n) v=n; + xmms_remote_set_main_volume + (lirc_plugin.xmms_session,v-n); + } + else if(strcasecmp("QUIT",c)==0) + { +#ifdef HAVE_XMMS_REMOTE_QUIT + xmms_remote_quit(lirc_plugin.xmms_session); +#else + raise(SIGTERM); +#endif + } + else if(strcasecmp("SETPOS",c)==0) + { + xmms_remote_set_playlist_pos(lirc_plugin.xmms_session,tracknr-1); + xmms_remote_play(lirc_plugin.xmms_session); + tracknr=0; + } + else if(strcasecmp("ONE",c)==0) + { + if(select_list!=NULL) + { + /* select_title(NULL,1); */ + } + else + { + tracknr=tracknr*10+1; + } + } + else if(strcasecmp("TWO",c)==0) + { + if(select_list!=NULL) + { + /* select_title(NULL,2); */ + } + else + { + tracknr=tracknr*10+2; + } + } + else if(strcasecmp("THREE",c)==0) + { + if(select_list!=NULL) + { + /* select_title(NULL,3);*/ + } + else + { + tracknr=tracknr*10+3; + } + } + else if(strcasecmp("FOUR",c)==0) + { + if(select_list!=NULL) + { + /* select_title(NULL,4);*/ + } + else + { + tracknr=tracknr*10+4; + } + } + else if(strcasecmp("FIVE",c)==0) + { + if(select_list!=NULL) + { + /*select_title(NULL,5);*/ + } + else + { + tracknr=tracknr*10+5; + } + } + else if(strcasecmp("SIX",c)==0) + { + if(select_list!=NULL) + { + /*select_title(NULL,6);*/ + } + else + { + tracknr=tracknr*10+6; + } + } + else if(strcasecmp("SEVEN",c)==0) + { + if(select_list!=NULL) + { + /*select_title(NULL,7);*/ + } + else + { + tracknr=tracknr*10+7; + } + } + else if(strcasecmp("EIGHT",c)==0) + { + if(select_list!=NULL) + { + /*select_title(NULL,8);*/ + } + else + { + tracknr=tracknr*10+8; + } + } + else if(strcasecmp("NINE",c)==0) + { + if(select_list!=NULL) + { + /*select_title(NULL,9);*/ + } + else + { + tracknr=tracknr*10+9; + } + } + else if(strcasecmp("ZERO",c)==0) + { + if(select_list!=NULL) + { + /*select_title(NULL,10);*/ + } + else + { + tracknr=tracknr*10; + } + } + else if(strcasecmp("MUTE",c)==0) + { + if(mute==0) + { + mute=1; + /* store the master volume so + we can restore it on unmute. */ + mute_vol = xmms_remote_get_main_volume + (lirc_plugin.xmms_session); + xmms_remote_set_main_volume + (lirc_plugin.xmms_session, 0); + } + else + { + mute=0; + xmms_remote_set_main_volume + (lirc_plugin.xmms_session, + mute_vol); + } + } + else if(strncasecmp("BAL_LEFT",c,8)==0) + { + ptr=c+8; + while(isspace(*ptr)) ptr++; + n=atoi(ptr); + if(n<=0) n=5; + + balance=xmms_remote_get_balance + (lirc_plugin.xmms_session); + balance-=n; + if(balance<-100) balance=-100; + xmms_remote_set_balance + (lirc_plugin.xmms_session,balance); + } + else if(strncasecmp("BAL_RIGHT",c,9)==0) + { + ptr=c+9; + while(isspace(*ptr)) ptr++; + n=atoi(ptr); + if(n<=0) n=5; + + balance=xmms_remote_get_balance + (lirc_plugin.xmms_session); + balance+=n; + if(balance>100) balance=100; + xmms_remote_set_balance + (lirc_plugin.xmms_session,balance); + } + else if(strcasecmp("BAL_CENTER",c)==0) + { + balance=0; + xmms_remote_set_balance + (lirc_plugin.xmms_session,balance); + } + else if(strcasecmp("LIST",c)==0) + { + show_pl=xmms_remote_is_pl_win + (lirc_plugin.xmms_session); + show_pl=(show_pl) ? 0:1; + xmms_remote_pl_win_toggle + (lirc_plugin.xmms_session,show_pl); + } + else if(strcasecmp("PLAYLIST_CLEAR",c)==0) + { + gboolean pl_visible; + + pl_visible=xmms_remote_is_pl_win + (lirc_plugin.xmms_session); + xmms_remote_stop(lirc_plugin.xmms_session); + xmms_remote_playlist_clear + (lirc_plugin.xmms_session); + /* This is to refresh window content */ + xmms_remote_pl_win_toggle + (lirc_plugin.xmms_session,pl_visible); + } + else if(strncasecmp("PLAYLIST_ADD ",c,13)==0) + { + gboolean pl_visible; + GList list; + + pl_visible=xmms_remote_is_pl_win + (lirc_plugin.xmms_session); + list.prev=list.next=NULL; + list.data=c+13; + xmms_remote_playlist_add + (lirc_plugin.xmms_session,&list); + /* This is to refresh window content */ + xmms_remote_pl_win_toggle + (lirc_plugin.xmms_session,pl_visible); + } + else if(strncasecmp("SELECT",c,6)==0) + { + char *sel; + int i; + + ptr=c+6; + while(isspace(*ptr)) ptr++; + + sel=ptr; + for(i=0;*ptr;ptr++) + { + if(isalnum(*ptr)) + { + sel[i]=toupper(*ptr); + i++; + } + } + sel[i]=0; + + if(strlen(sel)>0) + { + /*select_title(sel,0);*/ + } + } + else + { + fprintf(stderr,"%s: unknown command \"%s\"\n", + plugin_name,c); + } + } + free(code); + if(ret==-1) break; + } + if(ret==-1) + { + /* something went badly wrong */ + fprintf(stderr,"%s: disconnected from LIRC\n",plugin_name); + cleanup(); + return; + } +} + +void configure(void) +{ + if(!fsd) + { + GtkWidget *window; + + window=gtk_font_selection_dialog_new + ("Please choose font for SELECT popup."); + g_return_if_fail(GTK_IS_FONT_SELECTION_DIALOG(window)); + + fsd=window; + gtk_window_position(GTK_WINDOW(fsd),GTK_WIN_POS_MOUSE); + gtk_signal_connect(GTK_OBJECT(fsd), "destroy", + GTK_SIGNAL_FUNC(gtk_widget_destroyed), + &fsd); + gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG + (fsd)->ok_button), + "clicked", + GTK_SIGNAL_FUNC(font_selection_ok), + NULL); + gtk_signal_connect_object(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(fsd)->cancel_button), + "clicked", + GTK_SIGNAL_FUNC(gtk_widget_destroy), + GTK_OBJECT(fsd)); + } + if(!GTK_WIDGET_VISIBLE(fsd)) + gtk_widget_show(fsd); + else + gtk_widget_destroy(fsd); +} + +void font_selection_ok(GtkWidget *button,gpointer *data) +{ + gchar *new_fontname; + + new_fontname=gtk_font_selection_dialog_get_font_name + (GTK_FONT_SELECTION_DIALOG(fsd)); + if(new_fontname) + { + if(fontname) free(fontname); + fontname=new_fontname; + } + gtk_widget_destroy(fsd); + fsd=NULL; +} + +void cleanup() +{ + ConfigFile *cfg; + + if(config) + { + gtk_input_remove(input_tag); + lirc_freeconfig(config); + config=NULL; + } + if(lirc_fd!=-1) + { + lirc_deinit(); + lirc_fd=-1; + } + clear_select_list(&select_list); + if(fontname) + { + cfg=xmms_cfg_open_default_file(); + if(cfg) + { + xmms_cfg_write_string(cfg,"LIRC","font",fontname); + xmms_cfg_write_default_file(cfg); + xmms_cfg_free(cfg); + } + free(fontname); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Plugins/General/lirc/lirc.h Sat Nov 12 17:11:46 2005 -0800 @@ -0,0 +1,40 @@ +/* Lirc Plugin + + Copyright (C) 2005 Audacious development team + + Copyright (c) 1998-1999 Carl van Schaik (carl@leg.uct.ac.za) + + Copyright (C) 2000 Christoph Bartelmus (xmms@bartelmus.de) + + some code was stolen from: + IRman plugin for xmms by Charles Sielski (stray@teklabs.net) + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include <gtk/gtk.h> + +void clear_select_list(GList **list); +void clear_title_list(GList **list); +gchar *get_title_postfix(gchar *title); +void select_title(char *s,int num); +void init(void); +void font_selection_ok(GtkWidget *button,gpointer *data); +void configure(void); +void cleanup(void); +void about(void); + +void lirc_input_callback(gpointer data,gint source, + GdkInputCondition condition);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Plugins/General/lirc/lirc_image.h Sat Nov 12 17:11:46 2005 -0800 @@ -0,0 +1,96 @@ +/* XPM */ +static char *lirc_image[] = { +/* width height num_colors chars_per_pixel */ +" 288 63 26 1", +/* colors */ +". c #000080", +"# c #080880", +"a c #101088", +"b c #181888", +"c c #202090", +"d c #282890", +"e c #282c98", +"f c #303098", +"g c #383898", +"h c #383ca0", +"i c #4848a0", +"j c #5050a8", +"k c #6060b0", +"l c #686cb8", +"m c #7070b8", +"n c #7878b8", +"o c #9898c8", +"p c #a0a4d0", +"q c #b0b4d8", +"r c #c8cce0", +"s c #d0d4e8", +"t c #d8d8e8", +"u c #e0e0f0", +"v c #e8ecf0", +"w c #f0f4f8", +"x c #f8fcf8", +/* pixels */ +"................................................................................................................................................................................................................................................................................................", +"................................................................................................................................................................................................................................................................................................", +"................................................................................................................................................................................................................................................................................................", +"................................................................................................................................................................................................................................................................................................", +"................................................................................................................................................................................................................................................................................................", +"..............................................ff....................................afb.........................................................................................................................................................................................................", +"..............................................xxh...................................lxo.........................................................................................................................................................................................................", +"..............................................xxxs#.................................lxo.........................................................................................................................................................................................................", +"..............................................xxxxxh................................lxo.............................................................................................................................................................................bmnrrrpng...................", +"..............................................xxxxxxu#..............................lxo...................................................................xxxxxxxxx....................xxxxxxxxxxxxxxxxxxxxx.......xxxxxxxxxxxxxxxxxxxrnb........................nxxxxxxxxxxxxxxm...............", +"..............................................xxxxxxxxl.............................lxo...................................................................xxxxxxxxx....................xxxxxxxxxxxxxxxxxxxxx.......xxxxxxxxxxxxxxxxxxxxxxxp....................txxxxxxxxxxxxxxxxxxvb............", +"..............................................xxxxxxxxxua...........................lxo...................................................................xxxxxxxxx....................xxxxxxxxxxxxxxxxxxxxx.......xxxxxxxxxxxxxxxxxxxxxxxxxi................pxxxxxxxxxxxxxxxxxxxxxxx...........", +"..............................................xxxxxxxxxxxl..........................lxo...................................................................xxxxxxxxx....................xxxxxxxxxxxxxxxxxxxxx.......xxxxxxxxxxxxxxxxxxxxxxxxxxp..............vxxxxxxxxxxxxxxxxxxxxxxxx...........", +"..............................................xxxxxxxxxxxxvb........................lxo...................................................................xxxxxxxxx....................xxxxxxxxxxxxxxxxxxxxx.......xxxxxxxxxxxxxxxxxxxxxxxxxxxg............xxxxxxxxxxxxxxxxxxxxxxxxxx...........", +"..............................................xxxxxxxxxxxxxxo.......................lxo...................................................................xxxxxxxxx....................xxxxxxxxxxxxxxxxxxxxx.......xxxxxxxxxxxxxxxxxxxxxxxxxxxx...........vxxxxxxxxxxxxxxxxxxxxxxxxxx...........", +"..............................................xxxxxxxxxxxxxxxvc.....................lxo...................................................................xxxxxxxxx....................nnnnnnxxxxxxxxxnnnnnn.......xxxxxxxxxnnnnnnrxxxxxxxxxxxxi.........kxxxxxxxxxxxxpg....mxxxxxxxx...........", +"..............................................xxxxxxxxxxxxxxxxxo....................lxo...................................................................xxxxxxxxx..........................xxxxxxxxx.............xxxxxxxxx.........xxxxxxxxxxr.........xxxxxxxxxxxn.........bvxxxxx...........", +"..............................................xxxxxxxxxxxxxxxxxxwd..................lxo...................................................................xxxxxxxxx..........................xxxxxxxxx.............xxxxxxxxx..........xxxxxxxxxx........rxxxxxxxxxxb............exxxx...........", +"..............................................xxxxxxxxxxxxxxxxxwxxq.................lxo...................................................................xxxxxxxxx..........................xxxxxxxxx.............xxxxxxxxx..........rxxxxxxxxx........xxxxxxxxxxb...............vxx...........", +"..............................................xxxxxxxxxxxxxxxxxxxxxwh...............lxo...................................................................xxxxxxxxx..........................xxxxxxxxx.............xxxxxxxxx..........nxxxxxxxxx.......ixxxxxxxxxp.................px...........", +"..............................................xxxxxxxxxxxxxxxxxxxxwxxq..............lxo...................................................................xxxxxxxxx..........................xxxxxxxxx.............xxxxxxxxx..........nxxxxxxxxx.......vxxxxxxxxx...............................", +"..............................................xxxxxxxxxxxxxxxxxxxxxxxxxh............lxo...................................................................xxxxxxxxx..........................xxxxxxxxx.............xxxxxxxxx..........txxxxxxxxr.......xxxxxxxxxr...............................", +"..............................................xxxxxxxxxxxxxxxxxxxxxxxxxxq...........lxo...................................................................xxxxxxxxx..........................xxxxxxxxx.............xxxxxxxxx..........xxxxxxxxxe.......xxxxxxxxxe...............................", +"..............................................xxxxxxxxxxxxxxxxxxxxxxxxxxxxh.........lxo...................................................................xxxxxxxxx..........................xxxxxxxxx.............xxxxxxxxx.........xxxxxxxxxx.......bxxxxxxxxx................................", +"..............................................xxxxxxxxxxxxxxxxxxxxxxxxxxxxxs#.......lxo...................................................................xxxxxxxxx..........................xxxxxxxxx.............xxxxxxxxx......grxxxxxxxxxxk.......gxxxxxxxxx................................", +"..............................................xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxl......lxo...................................................................xxxxxxxxx..........................xxxxxxxxx.............xxxxxxxxxxxxxxxxxxxxxxxxxxt........nxxxxxxxxx................................", +"..............................................xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxu#....lxo...................................................................xxxxxxxxx..........................xxxxxxxxx.............xxxxxxxxxxxxxxxxxxxxxxxxxv.........nxxxxxxxxx................................", +"..............................................xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxl...lxo...................................................................xxxxxxxxx..........................xxxxxxxxx.............xxxxxxxxxxxxxxxxxxxxxxxxp..........nxxxxxxxxx................................", +"..............................................xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxua.lxo...................................................................xxxxxxxxx..........................xxxxxxxxx.............xxxxxxxxxxxxxxxxxxxxxxxb...........kxxxxxxxxx................................", +"..............................................xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxllxo...................................................................xxxxxxxxx..........................xxxxxxxxx.............xxxxxxxxxxxxxxxxxxxxxxe............gxxxxxxxxx................................", +"...looooooooooooooooooooooooooooooooooooooooooxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxwxsoooooooooooooooooooooooooooooooooooooooooooooooooooooooob..........xxxxxxxxx..........................xxxxxxxxx.............xxxxxxxxxxxxxxxxxxxxxxx.............xxxxxxxxxb...............................", +"...sxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxf..........xxxxxxxxx..........................xxxxxxxxx.............xxxxxxxxx....vxxxxxxxxxx............xxxxxxxxxp...............................", +"...looooooooooooooooooooooooooooooooooooooooooxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxsxsoooooooooooooooooooooooooooooooooooooooooooooooooooooooob..........xxxxxxxxx..........................xxxxxxxxx.............xxxxxxxxx.....xxxxxxxxxxr...........xxxxxxxxxx...............................", +"..............................................xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxs#lxo...................................................................xxxxxxxxx..........................xxxxxxxxx.............xxxxxxxxx.....bxxxxxxxxxxj..........nxxxxxxxxxn.................er...........", +"..............................................xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxh..lxo...................................................................xxxxxxxxx..........................xxxxxxxxx.............xxxxxxxxx......nxxxxxxxxxxb..........xxxxxxxxxx................pxx...........", +"..............................................xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxq#...lxo...................................................................xxxxxxxxx..........................xxxxxxxxx.............xxxxxxxxx.......vxxxxxxxxxx..........vxxxxxxxxxx..............vxxx...........", +"..............................................xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxh.....lxo...................................................................xxxxxxxxx..........................xxxxxxxxx.............xxxxxxxxx........xxxxxxxxxxv.........bxxxxxxxxxxxg..........nxxxxx...........", +"..............................................xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxq.......lxo...................................................................xxxxxxxxxxxxxxxxxxxxxxxxxg...ggggggxxxxxxxxxgggggg.......xxxxxxxxx........bxxxxxxxxxxp.........txxxxxxxxxxxxn.....erxxxxxxx...........", +"..............................................xxxxxxxxxxxxxxxxxxxxxxxxxxxxxh........lxo...................................................................xxxxxxxxxxxxxxxxxxxxxxxxxg...xxxxxxxxxxxxxxxxxxxxx.......xxxxxxxxx.........pxxxxxxxxxxe.........xxxxxxxxxxxxxxxxxxxxxxxxxxx...........", +"..............................................xxxxxxxxxxxxxxxxxxxxxxxxxxxq..........lxo...................................................................xxxxxxxxxxxxxxxxxxxxxxxxxg...xxxxxxxxxxxxxxxxxxxxx.......xxxxxxxxx..........vxxxxxxxxxx.........bxxxxxxxxxxxxxxxxxxxxxxxxxx...........", +"..............................................xxxxxxxxxxxxxxxxxxxxxxxxxxh...........lxo...................................................................xxxxxxxxxxxxxxxxxxxxxxxxxg...xxxxxxxxxxxxxxxxxxxxx.......xxxxxxxxx...........xxxxxxxxxxx.........bxxxxxxxxxxxxxxxxxxxxxxxxx...........", +"..............................................xxxxxxxxxxxxxxxxxxxxxxxxq.............lxo...................................................................xxxxxxxxxxxxxxxxxxxxxxxxxg...xxxxxxxxxxxxxxxxxxxxx.......xxxxxxxxx...........exxxxxxxxxxr..........vxxxxxxxxxxxxxxxxxxxxxxx...........", +"..............................................xxxxxxxxxxxxxxxxxxxxxxxh..............lxo...................................................................xxxxxxxxxxxxxxxxxxxxxxxxxg...xxxxxxxxxxxxxxxxxxxxx.......xxxxxxxxx............pxxxxxxxxxxj..........ixxxxxxxxxxxxxxxxxxxvb............", +"..............................................xxxxxxxxxxxxxxxxxxxxxq................lxo...................................................................xxxxxxxxxxxxxxxxxxxxxxxxxg...xxxxxxxxxxxxxxxxxxxxx.......xxxxxxxxx.............xxxxxxxxxxxb...........evxxxxxxxxxxxxxxn...............", +"..............................................xxxxxxxxxxxxxxxxxxxxh.................lxo.............................................................................................................................................................................kprxxxvrnb..................", +"..............................................xxxxxxxxxxxxxxxxxxq...................lxo.........................................................................................................................................................................................................", +"..............................................xxxxxxxxxxxxxxxxxh....................lxo.........................................................................................................................................................................................................", +"..............................................xxxxxxxxxxxxwxxq......................lxo.........................................................................................................................................................................................................", +"..............................................xxxxxxxxxxxxxwd.......................lxo.........................................................................................................................................................................................................", +"..............................................xxxxxxxxxwxxq.........................lxo.........................................................................................................................................................................................................", +"..............................................xxxxxxxxxxwd..........................lxo.........................................................................................................................................................................................................", +"..............................................xxxxxxwxxq............................lxo.........................................................................................................................................................................................................", +"..............................................xxxxxxxwd.............................lxo............................................................nx...nx....................gxxx.......txx......................xn...gxxxx.....................xr..........gxxxp............xg...........xg...", +"..............................................xxxwxxo...............................lxo............................................................nx...gn.nknr..nb.ngkn.bn#...gx..nknr.gxrkknbkeprm..n.n.brp...ppxn...gx..xn.brp..ngpn.pm..grn.bxtn.brp.....xp..p.grn..ngpp.kxpngnbn.krn..xg...", +"..............................................xxxxwc................................lxo............................................................nx...nx.xxnxt.xg.xn.xpxp....gx..xxnxtgxrkrxrpkiixm.xtr.xipx.xvgxn...gx.gxb.xipx.xvnxtpx.gxivxbxtn.xipx...gx....gxivx.xvnxpkxpnnxrrnxgxv.xg...", +"..............................................wxxo..................................lvo............................................................nx...nx.xr.rx.xg.xn.bxv.....gx..xr.rx.xn.rx..exxxn.x..nxxxx.xg.xn...gxxxk.nxxxx.xn.xg.x.rx.gx.xr.nxxxx...gx....rx.gx.xn.xr.xg.nx..xx.nx.xg...", +"...............................................vc..................................................................................................nx...nx.xr.rx.xn.xn.rxxe....gx..xr.rx.xn.rx..xn.xn.x..ix..b.xp.xn...gx.rxbix..b.xn.xg.x.nx.nx.xr.ix..b....xr.brnx.nx.xn.xr.xg.nx..rx.rx.xg...", +"...................................................................................................................................................nxxxxnx.xr.rx.rxvxnjx.nx...gxxx.xr.rx.xn.rx..pxxxn.x...rxxx.pxxxn...gx..xx.rxxx.xn.xg.x..vxxi.nxx.rxxx....bxxxn.vxxi.xn.xr.vxxnx...xxxe.xg...", +"................................................................................................................................................................................................................................................................................................", +"................................................................................................................................................................................................................................................................................................", +"................................................................................................................................................................................................................................................................................................", +"................................................................................................................................................................................................................................................................................................", +"................................................................................................................................................................................................................................................................................................" +};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Plugins/General/lirc/lirc_mini.xpm Sat Nov 12 17:11:46 2005 -0800 @@ -0,0 +1,69 @@ +/* XPM */ +static char * lirc_mini_xpm[] = { +"16 16 50 1", +" c None", +". c #000080", +"+ c #4748A2", +"@ c #7072B7", +"# c #060683", +"$ c #4648A3", +"% c #303096", +"& c #5E5FAD", +"* c #F8FCF8", +"= c #C1C4DE", +"- c #34359A", +"; c #5D5FAF", +"> c #F0F4F4", +", c #8588C1", +"' c #0C0C86", +") c #D5D8E7", +"! c #020281", +"~ c #F5F9F7", +"{ c #9DA0CD", +"] c #19198C", +"^ c #E0E4ED", +"/ c #5B5DAD", +"( c #010180", +"_ c #F7FBF8", +": c #B7BAD9", +"< c #252592", +"[ c #9293C6", +"} c #ECF0F3", +"| c #B7BADA", +"1 c #DCE0EB", +"2 c #A9ACD3", +"3 c #F4F8F6", +"4 c #9598C9", +"5 c #141489", +"6 c #D1D4E6", +"7 c #4143A0", +"8 c #F1F5F5", +"9 c #8689C2", +"0 c #0F0F87", +"a c #CACDE2", +"b c #35379A", +"c c #EDF0F3", +"d c #7678BA", +"e c #030381", +"f c #B7B9D9", +"g c #2A2B94", +"h c #292A94", +"i c #6365B0", +"j c #050582", +"k c #242592", +".+@#.........$%.", +".&*=-........;*.", +".&**>,'......;*.", +".&****)+!....;*.", +".&*****~{]...;*.", +".&*******^/(.;*.", +".&********_:<;*.", +"[[**********}|*[", +"[[**********12*[", +".&********345;*.", +".&*******67..;*.", +".&*****890...;*.", +".&***_ab(....;*.", +".&**cde......;*.", +".&_fg........;*.", +".hij.........k]."};