aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnatoly Spektor2013-02-18 14:53:25 (EST)
committerAlexander Kurtakov2013-02-21 16:25:10 (EST)
commit22fa45ac6dbb2092d2c5466d2ba94e8543ea83dd (patch)
tree35b28eb350822ee1340cbca07256093af3e92973
parent269e9bd88659168cd99ab994fb73a4e91595fd06 (diff)
downloadeclipse.platform.swt-22fa45ac6dbb2092d2c5466d2ba94e8543ea83dd.zip
eclipse.platform.swt-22fa45ac6dbb2092d2c5466d2ba94e8543ea83dd.tar.gz
eclipse.platform.swt-22fa45ac6dbb2092d2c5466d2ba94e8543ea83dd.tar.bz2
Add css style to button to solve button's height clipping issue
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c65
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java40
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java13
6 files changed, 127 insertions, 0 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 b579c98..2900290 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
@@ -9506,6 +9506,53 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1container_1set_1border_1width)
}
#endif
+#ifndef NO__1gtk_1css_1provider_1load_1from_1data
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1css_1provider_1load_1from_1data)
+ (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jintLong arg2, jintLongArray arg3)
+{
+ jbyte *lparg1=NULL;
+ jintLong *lparg3=NULL;
+ jboolean rc = 0;
+ OS_NATIVE_ENTER(env, that, _1gtk_1css_1provider_1load_1from_1data_FUNC);
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ if (arg3) if ((lparg3 = (*env)->GetIntLongArrayElements(env, arg3, NULL)) == NULL) goto fail;
+/*
+ rc = (jboolean)gtk_css_provider_load_from_data(arg0, (const gchar *)lparg1, (gssize)arg2, (GError **)lparg3);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gtk_css_provider_load_from_data)
+ if (fp) {
+ rc = (jboolean)((jboolean (CALLING_CONVENTION*)(jintLong, const gchar *, gssize, GError **))fp)(arg0, (const gchar *)lparg1, (gssize)arg2, (GError **)lparg3);
+ }
+ }
+fail:
+ if (arg3 && lparg3) (*env)->ReleaseIntLongArrayElements(env, arg3, lparg3, 0);
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ OS_NATIVE_EXIT(env, that, _1gtk_1css_1provider_1load_1from_1data_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1css_1provider_1new
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1css_1provider_1new)
+ (JNIEnv *env, jclass that)
+{
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1gtk_1css_1provider_1new_FUNC);
+/*
+ rc = (jintLong)gtk_css_provider_new();
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gtk_css_provider_new)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)())fp)();
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1gtk_1css_1provider_1new_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1gtk_1dialog_1add_1button
JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1dialog_1add_1button)
(JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jint arg2)
@@ -14898,6 +14945,24 @@ fail:
}
#endif
+#ifndef NO__1gtk_1style_1context_1add_1provider_1for_1screen
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1context_1add_1provider_1for_1screen)
+ (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jint arg2)
+{
+ OS_NATIVE_ENTER(env, that, _1gtk_1style_1context_1add_1provider_1for_1screen_FUNC);
+/*
+ gtk_style_context_add_provider_for_screen((GdkScreen *)arg0, arg1, (guint)arg2);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gtk_style_context_add_provider_for_screen)
+ if (fp) {
+ ((void (CALLING_CONVENTION*)(GdkScreen *, jintLong, guint))fp)((GdkScreen *)arg0, arg1, (guint)arg2);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1gtk_1style_1context_1add_1provider_1for_1screen_FUNC);
+}
+#endif
+
#ifndef NO__1gtk_1style_1context_1get_1background_1color
JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1context_1get_1background_1color)
(JNIEnv *env, jclass that, jintLong arg0, jint arg1, jobject arg2)
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 68b919b..b147c9f 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
@@ -275,6 +275,7 @@
#define gtk_scrolled_window_get_hscrollbar_LIB LIB_GTK
#define gtk_scrolled_window_get_vscrollbar_LIB LIB_GTK
#define gtk_scale_new_LIB LIB_GTK
+#define gtk_style_context_add_provider_for_screen_LIB LIB_GTK
#define gtk_style_context_restore_LIB LIB_GTK
#define gtk_style_context_save_LIB LIB_GTK
#define gtk_style_context_set_state_LIB LIB_GTK
@@ -536,6 +537,8 @@
#define gdk_event_get_scroll_deltas_LIB LIB_GTK
#define gtk_cell_renderer_set_fixed_size_LIB LIB_GTK
#define gtk_cell_renderer_get_preferred_height_for_width_LIB LIB_GTK
+#define gtk_css_provider_load_from_data_LIB LIB_GTK
+#define gtk_css_provider_new_LIB LIB_GTK
#define gtk_icon_set_render_icon_pixbuf_LIB LIB_GTK
/* Field accessors */
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 cc331d4..41fd5a4 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
@@ -705,6 +705,8 @@ char * OS_nativeFunctionNames[] = {
"_1gtk_1container_1remove",
"_1gtk_1container_1resize_1children",
"_1gtk_1container_1set_1border_1width",
+ "_1gtk_1css_1provider_1load_1from_1data",
+ "_1gtk_1css_1provider_1new",
"_1gtk_1dialog_1add_1button",
"_1gtk_1dialog_1run",
"_1gtk_1drag_1begin",
@@ -1064,6 +1066,7 @@ char * OS_nativeFunctionNames[] = {
"_1gtk_1status_1icon_1set_1tooltip",
"_1gtk_1status_1icon_1set_1visible",
"_1gtk_1style_1context_1add_1class",
+ "_1gtk_1style_1context_1add_1provider_1for_1screen",
"_1gtk_1style_1context_1get_1background_1color",
"_1gtk_1style_1context_1get_1border",
"_1gtk_1style_1context_1get_1border_1color",
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 237c57e..5f3e9a6 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
@@ -715,6 +715,8 @@ typedef enum {
_1gtk_1container_1remove_FUNC,
_1gtk_1container_1resize_1children_FUNC,
_1gtk_1container_1set_1border_1width_FUNC,
+ _1gtk_1css_1provider_1load_1from_1data_FUNC,
+ _1gtk_1css_1provider_1new_FUNC,
_1gtk_1dialog_1add_1button_FUNC,
_1gtk_1dialog_1run_FUNC,
_1gtk_1drag_1begin_FUNC,
@@ -1074,6 +1076,7 @@ typedef enum {
_1gtk_1status_1icon_1set_1tooltip_FUNC,
_1gtk_1status_1icon_1set_1visible_FUNC,
_1gtk_1style_1context_1add_1class_FUNC,
+ _1gtk_1style_1context_1add_1provider_1for_1screen_FUNC,
_1gtk_1style_1context_1get_1background_1color_FUNC,
_1gtk_1style_1context_1get_1border_FUNC,
_1gtk_1style_1context_1get_1border_1color_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 f5ab078..39f6afe 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
@@ -410,6 +410,7 @@ public class OS extends C {
public static final int GTK_TREE_VIEW_GRID_LINES_HORIZONTAL = 1;
public static final int GTK_TREE_VIEW_GRID_LINES_VERTICAL = 2;
public static final int GTK_TREE_VIEW_GRID_LINES_BOTH = 3;
+ public static final int GTK_STYLE_PROVIDER_PRIORITY_APPLICATION = 600;
public static final int GDK_UNMAP = 15;
public static final int GTK_UNIT_PIXEL = 0;
public static final int GTK_UNIT_POINTS = 1;
@@ -8458,6 +8459,45 @@ public static final long /*int*/ gtk_list_store_newv(int numColumns, long /*int*
}
}
/**
+ * @method flags=dynamic
+ * @param data cast=(const gchar *)
+ * @param length cast=(gssize)
+ * @param error cast=(GError **)
+ */
+public static final native boolean _gtk_css_provider_load_from_data(long /*int*/ css_provider, byte[] data, long /*int*/ length, long /*int*/ error[]);
+public static final boolean gtk_css_provider_load_from_data(long /*int*/ css_provider, byte[] data, long /*int*/ length, long /*int*/ error[] ) {
+ lock.lock();
+ try {
+ return _gtk_css_provider_load_from_data(css_provider, data, length, error);
+ } finally {
+ lock.unlock();
+ }
+}
+/** @method flags=dynamic */
+public static final native long /*int*/ _gtk_css_provider_new();
+public static final long /*int*/gtk_css_provider_new() {
+ lock.lock();
+ try {
+ return _gtk_css_provider_new();
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ * @param screen cast=(GdkScreen *)
+ * @param priority cast=(guint)
+ */
+public static final native void _gtk_style_context_add_provider_for_screen (long /*int*/ screen, long /*int*/ provider, int priority);
+public static final void gtk_style_context_add_provider_for_screen(long /*int*/ screen, long /*int*/ provider, int priority) {
+ lock.lock();
+ try {
+ _gtk_style_context_add_provider_for_screen(screen, provider, priority);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
* @param list_store cast=(GtkListStore *)
* @param iter cast=(GtkTreeIter *)
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
index 8282c90..690fd26 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
@@ -259,6 +259,19 @@ void createHandle (int index) {
fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
gtk_widget_set_has_window (fixedHandle, true);
+ if (OS.GTK3) {
+ String button_css = ".button {\n" +
+ "-GtkButton-default-border : 0px;\n" +
+ "-GtkWidget-focus-line-width : 0px;\n" +
+ "-GtkWidget-focus-padding : 0px;\n" +
+ "padding-bottom: 0px;\n" +
+ "}" ;
+ byte[] data = Converter.wcsToMbcs (null, button_css, true);
+ long /*int*/ provider = OS.gtk_css_provider_new();
+ OS.gtk_css_provider_load_from_data(provider, data, -1, null);
+ OS.gtk_style_context_add_provider_for_screen (OS.gdk_screen_get_default(), provider, OS.GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ OS.g_object_unref (provider);
+ }
switch (style & bits) {
case SWT.ARROW:
int arrow_type = OS.GTK_ARROW_UP;