diff options
author | Anatoly Spektor <aspektor@redhat.com> | 2012-10-02 14:11:25 -0400 |
---|---|---|
committer | Anatoly Spektor <aspektor@redhat.com> | 2012-10-02 14:11:25 -0400 |
commit | 1491738e69600a08f5e7a1ecbeb4a2853389f014 (patch) | |
tree | 5066a0bac7cc028f847b5260f3dddf5917ef23d7 | |
parent | a1ea264f398a2f293995337738255407e55a15c7 (diff) | |
download | eclipse.platform.swt-gtk3_fontchooser.tar.gz eclipse.platform.swt-gtk3_fontchooser.tar.xz eclipse.platform.swt-gtk3_fontchooser.zip |
Replace GtkFontSelection with GtkFontChooser for GTK+ 3.2 and highergtk3_fontchooser
6 files changed, 176 insertions, 8 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c index 416294629b..731ad24780 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c @@ -9491,13 +9491,87 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1fixed_1set_1has_1window) } #endif +#ifndef NO__1gtk_1font_1chooser_1dialog_1new +JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1font_1chooser_1dialog_1new) + (JNIEnv *env, jclass that, jbyteArray arg0, jintLong arg1) +{ + jbyte *lparg0=NULL; + jintLong rc = 0; + OS_NATIVE_ENTER(env, that, _1gtk_1font_1chooser_1dialog_1new_FUNC); + if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail; +/* + rc = (jintLong)gtk_font_chooser_dialog_new((const gchar *)lparg0, (GtkWindow *)arg1); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_font_chooser_dialog_new) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(const gchar *, GtkWindow *))fp)((const gchar *)lparg0, (GtkWindow *)arg1); + } + } +fail: + if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0); + OS_NATIVE_EXIT(env, that, _1gtk_1font_1chooser_1dialog_1new_FUNC); + return rc; +} +#endif + +#ifndef NO__1gtk_1font_1chooser_1get_1font +JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1font_1chooser_1get_1font) + (JNIEnv *env, jclass that, jintLong arg0) +{ + jintLong rc = 0; + OS_NATIVE_ENTER(env, that, _1gtk_1font_1chooser_1get_1font_FUNC); +/* + rc = (jintLong)gtk_font_chooser_get_font(arg0); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_font_chooser_get_font) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(jintLong))fp)(arg0); + } + } + OS_NATIVE_EXIT(env, that, _1gtk_1font_1chooser_1get_1font_FUNC); + return rc; +} +#endif + +#ifndef NO__1gtk_1font_1chooser_1set_1font +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1font_1chooser_1set_1font) + (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1) +{ + jbyte *lparg1=NULL; + OS_NATIVE_ENTER(env, that, _1gtk_1font_1chooser_1set_1font_FUNC); + if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail; +/* + gtk_font_chooser_set_font(arg0, (const gchar *)lparg1); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_font_chooser_set_font) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, const gchar *))fp)(arg0, (const gchar *)lparg1); + } + } +fail: + if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); + OS_NATIVE_EXIT(env, that, _1gtk_1font_1chooser_1set_1font_FUNC); +} +#endif + #ifndef NO__1gtk_1font_1selection_1dialog_1get_1font_1name JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1font_1selection_1dialog_1get_1font_1name) (JNIEnv *env, jclass that, jintLong arg0) { jintLong rc = 0; OS_NATIVE_ENTER(env, that, _1gtk_1font_1selection_1dialog_1get_1font_1name_FUNC); - rc = (jintLong)gtk_font_selection_dialog_get_font_name((GtkFontSelectionDialog *)arg0); +/* + rc = (jintLong)gtk_font_selection_dialog_get_font_name(arg0); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_font_selection_dialog_get_font_name) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(jintLong))fp)(arg0); + } + } OS_NATIVE_EXIT(env, that, _1gtk_1font_1selection_1dialog_1get_1font_1name_FUNC); return rc; } @@ -9511,7 +9585,15 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1font_1selection_1dialog_1new) jintLong rc = 0; OS_NATIVE_ENTER(env, that, _1gtk_1font_1selection_1dialog_1new_FUNC); if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail; +/* rc = (jintLong)gtk_font_selection_dialog_new((const gchar *)lparg0); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_font_selection_dialog_new) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(const gchar *))fp)((const gchar *)lparg0); + } + } fail: if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0); OS_NATIVE_EXIT(env, that, _1gtk_1font_1selection_1dialog_1new_FUNC); @@ -9527,7 +9609,15 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1font_1selection_1dialog_1set_1font_1 jboolean rc = 0; OS_NATIVE_ENTER(env, that, _1gtk_1font_1selection_1dialog_1set_1font_1name_FUNC); if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail; - rc = (jboolean)gtk_font_selection_dialog_set_font_name((GtkFontSelectionDialog *)arg0, (const gchar *)lparg1); +/* + rc = (jboolean)gtk_font_selection_dialog_set_font_name(arg0, (const gchar *)lparg1); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_font_selection_dialog_set_font_name) + if (fp) { + rc = (jboolean)((jboolean (CALLING_CONVENTION*)(jintLong, const gchar *))fp)(arg0, (const gchar *)lparg1); + } + } fail: if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); OS_NATIVE_EXIT(env, that, _1gtk_1font_1selection_1dialog_1set_1font_1name_FUNC); diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h index afd690ecd4..742f53d659 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h @@ -102,6 +102,12 @@ #define gtk_combo_box_popdown_LIB LIB_GTK #define gtk_entry_text_index_to_layout_index_LIB LIB_GTK #define gtk_entry_get_inner_border_LIB LIB_GTK +#define gtk_font_chooser_dialog_new_LIB LIB_GTK +#define gtk_font_chooser_get_font_LIB LIB_GTK +#define gtk_font_chooser_set_font_LIB LIB_GTK +#define gtk_font_selection_dialog_get_font_name_LIB LIB_GTK +#define gtk_font_selection_dialog_set_font_name_LIB LIB_GTK +#define gtk_font_selection_dialog_new_LIB LIB_GTK #define gtk_file_chooser_add_filter_LIB LIB_GTK #define gtk_file_chooser_dialog_new_LIB LIB_GTK #define gtk_file_chooser_get_current_folder_LIB LIB_GTK diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c index 8356918198..0ff3dee597 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c @@ -724,6 +724,9 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1fixed_1move", "_1gtk_1fixed_1new", "_1gtk_1fixed_1set_1has_1window", + "_1gtk_1font_1chooser_1dialog_1new", + "_1gtk_1font_1chooser_1get_1font", + "_1gtk_1font_1chooser_1set_1font", "_1gtk_1font_1selection_1dialog_1get_1font_1name", "_1gtk_1font_1selection_1dialog_1new", "_1gtk_1font_1selection_1dialog_1set_1font_1name", diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h index b0083a810d..2a3a21ec13 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h @@ -734,6 +734,9 @@ typedef enum { _1gtk_1fixed_1move_FUNC, _1gtk_1fixed_1new_FUNC, _1gtk_1fixed_1set_1has_1window_FUNC, + _1gtk_1font_1chooser_1dialog_1new_FUNC, + _1gtk_1font_1chooser_1get_1font_FUNC, + _1gtk_1font_1chooser_1set_1font_FUNC, _1gtk_1font_1selection_1dialog_1get_1font_1name_FUNC, _1gtk_1font_1selection_1dialog_1new_FUNC, _1gtk_1font_1selection_1dialog_1set_1font_1name_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java index e7230800c2..f9ccf73943 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java @@ -7081,7 +7081,7 @@ public static final void gtk_widget_set_has_window(long /*int*/ widget, boolean lock.unlock(); } } -/** @param fsd cast=(GtkFontSelectionDialog *) */ +/** @method flags=dynamic */ public static final native long /*int*/ _gtk_font_selection_dialog_get_font_name(long /*int*/ fsd); public static final long /*int*/ gtk_font_selection_dialog_get_font_name(long /*int*/ fsd) { lock.lock(); @@ -7091,7 +7091,47 @@ public static final long /*int*/ gtk_font_selection_dialog_get_font_name(long /* lock.unlock(); } } -/** @param title cast=(const gchar *) */ +/** + * @method flags=dynamic + * @param title cast=(const gchar *) + * @param parent cast=(GtkWindow *) + */ +public static final native long /*int*/ _gtk_font_chooser_dialog_new(byte[] title, long /*int*/ parent); +public static final long /*int*/ gtk_font_chooser_dialog_new(byte[] title, long /*int*/ parent) { + lock.lock(); + try { + return _gtk_font_chooser_dialog_new(title, parent); + } finally { + lock.unlock(); + } +} +/** @method flags=dynamic */ +public static final native long /*int*/ _gtk_font_chooser_get_font(long /*int*/ fontchooser); +public static final long /*int*/ gtk_font_chooser_get_font(long /*int*/ fontchooser) { + lock.lock(); + try { + return _gtk_font_chooser_get_font(fontchooser); + } finally { + lock.unlock(); + } +} +/** + * @method flags=dynamic + * @param fontname cast=(const gchar *) + */ +public static final native void _gtk_font_chooser_set_font(long /*int*/ fsd, byte[] fontname); +public static final void gtk_font_chooser_set_font(long /*int*/ fsd, byte[] fontname) { + lock.lock(); + try { + _gtk_font_chooser_set_font(fsd, fontname); + } finally { + lock.unlock(); + } +} +/** + * @method flags=dynamic + * @param title cast=(const gchar *) + */ public static final native long /*int*/ _gtk_font_selection_dialog_new(byte[] title); public static final long /*int*/ gtk_font_selection_dialog_new(byte[] title) { lock.lock(); @@ -7102,7 +7142,7 @@ public static final long /*int*/ gtk_font_selection_dialog_new(byte[] title) { } } /** - * @param fsd cast=(GtkFontSelectionDialog *) + * @method flags=dynamic * @param fontname cast=(const gchar *) */ public static final native boolean _gtk_font_selection_dialog_set_font_name(long /*int*/ fsd, byte[] fontname); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java index 905110d34d..9550665251 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java @@ -155,7 +155,7 @@ public FontData open () { byte [] titleBytes; titleBytes = Converter.wcsToMbcs (null, title, true); Display display = parent != null ? parent.getDisplay (): Display.getCurrent (); - handle = OS.gtk_font_selection_dialog_new (titleBytes); + handle = gtk_font_chooser_dialog_new (titleBytes); if (parent!=null) { long /*int*/ shellHandle = parent.topHandle (); OS.gtk_window_set_transient_for(handle, shellHandle); @@ -178,7 +178,7 @@ public FontData open () { OS.memmove (buffer, fontName, length); font.dispose(); OS.g_free (fontName); - OS.gtk_font_selection_dialog_set_font_name (handle, buffer); + gtk_font_chooser_set_font (handle, buffer); } display.addIdleProc (); Dialog oldModal = null; @@ -208,7 +208,7 @@ public FontData open () { } boolean success = response == OS.GTK_RESPONSE_OK; if (success) { - long /*int*/ fontName = OS.gtk_font_selection_dialog_get_font_name (handle); + long /*int*/ fontName = gtk_font_chooser_get_font (handle); int length = OS.strlen (fontName); byte [] buffer = new byte [length + 1]; OS.memmove (buffer, fontName, length); @@ -284,4 +284,30 @@ public void setFontList (FontData [] fontData) { public void setRGB (RGB rgb) { this.rgb = rgb; } + +long /*int*/ gtk_font_chooser_get_font(long /*int*/ fontchooser) { + if (OS.GTK_VERSION >= OS.VERSION(3, 2, 0)) { + return OS.gtk_font_chooser_get_font(fontchooser); + } else { + return OS.gtk_font_selection_dialog_get_font_name(fontchooser); + } +} + +long /*int*/ gtk_font_chooser_dialog_new (byte[] title) { + if (OS.GTK_VERSION >= OS.VERSION(3, 2, 0)) { + return OS.gtk_font_chooser_dialog_new (title, 0); + } else { + return OS.gtk_font_selection_dialog_new (title); + } +} + + +void gtk_font_chooser_set_font(long /*int*/ fsd, byte[] fontname) { + if (OS.GTK_VERSION >= OS.VERSION(3, 2, 0)) { + OS.gtk_font_chooser_set_font(fsd, fontname); + } else { + OS.gtk_font_selection_dialog_set_font_name(fsd, fontname); + } +} + } |