Re: [Muine] OSDMuine???



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tim Hermans wrote:
> Does anyone have the source to OSDmuine lying around?  The developer seems
> to have faded away:  his website is down and his mail bounces.
> 
> BTW, most of the links on the plugins page at GooeyLinux are dead.  What's
> up with that?

- From google cache:


// OSD_Muine.cs - Muine On Screen Display Plugin
// Copyright (C) 2005 - Pedro Villavicencio Garrido <pvillavi gnome org>
// Licensed under GNU GPL V2.
// Requeriments : libxosd.
// debian package name is libxosd-dev.

using System;
using System.Runtime.InteropServices;
using System.Threading;

using GConf;

using Muine.PluginLib;

public class OSD_Muine : Plugin
{
	private IPlayer player;
	private string align;
	private string color;
	private string display;
	private string position;
	private string font;
	
	[DllImport ("libxosd")]
	private static extern IntPtr xosd_create(int num);
	
	[DllImport ("libxosd")]
	private static extern void xosd_display(IntPtr osd, int num, IntPtr
XOSD_string, string msg);
	
	[DllImport ("libxosd")]
	private static extern void xosd_destroy(IntPtr osd);
	
	[DllImport ("libxosd")]
	private static extern void xosd_set_font(IntPtr osd, string font);

	[DllImport ("libxosd")]
	private static extern void xosd_set_shadow_offset(IntPtr osd, int offset);

	[DllImport ("libxosd")]
	private static extern int xosd_set_pos(IntPtr osd, int pos);

	[DllImport ("libxosd")]
	private static extern int xosd_set_align(IntPtr osd, int align);

	[DllImport ("libxosd")]
	private static extern int xosd_set_colour(IntPtr osd, string color);

	public override void Initialize(IPlayer player)
	{
		this.player = player;
		GConfKeys();
		player.SongChangedEvent += OnSongChange;
	}

	public void GConfKeys()
        {
		GConf.Client client = new GConf.Client();
		
		try{
			color = (string) client.Get("/apps/muine/plugins/osdmuine/color");
		}catch(GConf.NoSuchKeyException){
			color = "green";
			client.Set("/apps/muine/plugins/osdmuine/color", color);
		}

		try{
			position = (string) client.Get("/apps/muine/plugins/osdmuine/position");
		}catch(GConf.NoSuchKeyException){
			client.Set("/apps/muine/plugins/osdmuine/position", "bottom");
		}

		try{
			align = (string) client.Get("/apps/muine/plugins/osdmuine/align");
		}catch(GConf.NoSuchKeyException){
		       client.Set("/apps/muine/plugins/osdmuine/align", "left");
		}

		try{
			font = (string) client.Get("/apps/muine/plugins/osdmuine/font");
		}catch(GConf.NoSuchKeyException){
			client.Set("/apps/muine/plugins/osdmuine/font",
"-*-fixed-bold-r-normal-*-45-120-100-*-*-*-iso8859-*");
		}

		client.AddNotify("/apps/muine/plugins/osdmuine/color",  new
GConf.NotifyEventHandler(ColorChanged));
		client.AddNotify("/apps/muine/plugins/osdmuine/position", new
GConf.NotifyEventHandler(PositionChanged));
		client.AddNotify("/apps/muine/plugins/osdmuine/align", new
GConf.NotifyEventHandler(AlignChanged));
		client.AddNotify("/apps/muine/plugins/osdmuine/font", new
GConf.NotifyEventHandler(FontChanged));
	}
			
	public void OnSongChange(ISong song)
	{
		if(song == null)
			return;

		display = String.Format("Playing: {0} - {1}", song.Artists[0],
song.Title);
		Thread thread = new Thread(new ThreadStart(Display));
		thread.Start();
	}

	public void Display()
	{
		IntPtr osd = xosd_create(2);
		
		xosd_set_font(osd, font);
		xosd_set_colour(osd, color);
		xosd_set_pos(osd, ParsePosition(position));
		xosd_set_align(osd, ParseAlign(align));
		xosd_set_shadow_offset(osd, 2);
		xosd_display(osd, 0, new IntPtr(1), display);

		Thread.Sleep(2000);
		xosd_destroy(osd);
	}

	public void ColorChanged(object obj, NotifyEventArgs args)
	{
		color = (string) args.Value;
	}

	public void PositionChanged(object obj, NotifyEventArgs args)
	{	
		position = (string) args.Value;
	}

	public void AlignChanged(object obj, NotifyEventArgs args)
	{
		align = (string) args.Value;
	}

	public void FontChanged(object obj, NotifyEventArgs args)
	{
		font = (string) args.Value;
	}

	public int ParsePosition(string position)
	{
		switch(position){
		case "top" :
			return 0;
	        case "bottom":
		        return 1;
		case "center":
			return 2;
		default:
			return 1;
		}
	}

	public int ParseAlign(string align)
	{
		switch(align){
		case "left":
			return 0;
		case "center":
			return 1;
		case "right":
			return 2;
		default :
			return 0;
		}
	}


Yi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFD45xwtXlIMrUVVksRAsg9AJ0fsbl4/4AdhDsjsaETXKIT/cT+HQCfWOlY
S/uWxN+BCDFictIuVB8mwfk=
=ONc+
-----END PGP SIGNATURE-----



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]