Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 521308 | Differences between
and this patch

Collapse All | Expand All

(-)a/src/org/eclipse/swt/widgets/Combo.java (-37 / +66 lines)
Lines 341-347 void clearText () { Link Here
341
341
342
public Point computeSize (int wHint, int hHint, boolean changed) {
342
public Point computeSize (int wHint, int hHint, boolean changed) {
343
	checkWidget ();
343
	checkWidget ();
344
	if ((style & SWT.READ_ONLY) != 0 || menuHandle != 0) {
344
	if ((style & SWT.READ_ONLY) != 0) {
345
		return computeNativeSize (handle, wHint, hHint, changed);
345
		return computeNativeSize (handle, wHint, hHint, changed);
346
	}
346
	}
347
	if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
347
	if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
Lines 441-448 void createHandle (int index) { Link Here
441
	if (OS.GTK_VERSION < OS.VERSION (2, 8, 0)) {
441
	if (OS.GTK_VERSION < OS.VERSION (2, 8, 0)) {
442
		OS.gtk_widget_size_request(handle, new GtkRequisition());
442
		OS.gtk_widget_size_request(handle, new GtkRequisition());
443
	}
443
	}
444
	if (popupHandle != 0) findMenuHandle ();
444
        menuHandle = findMenuHandle ();
445
	findButtonHandle ();
445
        if (menuHandle != 0) OS.g_object_ref (menuHandle);
446
        buttonHandle = findButtonHandle ();
447
        if (buttonHandle != 0) OS.g_object_ref (buttonHandle);
446
	/*
448
	/*
447
	* Feature in GTK. By default, read only combo boxes 
449
	* Feature in GTK. By default, read only combo boxes 
448
	* process the RETURN key rather than allowing the 
450
	* process the RETURN key rather than allowing the 
Lines 526-532 long /*int*/ findPopupHandle (long /*int Link Here
526
}
528
}
527
529
528
530
529
void findButtonHandle() {
531
long /*int*/ findButtonHandle() {
530
	/*
532
	/*
531
	* Feature in GTK.  There is no API to query the button
533
	* Feature in GTK.  There is no API to query the button
532
	* handle from a combo box although it is possible to get the
534
	* handle from a combo box although it is possible to get the
Lines 534-565 void findButtonHandle() { Link Here
534
	* fix is to walk the combo tree and find the first child that is 
536
	* fix is to walk the combo tree and find the first child that is 
535
	* an instance of button.
537
	* an instance of button.
536
	*/
538
	*/
539
        long /*int*/ result = 0;
537
	OS.gtk_container_forall (handle, display.allChildrenProc, 0);
540
	OS.gtk_container_forall (handle, display.allChildrenProc, 0);
538
	if (display.allChildren != 0) {
541
	if (display.allChildren != 0) {
539
		long /*int*/ list = display.allChildren;
542
		long /*int*/ list = display.allChildren;
540
		while (list != 0) {
543
		while (list != 0) {
541
			long /*int*/ widget = OS.g_list_data (list);
544
			long /*int*/ widget = OS.g_list_data (list);
542
			if (OS.GTK_IS_BUTTON (widget)) {
545
			if (OS.GTK_IS_BUTTON (widget)) {
543
				buttonHandle = widget;
546
                                result = widget;
544
                OS.g_object_ref (buttonHandle);
545
				break;
547
				break;
546
			}
548
			}
547
			list = OS.g_list_next (list);
548
		}
549
		}
549
		OS.g_list_free (display.allChildren);
550
		OS.g_list_free (display.allChildren);
550
		display.allChildren = 0;
551
		display.allChildren = 0;
551
	}
552
	}
553
        return result;
552
}
554
}
553
555
554
void findMenuHandle() {
556
long /*int*/ findMenuHandle() {
557
        if (popupHandle == 0) return 0;
558
        long /*int*/ result = 0;
555
	OS.gtk_container_forall (popupHandle, display.allChildrenProc, 0);
559
	OS.gtk_container_forall (popupHandle, display.allChildrenProc, 0);
556
	if (display.allChildren != 0) {
560
	if (display.allChildren != 0) {
557
	    long /*int*/ list = display.allChildren;
561
	    long /*int*/ list = display.allChildren;
558
		while (list != 0) {
562
		while (list != 0) {
559
                       long /*int*/ widget = OS.g_list_data (list);
563
                       long /*int*/ widget = OS.g_list_data (list);
560
                       if (OS.G_OBJECT_TYPE (widget) == OS.GTK_TYPE_MENU ()) {
564
                       if (OS.G_OBJECT_TYPE (widget) == OS.GTK_TYPE_MENU ()) {
561
                               menuHandle = widget;
565
                               result = widget;
562
                               OS.g_object_ref (menuHandle);
563
                               break;
566
                               break;
564
                       }
567
                       }
565
                       list = OS.g_list_next (list);
568
                       list = OS.g_list_next (list);
Lines 567-572 void findMenuHandle() { Link Here
567
	    OS.g_list_free (display.allChildren);
570
	    OS.g_list_free (display.allChildren);
568
	    display.allChildren = 0;
571
	    display.allChildren = 0;
569
	}
572
	}
573
        return result;
570
}
574
}
571
	
575
	
572
void fixModal (long /*int*/ group, long /*int*/ modalGroup) {
576
void fixModal (long /*int*/ group, long /*int*/ modalGroup) {
Lines 607-613 long /*int*/ fontHandle () { Link Here
607
}
611
}
608
612
609
long /*int*/ focusHandle () {
613
long /*int*/ focusHandle () {
610
	if ((style & SWT.READ_ONLY) != 0 && buttonHandle != 0) return buttonHandle;
611
	if (entryHandle != 0) return entryHandle;
614
	if (entryHandle != 0) return entryHandle;
612
	return super.focusHandle ();
615
	return super.focusHandle ();
613
}
616
}
Lines 629-637 void hookEvents () { Link Here
629
		OS.g_signal_connect_closure (entryHandle, OS.activate, display.closures [ACTIVATE], false);
632
		OS.g_signal_connect_closure (entryHandle, OS.activate, display.closures [ACTIVATE], false);
630
		OS.g_signal_connect_closure (entryHandle, OS.populate_popup, display.closures [POPULATE_POPUP], false);
633
		OS.g_signal_connect_closure (entryHandle, OS.populate_popup, display.closures [POPULATE_POPUP], false);
631
	}
634
	}
632
	int eventMask =	OS.GDK_POINTER_MOTION_MASK | OS.GDK_BUTTON_PRESS_MASK | 
635
 
633
		OS.GDK_BUTTON_RELEASE_MASK;
636
        hookEvents(new long /*int*/ [] {buttonHandle, entryHandle, menuHandle});
634
 	long /*int*/ [] handles = new long /*int*/ [] {buttonHandle, entryHandle, menuHandle};
637
 
638
        long /*int*/ imContext = imContext ();
639
        if (imContext != 0) {
640
                OS.g_signal_connect_closure (imContext, OS.commit, display.closures [COMMIT], false);
641
                int id = OS.g_signal_lookup (OS.commit, OS.gtk_im_context_get_type ());
642
                int blockMask =  OS.G_SIGNAL_MATCH_DATA | OS.G_SIGNAL_MATCH_ID;
643
                OS.g_signal_handlers_block_matched (imContext, blockMask, id, 0, 0, 0, entryHandle);
644
        }
645
}
646
647
void hookEvents(long /*int*/ [] handles) {
648
        int eventMask = OS.GDK_POINTER_MOTION_MASK | OS.GDK_BUTTON_PRESS_MASK | OS.GDK_BUTTON_RELEASE_MASK;
635
	for (int i=0; i<handles.length; i++) {
649
	for (int i=0; i<handles.length; i++) {
636
		long /*int*/ eventHandle = handles [i];
650
		long /*int*/ eventHandle = handles [i];
637
		if (eventHandle != 0) {
651
		if (eventHandle != 0) {
Lines 655-671 void hookEvents () { Link Here
655
			if (eventHandle != focusHandle ()) {
669
			if (eventHandle != focusHandle ()) {
656
				OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [EVENT_AFTER], 0, display.closures [EVENT_AFTER], false);
670
				OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [EVENT_AFTER], 0, display.closures [EVENT_AFTER], false);
657
			}
671
			}
672
                        if (OS.G_OBJECT_TYPE (eventHandle) == OS.GTK_TYPE_MENU ()) {
673
                                OS.g_signal_connect_closure(eventHandle, OS.selection_done, display.closures[SELECTION_DONE], true);
674
                        }
658
		}
675
		}
659
	}
676
	}
660
	long /*int*/ imContext = imContext ();
661
	if (imContext != 0) {
662
		OS.g_signal_connect_closure (imContext, OS.commit, display.closures [COMMIT], false);
663
		int id = OS.g_signal_lookup (OS.commit, OS.gtk_im_context_get_type ());
664
		int blockMask =  OS.G_SIGNAL_MATCH_DATA | OS.G_SIGNAL_MATCH_ID;
665
		OS.g_signal_handlers_block_matched (imContext, blockMask, id, 0, 0, 0, entryHandle);
666
	}
667
	
668
	if (menuHandle != 0) OS.g_signal_connect_closure(menuHandle, OS.selection_done, display.closures[SELECTION_DONE], true);
669
}
677
}
670
678
671
long /*int*/ imContext () {
679
long /*int*/ imContext () {
Lines 1226-1245 long /*int*/ gtk_event_after (long /*int Link Here
1226
	OS.memmove (event, gdkEvent, GdkEvent.sizeof);
1234
	OS.memmove (event, gdkEvent, GdkEvent.sizeof);
1227
	switch (event.type) {
1235
	switch (event.type) {
1228
		case OS.GDK_BUTTON_PRESS: {
1236
		case OS.GDK_BUTTON_PRESS: {
1229
			if (OS.GTK_VERSION < OS.VERSION (2, 8, 0) && !selectionAdded) {
1230
				long /*int*/ grabHandle = OS.gtk_grab_get_current ();
1231
				if (grabHandle != 0) {
1232
					if (OS.G_OBJECT_TYPE (grabHandle) == OS.GTK_TYPE_MENU ()) {
1233
						menuHandle = grabHandle;
1234
						OS.g_object_ref (menuHandle);
1235
						OS.g_signal_connect_closure_by_id (menuHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.closures [BUTTON_RELEASE_EVENT], false);
1236
						OS.g_signal_connect_closure_by_id (menuHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.closures [BUTTON_RELEASE_EVENT_INVERSE], true);
1237
						OS.g_signal_connect_closure (menuHandle, OS.selection_done, display.closures [SELECTION_DONE], false);
1238
						display.addWidget (menuHandle, this);
1239
						selectionAdded = true;
1240
					}
1241
				}
1242
			}
1243
			GdkEventButton gdkEventButton = new GdkEventButton ();
1237
			GdkEventButton gdkEventButton = new GdkEventButton ();
1244
			OS.memmove (gdkEventButton, gdkEvent, GdkEventButton.sizeof);
1238
			OS.memmove (gdkEventButton, gdkEvent, GdkEventButton.sizeof);
1245
			if (gdkEventButton.button == 1) {
1239
			if (gdkEventButton.button == 1) {
Lines 1386-1391 long /*int*/ gtk_selection_done(long /*i Link Here
1386
	}
1380
	}
1387
	return 0;
1381
	return 0;
1388
}
1382
}
1383
1384
long /*int*/ gtk_style_set (long /*int*/ widget, long /*int*/ previousStyle) {
1385
        setButtonHandle (findButtonHandle ());
1386
        setMenuHandle (findMenuHandle ());
1387
        return super.gtk_style_set (widget, previousStyle);
1388
}
1389
1389
/**
1390
/**
1390
 * Searches the receiver's list starting at the first item
1391
 * Searches the receiver's list starting at the first item
1391
 * (index 0) until an item is found that is equal to the 
1392
 * (index 0) until an item is found that is equal to the 
Lines 1726-1731 int setBounds (int x, int y, int width, Link Here
1726
	return super.setBounds (x, y, width, newHeight, move, resize);
1727
	return super.setBounds (x, y, width, newHeight, move, resize);
1727
}
1728
}
1728
1729
1730
void setButtonHandle (long /*int*/ widget) {
1731
        if (buttonHandle == widget) return;
1732
        if (buttonHandle != 0) {
1733
                display.removeWidget (buttonHandle);
1734
                OS.g_object_unref (buttonHandle);
1735
        }
1736
        buttonHandle = widget;
1737
        if (buttonHandle != 0) {
1738
                OS.g_object_ref (buttonHandle);
1739
                display.addWidget (buttonHandle, this);
1740
                hookEvents (new long /*int*/[]{buttonHandle});
1741
        }
1742
}
1743
 
1744
void setMenuHandle (long /*int*/ widget) {
1745
        if (menuHandle == widget) return;
1746
        if (menuHandle != 0) {
1747
                display.removeWidget (menuHandle);
1748
                OS.g_object_unref (menuHandle);
1749
        }
1750
        menuHandle = widget;
1751
        if (menuHandle != 0) {
1752
                OS.g_object_ref (menuHandle);
1753
                display.addWidget (menuHandle, this);
1754
                hookEvents (new long /*int*/[]{menuHandle});
1755
        }
1756
}
1757
1729
void setFontDescription (long /*int*/ font) {
1758
void setFontDescription (long /*int*/ font) {
1730
	super.setFontDescription (font);
1759
	super.setFontDescription (font);
1731
	if (entryHandle != 0) OS.gtk_widget_modify_font (entryHandle, font);
1760
	if (entryHandle != 0) OS.gtk_widget_modify_font (entryHandle, font);

Return to bug 521308