added framework for having multiple simultaneous displays
-Yosh
This commit is contained in:
@ -1,3 +1,9 @@
|
||||
Sat Aug 28 15:36:36 PDT 1999 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* app/gdisplay.[ch]
|
||||
* app/gdisplay_color.[ch]: added framework for having multiple
|
||||
simultaneous displays
|
||||
|
||||
Sat Aug 28 12:15:15 PDT 1999 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* plug-ins/borderaverage/borderaverage.c
|
||||
|
@ -123,7 +123,7 @@ gdisplay_new (GimpImage *gimage,
|
||||
gdisp->idle_render.update_areas = NULL;
|
||||
gdisp->idle_render.active = FALSE;
|
||||
|
||||
gdisp->cd_name = NULL;
|
||||
gdisp->cd_list = NULL;
|
||||
|
||||
/* format the title */
|
||||
gdisplay_format_title (gdisp, title, MAX_TITLE_BUF);
|
||||
|
@ -22,8 +22,6 @@
|
||||
#include "info_dialog.h"
|
||||
#include "selection.h"
|
||||
|
||||
#include "libgimp/color_display.h"
|
||||
|
||||
#include "gdisplayF.h"
|
||||
|
||||
/*
|
||||
@ -154,9 +152,7 @@ struct _GDisplay
|
||||
|
||||
IdleRenderStruct idle_render; /* state of this gdisplay's render thread */
|
||||
|
||||
char *cd_name; /* color display conversion stuff */
|
||||
gpointer cd_ID;
|
||||
GimpColorDisplayConvert cd_convert;
|
||||
GList *cd_list; /* color display conversion stuff */
|
||||
};
|
||||
|
||||
|
||||
@ -220,4 +216,3 @@ void gdisplay_flush_displays_only (GDisplay *gdisp); /* no rerender! */
|
||||
|
||||
|
||||
#endif /* __GDISPLAY_H__ */
|
||||
|
||||
|
@ -123,7 +123,7 @@ gdisplay_new (GimpImage *gimage,
|
||||
gdisp->idle_render.update_areas = NULL;
|
||||
gdisp->idle_render.active = FALSE;
|
||||
|
||||
gdisp->cd_name = NULL;
|
||||
gdisp->cd_list = NULL;
|
||||
|
||||
/* format the title */
|
||||
gdisplay_format_title (gdisp, title, MAX_TITLE_BUF);
|
||||
|
@ -22,8 +22,6 @@
|
||||
#include "info_dialog.h"
|
||||
#include "selection.h"
|
||||
|
||||
#include "libgimp/color_display.h"
|
||||
|
||||
#include "gdisplayF.h"
|
||||
|
||||
/*
|
||||
@ -154,9 +152,7 @@ struct _GDisplay
|
||||
|
||||
IdleRenderStruct idle_render; /* state of this gdisplay's render thread */
|
||||
|
||||
char *cd_name; /* color display conversion stuff */
|
||||
gpointer cd_ID;
|
||||
GimpColorDisplayConvert cd_convert;
|
||||
GList *cd_list; /* color display conversion stuff */
|
||||
};
|
||||
|
||||
|
||||
@ -220,4 +216,3 @@ void gdisplay_flush_displays_only (GDisplay *gdisp); /* no rerender! */
|
||||
|
||||
|
||||
#endif /* __GDISPLAY_H__ */
|
||||
|
||||
|
@ -16,10 +16,15 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "gdisplay_color.h"
|
||||
#include "gdisplay.h"
|
||||
#include "gimpimageP.h"
|
||||
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
typedef struct _ColorDisplayInfo ColorDisplayInfo;
|
||||
@ -43,6 +48,12 @@ struct _GammaContext
|
||||
GtkWidget *spinner;
|
||||
};
|
||||
|
||||
static void gdisplay_color_detach_real (GDisplay *gdisp,
|
||||
ColorDisplayNode *node,
|
||||
gboolean unref);
|
||||
static gint node_name_compare (ColorDisplayNode *node,
|
||||
const char *name);
|
||||
|
||||
static gpointer gamma_new (int type);
|
||||
static void gamma_create_lookup_table (GammaContext *context);
|
||||
static void gamma_destroy (gpointer cd_ID);
|
||||
@ -110,12 +121,30 @@ gboolean
|
||||
gimp_color_display_unregister (const char *name)
|
||||
{
|
||||
ColorDisplayInfo *info;
|
||||
GDisplay *gdisp;
|
||||
GList *node;
|
||||
|
||||
if ((info = g_hash_table_lookup (color_display_table, name)))
|
||||
{
|
||||
GSList *refs = info->refs;
|
||||
|
||||
while (refs)
|
||||
{
|
||||
gdisp = (GDisplay *) refs->data;
|
||||
|
||||
node = g_list_find_custom (gdisp->cd_list, name, node_name_compare);
|
||||
gdisp->cd_list = g_slist_remove_link (gdisp->cd_list, node);
|
||||
|
||||
gdisplay_color_detach_real (gdisp, node->data, FALSE);
|
||||
|
||||
g_list_free_1 (node);
|
||||
|
||||
refs = refs->next;
|
||||
}
|
||||
|
||||
g_slist_free (info->refs);
|
||||
|
||||
g_hash_table_remove (color_display_table, name);
|
||||
|
||||
/* FIXME: Check refs here */
|
||||
|
||||
g_free (info->name);
|
||||
g_free (info);
|
||||
@ -129,48 +158,87 @@ gdisplay_color_attach (GDisplay *gdisp,
|
||||
const char *name)
|
||||
{
|
||||
ColorDisplayInfo *info;
|
||||
|
||||
gdisplay_color_detach (gdisp);
|
||||
|
||||
gdisp->cd_name = g_strdup (name);
|
||||
gdisp->cd_ID = NULL;
|
||||
gdisp->cd_convert = NULL;
|
||||
ColorDisplayNode *node;
|
||||
|
||||
if ((info = g_hash_table_lookup (color_display_table, name)))
|
||||
{
|
||||
node = g_new (ColorDisplayNode, 1);
|
||||
|
||||
node->cd_name = g_strdup (name);
|
||||
node->cd_ID = NULL;
|
||||
|
||||
if (!info->refs && info->methods.init)
|
||||
info->methods.init ();
|
||||
|
||||
info->refs = g_slist_append (info->refs, gdisp);
|
||||
|
||||
if (info->methods.new)
|
||||
gdisp->cd_ID = info->methods.new (gdisp->gimage->base_type);
|
||||
node->cd_ID = info->methods.new (gdisp->gimage->base_type);
|
||||
|
||||
gdisp->cd_convert = info->methods.convert;
|
||||
node->cd_convert = info->methods.convert;
|
||||
|
||||
gdisp->cd_list = g_list_append (gdisp->cd_list, name);
|
||||
}
|
||||
else
|
||||
g_warning ("Tried to attach a nonexistant color display");
|
||||
}
|
||||
|
||||
void
|
||||
gdisplay_color_detach (GDisplay *gdisp)
|
||||
gdisplay_color_detach (GDisplay *gdisp,
|
||||
const char *name)
|
||||
{
|
||||
GList *node;
|
||||
|
||||
node = g_list_find_custom (gdisp->cd_list, name, node_name_compare);
|
||||
gdisplay_color_detach_real (gdisp, node->data, TRUE);
|
||||
|
||||
gdisp->cd_list = g_list_remove_link (gdisp->cd_list, node);
|
||||
g_list_free_1 (node);
|
||||
}
|
||||
|
||||
void
|
||||
gdisplay_color_detach_all (GDisplay *gdisp)
|
||||
{
|
||||
GList *list = gdisp->cd_list;
|
||||
|
||||
while (list)
|
||||
{
|
||||
gdisplay_color_detach_real (gdisp, list->data, TRUE);
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
g_list_free (gdisp->cd_list);
|
||||
gdisp->cd_list = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gdisplay_color_detach_real (GDisplay *gdisp,
|
||||
ColorDisplayNode *node,
|
||||
gboolean unref)
|
||||
{
|
||||
ColorDisplayInfo *info;
|
||||
|
||||
if (gdisp->cd_name)
|
||||
|
||||
if ((info = g_hash_table_lookup (color_display_table, node->cd_name)))
|
||||
{
|
||||
if ((info = g_hash_table_lookup (color_display_table, gdisp->cd_name)))
|
||||
{
|
||||
if (info->methods.destroy)
|
||||
info->methods.destroy (gdisp->cd_ID);
|
||||
if (info->methods.destroy)
|
||||
info->methods.destroy (node->cd_ID);
|
||||
|
||||
info->refs = g_slist_remove (info->refs, gdisp);
|
||||
if (unref)
|
||||
info->refs = g_slist_remove (info->refs, gdisp);
|
||||
|
||||
if (!info->refs && info->methods.finalize)
|
||||
info->methods.finalize ();
|
||||
}
|
||||
if (!info->refs && info->methods.finalize)
|
||||
info->methods.finalize ();
|
||||
}
|
||||
|
||||
g_free (gdisp->cd_name);
|
||||
gdisp->cd_name = NULL;
|
||||
}
|
||||
g_free (node->cd_name);
|
||||
g_free (node);
|
||||
}
|
||||
|
||||
static gint
|
||||
node_name_compare (ColorDisplayNode *node,
|
||||
const char *name)
|
||||
{
|
||||
return strcmp (node->cd_name, name);
|
||||
}
|
||||
|
||||
/* The Gamma Color Display */
|
||||
|
@ -15,10 +15,25 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __GDISPLAY_COLOR_H__
|
||||
#define __GDISPLAY_COLOR_H__
|
||||
|
||||
#include "gdisplay.h"
|
||||
#include "libgimp/color_display.h"
|
||||
#include "gdisplayF.h"
|
||||
|
||||
void gdisplay_color_init (void);
|
||||
void gdisplay_color_attach (GDisplay *gdisp,
|
||||
const char *name);
|
||||
void gdisplay_color_detach (GDisplay *gdisp);
|
||||
typedef struct _ColorDisplayNode ColorDisplayNode;
|
||||
|
||||
struct _ColorDisplayNode {
|
||||
char *cd_name;
|
||||
gpointer cd_ID;
|
||||
GimpColorDisplayConvert cd_convert;
|
||||
};
|
||||
|
||||
void gdisplay_color_init (void);
|
||||
void gdisplay_color_attach (GDisplay *gdisp,
|
||||
const char *name);
|
||||
void gdisplay_color_detach (GDisplay *gdisp,
|
||||
const char *name);
|
||||
void gdisplay_color_detach_all (GDisplay *gdisp);
|
||||
|
||||
#endif /* __GDISPLAY_COLOR_H__ */
|
||||
|
@ -123,7 +123,7 @@ gdisplay_new (GimpImage *gimage,
|
||||
gdisp->idle_render.update_areas = NULL;
|
||||
gdisp->idle_render.active = FALSE;
|
||||
|
||||
gdisp->cd_name = NULL;
|
||||
gdisp->cd_list = NULL;
|
||||
|
||||
/* format the title */
|
||||
gdisplay_format_title (gdisp, title, MAX_TITLE_BUF);
|
||||
|
@ -22,8 +22,6 @@
|
||||
#include "info_dialog.h"
|
||||
#include "selection.h"
|
||||
|
||||
#include "libgimp/color_display.h"
|
||||
|
||||
#include "gdisplayF.h"
|
||||
|
||||
/*
|
||||
@ -154,9 +152,7 @@ struct _GDisplay
|
||||
|
||||
IdleRenderStruct idle_render; /* state of this gdisplay's render thread */
|
||||
|
||||
char *cd_name; /* color display conversion stuff */
|
||||
gpointer cd_ID;
|
||||
GimpColorDisplayConvert cd_convert;
|
||||
GList *cd_list; /* color display conversion stuff */
|
||||
};
|
||||
|
||||
|
||||
@ -220,4 +216,3 @@ void gdisplay_flush_displays_only (GDisplay *gdisp); /* no rerender! */
|
||||
|
||||
|
||||
#endif /* __GDISPLAY_H__ */
|
||||
|
||||
|
@ -16,10 +16,15 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "gdisplay_color.h"
|
||||
#include "gdisplay.h"
|
||||
#include "gimpimageP.h"
|
||||
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
typedef struct _ColorDisplayInfo ColorDisplayInfo;
|
||||
@ -43,6 +48,12 @@ struct _GammaContext
|
||||
GtkWidget *spinner;
|
||||
};
|
||||
|
||||
static void gdisplay_color_detach_real (GDisplay *gdisp,
|
||||
ColorDisplayNode *node,
|
||||
gboolean unref);
|
||||
static gint node_name_compare (ColorDisplayNode *node,
|
||||
const char *name);
|
||||
|
||||
static gpointer gamma_new (int type);
|
||||
static void gamma_create_lookup_table (GammaContext *context);
|
||||
static void gamma_destroy (gpointer cd_ID);
|
||||
@ -110,12 +121,30 @@ gboolean
|
||||
gimp_color_display_unregister (const char *name)
|
||||
{
|
||||
ColorDisplayInfo *info;
|
||||
GDisplay *gdisp;
|
||||
GList *node;
|
||||
|
||||
if ((info = g_hash_table_lookup (color_display_table, name)))
|
||||
{
|
||||
GSList *refs = info->refs;
|
||||
|
||||
while (refs)
|
||||
{
|
||||
gdisp = (GDisplay *) refs->data;
|
||||
|
||||
node = g_list_find_custom (gdisp->cd_list, name, node_name_compare);
|
||||
gdisp->cd_list = g_slist_remove_link (gdisp->cd_list, node);
|
||||
|
||||
gdisplay_color_detach_real (gdisp, node->data, FALSE);
|
||||
|
||||
g_list_free_1 (node);
|
||||
|
||||
refs = refs->next;
|
||||
}
|
||||
|
||||
g_slist_free (info->refs);
|
||||
|
||||
g_hash_table_remove (color_display_table, name);
|
||||
|
||||
/* FIXME: Check refs here */
|
||||
|
||||
g_free (info->name);
|
||||
g_free (info);
|
||||
@ -129,48 +158,87 @@ gdisplay_color_attach (GDisplay *gdisp,
|
||||
const char *name)
|
||||
{
|
||||
ColorDisplayInfo *info;
|
||||
|
||||
gdisplay_color_detach (gdisp);
|
||||
|
||||
gdisp->cd_name = g_strdup (name);
|
||||
gdisp->cd_ID = NULL;
|
||||
gdisp->cd_convert = NULL;
|
||||
ColorDisplayNode *node;
|
||||
|
||||
if ((info = g_hash_table_lookup (color_display_table, name)))
|
||||
{
|
||||
node = g_new (ColorDisplayNode, 1);
|
||||
|
||||
node->cd_name = g_strdup (name);
|
||||
node->cd_ID = NULL;
|
||||
|
||||
if (!info->refs && info->methods.init)
|
||||
info->methods.init ();
|
||||
|
||||
info->refs = g_slist_append (info->refs, gdisp);
|
||||
|
||||
if (info->methods.new)
|
||||
gdisp->cd_ID = info->methods.new (gdisp->gimage->base_type);
|
||||
node->cd_ID = info->methods.new (gdisp->gimage->base_type);
|
||||
|
||||
gdisp->cd_convert = info->methods.convert;
|
||||
node->cd_convert = info->methods.convert;
|
||||
|
||||
gdisp->cd_list = g_list_append (gdisp->cd_list, name);
|
||||
}
|
||||
else
|
||||
g_warning ("Tried to attach a nonexistant color display");
|
||||
}
|
||||
|
||||
void
|
||||
gdisplay_color_detach (GDisplay *gdisp)
|
||||
gdisplay_color_detach (GDisplay *gdisp,
|
||||
const char *name)
|
||||
{
|
||||
GList *node;
|
||||
|
||||
node = g_list_find_custom (gdisp->cd_list, name, node_name_compare);
|
||||
gdisplay_color_detach_real (gdisp, node->data, TRUE);
|
||||
|
||||
gdisp->cd_list = g_list_remove_link (gdisp->cd_list, node);
|
||||
g_list_free_1 (node);
|
||||
}
|
||||
|
||||
void
|
||||
gdisplay_color_detach_all (GDisplay *gdisp)
|
||||
{
|
||||
GList *list = gdisp->cd_list;
|
||||
|
||||
while (list)
|
||||
{
|
||||
gdisplay_color_detach_real (gdisp, list->data, TRUE);
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
g_list_free (gdisp->cd_list);
|
||||
gdisp->cd_list = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gdisplay_color_detach_real (GDisplay *gdisp,
|
||||
ColorDisplayNode *node,
|
||||
gboolean unref)
|
||||
{
|
||||
ColorDisplayInfo *info;
|
||||
|
||||
if (gdisp->cd_name)
|
||||
|
||||
if ((info = g_hash_table_lookup (color_display_table, node->cd_name)))
|
||||
{
|
||||
if ((info = g_hash_table_lookup (color_display_table, gdisp->cd_name)))
|
||||
{
|
||||
if (info->methods.destroy)
|
||||
info->methods.destroy (gdisp->cd_ID);
|
||||
if (info->methods.destroy)
|
||||
info->methods.destroy (node->cd_ID);
|
||||
|
||||
info->refs = g_slist_remove (info->refs, gdisp);
|
||||
if (unref)
|
||||
info->refs = g_slist_remove (info->refs, gdisp);
|
||||
|
||||
if (!info->refs && info->methods.finalize)
|
||||
info->methods.finalize ();
|
||||
}
|
||||
if (!info->refs && info->methods.finalize)
|
||||
info->methods.finalize ();
|
||||
}
|
||||
|
||||
g_free (gdisp->cd_name);
|
||||
gdisp->cd_name = NULL;
|
||||
}
|
||||
g_free (node->cd_name);
|
||||
g_free (node);
|
||||
}
|
||||
|
||||
static gint
|
||||
node_name_compare (ColorDisplayNode *node,
|
||||
const char *name)
|
||||
{
|
||||
return strcmp (node->cd_name, name);
|
||||
}
|
||||
|
||||
/* The Gamma Color Display */
|
||||
|
@ -15,10 +15,25 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __GDISPLAY_COLOR_H__
|
||||
#define __GDISPLAY_COLOR_H__
|
||||
|
||||
#include "gdisplay.h"
|
||||
#include "libgimp/color_display.h"
|
||||
#include "gdisplayF.h"
|
||||
|
||||
void gdisplay_color_init (void);
|
||||
void gdisplay_color_attach (GDisplay *gdisp,
|
||||
const char *name);
|
||||
void gdisplay_color_detach (GDisplay *gdisp);
|
||||
typedef struct _ColorDisplayNode ColorDisplayNode;
|
||||
|
||||
struct _ColorDisplayNode {
|
||||
char *cd_name;
|
||||
gpointer cd_ID;
|
||||
GimpColorDisplayConvert cd_convert;
|
||||
};
|
||||
|
||||
void gdisplay_color_init (void);
|
||||
void gdisplay_color_attach (GDisplay *gdisp,
|
||||
const char *name);
|
||||
void gdisplay_color_detach (GDisplay *gdisp,
|
||||
const char *name);
|
||||
void gdisplay_color_detach_all (GDisplay *gdisp);
|
||||
|
||||
#endif /* __GDISPLAY_COLOR_H__ */
|
||||
|
Reference in New Issue
Block a user