mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-10-05 21:02:42 +02:00
app, libgimpbase, pdb: rework layer dialog.
This commit changes the following: - It's now possible to set whether to store an absolute or relative path when editing link layer properties. - New layer dialog doesn't propose an "Image link" fill type anymore. Link layers won't be created this way (see in a future commit).
This commit is contained in:
@@ -181,9 +181,6 @@ static gint layers_mode_index (GimpLayerMode layer_mode
|
||||
const GimpLayerMode *modes,
|
||||
gint n_modes);
|
||||
|
||||
static void layers_link_dialog_response (GtkDialog *dialog,
|
||||
gint response_id,
|
||||
GimpImage *image);
|
||||
|
||||
/* private variables */
|
||||
|
||||
@@ -489,22 +486,6 @@ layers_new_last_vals_cmd_callback (GimpAction *action,
|
||||
return;
|
||||
}
|
||||
|
||||
if (config->layer_new_fill_type == GIMP_FILL_LINK)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gimp_open_dialog_new (image->gimp);
|
||||
gtk_window_set_title (GTK_WINDOW (dialog), _("Select Linked Image"));
|
||||
gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), FALSE);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (layers_link_dialog_response),
|
||||
image);
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
layer_mode = config->layer_new_mode;
|
||||
|
||||
if (layer_mode == GIMP_LAYER_MODE_NORMAL ||
|
||||
@@ -2398,6 +2379,8 @@ layers_new_callback (GtkWidget *dialog,
|
||||
gint n_layers = g_list_length (layers);
|
||||
gboolean run_once = (n_layers == 0);
|
||||
|
||||
g_return_if_fail (link == NULL);
|
||||
|
||||
g_object_set (config,
|
||||
"layer-new-name", layer_name,
|
||||
"layer-new-mode", layer_mode,
|
||||
@@ -2439,32 +2422,17 @@ layers_new_callback (GtkWidget *dialog,
|
||||
position = 0;
|
||||
}
|
||||
|
||||
if (layer_fill_type == GIMP_FILL_LINK)
|
||||
{
|
||||
if (link)
|
||||
{
|
||||
gimp_link_set_size (link, layer_width, layer_height);
|
||||
layer = gimp_link_layer_new (image, link);
|
||||
|
||||
if (layer_mode != gimp_layer_get_mode (layer))
|
||||
gimp_layer_set_mode (layer, layer_mode, TRUE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
layer = gimp_layer_new (image, layer_width, layer_height,
|
||||
gimp_image_get_layer_format (image, TRUE),
|
||||
config->layer_new_name,
|
||||
config->layer_new_opacity,
|
||||
config->layer_new_mode);
|
||||
}
|
||||
layer = gimp_layer_new (image, layer_width, layer_height,
|
||||
gimp_image_get_layer_format (image, TRUE),
|
||||
config->layer_new_name,
|
||||
config->layer_new_opacity,
|
||||
config->layer_new_mode);
|
||||
|
||||
if (layer)
|
||||
{
|
||||
gimp_item_set_offset (GIMP_ITEM (layer), layer_offset_x, layer_offset_y);
|
||||
if (layer_fill_type != GIMP_FILL_LINK)
|
||||
gimp_drawable_fill (GIMP_DRAWABLE (layer), context,
|
||||
config->layer_new_fill_type);
|
||||
gimp_drawable_fill (GIMP_DRAWABLE (layer), context,
|
||||
config->layer_new_fill_type);
|
||||
gimp_item_set_visible (GIMP_ITEM (layer), layer_visible, FALSE);
|
||||
gimp_item_set_color_tag (GIMP_ITEM (layer), layer_color_tag, FALSE);
|
||||
gimp_item_set_lock_content (GIMP_ITEM (layer), layer_lock_pixels,
|
||||
@@ -2483,16 +2451,6 @@ layers_new_callback (GtkWidget *dialog,
|
||||
|
||||
new_layers = g_list_prepend (new_layers, layer);
|
||||
}
|
||||
else if (layer_fill_type == GIMP_FILL_LINK)
|
||||
{
|
||||
/* We special-case the link layers because chances of failure are
|
||||
* higher and especially source of failure may be user choices.
|
||||
* For such case, we don't want to generate WARNINGS (which are
|
||||
* for code bugs), but an error dialog instead.
|
||||
*/
|
||||
gimp_message_literal (image->gimp, NULL, GIMP_MESSAGE_WARNING,
|
||||
_("Invalid image file"));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("%s: could not allocate new layer", G_STRFUNC);
|
||||
@@ -2844,45 +2802,3 @@ layers_mode_index (GimpLayerMode layer_mode,
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static void
|
||||
layers_link_dialog_response (GtkDialog *dialog,
|
||||
gint response_id,
|
||||
GimpImage *image)
|
||||
{
|
||||
if (response_id == GTK_RESPONSE_OK)
|
||||
{
|
||||
GFile *file;
|
||||
|
||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
if (file)
|
||||
{
|
||||
GimpLayer *layer;
|
||||
GimpLink *link;
|
||||
|
||||
link = gimp_link_new (image->gimp, file);
|
||||
layer = gimp_link_layer_new (image, link);
|
||||
|
||||
if (layer)
|
||||
{
|
||||
GimpDialogConfig *config;
|
||||
|
||||
config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
||||
gimp_layer_set_blend_space (layer,
|
||||
config->layer_new_blend_space, FALSE);
|
||||
gimp_layer_set_composite_space (layer,
|
||||
config->layer_new_composite_space, FALSE);
|
||||
gimp_layer_set_composite_mode (layer,
|
||||
config->layer_new_composite_mode, FALSE);
|
||||
|
||||
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_LAYER_ADD,
|
||||
_("Add Link Layer"));
|
||||
gimp_image_add_layer (image, layer, GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
|
||||
gimp_image_undo_group_end (image);
|
||||
gimp_image_flush (image);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||
}
|
||||
|
@@ -425,7 +425,6 @@ gimp_link_set_file (GimpLink *link,
|
||||
GFile *file)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_LINK (link));
|
||||
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (link)));
|
||||
g_return_if_fail (G_IS_FILE (file) || file == NULL);
|
||||
|
||||
if (file && g_file_equal (file, link->p->file))
|
||||
@@ -471,9 +470,14 @@ gimp_link_is_broken (GimpLink *link,
|
||||
GimpLink *
|
||||
gimp_link_duplicate (GimpLink *link)
|
||||
{
|
||||
GimpLink *new_link;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_LINK (link), NULL);
|
||||
|
||||
return gimp_link_new (link->p->gimp, link->p->file);
|
||||
new_link = gimp_link_new (link->p->gimp, link->p->file);
|
||||
gimp_link_set_absolute_path (new_link, gimp_link_get_absolute_path (link));
|
||||
|
||||
return new_link;
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -99,12 +99,10 @@ static void layer_options_dialog_mode_notify (GtkWidget *widget,
|
||||
static void layer_options_dialog_rename_toggled (GtkWidget *widget,
|
||||
LayerOptionsDialog *private);
|
||||
|
||||
|
||||
static void layer_options_fill_changed (GtkWidget *combo,
|
||||
GtkWidget *file_select);
|
||||
static void layer_options_file_set (GtkFileChooserButton *widget,
|
||||
LayerOptionsDialog *private);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
GtkWidget *
|
||||
@@ -169,6 +167,8 @@ layer_options_dialog_new (GimpImage *image,
|
||||
private->callback = callback;
|
||||
private->user_data = user_data;
|
||||
|
||||
private->link = NULL;
|
||||
|
||||
if (layer && gimp_item_is_text_layer (GIMP_ITEM (layer)))
|
||||
private->rename_text_layers = GIMP_TEXT_LAYER (layer)->auto_rename;
|
||||
|
||||
@@ -385,39 +385,6 @@ layer_options_dialog_new (GimpImage *image,
|
||||
|
||||
row += 2;
|
||||
|
||||
if (! layer)
|
||||
{
|
||||
GtkWidget *right_vbox = item_options_dialog_get_right_vbox (dialog);
|
||||
GtkWidget *open_dialog;
|
||||
|
||||
/* The fill type */
|
||||
combo = gimp_enum_combo_box_new (GIMP_TYPE_FILL_TYPE);
|
||||
gimp_grid_attach_aligned (GTK_GRID (grid), 0, row,
|
||||
_("_Fill with:"), 0.0, 0.5,
|
||||
combo, 1);
|
||||
|
||||
/* File chooser dialog. */
|
||||
open_dialog = gimp_open_dialog_new (private->gimp);
|
||||
gtk_window_set_title (GTK_WINDOW (open_dialog),
|
||||
_("Select Linked Image"));
|
||||
|
||||
/* File chooser button. */
|
||||
file_select = gtk_file_chooser_button_new_with_dialog (open_dialog);
|
||||
gtk_box_pack_end (GTK_BOX (right_vbox), file_select, FALSE, FALSE, 1);
|
||||
|
||||
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
|
||||
private->fill_type,
|
||||
G_CALLBACK (gimp_int_combo_box_get_active),
|
||||
&private->fill_type, NULL);
|
||||
g_signal_connect (combo, "changed",
|
||||
G_CALLBACK (layer_options_fill_changed),
|
||||
file_select);
|
||||
g_signal_connect (file_select, "file-set",
|
||||
G_CALLBACK (layer_options_file_set),
|
||||
private);
|
||||
layer_options_fill_changed (combo, file_select);
|
||||
}
|
||||
|
||||
if (layer)
|
||||
{
|
||||
GtkWidget *left_vbox = item_options_dialog_get_vbox (dialog);
|
||||
@@ -460,8 +427,33 @@ layer_options_dialog_new (GimpImage *image,
|
||||
g_signal_connect (file_select, "file-set",
|
||||
G_CALLBACK (layer_options_file_set),
|
||||
private);
|
||||
|
||||
private->link = gimp_link_duplicate (link);
|
||||
|
||||
/* Absolute path checkbox. */
|
||||
button = gtk_check_button_new_with_mnemonic (_("S_tore with absolute path"));
|
||||
gimp_grid_attach_aligned (GTK_GRID (grid), 0, row++,
|
||||
NULL, 0.0, 0.5,
|
||||
button, 2);
|
||||
g_object_bind_property (G_OBJECT (private->link), "absolute-path",
|
||||
G_OBJECT (button), "active",
|
||||
G_BINDING_SYNC_CREATE |
|
||||
G_BINDING_BIDIRECTIONAL);
|
||||
gtk_widget_set_visible (button, TRUE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The fill type */
|
||||
combo = gimp_enum_combo_box_new (GIMP_TYPE_FILL_TYPE);
|
||||
gimp_grid_attach_aligned (GTK_GRID (grid), 0, row,
|
||||
_("_Fill with:"), 0.0, 0.5,
|
||||
combo, 1);
|
||||
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
|
||||
private->fill_type,
|
||||
G_CALLBACK (gimp_int_combo_box_get_active),
|
||||
&private->fill_type, NULL);
|
||||
}
|
||||
|
||||
button = item_options_dialog_get_lock_position (dialog);
|
||||
|
||||
@@ -635,33 +627,19 @@ layer_options_dialog_rename_toggled (GtkWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
layer_options_fill_changed (GtkWidget *combo,
|
||||
GtkWidget *file_select)
|
||||
{
|
||||
gint value = GIMP_FILL_FOREGROUND;
|
||||
|
||||
g_return_if_fail (GIMP_IS_ENUM_COMBO_BOX (combo));
|
||||
g_return_if_fail (GTK_IS_WIDGET (file_select));
|
||||
|
||||
gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (combo), &value);
|
||||
gtk_widget_set_visible (file_select, (value == GIMP_FILL_LINK));
|
||||
}
|
||||
|
||||
static void
|
||||
layer_options_file_set (GtkFileChooserButton *widget,
|
||||
LayerOptionsDialog *private)
|
||||
{
|
||||
GimpLink *link = NULL;
|
||||
GFile *file;
|
||||
GFile *file;
|
||||
|
||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (widget));
|
||||
if (file)
|
||||
{
|
||||
link = gimp_link_new (private->gimp, file);
|
||||
if (gimp_link_is_broken (link, TRUE))
|
||||
gimp_link_set_file (private->link, file);
|
||||
if (gimp_link_is_broken (private->link, TRUE))
|
||||
{
|
||||
g_clear_object (&link);
|
||||
gimp_link_set_file (private->link, NULL);
|
||||
g_signal_handlers_block_by_func (widget,
|
||||
G_CALLBACK (layer_options_file_set),
|
||||
private);
|
||||
@@ -672,6 +650,4 @@ layer_options_file_set (GtkFileChooserButton *widget,
|
||||
}
|
||||
}
|
||||
g_clear_object (&file);
|
||||
|
||||
private->link = link;
|
||||
}
|
||||
|
@@ -511,7 +511,6 @@ gimp_fill_type_get_type (void)
|
||||
{ GIMP_FILL_WHITE, "GIMP_FILL_WHITE", "white" },
|
||||
{ GIMP_FILL_TRANSPARENT, "GIMP_FILL_TRANSPARENT", "transparent" },
|
||||
{ GIMP_FILL_PATTERN, "GIMP_FILL_PATTERN", "pattern" },
|
||||
{ GIMP_FILL_LINK, "GIMP_FILL_LINK", "link" },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
@@ -523,7 +522,6 @@ gimp_fill_type_get_type (void)
|
||||
{ GIMP_FILL_WHITE, NC_("fill-type", "White"), NULL },
|
||||
{ GIMP_FILL_TRANSPARENT, NC_("fill-type", "Transparency"), NULL },
|
||||
{ GIMP_FILL_PATTERN, NC_("fill-type", "Pattern"), NULL },
|
||||
{ GIMP_FILL_LINK, NC_("fill-type", "Image link"), NULL },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
|
@@ -368,7 +368,6 @@ typedef enum
|
||||
* @GIMP_FILL_WHITE: White
|
||||
* @GIMP_FILL_TRANSPARENT: Transparency
|
||||
* @GIMP_FILL_PATTERN: Pattern
|
||||
* @GIMP_FILL_LINK: Image link
|
||||
*
|
||||
* Types of filling.
|
||||
**/
|
||||
@@ -384,7 +383,6 @@ typedef enum
|
||||
GIMP_FILL_WHITE, /*< desc="White" >*/
|
||||
GIMP_FILL_TRANSPARENT, /*< desc="Transparency" >*/
|
||||
GIMP_FILL_PATTERN, /*< desc="Pattern" >*/
|
||||
GIMP_FILL_LINK /*< desc="Image link" >*/
|
||||
} GimpFillType;
|
||||
|
||||
|
||||
|
@@ -168,15 +168,13 @@ package Gimp::CodeGen::enums;
|
||||
header => 'libgimpbase/gimpbaseenums.h',
|
||||
symbols => [ qw(GIMP_FILL_FOREGROUND GIMP_FILL_BACKGROUND
|
||||
GIMP_FILL_CIELAB_MIDDLE_GRAY GIMP_FILL_WHITE
|
||||
GIMP_FILL_TRANSPARENT GIMP_FILL_PATTERN
|
||||
GIMP_FILL_LINK) ],
|
||||
GIMP_FILL_TRANSPARENT GIMP_FILL_PATTERN) ],
|
||||
mapping => { GIMP_FILL_FOREGROUND => '0',
|
||||
GIMP_FILL_BACKGROUND => '1',
|
||||
GIMP_FILL_CIELAB_MIDDLE_GRAY => '2',
|
||||
GIMP_FILL_WHITE => '3',
|
||||
GIMP_FILL_TRANSPARENT => '4',
|
||||
GIMP_FILL_PATTERN => '5',
|
||||
GIMP_FILL_LINK => '6' }
|
||||
GIMP_FILL_PATTERN => '5' }
|
||||
},
|
||||
GimpForegroundExtractMode =>
|
||||
{ contig => 1,
|
||||
|
Reference in New Issue
Block a user