예제 #1
0
static void
vectors_edit_attributes_callback (GtkWidget    *dialog,
                                  GimpImage    *image,
                                  GimpVectors  *vectors,
                                  GimpContext  *context,
                                  const gchar  *vectors_name,
                                  gboolean      vectors_visible,
                                  gboolean      vectors_linked,
                                  GimpColorTag  vectors_color_tag,
                                  gboolean      vectors_lock_content,
                                  gboolean      vectors_lock_position,
                                  gpointer      user_data)
{
  GimpItem *item = GIMP_ITEM (vectors);

  if (strcmp (vectors_name, gimp_object_get_name (vectors))      ||
      vectors_visible       != gimp_item_get_visible (item)      ||
      vectors_linked        != gimp_item_get_linked (item)       ||
      vectors_color_tag     != gimp_item_get_color_tag (item)    ||
      vectors_lock_content  != gimp_item_get_lock_content (item) ||
      vectors_lock_position != gimp_item_get_lock_position (item))
    {
      gimp_image_undo_group_start (image,
                                   GIMP_UNDO_GROUP_ITEM_PROPERTIES,
                                   _("Path Attributes"));

      if (strcmp (vectors_name, gimp_object_get_name (vectors)))
        gimp_item_rename (GIMP_ITEM (vectors), vectors_name, NULL);

      if (vectors_visible != gimp_item_get_visible (item))
        gimp_item_set_visible (item, vectors_visible, TRUE);

      if (vectors_linked != gimp_item_get_linked (item))
        gimp_item_set_linked (item, vectors_linked, TRUE);

      if (vectors_color_tag != gimp_item_get_color_tag (item))
        gimp_item_set_color_tag (item, vectors_color_tag, TRUE);

      if (vectors_lock_content != gimp_item_get_lock_content (item))
        gimp_item_set_lock_content (item, vectors_lock_content, TRUE);

      if (vectors_lock_position != gimp_item_get_lock_position (item))
        gimp_item_set_lock_position (item, vectors_lock_position, TRUE);

      gimp_image_undo_group_end (image);

      gimp_image_flush (image);
    }

  gtk_widget_destroy (dialog);
}
예제 #2
0
void
drawable_lock_content_cmd_callback (GtkAction *action,
                                    gpointer   data)
{
  GimpImage    *image;
  GimpDrawable *drawable;
  gboolean      locked;
  return_if_no_drawable (image, drawable, data);

  locked = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));

  if (GIMP_IS_LAYER_MASK (drawable))
    drawable =
      GIMP_DRAWABLE (gimp_layer_mask_get_layer (GIMP_LAYER_MASK (drawable)));

  if (locked != gimp_item_get_lock_content (GIMP_ITEM (drawable)))
    {
#if 0
      GimpUndo *undo;
#endif
      gboolean  push_undo = TRUE;

#if 0
      undo = gimp_image_undo_can_compress (image, GIMP_TYPE_ITEM_UNDO,
                                           GIMP_UNDO_ITEM_VISIBILITY);

      if (undo && GIMP_ITEM_UNDO (undo)->item == GIMP_ITEM (drawable))
        push_undo = FALSE;
#endif

      gimp_item_set_lock_content (GIMP_ITEM (drawable), locked, push_undo);
      gimp_image_flush (image);
    }
}
예제 #3
0
static void
gimp_item_prop_undo_constructed (GObject *object)
{
  GimpItemPropUndo *item_prop_undo = GIMP_ITEM_PROP_UNDO (object);
  GimpItem         *item;

  G_OBJECT_CLASS (parent_class)->constructed (object);

  item = GIMP_ITEM_UNDO (object)->item;

  switch (GIMP_UNDO (object)->undo_type)
    {
    case GIMP_UNDO_ITEM_REORDER:
      item_prop_undo->parent   = gimp_item_get_parent (item);
      item_prop_undo->position = gimp_item_get_index (item);
      break;

    case GIMP_UNDO_ITEM_RENAME:
      item_prop_undo->name = g_strdup (gimp_object_get_name (item));
      break;

    case GIMP_UNDO_ITEM_DISPLACE:
      gimp_item_get_offset (item,
                            &item_prop_undo->offset_x,
                            &item_prop_undo->offset_y);
      break;

    case GIMP_UNDO_ITEM_VISIBILITY:
      item_prop_undo->visible = gimp_item_get_visible (item);
      break;

    case GIMP_UNDO_ITEM_LINKED:
      item_prop_undo->linked = gimp_item_get_linked (item);
      break;

    case GIMP_UNDO_ITEM_COLOR_TAG:
      item_prop_undo->color_tag = gimp_item_get_color_tag (item);
      break;

    case GIMP_UNDO_ITEM_LOCK_CONTENT:
      item_prop_undo->lock_content = gimp_item_get_lock_content (item);
      break;

    case GIMP_UNDO_ITEM_LOCK_POSITION:
      item_prop_undo->lock_position = gimp_item_get_lock_position (item);
      break;

    case GIMP_UNDO_PARASITE_ATTACH:
    case GIMP_UNDO_PARASITE_REMOVE:
      g_assert (item_prop_undo->parasite_name != NULL);

      item_prop_undo->parasite = gimp_parasite_copy
        (gimp_item_parasite_find (item, item_prop_undo->parasite_name));
      break;

    default:
      g_assert_not_reached ();
    }
}
예제 #4
0
void
channels_edit_attributes_cmd_callback (GtkAction *action,
                                       gpointer   data)
{
  GimpImage   *image;
  GimpChannel *channel;
  GtkWidget   *widget;
  GtkWidget   *dialog;
  return_if_no_channel (image, channel, data);
  return_if_no_widget (widget, data);

#define EDIT_DIALOG_KEY "gimp-channel-edit-attributes-dialog"

  dialog = dialogs_get_dialog (G_OBJECT (channel), EDIT_DIALOG_KEY);

  if (! dialog)
    {
      GimpItem *item = GIMP_ITEM (channel);

      dialog = channel_options_dialog_new (image, channel,
                                           action_data_get_context (data),
                                           widget,
                                           _("Channel Attributes"),
                                           "gimp-channel-edit",
                                           "gtk-edit",
                                           _("Edit Channel Attributes"),
                                           GIMP_HELP_CHANNEL_EDIT,
                                           _("Edit Channel Color"),
                                           _("_Fill opacity:"),
                                           FALSE,
                                           gimp_object_get_name (channel),
                                           &channel->color,
                                           gimp_item_get_visible (item),
                                           gimp_item_get_linked (item),
                                           gimp_item_get_color_tag (item),
                                           gimp_item_get_lock_content (item),
                                           gimp_item_get_lock_position (item),
                                           channels_edit_attributes_callback,
                                           NULL);

      dialogs_attach_dialog (G_OBJECT (channel), EDIT_DIALOG_KEY, dialog);
    }

  gtk_window_present (GTK_WINDOW (dialog));
}
예제 #5
0
void
vectors_edit_attributes_cmd_callback (GtkAction *action,
                                      gpointer   data)
{
  GimpImage   *image;
  GimpVectors *vectors;
  GtkWidget   *widget;
  GtkWidget   *dialog;
  return_if_no_vectors (image, vectors, data);
  return_if_no_widget (widget, data);

#define EDIT_DIALOG_KEY "gimp-vectors-edit-attributes-dialog"

  dialog = dialogs_get_dialog (G_OBJECT (vectors), EDIT_DIALOG_KEY);

  if (! dialog)
    {
      GimpItem *item = GIMP_ITEM (vectors);

      dialog = vectors_options_dialog_new (image, vectors,
                                           action_data_get_context (data),
                                           widget,
                                           _("Path Attributes"),
                                           "gimp-vectors-edit",
                                           GIMP_ICON_EDIT,
                                           _("Edit Path Attributes"),
                                           GIMP_HELP_PATH_EDIT,
                                           gimp_object_get_name (vectors),
                                           gimp_item_get_visible (item),
                                           gimp_item_get_linked (item),
                                           gimp_item_get_color_tag (item),
                                           gimp_item_get_lock_content (item),
                                           gimp_item_get_lock_position (item),
                                           vectors_edit_attributes_callback,
                                           NULL);

      dialogs_attach_dialog (G_OBJECT (vectors), EDIT_DIALOG_KEY, dialog);
    }

  gtk_window_present (GTK_WINDOW (dialog));
}
예제 #6
0
static void
gimp_item_prop_undo_pop (GimpUndo            *undo,
                         GimpUndoMode         undo_mode,
                         GimpUndoAccumulator *accum)
{
  GimpItemPropUndo *item_prop_undo = GIMP_ITEM_PROP_UNDO (undo);
  GimpItem         *item           = GIMP_ITEM_UNDO (undo)->item;

  GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);

  switch (undo->undo_type)
    {
    case GIMP_UNDO_ITEM_REORDER:
      {
        GimpItem *parent;
        gint      position;

        parent   = gimp_item_get_parent (item);
        position = gimp_item_get_index (item);

        gimp_item_tree_reorder_item (gimp_item_get_tree (item), item,
                                     item_prop_undo->parent,
                                     item_prop_undo->position,
                                     FALSE, NULL);

        item_prop_undo->parent   = parent;
        item_prop_undo->position = position;
      }
      break;

    case GIMP_UNDO_ITEM_RENAME:
      {
        gchar *name;

        name = g_strdup (gimp_object_get_name (item));

        gimp_item_tree_rename_item (gimp_item_get_tree (item), item,
                                    item_prop_undo->name,
                                    FALSE, NULL);

        g_free (item_prop_undo->name);
        item_prop_undo->name = name;
      }
      break;

    case GIMP_UNDO_ITEM_DISPLACE:
      {
        gint offset_x;
        gint offset_y;

        gimp_item_get_offset (item, &offset_x, &offset_y);

        gimp_item_translate (item,
                             item_prop_undo->offset_x - offset_x,
                             item_prop_undo->offset_y - offset_y,
                             FALSE);

        item_prop_undo->offset_x = offset_x;
        item_prop_undo->offset_y = offset_y;
      }
      break;

    case GIMP_UNDO_ITEM_VISIBILITY:
      {
        gboolean visible;

        visible = gimp_item_get_visible (item);
        gimp_item_set_visible (item, item_prop_undo->visible, FALSE);
        item_prop_undo->visible = visible;
      }
      break;

    case GIMP_UNDO_ITEM_LINKED:
      {
        gboolean linked;

        linked = gimp_item_get_linked (item);
        gimp_item_set_linked (item, item_prop_undo->linked, FALSE);
        item_prop_undo->linked = linked;
      }
      break;

    case GIMP_UNDO_ITEM_COLOR_TAG:
      {
        GimpColorTag color_tag;

        color_tag = gimp_item_get_color_tag (item);
        gimp_item_set_color_tag (item, item_prop_undo->color_tag, FALSE);
        item_prop_undo->color_tag = color_tag;
      }
      break;

    case GIMP_UNDO_ITEM_LOCK_CONTENT:
      {
        gboolean lock_content;

        lock_content = gimp_item_get_lock_content (item);
        gimp_item_set_lock_content (item, item_prop_undo->lock_content, FALSE);
        item_prop_undo->lock_content = lock_content;
      }
      break;

    case GIMP_UNDO_ITEM_LOCK_POSITION:
      {
        gboolean lock_position;

        lock_position = gimp_item_get_lock_position (item);
        gimp_item_set_lock_position (item, item_prop_undo->lock_position, FALSE);
        item_prop_undo->lock_position = lock_position;
      }
      break;

    case GIMP_UNDO_PARASITE_ATTACH:
    case GIMP_UNDO_PARASITE_REMOVE:
      {
        GimpParasite *parasite;

        parasite = item_prop_undo->parasite;

        item_prop_undo->parasite = gimp_parasite_copy
          (gimp_item_parasite_find (item, item_prop_undo->parasite_name));

        if (parasite)
          gimp_item_parasite_attach (item, parasite, FALSE);
        else
          gimp_item_parasite_detach (item, item_prop_undo->parasite_name, FALSE);

        if (parasite)
          gimp_parasite_free (parasite);
      }
      break;

    default:
      g_assert_not_reached ();
    }
}
예제 #7
0
void
items_actions_update (GimpActionGroup *group,
                      const gchar     *prefix,
                      GimpItem        *item)
{
  GEnumClass *enum_class;
  GEnumValue *value;
  gchar       action[32];
  gboolean    visible       = FALSE;
  gboolean    linked        = FALSE;
  gboolean    has_color_tag = FALSE;
  gboolean    locked        = FALSE;
  gboolean    can_lock      = FALSE;
  gboolean    locked_pos    = FALSE;
  gboolean    can_lock_pos  = FALSE;
  GimpRGB     tag_color;

  if (item)
    {
      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);

      has_color_tag = gimp_get_color_tag_color (gimp_item_get_color_tag (item),
                                                &tag_color, FALSE);
    }

