*** disp_callbacks.c.orig Sat Jan 30 01:48:55 1999 --- disp_callbacks.c Sat Jan 30 01:52:58 1999 *************** *** 180,185 **** --- 180,187 ---- bevent = (GdkEventButton *) event; state = bevent->state; + gimage_set_active(gdisp->gimage); + switch (bevent->button) { case 1: *************** *** 357,362 **** --- 359,366 ---- case GDK_KEY_PRESS: kevent = (GdkEventKey *) event; state = kevent->state; + + gimage_set_active(gdisp->gimage); switch (kevent->keyval) { *** gimage.c.orig Sat Jan 30 00:42:41 1999 --- gimage.c Sat Jan 30 03:08:16 1999 *************** *** 65,70 **** --- 65,147 ---- return pdb_id_to_image(ID); } + /* Here we go. This is the first attempt to add a "active image"-concept + to the Gimp. Simon.Budig@unix-ag.org */ + + /* currently there is no visible indicator for the active image in the + UI. Maybe an indicator in the bottom right edge (between the scrollbars)? + or changing colors of the scrollbars? */ + + /* If the active image is closed - should the "active image"-pointer + move to another currently open image with display? Im not sure... + To detect it it is possible to add a callback a la + gtk_signal_connect (GTK_OBJECT (image_context), "remove", + GTK_SIGNAL_FUNC(gimage_get_active_update_cb), NULL); + */ + + /* I think it may be a good idea to make the active image changeable with + the L&C-Dialog (the topmost button). IMHO it could be good too, to change + the Display of the L&C-Dialog according to the active image. (Maybe + preferences setting? */ + + /* Is it useful to export the gimage_set_active() - function too? IMHO this + should be a clear GUI thing, but maybe there is a useful possibility? */ + + /* I have no idea how to make gimage_get_active_ID() a libgimp-function. + IMHO it should be in there... */ + + /* This is global - no idea where to put it. */ + static GImage* gimp_image_active=NULL; + + GImage* + gimage_get_active (void) + { + if (gimp_image_active != NULL + && gimp_set_have(image_context, gimp_image_active)) + return gimp_image_active; + else + /* It is necessary to check if there is an active image! */ + return NULL; + } + + gint + gimage_get_active_ID (void) + { + if (gimp_image_active != NULL + && gimp_set_have(image_context, gimp_image_active)) + return pdb_image_to_id(gimp_image_active); + else + return -1; + + /* Shorter, but does rely on gtk_get_object_data(NULL, "pdb_id")==NULL + btw. the pdb-ids doesnt seem to be correctly initialized??? + + return pdb_image_to_id(gimage_get_active()); + */ + } + + gboolean + gimage_set_active (GImage* gimage) + { + if (gimage != NULL && gimp_set_have(image_context, gimage)) { + gimp_image_active = gimage; + g_warning("active image set to %d.", pdb_image_to_id(gimp_image_active)); + + /* Any code to update the displays goes here */ + + return TRUE; + } else + return FALSE; + } + + gboolean + gimage_set_active_ID (gint ID) + { + return gimage_set_active(gimage_get_ID(ID)); + } + + /* End of "active image" stuff */ + /* Ack! GImages have their own ref counts! This is going to cause trouble.. It should be pretty easy to convert to proper GtkObject *** gimage.h.orig Sat Jan 30 00:42:46 1999 --- gimage.h Sat Jan 30 01:32:53 1999 *************** *** 30,35 **** --- 30,45 ---- GImage* gimage_get_ID (gint ID); + /* Here we go. This is the first attempt to add a "active image"-concept + to the Gimp. Simon.Budig@unix-ag.org */ + + GImage* gimage_get_active (void); + gint gimage_get_active_ID (void); + gboolean gimage_set_active (GImage* gimage); + gboolean gimage_set_active_ID (gint ID); + + /* End of "active image" stuff */ + void gimage_delete (GImage *gimage); *** gimage_cmds.c.orig Sat Jan 30 02:12:02 1999 --- gimage_cmds.c Sat Jan 30 02:55:04 1999 *************** *** 133,138 **** --- 133,184 ---- { { gimage_list_images_invoker } }, }; + /************************/ + /* GIMAGE_GET_ACTIVE */ + + static Argument * + gimage_get_active_invoker (Argument *args) + { + Argument *return_args; + + return_args = procedural_db_return_args (&gimage_get_active_proc, TRUE); + + return_args[1].value.pdb_int = gimage_get_active_ID(); + + return return_args; + } + + /* The procedure definition */ + ProcArg gimage_get_active_out_args[] = + { + { PDB_INT32, + "image_id", + "The id of the currently active image" + } + }; + + ProcRecord gimage_get_active_proc = + { + "gimp_image_get_active", + "Returns the currently active image", + "This procedure returns the currently active image. Only useful for gui-oriented plugins", + "Simon Budig", + "Simon Budig", + "1999", + PDB_INTERNAL, + + /* Input arguments */ + 0, + NULL, + + /* Output arguments */ + 1, + gimage_get_active_out_args, + + /* Exec method */ + { { gimage_get_active_invoker } }, + }; + /**********************/ /* GIMAGE_NEW_IMAGE */ *** gimage_cmds.h.orig Sat Jan 30 02:10:07 1999 --- gimage_cmds.h Sat Jan 30 02:10:57 1999 *************** *** 23,28 **** --- 23,29 ---- void channel_ops_duplicate (void *); extern ProcRecord gimage_list_images_proc; + extern ProcRecord gimage_get_active_proc; extern ProcRecord gimage_new_proc; extern ProcRecord gimage_resize_proc; extern ProcRecord gimage_scale_proc; *** internal_procs.c.orig Sat Jan 30 02:29:12 1999 --- internal_procs.c Sat Jan 30 02:30:08 1999 *************** *** 140,145 **** --- 140,146 ---- /* GImage procedures */ procedural_db_register (&gimage_list_images_proc); pcount++; + procedural_db_register (&gimage_get_active_proc); pcount++; procedural_db_register (&gimage_new_proc); pcount++; procedural_db_register (&gimage_resize_proc); pcount++; procedural_db_register (&gimage_scale_proc); pcount++;