mirror of https://github.com/GNOME/gimp.git
app/disp_callbacks.c app/gimpset.[ch] app/gimpsetP.h applied Simon's
1999-06-02 Michael Natterer <mitschel@cs.tu-berlin.de> * app/disp_callbacks.c * app/gimpset.[ch] * app/gimpsetP.h * app/layers_dialog.c: applied Simon's <Simon.Budig@unix-ag.org> active image patch. GimpSet has an "active_changed" signal now. The image_context emits it whenever there is a button or key event in the gdisplay and the L&C dlg. connects to it for the new auto-update feature.
This commit is contained in:
parent
01a045a4c8
commit
e785fa4cda
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
1999-06-02 Michael Natterer <mitschel@cs.tu-berlin.de>
|
||||
|
||||
* app/disp_callbacks.c
|
||||
* app/gimpset.[ch]
|
||||
* app/gimpsetP.h
|
||||
* app/layers_dialog.c: applied Simon's <Simon.Budig@unix-ag.org>
|
||||
active image patch.
|
||||
GimpSet has an "active_changed" signal now. The image_context
|
||||
emits it whenever there is a button or key event in the gdisplay
|
||||
and the L&C dlg. connects to it for the new auto-update feature.
|
||||
|
||||
1999-06-01 Michael Natterer <mitschel@cs.tu-berlin.de>
|
||||
|
||||
* app/commands.[ch]
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "gdisplay.h"
|
||||
#include "general.h"
|
||||
#include "gimprc.h"
|
||||
#include "gimpset.h"
|
||||
#include "interface.h"
|
||||
#include "layer_select.h"
|
||||
#include "move.h"
|
||||
|
@ -196,6 +197,9 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
bevent = (GdkEventButton *) event;
|
||||
state = bevent->state;
|
||||
|
||||
/* Set the active Image to the image where the user clicked */
|
||||
gimp_set_set_active(image_context, gdisp->gimage);
|
||||
|
||||
switch (bevent->button)
|
||||
{
|
||||
case 1:
|
||||
|
@ -384,6 +388,9 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
kevent = (GdkEventKey *) event;
|
||||
state = kevent->state;
|
||||
|
||||
/* Set the active Image to the image where the user typed */
|
||||
gimp_set_set_active(image_context, gdisp->gimage);
|
||||
|
||||
switch (kevent->keyval)
|
||||
{
|
||||
case GDK_Left: case GDK_Right:
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "gdisplay.h"
|
||||
#include "general.h"
|
||||
#include "gimprc.h"
|
||||
#include "gimpset.h"
|
||||
#include "interface.h"
|
||||
#include "layer_select.h"
|
||||
#include "move.h"
|
||||
|
@ -196,6 +197,9 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
bevent = (GdkEventButton *) event;
|
||||
state = bevent->state;
|
||||
|
||||
/* Set the active Image to the image where the user clicked */
|
||||
gimp_set_set_active(image_context, gdisp->gimage);
|
||||
|
||||
switch (bevent->button)
|
||||
{
|
||||
case 1:
|
||||
|
@ -384,6 +388,9 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
kevent = (GdkEventKey *) event;
|
||||
state = kevent->state;
|
||||
|
||||
/* Set the active Image to the image where the user typed */
|
||||
gimp_set_set_active(image_context, gdisp->gimage);
|
||||
|
||||
switch (kevent->keyval)
|
||||
{
|
||||
case GDK_Left: case GDK_Right:
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "gdisplay.h"
|
||||
#include "general.h"
|
||||
#include "gimprc.h"
|
||||
#include "gimpset.h"
|
||||
#include "interface.h"
|
||||
#include "layer_select.h"
|
||||
#include "move.h"
|
||||
|
@ -196,6 +197,9 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
bevent = (GdkEventButton *) event;
|
||||
state = bevent->state;
|
||||
|
||||
/* Set the active Image to the image where the user clicked */
|
||||
gimp_set_set_active(image_context, gdisp->gimage);
|
||||
|
||||
switch (bevent->button)
|
||||
{
|
||||
case 1:
|
||||
|
@ -384,6 +388,9 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
kevent = (GdkEventKey *) event;
|
||||
state = kevent->state;
|
||||
|
||||
/* Set the active Image to the image where the user typed */
|
||||
gimp_set_set_active(image_context, gdisp->gimage);
|
||||
|
||||
switch (kevent->keyval)
|
||||
{
|
||||
case GDK_Left: case GDK_Right:
|
||||
|
|
|
@ -20,6 +20,7 @@ enum
|
|||
{
|
||||
ADD,
|
||||
REMOVE,
|
||||
ACTIVE_CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
@ -53,6 +54,7 @@ gimp_set_init (GimpSet* set)
|
|||
set->list=NULL;
|
||||
set->type=GTK_TYPE_OBJECT;
|
||||
set->handlers=g_array_new(FALSE, FALSE, sizeof(GimpSetHandler));
|
||||
set->active_element=NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -69,6 +71,8 @@ gimp_set_class_init (GimpSetClass* klass)
|
|||
gimp_signal_new ("add", GTK_RUN_FIRST, type, 0, gimp_sigtype_pointer);
|
||||
gimp_set_signals[REMOVE]=
|
||||
gimp_signal_new ("remove", GTK_RUN_FIRST, type, 0, gimp_sigtype_pointer);
|
||||
gimp_set_signals[ACTIVE_CHANGED]=
|
||||
gimp_signal_new ("active_changed", GTK_RUN_FIRST, type, 0, gimp_sigtype_pointer);
|
||||
gtk_object_class_add_signals (object_class,
|
||||
gimp_set_signals,
|
||||
LAST_SIGNAL);
|
||||
|
@ -222,6 +226,24 @@ gimp_set_type (GimpSet* set){
|
|||
return set->type;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_set_set_active (GimpSet* set, gpointer ob)
|
||||
{
|
||||
if (ob != set->active_element && gimp_set_have(set, ob)) {
|
||||
/* g_warning("Gimp_Set got new active element"); */
|
||||
set->active_element = ob;
|
||||
gtk_signal_emit (GTK_OBJECT(set), gimp_set_signals[ACTIVE_CHANGED], ob);
|
||||
}
|
||||
}
|
||||
|
||||
gpointer
|
||||
gimp_set_get_active(GimpSet* set)
|
||||
{
|
||||
if (gimp_set_have(set, set->active_element))
|
||||
return set->active_element;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GimpSetHandlerId
|
||||
gimp_set_add_handler(GimpSet* set, const gchar* signame,
|
||||
GtkSignalFunc handler, gpointer user_data){
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
/* Signals:
|
||||
add
|
||||
remove
|
||||
member_modified
|
||||
active_changed
|
||||
*/
|
||||
|
||||
typedef guint GimpSetHandlerId;
|
||||
|
@ -43,6 +43,9 @@ void gimp_set_foreach(GimpSet* gimpset, GFunc func,
|
|||
gpointer user_data);
|
||||
gint gimp_set_size (GimpSet* gimpset);
|
||||
|
||||
void gimp_set_set_active(GimpSet* gimpset, gpointer ob);
|
||||
gpointer gimp_set_get_active(GimpSet* gimpset);
|
||||
|
||||
GimpSetHandlerId gimp_set_add_handler (GimpSet* set,
|
||||
const gchar* signame,
|
||||
GtkSignalFunc handler,
|
||||
|
|
|
@ -10,6 +10,7 @@ struct _GimpSet{
|
|||
GSList* list;
|
||||
GArray* handlers;
|
||||
gboolean weak;
|
||||
gpointer active_element;
|
||||
};
|
||||
|
||||
struct _GimpSetClass{
|
||||
|
|
|
@ -104,6 +104,7 @@ struct _LayersDialog {
|
|||
GimpImage* gimage;
|
||||
Layer * active_layer;
|
||||
Channel * active_channel;
|
||||
gboolean auto_follow_active;
|
||||
Layer * floating_sel;
|
||||
GSList * layer_widgets;
|
||||
};
|
||||
|
@ -172,9 +173,11 @@ static void layers_dialog_flatten_image_callback (GtkWidget *, gpointer);
|
|||
static void layers_dialog_alpha_select_callback (GtkWidget *, gpointer);
|
||||
static void layers_dialog_mask_select_callback (GtkWidget *, gpointer);
|
||||
static void layers_dialog_add_alpha_channel_callback (GtkWidget *, gpointer);
|
||||
static gint lc_dialog_auto_callback (GtkWidget *, gpointer);
|
||||
static gint lc_dialog_close_callback (GtkWidget *, gpointer);
|
||||
|
||||
static void lc_dialog_update_cb (GimpSet *, GimpImage *, gpointer);
|
||||
static void lc_dialog_change_image (GimpSet *, GimpImage *, gpointer);
|
||||
|
||||
/* layer widget function prototypes */
|
||||
static LayerWidget *layer_widget_get_ID (Layer *);
|
||||
|
@ -314,6 +317,7 @@ void
|
|||
lc_dialog_create (GimpImage* gimage)
|
||||
{
|
||||
GtkWidget *util_box;
|
||||
GtkWidget *auto_button;
|
||||
GtkWidget *button;
|
||||
GtkWidget *label;
|
||||
GtkWidget *notebook;
|
||||
|
@ -363,6 +367,16 @@ lc_dialog_create (GimpImage* gimage)
|
|||
gtk_option_menu_set_history (GTK_OPTION_MENU (image_option_menu), default_index);
|
||||
gtk_widget_show (label);
|
||||
|
||||
/* The Auto-button */
|
||||
|
||||
auto_button = gtk_toggle_button_new_with_label (_("Auto"));
|
||||
gtk_box_pack_start (GTK_BOX (util_box), auto_button, FALSE, FALSE, 2);
|
||||
gtk_signal_connect_object (GTK_OBJECT (auto_button), "clicked",
|
||||
(GtkSignalFunc) lc_dialog_auto_callback,
|
||||
GTK_OBJECT(auto_button));
|
||||
gtk_widget_show (auto_button);
|
||||
/* State will be set, when LayersD exists (see below) */
|
||||
|
||||
gtk_widget_show (util_box);
|
||||
|
||||
separator = gtk_hseparator_new ();
|
||||
|
@ -379,6 +393,10 @@ lc_dialog_create (GimpImage* gimage)
|
|||
label);
|
||||
gtk_widget_show (label);
|
||||
|
||||
/* Now layersD exists, we can set the Auto-togglebutton */
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (auto_button),
|
||||
layersD->auto_follow_active);
|
||||
|
||||
label = gtk_label_new (_("Channels"));
|
||||
gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
|
||||
channels_dialog_create (),
|
||||
|
@ -424,6 +442,8 @@ lc_dialog_create (GimpImage* gimage)
|
|||
GTK_SIGNAL_FUNC (lc_dialog_update_cb), NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (image_context), "remove",
|
||||
GTK_SIGNAL_FUNC(lc_dialog_update_cb), NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (image_context), "active_changed",
|
||||
GTK_SIGNAL_FUNC(lc_dialog_change_image), NULL);
|
||||
|
||||
layers_dialog_update (gimage);
|
||||
channels_dialog_update (gimage);
|
||||
|
@ -1988,6 +2008,16 @@ layers_dialog_add_alpha_channel_callback (GtkWidget *w,
|
|||
}
|
||||
|
||||
|
||||
static gint
|
||||
lc_dialog_auto_callback (GtkWidget *toggle_button, gpointer client_data)
|
||||
{
|
||||
if (layersD)
|
||||
layersD->auto_follow_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle_button));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static gint
|
||||
lc_dialog_close_callback (GtkWidget *w,
|
||||
gpointer client_data)
|
||||
|
@ -2010,6 +2040,21 @@ lc_dialog_update_cb (GimpSet *set,
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
lc_dialog_change_image (GimpSet *set,
|
||||
GimpImage *gimage,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (layersD && layersD->auto_follow_active && gimage) {
|
||||
layers_dialog_update (gimage);
|
||||
channels_dialog_update (gimage);
|
||||
paths_dialog_update (gimage);
|
||||
lc_dialog_update_image_list ();
|
||||
gdisplays_flush ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************/
|
||||
/* layer widget functions */
|
||||
/****************************/
|
||||
|
|
|
@ -104,6 +104,7 @@ struct _LayersDialog {
|
|||
GimpImage* gimage;
|
||||
Layer * active_layer;
|
||||
Channel * active_channel;
|
||||
gboolean auto_follow_active;
|
||||
Layer * floating_sel;
|
||||
GSList * layer_widgets;
|
||||
};
|
||||
|
@ -172,9 +173,11 @@ static void layers_dialog_flatten_image_callback (GtkWidget *, gpointer);
|
|||
static void layers_dialog_alpha_select_callback (GtkWidget *, gpointer);
|
||||
static void layers_dialog_mask_select_callback (GtkWidget *, gpointer);
|
||||
static void layers_dialog_add_alpha_channel_callback (GtkWidget *, gpointer);
|
||||
static gint lc_dialog_auto_callback (GtkWidget *, gpointer);
|
||||
static gint lc_dialog_close_callback (GtkWidget *, gpointer);
|
||||
|
||||
static void lc_dialog_update_cb (GimpSet *, GimpImage *, gpointer);
|
||||
static void lc_dialog_change_image (GimpSet *, GimpImage *, gpointer);
|
||||
|
||||
/* layer widget function prototypes */
|
||||
static LayerWidget *layer_widget_get_ID (Layer *);
|
||||
|
@ -314,6 +317,7 @@ void
|
|||
lc_dialog_create (GimpImage* gimage)
|
||||
{
|
||||
GtkWidget *util_box;
|
||||
GtkWidget *auto_button;
|
||||
GtkWidget *button;
|
||||
GtkWidget *label;
|
||||
GtkWidget *notebook;
|
||||
|
@ -363,6 +367,16 @@ lc_dialog_create (GimpImage* gimage)
|
|||
gtk_option_menu_set_history (GTK_OPTION_MENU (image_option_menu), default_index);
|
||||
gtk_widget_show (label);
|
||||
|
||||
/* The Auto-button */
|
||||
|
||||
auto_button = gtk_toggle_button_new_with_label (_("Auto"));
|
||||
gtk_box_pack_start (GTK_BOX (util_box), auto_button, FALSE, FALSE, 2);
|
||||
gtk_signal_connect_object (GTK_OBJECT (auto_button), "clicked",
|
||||
(GtkSignalFunc) lc_dialog_auto_callback,
|
||||
GTK_OBJECT(auto_button));
|
||||
gtk_widget_show (auto_button);
|
||||
/* State will be set, when LayersD exists (see below) */
|
||||
|
||||
gtk_widget_show (util_box);
|
||||
|
||||
separator = gtk_hseparator_new ();
|
||||
|
@ -379,6 +393,10 @@ lc_dialog_create (GimpImage* gimage)
|
|||
label);
|
||||
gtk_widget_show (label);
|
||||
|
||||
/* Now layersD exists, we can set the Auto-togglebutton */
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (auto_button),
|
||||
layersD->auto_follow_active);
|
||||
|
||||
label = gtk_label_new (_("Channels"));
|
||||
gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
|
||||
channels_dialog_create (),
|
||||
|
@ -424,6 +442,8 @@ lc_dialog_create (GimpImage* gimage)
|
|||
GTK_SIGNAL_FUNC (lc_dialog_update_cb), NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (image_context), "remove",
|
||||
GTK_SIGNAL_FUNC(lc_dialog_update_cb), NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (image_context), "active_changed",
|
||||
GTK_SIGNAL_FUNC(lc_dialog_change_image), NULL);
|
||||
|
||||
layers_dialog_update (gimage);
|
||||
channels_dialog_update (gimage);
|
||||
|
@ -1988,6 +2008,16 @@ layers_dialog_add_alpha_channel_callback (GtkWidget *w,
|
|||
}
|
||||
|
||||
|
||||
static gint
|
||||
lc_dialog_auto_callback (GtkWidget *toggle_button, gpointer client_data)
|
||||
{
|
||||
if (layersD)
|
||||
layersD->auto_follow_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle_button));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static gint
|
||||
lc_dialog_close_callback (GtkWidget *w,
|
||||
gpointer client_data)
|
||||
|
@ -2010,6 +2040,21 @@ lc_dialog_update_cb (GimpSet *set,
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
lc_dialog_change_image (GimpSet *set,
|
||||
GimpImage *gimage,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (layersD && layersD->auto_follow_active && gimage) {
|
||||
layers_dialog_update (gimage);
|
||||
channels_dialog_update (gimage);
|
||||
paths_dialog_update (gimage);
|
||||
lc_dialog_update_image_list ();
|
||||
gdisplays_flush ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************/
|
||||
/* layer widget functions */
|
||||
/****************************/
|
||||
|
|
Loading…
Reference in New Issue