All pastes #564120 Raw Edit

volume layout magic

public text v1 · immutable
·published 2007-06-13 13:35 UTC
rendered paste body
static void kiba_volume_get_dock_position (KibaVolume *volume,
					   gint       *x,
					   gint       *y) {
	GtkWidget *dock;
	gint width, height;
	const KibaLayoutData *d;
	
	dock = GTK_WIDGET(volume->icon)->parent;
	d = &kiba_layout_data[KIBA_DOCK(dock)->d.position];
	
	gtk_window_get_size (GTK_WINDOW (volume->scrollbar), &width, &height);
	*x = KIBA_OBJECT(volume->icon)->allocation.x + dock->parent->allocation.x;
	*y = KIBA_OBJECT(volume->icon)->allocation.y + dock->parent->allocation.y;
	
	/* switch coordinates ;) */
	struct {
		gint *x, *y;
		gint  w,  h;
		gint alignment;
	} layout_magic[2] = {
		{ x, y, width,  height, d->valignment },  /**< GTK_ORIENTATION_HORIZONTAL. */
		{ y, x, height, width,  d->halignment }   /**< GTK_ORIENTATION_VERTICAL. */
	};
	
	*layout_magic[d->orientation].x -=
		(layout_magic[d->orientation].w - KIBA_OBJECT(volume->icon)->allocation.width) / 2.0;
	*layout_magic[d->orientation].y -=
		layout_magic[d->orientation].alignment == 0 ?
			-KIBA_OBJECT(volume->icon)->allocation.width : layout_magic[d->orientation].h;
}