Пример #1
0
const gchar* g_module_check_init(GModule *module)
{
	gchar title_font[1024]="Sans Regular 18";
	if(!ly_reg_get("3inf_title_font", "%1024[^\n]", title_font))
		ly_reg_set("3inf_title_font", "%s", title_font);
	gchar normal_font[1024]="Sans Regular 10";
	if(!ly_reg_get("3inf_normal_font", "%1024[^\n]", normal_font))
		ly_reg_set("3inf_normal_font", "%s", normal_font);
		
	ly_3inf_cover_init();
	char path[1024]="";
	g_snprintf(path, sizeof(path), "%sicon/cd.png", LY_GLB_PROG_UIXDIR);
	ly_3inf_pixbuf_cd=gdk_pixbuf_new_from_file_at_scale(path, 250, 200, TRUE, NULL);
	return NULL;
}
Пример #2
0
gpointer		ly_3dnc_lrc_search(gpointer data)
{
	GtkTreeStore *store=NULL;

	char server[128]="qianqian";
	ly_reg_get("3dnc_lrc_server", "%[^\n]", server);
	if(g_str_equal(server, "qianqian"))
	{
		store=ly_3dnc_lrc_qianqian_search(ly_3dnc_lrc_title, ly_3dnc_lrc_artist);
	}
	else if(g_str_equal(server, "lrc123"))
	{
		store=ly_3dnc_lrc_lrc123_search(ly_3dnc_lrc_title, ly_3dnc_lrc_artist);
	}
	else
	{
		g_mutex_unlock(ly_3dnc_lrc_mutex);
		ly_dbg_warning(_("Illegal server name!"));
		return NULL;
	}
	
	
	if(!store)
	{
		g_mutex_unlock(ly_3dnc_lrc_mutex);
		ly_dbg_message(_("Find nothing by searching the web!"));
		return NULL;
	}
	g_idle_add(ly_3dnc_lrc_notify, store);
	return NULL;
}
Пример #3
0
gboolean ly_3lrc_desktop_on_drag_cb( GtkWidget * widget, GdkEvent *event, gpointer data)
{
	//GdkCursor *cursor;
	if (event->button.button == 1)
	{
		switch(event->type)
		{
			case GDK_BUTTON_PRESS:
				pos_old[X] = event->button.x;
				pos_old[Y] = event->button.y;
				flag_drag=TRUE;
				
				//鼠标变成手形
				//cursor= gdk_cursor_new(GDK_FLEUR);
				//gdk_window_set_cursor(widget->window,cursor);
				//gdk_cursor_destroy(cursor);
				break;
			case GDK_BUTTON_RELEASE:
				flag_drag=FALSE;
				
				//鼠标变成默认箭头
				//cursor= gdk_cursor_new(GDK_LEFT_PTR);
				//gdk_window_set_cursor(widget->window,cursor);
				//gdk_cursor_destroy(cursor);
				gtk_window_get_position(GTK_WINDOW(widget), &(pos_old[X]), &(pos_old[Y]));
				
				int x=0;
				int y=0;
				int w=1000;
				int h=50;
				
				ly_reg_get("3lrc_desktop_pos_and_size", "%d:%d:%d:%d", &x, &y, &w, &h);
				ly_reg_set("3lrc_desktop_pos_and_size", "%d:%d:%d:%d", pos_old[X], pos_old[Y], w, h);
				break;
			case GDK_MOTION_NOTIFY:
				if(flag_drag)
				{
					int x, y;
					GtkWidget *window = widget;
					gtk_window_get_position(GTK_WINDOW(window), &x, &y);
					gtk_window_move((GtkWindow *) window,x+event->button.x-pos_old[X],y+event->button.y-pos_old[Y]);
				}	
			default:
				break;
		}
	}
	switch(event->type)
	{
		case GDK_ENTER_NOTIFY:
			flag_notify=TRUE;
			break;
		case GDK_LEAVE_NOTIFY:
			if(!flag_drag)
				flag_notify=FALSE;
			break;
		default:
			break;
	}
	return TRUE;
}
Пример #4
0
gpointer	ly_3dnc_cov_analysis(gpointer data)
{
	gchar *url=NULL;
	
	char server[128]="last.fm";
	ly_reg_get("3dnc_cov_server", "%[^\n]", server);
	if(g_str_equal(server, "last.fm"))
	{
		url=ly_3dnc_cov_lastfm_analysis((gchar *)(data));
	}
	else if(g_str_equal(server, "top100"))
	{
		url=ly_3dnc_cov_top100_analysis((gchar *)(data));
	}
	else
	{
		g_mutex_unlock(ly_3dnc_cov_mutex);
		ly_dbg_warning(_("Illegal server name!"));
		return NULL;
	}

	g_free(data);
	if(!url)
	{
		g_mutex_unlock(ly_3dnc_cov_mutex);
		ly_dbg_message(_("Cannot get the real resource adress!"));
		return NULL;
	}
	g_thread_create(ly_3dnc_cov_down, url, TRUE, NULL);
	
}
Пример #5
0
gpointer		ly_3dnc_cov_search(gpointer data)
{
	GtkTreeStore *store=NULL;
	
	char server[128]="last.fm";
	ly_reg_get("3dnc_cov_server", "%[^\n]", server);
	if(g_str_equal(server, "last.fm"))
	{
		store=ly_3dnc_cov_lastfm_search(ly_3dnc_cov_artist, ly_3dnc_cov_album);
	}
	else if(g_str_equal(server, "top100"))
	{
		store=ly_3dnc_cov_top100_search(ly_3dnc_cov_artist, ly_3dnc_cov_album);
	}
	else
	{
		g_mutex_unlock(ly_3dnc_cov_mutex);
		ly_dbg_warning(_("Illegal server name!"));
		return NULL;
	}
	
	if(!store)
	{
		g_mutex_unlock(ly_3dnc_cov_mutex);
		ly_dbg_message(_("Find nothing by searching the web!"));
		return NULL;
	}
	g_idle_add(ly_3dnc_cov_notify, store);
	return NULL;
}
Пример #6
0
void		ly_3lrc_desktop_create			()
{
	int lrc_desktop_visible=1;
	int lrc_desktop_fixed=0;
	if(!ly_reg_get("3lrc_desktop_state", "%d:%d", &lrc_desktop_visible, &lrc_desktop_fixed))
	{
		ly_reg_set("3lrc_desktop_state", "%d:%d", lrc_desktop_visible, lrc_desktop_fixed);
	}

	int w=1000;
	int h=50;
	int x=0;
	int y=0;
	ly_reg_get("3lrc_desktop_pos_and_size", "%d:%d:%d:%d", &x, &y, &w, &h);	
	ly_3lrc_desktop=gtk_window_new(GTK_WINDOW_POPUP);
	gtk_window_set_default_size(GTK_WINDOW(ly_3lrc_desktop),w,h);
	gtk_window_move(GTK_WINDOW(ly_3lrc_desktop),x,y);
	gtk_widget_set_app_paintable(ly_3lrc_desktop, TRUE);
	gtk_window_set_decorated(GTK_WINDOW(ly_3lrc_desktop), FALSE);
		
	GdkVisual *visual;
	GdkScreen *screen;
	screen = gtk_widget_get_screen(ly_3lrc_desktop);	
	visual = gdk_screen_get_rgba_visual (screen);
	if (visual == NULL)
		visual = gdk_screen_get_system_visual (screen);
	gtk_widget_set_visual (GTK_WIDGET (ly_3lrc_desktop), visual);

	gtk_widget_set_events(ly_3lrc_desktop,GDK_ALL_EVENTS_MASK);
		
	if(lrc_desktop_visible<=0)
		gtk_widget_hide(ly_3lrc_desktop);
	if(lrc_desktop_fixed>0)
		gtk_widget_set_sensitive(ly_3lrc_desktop,FALSE);
			
	gtk_widget_show_all(ly_3lrc_desktop);
	g_signal_connect(G_OBJECT(ly_3lrc_desktop), "draw", G_CALLBACK(ly_3lrc_desktop_on_expose_cb), NULL);
	g_signal_connect(G_OBJECT(ly_3lrc_desktop), "button_press_event", G_CALLBACK(ly_3lrc_desktop_on_drag_cb), NULL);
	g_signal_connect(G_OBJECT(ly_3lrc_desktop), "button_release_event", G_CALLBACK(ly_3lrc_desktop_on_drag_cb), NULL);
	g_signal_connect(G_OBJECT(ly_3lrc_desktop), "motion_notify_event", G_CALLBACK(ly_3lrc_desktop_on_drag_cb), NULL);
	g_signal_connect(G_OBJECT(ly_3lrc_desktop), "enter_notify_event", G_CALLBACK(ly_3lrc_desktop_on_drag_cb), NULL);
	g_signal_connect(G_OBJECT(ly_3lrc_desktop), "leave_notify_event", G_CALLBACK(ly_3lrc_desktop_on_drag_cb), NULL);

	ly_3lrc_desktop_timeout=g_timeout_add(100, ly_3lrc_desktop_on_update_cb, NULL);
}
Пример #7
0
void		ly_3dnc_lrc_init()
{
	char server[128]="qianqian";
	if(!ly_reg_get("3dnc_lrc_server", "%[^\n]", server))
	{
		ly_reg_set("3dnc_lrc_server", "%s", server);
	}

	ly_3dnc_lrc_mutex = g_mutex_new();
	ly_mbs_bind("lrc_missing", "", ly_3dnc_lrc_check, NULL);
}
Пример #8
0
void		ly_3dnc_cov_init()
{
	char server[128]="last.fm";
	if(!ly_reg_get("3dnc_cov_server", "%[^\n]", server))
	{
		ly_reg_set("3dnc_cov_server", "%s", server);
	}

	ly_3dnc_cov_mutex = g_mutex_new();
	ly_mbs_bind("cov_missing", "", ly_3dnc_cov_check, NULL);
}
Пример #9
0
/**
 * ly_aud_init:
 *
 * Initialize the aud module, it will be called by #ly_cox_init.
 */
