static char wcsToMbcs (char ch) { int key = ch & 0xFFFF; if (key <= 0x7F) return ch; byte [] buffer = Converter.wcsToMbcs (null, new char [] {ch}, false); if (buffer.length == 1) return (char) buffer [0]; if (buffer.length == 2) { return (char) (((buffer [0] & 0xFF) << 8) | (buffer [1] & 0xFF)); } return 0; }
static char wcsToMbcs (char ch) { int key = ch & 0xFFFF; if (key <= 0x7F) return ch; byte [] buffer = Converter.wcsToMbcs (null, new char [] {ch}, false); if (buffer.length == 1) return (char) buffer [0]; if (buffer.length == 2) { return (char) (((buffer [0] & 0xFF) << 8) | (buffer [1] & 0xFF)); } return 0; }
public static byte [] wcsToMbcs (String codePage, String string, boolean terminate) { int length = string.length (); char [] buffer = new char [length]; string.getChars (0, length, buffer, 0); return wcsToMbcs (codePage, buffer, terminate); }
public static byte [] wcsToMbcs (String codePage, String string, boolean terminate) { int length = string.length (); char [] buffer = new char [length]; string.getChars (0, length, buffer, 0); return wcsToMbcs (codePage, buffer, terminate); }
static boolean cde_isExecutable(String fileName) { byte [] fileNameBuffer = Converter.wcsToMbcs(null, fileName, true); return OS.access(fileNameBuffer, OS.X_OK) == 0; //TODO find the content type of the file and check if it is executable }
int getWidgetProperty(long /*int*/ handle, String name) { byte[] propertyName = Converter.wcsToMbcs(null, name, true); int[] result = new int[1]; OS.gtk_widget_style_get(handle, propertyName, result, 0); return result[0]; }
static int /*long*/ JSObjectHasPropertyProc (int /*long*/ ctx, int /*long*/ object, int /*long*/ propertyName) { byte[] bytes = null; try { bytes = (FUNCTIONNAME_CALLJAVA + '\0').getBytes (CHARSET_UTF8); //$NON-NLS-1$ } catch (UnsupportedEncodingException e) { bytes = Converter.wcsToMbcs (null, FUNCTIONNAME_CALLJAVA, true); } return WebKitGTK.JSStringIsEqualToUTF8CString (propertyName, bytes); }
int getWidgetProperty(int /*long*/ handle, String name) { byte[] propertyName = Converter.wcsToMbcs(null, name, true); int[] result = new int[1]; OS.gtk_widget_style_get(handle, propertyName, result, 0); return result[0]; }
GdkRGBA gtk_css_property_to_rgba(String property) { /* Here we convert rgb(...) or rgba(...) properties * into GdkRGBA objects using gdk_rgba_parse(). Note * that we still need to remove the ";" character from the * input string. */ GdkRGBA rgba = new GdkRGBA (); String [] propertyParsed = new String [1]; propertyParsed = property.split (";"); OS.gdk_rgba_parse (rgba, Converter.wcsToMbcs (null, propertyParsed[0], true)); return rgba; }
static Program gio_getProgram(Display display, String mimeType) { Program program = null; byte[] mimeTypeBuffer = Converter.wcsToMbcs (null, mimeType, true); long /*int*/ application = OS.g_app_info_get_default_for_type (mimeTypeBuffer, false); if (application != 0) { program = gio_getProgram(display, application); } return program; }
static long /*int*/ getStringPtr (String str) { byte [] buffer = Converter.wcsToMbcs(null, str != null ? str : "", true); long /*int*/ ptr = OS.g_malloc(buffer.length); OS.memmove(ptr, buffer, buffer.length); return ptr; }
static Program gio_getProgram(Display display, String mimeType) { Program program = null; byte[] mimeTypeBuffer = Converter.wcsToMbcs (null, mimeType, true); int /*long*/ application = OS.g_app_info_get_default_for_type (mimeTypeBuffer, false); if (application != 0) { program = gio_getProgram(display, application); } return program; }
/** * GNOME 2.4 - Launch the default program for the given file. */ static boolean gnome_launch(String fileName) { byte[] fileNameBuffer = Converter.wcsToMbcs(null, fileName, true); int /*long*/ uri = GNOME.gnome_vfs_make_uri_from_input_with_dirs(fileNameBuffer, GNOME.GNOME_VFS_MAKE_URI_DIR_CURRENT); int result = GNOME.gnome_vfs_url_show(uri); OS.g_free(uri); return (result == GNOME.GNOME_VFS_OK); }
static int /*long*/ JSObjectGetPropertyProc (int /*long*/ ctx, int /*long*/ object, int /*long*/ propertyName, int /*long*/ exception) { byte[] bytes = null; try { bytes = (FUNCTIONNAME_CALLJAVA + '\0').getBytes (CHARSET_UTF8); //$NON-NLS-1$ } catch (UnsupportedEncodingException e) { bytes = Converter.wcsToMbcs (null, FUNCTIONNAME_CALLJAVA, true); } int /*long*/ name = WebKitGTK.JSStringCreateWithUTF8CString (bytes); int /*long*/ function = WebKitGTK.JSObjectMakeFunctionWithCallback (ctx, name, JSObjectCallAsFunctionProc.getAddress ()); WebKitGTK.JSStringRelease (name); return function; }
static int /*long*/ JSObjectGetPropertyProc (int /*long*/ ctx, int /*long*/ object, int /*long*/ propertyName, int /*long*/ exception) { byte[] bytes = null; try { bytes = (FUNCTIONNAME_CALLJAVA + '\0').getBytes (CHARSET_UTF8); //$NON-NLS-1$ } catch (UnsupportedEncodingException e) { bytes = Converter.wcsToMbcs (null, FUNCTIONNAME_CALLJAVA, true); } int /*long*/ name = WebKitGTK.JSStringCreateWithUTF8CString (bytes); int /*long*/ function = WebKitGTK.JSObjectMakeFunctionWithCallback (ctx, name, JSObjectCallAsFunctionProc.getAddress ()); WebKitGTK.JSStringRelease (name); return function; }
void gtk_css_provider_load_from_css (int /*long*/ context, String css) { /* Utility function. */ //@param css : a 'css java' string like "{\nbackground: red;\n}". if (provider == 0) { provider = OS.gtk_css_provider_new (); OS.gtk_style_context_add_provider (context, provider, OS.GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); OS.g_object_unref (provider); } OS.gtk_css_provider_load_from_data (provider, Converter.wcsToMbcs (null, css, true), -1, null); }
void gtk_css_provider_load_from_css (int /*long*/ context, String css) { /* Utility function. */ //@param css : a 'css java' string like "{\nbackground: red;\n}". if (provider == 0) { provider = OS.gtk_css_provider_new (); OS.gtk_style_context_add_provider (context, provider, OS.GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); OS.g_object_unref (provider); } OS.gtk_css_provider_load_from_data (provider, Converter.wcsToMbcs (null, css, true), -1, null); }
void gtk_css_provider_load_from_css (long /*int*/ context, String css) { /* Utility function. */ //@param css : a 'css java' string like "{\nbackground: red;\n}". if (provider == 0) { provider = OS.gtk_css_provider_new (); OS.gtk_style_context_add_provider (context, provider, OS.GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); OS.g_object_unref (provider); } OS.gtk_css_provider_load_from_data (provider, Converter.wcsToMbcs (null, css, true), -1, null); }
private void setAccelLabel(int /*long*/ label, String accelString) { byte[] buffer = Converter.wcsToMbcs (null, accelString, true); int /*long*/ ptr = OS.g_malloc (buffer.length); OS.memmove (ptr, buffer, buffer.length); int /*long*/ oldPtr = OS.GTK_ACCEL_LABEL_GET_ACCEL_STRING (label); OS.GTK_ACCEL_LABEL_SET_ACCEL_STRING (label, ptr); if (oldPtr != 0) OS.g_free (oldPtr); }
void replaceCurrentlySelectedTextRegion (String string) { checkWidget (); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); byte [] buffer = Converter.wcsToMbcs (null, string, false); int [] start = new int [1], end = new int [1]; OS.gtk_editable_get_selection_bounds (textEntryHandle, start, end); OS.gtk_editable_delete_selection (textEntryHandle); OS.gtk_editable_insert_text (textEntryHandle, buffer, buffer.length, start); OS.gtk_editable_set_position (textEntryHandle, start [0]); }