static void gimp_image_prop_view_update (GimpImagePropView *view) { GimpImage *image = view->image; GimpImageBaseType type; GimpPrecision precision; GimpUnit unit; gdouble unit_factor; gint unit_digits; const gchar *desc; gchar format_buf[32]; gchar buf[256]; gdouble xres; gdouble yres; gimp_image_get_resolution (image, &xres, &yres); /* pixel size */ g_snprintf (buf, sizeof (buf), ngettext ("%d × %d pixel", "%d × %d pixels", gimp_image_get_height (image)), gimp_image_get_width (image), gimp_image_get_height (image)); gtk_label_set_text (GTK_LABEL (view->pixel_size_label), buf); /* print size */ unit = gimp_get_default_unit (); unit_digits = gimp_unit_get_digits (unit); g_snprintf (format_buf, sizeof (format_buf), "%%.%df × %%.%df %s", unit_digits + 1, unit_digits + 1, gimp_unit_get_plural (unit)); g_snprintf (buf, sizeof (buf), format_buf, gimp_pixels_to_units (gimp_image_get_width (image), unit, xres), gimp_pixels_to_units (gimp_image_get_height (image), unit, yres)); gtk_label_set_text (GTK_LABEL (view->print_size_label), buf); /* resolution */ unit = gimp_image_get_unit (image); unit_factor = gimp_unit_get_factor (unit); g_snprintf (format_buf, sizeof (format_buf), _("pixels/%s"), gimp_unit_get_abbreviation (unit)); g_snprintf (buf, sizeof (buf), _("%g × %g %s"), xres / unit_factor, yres / unit_factor, unit == GIMP_UNIT_INCH ? _("ppi") : format_buf); gtk_label_set_text (GTK_LABEL (view->resolution_label), buf); /* color type */ type = gimp_image_get_base_type (image); gimp_enum_get_value (GIMP_TYPE_IMAGE_BASE_TYPE, type, NULL, NULL, &desc, NULL); switch (type) { case GIMP_RGB: case GIMP_GRAY: g_snprintf (buf, sizeof (buf), "%s", desc); break; case GIMP_INDEXED: g_snprintf (buf, sizeof (buf), "%s (%d %s)", desc, gimp_image_get_colormap_size (image), _("colors")); break; } gtk_label_set_text (GTK_LABEL (view->colorspace_label), buf); /* precision */ precision = gimp_image_get_precision (image); gimp_enum_get_value (GIMP_TYPE_PRECISION, precision, NULL, NULL, &desc, NULL); gtk_label_set_text (GTK_LABEL (view->precision_label), desc); /* size in memory */ gimp_image_prop_view_label_set_memsize (view->memsize_label, GIMP_OBJECT (image)); /* undo / redo */ gimp_image_prop_view_label_set_undo (view->undo_label, gimp_image_get_undo_stack (image)); gimp_image_prop_view_label_set_undo (view->redo_label, gimp_image_get_redo_stack (image)); /* number of layers */ g_snprintf (buf, sizeof (buf), "%d", gimp_image_get_width (image) * gimp_image_get_height (image)); gtk_label_set_text (GTK_LABEL (view->pixels_label), buf); /* number of layers */ g_snprintf (buf, sizeof (buf), "%d", gimp_image_get_n_layers (image)); gtk_label_set_text (GTK_LABEL (view->layers_label), buf); /* number of channels */ g_snprintf (buf, sizeof (buf), "%d", gimp_image_get_n_channels (image)); gtk_label_set_text (GTK_LABEL (view->channels_label), buf); /* number of vectors */ g_snprintf (buf, sizeof (buf), "%d", gimp_image_get_n_vectors (image)); gtk_label_set_text (GTK_LABEL (view->vectors_label), buf); }
void vectors_actions_update (GimpActionGroup *group, gpointer data) { GimpImage *image = action_data_get_image (data); GimpVectors *vectors = NULL; GimpDrawable *drawable = NULL; gint n_vectors = 0; gboolean mask_empty = TRUE; gboolean visible = FALSE; gboolean linked = FALSE; gboolean locked = FALSE; gboolean can_lock = FALSE; gboolean locked_pos = FALSE; gboolean can_lock_pos = FALSE; gboolean dr_writable = FALSE; gboolean dr_children = FALSE; GList *next = NULL; GList *prev = NULL; if (image) { n_vectors = gimp_image_get_n_vectors (image); mask_empty = gimp_channel_is_empty (gimp_image_get_mask (image)); vectors = gimp_image_get_active_vectors (image); if (vectors) { GimpItem *item = GIMP_ITEM (vectors); GList *vectors_list; GList *list; visible = gimp_item_get_visible (item); linked = gimp_item_get_linked (item); locked = gimp_item_get_lock_content (item); can_lock = gimp_item_can_lock_content (item); locked_pos = gimp_item_get_lock_position (item); can_lock_pos = gimp_item_can_lock_position (item); vectors_list = gimp_item_get_container_iter (item); list = g_list_find (vectors_list, vectors); if (list) { prev = g_list_previous (list); next = g_list_next (list); } } drawable = gimp_image_get_active_drawable (image); if (drawable) { GimpItem *item = GIMP_ITEM (drawable); dr_writable = ! gimp_item_is_content_locked (item); if (gimp_viewable_get_children (GIMP_VIEWABLE (item))) dr_children = TRUE; } } #define SET_SENSITIVE(action,condition) \ gimp_action_group_set_action_sensitive (group, action, (condition) != 0) #define SET_ACTIVE(action,condition) \ gimp_action_group_set_action_active (group, action, (condition) != 0) SET_SENSITIVE ("vectors-path-tool", vectors); SET_SENSITIVE ("vectors-edit-attributes", vectors); SET_SENSITIVE ("vectors-new", image); SET_SENSITIVE ("vectors-new-last-values", image); SET_SENSITIVE ("vectors-duplicate", vectors); SET_SENSITIVE ("vectors-delete", vectors); SET_SENSITIVE ("vectors-merge-visible", n_vectors > 1); SET_SENSITIVE ("vectors-raise", vectors && prev); SET_SENSITIVE ("vectors-raise-to-top", vectors && prev); SET_SENSITIVE ("vectors-lower", vectors && next); SET_SENSITIVE ("vectors-lower-to-bottom", vectors && next); SET_SENSITIVE ("vectors-copy", vectors); SET_SENSITIVE ("vectors-paste", image); SET_SENSITIVE ("vectors-export", vectors); SET_SENSITIVE ("vectors-import", image); SET_SENSITIVE ("vectors-visible", vectors); SET_SENSITIVE ("vectors-linked", vectors); SET_SENSITIVE ("vectors-lock-content", can_lock); SET_SENSITIVE ("vectors-lock-position", can_lock_pos); SET_ACTIVE ("vectors-visible", visible); SET_ACTIVE ("vectors-linked", linked); SET_ACTIVE ("vectors-lock-content", locked); SET_ACTIVE ("vectors-lock-position", locked_pos); SET_SENSITIVE ("vectors-selection-to-vectors", image && !mask_empty); SET_SENSITIVE ("vectors-selection-to-vectors-short", image && !mask_empty); SET_SENSITIVE ("vectors-selection-to-vectors-advanced", image && !mask_empty); SET_SENSITIVE ("vectors-fill", vectors && dr_writable && !dr_children); SET_SENSITIVE ("vectors-fill-last-values", vectors && dr_writable && !dr_children); SET_SENSITIVE ("vectors-stroke", vectors && dr_writable && !dr_children); SET_SENSITIVE ("vectors-stroke-last-values", vectors && dr_writable && !dr_children); SET_SENSITIVE ("vectors-selection-replace", vectors); SET_SENSITIVE ("vectors-selection-from-vectors", vectors); SET_SENSITIVE ("vectors-selection-add", vectors); SET_SENSITIVE ("vectors-selection-subtract", vectors); SET_SENSITIVE ("vectors-selection-intersect", vectors); #undef SET_SENSITIVE #undef SET_ACTIVE }