static gboolean get_child_position (GtkOverlay *overlay, GtkWidget *widget, GtkAllocation *allocation, GtkColorEditor *editor) { GtkRequisition req; GtkAllocation alloc; gint s, e; gtk_widget_get_preferred_size (widget, &req, NULL); allocation->x = 0; allocation->y = 0; allocation->width = req.width; allocation->height = req.height; if (widget == editor->priv->sv_popup) { if (gtk_widget_get_direction (GTK_WIDGET (overlay)) == GTK_TEXT_DIR_RTL) allocation->x = 0; else allocation->x = gtk_widget_get_allocated_width (GTK_WIDGET (overlay)) - req.width; allocation->y = req.height / 3; } else if (widget == editor->priv->h_popup) { gtk_widget_get_allocation (editor->priv->h_slider, &alloc); gtk_range_get_slider_range (GTK_RANGE (editor->priv->h_slider), &s, &e); if (gtk_widget_get_direction (GTK_WIDGET (overlay)) == GTK_TEXT_DIR_RTL) gtk_widget_translate_coordinates (editor->priv->h_slider, gtk_widget_get_parent (editor->priv->grid), - req.width, (s + e - req.height) / 2, &allocation->x, &allocation->y); else gtk_widget_translate_coordinates (editor->priv->h_slider, gtk_widget_get_parent (editor->priv->grid), alloc.width, (s + e - req.height) / 2, &allocation->x, &allocation->y); } else if (widget == editor->priv->a_popup) { gtk_widget_get_allocation (editor->priv->a_slider, &alloc); gtk_range_get_slider_range (GTK_RANGE (editor->priv->a_slider), &s, &e); gtk_widget_translate_coordinates (editor->priv->a_slider, gtk_widget_get_parent (editor->priv->grid), (s + e - req.width) / 2, - req.height, &allocation->x, &allocation->y); } else return FALSE; allocation->x = CLAMP (allocation->x, 0, gtk_widget_get_allocated_width (GTK_WIDGET (overlay)) - req.width); allocation->y = CLAMP (allocation->y, 0, gtk_widget_get_allocated_height (GTK_WIDGET (overlay)) - req.height); return TRUE; }
static void popup_edit (GtkWidget *widget, GtkColorEditor *editor) { GtkWidget *popup = NULL; GtkWidget *toplevel; GtkWidget *focus; gint position; gint s, e; if (widget == editor->priv->sv_plane) { popup = editor->priv->sv_popup; focus = editor->priv->s_entry; position = 0; } else if (widget == editor->priv->h_slider) { popup = editor->priv->h_popup; focus = editor->priv->h_entry; gtk_range_get_slider_range (GTK_RANGE (editor->priv->h_slider), &s, &e); position = (s + e) / 2; } else if (widget == editor->priv->a_slider) { popup = editor->priv->a_popup; focus = editor->priv->a_entry; gtk_range_get_slider_range (GTK_RANGE (editor->priv->a_slider), &s, &e); position = (s + e) / 2; } if (popup == editor->priv->current_popup) dismiss_current_popup (editor); else if (popup) { dismiss_current_popup (editor); toplevel = gtk_widget_get_toplevel (GTK_WIDGET (editor)); editor->priv->popdown_focus = gtk_window_get_focus (GTK_WINDOW (toplevel)); editor->priv->current_popup = popup; editor->priv->popup_position = position; gtk_widget_show (popup); gtk_widget_grab_focus (focus); } }
JNIEXPORT void JNICALL Java_org_gnome_gtk_GtkRange_gtk_1range_1get_1slider_1range ( JNIEnv* env, jclass cls, jlong _self, jintArray _sliderStart, jintArray _sliderEnd ) { GtkRange* self; gint* sliderStart; gint* sliderEnd; // convert parameter self self = (GtkRange*) _self; // convert parameter sliderStart sliderStart = (gint*) (*env)->GetIntArrayElements(env, _sliderStart, NULL); if (sliderStart == NULL) { return; // Java Exception already thrown } // convert parameter sliderEnd sliderEnd = (gint*) (*env)->GetIntArrayElements(env, _sliderEnd, NULL); if (sliderEnd == NULL) { return; // Java Exception already thrown } // call function gtk_range_get_slider_range(self, sliderStart, sliderEnd); // cleanup parameter self // cleanup parameter sliderStart (*env)->ReleaseIntArrayElements(env, _sliderStart, (jint*)sliderStart, 0); // cleanup parameter sliderEnd (*env)->ReleaseIntArrayElements(env, _sliderEnd, (jint*)sliderEnd, 0); }