void
ly_aud_init()
{
	/*
	 * mode
	 */
	gint random=0;
	gint repeat=1;
	gint single=0;

	if(!ly_reg_get("aud_mode","%d:%d:%d", &random,&repeat,&single))
		ly_reg_set("aud_mode","%d:%d:%d",random, repeat, single);

	/*
	 * volume
	 */
	double vol=0.3;
	if(!ly_reg_get("aud_volume","%lf",&vol))
	{
		ly_reg_set("aud_volume","%lf",vol);
	}
	GstElement *ele=ly_ppl_audio_get_element("volume");
	if(ele)
	{
		g_object_set(G_OBJECT(ele), "volume", vol, NULL);
	}

	/*
	 * autoplay
	 */
	int autoplay=0;
	if(!ly_reg_get("aud_autoplay", "%d", &autoplay))
		ly_reg_set("aud_autoplay", "%d", autoplay);

	if(autoplay)
	{
		ly_aud_play();
	}
	ly_mbs_put("meta_changed", "core:aud", NULL);
	ly_mbs_bind("ppl_eos", "core:ppl", ly_aud_on_ppl_eos_cb, NULL);
}
Пример #10
0
void		ly_3lrc_desktop_init			()
{
	int w=1000;
	int h=50;
	int x=0;
	int y=0;
	if(!ly_reg_get("3lrc_desktop_pos_and_size", "%d:%d:%d:%d", &x, &y, &w, &h))
	{
		ly_reg_set("3lrc_desktop_pos_and_size", "%d:%d:%d:%d", x, y, w, h);
	}
	ly_3lrc_desktop_create();
}
Пример #11
0
/**
 * ly_mdh_init:
 *
 * Initialize the mdh module, it will be called by #ly_cox_init
 */
