Fix for Checkbox states.
2003-12-08 Kim Ho <kho@redhat.com> Fix for Checkbox states. * gnu/java/awt/peer/gtk/GtkCheckboxPeer.java: (currentState): New field. (nativeCreate): Add initial state parameter. (create): Changed to reflect new parameter. (setState): Fire only on changed states. (postItemEvent): Fire only on changed states. Also change the Java Checkbox to reflect new state. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c: (nativeCreate): Add parameter and set active state. From-SVN: r74459
This commit is contained in:
parent
7dd8177fc7
commit
bc67c73d4a
3 changed files with 38 additions and 8 deletions
|
@ -1,3 +1,16 @@
|
||||||
|
2003-12-08 Kim Ho <kho@redhat.com>
|
||||||
|
|
||||||
|
Fix for Checkbox states.
|
||||||
|
* gnu/java/awt/peer/gtk/GtkCheckboxPeer.java:
|
||||||
|
(currentState): New field.
|
||||||
|
(nativeCreate): Add initial state parameter.
|
||||||
|
(create): Changed to reflect new parameter.
|
||||||
|
(setState): Fire only on changed states.
|
||||||
|
(postItemEvent): Fire only on changed states. Also change the
|
||||||
|
Java Checkbox to reflect new state.
|
||||||
|
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c:
|
||||||
|
(nativeCreate): Add parameter and set active state.
|
||||||
|
|
||||||
2003-12-08 Fernando Nasser <fnasser@redhat.com>
|
2003-12-08 Fernando Nasser <fnasser@redhat.com>
|
||||||
|
|
||||||
* java/awt/datatransfer/StringSelection.java (getTransferData): Return
|
* java/awt/datatransfer/StringSelection.java (getTransferData): Return
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* GtkCheckboxPeer.java -- Implements CheckboxPeer with GTK
|
/* GtkCheckboxPeer.java -- Implements CheckboxPeer with GTK
|
||||||
Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc.
|
Copyright (C) 1998, 1999, 2002, 2003 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of GNU Classpath.
|
This file is part of GNU Classpath.
|
||||||
|
|
||||||
|
@ -48,8 +48,11 @@ public class GtkCheckboxPeer extends GtkComponentPeer
|
||||||
{
|
{
|
||||||
// Group from last time it was set.
|
// Group from last time it was set.
|
||||||
public GtkCheckboxGroupPeer old_group;
|
public GtkCheckboxGroupPeer old_group;
|
||||||
|
// The current state of the GTK checkbox.
|
||||||
|
private boolean currentState;
|
||||||
|
|
||||||
public native void nativeCreate (GtkCheckboxGroupPeer group);
|
public native void nativeCreate (GtkCheckboxGroupPeer group,
|
||||||
|
boolean state);
|
||||||
public native void nativeSetCheckboxGroup (GtkCheckboxGroupPeer group);
|
public native void nativeSetCheckboxGroup (GtkCheckboxGroupPeer group);
|
||||||
public native void connectHooks ();
|
public native void connectHooks ();
|
||||||
|
|
||||||
|
@ -66,12 +69,14 @@ public class GtkCheckboxPeer extends GtkComponentPeer
|
||||||
{
|
{
|
||||||
CheckboxGroup g = ((Checkbox) awtComponent).getCheckboxGroup ();
|
CheckboxGroup g = ((Checkbox) awtComponent).getCheckboxGroup ();
|
||||||
old_group = GtkCheckboxGroupPeer.getCheckboxGroupPeer (g);
|
old_group = GtkCheckboxGroupPeer.getCheckboxGroupPeer (g);
|
||||||
nativeCreate (old_group);
|
currentState = ((Checkbox)awtComponent).getState();
|
||||||
|
nativeCreate (old_group, currentState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setState (boolean state)
|
public void setState (boolean state)
|
||||||
{
|
{
|
||||||
set ("active", state);
|
if (currentState != state)
|
||||||
|
set ("active", state);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLabel (String label)
|
public void setLabel (String label)
|
||||||
|
@ -103,7 +108,19 @@ public class GtkCheckboxPeer extends GtkComponentPeer
|
||||||
// need information that we have.
|
// need information that we have.
|
||||||
public void postItemEvent (Object item, int stateChange)
|
public void postItemEvent (Object item, int stateChange)
|
||||||
{
|
{
|
||||||
super.postItemEvent (awtComponent, stateChange);
|
Checkbox currentCheckBox = ((Checkbox)awtComponent);
|
||||||
|
// A firing of the event is only desired if the state has changed due to a
|
||||||
|
// button press. The currentCheckBox's state must be different from the
|
||||||
|
// one that the stateChange is changing to.
|
||||||
|
// stateChange = 1 if it goes from false -> true
|
||||||
|
// stateChange = 2 if it goes from true -> false
|
||||||
|
if (( !currentCheckBox.getState() && stateChange == 1)
|
||||||
|
|| (currentCheckBox.getState() && stateChange == 2))
|
||||||
|
{
|
||||||
|
super.postItemEvent (awtComponent, stateChange);
|
||||||
|
currentState = !currentCheckBox.getState();
|
||||||
|
currentCheckBox.setState(currentState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose ()
|
public void dispose ()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* gtkcheckboxpeer.c -- Native implementation of GtkCheckboxPeer
|
/* gtkcheckboxpeer.c -- Native implementation of GtkCheckboxPeer
|
||||||
Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc.
|
Copyright (C) 1998, 1999, 2002, 2003 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of GNU Classpath.
|
This file is part of GNU Classpath.
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer_remove
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_nativeCreate
|
Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_nativeCreate
|
||||||
(JNIEnv *env, jobject obj, jobject group)
|
(JNIEnv *env, jobject obj, jobject group, jboolean state)
|
||||||
{
|
{
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_nativeCreate
|
||||||
NSA_SET_PTR (env, group, button);
|
NSA_SET_PTR (env, group, button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), state);
|
||||||
gdk_threads_leave ();
|
gdk_threads_leave ();
|
||||||
|
|
||||||
NSA_SET_PTR (env, obj, button);
|
NSA_SET_PTR (env, obj, button);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue