Commit 509a6c57 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/core/Makefile.am new files defining a GimpGui vtable struct and

2004-07-12  Michael Natterer  <mitch@gimp.org>

	* app/core/Makefile.am
	* app/core/gimp-gui.[ch]: new files defining a GimpGui vtable
	struct and contianing all the vtable wrapper functions. Reordered
	and renamed some functions for consistency.

	* app/core/gimp.[ch]: removed all the vtable code.

	* app/gui/gui-vtable.c: changed accordingly.
parent ce097837
2004-07-12 Michael Natterer <mitch@gimp.org>
* app/core/Makefile.am
* app/core/gimp-gui.[ch]: new files defining a GimpGui vtable
struct and contianing all the vtable wrapper functions. Reordered
and renamed some functions for consistency.
* app/core/gimp.[ch]: removed all the vtable code.
* app/gui/gui-vtable.c: changed accordingly.
2004-07-12 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplay-foreach.c
......
......@@ -28,6 +28,8 @@ libappcore_a_sources = \
gimp-edit.h \
gimp-gradients.c \
gimp-gradients.h \
gimp-gui.c \
gimp-gui.h \
gimp-modules.c \
gimp-modules.h \
gimp-parasites.c \
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-2002 Spencer Kimball, Peter Mattis, and others
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib-object.h>
#include "core-types.h"
#include "gimp.h"
#include "gimp-gui.h"
#include "gimpcontainer.h"
#include "gimpcontext.h"
#include "gimpimage.h"
#include "gimp-intl.h"
void
gimp_gui_init (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
gimp->gui.threads_enter = NULL;
gimp->gui.threads_leave = NULL;
gimp->gui.set_busy = NULL;
gimp->gui.unset_busy = NULL;
gimp->gui.message = NULL;
gimp->gui.help = NULL;
gimp->gui.get_program_class = NULL;
gimp->gui.get_display_name = NULL;
gimp->gui.get_theme_dir = NULL;
gimp->gui.display_get_by_id = NULL;
gimp->gui.display_get_id = NULL;
gimp->gui.display_create = NULL;
gimp->gui.display_delete = NULL;
gimp->gui.displays_reconnect = NULL;
gimp->gui.menus_init = NULL;
gimp->gui.menus_create = NULL;
gimp->gui.menus_delete = NULL;
gimp->gui.progress_start = NULL;
gimp->gui.progress_restart = NULL;
gimp->gui.progress_update = NULL;
gimp->gui.progress_end = NULL;
gimp->gui.pdb_dialog_set = NULL;
gimp->gui.pdb_dialog_close = NULL;
gimp->gui.pdb_dialogs_check = NULL;
}
void
gimp_threads_enter (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (gimp->gui.threads_enter)
gimp->gui.threads_enter (gimp);
}
void
gimp_threads_leave (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (gimp->gui.threads_leave)
gimp->gui.threads_leave (gimp);
}
void
gimp_set_busy (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
/* FIXME: gimp_busy HACK */
gimp->busy++;
if (gimp->busy == 1)
{
if (gimp->gui.set_busy)
gimp->gui.set_busy (gimp);
}
}
static gboolean
gimp_idle_unset_busy (gpointer data)
{
Gimp *gimp = data;
gimp_unset_busy (gimp);
gimp->busy_idle_id = 0;
return FALSE;
}
void
gimp_set_busy_until_idle (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (! gimp->busy_idle_id)
{
gimp_set_busy (gimp);
gimp->busy_idle_id = g_idle_add_full (G_PRIORITY_HIGH,
gimp_idle_unset_busy, gimp,
NULL);
}
}
void
gimp_unset_busy (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (gimp->busy > 0);
/* FIXME: gimp_busy HACK */
gimp->busy--;
if (gimp->busy == 0)
{
if (gimp->gui.unset_busy)
gimp->gui.unset_busy (gimp);
}
}
void
gimp_message (Gimp *gimp,
const gchar *domain,
const gchar *message)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (! gimp->console_messages)
{
switch (gimp->message_handler)
{
case GIMP_MESSAGE_BOX:
case GIMP_ERROR_CONSOLE:
if (gimp->gui.message)
{
gimp->gui.message (gimp, domain, message);
return;
}
break;
default:
break;
}
}
g_printerr ("%s: %s\n\n", domain ? domain : _("GIMP"), message);
}
void
gimp_help (Gimp *gimp,
const gchar *help_domain,
const gchar *help_id)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (gimp->gui.help)
gimp->gui.help (gimp, help_domain, help_id);
}
const gchar *
gimp_get_program_class (Gimp *gimp)
{
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
if (gimp->gui.get_program_class)
return gimp->gui.get_program_class (gimp);
return NULL;
}
gchar *
gimp_get_display_name (Gimp *gimp,
gint gdisp_ID,
gint *monitor_number)
{
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (monitor_number != NULL, NULL);
if (gimp->gui.get_display_name)
return gimp->gui.get_display_name (gimp, gdisp_ID, monitor_number);
*monitor_number = 0;
return NULL;
}
const gchar *
gimp_get_theme_dir (Gimp *gimp)
{
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
if (gimp->gui.get_theme_dir)
return gimp->gui.get_theme_dir (gimp);
return NULL;
}
GimpObject *
gimp_get_display_by_ID (Gimp *gimp,
gint ID)
{
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
if (gimp->gui.display_get_by_id)
return gimp->gui.display_get_by_id (gimp, ID);
return NULL;
}
gint
gimp_get_display_ID (Gimp *gimp,
GimpObject *display)
{
g_return_val_if_fail (GIMP_IS_GIMP (gimp), -1);
g_return_val_if_fail (GIMP_IS_OBJECT (display), -1);
if (gimp->gui.display_get_id)
return gimp->gui.display_get_id (display);
return -1;
}
GimpObject *
gimp_create_display (Gimp *gimp,
GimpImage *gimage,
GimpUnit unit,
gdouble scale)
{
GimpObject *display = NULL;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
if (gimp->gui.display_create)
{
display = gimp->gui.display_create (gimage, unit, scale);
gimp_container_add (gimp->displays, display);
}
return display;
}
void
gimp_delete_display (Gimp *gimp,
GimpObject *display)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (GIMP_IS_OBJECT (display));
if (gimp->gui.display_delete)
gimp->gui.display_delete (display);
}
void
gimp_reconnect_displays (Gimp *gimp,
GimpImage *old_image,
GimpImage *new_image)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (GIMP_IS_IMAGE (old_image));
g_return_if_fail (GIMP_IS_IMAGE (new_image));
if (gimp->gui.displays_reconnect)
gimp->gui.displays_reconnect (gimp, old_image, new_image);
}
void
gimp_menus_init (Gimp *gimp,
GSList *plug_in_defs,
const gchar *std_plugins_domain)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (std_plugins_domain != NULL);
if (gimp->gui.menus_init)
gimp->gui.menus_init (gimp, plug_in_defs, std_plugins_domain);
}
void
gimp_menus_create_entry (Gimp *gimp,
PlugInProcDef *proc_def)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (proc_def != NULL);
if (gimp->gui.menus_create)
gimp->gui.menus_create (gimp, proc_def);
}
void
gimp_menus_delete_entry (Gimp *gimp,
PlugInProcDef *proc_def)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (proc_def != NULL);
if (gimp->gui.menus_delete)
gimp->gui.menus_delete (gimp, proc_def);
}
GimpProgress *
gimp_start_progress (Gimp *gimp,
gint gdisp_ID,
const gchar *message,
GCallback cancel_cb,
gpointer cancel_data)
{
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
if (gimp->gui.progress_start)
return gimp->gui.progress_start (gimp, gdisp_ID, message,
cancel_cb, cancel_data);
return NULL;
}
GimpProgress *
gimp_restart_progress (Gimp *gimp,
GimpProgress *progress,
const gchar *message,
GCallback cancel_cb,
gpointer cancel_data)
{
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (progress != NULL, NULL);
if (gimp->gui.progress_restart)
return gimp->gui.progress_restart (gimp, progress, message,
cancel_cb, cancel_data);
return NULL;
}
void
gimp_update_progress (Gimp *gimp,
GimpProgress *progress,
gdouble percentage)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (progress != NULL);
if (gimp->gui.progress_update)
gimp->gui.progress_update (gimp, progress, percentage);
}
void
gimp_end_progress (Gimp *gimp,
GimpProgress *progress)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (progress != NULL);
if (gimp->gui.progress_end)
gimp->gui.progress_end (gimp, progress);
}
gboolean
gimp_pdb_dialog_new (Gimp *gimp,
GimpContext *context,
GimpContainer *container,
const gchar *title,
const gchar *callback_name,
const gchar *object_name,
...)
{
gboolean retval = FALSE;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
g_return_val_if_fail (GIMP_IS_CONTAINER (container), FALSE);
g_return_val_if_fail (title != NULL, FALSE);
g_return_val_if_fail (callback_name != NULL, FALSE);
if (gimp->gui.pdb_dialog_new)
{
va_list args;
va_start (args, object_name);
retval = gimp->gui.pdb_dialog_new (gimp, context, container, title,
callback_name, object_name,
args);
va_end (args);
}
return retval;
}
gboolean
gimp_pdb_dialog_set (Gimp *gimp,
GimpContainer *container,
const gchar *callback_name,
const gchar *object_name,
...)
{
gboolean retval = FALSE;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
g_return_val_if_fail (GIMP_IS_CONTAINER (container), FALSE);
g_return_val_if_fail (callback_name != NULL, FALSE);
g_return_val_if_fail (object_name != NULL, FALSE);
if (gimp->gui.pdb_dialog_set)
{
va_list args;
va_start (args, object_name);
retval = gimp->gui.pdb_dialog_set (gimp, container, callback_name,
object_name, args);
va_end (args);
}
return retval;
}
gboolean
gimp_pdb_dialog_close (Gimp *gimp,
GimpContainer *container,
const gchar *callback_name)
{
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
g_return_val_if_fail (GIMP_IS_CONTAINER (container), FALSE);
g_return_val_if_fail (callback_name != NULL, FALSE);
if (gimp->gui.pdb_dialog_close)
return gimp->gui.pdb_dialog_close (gimp, container, callback_name);
return FALSE;
}
void
gimp_pdb_dialogs_check (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (gimp->gui.pdb_dialogs_check)
gimp->gui.pdb_dialogs_check (gimp);
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_GUI_H__
#define __GIMP_GUI_H__
typedef struct _GimpGui GimpGui;
struct _GimpGui
{
void (* threads_enter) (Gimp *gimp);
void (* threads_leave) (Gimp *gimp);
void (* set_busy) (Gimp *gimp);
void (* unset_busy) (Gimp *gimp);
void (* message) (Gimp *gimp,
const gchar *domain,
const gchar *message);
void (* help) (Gimp *gimp,
const gchar *help_domain,
const gchar *help_id);
const gchar * (* get_program_class) (Gimp *gimp);
gchar * (* get_display_name) (Gimp *gimp,
gint gdisp_ID,
gint *monitor_number);
const gchar * (* get_theme_dir) (Gimp *gimp);
GimpObject * (* display_get_by_id) (Gimp *gimp,
gint ID);
gint (* display_get_id) (GimpObject *display);
GimpObject * (* display_create) (GimpImage *gimage,
GimpUnit unit,
gdouble scale);
void (* display_delete) (GimpObject *display);
void (* displays_reconnect) (Gimp *gimp,
GimpImage *old_image,
GimpImage *new_image);
void (* menus_init) (Gimp *gimp,
GSList *plug_in_defs,
const gchar *std_domain);
void (* menus_create) (Gimp *gimp,
PlugInProcDef *proc_def);
void (* menus_delete) (Gimp *gimp,
PlugInProcDef *proc_def);
GimpProgress * (* progress_start) (Gimp *gimp,
gint gdisp_ID,
const gchar *message,
GCallback cancel_cb,
gpointer cancel_data);
GimpProgress * (* progress_restart) (Gimp *gimp,
GimpProgress *progress,
const gchar *message,
GCallback cancel_cb,
gpointer cancel_data);
void (* progress_update) (Gimp *gimp,
GimpProgress *progress,
gdouble percentage);
void (* progress_end) (Gimp *gimp,
GimpProgress *progress);
gboolean (* pdb_dialog_new) (Gimp *gimp,
GimpContext *context,
GimpContainer *container,
const gchar *title,
const gchar *callback_name,
const gchar *object_name,
va_list args);
gboolean (* pdb_dialog_set) (Gimp *gimp,
GimpContainer *container,
const gchar *callback_name,
const gchar *object_name,
va_list args);
gboolean (* pdb_dialog_close) (Gimp *gimp,
GimpContainer *container,
const gchar *callback_name);
void (* pdb_dialogs_check) (Gimp *gimp);
};
void gimp_gui_init (Gimp *gimp);
void gimp_threads_enter (Gimp *gimp);
void gimp_threads_leave (Gimp *gimp);
GimpObject * gimp_get_display_by_ID (Gimp *gimp,
gint ID);
gint gimp_get_display_ID (Gimp *gimp,
GimpObject *display);
GimpObject * gimp_create_display (Gimp *gimp,
GimpImage *gimage,
GimpUnit unit,
gdouble scale);
void gimp_delete_display (Gimp *gimp,
GimpObject *display);
void gimp_reconnect_displays (Gimp *gimp,
GimpImage *old_image,
GimpImage *new_image);
void gimp_set_busy (Gimp *gimp);
void gimp_set_busy_until_idle (Gimp *gimp);
void gimp_unset_busy (Gimp *gimp);
void gimp_message (Gimp *gimp,
const gchar *domain,
const gchar *message);
void gimp_help (Gimp *gimp,
const gchar *help_domain,
const gchar *help_id);
void gimp_menus_init (Gimp *gimp,
GSList *plug_in_defs,
const gchar *std_plugins_domain);
void gimp_menus_create_entry (Gimp *gimp,
PlugInProcDef *proc_def);
void gimp_menus_delete_entry (Gimp *gimp,
PlugInProcDef *proc_def);
GimpProgress * gimp_start_progress (Gimp *gimp,
gint gdisp_ID,
const gchar *message,
GCallback cancel_cb,
gpointer cancel_data);
GimpProgress * gimp_restart_progress (Gimp *gimp,
GimpProgress *progress,
const gchar *message,
GCallback cancel_cb,
gpointer cancel_data);
void gimp_update_progress (Gimp *gimp,
GimpProgress *progress,
gdouble percentage);
void gimp_end_progress (Gimp *gimp,
GimpProgress *progress);
const gchar * gimp_get_program_class (Gimp *gimp);
gchar * gimp_get_display_name (Gimp *gimp,
gint gdisp_ID,
gint *monitor_number);
const gchar * gimp_get_theme_dir (Gimp *gimp);
gboolean gimp_pdb_dialog_new (Gimp *gimp,
GimpContext *context,
GimpContainer *container,
const gchar *title,
const gchar *callback_name,
const gchar *object_name,
...);
gboolean gimp_pdb_dialog_set (Gimp *gimp,
GimpContainer *container,
const gchar *callback_name,
const gchar *object_name,
...);
gboolean gimp_pdb_dialog_close (Gimp *gimp,
GimpContainer *container,
const gchar *callback_name);
void gimp_pdb_dialogs_check (Gimp *gimp);
#endif /* __GIMP_GUI_H__ */
......@@ -210,30 +210,7 @@ gimp_init (Gimp *gimp)
gimp->stack_trace_mode = GIMP_STACK_TRACE_NEVER;
gimp->pdb_compat_mode = GIMP_PDB_COMPAT_OFF;
gimp->gui_threads_enter_func = NULL;
gimp->gui_threads_leave_func = NULL;
gimp->gui_get_display_by_id_func = NULL;
gimp->gui_get_display_id_func = NULL;
gimp->gui_create_display_func = NULL;
gimp->gui_delete_display_func = NULL;
gimp->gui_reconnect_displays_func = NULL;
gimp->gui_set_busy_func = NULL;
gimp->gui_unset_busy_func = NULL;
gimp->gui_message_func = NULL;
gimp->gui_help_func = NULL;
gimp->gui_menus_init_func = NULL;
gimp->gui_menus_create_func = NULL;
gimp->gui_menus_delete_func = NULL;
gimp->gui_progress_start_func = NULL;
gimp->gui_progress_restart_func = NULL;
gimp->gui_progress_update_func = NULL;
gimp->gui_progress_end_func = NULL;
gimp->gui_get_program_class_func = NULL;
gimp->gui_get_display_name_func = NULL;
gimp->gui_get_theme_dir_func = NULL;
gimp->gui_pdb_dialog_set_func = NULL;
gimp->gui_pdb_dialog_close_func = NULL;
gimp->gui_pdb_dialogs_check_func = NULL;
gimp_gui_init (gimp);
gimp->busy = 0;
gimp->busy_idle_id = 0;
......@@ -288,6 +265,7 @@ gimp_init (Gimp *gimp)
gimp->documents = gimp_document_list_new (gimp);
gimp->templates = gimp_list_new (GIMP_TYPE_TEMPLATE, TRUE);
gimp_object_set_name (GIMP_OBJECT (gimp->tool_info_list), "templates");
gimp->image_new_last_template = NULL;
gimp->have_current_cut_buffer = FALSE;
......@@ -944,405 +922,6 @@ gimp_set_global_buffer (Gimp *gimp,
g_signal_emit (gimp, gimp_signals[BUFFER_CHANGED], 0);
}
void
gimp_threads_enter (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (gimp->gui_threads_enter_func)
gimp->gui_threads_enter_func (gimp);
}
void
gimp_threads_leave (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (gimp->gui_threads_leave_func)
gimp->gui_threads_leave_func (gimp);
}
GimpObject *
gimp_get_display_by_ID (Gimp<