void			ly_mdh_init				()
{
	char extra_encoding[1024]="GB18030";
	if(!ly_reg_get("dbm_extra_encoding", "%*[^\n(](%1023[^\n)]", extra_encoding))
	{
		ly_reg_set("dbm_extra_encoding", "Chinese Simplified (GB18030)");
	}
	char encoding[1024]="";
	g_snprintf(encoding, sizeof(encoding), "%s:UTF-8", extra_encoding);
	g_setenv("GST_ID3_TAG_ENCODING", encoding, TRUE);
	
	ly_mdh_put_mutex=g_mutex_new();
}
Пример #12
0
const gchar* g_module_check_init(GModule *module)
{
	int offset=0;
	int limit=-1;
	int index0=0;
	int index1=0;
	int id=0;
	char name[1024]="unknown";
	
	if(!ly_reg_get("3opc_limit", "%d:%d", &offset, &limit))
	{
		ly_reg_set("3opc_limit", "%d:%d", offset, limit);
	}
	if(!ly_reg_get("3opc_select", "%d:%d:%d:%s", &index0, &index1, &id, name))
	{
		ly_reg_set("3opc_select", "%d:%d:%d:%s", index0, index1, id, name);
	}
	
	ly_3opc_left_init();
	ly_3opc_right_init();
	return NULL;
}
Пример #13
0
gboolean	ly_3lrc_config_on_fixed_changed_cb		(GtkWidget *widget, gpointer data)
{
	int lrc_desktop=0;
	int lrc_desktop_fixed=0;
	
	ly_reg_get("3lrc_desktop_state", "%d:%d", &lrc_desktop, &lrc_desktop_fixed);
	if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
	{
		lrc_desktop_fixed=1;
	}
	else
	{
		lrc_desktop_fixed=0;
	}
	ly_reg_set("3lrc_desktop_state", "%d:%d", lrc_desktop, lrc_desktop_fixed);
	return FALSE;
}
Пример #14
0
gboolean ly_3lrc_desktop_on_update_cb(gpointer data)
{
	if(!ly_3lrc_desktop)
		return TRUE;
		
	int lrc_desktop_visible=0;
	ly_reg_get("3lrc_desktop_state", "%d:%*d", &lrc_desktop_visible);
	if(lrc_desktop_visible<=0)
	{
		gtk_widget_hide(ly_3lrc_desktop);
		return TRUE;
	}
	else
	{
		gtk_widget_show(ly_3lrc_desktop);
		gtk_widget_queue_draw (ly_3lrc_desktop);
	}	
	return TRUE;
}
Пример #15
0
/**
 * ly_aud_prev:
 *
 * play the prev song.
 *
 * Returns:	TRUE for success, others FALSE.
 */
