static void unicapgtk_video_display_compute_child_allocation( GtkFrame *frame, GtkAllocation *child_allocation ) { UnicapgtkVideoDisplay *ugtk = UNICAPGTK_VIDEO_DISPLAY( frame ); GTK_FRAME_CLASS( parent_class )->compute_child_allocation( frame, child_allocation ); if( child_allocation->width < 0 ) { child_allocation->width = ugtk->crop_width; } if( child_allocation->height < 0 ) { child_allocation->height = ugtk->crop_height; } if( ugtk->scale_to_fit ) { return; } if( child_allocation->width > ugtk->crop_width ) { child_allocation->x += GTK_ASPECT_FRAME( frame )->xalign * (child_allocation->width - ugtk->crop_width); child_allocation->width = ugtk->crop_width; } if( child_allocation->height > ugtk->crop_height ) { child_allocation->y += GTK_ASPECT_FRAME( frame )->yalign * (child_allocation->height - ugtk->crop_height); child_allocation->height = ugtk->crop_height; } }
/** * vik_print_preview_new: * @page: page setup * @drawable_id: the drawable to print * * Creates a new #VikPrintPreview widget. * * Return value: the new #VikPrintPreview widget. **/ GtkWidget * vik_print_preview_new (GtkPageSetup *page, GdkDrawable *drawable) { VikPrintPreview *preview; gfloat ratio; preview = g_object_new (VIK_TYPE_PRINT_PREVIEW, NULL); preview->drawable = drawable; if (page != NULL) preview->page = gtk_page_setup_copy (page); else preview->page = gtk_page_setup_new (); ratio = (gtk_page_setup_get_paper_width (preview->page, GTK_UNIT_POINTS) / gtk_page_setup_get_paper_height (preview->page, GTK_UNIT_POINTS)); gtk_aspect_frame_set (GTK_ASPECT_FRAME (preview), 0.5, 0.5, ratio, FALSE); gtk_widget_set_size_request (preview->area, DRAWING_AREA_SIZE, DRAWING_AREA_SIZE); return GTK_WIDGET (preview); }
void asgtk_image_view_set_aspect (ASGtkImageView * iv, int aspect_x, int aspect_y) { Bool changed = False; g_return_if_fail (ASGTK_IS_IMAGE_VIEW (iv)); if (aspect_x <= 0 || aspect_y <= 0) { iv->aspect_x = iv->aspect_y = -1; changed = set_aspect_ratio_from_image (iv); } else { gfloat old_ratio, new_ratio; iv->aspect_x = aspect_x; iv->aspect_y = aspect_y; new_ratio = (gfloat) aspect_x / (gfloat) aspect_y; old_ratio = get_old_ratio (iv); if (old_ratio != new_ratio) { changed = True; gtk_aspect_frame_set (GTK_ASPECT_FRAME (iv->frame), 0.5, 0.5, new_ratio, FALSE); } } if (!changed) display_image_view (iv); else gtk_image_set_from_pixbuf (GTK_IMAGE (iv->view), NULL); }
static VALUE aframe_set(VALUE self, VALUE xalign, VALUE yalign, VALUE ratio, VALUE obey_child) { gtk_aspect_frame_set(GTK_ASPECT_FRAME(RVAL2GOBJ(self)), NUM2DBL(xalign), NUM2DBL(yalign), NUM2DBL(ratio), RVAL2CBOOL(obey_child)); return self; }
/** * vik_print_preview_set_page_setup: * @preview: a #VikPrintPreview. * @page: the page setup to use * * Sets the page setup to use by the #VikPrintPreview. **/ void vik_print_preview_set_page_setup (VikPrintPreview *preview, GtkPageSetup *page) { gfloat ratio; if (preview->page) g_object_unref (preview->page); preview->page = gtk_page_setup_copy (page); ratio = (gtk_page_setup_get_paper_width (page, GTK_UNIT_POINTS) / gtk_page_setup_get_paper_height (page, GTK_UNIT_POINTS)); gtk_aspect_frame_set (GTK_ASPECT_FRAME (preview), 0.5, 0.5, ratio, FALSE); print_preview_queue_draw (preview); }
static Bool set_aspect_ratio_from_image (ASGtkImageView * iv) { gfloat old_ratio, new_ratio; if (iv->image_entry && iv->image_entry->preview) new_ratio = (gfloat) iv->image_entry->preview->width / (gfloat) iv->image_entry->preview->height; else new_ratio = 1.0; old_ratio = get_old_ratio (iv); if (old_ratio == new_ratio) return False; gtk_aspect_frame_set (GTK_ASPECT_FRAME (iv->frame), 0.5, 0.5, new_ratio, FALSE); return True; }
static void photos_print_preview_init (PhotosPrintPreview *preview) { PhotosPrintPreviewPrivate *priv; gfloat ratio; preview->priv = photos_print_preview_get_instance_private (preview); priv = preview->priv; priv->area = GTK_WIDGET (gtk_drawing_area_new ()); gtk_container_add (GTK_CONTAINER (preview), priv->area); priv->p_width = 8.5; priv->p_height = 11.0; ratio = priv->p_width/priv->p_height; gtk_aspect_frame_set (GTK_ASPECT_FRAME (preview), 0.5, 0.5, ratio, FALSE); priv->pixbuf = NULL; priv->pixbuf_scaled = NULL; priv->pixbuf_x_align = 0.5; priv->pixbuf_y_align = 0.5; priv->i_scale = 1; priv->surface = NULL; priv->flag_create_surface = TRUE; priv->p_scale = 0; priv->l_margin = 0.25; priv->r_margin = 0.25; priv->t_margin = 0.25; priv->b_margin = 0.56; priv->grabbed = FALSE; priv->cursorx = 0; priv->cursory = 0; priv->r_dx = 0; priv->r_dy = 0; }
static void eom_print_preview_init (EomPrintPreview *preview) { EomPrintPreviewPrivate *priv; gfloat ratio; priv = preview->priv = EOM_PRINT_PREVIEW_GET_PRIVATE (preview); priv->area = GTK_WIDGET (gtk_drawing_area_new ()); gtk_container_add (GTK_CONTAINER (preview), priv->area); priv->p_width = 8.5; priv->p_height = 11.0; ratio = priv->p_width/priv->p_height; gtk_aspect_frame_set (GTK_ASPECT_FRAME (preview), 0.5, 0.5, ratio, FALSE); priv->image = NULL; priv->image_scaled = NULL; priv->image_x_align = 0.5; priv->image_y_align = 0.5; priv->i_scale = 1; priv->surface = NULL; priv->flag_create_surface = TRUE; priv->p_scale = 0; priv->l_margin = 0.25; priv->r_margin = 0.25; priv->t_margin = 0.25; priv->b_margin = 0.56; priv->grabbed = FALSE; priv->cursorx = 0; priv->cursory = 0; priv->r_dx = 0; priv->r_dy = 0; }
/* ------------------------------ * gap_pview_set_size * ------------------------------ * set new preview size * and allocate buffers for src columns and row at previesize */ void gap_pview_set_size(GapPView *pv_ptr, gint pv_width, gint pv_height, gint pv_check_size) { g_return_if_fail (pv_width > 0 && pv_height > 0); if(pv_ptr->da_widget == NULL) { return; } gap_pview_reset(pv_ptr); gtk_widget_set_size_request (pv_ptr->da_widget, pv_width, pv_height); if(pv_ptr->aspect_frame) { gtk_aspect_frame_set (GTK_ASPECT_FRAME(pv_ptr->aspect_frame) ,0.5 /* align x centered */ ,0.5 /* align y centered */ , pv_width / pv_height , TRUE /* obey_child */ ); gtk_widget_set_size_request (pv_ptr->aspect_frame , pv_width+5 , (gdouble)(pv_width+5) * ( (gdouble)pv_height / (gdouble)pv_width) /* pv_height */ ); } pv_ptr->pv_width = pv_width; pv_ptr->pv_height = pv_height; pv_ptr->pv_check_size = pv_check_size; pv_ptr->pv_area_data = g_new ( guchar , pv_ptr->pv_height * pv_ptr->pv_width * pv_ptr->pv_bpp ); pv_ptr->src_col = g_new ( gint, pv_ptr->pv_width ); /* column fetch indexes foreach preview col */ if(pv_ptr->pv_desaturated_area_data) { g_free(pv_ptr->pv_desaturated_area_data); pv_ptr->pv_desaturated_area_data = NULL; } } /* end gap_pview_set_size */
static void unicapgtk_video_display_init( UnicapgtkVideoDisplay *ugtk ) { ugtk->backend_fourcc = 0; gtk_aspect_frame_set( GTK_ASPECT_FRAME( ugtk ), 0.5, 0.5, 1.0, TRUE ); gtk_frame_set_shadow_type( GTK_FRAME( ugtk ), GTK_SHADOW_NONE ); ugtk->drawing_area = gtk_drawing_area_new( ); gtk_widget_add_events( ugtk->drawing_area, GDK_ALL_EVENTS_MASK ); gtk_container_add( GTK_CONTAINER( ugtk ), ugtk->drawing_area ); gtk_widget_show( ugtk->drawing_area ); g_signal_connect( ugtk->drawing_area, "hierarchy-changed", G_CALLBACK( da_hierarchy_changed_cb ), ugtk ); g_signal_connect( ugtk->drawing_area, "configure-event", G_CALLBACK( da_configure_cb ), ugtk ); g_signal_connect( ugtk->drawing_area, "unmap", G_CALLBACK(gtk_widget_destroyed), &ugtk->gc ); g_signal_connect( ugtk->drawing_area, "expose-event", G_CALLBACK( da_expose_event ), ugtk ); g_signal_connect( ugtk->drawing_area, "size-allocate", G_CALLBACK( da_size_allocate ), ugtk ); ugtk->unicap_handle = NULL; ugtk->scale_to_fit = FALSE; ugtk->display_timeout_tag = TIMEOUT_UNSET; }
GtkAspectFrame* cast_GtkAspectFrame(GtkWidget* widget) { return GTK_ASPECT_FRAME(widget); }