Mercurial > audlegacy-plugins
comparison src/aosd/aosd.c @ 569:d401f87f89f7 trunk
[svn] - added Audacious OSD, yet-another-written-from-scratch plugin to display OSD, based on Ghosd library; currently untied from configure, to compile it you have to run make in its directory; will be added to configure after some testing
author | giacomo |
---|---|
date | Mon, 29 Jan 2007 06:40:04 -0800 |
parents | |
children | 1708b03e116c |
comparison
equal
deleted
inserted
replaced
568:8c64b5abdcda | 569:d401f87f89f7 |
---|---|
1 /* | |
2 * | |
3 * Author: Giacomo Lozito <james@develia.org>, (C) 2005-2007 | |
4 * | |
5 * This program is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License as published by the | |
7 * Free Software Foundation; either version 2 of the License, or (at your | |
8 * option) any later version. | |
9 * | |
10 * This program is distributed in the hope that it will be useful, but | |
11 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 * General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU General Public License along | |
16 * with this program; if not, write to the Free Software Foundation, Inc., | |
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
18 * | |
19 */ | |
20 | |
21 #include "aosd.h" | |
22 #include "aosd_osd.h" | |
23 #include "aosd_cfg.h" | |
24 #include <audacious/input.h> | |
25 #include <audacious/playlist.h> | |
26 #include <audacious/strings.h> | |
27 | |
28 | |
29 static guint timeout_sid = 0; | |
30 static gchar *prev_title = NULL; | |
31 static gboolean was_playing = FALSE; | |
32 aosd_cfg_t * global_config = NULL; | |
33 | |
34 | |
35 gboolean | |
36 aosd_check_pl_change ( gpointer data ) | |
37 { | |
38 if ( ip_data.playing ) | |
39 { | |
40 Playlist *active = playlist_get_active(); | |
41 gint pos = playlist_get_position(active); | |
42 gchar *title = playlist_get_songtitle(active, pos); | |
43 | |
44 if ( ( title != NULL ) && | |
45 ( (( prev_title != NULL ) && ( strcmp(title,prev_title) )) || | |
46 ( was_playing == FALSE ) ) ) | |
47 { | |
48 /* string formatting is done here a.t.m. - TODO - improve this area */ | |
49 gchar *utf8_title = str_to_utf8( title ); | |
50 gchar *utf8_title_markup = g_markup_printf_escaped( | |
51 "<span font_desc='%s'>%s</span>" , global_config->osd->text.fonts_name[0] , utf8_title ); | |
52 aosd_display( utf8_title_markup , global_config->osd , FALSE ); | |
53 g_free( utf8_title_markup ); | |
54 g_free( utf8_title ); | |
55 } | |
56 | |
57 if ( prev_title != NULL ) | |
58 g_free(prev_title); | |
59 prev_title = g_strdup(title); | |
60 | |
61 g_free( title ); | |
62 } | |
63 else | |
64 { | |
65 if ( prev_title != NULL ) | |
66 { g_free(prev_title); prev_title = NULL; } | |
67 } | |
68 | |
69 was_playing = ip_data.playing; | |
70 return TRUE; | |
71 } | |
72 | |
73 | |
74 /* ***************** */ | |
75 /* plug-in functions */ | |
76 | |
77 GeneralPlugin *get_gplugin_info() | |
78 { | |
79 return &aosd_gp; | |
80 } | |
81 | |
82 | |
83 void | |
84 aosd_init ( void ) | |
85 { | |
86 g_log_set_handler( NULL , G_LOG_LEVEL_WARNING , g_log_default_handler , NULL ); | |
87 | |
88 global_config = aosd_cfg_new(); | |
89 aosd_cfg_load( global_config ); | |
90 | |
91 timeout_sid = g_timeout_add( 500 , (GSourceFunc)aosd_check_pl_change , NULL ); | |
92 return; | |
93 } | |
94 | |
95 | |
96 void | |
97 aosd_cleanup ( void ) | |
98 { | |
99 if ( timeout_sid > 0 ) | |
100 g_source_remove( timeout_sid ); | |
101 | |
102 if ( prev_title != NULL ) | |
103 { | |
104 g_free(prev_title); | |
105 prev_title = NULL; | |
106 } | |
107 | |
108 aosd_shutdown(); | |
109 | |
110 if ( global_config != NULL ) | |
111 { | |
112 aosd_cfg_delete( global_config ); | |
113 global_config = NULL; | |
114 } | |
115 | |
116 return; | |
117 } | |
118 | |
119 | |
120 void | |
121 aosd_configure ( void ) | |
122 { | |
123 /* create a new configuration object */ | |
124 aosd_cfg_t *cfg = aosd_cfg_new(); | |
125 /* fill it with information from config file */ | |
126 aosd_cfg_load( cfg ); | |
127 /* call the configuration UI */ | |
128 aosd_ui_configure( cfg ); | |
129 /* delete configuration object */ | |
130 aosd_cfg_delete( cfg ); | |
131 return; | |
132 } | |
133 | |
134 | |
135 void | |
136 aosd_about ( void ) | |
137 { | |
138 aosd_ui_about(); | |
139 return; | |
140 } |