static gint gd_tagged_entry_tag_panel_get_height (GdTaggedEntryTag *tag, GdTaggedEntry *entry) { GtkWidget *widget = GTK_WIDGET (entry); gint height, req_height; GtkRequisition requisition; GtkAllocation allocation; GtkBorder margin; gtk_widget_get_allocation (widget, &allocation); gtk_widget_get_preferred_size (widget, &requisition, NULL); gd_tagged_entry_tag_get_margin (tag, entry, &margin); /* the tag panel height is the whole entry height, minus the tag margins */ req_height = requisition.height - gtk_widget_get_margin_top (widget) - gtk_widget_get_margin_bottom (widget); height = MIN (req_height, allocation.height) - margin.top - margin.bottom; return height; }
static void gd_tagged_entry_tag_panel_get_position (GdTaggedEntry *self, gint *x_out, gint *y_out) { GtkWidget *widget = GTK_WIDGET (self); gint text_x, text_y, text_width, text_height, req_height; GtkAllocation allocation; GtkRequisition requisition; gtk_widget_get_allocation (widget, &allocation); gtk_widget_get_preferred_size (widget, &requisition, NULL); req_height = requisition.height - gtk_widget_get_margin_top (widget) - gtk_widget_get_margin_bottom (widget); gd_tagged_entry_get_text_area_size (GTK_ENTRY (self), &text_x, &text_y, &text_width, &text_height); /* allocate the panel immediately after the text area */ if (x_out) *x_out = allocation.x + text_x + text_width; if (y_out) *y_out = allocation.y + (gint) floor ((allocation.height - req_height) / 2); }
/* * Class: org_java_gtk_gtk_Widget * Method: gtk_widget_get_margin_top * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_java_1gtk_gtk_Widget_gtk_1widget_1get_1margin_1top (JNIEnv *env, jclass cls, jlong widget) { return (jint)gtk_widget_get_margin_top((GtkWidget*)widget); }