gboolean
ly_aud_prev()
{
	LyMdhMetadata *md=ly_pqm_get_current_md();
	if(!md)
		return FALSE;

	GstState state;
	state=ly_aud_get_state();
	ly_aud_stop();

	gint random=0;
	gint repeat=1;
	gint single=0;
	ly_reg_get("aud_mode","%d:%d:%d", &random,&repeat,&single);

	if(random)
	{
		ly_pqm_set_rand();
	}
	else
	{
		if(single)
		{
			if(!repeat)
			{
				state=GST_STATE_READY;
			}
		}
		else
		{

			ly_pqm_set_prev();
		}
	}

	if(state==GST_STATE_PLAYING)
	{
		ly_aud_play();
	}
	return TRUE;
}
Пример #16
0
gboolean ly_3lrc_widget_on_expose_cb(GtkWidget * widget, cairo_t *cr, gpointer data)
{
	
	gint width;
	gint height;
	width = gtk_widget_get_allocated_width (widget);
	height = gtk_widget_get_allocated_height (widget);

	gchar title_font[1024]="Sans Regular 18";
	ly_reg_get("3lrc_title_font", "%1024[^\n]", title_font);
	gchar normal_font[1024]="Sans Regular 10";
	ly_reg_get("3lrc_normal_font", "%1024[^\n]", normal_font);

	/*
	 * draw bg
	 */
	if(ly_3lrc_pixbuf_bg)
	{
		if(ly_3lrc_pixbuf_bg_copy)
		{
			int h=gdk_pixbuf_get_height(ly_3lrc_pixbuf_bg_copy);
			int w=gdk_pixbuf_get_width(ly_3lrc_pixbuf_bg_copy);
			if(h<height||h-height>2||w<width||w-width>2)
			{
				g_object_unref(ly_3lrc_pixbuf_bg_copy);
				ly_3lrc_pixbuf_bg_copy=gdk_pixbuf_scale_simple(ly_3lrc_pixbuf_bg, width, height, GDK_INTERP_BILINEAR);
			}
		}
		else
		{
			ly_3lrc_pixbuf_bg_copy=gdk_pixbuf_scale_simple(ly_3lrc_pixbuf_bg, width, height, GDK_INTERP_BILINEAR);
		}
		gdk_cairo_set_source_pixbuf(cr, ly_3lrc_pixbuf_bg_copy, 0, 0);	
		cairo_paint(cr);
	}
	cairo_rectangle (cr, 0, 0, width, height);
	cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
	cairo_fill(cr);

	//画标题
	cairo_pattern_t *pat;
	pat = cairo_pattern_create_linear (0, 0, 0, 45);
	cairo_pattern_add_color_stop_rgba (pat, 0, 1, 1, 1, 0.5);
	cairo_pattern_add_color_stop_rgba (pat, 0.18, 1, 1, 1, 0.3);
	cairo_pattern_add_color_stop_rgba (pat, 0.25, 1, 1, 1, 0.1);
	cairo_pattern_add_color_stop_rgba (pat, 1, 1, 1, 1, 0.1);
	cairo_rectangle (cr, 0, 0, width, 45);
	cairo_set_source (cr, pat);
	cairo_fill(cr);
	cairo_pattern_destroy (pat);

	cairo_set_line_width(cr, 0.5);
	cairo_set_source_rgba (cr, 0.9, 0.9, 0.9, 0.6);
	cairo_move_to(cr, 0, 44);
	cairo_line_to(cr, width, 44);
	cairo_stroke(cr);
	cairo_set_source_rgba (cr, 0, 0, 0, 0.9);
	cairo_move_to(cr, 0, 44.5);
	cairo_line_to(cr, width, 44.5);
	cairo_stroke(cr);

	LyMdhMetadata *md=ly_pqm_get_current_md();
	int length=ly_lrc_get_length();

	if(md)
	{
		gchar title[1024]="";
		g_snprintf(title, sizeof(title), "%s - %s", md->title,md->artist);
		cairo_set_source_rgb ( cr, 0.1, 0.1, 0.1);
		ly_3lrc_widget_draw_text_midx(cr, title, title_font, width ,6);
		cairo_set_source_rgb ( cr, 0.9, 0.9, 0.9);
		ly_3lrc_widget_draw_text_midx(cr, title, title_font, width ,7);
	}
	
	
	//没有找到歌词
	if(length<=0||!md)
	{
		//画边框
		cairo_set_source_rgba ( cr, 0.3 , 0.3 , 0.3 ,0.8) ;
		cairo_set_line_width ( cr,1);
		cairo_translate ( cr, width/2 , height/2);
		cairo_move_to(cr, -70, -30);
		cairo_line_to(cr, 70, -30);
		cairo_arc(cr, 70, 0.0, 30.0 ,-M_PI/2 ,-M_PI*3/2);
		cairo_line_to(cr, 70, 30);
		cairo_arc(cr, -70, 0.0, 30.0 ,M_PI/2 ,M_PI*3/2);
		cairo_fill (cr);
		
		//画闪烁的原点
		cairo_translate ( cr, -60 , 0 );
		static  gdouble const  trs[ 8 ] [ 8 ]  = {
			{ 0.0 , 0.15 , 0.30 , 0.5 , 0.65 , 0.80 , 0.9 , 1.0 } ,
			{ 1.0 , 0.0 , 0.15 , 0.30 , 0.5 , 0.65 , 0.8 , 0.9 } ,
			{ 0.9 , 1.0 , 0.0 , 0.15 , 0.3 , 0.5 , 0.65 , 0.8 } ,
			{ 0.8 , 0.9 , 1.0 , 0.0 , 0.15 , 0.3 , 0.5 , 0.65 } ,
			{ 0.65 , 0.8 , 0.9 , 1.0 , 0.0 , 0.15 , 0.3 , 0.5 } ,
			{ 0.5 , 0.65 , 0.8 , 0.9 , 1.0 , 0.0 , 0.15 , 0.3 } ,
			{ 0.3 , 0.5 , 0.65 , 0.8 , 0.9 , 1.0 , 0.0 , 0.15 } ,
			{ 0.15 , 0.3 , 0.5 , 0.65 , 0.8 , 0.9 , 1.0 , 0.0 ,}
		};
		gint i = 0 ;
		for ( i = 0 ; i < 8 ; i++)
		{
			cairo_set_line_width ( cr, 8 ) ;
			cairo_set_line_cap ( cr, CAIRO_LINE_CAP_ROUND) ;
			cairo_set_source_rgba ( cr, 1.0 , 1.0 , 1.0 , trs[count%8][i]) ;
			
			cairo_move_to ( cr, 0.0 , -15.0 );
			cairo_line_to (cr, 0.0, -15.0);
			cairo_rotate ( cr, M_PI / 4 ) ;
			
			cairo_stroke ( cr) ;
		}
		
		//写字“Serching Lyrics...”
		cairo_set_source_rgba ( cr, 1.0 , 1.0 , 1.0 , 1.0) ;
		cairo_move_to (cr, 30.0 , -6.0);
		ly_3lrc_widget_draw_text(cr,"Missing Lyrics...", "Sans Regular 10");
		
		count=(count+1)%8;
	}
	
	//有歌词
	else
	{
		gint lrc_gap=20;
		if(!ly_reg_get("lrc_gap","%d",&lrc_gap))
		{
			ly_reg_set("lrc_gap","%d",lrc_gap);
		}
		
		int y=height/2;
		LyLrcLyric **array=ly_lrc_get_array();
		int index=ly_lrc_get_index();
		if(flag_seek&&flag_seeked)
		{
			cairo_set_source_rgba ( cr, 0.8, 0.8, 0.8, 0.8);
			cairo_set_line_width ( cr,20);
			cairo_set_line_cap ( cr, CAIRO_LINE_CAP_ROUND) ;
			cairo_move_to(cr, 10.0, height/2.0+8);
			cairo_line_to(cr, width-10.0, height/2.0+8);
			cairo_stroke (cr);
			y=height/2.0;
		}
		else
		{
			gint64 t1=0;
			gint64 t2=0;
			
			if(index+1<length)
			{
				t1=array[index+1]->time-array[index]->time;
			}
			else
				t1=ly_mdh_time_str2int(md->duration)-array[index]->time;
			t2=ly_aud_get_position_abs()-array[index]->time;
			
			if(t1!=0)
			{
				y=y-(int)((t2/(gdouble)t1)*lrc_gap);
			}
		}
		//正式画歌词区域
		//画当前歌词
		cairo_set_source_rgb(cr,1, 1, 1);
		if(y>height/5.0&&y<height*4/5.0)
			ly_3lrc_widget_draw_text_midx(cr,array[index]->text, normal_font,width,y);
		
		//画普通歌词
		cairo_set_source_rgb(cr,0.5,0.5,0.5);
		int i=1;
		for(i=1;i<=10;i++)
		{
			if(index-i>=0 &&(y-i*(lrc_gap)>height/5.0))
			{
				ly_3lrc_widget_draw_text_midx(cr,array[index-i]->text, normal_font,width,y-i*(lrc_gap));
			}
			else
				break;
		}
		for(i=1;i<=10;i++)
		{
			if(index+i<length &&(y+i*(lrc_gap)<(height/5.0*4)))
			{
				ly_3lrc_widget_draw_text_midx(cr,array[index+i]->text,normal_font,width,y+i*(lrc_gap));
			}
			else
				break;
		}
	}
	return FALSE;
}
Пример #17
0
gboolean ly_3inf_on_expose_cb(GtkWidget *widget, cairo_t *cr, gpointer data)
{
	/*
	 * get width & height
	 */
	gint width;
	gint height;
	gint x;
	gint y;
	width = gtk_widget_get_allocated_width (widget);
	height = gtk_widget_get_allocated_height (widget);
	
	/*
	 * draw bg
	 */
	if(ly_3inf_pixbuf_bg)
	{
		if(ly_3inf_pixbuf_bg_copy)
		{
			int h=gdk_pixbuf_get_height(ly_3inf_pixbuf_bg_copy);
			int w=gdk_pixbuf_get_width(ly_3inf_pixbuf_bg_copy);
			if(h<height||h-height>2||w<width||w-width>2)
			{
				g_object_unref(ly_3inf_pixbuf_bg_copy);
				ly_3inf_pixbuf_bg_copy=gdk_pixbuf_scale_simple(ly_3inf_pixbuf_bg, width, height, GDK_INTERP_BILINEAR);
			}
		}
		else
		{
			ly_3inf_pixbuf_bg_copy=gdk_pixbuf_scale_simple(ly_3inf_pixbuf_bg, width, height, GDK_INTERP_BILINEAR);
		}
		gdk_cairo_set_source_pixbuf(cr, ly_3inf_pixbuf_bg_copy, 0, 0);	
		cairo_paint(cr);
	}

	/*
	 * draw banner
	 */
	cairo_rectangle (cr, 0, height/2-120, width, 240);
	cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
	cairo_fill(cr);
	
	cairo_set_line_width(cr, 0.5);
	cairo_set_source_rgba (cr, 0.9, 0.9, 0.9, 0.7);
	cairo_move_to(cr, 0, height/2-118.5);
	cairo_line_to(cr, width, height/2-118.5);
	cairo_stroke(cr);
	cairo_move_to(cr, 0, height/2+118.5);
	cairo_line_to(cr, width, height/2+118.5);
	cairo_stroke(cr);
	
	/*
	 * draw image
	 */
	x=width/10;
	y=height/2-100;
	GdkPixbuf *pixbuf=NULL;
	pixbuf=ly_3inf_cover_get();
	if(pixbuf)
	{
		gdk_cairo_set_source_pixbuf(cr,	pixbuf, x, y);
		cairo_paint(cr);
		g_object_unref(pixbuf);
	}
	cairo_move_to(cr, 100, 100);
	if(ly_3inf_pixbuf_cd)
	{
		gdk_cairo_set_source_pixbuf(cr, ly_3inf_pixbuf_cd, x, y);
		cairo_paint(cr);
	}
	
	/*
	 * draw information
	 */
	gchar title_font[1024]="Sans Regular 18";
	ly_reg_get("3inf_title_font", "%1024[^\n]", title_font);
	gchar normal_font[1024]="Sans Regular 10";
	ly_reg_get("3inf_normal_font", "%1024[^\n]", normal_font);
	
	LyMdhMetadata *md=ly_pqm_get_current_md();
	if(!md)
		return FALSE;
	x=width/10+270;
	y=height/2-60;
	cairo_set_source_rgba ( cr, 0.1 , 0.1 , 0.1 ,1.0);
	cairo_move_to ( cr, x, y-2);
	ly_3inf_draw_text(cr, md->title, title_font);
	cairo_set_source_rgba ( cr, 0.9 , 0.9 , 0.9 ,1.0);
	cairo_move_to ( cr, x, y);
	ly_3inf_draw_text(cr, md->title, title_font);

	x=x;
	y=y+50;
	char str[1024]="";
	cairo_set_source_rgba ( cr, 0.7 , 0.7 , 0.7 ,0.8);
	cairo_move_to ( cr, x, y);
	ly_3inf_draw_text(cr, md->artist, normal_font);
	cairo_move_to ( cr, x, y+30);
	ly_3inf_draw_text(cr, md->album, normal_font);
	cairo_move_to ( cr, x, y+60);
	g_snprintf(str, sizeof(str), "%s - %d kb/s", md->codec, md->bitrate/1024);
	ly_3inf_draw_text(cr, str, normal_font);
	
	return FALSE;
}
Пример #18
0
GtkWidget *ly_3lrc_config()
{
	GtkWidget *page;
	GtkWidget *item;
	GtkWidget *vbox;
	GtkWidget *hbox;
	GtkWidget *check;
	GtkWidget *button;	
	GtkWidget *entry;
	GtkWidget *label;
	GtkWidget *table;
	char str[1024]="";
	
	char name[1024]="";
	LyPliPlugin *pl=ly_pli_get("lrc");
	g_snprintf(name, sizeof(name), "PLUGIN:%s", pl->name);
	page=ly_cfg_page_new(name, pl->alias, pl->logo);
	
	item=ly_cfg_item_new(_("Desktop Lyrics"));
	ly_cfg_page_append(LY_CFG_PAGE(page), item);
	vbox=gtk_vbox_new(FALSE, 0);
	ly_cfg_item_append(LY_CFG_ITEM(item), vbox);
	int lrc_desktop=0;
	int lrc_desktop_fixed=0;
	ly_reg_get("3lrc_desktop_state", "%d:%d", &lrc_desktop, &lrc_desktop_fixed);
	check=gtk_check_button_new_with_label(_("Show desktop lyrics"));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),(gboolean)lrc_desktop);
	g_signal_connect(G_OBJECT(check), "toggled", G_CALLBACK(ly_3lrc_config_on_desktop_changed_cb), NULL);
	gtk_box_pack_start(GTK_BOX(vbox),check,FALSE,FALSE,0);
	check=gtk_check_button_new_with_label(_("Set desktop lyrics FIXED"));
	g_signal_connect(G_OBJECT(check), "toggled", G_CALLBACK(ly_3lrc_config_on_fixed_changed_cb), NULL);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),(gboolean)lrc_desktop_fixed);
	gtk_box_pack_start(GTK_BOX(vbox),check,FALSE,FALSE,0);
	
	item=ly_cfg_item_new(_("Lyrics File Storage"));
	ly_cfg_page_append(LY_CFG_PAGE(page), item);
	char location[1024]="./";
	ly_reg_get("lrc_dir", "%s", location);
	vbox=gtk_vbox_new(FALSE, 0);
	ly_cfg_item_append(LY_CFG_ITEM(item), vbox);
	hbox=gtk_hbox_new(FALSE,0);
	if(g_str_equal(location,"")||g_str_equal(location,"./"))
		gtk_widget_set_sensitive(hbox, FALSE);
	check=gtk_check_button_new_with_label(_("The same directory of music file"));
	if(g_str_equal(location,"")||g_str_equal(location,"./"))
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), TRUE);
	g_signal_connect(G_OBJECT(check), "toggled", G_CALLBACK(ly_3lrc_config_on_location_changed_cb), hbox);
	gtk_box_pack_start(GTK_BOX(vbox),check,FALSE,FALSE,0);
	gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,0);
	label=gtk_label_new(_("Custom LRC location"));
	gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,0);
	entry=gtk_entry_new();
	gtk_entry_set_text(GTK_ENTRY(entry), location);
	check=gtk_check_button_new_with_label(_("The same directory of music file"));
	gtk_widget_set_sensitive(entry,FALSE);
	gtk_box_pack_start(GTK_BOX(hbox),entry,TRUE,TRUE,0);
	button=gtk_button_new_from_stock(GTK_STOCK_OPEN);
	g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(ly_3lrc_config_on_location_set_cb), entry);
	gtk_box_pack_start(GTK_BOX(hbox),button,FALSE,FALSE,0);
	
	item=ly_cfg_item_new(_("Font"));
	ly_cfg_page_append(LY_CFG_PAGE(page), item);
	table=gtk_table_new(3, 2, FALSE);
	ly_cfg_item_append(LY_CFG_ITEM(item), table);
	label=gtk_label_new(_("Title Font"));
	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
	ly_reg_get("3lrc_title_font", "%1024[^\n]", str);
	button=gtk_font_button_new_with_font(str);
	g_signal_connect(G_OBJECT(button), "font-set", G_CALLBACK(ly_3lrc_config_on_title_font_set_cb), NULL);
	gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 0, 1);
	label=gtk_label_new(_("Normal Font"));
	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);
	ly_reg_get("3lrc_normal_font", "%1024[^\n]", str);
	button=gtk_font_button_new_with_font(str);
	g_signal_connect(G_OBJECT(button), "font-set", G_CALLBACK(ly_3lrc_config_on_normal_font_set_cb), NULL);
	gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 1, 2);
	label=gtk_label_new(_("Desktop Font"));
	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3);
	ly_reg_get("3lrc_desktop_font", "%1024[^\n]", str);
	button=gtk_font_button_new_with_font(str);
	g_signal_connect(G_OBJECT(button), "font-set", G_CALLBACK(ly_3lrc_config_on_desktop_font_set_cb), NULL);
	gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 2, 3);
	
	return page;
}
Пример #19
0
gboolean	ly_3lrc_desktop_on_expose_cb	(GtkWidget * widget, cairo_t *cr, gpointer data)
{
	gchar desktop_font[1024]="Sans Regular 25";
	ly_reg_get("3lrc_desktop_font", "%1024[^\n]", desktop_font);

	gchar path[1024];
	g_snprintf(path,sizeof(path),"%sicon/null.png",LY_GLB_PROG_UIXDIR);
	if(!desktop_bg)
		desktop_bg=cairo_image_surface_create_from_png(path);

	cairo_set_source_surface(cr, desktop_bg, 0, 0);
	cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
	cairo_paint(cr);
	
	int width;
	int height;
	width = gtk_widget_get_allocated_width (widget);
	height = gtk_widget_get_allocated_height (widget);
	
	int x=0;
	int y=height;
	
	//鼠标进入
	if(flag_notify)
	{
		//填充圆角矩形拖动区域
		cairo_set_source_rgba(cr,0,0,0,0.3);
		cairo_move_to (cr, 0 + 5, 0);
		cairo_line_to (cr, 0 + width - 5, 0);
		cairo_move_to (cr, 0 + width, 0 + 5);
		cairo_line_to (cr, 0 + width, 0 + height - 5);
		cairo_move_to (cr, 0 + width - 5, 0 + height);
		cairo_line_to (cr, 0 + 5, 0 + height);
		cairo_move_to (cr, 0, 0 + height - 5);
		cairo_line_to (cr, 0, 0 + 5);
		cairo_arc (cr, 0 + 5, 0 + 5, 5, M_PI, 3 * M_PI / 2.0);
		cairo_arc (cr, 0 + width - 5, 0 + 5, 5, 3 * M_PI / 2, 2 * M_PI);
		cairo_arc (cr, 0 + width - 5, 0 + height - 5, 5, 0, M_PI / 2);
		cairo_arc (cr, 0 + 5, 0 + height - 5, 5, M_PI / 2, M_PI);
		cairo_fill(cr);
	}
	
	if(ly_lrc_get_length()>0)
	{
		//计算占空比
		gint64 t1=0;
		gint64 t2=0;
		
		LyMdhMetadata *md=NULL;
		md=ly_pqm_get_current_md();
		if(!md)
			return FALSE;
		if(ly_lrc_get_index()+1<ly_lrc_get_length())
			t1=(ly_lrc_get_array()[ly_lrc_get_index()+1])->time-(ly_lrc_get_array()[ly_lrc_get_index()])->time;
		else
			t1=ly_mdh_time_str2int(md->duration)-ly_mdh_time_str2int(md->start)-(ly_lrc_get_array()[ly_lrc_get_index()])->time;
		
		t2=ly_aud_get_position_abs()-ly_mdh_time_str2int(md->start)-(ly_lrc_get_array()[ly_lrc_get_index()])->time;
		if(t1!=0)
		{
			x=(int)((t2/(gdouble)t1)*pos_layout[X]);
		}
		
		//画歌词
		cairo_set_source_rgb(cr,0,0,0);
		
		//确定起始点
		if((x>=width/2)&&(pos_layout[X]>width)&&(width<(pos_layout[X]-x)*2))
		{
			cairo_move_to(cr, 0-(x-width/2), 5);
			x=width/2;
		}
		else if((x>=width/2)&&(pos_layout[X]>width)&&(width>=(pos_layout[X]-x)*2))
			cairo_move_to(cr, 0-(pos_layout[X]-width), 5);
		else
			cairo_move_to(cr, 0, 5);
		
		PangoLayout *layout;
		PangoFontDescription *desc;
		layout = pango_cairo_create_layout (cr);
		
		pango_layout_set_text(layout, ly_lrc_get_array()[ly_lrc_get_index()]->text, -1);
		desc = pango_font_description_from_string (desktop_font);
		pango_layout_set_font_description (layout, desc);
		pango_font_description_free (desc);
		
		
		pango_layout_get_size(layout,&pos_layout[X],&pos_layout[Y]);
		pos_layout[X]=pos_layout[X]/1000;
		
		pango_cairo_update_layout (cr, layout);
		pango_cairo_layout_path (cr, layout);
		cairo_clip(cr);
		g_object_unref (layout);
		
		//画背景条
		cairo_pattern_t *pat;
		pat = cairo_pattern_create_linear (0, 0,10.0, 150);
		cairo_pattern_add_color_stop_rgb (pat, 0.1, 65535/65535.0, 10449/65535.0, 0/65535.0);
		cairo_pattern_add_color_stop_rgb (pat, 0.5, 65535/65535.0, 61062/65535.0, 0/65535.0);
		cairo_pattern_add_color_stop_rgb (pat, 0.9, 65535/65535.0, 10449/65535.0, 0/65535.0);
		//画矩形
		if((x>=width/2)&&(pos_layout[X]>width)&&(width<(pos_layout[X]-x)*2))
			cairo_rectangle (cr, 0, 0, width/2, y);
		else if((x>=width/2)&&(pos_layout[X]>width)&&(width>=(pos_layout[X]-x)*2))
			cairo_rectangle (cr, 0, 0, width-(pos_layout[X]-x), y);
		else
			cairo_rectangle (cr, 0, 0, x, y);
		cairo_set_source (cr, pat);
		cairo_fill(cr);
		cairo_pattern_destroy (pat);
		pat = cairo_pattern_create_linear (0, 0,10.0, 150);
		cairo_pattern_add_color_stop_rgb (pat, 0.1, 19532/65535.0, 65535/65535.0, 65535/65535.0);
		cairo_pattern_add_color_stop_rgb (pat, 0.5, 5539/65535.0, 0/65535.0, 65535/65535.0);
		cairo_pattern_add_color_stop_rgb (pat, 0.9, 19532/65535.0, 65535/65535.0, 65535/65535.0);
		//画矩形
		if((x>=width/2)&&(pos_layout[X]>width)&&(width<(pos_layout[X]-x)*2))
			cairo_rectangle (cr, width/2, 0, width-(width/2), y);
		else if((x>=width/2)&&(pos_layout[X]>width)&&(width>=(pos_layout[X]-x)*2))
			cairo_rectangle (cr, width-(pos_layout[X]-x), 0, pos_layout[X]-x, y);
		else
			cairo_rectangle (cr, x, 0, width-x, y);
		cairo_set_source (cr, pat);
		cairo_fill(cr);
		cairo_pattern_destroy (pat);
	}
	
	int lrc_desktop=1;
	int lrc_desktop_fix=0;
	if(!ly_reg_get("3lrc_desktop_state", "%d:%d", &lrc_desktop, &lrc_desktop_fix))
	{
		ly_reg_set("3lrc_desktop_state", "%d:%d", lrc_desktop, lrc_desktop_fix);
	}
	if(lrc_desktop_fix>0)
		gtk_widget_set_sensitive(widget,FALSE);
	else
		gtk_widget_set_sensitive(widget,TRUE);
	cairo_region_t *region;
	if(!(lrc_desktop_fix))
	{
		cairo_rectangle_int_t rect;
		rect.x=rect.y=0;
		rect.width=width;
		rect.height=height;
		region=cairo_region_create_rectangle(&rect);
	}
	else
	{
		region=cairo_region_create();
	}
	gdk_window_input_shape_combine_region (gtk_widget_get_window(widget), region, 0, 0);
	cairo_region_destroy (region);
	
	return FALSE;
}
Пример #20
0
gboolean ly_3lrc_widget_on_seek_cb(GtkWidget * widget, GdkEventButton *event, gpointer data)
{
	LyMdhMetadata *md=ly_pqm_get_current_md();
	if(!md)
		return FALSE;
	
	int length=ly_lrc_get_length();
	if(length<=0)
		return FALSE;
		
	//GdkCursor *cursor;
	int index=0;
	if (event->button == 1)
	{
		switch(event->type)
		{
			case GDK_BUTTON_PRESS:
				flag_seek=TRUE;
				ly_3lrc_widget_pos_old[X] = event->x;
				ly_3lrc_widget_pos_old[Y] = event->y;
				index_mark=ly_lrc_get_index();
				break;
			case GDK_BUTTON_RELEASE:
				if(flag_seek==TRUE&&flag_seeked==TRUE)
				{
					LyLrcLyric **array=ly_lrc_get_array();
					index=ly_lrc_get_index();
					ly_aud_set_position(array[index]->time/(double)ly_mdh_time_str2int(md->duration));
				}
				flag_seek = FALSE;
				flag_seeked=FALSE;
				ly_lrc_set_update_state(TRUE);

				break;
			default:
				break;
		}
	}
	if(flag_seek)
	{
		int pos[2]={0,0};
		gtk_widget_get_pointer(widget, &pos[X], &pos[Y]);
		ly_3lrc_widget_pos_delta[Y]=pos[Y]-ly_3lrc_widget_pos_old[Y];
		if(pos[Y]-ly_3lrc_widget_pos_old[Y])
			flag_seeked=TRUE;
			ly_lrc_set_update_state(FALSE);
	}
	if(flag_seek&&flag_seeked)
	{
		gint lrc_gap=20;
		if(!ly_reg_get("lrc_gap","%d",&lrc_gap))
		{
			ly_reg_set("lrc_gap","%d",lrc_gap);
		}
		index=index_mark;
		if(ly_3lrc_widget_pos_delta[Y]>=0)
		{
			index-=(int)(abs(ly_3lrc_widget_pos_delta[Y])/lrc_gap);
			if(index<0)
			{
				index=0;
			}
		}
		else
		{
			index+=(int)(abs(ly_3lrc_widget_pos_delta[Y])/lrc_gap);
			if(index>=length)
			{
				index=length-1;
			}
		}
		ly_lrc_set_index(index);
	}
	return FALSE;
}