annotate src/statusicon/si_ui.c @ 455:f001b217c88b trunk

[svn] - status icon plugin: added a workaround to handle situations where KWin doesn't give a correct size for tray icons
author giacomo
date Wed, 17 Jan 2007 08:46:53 -0800
parents 6c1c03111db4
children 2e0b55117302
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>
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
30 #include <glib.h>
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
31 #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
32 #include <gdk/gdk.h>
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
33 #include <gtk/gtk.h>
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
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
36 static GtkWidget * si_evbox = NULL;
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
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
39 static GtkTrayIcon *
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
40 si_ui_statusicon_create ( void )
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
41 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
42 GtkTrayIcon *si_applet = NULL;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
43
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
44 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
45
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
46 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
47
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
48 return si_applet;
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
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
52 static gboolean
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
53 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
54 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
55 switch ( event->button )
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 case 1:
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 si_audacious_toggle_visibility();
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
60 break;
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 case 3:
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
64 {
452
829f029fbd03 [svn] - status icon plugin: display main menu on right click
giacomo
parents: 448
diff changeset
65 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
66 break;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
67 }
439
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
68 }
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 return FALSE;
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
71 }
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 static gboolean
453
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
75 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
76 {
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
77 switch ( event->direction )
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
78 {
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
79 case GDK_SCROLL_UP:
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
80 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
81 break;
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
82 case GDK_SCROLL_DOWN:
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
83 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
84 break;
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
85 }
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 return FALSE;
60395c0d7587 [svn] - status icon plugin: use scroll wheel on the status icon to change volume
giacomo
parents: 452
diff changeset
88 }
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 static gboolean
439
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
440
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
199 static void
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
200 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
201 {
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
202 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
203 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
204 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
205
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
206 /* 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
207 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
208 {
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
209 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
210 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
211 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
212 }
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
213 else if ( ( size > 22 ) && ( !strcmp("KWin",wmname) ) )
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 size = 22;
440
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
215
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
216 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
217 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
218 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
219 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
220 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
221
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
222 return;
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
223 }
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
224
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 static void
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
227 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
228 {
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
229 GtkOrientation orientation;
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
230 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
231 gint size = 0;
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
232
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
233 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
234 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
235 size = allocation->height;
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
236 else
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
237 size = allocation->width;
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 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
240 {
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
241 prev_size = size;
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
242 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
243 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
244 }
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
245
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
246 return;
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
247 }
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
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
250 void
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
251 si_ui_statusicon_show ( void )
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
252 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
253 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
254 GtkWidget *si_popup;
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
255 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
256 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
257 GtkAllocation allocation;
433
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 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
260 if ( si_applet == NULL )
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
261 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
262 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
263 return;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
264 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
265
440
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
266 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
267 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
268
84fdf898438b [svn] - status icon plugin: try to auto-detect the correct size for the status icon
giacomo
parents: 439
diff changeset
269 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
270 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
271
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
272 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
273 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
274
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
275 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
276
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
277 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
278 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
279
84029a5250c1 [svn] - status icon plugin: made a tooltip popup that displays metadata of the current song
giacomo
parents: 433
diff changeset
280 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
281 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
282
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
283 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
284 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
285 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
286 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
287 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
288 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
289
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
290 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
291 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
292
448
da802c766018 [svn] status icon plugin: ensure that the size-allocate signal is called for the tray icon widget
giacomo
parents: 440
diff changeset
293 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
294
448
da802c766018 [svn] status icon plugin: ensure that the size-allocate signal is called for the tray icon widget
giacomo
parents: 440
diff changeset
295 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
296 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
297 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
298 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
299 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
300 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
301
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
302 return;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
303 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
304
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
305
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
306 void
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
307 si_ui_statusicon_hide ( void )
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
308 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
309 if ( si_evbox != NULL )
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
310 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
311 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
312 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
313 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
314 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
315 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
316 return;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
317 }
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
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
320 void
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
321 si_ui_about_show ( void )
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
322 {
454
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
323 static GtkWidget *about_dlg = NULL;
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
324 gchar *about_title;
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
325 gchar *about_text;
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
326
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
327 if ( about_dlg != NULL )
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
328 {
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
329 gtk_window_present( GTK_WINDOW(about_dlg) );
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
330 return;
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
331 }
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
332
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
333 about_title = g_strdup( _("About Status Icon Plugin") );
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
334 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
335 _("\nwritten by Giacomo Lozito < james@develia.org >\n\n"
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
336 "This plugin provides a status icon, placed in\n"
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
337 "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
338
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
339 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
340 g_signal_connect( G_OBJECT(about_dlg) , "destroy" ,
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
341 G_CALLBACK(gtk_widget_destroyed), &about_dlg );
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
342 g_free( about_text );
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
343 g_free( about_title );
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
344
6c1c03111db4 [svn] - use xmms_show_message for the about box
giacomo
parents: 453
diff changeset
345 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
346 return;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
347 }