annotate src/statusicon/si_ui.c @ 542:d58404ba9af9 trunk

[svn] - made popup window use audacious_fileinfopopup_show_from_title if track_name and song length is not available
author giacomo
date Tue, 23 Jan 2007 16:44:29 -0800
parents d124034ebea3
children ca6dca840074
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>
452
829f029fbd03 [svn] - status icon plugin: display main menu on right click
giacomo
parents: 448
diff changeset
29 #include <audacious/util.h>
527
d124034ebea3 [svn] - glib/gi18n.h -> audacious/i18n.h for automatic dgettext support
nenolod
parents: 456
diff changeset
30 #include <audacious/i18n.h>
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
31 #include <glib.h>
439
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
32 #include <gdk/gdk.h>
542
d58404ba9af9 [svn] - made popup window use audacious_fileinfopopup_show_from_title if track_name and song length is not available
giacomo
parents: 527
diff changeset
33 #include <gdk/gdkx.h>
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
34 #include <gtk/gtk.h>
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
35
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 static GtkWidget * si_evbox = NULL;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
38
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
39
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
40 static GtkTrayIcon *
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
41 si_ui_statusicon_create ( void )
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 GtkTrayIcon *si_applet = NULL;
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 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
46
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
47 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
48
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
49 return si_applet;
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
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
52
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
53 static gboolean
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
54 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
55 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
56 switch ( event->button )
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
57 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
58 case 1:
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
59 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
60 si_audacious_toggle_visibility();
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
61 break;
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 case 3:
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
65 {
452
829f029fbd03 [svn] - status icon plugin: display main menu on right click
giacomo
parents: 448
diff changeset
66 audacious_menu_main_show( event->x_root , event->y_root , 3 , event->time );
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
67 break;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
68 }
439
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
69 }
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
70
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
71 return FALSE;
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
72 }
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
73
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
74
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
75 static gboolean
453
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
76 si_ui_statusicon_cb_btscroll ( GtkWidget * evbox , GdkEventScroll * event )
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
77 {
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
78 switch ( event->direction )
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
79 {
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
80 case GDK_SCROLL_UP:
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
81 si_audacious_volume_change( 5 );
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
82 break;
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
83 case GDK_SCROLL_DOWN:
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
84 si_audacious_volume_change( -5 );
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
85 break;
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
86 }
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
87
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
88 return FALSE;
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
89 }
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
90
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
91
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
92 static gboolean
439
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
93 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
94 {
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
95 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
96 {
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
97 TitleInput *tuple;
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
98 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
99 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
100 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
101
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
102 tuple = playlist_get_tuple( pl_active , pos );
542
d58404ba9af9 [svn] - made popup window use audacious_fileinfopopup_show_from_title if track_name and song length is not available
giacomo
parents: 527
diff changeset
103 if (( tuple == NULL ) || (( tuple->track_name == NULL ) && ( tuple->length < 1 )))
d58404ba9af9 [svn] - made popup window use audacious_fileinfopopup_show_from_title if track_name and song length is not available
giacomo
parents: 527
diff changeset
104 {
d58404ba9af9 [svn] - made popup window use audacious_fileinfopopup_show_from_title if track_name and song length is not available
giacomo
parents: 527
diff changeset
105 gchar *title = playlist_get_songtitle( pl_active , pos );
d58404ba9af9 [svn] - made popup window use audacious_fileinfopopup_show_from_title if track_name and song length is not available
giacomo
parents: 527
diff changeset
106 audacious_fileinfopopup_show_from_title( popup , title );
d58404ba9af9 [svn] - made popup window use audacious_fileinfopopup_show_from_title if track_name and song length is not available
giacomo
parents: 527
diff changeset
107 g_free( title );
d58404ba9af9 [svn] - made popup window use audacious_fileinfopopup_show_from_title if track_name and song length is not available
giacomo
parents: 527
diff changeset
108 }
d58404ba9af9 [svn] - made popup window use audacious_fileinfopopup_show_from_title if track_name and song length is not available
giacomo
parents: 527
diff changeset
109 else
d58404ba9af9 [svn] - made popup window use audacious_fileinfopopup_show_from_title if track_name and song length is not available
giacomo
parents: 527
diff changeset
110 {
d58404ba9af9 [svn] - made popup window use audacious_fileinfopopup_show_from_title if track_name and song length is not available
giacomo
parents: 527
diff changeset
111 audacious_fileinfopopup_show_from_tuple( popup , tuple );
d58404ba9af9 [svn] - made popup window use audacious_fileinfopopup_show_from_title if track_name and song length is not available
giacomo
parents: 527
diff changeset
112 }
439
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
113
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
114 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
115 }
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
116
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
117 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
118 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
119 return FALSE;
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
120 }
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 static void
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
124 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
125 {
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
126 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
127 {
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
128 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
129 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
130 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
131 }
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_start ( 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 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
139 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
140 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
141 return;
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
142 }
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
143
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 static void
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
146 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
147 {
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
148 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
149 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
150
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
151 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
152 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
153 return;
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
154 }
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
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
157 static gboolean
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
158 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
159 {
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
160 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
161 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
162 return FALSE;
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
163
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
164 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
165 {
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
166 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
167 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
168 return FALSE;
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
169 }
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 switch (event->type)
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
172 {
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
173 case GDK_EXPOSE:
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
174 /* do nothing */
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_ENTER_NOTIFY:
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
178 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
179 break;
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
180
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
181 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
182 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
183 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
184 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
185 break;
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
186
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
187 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
188 break; /* ignore */
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
189
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
190 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
191 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
192 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
193 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
194 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
195 case GDK_SCROLL:
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
196 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
197 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
198 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
199 break;
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
200
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
201 default:
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
202 break;
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
203 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
204
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
205 return FALSE;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
206 }
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
440
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
209 static void
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
210 si_ui_statusicon_image_update ( GtkWidget * image )
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
211 {
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
212 GdkPixbuf *si_pixbuf, *si_scaled_pixbuf;
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
213 gint size = GPOINTER_TO_INT(g_object_get_data( G_OBJECT(image) , "size" ));
455
f001b217c88b [svn] - status icon plugin: added a workaround to handle situations where KWin doesn't give a correct size for tray icons
giacomo
parents: 454
diff changeset
214 static gchar *wmname = NULL;
f001b217c88b [svn] - status icon plugin: added a workaround to handle situations where KWin doesn't give a correct size for tray icons
giacomo
parents: 454
diff changeset
215
f001b217c88b [svn] - status icon plugin: added a workaround to handle situations where KWin doesn't give a correct size for tray icons
giacomo
parents: 454
diff changeset
216 /* sometimes, KDE won't give the correct size-allocation; workaround this */
f001b217c88b [svn] - status icon plugin: added a workaround to handle situations where KWin doesn't give a correct size for tray icons
giacomo
parents: 454
diff changeset
217 if ( wmname == NULL )
f001b217c88b [svn] - status icon plugin: added a workaround to handle situations where KWin doesn't give a correct size for tray icons
giacomo
parents: 454
diff changeset
218 {
f001b217c88b [svn] - status icon plugin: added a workaround to handle situations where KWin doesn't give a correct size for tray icons
giacomo
parents: 454
diff changeset
219 GdkScreen *screen = gdk_screen_get_default();
f001b217c88b [svn] - status icon plugin: added a workaround to handle situations where KWin doesn't give a correct size for tray icons
giacomo
parents: 454
diff changeset
220 if ( screen != NULL )
f001b217c88b [svn] - status icon plugin: added a workaround to handle situations where KWin doesn't give a correct size for tray icons
giacomo
parents: 454
diff changeset
221 wmname = (gchar*)gdk_x11_screen_get_window_manager_name( screen );
f001b217c88b [svn] - status icon plugin: added a workaround to handle situations where KWin doesn't give a correct size for tray icons
giacomo
parents: 454
diff changeset
222 }
456
2e0b55117302 [svn] - status icon plugin: better logic for KWin workaround
giacomo
parents: 455
diff changeset
223 if ( ( size > 22 ) && ( wmname != NULL ) && ( !strcmp("KWin",wmname) ) )
455
f001b217c88b [svn] - status icon plugin: added a workaround to handle situations where KWin doesn't give a correct size for tray icons
giacomo
parents: 454
diff changeset
224 size = 22;
440
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
225
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
226 si_pixbuf = gdk_pixbuf_new_from_xpm_data( (const char**)si_xpm );
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
227 si_scaled_pixbuf = gdk_pixbuf_scale_simple( si_pixbuf , size , size , GDK_INTERP_BILINEAR );
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
228 gtk_image_set_from_pixbuf( GTK_IMAGE(image) , si_scaled_pixbuf );
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
229 g_object_unref( si_pixbuf );
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
230 g_object_unref( si_scaled_pixbuf );
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
231
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
232 return;
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
233 }
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
234
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
235
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
236 static void
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
237 si_ui_statusicon_cb_image_sizalloc ( GtkWidget * image , GtkAllocation * allocation , gpointer si_applet )
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
238 {
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
239 GtkOrientation orientation;
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
240 static gint prev_size = 0;
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
241 gint size = 0;
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
242
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
243 orientation = _gtk_tray_icon_get_orientation( GTK_TRAY_ICON(si_applet) );
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
244 if ( orientation == GTK_ORIENTATION_HORIZONTAL )
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
245 size = allocation->height;
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
246 else
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
247 size = allocation->width;
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
248
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
249 if ( prev_size != size )
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
250 {
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
251 prev_size = size;
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
252 g_object_set_data( G_OBJECT(image) , "size" , GINT_TO_POINTER(size) );
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
253 si_ui_statusicon_image_update( image );
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
254 }
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
255
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
256 return;
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
257 }
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
258
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
259
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
260 void
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
261 si_ui_statusicon_show ( void )
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
262 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
263 GtkWidget *si_image;
439
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
264 GtkWidget *si_popup;
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
265 GtkTrayIcon *si_applet;
448
da802c766018 [svn] status icon plugin: ensure that the size-allocate signal is called for the tray icon widget
giacomo
parents: 440
diff changeset
266 GtkRequisition req;
da802c766018 [svn] status icon plugin: ensure that the size-allocate signal is called for the tray icon widget
giacomo
parents: 440
diff changeset
267 GtkAllocation allocation;
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
268
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
269 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
270 if ( si_applet == NULL )
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
271 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
272 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
273 return;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
274 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
275
440
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
276 si_image = gtk_image_new();
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
277 g_object_set_data( G_OBJECT(si_image) , "size" , GINT_TO_POINTER(0) );
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
278
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
279 g_signal_connect( si_image , "size-allocate" ,
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
280 G_CALLBACK(si_ui_statusicon_cb_image_sizalloc) , si_applet );
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
281
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
282 si_evbox = gtk_event_box_new();
439
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
283 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
284
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
285 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
286
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
287 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
288 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
289
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
290 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
291 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
292
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
293 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
294 G_CALLBACK(si_ui_statusicon_cb_btpress) , NULL );
453
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
295 g_signal_connect( G_OBJECT(si_evbox) , "scroll-event" ,
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
296 G_CALLBACK(si_ui_statusicon_cb_btscroll) , NULL );
439
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
297 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
298 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
299
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
300 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
301 gtk_container_add( GTK_CONTAINER(si_applet), si_evbox );
453
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
302
448
da802c766018 [svn] status icon plugin: ensure that the size-allocate signal is called for the tray icon widget
giacomo
parents: 440
diff changeset
303 gtk_widget_show_all( GTK_WIDGET(si_applet) );
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
304
448
da802c766018 [svn] status icon plugin: ensure that the size-allocate signal is called for the tray icon widget
giacomo
parents: 440
diff changeset
305 gtk_widget_size_request( GTK_WIDGET(si_applet) , &req );
da802c766018 [svn] status icon plugin: ensure that the size-allocate signal is called for the tray icon widget
giacomo
parents: 440
diff changeset
306 allocation.x = 0;
da802c766018 [svn] status icon plugin: ensure that the size-allocate signal is called for the tray icon widget
giacomo
parents: 440
diff changeset
307 allocation.y = 0;
da802c766018 [svn] status icon plugin: ensure that the size-allocate signal is called for the tray icon widget
giacomo
parents: 440
diff changeset
308 allocation.width = req.width;
da802c766018 [svn] status icon plugin: ensure that the size-allocate signal is called for the tray icon widget
giacomo
parents: 440
diff changeset
309 allocation.height = req.height;
da802c766018 [svn] status icon plugin: ensure that the size-allocate signal is called for the tray icon widget
giacomo
parents: 440
diff changeset
310 gtk_widget_size_allocate( GTK_WIDGET(si_applet) , &allocation );
454
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
311
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
312 return;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
313 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
314
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
315
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
316 void
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
317 si_ui_statusicon_hide ( void )
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
318 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
319 if ( si_evbox != NULL )
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
320 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
321 GtkTrayIcon *si_applet = g_object_get_data( G_OBJECT(si_evbox) , "applet" );
439
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
322 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
323 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
324 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
325 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
326 return;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
327 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
328
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
329
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
330 void
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
331 si_ui_about_show ( void )
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
332 {
454
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
333 static GtkWidget *about_dlg = NULL;
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
334 gchar *about_title;
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
335 gchar *about_text;
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
336
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
337 if ( about_dlg != NULL )
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
338 {
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
339 gtk_window_present( GTK_WINDOW(about_dlg) );
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
340 return;
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
341 }
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
342
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
343 about_title = g_strdup( _("About Status Icon Plugin") );
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
344 about_text = g_strjoin( "" , "Status Icon Plugin " , SI_VERSION_PLUGIN ,
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
345 _("\nwritten by Giacomo Lozito < james@develia.org >\n\n"
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
346 "This plugin provides a status icon, placed in\n"
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
347 "the system tray area of the window manager.\n") , NULL );
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
348
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
349 about_dlg = xmms_show_message( about_title , about_text , _("Ok") , FALSE , NULL , NULL );
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
350 g_signal_connect( G_OBJECT(about_dlg) , "destroy" ,
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
351 G_CALLBACK(gtk_widget_destroyed), &about_dlg );
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
352 g_free( about_text );
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
353 g_free( about_title );
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
354
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
355 gtk_widget_show_all( about_dlg );
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
356 return;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
357 }