libgimp: fix the non-generated API with the new class types.

This commit is contained in:
Jehan 2019-08-13 22:54:37 +02:00
parent 8c95499e14
commit 5e6d4d8fbd
12 changed files with 150 additions and 67 deletions

View file

@ -836,12 +836,12 @@ gimp_check_type (void)
* *
* This is a constant value given at plug-in configuration time. * This is a constant value given at plug-in configuration time.
* *
* Returns: the default display ID * Returns: (transfer full): the default display ID
**/ **/
gint32 GimpDisplay *
gimp_default_display (void) gimp_default_display (void)
{ {
return _gdisp_ID; return gimp_display_new_by_id (_gdisp_ID);
} }
/** /**

View file

@ -175,7 +175,7 @@ gboolean gimp_export_xmp (void) G_GNUC_CONST;
gboolean gimp_export_iptc (void) G_GNUC_CONST; gboolean gimp_export_iptc (void) G_GNUC_CONST;
GimpCheckSize gimp_check_size (void) G_GNUC_CONST; GimpCheckSize gimp_check_size (void) G_GNUC_CONST;
GimpCheckType gimp_check_type (void) G_GNUC_CONST; GimpCheckType gimp_check_type (void) G_GNUC_CONST;
gint32 gimp_default_display (void) G_GNUC_CONST; GimpDisplay * gimp_default_display (void) G_GNUC_CONST;
const gchar * gimp_wm_class (void) G_GNUC_CONST; const gchar * gimp_wm_class (void) G_GNUC_CONST;
const gchar * gimp_display_name (void) G_GNUC_CONST; const gchar * gimp_display_name (void) G_GNUC_CONST;
gint gimp_monitor_number (void) G_GNUC_CONST; gint gimp_monitor_number (void) G_GNUC_CONST;

View file

@ -312,22 +312,20 @@ gimp_aspect_preview_draw_buffer (GimpPreview *preview,
} }
else else
{ {
guchar *sel; guchar *sel;
guchar *src; guchar *src;
GimpDrawable *selection; GimpSelection *selection;
gint selection_ID; gint w, h;
gint w, h; gint bpp;
gint bpp;
selection_ID = gimp_image_get_selection (image); selection = gimp_image_get_selection (image);
selection = GIMP_DRAWABLE (gimp_item_new_by_id (selection_ID));
w = width; w = width;
h = height; h = height;
src = gimp_drawable_get_thumbnail_data (priv->drawable, src = gimp_drawable_get_thumbnail_data (priv->drawable,
&w, &h, &bpp); &w, &h, &bpp);
sel = gimp_drawable_get_thumbnail_data (selection, sel = gimp_drawable_get_thumbnail_data (GIMP_DRAWABLE (selection),
&w, &h, &bpp); &w, &h, &bpp);
g_object_unref (selection); g_object_unref (selection);

View file

@ -62,7 +62,7 @@ gimp_channel_init (GimpChannel *channel)
* *
* Returns: The newly created channel. * Returns: The newly created channel.
*/ */
gint32 GimpChannel *
gimp_channel_new (GimpImage *image, gimp_channel_new (GimpImage *image,
const gchar *name, const gchar *name,
guint width, guint width,
@ -111,13 +111,16 @@ gimp_channel_new_deprecated (gint32 image_id,
gdouble opacity, gdouble opacity,
const GimpRGB *color) const GimpRGB *color)
{ {
GimpImage *image = gimp_image_new_by_id (image_id); GimpImage *image = gimp_image_new_by_id (image_id);
gint32 channel_id; GimpChannel *channel;
gint32 channel_id;
channel_id = gimp_channel_new (image, name, width, height, channel = gimp_channel_new (image, name, width, height,
opacity, color); opacity, color);
channel_id = gimp_item_get_id (GIMP_ITEM (channel));
g_object_unref (image); g_object_unref (image);
g_object_unref (channel);
return channel_id; return channel_id;
} }

View file

@ -67,12 +67,12 @@ GType gimp_channel_get_type (void) G_GNUC_CONST;
#ifndef GIMP_DEPRECATED_REPLACE_NEW_API #ifndef GIMP_DEPRECATED_REPLACE_NEW_API
gint32 gimp_channel_new (GimpImage *image, GimpChannel * gimp_channel_new (GimpImage *image,
const gchar *name, const gchar *name,
guint width, guint width,
guint height, guint height,
gdouble opacity, gdouble opacity,
const GimpRGB *color); const GimpRGB *color);
#else /* GIMP_DEPRECATED_REPLACE_NEW_API */ #else /* GIMP_DEPRECATED_REPLACE_NEW_API */

View file

@ -447,13 +447,12 @@ gimp_drawable_preview_draw_area (GimpDrawablePreview *preview,
&draw_x, &draw_y, &draw_x, &draw_y,
&draw_width, &draw_height)) &draw_width, &draw_height))
{ {
GimpImageType type; GimpImageType type;
GimpDrawable *selection; GimpSelection *selection;
gint32 selection_ID; guchar *src;
guchar *src; guchar *sel;
guchar *sel; gint d_w, d_h, d_bpp;
gint d_w, d_h, d_bpp; gint s_w, s_h, s_bpp;
gint s_w, s_h, s_bpp;
d_w = draw_width; d_w = draw_width;
d_h = draw_height; d_h = draw_height;
@ -461,8 +460,7 @@ gimp_drawable_preview_draw_area (GimpDrawablePreview *preview,
s_w = draw_width; s_w = draw_width;
s_h = draw_height; s_h = draw_height;
selection_ID = gimp_image_get_selection (image); selection = gimp_image_get_selection (image);
selection = GIMP_DRAWABLE (gimp_item_new_by_id (selection_ID));
src = gimp_drawable_get_sub_thumbnail_data (priv->drawable, src = gimp_drawable_get_sub_thumbnail_data (priv->drawable,
draw_x, draw_y, draw_x, draw_y,
@ -470,7 +468,7 @@ gimp_drawable_preview_draw_area (GimpDrawablePreview *preview,
&d_w, &d_h, &d_w, &d_h,
&d_bpp); &d_bpp);
sel = gimp_drawable_get_sub_thumbnail_data (selection, sel = gimp_drawable_get_sub_thumbnail_data (GIMP_DRAWABLE (selection),
draw_x + offset_x, draw_x + offset_x,
draw_y + offset_y, draw_y + offset_y,
draw_width, draw_height, draw_width, draw_height,

View file

@ -206,13 +206,16 @@ export_apply_masks (GimpImage *image,
for (i = 0; i < n_layers; i++) for (i = 0; i < n_layers; i++)
{ {
GimpLayer *layer; GimpLayer *layer;
GimpLayerMask *mask;
layer = GIMP_LAYER (gimp_item_new_by_id (layers[i])); layer = GIMP_LAYER (gimp_item_new_by_id (layers[i]));
if (gimp_layer_get_mask (layer) != -1) mask = gimp_layer_get_mask (layer);
if (mask)
gimp_layer_remove_mask (layer, GIMP_MASK_APPLY); gimp_layer_remove_mask (layer, GIMP_MASK_APPLY);
g_object_unref (layer); g_object_unref (layer);
g_clear_object (&mask);
} }
g_free (layers); g_free (layers);
@ -864,12 +867,15 @@ gimp_export_image (GimpImage **image,
{ {
for (i = 0; i < n_layers; i++) for (i = 0; i < n_layers; i++)
{ {
GimpLayer *layer = GIMP_LAYER (gimp_item_new_by_id (layers[i])); GimpLayer *layer = GIMP_LAYER (gimp_item_new_by_id (layers[i]));
GimpLayerMask *mask;
if (gimp_layer_get_mask (layer) != -1) mask = gimp_layer_get_mask (layer);
if (mask)
has_layer_masks = TRUE; has_layer_masks = TRUE;
g_object_unref (layer); g_object_unref (layer);
g_clear_object (&mask);
} }
} }

View file

@ -1291,7 +1291,7 @@ gimp_param_display_id_validate (GParamSpec *pspec,
if (ispec->none_ok && (display_id == 0 || display_id == -1)) if (ispec->none_ok && (display_id == 0 || display_id == -1))
return FALSE; return FALSE;
if (! gimp_display_is_valid (display_id)) if (! _gimp_display_is_valid (display_id))
{ {
value->data[0].v_int = -1; value->data[0].v_int = -1;
return TRUE; return TRUE;

View file

@ -181,9 +181,15 @@ gimp_progress_uninstall (const gchar *progress_callback)
gboolean gboolean
gimp_progress_init (const gchar *message) gimp_progress_init (const gchar *message)
{ {
GimpDisplay *display = gimp_default_display ();
gboolean success;
gimp_progress_current = 0.0; gimp_progress_current = 0.0;
return _gimp_progress_init (message, gimp_default_display ()); success = _gimp_progress_init (message, display);
g_clear_object (&display);
return success;
} }
/** /**

View file

@ -195,7 +195,7 @@ gimp_ui_get_foreign_window (guint32 window)
/** /**
* gimp_ui_get_display_window: * gimp_ui_get_display_window:
* @gdisp_ID: a GimpDisplay ID. * @display: a #GimpDisplay.
* *
* Returns the #GdkWindow of a display window. The purpose is to allow * Returns the #GdkWindow of a display window. The purpose is to allow
* to make plug-in dialogs transient to the image display as explained * to make plug-in dialogs transient to the image display as explained
@ -211,13 +211,13 @@ gimp_ui_get_foreign_window (guint32 window)
* Since: 2.4 * Since: 2.4
*/ */
GdkWindow * GdkWindow *
gimp_ui_get_display_window (guint32 gdisp_ID) gimp_ui_get_display_window (GimpDisplay *display)
{ {
guint32 window; guint32 window;
g_return_val_if_fail (gimp_ui_initialized, NULL); g_return_val_if_fail (gimp_ui_initialized, NULL);
window = gimp_display_get_window_handle (gdisp_ID); window = gimp_display_get_window_handle (display);
if (window) if (window)
return gimp_ui_get_foreign_window (window); return gimp_ui_get_foreign_window (window);
@ -267,12 +267,12 @@ gimp_window_transient_show (GtkWidget *window)
/** /**
* gimp_window_set_transient_for_display: * gimp_window_set_transient_for_display:
* @window: the #GtkWindow that should become transient * @window: the #GtkWindow that should become transient
* @gdisp_ID: display ID of the image window that should become the parent * @display: display of the image window that should become the parent
* *
* Indicates to the window manager that @window is a transient dialog * Indicates to the window manager that @window is a transient dialog
* associated with the GIMP image window that is identified by it's * associated with the GIMP image window that is identified by it's
* display ID. See gdk_window_set_transient_for () for more information. * display ID. See gdk_window_set_transient_for () for more information.
* *
* Most of the time you will want to use the convenience function * Most of the time you will want to use the convenience function
* gimp_window_set_transient(). * gimp_window_set_transient().
@ -280,14 +280,14 @@ gimp_window_transient_show (GtkWidget *window)
* Since: 2.4 * Since: 2.4
*/ */
void void
gimp_window_set_transient_for_display (GtkWindow *window, gimp_window_set_transient_for_display (GtkWindow *window,
guint32 gdisp_ID) GimpDisplay *display)
{ {
g_return_if_fail (gimp_ui_initialized); g_return_if_fail (gimp_ui_initialized);
g_return_if_fail (GTK_IS_WINDOW (window)); g_return_if_fail (GTK_IS_WINDOW (window));
if (! gimp_window_set_transient_for (window, if (! gimp_window_set_transient_for (window,
gimp_ui_get_display_window (gdisp_ID))) gimp_ui_get_display_window (display)))
{ {
/* if setting the window transient failed, at least set /* if setting the window transient failed, at least set
* WIN_POS_CENTER, which will center the window on the screen * WIN_POS_CENTER, which will center the window on the screen
@ -448,3 +448,60 @@ gimp_osx_focus_window (void)
[NSApp activateIgnoringOtherApps:YES]; [NSApp activateIgnoringOtherApps:YES];
} }
#endif #endif
/* Deprecated API. */
/**
* gimp_ui_get_display_window_deprecated: (skip)
* @gdisp_ID: a GimpDisplay ID.
*
* Returns the #GdkWindow of a display window. The purpose is to allow
* to make plug-in dialogs transient to the image display as explained
* with gdk_window_set_transient_for().
*
* You shouldn't have to call this function directly. Use
* gimp_window_set_transient_for_display() instead.
*
* Returns: (nullable) (transfer full): A reference to a #GdkWindow or %NULL.
* You should unref the window using g_object_unref() as
* soon as you don't need it any longer.
*
* Since: 2.4
*/
GdkWindow *
gimp_ui_get_display_window_deprecated (guint32 gdisp_ID)
{
GimpDisplay *display = gimp_display_new_by_id (gdisp_ID);
GdkWindow *window;
window = gimp_ui_get_display_window (display);
g_object_unref (display);
return window;
}
/**
* gimp_window_set_transient_for_display_deprecated: (skip)
* @window: the #GtkWindow that should become transient
* @gdisp_ID: display ID of the image window that should become the parent
*
* Indicates to the window manager that @window is a transient dialog
* associated with the GIMP image window that is identified by it's
* display ID. See gdk_window_set_transient_for () for more information.
*
* Most of the time you will want to use the convenience function
* gimp_window_set_transient().
*
* Since: 2.4
*/
void
gimp_window_set_transient_for_display_deprecated (GtkWindow *window,
guint32 gdisp_ID)
{
GimpDisplay *display = gimp_display_new_by_id (gdisp_ID);
gimp_window_set_transient_for_display (window, display);
g_object_unref (display);
}

View file

@ -54,13 +54,30 @@ G_BEGIN_DECLS
void gimp_ui_init (const gchar *prog_name, void gimp_ui_init (const gchar *prog_name,
gboolean preview); gboolean preview);
GdkWindow * gimp_ui_get_display_window (guint32 gdisp_ID);
GdkWindow * gimp_ui_get_progress_window (void); GdkWindow * gimp_ui_get_progress_window (void);
void gimp_window_set_transient_for_display (GtkWindow *window,
guint32 gdisp_ID);
void gimp_window_set_transient (GtkWindow *window); void gimp_window_set_transient (GtkWindow *window);
#ifndef GIMP_DEPRECATED_REPLACE_NEW_API
GdkWindow * gimp_ui_get_display_window (GimpDisplay *display);
void gimp_window_set_transient_for_display (GtkWindow *window,
GimpDisplay *display);
#else /* GIMP_DEPRECATED_REPLACE_NEW_API */
#define gimp_ui_get_display_window gimp_ui_get_display_window_deprecated
#define gimp_window_set_transient_for_display gimp_window_set_transient_for_display_deprecated
#endif /* GIMP_DEPRECATED_REPLACE_NEW_API */
GdkWindow * gimp_ui_get_display_window_deprecated (guint32 gdisp_ID);
void gimp_window_set_transient_for_display_deprecated (GtkWindow *window,
guint32 gdisp_ID);
G_END_DECLS G_END_DECLS
#endif /* __GIMP_UI_H__ */ #endif /* __GIMP_UI_H__ */

View file

@ -517,21 +517,19 @@ gimp_zoom_preview_draw_buffer (GimpPreview *preview,
} }
else else
{ {
guchar *sel; guchar *sel;
guchar *src; guchar *src;
GimpDrawable *selection; GimpSelection *selection;
gint selection_ID; gint w, h;
gint w, h; gint bpp;
gint bpp; gint src_x;
gint src_x; gint src_y;
gint src_y; gint src_width;
gint src_width; gint src_height;
gint src_height; gint offsx = 0;
gint offsx = 0; gint offsy = 0;
gint offsy = 0;
selection_ID = gimp_image_get_selection (image); selection = gimp_image_get_selection (image);
selection = GIMP_DRAWABLE (gimp_item_new_by_id (selection_ID));
w = width; w = width;
h = height; h = height;
@ -545,7 +543,7 @@ gimp_zoom_preview_draw_buffer (GimpPreview *preview,
src_width, src_height, src_width, src_height,
&w, &h, &bpp); &w, &h, &bpp);
gimp_drawable_offsets (priv->drawable, &offsx, &offsy); gimp_drawable_offsets (priv->drawable, &offsx, &offsy);
sel = gimp_drawable_get_sub_thumbnail_data (selection, sel = gimp_drawable_get_sub_thumbnail_data (GIMP_DRAWABLE (selection),
src_x + offsx, src_y + offsy, src_x + offsx, src_y + offsy,
src_width, src_height, src_width, src_height,
&width, &height, &bpp); &width, &height, &bpp);