summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiWoong Kim <giwoong.kim@samsung.com>2014-03-21 20:35:54 +0900
committerGiWoong Kim <giwoong.kim@samsung.com>2014-04-02 14:50:48 +0900
commit25c93abf7e3754ab986accfa260b4f101f37c875 (patch)
treea6d7fb2a092251b8870bc724f85c83ec3fa12c9b
parentc4e7bc432fed2ee00ade6c480056d7fe46e9bb6e (diff)
downloadqemu-25c93abf7e3754ab986accfa260b4f101f37c875.tar.gz
qemu-25c93abf7e3754ab986accfa260b4f101f37c875.tar.bz2
qemu-25c93abf7e3754ab986accfa260b4f101f37c875.zip
menu: modified CopyToClipboard on Ubuntu 64bit
replace JNI-GTK to Python-GTK Change-Id: I5663d9768eeb5e78979295615fd91577febac17f Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
-rw-r--r--tizen/src/Makefile4
-rw-r--r--tizen/src/skin/client/build.xml6
-rw-r--r--tizen/src/skin/client/native_src/clipboard.py15
-rwxr-xr-xtizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java2
-rw-r--r--tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java2
-rw-r--r--tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java74
6 files changed, 61 insertions, 42 deletions
diff --git a/tizen/src/Makefile b/tizen/src/Makefile
index 9967cf633f..efb53f6d7f 100644
--- a/tizen/src/Makefile
+++ b/tizen/src/Makefile
@@ -135,7 +135,7 @@ endif
# use GTK for CopyToClipboard on Ubuntu 12.04 64bit
ifdef CONFIG_LINUX
- cp -pP skin/client/native_src/libclipboard.so $(EMUL_DIR)/bin
+ cp -pP skin/client/native_src/clipboard.py $(EMUL_DIR)/bin
endif
# change loading path of dynamic shared libraries on MAC OS X
@@ -244,7 +244,7 @@ endif
# use GTK for CopyToClipboard on Ubuntu 12.04 64bit
ifdef CONFIG_LINUX
- cp -pP skin/client/native_src/libclipboard.so $(DIBS_COMMON_DIR)/bin
+ cp -pP skin/client/native_src/clipboard.py $(DIBS_COMMON_DIR)/bin
endif
# change loading path of dynamic shared libraries on MAC OS X
diff --git a/tizen/src/skin/client/build.xml b/tizen/src/skin/client/build.xml
index 814e1c61ee..4fe9f2f7f9 100644
--- a/tizen/src/skin/client/build.xml
+++ b/tizen/src/skin/client/build.xml
@@ -100,6 +100,7 @@
<arg line="libshared.so" />
</exec>
+ <!--
<exec dir="native_src" executable="./check-gtk.sh" outputproperty="gtkabi" failifexecutionfails="false" />
<echo message="gtkversion : ${gtkabi}" />
@@ -108,8 +109,8 @@
</javah>
<echo message="build libclipboard.so" />
<exec executable="pkg-config" outputproperty="gtk" failifexecutionfails="false">
- <arg line="--cflags" />
- <arg line="--libs" />
+ <arg line="- -cflags" />
+ <arg line="- -libs" />
<arg line="${gtkabi}" />
</exec>
<exec dir="native_src" executable="gcc" failifexecutionfails="false">
@@ -128,6 +129,7 @@
<arg line="-o" />
<arg line="libclipboard.so" />
</exec>
+ -->
<delete>
<fileset dir="native_src" includes="**/*.h" />
diff --git a/tizen/src/skin/client/native_src/clipboard.py b/tizen/src/skin/client/native_src/clipboard.py
new file mode 100644
index 0000000000..074e827b94
--- /dev/null
+++ b/tizen/src/skin/client/native_src/clipboard.py
@@ -0,0 +1,15 @@
+#!/usr/bin/env python
+
+import pygtk
+import gtk
+import sys
+
+def copy_image(f):
+ image = gtk.gdk.pixbuf_new_from_file(f)
+
+ clipboard = gtk.clipboard_get()
+ clipboard.set_image(image)
+ clipboard.store()
+
+
+copy_image(sys.argv[1]);
diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java
index 4a33e7335d..43c546302f 100755
--- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java
+++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java
@@ -142,7 +142,7 @@ public class EmulatorSkin {
private static Logger logger =
SkinLogger.getSkinLogger(EmulatorSkin.class).getLogger();
- protected EmulatorConfig config;
+ public EmulatorConfig config;
protected Shell shell;
protected ImageRegistry imageRegistry;
protected Canvas lcdCanvas;
diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java
index c8ef6d9f12..6c8ebbb01c 100644
--- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java
+++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java
@@ -138,6 +138,8 @@ public class EmulatorSkinMain {
logger.info("swt platform : " + SWT.getPlatform());
logger.info("swt version : " + SWT.getVersion());
+ logger.info("working directory" + System.getProperty("user.dir"));
+
/* startup arguments parsing */
Map<String, String> argsMap = parseArgs(args);
EmulatorConfig.validateArgs(argsMap);
diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java
index 103a39cd36..a1506cafb3 100644
--- a/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java
+++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java
@@ -43,7 +43,6 @@ import java.util.logging.Logger;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.ImageTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.MouseEvent;
@@ -69,12 +68,12 @@ import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.tizen.emulator.skin.EmulatorSkin;
import org.tizen.emulator.skin.config.EmulatorConfig;
+import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
import org.tizen.emulator.skin.exception.ScreenShotException;
import org.tizen.emulator.skin.image.ImageRegistry;
import org.tizen.emulator.skin.image.ImageRegistry.IconName;
@@ -98,30 +97,6 @@ public class ScreenShotDialog {
private static Logger logger =
SkinLogger.getSkinLogger(ScreenShotDialog.class).getLogger();
- static {
- /* load JNI library file */
- try {
- if (SwtUtil.isLinuxPlatform() == true &&
- SwtUtil.is64bitPlatform() == true) {
- System.loadLibrary(JNI_LIBRARY_FILE);
- }
- } catch (UnsatisfiedLinkError e) {
- logger.severe("Failed to load a " + JNI_LIBRARY_FILE + " file.\n" + e);
-
- Shell temp = new Shell(Display.getDefault());
- MessageBox messageBox = new MessageBox(temp, SWT.ICON_ERROR);
- messageBox.setText("Emulator");
- messageBox.setMessage(
- "Failed to load a JNI library file from "
- + System.getProperty("java.library.path") + ".\n\n" + e);
- messageBox.open();
- temp.dispose();
- }
- }
-
- /* define JNI function */
- public native int copyToClipboard(int width, int height, byte buf[]);
-
protected EmulatorSkin skin;
protected EmulatorConfig config;
private Shell shell;
@@ -527,21 +502,46 @@ public class ScreenShotDialog {
loader.data = new ImageData[] { shotData };
- ByteArrayOutputStream bao = new ByteArrayOutputStream();
- loader.save(bao, SWT.IMAGE_PNG);
-
- ImageData pngData = new ImageData(
- new ByteArrayInputStream(bao.toByteArray()));
-
if (SwtUtil.isLinuxPlatform() == true &&
SwtUtil.is64bitPlatform() == true) {
- /* use JNI for Ubuntu 12.04 64bit */
- int result = copyToClipboard(
- pngData.width, pngData.height, pngData.data);
- if (result < 0) {
- DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
+ /* use Python for Ubuntu 64bit */
+ FileOutputStream fos = null;
+ String fileName = "screenshot" +
+ skin.config.getArgInt(ArgsConstants.VM_BASE_PORT) + ".png";
+
+ try {
+ fos = new FileOutputStream(fileName, false);
+ } catch (FileNotFoundException ee) {
+ logger.log(Level.SEVERE, ee.getMessage(), ee);
+ SkinUtil.openMessage(shell, null,
+ "Failed to copy to clipboard : \n" + ee.getMessage(),
+ SWT.ICON_ERROR, config);
+ return;
+ }
+
+ loader.save(fos, SWT.IMAGE_PNG);
+ IOUtil.close(fos);
+
+ ProcessBuilder procPy = new ProcessBuilder();
+ procPy.command("python", "clipboard.py", fileName);
+
+ logger.info(procPy.command().toString());
+
+ try {
+ procPy.start();
+ } catch (Exception ee) {
+ logger.log(Level.SEVERE, ee.getMessage(), ee);
+ SkinUtil.openMessage(shell, null,
+ "Failed to copy to clipboard : \n" + ee.getMessage(),
+ SWT.ICON_ERROR, config);
}
} else {
+ ByteArrayOutputStream bao = new ByteArrayOutputStream();
+ loader.save(bao, SWT.IMAGE_PNG);
+
+ ImageData pngData = new ImageData(
+ new ByteArrayInputStream(bao.toByteArray()));
+
Object[] imageObject = new Object[] { pngData };
Transfer[] transfer = new Transfer[] { ImageTransfer.getInstance() };