123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- /**
- *
- * Copyright (c) 2002, Marc Bruenink
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of the author nor the names of his contributors may be
- * used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
- #include <ostream.h>
- #include <cstdlib>
- #include <string.h>
- #include <gtk-1.2/gtk/gtk.h>
- #include <xmms/plugin.h>
- #include <xmms/xmmsctrl.h>
- #include <xmms/util.h>
- // my includes
- #include "Xlib_textfader.cc"
- #include "configuration.h"
- #include "myhelpfunctions.h"
- #define VERSION "0.4.7"
- extern "C" void init();
- extern "C" void about();
- extern "C" void configure();
- extern "C" void cleanup();
- extern "C" GeneralPlugin *get_gplugin_info();
- GeneralPlugin plugin = { NULL,
- NULL,
- -1,
- "Title Fader Plugin "VERSION,
- init,
- about,
- configure,
- cleanup};
-
- gint iTimeout;
- int timeoutFunction(gpointer);
- gchar *cLastTitle = NULL;
- Xlib_textfader *fader;
- Config conf;
- extern "C" {
- void init() {
- iTimeout = gtk_timeout_add(50, timeoutFunction, NULL);
- fader = new Xlib_textfader();
- ;
-
- }// end init()
-
- void about() {
- xmms_show_message("Title Fader Plugin", "This xmms plugin blends the title of new songs on screen.\n\n send all complaints & suggestions to:\nfidor@users.sourceforge.net\n\nhttp://xmms-titlefader.sourceforge.net", "OK", TRUE, NULL, NULL);
- }// end about()
- void configure() {
- // delete conf;
- //static Config conf;
- // conf = new Config();
- conf.show();
- }//end configure()
- void cleanup() {
- if(iTimeout){
- gtk_timeout_remove(iTimeout);
- }
- if (cLastTitle != NULL) {
- g_free(cLastTitle);
- cLastTitle = NULL;
- }
- delete fader;
-
- }//endcleanup()
- GeneralPlugin *get_gplugin_info(void)
- {
- return &plugin;
- }
- } // end extern
- int timeoutFunction(gpointer gpData){
- if (xmms_remote_is_playing(plugin.xmms_session) == TRUE) {
-
- gchar *cBuffer = NULL;
-
- cBuffer = xmms_remote_get_playlist_title(plugin.xmms_session, xmms_remote_get_playlist_pos(plugin.xmms_session));
-
- // print title
-
- if (cLastTitle != NULL) {
- if ( strcmp(cBuffer, cLastTitle) != 0) {
-
- fader->set_text_color(conf.col_selected[0], conf.col_selected[1], conf.col_selected[2]);
- fader->set_font(conf.font_selected);
- fader->set_fade_position(conf.hWinScalePos,conf.vWinScalePos);
- fader->fade(cBuffer, getCharLength(cBuffer)-1, conf.frameScalePos, conf.fadeOptions);
- }
- }
- else {
- fader->set_text_color(conf.col_selected[0], conf.col_selected[1], conf.col_selected[2]);
- fader->set_font(conf.font_selected);
- fader->set_fade_position(conf.hWinScalePos,conf.vWinScalePos);
- fader->fade(cBuffer, getCharLength(cBuffer)-1, conf.frameScalePos, conf.fadeOptions);
- }
-
-
- // strcpy(cLastTitle, cBuffer);
-
- if(cLastTitle != NULL) {
- g_free(cLastTitle);
- cLastTitle = NULL;
- }
-
- cLastTitle = strdup(cBuffer);
-
-
- // save old values
-
- if (cBuffer != NULL){
- g_free(cBuffer);
- cBuffer=NULL;
- }
-
- }// end if playing
-
- return TRUE;
- } // end timeout()
|