mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-04 01:43:24 +00:00
libgimp: s/gimp_display_new_by_id/gimp_display_get_by_id/
GimpDisplay objects now also belongs to libgimp!
This commit is contained in:
parent
cfd30ec62a
commit
d15388c8c9
7 changed files with 44 additions and 27 deletions
|
@ -836,12 +836,13 @@ gimp_check_type (void)
|
|||
*
|
||||
* This is a constant value given at plug-in configuration time.
|
||||
*
|
||||
* Returns: (transfer full): the default display ID
|
||||
* Returns: (transfer none): the default display ID
|
||||
* The object belongs to libgimp and you should not free it.
|
||||
**/
|
||||
GimpDisplay *
|
||||
gimp_default_display (void)
|
||||
{
|
||||
return gimp_display_new_by_id (_gdisp_ID);
|
||||
return gimp_display_get_by_id (_gdisp_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,6 +37,9 @@ struct _GimpDisplayPrivate
|
|||
gint id;
|
||||
};
|
||||
|
||||
static GHashTable *gimp_displays = NULL;
|
||||
|
||||
|
||||
static void gimp_display_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
|
@ -132,29 +135,51 @@ gimp_display_get_property (GObject *object,
|
|||
gint32
|
||||
gimp_display_get_id (GimpDisplay *display)
|
||||
{
|
||||
return display->priv->id;
|
||||
return display ? display->priv->id : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_display_new_by_id:
|
||||
* gimp_display_get_by_id:
|
||||
* @display_id: The display id.
|
||||
*
|
||||
* Creates a #GimpDisplay representing @display_id.
|
||||
*
|
||||
* Returns: (nullable) (transfer full): a #GimpDisplay for @display_id or
|
||||
* Returns: (nullable) (transfer none): a #GimpDisplay for @display_id or
|
||||
* %NULL if @display_id does not represent a valid display.
|
||||
* The object belongs to libgimp and you should not free it.
|
||||
*
|
||||
* Since: 3.0
|
||||
**/
|
||||
GimpDisplay *
|
||||
gimp_display_new_by_id (gint32 display_id)
|
||||
gimp_display_get_by_id (gint32 display_id)
|
||||
{
|
||||
GimpDisplay *display = NULL;
|
||||
|
||||
if (_gimp_display_is_valid (display_id))
|
||||
display = g_object_new (GIMP_TYPE_DISPLAY,
|
||||
"id", display_id,
|
||||
NULL);
|
||||
if (G_UNLIKELY (! gimp_displays))
|
||||
gimp_displays = g_hash_table_new_full (g_direct_hash,
|
||||
g_direct_equal,
|
||||
NULL,
|
||||
(GDestroyNotify) g_object_unref);
|
||||
|
||||
if (! _gimp_display_is_valid (display_id))
|
||||
{
|
||||
g_hash_table_remove (gimp_displays, GINT_TO_POINTER (display_id));
|
||||
}
|
||||
else
|
||||
{
|
||||
display = g_hash_table_lookup (gimp_displays,
|
||||
GINT_TO_POINTER (display_id));
|
||||
|
||||
if (! display)
|
||||
{
|
||||
display = g_object_new (GIMP_TYPE_DISPLAY,
|
||||
"id", display_id,
|
||||
NULL);
|
||||
g_hash_table_insert (gimp_displays,
|
||||
GINT_TO_POINTER (display_id),
|
||||
display);
|
||||
}
|
||||
}
|
||||
|
||||
return display;
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ struct _GimpDisplayClass
|
|||
GType gimp_display_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gint32 gimp_display_get_id (GimpDisplay *display);
|
||||
GimpDisplay * gimp_display_new_by_id (gint32 display_id);
|
||||
GimpDisplay * gimp_display_get_by_id (gint32 display_id);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -131,7 +131,7 @@ _gimp_display_is_valid (gint32 display_ID)
|
|||
* procedure only makes sense for use with the GIMP UI, and will result
|
||||
* in an execution error if called when GIMP has no UI.
|
||||
*
|
||||
* Returns: (transfer full): The new display.
|
||||
* Returns: (transfer none): The new display.
|
||||
**/
|
||||
GimpDisplay *
|
||||
gimp_display_new (GimpImage *image)
|
||||
|
@ -155,7 +155,7 @@ gimp_display_new (GimpImage *image)
|
|||
gimp_value_array_unref (args);
|
||||
|
||||
if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
|
||||
display = gimp_display_new_by_id (gimp_value_get_display_id (gimp_value_array_index (return_vals, 1)));
|
||||
display = gimp_display_get_by_id (gimp_value_get_display_id (gimp_value_array_index (return_vals, 1)));
|
||||
|
||||
gimp_value_array_unref (return_vals);
|
||||
|
||||
|
|
|
@ -187,7 +187,6 @@ gimp_progress_init (const gchar *message)
|
|||
gimp_progress_current = 0.0;
|
||||
|
||||
success = _gimp_progress_init (message, display);
|
||||
g_clear_object (&display);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
|
|
@ -473,13 +473,7 @@ gimp_osx_focus_window (void)
|
|||
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;
|
||||
return gimp_ui_get_display_window (gimp_display_get_by_id (gdisp_ID));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -500,8 +494,6 @@ 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);
|
||||
gimp_window_set_transient_for_display (window,
|
||||
gimp_display_get_by_id (gdisp_ID));
|
||||
}
|
||||
|
|
|
@ -156,9 +156,9 @@ package Gimp::CodeGen::pdb;
|
|||
app_const_type => 'GimpObject *',
|
||||
id => 1,
|
||||
init_value => 'NULL',
|
||||
out_annotate => '(transfer full)',
|
||||
out_annotate => '(transfer none)',
|
||||
get_value_func => '$var = gimp_value_get_display ($value, gimp)',
|
||||
dup_value_func => '$var = gimp_display_new_by_id (gimp_value_get_display_id ($value))',
|
||||
dup_value_func => '$var = gimp_display_get_by_id (gimp_value_get_display_id ($value))',
|
||||
dup_value_func_d=> '$var = gimp_value_get_display_id ($value)',
|
||||
set_value_func => 'gimp_value_set_display_id ($value, gimp_display_get_id ($var))',
|
||||
take_value_func => 'gimp_value_set_display ($value, $var)' ,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue