static gboolean loadable_icon_key_equal (const LoadableIconKey *a, const LoadableIconKey *b) { return a->size == b->size && g_icon_equal (a->icon, b->icon); }
void st_icon_set_icon_name (StIcon *icon, const gchar *icon_name) { StIconPrivate *priv = icon->priv; GIcon *gicon = NULL; g_return_if_fail (ST_IS_ICON (icon)); if (icon_name) gicon = g_themed_icon_new_with_default_fallbacks (icon_name); if (g_icon_equal (priv->gicon, gicon)) /* do nothing */ { g_object_unref (gicon); return; } if (priv->gicon) g_object_unref (priv->gicon); g_object_freeze_notify (G_OBJECT (icon)); priv->gicon = gicon; g_object_notify (G_OBJECT (icon), "gicon"); g_object_notify (G_OBJECT (icon), "icon-name"); g_object_thaw_notify (G_OBJECT (icon)); st_icon_update (icon); }
static void trash_applet_monitor_changed (TrashApplet *applet) { GError *error = NULL; GFileInfo *info; GIcon *icon; gint items; info = g_file_query_info (applet->trash, G_FILE_ATTRIBUTE_STANDARD_ICON"," G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT, 0, NULL, &error); if (!info) { g_critical ("could not query trash:/: '%s'", error->message); g_error_free (error); return; } icon = g_file_info_get_icon (info); items = g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT); if (!g_icon_equal (icon, applet->icon)) { /* note: the size is meaningless here, * since we do set_pixel_size() later */ gtk_image_set_from_gicon (GTK_IMAGE (applet->image), icon, GTK_ICON_SIZE_MENU); if (applet->icon) g_object_unref (applet->icon); applet->icon = g_object_ref (icon); } if (items != applet->items) { if (items) { char *text; text = g_strdup_printf (ngettext ("%d Item in Trash", "%d Items in Trash", items), items); gtk_widget_set_tooltip_text (GTK_WIDGET (applet), text); g_free (text); } else gtk_widget_set_tooltip_text (GTK_WIDGET (applet), _("No Items in Trash")); applet->items = items; } g_object_unref (info); }
static void nemo_bookmark_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { NemoBookmark *self = NEMO_BOOKMARK (object); GIcon *new_icon; switch (property_id) { case PROP_ICON: new_icon = g_value_get_object (value); if (new_icon != NULL && !g_icon_equal (self->details->icon, new_icon)) { g_clear_object (&self->details->icon); self->details->icon = g_object_ref (new_icon); } break; case PROP_LOCATION: self->details->location = g_value_dup_object (value); break; case PROP_CUSTOM_NAME: self->details->has_custom_name = g_value_get_boolean (value); break; case PROP_NAME: nemo_bookmark_set_name_internal (self, g_value_get_string (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
static void panel_run_dialog_set_icon (PanelRunDialog *dialog, GIcon *icon, gboolean force) { GdkPixbuf *pixbuf = NULL; if (!force && g_icon_equal(icon, dialog->icon)) return; g_clear_object(&(dialog->icon)); if (icon) { int size; gtk_icon_size_lookup (GTK_ICON_SIZE_DIALOG, &size, NULL); GtkIconTheme *icon_theme = gtk_icon_theme_get_default (); GtkIconInfo *icon_info = gtk_icon_theme_lookup_by_gicon (icon_theme, icon, size, 0); pixbuf = gtk_icon_info_load_icon (icon_info, NULL); #if GTK_CHECK_VERSION (3, 8, 0) g_object_unref (icon_info); #else gtk_icon_info_free (icon_info); #endif } if (pixbuf) { dialog->icon = g_object_ref (icon); /* Don't bother scaling the image if it's too small. * Scaled looks worse than a smaller image. */ gtk_image_set_from_pixbuf (GTK_IMAGE (dialog->pixmap), pixbuf); //FIXME: it'd be better to set an icon of the correct size, //(ditto for the drag icon?) gtk_window_set_icon (GTK_WINDOW (dialog->run_dialog), pixbuf); #if GTK_CHECK_VERSION (3, 2, 0) gtk_drag_source_set_icon_gicon (dialog->run_dialog, dialog->icon); #else gtk_drag_source_set_icon_pixbuf (dialog->run_dialog, pixbuf); #endif g_object_unref (pixbuf); } else { panel_run_dialog_set_default_icon (dialog, TRUE); } }
static gboolean real_set_background_icon (GtkNumerableIcon *self, GIcon *icon) { if (!g_icon_equal (self->priv->background_icon, icon)) { g_clear_object (&self->priv->background_icon); if (icon != NULL) self->priv->background_icon = g_object_ref (icon); gtk_numerable_icon_ensure_emblem (self); return TRUE; } return FALSE; }
/** * st_icon_set_gicon: * @icon: an icon * @gicon: (allow-none): a #GIcon to override :icon-name */ void st_icon_set_gicon (StIcon *icon, GIcon *gicon) { g_return_if_fail (ST_IS_ICON (icon)); g_return_if_fail (gicon == NULL || G_IS_ICON (gicon)); if (g_icon_equal (icon->priv->gicon, gicon)) /* do nothing */ return; if (icon->priv->gicon) { g_object_unref (icon->priv->gicon); icon->priv->gicon = NULL; } if (gicon) icon->priv->gicon = g_object_ref (gicon); g_object_notify (G_OBJECT (icon), "gicon"); st_icon_update (icon); }
static VALUE icon_equal(VALUE self, VALUE other) { return CBOOL2RVAL(g_icon_equal(_SELF(self), _SELF(other))); }