const gchar * gimp_font_select_new (const gchar *title, const gchar *font_name, GimpRunFontCallback callback, gpointer data) { static const GimpParamDef args[] = { { GIMP_PDB_STRING, "str", "String" }, { GIMP_PDB_INT32, "dialog status", "If the dialog was closing " "[0 = No, 1 = Yes]" } }; gchar *font_callback = gimp_procedural_db_temp_name (); gimp_install_temp_proc (font_callback, "Temporary font popup callback procedure", "", "", "", "", NULL, "", GIMP_TEMPORARY, G_N_ELEMENTS (args), 0, args, NULL, gimp_temp_font_run); if (gimp_fonts_popup (font_callback, title, font_name)) { GimpFontData *font_data; gimp_extension_enable (); /* Allow callbacks to be watched */ /* Now add to hash table so we can find it again */ if (! gimp_font_select_ht) { gimp_font_select_ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) gimp_font_data_free); } font_data = g_slice_new0 (GimpFontData); font_data->font_callback = font_callback; font_data->callback = callback; font_data->data = data; g_hash_table_insert (gimp_font_select_ht, font_callback, font_data); return font_callback; } gimp_uninstall_temp_proc (font_callback); g_free (font_callback); return NULL; }
/** * gimp_progress_install_vtable: * @vtable: a pointer to a @GimpProgressVtable. * @user_data: a pointer that is passed as user_data to all vtable functions. * * Return value: the name of the temporary procedure that's been installed * * Since: GIMP 2.4 **/ const gchar * gimp_progress_install_vtable (const GimpProgressVtable *vtable, gpointer user_data) { static const GimpParamDef args[] = { { GIMP_PDB_INT32, "command", "" }, { GIMP_PDB_STRING, "text", "" }, { GIMP_PDB_FLOAT, "value", "" } }; static const GimpParamDef values[] = { { GIMP_PDB_FLOAT, "value", "" } }; gchar *progress_callback; g_return_val_if_fail (vtable != NULL, NULL); g_return_val_if_fail (vtable->start != NULL, NULL); g_return_val_if_fail (vtable->end != NULL, NULL); g_return_val_if_fail (vtable->set_text != NULL, NULL); g_return_val_if_fail (vtable->set_value != NULL, NULL); progress_callback = gimp_procedural_db_temp_name (); gimp_install_temp_proc (progress_callback, "Temporary progress callback procedure", "", "", "", "", NULL, "", GIMP_TEMPORARY, G_N_ELEMENTS (args), G_N_ELEMENTS (values), args, values, gimp_temp_progress_run); if (_gimp_progress_install (progress_callback)) { GimpProgressData *progress_data; gimp_extension_enable (); /* Allow callbacks to be watched */ /* Now add to hash table so we can find it again */ if (! gimp_progress_ht) { gimp_progress_ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) gimp_progress_data_free); } progress_data = g_slice_new0 (GimpProgressData); progress_data->progress_callback = progress_callback; progress_data->vtable.start = vtable->start; progress_data->vtable.end = vtable->end; progress_data->vtable.set_text = vtable->set_text; progress_data->vtable.set_value = vtable->set_value; progress_data->vtable.pulse = vtable->pulse; progress_data->vtable.get_window = vtable->get_window; progress_data->data = user_data; g_hash_table_insert (gimp_progress_ht, progress_callback, progress_data); return progress_callback; } gimp_uninstall_temp_proc (progress_callback); g_free (progress_callback); return NULL; }