#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)
#define SET_COLOR(action,color) \
        gimp_action_group_set_action_color (group, action, color, FALSE)

  g_snprintf (action, sizeof (action), "%s-visible", prefix);
  SET_SENSITIVE (action, item);
  SET_ACTIVE    (action, visible);

  g_snprintf (action, sizeof (action), "%s-linked", prefix);
  SET_SENSITIVE (action, item);
  SET_ACTIVE    (action, linked);

  g_snprintf (action, sizeof (action), "%s-lock-content", prefix);
  SET_SENSITIVE (action, can_lock);
  SET_ACTIVE    (action, locked);

  g_snprintf (action, sizeof (action), "%s-lock-position", prefix);
  SET_SENSITIVE (action, can_lock_pos);
  SET_ACTIVE    (action, locked_pos);

  g_snprintf (action, sizeof (action), "%s-color-tag-menu", prefix);
  SET_COLOR (action, has_color_tag ? &tag_color : NULL);

  enum_class = g_type_class_ref (GIMP_TYPE_COLOR_TAG);

  for (value = enum_class->values; value->value_name; value++)
    {
      g_snprintf (action, sizeof (action),
                  "%s-color-tag-%s", prefix, value->value_nick);

      SET_SENSITIVE (action, item);
    }

  g_type_class_unref (enum_class);

