+
+wxTaskBarIcon::Private::Private(wxTaskBarIcon* taskBarIcon)
+{
+ m_taskBarIcon = taskBarIcon;
+ m_statusIcon = NULL;
+ m_eggTrayIcon = NULL;
+ m_win = NULL;
+ m_tooltips = NULL;
+ m_size = 0;
+}
+
+wxTaskBarIcon::Private::~Private()
+{
+ if (m_statusIcon)
+ g_object_unref(m_statusIcon);
+ else if (m_eggTrayIcon)
+ {
+ g_signal_handlers_disconnect_by_func(m_eggTrayIcon, (void*)icon_destroy, this);
+ gtk_widget_destroy(m_eggTrayIcon);
+ }
+ if (m_win)
+ {
+ m_win->PopEventHandler();
+ m_win->Destroy();
+ }
+ if (m_tooltips)
+ {
+ gtk_object_destroy(GTK_OBJECT(m_tooltips));
+ g_object_unref(m_tooltips);
+ }
+}
+
+void wxTaskBarIcon::Private::SetIcon()
+{
+#if GTK_CHECK_VERSION(2,10,0)
+ if (gtk_check_version(2,10,0) == NULL)
+ {
+ if (m_statusIcon)
+ gtk_status_icon_set_from_pixbuf(m_statusIcon, m_bitmap.GetPixbuf());
+ else
+ {
+ m_statusIcon = gtk_status_icon_new_from_pixbuf(m_bitmap.GetPixbuf());
+ g_signal_connect(m_statusIcon, "activate",
+ G_CALLBACK(icon_activate), m_taskBarIcon);
+ g_signal_connect(m_statusIcon, "popup_menu",
+ G_CALLBACK(status_icon_popup_menu), m_taskBarIcon);
+ }
+ }
+ else
+#endif
+ {
+ m_size = 0;
+ if (m_eggTrayIcon)
+ {
+ GtkWidget* image = GTK_BIN(m_eggTrayIcon)->child;
+ gtk_image_set_from_pixbuf(GTK_IMAGE(image), m_bitmap.GetPixbuf());
+ }
+ else
+ {
+ m_eggTrayIcon = GTK_WIDGET(egg_tray_icon_new("wxTaskBarIcon"));
+ gtk_widget_add_events(m_eggTrayIcon, GDK_BUTTON_PRESS_MASK);
+ g_signal_connect(m_eggTrayIcon, "size_allocate",
+ G_CALLBACK(icon_size_allocate), this);
+ g_signal_connect(m_eggTrayIcon, "destroy",
+ G_CALLBACK(icon_destroy), this);
+ g_signal_connect(m_eggTrayIcon, "button_press_event",
+ G_CALLBACK(icon_button_press_event), m_taskBarIcon);
+ g_signal_connect(m_eggTrayIcon, "popup_menu",
+ G_CALLBACK(icon_popup_menu), m_taskBarIcon);
+ GtkWidget* image = gtk_image_new_from_pixbuf(m_bitmap.GetPixbuf());
+ gtk_container_add(GTK_CONTAINER(m_eggTrayIcon), image);
+ gtk_widget_show_all(m_eggTrayIcon);
+ }
+ }
+#if wxUSE_TOOLTIPS
+ const char *tip_text = NULL;
+ if (!m_tipText.empty())
+ tip_text = m_tipText.c_str();
+
+#if GTK_CHECK_VERSION(2,10,0)
+ if (m_statusIcon)
+ gtk_status_icon_set_tooltip(m_statusIcon, tip_text);
+ else
+#endif
+ {
+ if (tip_text && m_tooltips == NULL)
+ {
+ m_tooltips = gtk_tooltips_new();
+ g_object_ref(m_tooltips);
+ gtk_object_sink(GTK_OBJECT(m_tooltips));
+ }
+ if (m_tooltips)
+ gtk_tooltips_set_tip(m_tooltips, m_eggTrayIcon, tip_text, "");
+ }
+#endif // wxUSE_TOOLTIPS
+}
+
+void wxTaskBarIcon::Private::size_allocate(int width, int height)
+{
+ int size = height;
+ EggTrayIcon* icon = EGG_TRAY_ICON(m_eggTrayIcon);
+ if (egg_tray_icon_get_orientation(icon) == GTK_ORIENTATION_VERTICAL)
+ size = width;
+ if (m_size == size)
+ return;
+ m_size = size;
+ int w = m_bitmap.GetWidth();
+ int h = m_bitmap.GetHeight();
+ if (w > size || h > size)
+ {
+ if (w > size) w = size;
+ if (h > size) h = size;
+ GdkPixbuf* pixbuf =
+ gdk_pixbuf_scale_simple(m_bitmap.GetPixbuf(), w, h, GDK_INTERP_BILINEAR);
+ GtkImage* image = GTK_IMAGE(GTK_BIN(m_eggTrayIcon)->child);
+ gtk_image_set_from_pixbuf(image, pixbuf);
+ g_object_unref(pixbuf);
+ }
+}