annotate src/statusicon/si_ui.c @ 439:84029a5250c1 trunk

[svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
author giacomo
date Tue, 16 Jan 2007 10:34:12 -0800
parents 38fe08dff5cd
children 84fdf898438b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
1 /*
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
2 *
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
3 * Author: Giacomo Lozito <james@develia.org>, (C) 2005-2007
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
4 *
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify it
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
6 * under the terms of the GNU General Public License as published by the
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
7 * Free Software Foundation; either version 2 of the License, or (at your
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
8 * option) any later version.
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
9 *
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful, but
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
13 * General Public License for more details.
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
14 *
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License along
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
16 * with this program; if not, write to the Free Software Foundation, Inc.,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
18 *
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
19 */
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
20
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
21 #include "si_ui.h"
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
22 #include "si_audacious.h"
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
23 #include "si_common.h"
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
24 #include "gtktrayicon.h"
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
25 #include "si.xpm"
439
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
26 #include <audacious/playlist.h>
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
27 #include <audacious/titlestring.h>
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
28 #include <audacious/ui_fileinfopopup.h>
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
29 #include <glib.h>
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
30 #include <glib/gi18n.h>
439
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
31 #include <gdk/gdk.h>
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
32 #include <gtk/gtk.h>
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
33
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
34
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
35 static GtkWidget * si_evbox = NULL;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
36
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
37
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
38 static GtkTrayIcon *
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
39 si_ui_statusicon_create ( void )
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
40 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
41 GtkTrayIcon *si_applet = NULL;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
42
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
43 si_applet = _gtk_tray_icon_new( "audacious" );
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
44
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
45 gtk_widget_show( GTK_WIDGET(si_applet) );
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
46
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
47 return si_applet;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
48 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
49
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
50
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
51 static GtkWidget *
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
52 si_ui_rmenu_create ( GtkWidget * evbox )
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
53 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
54 GtkWidget *menu;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
55 GtkWidget *menuitem;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
56
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
57 menu = gtk_menu_new();
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
58
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
59 /* gtk_widget_show_all( GTK_WIDGET(menu) ); */
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
60 return menu;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
61 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
62
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
63
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
64 static gboolean
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
65 si_ui_statusicon_cb_btpress ( GtkWidget * evbox , GdkEventButton * event )
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
66 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
67 switch ( event->button )
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
68 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
69 case 1:
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
70 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
71 si_audacious_toggle_visibility();
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
72 break;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
73 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
74
439
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
75 /*
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
76 case 3:
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
77 {
439
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
78
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
79 GtkWidget *si_rmenu = GTK_WIDGET(g_object_get_data( G_OBJECT(evbox) , "rmenu" ));
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
80 gtk_menu_popup( GTK_MENU(si_rmenu) , NULL , NULL ,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
81 NULL , NULL , event->button , event->time );
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
82 break;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
83 }
439
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
84 */
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
85 }
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
86
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
87 return FALSE;
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
88 }
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
89
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
90
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
91 static gboolean
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
92 si_ui_statusicon_popup_show ( gpointer evbox )
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
93 {
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
94 if ( GPOINTER_TO_INT(g_object_get_data( G_OBJECT(evbox) , "timer_active" )) == 1 )
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
95 {
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
96 TitleInput *tuple;
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
97 Playlist *pl_active = playlist_get_active();
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
98 gint pos = playlist_get_position(pl_active);
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
99 GtkWidget *popup = g_object_get_data( G_OBJECT(evbox) , "popup" );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
100
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
101 tuple = playlist_get_tuple( pl_active , pos );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
102 audacious_fileinfopopup_show_from_tuple( popup , tuple );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
103
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
104 g_object_set_data( G_OBJECT(evbox) , "popup_active" , GINT_TO_POINTER(1) );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
105 }
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
106
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
107 g_object_set_data( G_OBJECT(evbox) , "timer_id" , GINT_TO_POINTER(0) );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
108 g_object_set_data( G_OBJECT(evbox) , "timer_active" , GINT_TO_POINTER(0) );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
109 return FALSE;
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
110 }
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
111
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
112
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
113 static void
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
114 si_ui_statusicon_popup_hide ( gpointer evbox )
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
115 {
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
116 if ( GPOINTER_TO_INT(g_object_get_data( G_OBJECT(evbox) , "popup_active" )) == 1 )
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
117 {
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
118 GtkWidget *popup = g_object_get_data( G_OBJECT(evbox) , "popup" );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
119 g_object_set_data( G_OBJECT(evbox) , "popup_active" , GINT_TO_POINTER(0) );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
120 audacious_fileinfopopup_hide( popup , NULL );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
121 }
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
122 }
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
123
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
124
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
125 static void
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
126 si_ui_statusicon_popup_timer_start ( GtkWidget * evbox )
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
127 {
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
128 gint timer_id = g_timeout_add( 500 , si_ui_statusicon_popup_show , evbox );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
129 g_object_set_data( G_OBJECT(evbox) , "timer_id" , GINT_TO_POINTER(timer_id) );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
130 g_object_set_data( G_OBJECT(evbox) , "timer_active" , GINT_TO_POINTER(1) );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
131 return;
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
132 }
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
133
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
134
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
135 static void
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
136 si_ui_statusicon_popup_timer_stop ( GtkWidget * evbox )
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
137 {
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
138 if ( GPOINTER_TO_INT(g_object_get_data(G_OBJECT(evbox),"timer_active")) == 1 )
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
139 g_source_remove( GPOINTER_TO_INT(g_object_get_data(G_OBJECT(evbox),"timer_id")) );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
140
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
141 g_object_set_data( G_OBJECT(evbox) , "timer_id" , GINT_TO_POINTER(0) );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
142 g_object_set_data( G_OBJECT(evbox) , "timer_active" , GINT_TO_POINTER(0) );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
143 return;
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
144 }
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
145
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
146
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
147 static gboolean
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
148 si_ui_statusicon_cb_popup ( GtkWidget * evbox , GdkEvent * event )
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
149 {
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
150 if ((event->type == GDK_LEAVE_NOTIFY || event->type == GDK_ENTER_NOTIFY) &&
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
151 event->crossing.detail == GDK_NOTIFY_INFERIOR)
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
152 return FALSE;
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
153
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
154 if ( event->type != GDK_KEY_PRESS && event->type != GDK_KEY_RELEASE )
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
155 {
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
156 GtkWidget *event_widget = gtk_get_event_widget( event );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
157 if ( event_widget != evbox )
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
158 return FALSE;
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
159 }
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
160
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
161 switch (event->type)
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
162 {
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
163 case GDK_EXPOSE:
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
164 /* do nothing */
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
165 break;
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
166
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
167 case GDK_ENTER_NOTIFY:
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
168 si_ui_statusicon_popup_timer_start( evbox );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
169 break;
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
170
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
171 case GDK_LEAVE_NOTIFY:
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
172 si_ui_statusicon_popup_timer_stop( evbox );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
173 if ( GPOINTER_TO_INT(g_object_get_data( G_OBJECT(evbox) , "popup_active" )) == 1 )
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
174 si_ui_statusicon_popup_hide( evbox );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
175 break;
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
176
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
177 case GDK_MOTION_NOTIFY:
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
178 break; /* ignore */
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
179
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
180 case GDK_BUTTON_PRESS:
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
181 case GDK_BUTTON_RELEASE:
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
182 case GDK_KEY_PRESS:
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
183 case GDK_KEY_RELEASE:
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
184 case GDK_PROXIMITY_IN:
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
185 case GDK_SCROLL:
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
186 si_ui_statusicon_popup_timer_stop( evbox );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
187 if ( GPOINTER_TO_INT(g_object_get_data( G_OBJECT(evbox) , "popup_active" )) == 1 )
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
188 si_ui_statusicon_popup_hide( evbox );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
189 break;
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
190
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
191 default:
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
192 break;
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
193 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
194
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
195 return FALSE;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
196 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
197
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
198
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
199 void
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
200 si_ui_statusicon_show ( void )
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
201 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
202 GtkWidget *si_image;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
203 GtkWidget *si_rmenu;
439
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
204 GtkWidget *si_popup;
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
205 GdkPixbuf *si_pixbuf;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
206 GtkTrayIcon *si_applet;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
207
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
208 si_applet = si_ui_statusicon_create();
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
209 if ( si_applet == NULL )
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
210 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
211 g_warning( "StatusIcon plugin: unable to create a status icon.\n" );
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
212 return;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
213 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
214
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
215 si_pixbuf = gdk_pixbuf_new_from_xpm_data( (const char**)si_xpm );
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
216 si_image = gtk_image_new_from_pixbuf( si_pixbuf );
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
217 g_object_unref( si_pixbuf );
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
218
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
219 si_evbox = gtk_event_box_new();
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
220 si_rmenu = si_ui_rmenu_create( si_evbox );
439
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
221 si_popup = audacious_fileinfopopup_create();
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
222
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
223 g_object_set_data( G_OBJECT(si_evbox) , "rmenu" , si_rmenu );
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
224 g_object_set_data( G_OBJECT(si_evbox) , "applet" , si_applet );
439
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
225
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
226 g_object_set_data( G_OBJECT(si_evbox) , "timer_id" , GINT_TO_POINTER(0) );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
227 g_object_set_data( G_OBJECT(si_evbox) , "timer_active" , GINT_TO_POINTER(0) );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
228
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
229 g_object_set_data( G_OBJECT(si_evbox) , "popup_active" , GINT_TO_POINTER(0) );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
230 g_object_set_data( G_OBJECT(si_evbox) , "popup" , si_popup );
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
231
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
232 g_signal_connect( G_OBJECT(si_evbox) , "button-press-event" ,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
233 G_CALLBACK(si_ui_statusicon_cb_btpress) , NULL );
439
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
234 g_signal_connect_after( G_OBJECT(si_evbox) , "event-after" ,
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
235 G_CALLBACK(si_ui_statusicon_cb_popup) , NULL );
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
236
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
237 gtk_container_add( GTK_CONTAINER(si_evbox), si_image );
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
238 gtk_container_add( GTK_CONTAINER(si_applet), si_evbox );
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
239
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
240 gtk_widget_show_all( GTK_WIDGET(si_applet) );
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
241 return;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
242 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
243
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
244
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
245 void
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
246 si_ui_statusicon_hide ( void )
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
247 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
248 if ( si_evbox != NULL )
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
249 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
250 GtkTrayIcon *si_applet = g_object_get_data( G_OBJECT(si_evbox) , "applet" );
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
251 GtkWidget *si_rmenu = g_object_get_data( G_OBJECT(si_evbox) , "rmenu" );
439
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
252 si_ui_statusicon_popup_timer_stop( si_evbox ); /* just in case the timer is active */
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
253 gtk_widget_destroy( GTK_WIDGET(si_evbox) );
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
254 gtk_widget_destroy( GTK_WIDGET(si_rmenu) );
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
255 gtk_widget_destroy( GTK_WIDGET(si_applet) );
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
256 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
257 return;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
258 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
259
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
260
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
261 void
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
262 si_ui_about_show ( void )
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
263 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
264 GtkWidget *about_dlg = gtk_message_dialog_new(
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
265 NULL , 0 , GTK_MESSAGE_INFO , GTK_BUTTONS_CLOSE ,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
266 _( "Status Icon Plugin " SI_VERSION_PLUGIN "\n"
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
267 "written by Giacomo Lozito < james@develia.org >\n\n"
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
268 "This plugin provides a status icon, placed in\n"
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
269 "the system tray area of the window manager.\n" ) );
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
270 gtk_dialog_run( GTK_DIALOG(about_dlg) );
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
271 gtk_widget_destroy( about_dlg );
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
272 return;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
273 }