statusicons: Improve code readability and remove dead code

This commit is contained in:
Victor Kareh 2019-11-12 09:13:24 -05:00
parent 1c09104dc6
commit 4fc32b2751

View File

@ -1398,7 +1398,9 @@ gtk_status_icon_update_image (GtkStatusIcon *status_icon)
GtkIconHelper *icon_helper;
cairo_surface_t *surface;
GtkWidget *widget;
GdkPixbuf *pixbuf = NULL;
#ifndef GDK_WINDOWING_X11
GdkPixbuf *pixbuf;
#endif
gint round_size;
gint scale;
@ -1421,28 +1423,32 @@ gtk_status_icon_update_image (GtkStatusIcon *status_icon)
_gtk_icon_helper_set_icon_size (icon_helper, GTK_ICON_SIZE_SMALL_TOOLBAR);
_gtk_icon_helper_set_pixel_size (icon_helper, round_size);
surface = gtk_icon_helper_load_surface (icon_helper, scale);
g_object_unref (icon_helper);
#ifdef GDK_WINDOWING_X11
if (surface)
{
#ifdef GDK_WINDOWING_X11
gtk_image_set_from_surface (GTK_IMAGE (priv->image), surface);
#else
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0,
cairo_image_surface_get_width (surface),
cairo_image_surface_get_height (surface));
#endif
cairo_surface_destroy (surface);
}
else
{
#ifdef GDK_WINDOWING_X11
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), NULL);
#endif
}
g_object_unref (icon_helper);
#endif
#ifdef GDK_WINDOWING_WIN32
if (surface)
{
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0,
cairo_image_surface_get_width (surface),
cairo_image_surface_get_height (surface));
cairo_surface_destroy (surface);
}
if (pixbuf != NULL)
{
#ifdef GDK_WINDOWING_WIN32
prev_hicon = priv->nid.hIcon;
priv->nid.hIcon = gdk_win32_pixbuf_to_hicon_libgtk_only (pixbuf);
priv->nid.uFlags |= NIF_ICON;
@ -1451,27 +1457,40 @@ gtk_status_icon_update_image (GtkStatusIcon *status_icon)
g_warning (G_STRLOC ": Shell_NotifyIcon(NIM_MODIFY) failed");
if (prev_hicon)
DestroyIcon (prev_hicon);
#endif
#ifdef GDK_WINDOWING_QUARTZ
QUARTZ_POOL_ALLOC;
[priv->status_item setImage:pixbuf];
QUARTZ_POOL_RELEASE;
#endif
}
else
{
#ifdef GDK_WINDOWING_WIN32
priv->nid.uFlags &= ~NIF_ICON;
if (priv->nid.hWnd != NULL && priv->visible)
if (!Shell_NotifyIconW (NIM_MODIFY, &priv->nid))
g_warning (G_STRLOC ": Shell_NotifyIcon(NIM_MODIFY) failed");
#endif
#ifdef GDK_WINDOWING_QUARTZ
[priv->status_item setImage:NULL];
#endif
}
g_clear_object (&pixbuf);
#endif
#ifdef GDK_WINDOWING_QUARTZ
if (surface)
{
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0,
cairo_image_surface_get_width (surface),
cairo_image_surface_get_height (surface));
cairo_surface_destroy (surface);
}
if (pixbuf != NULL)
{
QUARTZ_POOL_ALLOC;
[priv->status_item setImage:pixbuf];
QUARTZ_POOL_RELEASE;
}
else
{
[priv->status_item setImage:NULL];
}
g_clear_object (&pixbuf);
#endif
}
#ifdef GDK_WINDOWING_X11