#undef SET_SENSITIVE
#undef SET_ACTIVE
#undef SET_COLOR
}
예제 #8
0
void
drawable_actions_update (GimpActionGroup *group,
                         gpointer         data)
{
  GimpImage    *image;
  GimpDrawable *drawable   = NULL;
  gboolean      is_rgb     = FALSE;
  gboolean      is_gray    = FALSE;
  gboolean      is_indexed = FALSE;
  gboolean      visible    = FALSE;
  gboolean      linked     = FALSE;
  gboolean      locked     = FALSE;
  gboolean      can_lock   = FALSE;
  gboolean      writable   = FALSE;
  gboolean      children   = FALSE;

  image = action_data_get_image (data);

  if (image)
    {
      drawable = gimp_image_get_active_drawable (image);

      if (drawable)
        {
          GimpImageType  drawable_type = gimp_drawable_type (drawable);
          GimpItem      *item;

          is_rgb     = GIMP_IMAGE_TYPE_IS_RGB     (drawable_type);
          is_gray    = GIMP_IMAGE_TYPE_IS_GRAY    (drawable_type);
          is_indexed = GIMP_IMAGE_TYPE_IS_INDEXED (drawable_type);

          if (GIMP_IS_LAYER_MASK (drawable))
            item = GIMP_ITEM (gimp_layer_mask_get_layer (GIMP_LAYER_MASK (drawable)));
          else
            item = GIMP_ITEM (drawable);

          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);
          writable = ! gimp_item_is_content_locked (item);

          if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)))
            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 ("drawable-equalize",       writable && !children && !is_indexed);
  SET_SENSITIVE ("drawable-invert",         writable && !children && !is_indexed);
  SET_SENSITIVE ("drawable-levels-stretch", writable && !children &&  is_rgb);
  SET_SENSITIVE ("drawable-offset",         writable && !children);

  SET_SENSITIVE ("drawable-visible",      drawable);
  SET_SENSITIVE ("drawable-linked",       drawable);
  SET_SENSITIVE ("drawable-lock-content", can_lock);

  SET_ACTIVE ("drawable-visible",      visible);
  SET_ACTIVE ("drawable-linked",       linked);
  SET_ACTIVE ("drawable-lock-content", locked);

  SET_SENSITIVE ("drawable-flip-horizontal", writable);
  SET_SENSITIVE ("drawable-flip-vertical",   writable);

  SET_SENSITIVE ("drawable-rotate-90",  writable);
  SET_SENSITIVE ("drawable-rotate-180", writable);
  SET_SENSITIVE ("drawable-rotate-270", writable);

#undef SET_SENSITIVE
#undef SET_ACTIVE
}
예제 #9
0
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
}