GdkPixbuf *wibuti_watcher_get_icon(WibutiWatcher *self) { if (WNCK_IS_WINDOW(self->tracked)) { return wnck_window_get_icon(self->tracked); } else { return NULL; } }
static void on_icon_changed(WnckWindow *controlwindow, WindowckPlugin *wckp) { GdkPixbuf *pixbuf = NULL; GdkPixbuf *grayscale = NULL; if (!controlwindow) { xfce_panel_image_clear(XFCE_PANEL_IMAGE (wckp->icon->symbol)); } else if (wckp->prefs->show_on_desktop) { gtk_widget_set_sensitive (wckp->icon->symbol, TRUE); if (wnck_window_get_window_type (controlwindow) == WNCK_WINDOW_DESKTOP) { if (!wnck_window_is_active(controlwindow)) gtk_widget_set_sensitive (wckp->icon->symbol, FALSE); xfce_panel_image_set_from_source (XFCE_PANEL_IMAGE (wckp->icon->symbol),GTK_STOCK_HOME); } } if (controlwindow && wnck_window_get_window_type (controlwindow) != WNCK_WINDOW_DESKTOP) { /* This only returns a pointer - it SHOULDN'T be unrefed! */ if (XFCE_PANEL_IS_SMALL) pixbuf = wnck_window_get_mini_icon(controlwindow); else pixbuf = wnck_window_get_icon(controlwindow); /* leave when there is no valid pixbuf */ if (G_UNLIKELY (pixbuf == NULL)) { xfce_panel_image_clear (XFCE_PANEL_IMAGE (wckp->icon->symbol)); return; } if (!wnck_window_is_active(controlwindow)) { /* icon color is set to grayscale */ grayscale = gdk_pixbuf_copy(pixbuf); gdk_pixbuf_saturate_and_pixelate(grayscale, grayscale, 0, FALSE); if (G_UNLIKELY (grayscale != NULL)) pixbuf = grayscale; } xfce_panel_image_set_from_pixbuf(XFCE_PANEL_IMAGE (wckp->icon->symbol), pixbuf); } if (grayscale != NULL && grayscale != pixbuf) g_object_unref (G_OBJECT (grayscale)); }
static gboolean on_query_tooltip (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, TaskItem *item) { WnckWindow *window = item->priv->window; g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE); gtk_tooltip_set_text (tooltip, wnck_window_get_name(window)); gtk_tooltip_set_icon (tooltip, wnck_window_get_icon (window)); return TRUE; }
static GdkPixbuf * task_item_sized_pixbuf_for_window (TaskItem *item, WnckWindow *window, gint size) { GdkPixbuf *pbuf = NULL; g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL); if (wnck_window_has_icon_name (window)) { const gchar *icon_name = wnck_window_get_icon_name (window); GtkIconTheme *icon_theme = gtk_icon_theme_get_default (); if (gtk_icon_theme_has_icon (icon_theme, icon_name)) { GdkPixbuf *internal = gtk_icon_theme_load_icon (icon_theme, icon_name, size, GTK_ICON_LOOKUP_FORCE_SIZE, NULL); pbuf = gdk_pixbuf_copy (internal); g_object_unref (internal); } } if (!pbuf) { pbuf = gdk_pixbuf_copy (wnck_window_get_icon (item->priv->window)); } gint width = gdk_pixbuf_get_width (pbuf); gint height = gdk_pixbuf_get_height (pbuf); if (MAX (width, height) != size) { gdouble scale = (gdouble) size / (gdouble) MAX (width, height); GdkPixbuf *tmp = pbuf; pbuf = gdk_pixbuf_scale_simple (tmp, (gint) (width * scale), (gint) (height * scale), GDK_INTERP_HYPER); g_object_unref (tmp); } return pbuf; }
/** * wnck_application_get_icon: * @app: a #WnckApplication. * * Gets the icon to be used for @app. If no icon is set for @app, a * suboptimal heuristic is used to find an appropriate icon. If no icon was * found, a fallback icon is used. * * Return value: (transfer none): the icon for @app. The caller should * reference the returned <classname>GdkPixbuf</classname> if it needs to keep * the icon around. **/ GdkPixbuf* wnck_application_get_icon (WnckApplication *app) { g_return_val_if_fail (WNCK_IS_APPLICATION (app), NULL); _wnck_application_load_icons (app); if (app->priv->icon) return app->priv->icon; else { WnckWindow *w = find_icon_window (app); if (w) return wnck_window_get_icon (w); else return NULL; } }
// Updates the images according to preferences and the window situation // Warning! This function is called very often, so it should only do the most necessary things! void updateTitle(WTApplet *wtapplet) { WnckWindow *controlledwindow; gchar *title_text, *title_color, *title_font; GdkPixbuf *icon_pixbuf; if (wtapplet->prefs->only_maximized) { controlledwindow = wtapplet->umaxedwindow; } else { controlledwindow = wtapplet->activewindow; } if (controlledwindow == NULL) return; if (controlledwindow == wtapplet->rootwindow) { // we're on desktop if (wtapplet->prefs->hide_on_unmaximized) { // hide everything icon_pixbuf = NULL; title_text = ""; } else { // display "custom" icon/title (TODO: customization via preferences?) icon_pixbuf = gtk_widget_render_icon(GTK_WIDGET(wtapplet),GTK_STOCK_HOME,GTK_ICON_SIZE_MENU,NULL); // This has to be unrefed! title_text = ("Desktop"); } } else { icon_pixbuf = wnck_window_get_icon(controlledwindow); // This only returns a pointer - it SHOULDN'T be unrefed! title_text = (gchar*)wnck_window_get_name(controlledwindow); } // TODO: we need the default font to somehow be the same in both modes if (wtapplet->prefs->custom_style) { // custom style if (controlledwindow == wtapplet->activewindow) { // window focused title_color = wtapplet->prefs->title_active_color; title_font = wtapplet->prefs->title_active_font; } else { // window unfocused title_color = wtapplet->prefs->title_inactive_color; title_font = wtapplet->prefs->title_inactive_font; } } else { // automatic (non-custom) style if (controlledwindow == wtapplet->activewindow) { // window focused title_color = wtapplet->panel_color_fg; title_font = ""; } else { // window unfocused title_color = "#808080"; // inactive title color. best fits for any panel regardless of color title_font = ""; } } // Set tooltips if (wtapplet->prefs->show_tooltips) { gtk_widget_set_tooltip_text (GTK_WIDGET(wtapplet->icon), title_text); gtk_widget_set_tooltip_text (GTK_WIDGET(wtapplet->title), title_text); } title_text = g_markup_printf_escaped("<span font=\"%s\" color=\"%s\">%s</span>", title_font, title_color, title_text); // Apply markup to label widget gtk_label_set_markup(GTK_LABEL(wtapplet->title), title_text); g_free(title_text); if (icon_pixbuf == NULL) { gtk_image_clear(wtapplet->icon); } else { // We're updating window info (Careful! We've had pixbuf memory leaks here) GdkPixbuf *ipb1 = gdk_pixbuf_scale_simple(icon_pixbuf, ICON_WIDTH, ICON_HEIGHT, GDK_INTERP_BILINEAR); if (controlledwindow == wtapplet->rootwindow) g_object_unref(icon_pixbuf); //this is stupid beyond belief, thanks to the retarded GTK framework GdkPixbuf *ipb2 = gdk_pixbuf_rotate_simple(ipb1, wtapplet->angle); g_object_unref(ipb1); // Unref ipb1 to get it cleared from memory (we still need ipb2) // Saturate icon when window is not focused if (controlledwindow != wtapplet->activewindow) gdk_pixbuf_saturate_and_pixelate(ipb2, ipb2, 0, FALSE); // Apply pixbuf to icon widget gtk_image_set_from_pixbuf(wtapplet->icon, ipb2); g_object_unref(ipb2); // Unref ipb2 to get it cleared from memory } }