1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
/* gap_navi_activtable.c
* 2002.04.21 hof (Wolfgang Hofer)
*
* GAP ... Gimp Animation Plugins
*
*/
#include "libgimp/gimp.h"
#include "gap_navi_activtable.h"
typedef struct t_gap_activdata {
gint32 pid;
gint32 old_image_id;
gint32 new_image_id;
} t_gap_activdata;
extern int gap_debug; /* ==0 ... dont print debug infos */
#define GAP_NAVID_ACTIVE_IMAGE "plug_in_gap_navid_ACTIVE_IMAGETABLE"
/* ============================================================================
* gap_navat_update_active_image
* update activ_image table.
* - is usually called in gap_lib at change of the current frame.
* - The activ_image table contains all the active_images for all
* open navigator dialogs. (currently 1 or 0 entries)
* ============================================================================
*/
/* revision history:
* 1.3.5a; 2002/04/21 hof: created (Handle Event: active_image changed id)
*/
void
gap_navat_update_active_image(gint32 old_image_id, gint32 new_image_id)
{
gint32 l_idx;
gint32 l_activsize;
gint32 l_nactivs;
t_gap_activdata *l_activtab;
/* update activtable (all records that match old_image_id) */
l_activsize = gimp_get_data_size (GAP_NAVID_ACTIVE_IMAGE);
if (l_activsize > 0)
{
l_nactivs = l_activsize / (sizeof(t_gap_activdata));
l_activtab = g_new(t_gap_activdata, l_nactivs);
gimp_get_data (GAP_NAVID_ACTIVE_IMAGE, l_activtab);
for(l_idx=0; l_idx < l_nactivs; l_idx++)
{
if(l_activtab[l_idx].old_image_id == old_image_id)
{
l_activtab[l_idx].new_image_id = new_image_id;
gimp_set_data(GAP_NAVID_ACTIVE_IMAGE, l_activtab, l_nactivs * sizeof(t_gap_activdata));
}
}
g_free(l_activtab);
}
} /* end gap_navat_update_active_image */
/* ============================================================================
* gap_navat_set_active_image
* set active image for one (Navigator) Process in the activ_image table.
* ============================================================================
*/
void
gap_navat_set_active_image(gint32 image_id, gint32 pid)
{
gint32 l_idx;
gint32 l_activsize;
gint32 l_nactivs;
gint32 l_nactivs_old;
t_gap_activdata *l_activtab;
/* check activtable for empty records */
l_activsize = gimp_get_data_size (GAP_NAVID_ACTIVE_IMAGE);
if (l_activsize > 0)
{
l_nactivs_old = l_activsize / (sizeof(t_gap_activdata));
l_nactivs = l_nactivs_old + 1;
l_activtab = g_new(t_gap_activdata, l_nactivs);
gimp_get_data (GAP_NAVID_ACTIVE_IMAGE, l_activtab);
for(l_idx=0; l_idx < l_nactivs_old; l_idx++)
{
if (l_activtab[l_idx].pid == pid)
{
l_nactivs--;
break;
}
}
}
else
{
/* create a new tab with 1 entry */
l_nactivs = 1;
l_idx = 0;
l_activtab = g_new(t_gap_activdata, l_nactivs);
}
l_activtab[l_idx].old_image_id = image_id;
l_activtab[l_idx].new_image_id = image_id;
l_activtab[l_idx].pid = pid;
gimp_set_data(GAP_NAVID_ACTIVE_IMAGE, l_activtab, l_nactivs * sizeof(t_gap_activdata));
g_free(l_activtab);
} /* end gap_navat_set_active_image */
/* ============================================================================
* gap_navat_get_active_image
* get new_image_id for the active image (image_id)
* for one (Navigator) Process in the activ_image table.
* - If the table has information about a change of the old active image_id,
* the new_image_id is returned
* - If the old active image_id is found in the table, but still is
* the same (as new_image_id) then -1 is returned.
* - If the active_image table is empty
* the input image_id is retuned.
* ============================================================================
*/
gint32
gap_navat_get_active_image(gint32 image_id, gint32 pid)
{
gint32 l_idx;
gint32 l_activsize;
gint32 l_nactivs;
gint32 l_new_image_id;
t_gap_activdata *l_activtab;
l_new_image_id = image_id;
/* check activtable for empty records */
l_activsize = gimp_get_data_size (GAP_NAVID_ACTIVE_IMAGE);
if (l_activsize > 0)
{
l_nactivs = l_activsize / (sizeof(t_gap_activdata));
l_activtab = g_new(t_gap_activdata, l_nactivs);
gimp_get_data (GAP_NAVID_ACTIVE_IMAGE, l_activtab);
for(l_idx=0; l_idx < l_nactivs; l_idx++)
{
if ((l_activtab[l_idx].pid == pid)
&& (l_activtab[l_idx].old_image_id == image_id))
{
if(l_activtab[l_idx].new_image_id == image_id)
{
l_new_image_id = -1;
}
else
{
l_new_image_id = l_activtab[l_idx].new_image_id;
}
break;
}
}
g_free(l_activtab);
}
return (l_new_image_id);
} /* end gap_navat_get_active_image */
|