104
110
gtk_widget_show_all(tray_menu);
107
static gboolean tray_destroyed_cb(GtkWidget *widget, GdkEvent *event, gpointer data)
109
create_tray_icon(GTK_WIDGET(data));
113
static gboolean tray_clicked_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
113
static void tray_activate_cb(GtkStatusIcon* icon, gpointer data)
116
switch (event->button)
119
if (event->type != GDK_BUTTON_PRESS)
121
active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(showwindow_menuitem));
122
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(showwindow_menuitem), !active);
125
if (event->type != GDK_BUTTON_PRESS)
127
gtk_menu_popup(GTK_MENU(tray_menu), NULL, NULL, NULL, NULL, event->button, event->time);
116
active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(showwindow_menuitem));
117
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(showwindow_menuitem), !active);
120
static void tray_popup_menu (GtkStatusIcon* icon, guint button, guint32 time, gpointer data)
122
gtk_menu_popup(GTK_MENU(tray_menu), NULL, NULL, NULL, icon, button, time);
133
125
void create_tray_icon(GtkWidget *app)
135
127
GdkPixbuf *pixbuf;
136
GtkWidget *tray_icon_image;
137
128
GtkWidget *eventbox;
138
129
GtkIconTheme *icontheme;
141
tray_icon = GTK_WIDGET(egg_tray_icon_new (PACKAGE));
142
132
icontheme = gtk_icon_theme_get_default();
143
133
pixbuf = gtk_icon_theme_load_icon(icontheme, "gnomeradio", 22, 0, NULL);
144
134
g_return_if_fail(pixbuf);
145
tray_icon_image = gtk_image_new_from_pixbuf(pixbuf);
135
tray_icon = G_OBJECT(gtk_status_icon_new_from_pixbuf(pixbuf));
146
136
gdk_pixbuf_unref(pixbuf);
148
eventbox = gtk_event_box_new();
149
gtk_container_add(GTK_CONTAINER(eventbox), tray_icon_image);
150
gtk_container_add (GTK_CONTAINER(tray_icon), eventbox);
152
g_signal_connect(G_OBJECT(eventbox), "button-press-event",
153
G_CALLBACK(tray_clicked_cb), (gpointer)app);
154
g_signal_connect(G_OBJECT(tray_icon), "destroy-event",
155
G_CALLBACK(tray_destroyed_cb), (gpointer)app);
156
gtk_widget_show_all(GTK_WIDGET(tray_icon));
139
g_signal_connect(G_OBJECT(tray_icon), "activate",
140
G_CALLBACK(tray_activate_cb), (gpointer)app);
141
g_signal_connect(G_OBJECT(tray_icon), "popup-menu",
142
G_CALLBACK(tray_popup_menu), (gpointer)app);
158
144
text = g_strdup_printf(_("Gnomeradio - %.2f MHz"), adj->value/STEPS);
159
gtk_tooltips_set_tip(tooltips, tray_icon, text, NULL);
145
gtk_status_icon_set_tooltip(GTK_STATUS_ICON(tray_icon), text);