Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
GNOME
GIMP
Commits
72bcb72c
Commit
72bcb72c
authored
Jun 05, 2010
by
Michael Natterer
😴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
app: rename gimp_template_create_image() to gimp_image_new_from_template()
and move it from gimptemplate.c to gimpimage-new.c
parent
9dd373d8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
87 deletions
+81
-87
app/actions/templates-commands.c
app/actions/templates-commands.c
+1
-1
app/core/gimpimage-new.c
app/core/gimpimage-new.c
+72
-0
app/core/gimpimage-new.h
app/core/gimpimage-new.h
+3
-0
app/core/gimptemplate.c
app/core/gimptemplate.c
+0
-77
app/core/gimptemplate.h
app/core/gimptemplate.h
+4
-8
app/dialogs/image-new-dialog.c
app/dialogs/image-new-dialog.c
+1
-1
No files found.
app/actions/templates-commands.c
View file @
72bcb72c
...
...
@@ -91,7 +91,7 @@ templates_create_image_cmd_callback (GtkAction *action,
if
(
template
&&
gimp_container_have
(
container
,
GIMP_OBJECT
(
template
)))
{
gimp_
template_create_imag
e
(
gimp
,
template
,
context
);
gimp_
image_new_from_templat
e
(
gimp
,
template
,
context
);
gimp_image_new_set_last_template
(
gimp
,
template
);
}
}
...
...
app/core/gimpimage-new.c
View file @
72bcb72c
...
...
@@ -31,6 +31,7 @@
#include "gimp.h"
#include "gimpbuffer.h"
#include "gimpchannel.h"
#include "gimpcontext.h"
#include "gimpimage.h"
#include "gimpimage-colormap.h"
#include "gimpimage-new.h"
...
...
@@ -78,6 +79,77 @@ gimp_image_new_set_last_template (Gimp *gimp,
G_OBJECT
(
gimp
->
image_new_last_template
),
0
);
}
GimpImage
*
gimp_image_new_from_template
(
Gimp
*
gimp
,
GimpTemplate
*
template
,
GimpContext
*
context
)
{
GimpImage
*
image
;
GimpLayer
*
layer
;
GimpImageType
type
;
gint
width
,
height
;
g_return_val_if_fail
(
GIMP_IS_GIMP
(
gimp
),
NULL
);
g_return_val_if_fail
(
GIMP_IS_TEMPLATE
(
template
),
NULL
);
g_return_val_if_fail
(
GIMP_IS_CONTEXT
(
context
),
NULL
);
image
=
gimp_create_image
(
gimp
,
template
->
width
,
template
->
height
,
template
->
image_type
,
FALSE
);
gimp_image_undo_disable
(
image
);
if
(
template
->
comment
)
{
GimpParasite
*
parasite
;
parasite
=
gimp_parasite_new
(
"gimp-comment"
,
GIMP_PARASITE_PERSISTENT
,
strlen
(
template
->
comment
)
+
1
,
template
->
comment
);
gimp_image_parasite_attach
(
image
,
parasite
);
gimp_parasite_free
(
parasite
);
}
gimp_image_set_resolution
(
image
,
template
->
xresolution
,
template
->
yresolution
);
gimp_image_set_unit
(
image
,
template
->
resolution_unit
);
width
=
gimp_image_get_width
(
image
);
height
=
gimp_image_get_height
(
image
);
switch
(
template
->
fill_type
)
{
case
GIMP_TRANSPARENT_FILL
:
type
=
((
template
->
image_type
==
GIMP_RGB
)
?
GIMP_RGBA_IMAGE
:
GIMP_GRAYA_IMAGE
);
break
;
default:
type
=
((
template
->
image_type
==
GIMP_RGB
)
?
GIMP_RGB_IMAGE
:
GIMP_GRAY_IMAGE
);
break
;
}
layer
=
gimp_layer_new
(
image
,
width
,
height
,
type
,
_
(
"Background"
),
GIMP_OPACITY_OPAQUE
,
GIMP_NORMAL_MODE
);
gimp_drawable_fill_by_type
(
GIMP_DRAWABLE
(
layer
),
context
,
template
->
fill_type
);
gimp_image_add_layer
(
image
,
layer
,
NULL
,
0
,
FALSE
);
gimp_image_undo_enable
(
image
);
gimp_image_clean_all
(
image
);
gimp_create_display
(
gimp
,
image
,
template
->
unit
,
1
.
0
);
g_object_unref
(
image
);
return
image
;
}
GimpImage
*
gimp_image_new_from_drawable
(
Gimp
*
gimp
,
GimpDrawable
*
drawable
)
...
...
app/core/gimpimage-new.h
View file @
72bcb72c
...
...
@@ -24,6 +24,9 @@ GimpTemplate * gimp_image_new_get_last_template (Gimp *gimp,
void
gimp_image_new_set_last_template
(
Gimp
*
gimp
,
GimpTemplate
*
template
);
GimpImage
*
gimp_image_new_from_template
(
Gimp
*
gimp
,
GimpTemplate
*
template
,
GimpContext
*
context
);
GimpImage
*
gimp_image_new_from_drawable
(
Gimp
*
gimp
,
GimpDrawable
*
drawable
);
GimpImage
*
gimp_image_new_from_component
(
Gimp
*
gimp
,
...
...
app/core/gimptemplate.c
View file @
72bcb72c
...
...
@@ -20,8 +20,6 @@
#include "config.h"
#include <string.h>
#include <gegl.h>
#include "libgimpbase/gimpbase.h"
...
...
@@ -29,11 +27,7 @@
#include "core-types.h"
#include "gimp.h"
#include "gimpcontext.h"
#include "gimpimage.h"
#include "gimpimage-undo.h"
#include "gimplayer.h"
#include "gimpprojection.h"
#include "gimptemplate.h"
...
...
@@ -348,74 +342,3 @@ gimp_template_set_from_image (GimpTemplate *template,
if
(
comment
)
g_free
(
comment
);
}
GimpImage
*
gimp_template_create_image
(
Gimp
*
gimp
,
GimpTemplate
*
template
,
GimpContext
*
context
)
{
GimpImage
*
image
;
GimpLayer
*
layer
;
GimpImageType
type
;
gint
width
,
height
;
g_return_val_if_fail
(
GIMP_IS_GIMP
(
gimp
),
NULL
);
g_return_val_if_fail
(
GIMP_IS_TEMPLATE
(
template
),
NULL
);
g_return_val_if_fail
(
GIMP_IS_CONTEXT
(
context
),
NULL
);
image
=
gimp_create_image
(
gimp
,
template
->
width
,
template
->
height
,
template
->
image_type
,
FALSE
);
gimp_image_undo_disable
(
image
);
if
(
template
->
comment
)
{
GimpParasite
*
parasite
;
parasite
=
gimp_parasite_new
(
"gimp-comment"
,
GIMP_PARASITE_PERSISTENT
,
strlen
(
template
->
comment
)
+
1
,
template
->
comment
);
gimp_image_parasite_attach
(
image
,
parasite
);
gimp_parasite_free
(
parasite
);
}
gimp_image_set_resolution
(
image
,
template
->
xresolution
,
template
->
yresolution
);
gimp_image_set_unit
(
image
,
template
->
resolution_unit
);
width
=
gimp_image_get_width
(
image
);
height
=
gimp_image_get_height
(
image
);
switch
(
template
->
fill_type
)
{
case
GIMP_TRANSPARENT_FILL
:
type
=
((
template
->
image_type
==
GIMP_RGB
)
?
GIMP_RGBA_IMAGE
:
GIMP_GRAYA_IMAGE
);
break
;
default:
type
=
((
template
->
image_type
==
GIMP_RGB
)
?
GIMP_RGB_IMAGE
:
GIMP_GRAY_IMAGE
);
break
;
}
layer
=
gimp_layer_new
(
image
,
width
,
height
,
type
,
_
(
"Background"
),
GIMP_OPACITY_OPAQUE
,
GIMP_NORMAL_MODE
);
gimp_drawable_fill_by_type
(
GIMP_DRAWABLE
(
layer
),
context
,
template
->
fill_type
);
gimp_image_add_layer
(
image
,
layer
,
NULL
,
0
,
FALSE
);
gimp_image_undo_enable
(
image
);
gimp_image_clean_all
(
image
);
gimp_create_display
(
gimp
,
image
,
template
->
unit
,
1
.
0
);
g_object_unref
(
image
);
return
image
;
}
app/core/gimptemplate.h
View file @
72bcb72c
...
...
@@ -78,16 +78,12 @@ struct _GimpTemplateClass
};
GType
gimp_template_get_type
(
void
)
G_GNUC_CONST
;
GType
gimp_template_get_type
(
void
)
G_GNUC_CONST
;
GimpTemplate
*
gimp_template_new
(
const
gchar
*
name
);
GimpTemplate
*
gimp_template_new
(
const
gchar
*
name
);
void
gimp_template_set_from_image
(
GimpTemplate
*
template
,
GimpImage
*
image
);
GimpImage
*
gimp_template_create_image
(
Gimp
*
gimp
,
GimpTemplate
*
template
,
GimpContext
*
context
);
void
gimp_template_set_from_image
(
GimpTemplate
*
template
,
GimpImage
*
image
);
#endif
/* __GIMP_TEMPLATE__ */
app/dialogs/image-new-dialog.c
View file @
72bcb72c
...
...
@@ -344,7 +344,7 @@ image_new_create_image (ImageNewDialog *dialog)
gtk_widget_destroy
(
dialog
->
dialog
);
gimp_
template_create_imag
e
(
gimp
,
template
,
gimp_get_user_context
(
gimp
));
gimp_
image_new_from_templat
e
(
gimp
,
template
,
gimp_get_user_context
(
gimp
));
gimp_image_new_set_last_template
(
gimp
,
template
);
g_object_unref
(
template
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment