JNIEXPORT jint JNICALL Java_org_gnome_gtk_GtkWindow_gtk_1window_1get_1gravity ( JNIEnv* env, jclass cls, jlong _self ) { GdkGravity result; jint _result; GtkWindow* self; // convert parameter self self = (GtkWindow*) _self; // call function result = gtk_window_get_gravity(self); // cleanup parameter self // translate return value to JNI type _result = (jint) result; // and finally return _result; }
static void compensate_for_gravity (GtkWindow *window, gint *x, gint *y, gint w, gint h) { GdkGravity gravity; gravity = gtk_window_get_gravity (window); /* Horizontal */ switch (gravity) { case GDK_GRAVITY_NORTH: case GDK_GRAVITY_SOUTH: case GDK_GRAVITY_CENTER: *x = w / 2; break; case GDK_GRAVITY_NORTH_EAST: case GDK_GRAVITY_SOUTH_EAST: case GDK_GRAVITY_EAST: *x = w; break; default: *x = 0; break; } /* Vertical */ switch (gravity) { case GDK_GRAVITY_WEST: case GDK_GRAVITY_CENTER: case GDK_GRAVITY_EAST: *y = w / 2; break; case GDK_GRAVITY_SOUTH_EAST: case GDK_GRAVITY_SOUTH: case GDK_GRAVITY_SOUTH_WEST: *y = w; break; default: *y = 0; break; } }
/** * eel_gtk_window_get_geometry_string: * @window: a #GtkWindow * * Obtains the geometry string for this window, suitable for * set_geometry_string(); assumes the window has NorthWest gravity * * Return value: geometry string, must be freed **/ char* eel_gtk_window_get_geometry_string (GtkWindow *window) { char *str; int w, h, x, y; g_return_val_if_fail (GTK_IS_WINDOW (window), NULL); g_return_val_if_fail (gtk_window_get_gravity (window) == GDK_GRAVITY_NORTH_WEST, NULL); gtk_window_get_position (window, &x, &y); gtk_window_get_size (window, &w, &h); str = g_strdup_printf ("%dx%d+%d+%d", w, h, x, y); return str; }