Пример #1
0
Файл: pager.c Проект: g7/fbpanel
static void
desk_draw_bg(pager_priv *pg, desk *d1)
{
    Pixmap xpix;
    GdkPixmap *gpix;
    GdkPixbuf *p1, *p2;
    gint width, height, depth;
    FbBg *bg = pg->fbbg;
    GtkWidget *widget = d1->da;

    ENTER;
    if (d1->no) {
        desk *d0 = d1->pg->desks[0];
        if (d0->gpix && d0->xpix != None
              && d0->da->allocation.width == widget->allocation.width
              && d0->da->allocation.height == widget->allocation.height) {
            gdk_draw_drawable(d1->gpix,
                  widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
                  d0->gpix,0, 0, 0, 0,
                  widget->allocation.width,
                  widget->allocation.height);
            d1->xpix = d0->xpix;
            DBG("copy gpix from d0 to d%d\n", d1->no);
            RET();
        }
    }
    xpix = fb_bg_get_xrootpmap(bg);
    d1->xpix = None;
    width = widget->allocation.width;
    height = widget->allocation.height;
    DBG("w %d h %d\n", width, height);
    if (width < 3 || height < 3)
        RET();

    // create new pix
    xpix = fb_bg_get_xrootpmap(bg);
    if (xpix == None)
        RET();
    depth = gdk_drawable_get_depth(widget->window);
    gpix = fb_bg_get_xroot_pix_for_area(bg, 0, 0, gdk_screen_width(), gdk_screen_height(), depth);
    if (!gpix) {
        ERR("fb_bg_get_xroot_pix_for_area failed\n");
        RET();
    }
    p1 = gdk_pixbuf_get_from_drawable(NULL, gpix, NULL, 0, 0, 0, 0,
          gdk_screen_width(), gdk_screen_height());
    if (!p1) {
        ERR("gdk_pixbuf_get_from_drawable failed\n");
        goto err_gpix;
    }
    p2 = gdk_pixbuf_scale_simple(p1, width, height,
          //GDK_INTERP_NEAREST
          //GDK_INTERP_TILES
          //GDK_INTERP_BILINEAR
          GDK_INTERP_HYPER
        );
    if (!p2) {
        ERR("gdk_pixbuf_scale_simple failed\n");
        goto err_p1;
    }
    gdk_draw_pixbuf(d1->gpix, widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
          p2, 0, 0, 0, 0, width, height,  GDK_RGB_DITHER_NONE, 0, 0);

    d1->xpix = xpix;
    g_object_unref(p2);
 err_p1:
    g_object_unref(p1);
 err_gpix:
    g_object_unref(gpix);
    RET();
}
Пример #2
0
Файл: print.c Проект: gdt/viking
static void draw_page_cairo(GtkPrintContext *context, PrintData *data)
{
  cairo_t         *cr;
  GdkPixbuf       *pixbuf_to_draw; 
  cairo_surface_t *surface;
  guchar          *surface_pixels;
  guchar          *pixbuf_pixels;
  gint             stride;
  gint             pixbuf_stride;
  gint             pixbuf_n_channels;
  gdouble          cr_dpi_x;
  gdouble          cr_dpi_y;
  gdouble          scale_x;
  gdouble          scale_y;
  gint             y;

  cr = gtk_print_context_get_cairo_context(context);
  pixbuf_to_draw = gdk_pixbuf_get_from_drawable(NULL,
                               GDK_DRAWABLE(vik_viewport_get_pixmap(data->vvp)),
                               NULL, 0, 0, 0, 0, data->width, data->height);
  surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24,
                                       data->width, data->height);
  
  cr_dpi_x  = gtk_print_context_get_dpi_x  (context);
  cr_dpi_y  = gtk_print_context_get_dpi_y  (context);

  scale_x = cr_dpi_x / data->xres;
  scale_y = cr_dpi_y / data->yres;

  cairo_translate (cr,
                   data->offset_x / cr_dpi_x * 72.0,
                   data->offset_y / cr_dpi_y * 72.0);
  cairo_scale (cr, scale_x, scale_y);

  surface_pixels = cairo_image_surface_get_data (surface);
  stride = cairo_image_surface_get_stride (surface);
  pixbuf_pixels = gdk_pixbuf_get_pixels (pixbuf_to_draw);
  pixbuf_stride = gdk_pixbuf_get_rowstride(pixbuf_to_draw);
  pixbuf_n_channels = gdk_pixbuf_get_n_channels(pixbuf_to_draw);

  // fprintf(stderr, "DEBUG: %s() surface_pixels=%p pixbuf_pixels=%p size=%d surface_width=%d surface_height=%d stride=%d data_height=%d pixmap_stride=%d pixmap_nchannels=%d pixmap_bit_per_Sample=%d\n", __PRETTY_FUNCTION__, surface_pixels, pixbuf_pixels, stride * data->height, cairo_image_surface_get_width(surface), cairo_image_surface_get_height(surface), stride, data->height, gdk_pixbuf_get_rowstride(pixbuf_to_draw), gdk_pixbuf_get_n_channels(pixbuf_to_draw), gdk_pixbuf_get_bits_per_sample(pixbuf_to_draw));

  /* Assume the pixbuf has 8 bits per channel */
  for (y = 0; y < data->height; y++, surface_pixels += stride, pixbuf_pixels += pixbuf_stride) {
    switch (pixbuf_n_channels) {
      case 3:
        copy_row_from_rgb (surface_pixels, pixbuf_pixels, data->width);
        break;
      case 4:
        copy_row_from_rgba (surface_pixels, pixbuf_pixels, data->width);
        break;
    }
  }

  g_object_unref(G_OBJECT(pixbuf_to_draw));

  cairo_set_source_surface(cr, surface, 0, 0);
  cairo_rectangle(cr, 0, 0, data->width, data->height);
  cairo_fill(cr);
  cairo_surface_destroy(surface);
}
static void
setup_font_sample (GtkWidget   *darea,
		   Antialiasing antialiasing,
		   Hinting      hinting)
{
  const char *string1 = "abcfgop AO ";
  const char *string2 = "abcfgop";

  XftColor black, white;
  XRenderColor rendcolor;

  Display *xdisplay = gdk_x11_get_default_xdisplay ();

  GdkColormap *colormap = gdk_rgb_get_colormap ();
  Colormap xcolormap = GDK_COLORMAP_XCOLORMAP (colormap);

  GdkVisual *visual = gdk_colormap_get_visual (colormap);
  Visual *xvisual = GDK_VISUAL_XVISUAL (visual);

  FcPattern *pattern;
  XftFont *font1, *font2;
  XGlyphInfo extents1 = { 0 };
  XGlyphInfo extents2 = { 0 };
  GdkPixmap *pixmap;
  XftDraw *draw;
  GdkPixbuf *tmp_pixbuf, *pixbuf;

  int width, height;
  int ascent, descent;

  pattern = FcPatternBuild (NULL,
			    FC_FAMILY, FcTypeString, "Serif",
			    FC_SLANT, FcTypeInteger, FC_SLANT_ROMAN,
			    FC_SIZE, FcTypeDouble, 18.,
			    NULL);
  font1 = open_pattern (pattern, antialiasing, hinting);
  FcPatternDestroy (pattern);

  pattern = FcPatternBuild (NULL,
			    FC_FAMILY, FcTypeString, "Serif",
			    FC_SLANT, FcTypeInteger, FC_SLANT_ITALIC,
			    FC_SIZE, FcTypeDouble, 20.,
			    NULL);
  font2 = open_pattern (pattern, antialiasing, hinting);
  FcPatternDestroy (pattern);

  ascent = 0;
  descent = 0;
  if (font1) {
    XftTextExtentsUtf8 (xdisplay, font1, (unsigned char *) string1,
			strlen (string1), &extents1);
    ascent = MAX (ascent, font1->ascent);
    descent = MAX (descent, font1->descent);
  }

  if (font2) {
    XftTextExtentsUtf8 (xdisplay, font2, (unsigned char *) string2,
			strlen (string2), &extents2);
    ascent = MAX (ascent, font2->ascent);
    descent = MAX (descent, font2->descent);
  }

  width = extents1.xOff + extents2.xOff + 4;
  height = ascent + descent + 2;

  pixmap = gdk_pixmap_new (NULL, width, height, visual->depth);

  draw = XftDrawCreate (xdisplay, GDK_DRAWABLE_XID (pixmap), xvisual, xcolormap);

  rendcolor.red = 0;
  rendcolor.green = 0;
  rendcolor.blue = 0;
  rendcolor.alpha = 0xffff;
  XftColorAllocValue (xdisplay, xvisual, xcolormap, &rendcolor, &black);

  rendcolor.red = 0xffff;
  rendcolor.green = 0xffff;
  rendcolor.blue = 0xffff;
  rendcolor.alpha = 0xffff;
  XftColorAllocValue (xdisplay, xvisual, xcolormap, &rendcolor, &white);
  XftDrawRect (draw, &white, 0, 0, width, height);
  if (font1)
    XftDrawStringUtf8 (draw, &black, font1,
		       2, 2 + ascent,
		       (unsigned char *) string1, strlen (string1));
  if (font2)
    XftDrawStringUtf8 (draw, &black, font2,
		       2 + extents1.xOff, 2 + ascent,
		       (unsigned char *) string2, strlen (string2));

  XftDrawDestroy (draw);

  if (font1)
    XftFontClose (xdisplay, font1);
  if (font2)
    XftFontClose (xdisplay, font2);

  tmp_pixbuf = gdk_pixbuf_get_from_drawable (NULL, pixmap, colormap, 0, 0, 0, 0, width, height);
  pixbuf = gdk_pixbuf_scale_simple (tmp_pixbuf, 1 * width, 1 * height, GDK_INTERP_TILES);

  g_object_unref (pixmap);
  g_object_unref (tmp_pixbuf);

  g_object_set_data_full (G_OBJECT (darea), "sample-pixbuf",
			  pixbuf, (GDestroyNotify) g_object_unref);

  g_signal_connect (darea, "size_request", G_CALLBACK (sample_size_request), NULL);
  g_signal_connect (darea, "expose_event", G_CALLBACK (sample_expose), NULL);
}
Пример #4
0
static GdkPixbuf *
take_window_shot (Window   child,
                  gboolean include_decoration)
{
  GdkDisplay *display;
  GdkScreen  *screen;
  GdkWindow  *window;
  Window      xid;
  gint        x_orig, y_orig;
  gint        x = 0, y = 0;
  gint        width, height;
  GdkPixbuf  *tmp, *tmp2;
  GdkPixbuf  *retval;

  display = gdk_display_get_default ();
  screen = gdk_screen_get_default ();

  if (include_decoration)
    xid = find_toplevel_window (gdk_x11_display_get_xdisplay (display), child);
  else
    xid = child;

  window = gdk_x11_window_foreign_new_for_display (display, xid);

  width  = gdk_window_get_width  (window);
  height = gdk_window_get_height (window);
  gdk_window_get_origin (window, &x_orig, &y_orig);

  if (x_orig < 0)
    {
      x = - x_orig;
      width = width + x_orig;
      x_orig = 0;
    }

  if (y_orig < 0)
    {
      y = - y_orig;
      height = height + y_orig;
      y_orig = 0;
    }

  if (x_orig + width > gdk_screen_get_width (screen))
    width = gdk_screen_get_width (screen) - x_orig;

  if (y_orig + height > gdk_screen_get_height (screen))
    height = gdk_screen_get_height (screen) - y_orig;

  tmp = gdk_pixbuf_get_from_drawable (NULL, window, NULL,
                                      x, y, 0, 0, width, height);

  if (include_decoration)
    tmp2 = remove_shaped_area (tmp, xid);
  else
    tmp2 = add_border_to_shot (tmp);

  retval = create_shadowed_pixbuf (tmp2);

  g_object_unref (tmp);
  g_object_unref (tmp2);

  return retval;
}
Пример #5
0
static GdkPixbuf* drawtheme_calc_alpha (MCThemeDrawInfo &p_info)
{
	GdkPixbuf *t_pb_black;
    GdkPixbuf *t_pb_white;
    
	GdkPixmap *t_black ;
	GdkPixmap *t_white ;

	GdkColormap *cm ;
	GdkVisual *best_vis ;
	
	uint4	t_w ;
	uint4	t_h ;	
		
	t_w = p_info.drect.width ;
	t_h = p_info.drect.height ;

	// MM-2013-11-06: [[ Bug 11360 ]] Make sure we take into account the screen depth when creating pixmaps.
	uint4 t_screen_depth;
	t_screen_depth = ((MCScreenDC*) MCscreen) -> getdepth();
	
	// Create two new pixmaps
	t_black = gdk_pixmap_new(NULL, t_w, t_h, t_screen_depth);
	t_white = gdk_pixmap_new(NULL, t_w, t_h, t_screen_depth);
	
	// We need to attach a colourmap to the Drawables in GDK
	best_vis = gdk_visual_get_best_with_depth(t_screen_depth);
    if (best_vis == NULL)
        return NULL;
    
	cm = gdk_colormap_new(best_vis, FALSE) ;
	gdk_drawable_set_colormap(t_black, cm);
	gdk_drawable_set_colormap(t_white, cm);

	// Render solid black into one and white into the other.
	fill_gdk_drawable(t_black, cm, 0, 0, 0, t_w, t_h);
	fill_gdk_drawable(t_white, cm, 65535, 65535, 65535, t_w, t_h);
	
	MCThemeDrawInfo t_info;
	
	t_info = p_info;
	moz_gtk_widget_paint ( p_info.moztype, t_white , &t_info.drect, &t_info.cliprect, &t_info.state, t_info.flags ) ;
	
	t_info = p_info;
	moz_gtk_widget_paint ( p_info.moztype, t_black , &t_info.drect, &t_info.cliprect, &t_info.state, t_info.flags ) ;

	gdk_flush();
	
    // Convert the server-side pixmaps into client-side pixbufs. The black
    // pixbuf will need to have an alpha channel so that we can fill it in.
    t_pb_black = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, t_w, t_h);
    if (t_pb_black == NULL)
        return NULL;
        
    t_pb_white = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, t_w, t_h);
    if (t_pb_white == NULL)
        return NULL;
    
    t_pb_black = gdk_pixbuf_get_from_drawable(t_pb_black, t_black, NULL, 0, 0, 0, 0, t_w, t_h);
    if (t_pb_black == NULL)
        return NULL;
    
    t_pb_white = gdk_pixbuf_get_from_drawable(t_pb_white, t_white, NULL, 0, 0, 0, 0, t_w, t_h);
    if (t_pb_white == NULL)
        return NULL;
    
	// Calculate the alpha from these two bitmaps --- the t_bm_black image now has full ARGB
    // Note that this also frees the t_pb_white pixbuf
	calc_alpha_from_pixbufs(t_pb_black, t_pb_white);
	
	// clean up.
	g_object_unref(t_black);
	g_object_unref(t_white);
	g_object_unref(cm);
		
	return t_pb_black;
}
Пример #6
0
static gint32
shoot (GdkScreen *screen)
{
  GdkDisplay   *display;
  GdkWindow    *window;
  GdkPixbuf    *screenshot;
  GdkRegion    *shape = NULL;
  GdkRectangle  rect;
  GdkRectangle  screen_rect;
  gchar        *name  = NULL;
  gint32        image;
  gint          screen_x;
  gint          screen_y;
  gint          x, y;

  /* use default screen if we are running non-interactively */
  if (screen == NULL)
    screen = gdk_screen_get_default ();

  display = gdk_screen_get_display (screen);

  screen_rect.x      = 0;
  screen_rect.y      = 0;
  screen_rect.width  = gdk_screen_get_width (screen);
  screen_rect.height = gdk_screen_get_height (screen);

  if (shootvals.shoot_type == SHOOT_REGION)
    {
      rect.x = MIN (shootvals.x1, shootvals.x2);
      rect.y = MIN (shootvals.y1, shootvals.y2);
      rect.width  = ABS (shootvals.x2 - shootvals.x1);
      rect.height = ABS (shootvals.y2 - shootvals.y1);
    }
  else
    {
      if (shootvals.shoot_type == SHOOT_ROOT)
        {
          window = gdk_screen_get_root_window (screen);
        }
      else
        {
          window = gdk_window_foreign_new_for_display (display,
                                                       shootvals.window_id);
        }

      if (! window)
        {
          g_message (_("Specified window not found"));
          return -1;
        }

      gdk_drawable_get_size (GDK_DRAWABLE (window), &rect.width, &rect.height);
      gdk_window_get_origin (window, &x, &y);

      rect.x = x;
      rect.y = y;
    }

  if (! gdk_rectangle_intersect (&rect, &screen_rect, &rect))
    return -1;

  window = gdk_screen_get_root_window (screen);
  gdk_window_get_origin (window, &screen_x, &screen_y);

  screenshot = gdk_pixbuf_get_from_drawable (NULL, window, NULL,
                                             rect.x - screen_x,
                                             rect.y - screen_y,
                                             0, 0, rect.width, rect.height);

  gdk_display_beep (display);
  gdk_flush ();

  if (! screenshot)
    {
      g_message (_("There was an error taking the screenshot."));
      return -1;
    }

  if (shootvals.shoot_type == SHOOT_WINDOW)
    {
      name = window_get_title (display, shootvals.window_id);

      shape = window_get_shape (screen, shootvals.window_id);

      if (shape)
        gdk_region_offset (shape, x - rect.x, y - rect.y);
    }

  image = create_image (screenshot, shape, name);

  g_object_unref (screenshot);

  if (shape)
    gdk_region_destroy (shape);

  g_free (name);

  return image;
}
static void
button_clicked(GtkWidget * button,  ScreenshotData * sd)
{
    GdkPixbuf * screenshot;
    GdkPixbuf * thumbnail;
    GdkWindow * window;
    GdkNativeWindow nwindow;
    gint delay;

    gint width;
    gint height;

    gchar * filename = NULL;
    gchar * basename = NULL;
    gchar * curdir = NULL;

    
    if (sd->whole_screen) {
        window = gdk_get_default_root_window();
    } else {
        if (delay = sd->window_delay) {
            g_timeout_add(1000, delay_callback, &delay);
            gtk_main();
        }
        nwindow = select_window(gdk_screen_get_default());
        if (nwindow) {
            window = gdk_window_foreign_new(nwindow);
        } else {
            window = gdk_get_default_root_window();
        }
    }

    gdk_drawable_get_size(window, &width, &height);
    
    if (delay = sd->screenshot_delay) {
        g_timeout_add(1000, delay_callback, &delay);
        gtk_main();
    }
    
    screenshot = gdk_pixbuf_get_from_drawable (NULL,
					       window,
					       NULL, 0, 0, 0, 0,
					       width, height);
    
    thumbnail = gdk_pixbuf_scale_simple (screenshot,
				         width/5,
				         height/5, GDK_INTERP_BILINEAR);
    
    gtk_image_set_from_pixbuf (GTK_IMAGE (sd->preview), thumbnail);
    g_object_unref (thumbnail);
            filename = generate_filename_for_uri (xfce_file_chooser_get_current_folder(XFCE_FILE_CHOOSER (sd->chooser)));
    
    if (sd->ask_for_file && filename)
    {    
        gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (sd->chooser), filename);
        if (gtk_dialog_run (GTK_DIALOG (sd->chooser)) == GTK_RESPONSE_ACCEPT)
        {    
        filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(sd->chooser));
        }
        gtk_widget_hide (GTK_WIDGET (sd->chooser));
    }
    else
    {
       /* sd->counter++;
        basename = g_strdup_printf ("Screenshot-%d.png", sd->counter);
       filename = g_build_filename (sd->screenshots_dir, basename, NULL);
        curdir = g_get_current_dir();
        filename = g_build_filename (curdir, basename, NULL);
        g_free(basename);
        */
    }
    
    if (filename) {
        gdk_pixbuf_save (screenshot, filename, "png", NULL, NULL);
        g_free (filename);
    }
}
Пример #8
0
void
testcase_exercise (Testcase* self)
{
	guchar   * gdkdata;
	guchar   * cairodata;
	gsize      index;
	GdkPixbuf* gdk_pixbuf;
	GdkPixbuf* cairo_pixbuf;
	cairo_t* cr;

	g_return_if_fail (IS_TESTCASE (self));

	g_signal_emit (self,
		       testcase_signals[EXERCISE_GDK],
		       0,
		       PRIV(self)->gdk_pixmap,
		       PRIV(self)->gdk_gc);

	cr = gdk_cairo_create (PRIV(self)->cairo_pixmap);
	g_signal_emit (self,
		       testcase_signals[EXERCISE_CAIRO],
		       0,
		       cr,
		       PRIV(self)->cairo_gc);
	cairo_destroy (cr);

	gdk_pixbuf   = gdk_pixbuf_get_from_drawable (NULL,
						     PRIV(self)->gdk_pixmap,
								 gdk_rgb_get_colormap (),
								 0, 0,
								 0, 0,
								 100, 80);
	cairo_pixbuf = gdk_pixbuf_get_from_drawable (NULL,
						     PRIV(self)->cairo_pixmap,
								 gdk_rgb_get_colormap (),
								 0, 0,
								 0, 0,
								 100, 80);

	gdkdata   = gdk_pixbuf_get_pixels (gdk_pixbuf);
	cairodata = gdk_pixbuf_get_pixels (cairo_pixbuf);

	g_return_if_fail (gdk_pixbuf_get_rowstride (gdk_pixbuf) == gdk_pixbuf_get_rowstride (cairo_pixbuf));
	g_return_if_fail (gdk_pixbuf_get_n_channels (gdk_pixbuf) == gdk_pixbuf_get_n_channels (cairo_pixbuf));
	g_return_if_fail (gdk_pixbuf_get_height (gdk_pixbuf) == gdk_pixbuf_get_height (cairo_pixbuf));
	g_return_if_fail (gdk_pixbuf_get_width (gdk_pixbuf) == gdk_pixbuf_get_width (cairo_pixbuf));

	PRIV(self)->passed = TRUE;

	for (index = 0; index < gdk_pixbuf_get_height (gdk_pixbuf) * gdk_pixbuf_get_rowstride (gdk_pixbuf); index++) {
		if (gdkdata[index] != cairodata[index]) {
			gchar* filepath;
			g_warning ("Eeek! Differences at byte %d: %c vs. %c",
				   index,
				   gdkdata[index],
				   cairodata[index]);
			PRIV(self)->passed = FALSE;

			filepath = g_strdup_printf ("%s-gdk.png",
						    g_get_prgname ());
			gdk_pixbuf_save (gdk_pixbuf,
					 filepath,
					 "png",
					 NULL, /* FIXME: handle errors */
					 NULL);
			g_message ("=> wrote gdk image to \"%s\"",
				   filepath);
			g_free (filepath);

			filepath = g_strdup_printf ("%s-cairo.png",
						    g_get_prgname ());
			gdk_pixbuf_save (cairo_pixbuf,
					 filepath,
					 "png",
					 NULL, /* FIXME: handle errors */
					 NULL);
			g_message ("=> wrote cairo image to \"%s\"",
				   filepath);
			g_free (filepath);
			break;
		}
	}

	g_object_unref (gdk_pixbuf);
	g_object_unref (cairo_pixbuf);
}
Пример #9
0
int  hid_screenshot(char *filename)
{
	gchar *outfile;
	gchar *ext = "";
	gchar *type = "";

	GdkPixbuf *pixbuf = { 0 };
	gboolean result = FALSE;
	GError *error = NULL;

	if(filename == NULL) 
	{
		switch(options2.format) 
		{
			case IMG_JPG: ext = "jpg"; type = "jpeg"; break;
			case IMG_PNG: ext = "png"; type = "png";  break;
			case IMG_ICO: ext = "ico"; type = "ico";  break;
 		    case IMG_EPS: ext = "eps"; type = "eps";  break;
 		    case IMG_PDF: ext = "pdf"; type = "pdf";  break;
			default: ext = "png"; type = "png";  break;
		}
      
		outfile = g_strdup_printf("%s%03i.%s", options2.file, options2.counter, ext);
	} 
	else 
	{
		outfile = g_strdup(filename);
	}

	printl(0, "Screenshot to %s... ", outfile);

	if((options2.size == IMG_LCD) && (options2.type == IMG_BW)) 
	{
		// get pixbuf from TI memory (LCD buffer)
		pixbuf = hid_copy_lcd();
	} 
	else if((options2.size == IMG_LCD) && (options2.type == IMG_COL)) 
	{
        // get pixbuf from grayscale lcd
		pixbuf = gdk_pixbuf_copy(si.l);
	} 
	else if(options2.size == IMG_SKIN) 
	{
		// get pixbuf from backing pixmap
		pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, NULL,
					0, 0, 0, 0, skin_infos.width, skin_infos.height);
	}

	switch (options2.format)
	{
	case IMG_EPS:
		result = tiemu_screen_write_eps(outfile, pixbuf, &error);
		break;
	case IMG_PDF:
		result = tiemu_screen_write_pdf(outfile, pixbuf, &error);
		break;
	default:
		result = gdk_pixbuf_save(pixbuf, outfile, type, &error, NULL);
		break;
	}

	if (result == FALSE) 
	{
		printl(0, "Failed to save pixbuf file: %s: %s\n", outfile, error->message);
		g_error_free(error);
	}
	g_object_unref(pixbuf);

	printl(0, "Done !\n");
	options2.counter++;
	g_free(filename);

	return 0;
}
Пример #10
0
static GdkPixbuf* preview_window(RrTheme *theme, const gchar *titlelayout,
                                 gboolean focus, gint width, gint height)
{
    RrAppearance *title;
    RrAppearance *handle;
    RrAppearance *a;

    GdkPixmap *pixmap;
    GdkPixbuf *pixbuf = NULL;
    GdkPixbuf *scratch;

    gint w, label_w, h, x, y;

    const gchar *layout;

    title = focus ? theme->a_focused_title : theme->a_unfocused_title;

    /* set border */
    pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
    gdk_pixbuf_fill(pixbuf,
                    rr_color_pixel(focus ?
                                   theme->frame_focused_border_color :
                                   theme->frame_unfocused_border_color));

    /* title */
    w = width - 2*theme->fbwidth;
    h = theme->title_height;
    theme_pixmap_paint(title, w, h);

    x = y = theme->fbwidth;
    pixmap = gdk_pixmap_foreign_new(title->pixmap);
    pixbuf = gdk_pixbuf_get_from_drawable(pixbuf, pixmap,
                                          gdk_colormap_get_system(),
                                          0, 0, x, y, w, h);

    /* calculate label width */
    label_w = width - (theme->paddingx + theme->fbwidth + 1) * 2;

    for (layout = titlelayout; *layout; layout++) {
        switch (*layout) {
        case 'N':
            label_w -= theme->button_size + 2 + theme->paddingx + 1;
            break;
        case 'D':
        case 'S':
        case 'I':
        case 'M':
        case 'C':
            label_w -= theme->button_size + theme->paddingx + 1;
            break;
        default:
            break;
        }
    }

    x = theme->paddingx + theme->fbwidth + 1;
    y += theme->paddingy;
    for (layout = titlelayout; *layout; layout++) {
        /* icon */
        if (*layout == 'N') {
            a = theme->a_icon;
            /* set default icon */
            a->texture[0].type = RR_TEXTURE_RGBA;
            a->texture[0].data.rgba.width = 48;
            a->texture[0].data.rgba.height = 48;
            a->texture[0].data.rgba.alpha = 0xff;
            a->texture[0].data.rgba.data = theme->def_win_icon;

            a->surface.parent = title;
            a->surface.parentx = x - theme->fbwidth;
            a->surface.parenty = theme->paddingy;

            w = h = theme->button_size + 2;

            theme_pixmap_paint(a, w, h);
            pixmap = gdk_pixmap_foreign_new(a->pixmap);
            pixbuf = gdk_pixbuf_get_from_drawable(pixbuf, pixmap,
                                                  gdk_colormap_get_system(),
                                                  0, 0, x, y, w, h);

            x += theme->button_size + 2 + theme->paddingx + 1;
        } else if (*layout == 'L') { /* label */
            a = focus ? theme->a_focused_label : theme->a_unfocused_label;
            a->texture[0].data.text.string = focus ? "Active" : "Inactive";

            a->surface.parent = title;
            a->surface.parentx = x - theme->fbwidth;
            a->surface.parenty = theme->paddingy;
            w = label_w;
            h = theme->label_height;

            theme_pixmap_paint(a, w, h);
            pixmap = gdk_pixmap_foreign_new(a->pixmap);
            pixbuf = gdk_pixbuf_get_from_drawable(pixbuf, pixmap,
                                                  gdk_colormap_get_system(),
                                                  0, 0, x, y, w, h);

            x += w + theme->paddingx + 1;
        } else {
            /* buttons */
            switch (*layout) {
            case 'D':
                a = focus ?
                    theme->btn_desk->a_focused_unpressed :
                    theme->btn_desk->a_unfocused_unpressed;
                break;
            case 'S':
                a = focus ?
                    theme->btn_shade->a_focused_unpressed :
                    theme->btn_shade->a_unfocused_unpressed;
                break;
            case 'I':
                a = focus ?
                    theme->btn_iconify->a_focused_unpressed :
                    theme->btn_iconify->a_unfocused_unpressed;
                break;
            case 'M':
                a = focus ?
                    theme->btn_max->a_focused_unpressed :
                    theme->btn_max->a_unfocused_unpressed;
                break;
            case 'C':
                a = focus ?
                    theme->btn_close->a_focused_unpressed :
                    theme->btn_close->a_unfocused_unpressed;
                break;
            default:
                continue;
            }

            a->surface.parent = title;
            a->surface.parentx = x - theme->fbwidth;
            a->surface.parenty = theme->paddingy + 1;

            w = theme->button_size;
            h = theme->button_size;

            theme_pixmap_paint(a, w, h);
            pixmap = gdk_pixmap_foreign_new(a->pixmap);
            /* use y + 1 because these buttons should be centered wrt the label
             */
            pixbuf = gdk_pixbuf_get_from_drawable(pixbuf, pixmap,
                                                  gdk_colormap_get_system(),
                                                  0, 0, x, y + 1, w, h);

            x += theme->button_size + theme->paddingx + 1;
        }
    }

    if (theme->handle_height) {
        /* handle */
        handle = focus ? theme->a_focused_handle : theme->a_unfocused_handle;
        x = 2*theme->fbwidth + theme->grip_width;
        y = height - theme->fbwidth - theme->handle_height;
        w = width - 4*theme->fbwidth - 2*theme->grip_width;
        h = theme->handle_height;

        theme_pixmap_paint(handle, w, h);
        pixmap = gdk_pixmap_foreign_new(handle->pixmap);
        pixbuf = gdk_pixbuf_get_from_drawable(pixbuf, pixmap,
                                              gdk_colormap_get_system(),
                                              0, 0, x, y, w, h);

        /* openbox handles this drawing stuff differently (it fills the bottom
         * of the window with the handle), so it avoids this bug where
         * parentrelative grips are not fully filled. i'm avoiding it slightly
         * differently. */

        theme_pixmap_paint(handle, width, h);

        /* grips */
        a = focus ? theme->a_focused_grip : theme->a_unfocused_grip;
        a->surface.parent = handle;

        x = theme->fbwidth;
        /* same y and h as handle */
        w = theme->grip_width;

        theme_pixmap_paint(a, w, h);
        pixmap = gdk_pixmap_foreign_new(a->pixmap);
        pixbuf = gdk_pixbuf_get_from_drawable(pixbuf, pixmap,
                                              gdk_colormap_get_system(),
                                              0, 0, x, y, w, h);

        /* right grip */
        x = width - theme->fbwidth - theme->grip_width;
        pixbuf = gdk_pixbuf_get_from_drawable(pixbuf, pixmap,
                                              gdk_colormap_get_system(),
                                              0, 0, x, y, w, h);
    }

    /* title separator colour */
    x = theme->fbwidth;
    y = theme->fbwidth + theme->title_height;
    w = width - 2*theme->fbwidth;
    h = theme->fbwidth;

    scratch = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, w, h);
    gdk_pixbuf_fill(scratch, rr_color_pixel(focus ?
                                            theme->title_separator_focused_color :
                                            theme->title_separator_unfocused_color));

    gdk_pixbuf_copy_area(scratch, 0, 0, w, h, pixbuf, x, y);

    /* retarded way of adding client colour */
    x = theme->fbwidth;
    y = theme->title_height + 2*theme->fbwidth;
    w = width - 2*theme->fbwidth;
    h = height - theme->title_height - 3*theme->fbwidth -
        (theme->handle_height ? (theme->fbwidth + theme->handle_height) : 0);

    scratch = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, w, h);
    gdk_pixbuf_fill(scratch, rr_color_pixel(focus ?
                                            theme->cb_focused_color :
                                            theme->cb_unfocused_color));

    gdk_pixbuf_copy_area(scratch, 0, 0, w, h, pixbuf, x, y);

    /* clear (no alpha!) the area where the client resides */
    gdk_pixbuf_fill(scratch, 0xffffffff);
    gdk_pixbuf_copy_area(scratch, 0, 0,
                         w - 2*theme->cbwidthx,
                         h - 2*theme->cbwidthy,
                         pixbuf,
                         x + theme->cbwidthx,
                         y + theme->cbwidthy);

    return pixbuf;
}
Пример #11
0
/* XXX: Make this more general */
static GdkPixbuf* preview_menu(RrTheme *theme)
{
    RrAppearance *title;
    RrAppearance *title_text;

    RrAppearance *menu;
    RrAppearance *background;

    RrAppearance *normal;
    RrAppearance *disabled;
    RrAppearance *selected;
    RrAppearance *bullet; /* for submenu */

    GdkPixmap *pixmap;
    GdkPixbuf *pixbuf;

    /* width and height of the whole menu */
    gint width, height;
    gint x, y;
    gint title_h;
    gint tw, th;
    gint bw, bh;
    gint unused;

    /* set up appearances */
    title = theme->a_menu_title;

    title_text = theme->a_menu_text_title;
    title_text->surface.parent = title;
    title_text->texture[0].data.text.string = "Menu";

    normal = theme->a_menu_text_normal;
    normal->texture[0].data.text.string = "Normal";

    disabled = theme->a_menu_text_disabled;
    disabled->texture[0].data.text.string = "Disabled";

    selected = theme->a_menu_text_selected;
    selected->texture[0].data.text.string = "Selected";

    bullet = theme->a_menu_bullet_normal;

    /* determine window size */
    RrMinSize(normal, &width, &th);
    width += th + PADDING; /* make space for the bullet */
    //height = th;

    width += 2*theme->mbwidth + 2*PADDING;

    /* get minimum title size */
    RrMinSize(title, &tw, &title_h);

    /* size of background behind each text line */
    bw = width - 2*theme->mbwidth;
    //title_h += 2*PADDING;
    title_h = theme->menu_title_height;

    RrMinSize(normal, &unused, &th);
    bh = th + 2*PADDING;

    height = title_h + 3*bh + 3*theme->mbwidth;

    //height += 3*th + 3*theme->mbwidth + 5*PADDING;

    /* set border */
    pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, width, height);
    gdk_pixbuf_fill(pixbuf, rr_color_pixel(theme->menu_border_color));

    /* draw title */
    x = y = theme->mbwidth;
    theme_pixmap_paint(title, bw, title_h);

    /* draw title text */
    title_text->surface.parentx = 0;
    title_text->surface.parenty = 0;

    theme_pixmap_paint(title_text, bw, title_h);

    pixmap = gdk_pixmap_foreign_new(title_text->pixmap);
    pixbuf = gdk_pixbuf_get_from_drawable(pixbuf, pixmap,
                                          gdk_colormap_get_system(),
                                          0, 0, x, y, bw, title_h);

    /* menu appears after title */
    y += theme->mbwidth + title_h;

    /* fill in menu appearance, used as the parent to every menu item's bg */
    menu = theme->a_menu;
    th = height - 3*theme->mbwidth - title_h;
    theme_pixmap_paint(menu, bw, th);

    pixmap = gdk_pixmap_foreign_new(menu->pixmap);
    pixbuf = gdk_pixbuf_get_from_drawable(pixbuf, pixmap,
                                          gdk_colormap_get_system(),
                                          0, 0, x, y, bw, th);

    /* fill in background appearance, used as the parent to text items */
    background = theme->a_menu_normal;
    background->surface.parent = menu;
    background->surface.parentx = 0;
    background->surface.parenty = 0;

    /* draw background for normal entry */
    theme_pixmap_paint(background, bw, bh);
    pixmap = gdk_pixmap_foreign_new(background->pixmap);
    pixbuf = gdk_pixbuf_get_from_drawable(pixbuf, pixmap,
                                          gdk_colormap_get_system(),
                                          0, 0, x, y, bw, bh);

    /* draw normal entry */
    normal->surface.parent = background;
    normal->surface.parentx = PADDING;
    normal->surface.parenty = PADDING;
    x += PADDING;
    y += PADDING;
    RrMinSize(normal, &tw, &th);
    theme_pixmap_paint(normal, tw, th);
    pixmap = gdk_pixmap_foreign_new(normal->pixmap);
    pixbuf = gdk_pixbuf_get_from_drawable(pixbuf, pixmap,
                                          gdk_colormap_get_system(),
                                          0, 0, x, y, tw, th);

    /* draw bullet */
    RrMinSize(normal, &tw, &th);
    bullet->surface.parent = background;
    bullet->surface.parentx = bw - th;
    bullet->surface.parenty = PADDING;
    theme_pixmap_paint(bullet, th, th);
    pixmap = gdk_pixmap_foreign_new(bullet->pixmap);
    pixbuf = gdk_pixbuf_get_from_drawable(pixbuf, pixmap,
                                          gdk_colormap_get_system(),
                                          0, 0, width - theme->mbwidth - th, y,
                                          th, th);

    y += th + 2*PADDING;

    /* draw background for disabled entry */
    background->surface.parenty = bh;
    theme_pixmap_paint(background, bw, bh);
    pixmap = gdk_pixmap_foreign_new(background->pixmap);
    pixbuf = gdk_pixbuf_get_from_drawable(pixbuf, pixmap,
                                          gdk_colormap_get_system(),
                                          0, 0, x - PADDING, y - PADDING,
                                          bw, bh);

    /* draw disabled entry */
    RrMinSize(disabled, &tw, &th);
    disabled->surface.parent = background;
    disabled->surface.parentx = PADDING;
    disabled->surface.parenty = PADDING;
    theme_pixmap_paint(disabled, tw, th);
    pixmap = gdk_pixmap_foreign_new(disabled->pixmap);
    pixbuf = gdk_pixbuf_get_from_drawable(pixbuf, pixmap,
                                          gdk_colormap_get_system(),
                                          0, 0, x, y, tw, th);

    y += th + 2*PADDING;

    /* draw background for selected entry */
    background = theme->a_menu_selected;
    background->surface.parent = menu;
    background->surface.parentx = 2*bh;

    theme_pixmap_paint(background, bw, bh);
    pixmap = gdk_pixmap_foreign_new(background->pixmap);
    pixbuf = gdk_pixbuf_get_from_drawable(pixbuf, pixmap,
                                          gdk_colormap_get_system(),
                                          0, 0, x - PADDING, y - PADDING,
                                          bw, bh);

    /* draw selected entry */
    RrMinSize(selected, &tw, &th);
    selected->surface.parent = background;
    selected->surface.parentx = PADDING;
    selected->surface.parenty = PADDING;
    theme_pixmap_paint(selected, tw, th);
    pixmap = gdk_pixmap_foreign_new(selected->pixmap);
    pixbuf = gdk_pixbuf_get_from_drawable(pixbuf, pixmap,
                                          gdk_colormap_get_system(),
                                          0, 0, x, y, tw, th);

    return pixbuf;
}
Пример #12
0
G_MODULE_EXPORT void save_as(const char *filename, int type)
{

	FILE *fp;
	unsigned int i, j;
	double freq, k;
	mat_t *mat;
	matvar_t *matvar;
	int dims[2];
	char tmp[20];
	GdkPixbuf *pixbuf;
	GError *err=NULL;
	GdkColormap *cmap;
	gint width, height;
	gboolean ret = true;
	char *name;
	gdouble *tmp_data;

	name = malloc(strlen(filename) + 5);
	switch(type) {
		/* Response Codes encoded in glade file */
		case GTK_RESPONSE_DELETE_EVENT:
		case GTK_RESPONSE_CANCEL:
			break;
		case SAVE_VSA:
			/* Allow saving data when only in Time Domanin */
			if ((gtk_combo_box_get_active(GTK_COMBO_BOX(plot_domain)) != TIME_PLOT) &&
			    (gtk_combo_box_get_active(GTK_COMBO_BOX(plot_domain)) != XY_PLOT)) {
				create_blocking_popup(GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, "Invalid Plot Type",
					"Please make sure to set the Plot Type to \"Time Domanin\" before saving data.");
				return;
			}
			/* Save as Agilent VSA formatted file */
			if (!strncasecmp(&filename[strlen(filename)-4], ".txt", 4))
				strcpy(name, filename);
			else
				sprintf(name, "%s.txt", filename);

			fp = fopen(name, "w");
			if (!fp)
				break;
			fprintf(fp, "InputZoom\tTRUE\n");
			fprintf(fp, "InputCenter\t0\n");
			fprintf(fp, "InputRange\t1\n");
			fprintf(fp, "InputRefImped\t50\n");
			fprintf(fp, "XStart\t0\n");
			if (!strcmp(adc_scale, "M"))
				freq = adc_freq * 1000000;
			else if (!strcmp(adc_scale, "k"))
				freq = adc_freq * 1000;
			else {
				printf("error in writing\n");
				break;
			}

			fprintf(fp, "XDelta\t%-.17f\n", 1.0/freq);
			fprintf(fp, "XDomain\t2\n");
			fprintf(fp, "XUnit\tSec\n");
			fprintf(fp, "YUnit\tV\n");
			fprintf(fp, "FreqValidMax\t%e\n", freq / 2);
			fprintf(fp, "FreqValidMin\t-%e\n", freq / 2);
			fprintf(fp, "Y\n");

			for (j = 0; j < num_samples; j++) {
				for (i = 0; i < num_active_channels ; i++) {
					fprintf(fp, "%g", channel_data[i][j]);
					if (i < (num_active_channels - 1))
						fprintf(fp, "\t");
				}
				fprintf(fp, "\n");
			}
			fprintf(fp, "\n");
			fclose(fp);

			break;
		case SAVE_MAT:
			/* Allow saving data when only in Time Domanin */
			if (gtk_combo_box_get_active(GTK_COMBO_BOX(plot_domain)) != TIME_PLOT) {
				create_blocking_popup(GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, "Invalid Plot Type",
					"Please make sure to set the Plot Type to \"Time Domanin\" before saving data.");
				return;
			}
			/* Matlab file
			 * http://na-wiki.csc.kth.se/mediawiki/index.php/MatIO
			 */
			if (!strncasecmp(&filename[strlen(filename)-4], ".mat", 4))
				strcpy(name, filename);
			else
				sprintf(name, "%s.mat", filename);

			dims[1] = 1;
			dims[0] = num_samples;

			mat = Mat_Open(name, MAT_ACC_RDWR);
			if(mat) {
				for (i = 0; i < num_active_channels; i++) {
					sprintf(tmp, "in_voltage%d", i);
					if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(save_mat_scale))) {
						matvar = Mat_VarCreate(tmp, MAT_C_SINGLE,
								MAT_T_SINGLE, 2, dims, channel_data[i], 0);
					} else {
						tmp_data = g_new(gdouble, num_samples);
						if (channels[i].is_signed)
							k = channels[i].bits_used - 1;
						else
							k = channels[i].bits_used;

						for (j = 0; j < num_samples; j++) {
							tmp_data[j] = (gdouble)channel_data[i][j] /
									(pow(2.0, k));
						}
						matvar = Mat_VarCreate(tmp, MAT_C_DOUBLE,
								MAT_T_DOUBLE, 2, dims, tmp_data, 0);
						g_free(tmp_data);
					}
					if (!matvar)
						printf("error creating matvar on channel %i\n", i);
					else {
						Mat_VarWrite(mat, matvar, 0);
						Mat_VarFree(matvar);
					}
				}
				Mat_Close(mat);
			}
			break;
		case SAVE_CSV:
			/* Allow saving data when only in Time Domanin */
			if (gtk_combo_box_get_active(GTK_COMBO_BOX(plot_domain)) != TIME_PLOT) {
				create_blocking_popup(GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, "Invalid Plot Type",
					"Please make sure to set the Plot Type to \"Time Domanin\" before saving data.");
				return;
			}
			/* save comma seperated valus (csv) */
			if (!strncasecmp(&filename[strlen(filename)-4], ".csv", 4))
				strcpy(name, filename);
			else
				sprintf(name, "%s.csv", filename);

			fp = fopen(name, "w");
			if (!fp)
				break;

			for (j = 0; j < num_samples; j++) {
				for (i = 0; i < num_active_channels ; i++) {
					fprintf(fp, "%g", channel_data[i][j]);
					if (i < (num_active_channels - 1))
						fprintf(fp, ", ");
				}
				fprintf(fp, "\n");
			}
			fprintf(fp, "\n");
			fclose(fp);
			break;
		case SAVE_PNG:
			/* save_png */
			if (!strncasecmp(&filename[strlen(filename)-4], ".png", 4))
				strcpy(name, filename);
			else
				sprintf(name, "%s.png", filename);

			cmap = gdk_window_get_colormap(
					GDK_DRAWABLE(gtk_widget_get_window(capture_graph)));
			gdk_drawable_get_size(GDK_DRAWABLE(gtk_widget_get_window(capture_graph)),
					&width, &height);
			pixbuf = gdk_pixbuf_get_from_drawable(NULL,
					GDK_DRAWABLE(gtk_widget_get_window(capture_graph)),
					cmap, 0, 0, 0, 0, width, height);

			if (pixbuf)
				ret = gdk_pixbuf_save(pixbuf, name, "png", &err, NULL);
			if (!pixbuf || !ret)
				printf("error creating %s\n", name);
			break;
		default:
			printf("ret : %i\n", ret);
	}
	free(name);
}
Пример #13
0
SetIconText(GtkStatusIcon *tray_icon, const char *text, const char *color) {

  // build background from image
  GdkPixbuf* special_icon = gdk_pixbuf_new_from_file("message-mail-new.png", NULL); // GError **error);
  GdkPixbuf *dest = gdk_pixbuf_copy(special_icon);
  int w=gdk_pixbuf_get_width(special_icon);
  int h=gdk_pixbuf_get_height(special_icon);

  // prepare colors/alpha
  GdkColormap* cmap=gdk_screen_get_system_colormap(gdk_screen_get_default());
  int screen_depth=24;
  GdkVisual* visual = gdk_colormap_get_visual(cmap);
  screen_depth = visual->depth;
  GdkColor fore = { 0, 0, 0, 0 };
  GdkColor alpha  = { 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF};
  gdk_color_parse(color, &fore);
  if(fore.red==alpha.red && fore.green==alpha.green && fore.blue==alpha.blue) {
    alpha.red=0; // make sure alpha is different from fore
  }
  gdk_colormap_alloc_color (cmap, &fore, TRUE, TRUE);
  gdk_colormap_alloc_color (cmap, &alpha, TRUE, TRUE);

  // build pixmap with rectangle
  GdkPixmap *pm = gdk_pixmap_new (NULL, w, h, screen_depth);
  cairo_t *cr = gdk_cairo_create(pm);
  gdk_cairo_set_source_color(cr, &alpha);
/* void                gdk_cairo_set_source_color          (cairo_t *cr, */
/*                                                          const GdkColor *color); */
  cairo_rectangle(cr, 0, 0, w, h);
  /* void                cairo_rectangle                     (cairo_t *cr, */
  /*                                                          double x, */
  /*                                                          double y, */
  /*                                                          double width, */
  /*                                                          double height); */
  cairo_set_source_rgb(cr, 1, 1, 1);
  cairo_fill(cr);

  // build text
  GtkWidget *scratch = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  PangoLayout *layout = gtk_widget_create_pango_layout(scratch, NULL);
  gtk_widget_destroy(scratch);
  PangoFontDescription *fnt = pango_font_description_from_string("Sans 18");
  pango_font_description_set_weight (fnt,PANGO_WEIGHT_SEMIBOLD);
  pango_layout_set_spacing            (layout,0);
  pango_layout_set_font_description   (layout, fnt);
  pango_layout_set_text (layout, (gchar *)text,-1);
  int tw=0;
  int th=0;
  int sz;
  int border=4;
  pango_layout_get_pixel_size(layout, &tw, &th);
  while( (tw>w - border || th > h - border)) //fit text to the icon by decreasing font size
  {
    sz=pango_font_description_get_size (fnt);
    if(sz<MIN_FONT_SIZE) {
      sz=MIN_FONT_SIZE;
      break;
    }
    sz-=PANGO_SCALE;
    pango_font_description_set_size (fnt,sz);
    pango_layout_set_font_description   (layout, fnt);
    pango_layout_get_pixel_size(layout, &tw, &th);
  }
  pango_font_description_free (fnt);
  // center text
  int px, py;
  px=(w-tw)/2;
  py=(h-th)/2;

  // draw text on pixmap
  gdk_cairo_set_source_color(cr, &fore);
  cairo_move_to (cr, px, py);
  pango_cairo_show_layout (cr, layout);
  cairo_destroy(cr);
  g_object_unref (layout);

  GdkPixbuf *buf = gdk_pixbuf_get_from_drawable (NULL, pm, NULL, 0, 0, 0, 0, w, h);
  g_object_unref (pm);
  GdkPixbuf *alpha_buf = gdk_pixbuf_add_alpha(buf, TRUE, (guchar)alpha.red, (guchar)alpha.green, (guchar)alpha.blue);
  g_object_unref (buf);

  //merge the rendered text on top
  gdk_pixbuf_composite(alpha_buf,dest,0,0,w,h,0,0,1,1,GDK_INTERP_NEAREST,255);
  g_object_unref(alpha_buf);
  /* gdk_pixbuf_composite(buf,dest,0,0,w,h,0,0,1,1,GDK_INTERP_NEAREST,255); */
  /* g_object_unref(buf); */

  gtk_status_icon_set_from_pixbuf(GTK_STATUS_ICON(tray_icon), GDK_PIXBUF(dest));
}
Пример #14
0
XfsmFadeout*
xfsm_fadeout_new (GdkDisplay *display)
{
  GdkWindowAttr  attr;
  XfsmFadeout   *fadeout;
  GdkWindow     *root;
  GdkCursor     *cursor;
  FoScreen      *screen;
  cairo_t       *cr;
  GList         *lp;
  gint           width;
  gint           height;
  gint           n;

  fadeout = g_new0 (XfsmFadeout, 1);
  gdk_color_parse (COLOR, &fadeout->color);

  cursor = gdk_cursor_new (GDK_WATCH);

  attr.x = 0;
  attr.y = 0;
  attr.event_mask = 0;
  attr.wclass = GDK_INPUT_OUTPUT;
  attr.window_type = GDK_WINDOW_TEMP;
  attr.cursor = cursor;
  attr.override_redirect = TRUE;

  for (n = 0; n < gdk_display_get_n_screens (display); ++n)
    {
      GdkPixbuf *root_pixbuf;

      screen = g_new (FoScreen, 1);

      root = gdk_screen_get_root_window (gdk_display_get_screen (display, n));
      gdk_drawable_get_size (GDK_DRAWABLE (root), &width, &height);

      screen->backbuf = gdk_pixmap_new (GDK_DRAWABLE (root), width, height, -1);

      /* Copy the root window */
      root_pixbuf = gdk_pixbuf_get_from_drawable (NULL, GDK_DRAWABLE (root), NULL,
                                                  0, 0, 0, 0, width, height);
      cr = gdk_cairo_create (GDK_DRAWABLE (screen->backbuf));
      gdk_cairo_set_source_pixbuf (cr, root_pixbuf, 0, 0);
      cairo_paint (cr);
      gdk_cairo_set_source_color (cr, &fadeout->color);
      cairo_paint_with_alpha (cr, 0.5);

      attr.width = width;
      attr.height = height;

      screen->window = gdk_window_new (root, &attr, GDK_WA_X | GDK_WA_Y
                                       | GDK_WA_NOREDIR | GDK_WA_CURSOR);
      gdk_window_set_back_pixmap (screen->window, screen->backbuf, FALSE);

      g_object_unref (root_pixbuf);
      cairo_destroy (cr);

      fadeout->screens = g_list_append (fadeout->screens, screen);
    }

  for (lp = fadeout->screens; lp != NULL; lp = lp->next)
    gdk_window_show (((FoScreen *) lp->data)->window);

  gdk_cursor_unref (cursor);

  return fadeout;
}
Пример #15
0
int main(int argc, char** argv)
{
  gdk_init(&argc, &argv);

#if defined(HAVE_LIBXSS) && defined(MOZ_WIDGET_GTK)
  int event_base, error_base;
  Bool have_xscreensaver =
    XScreenSaverQueryExtension(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
                               &event_base, &error_base);

  if (!have_xscreensaver) {
    fprintf(stderr, "No XScreenSaver extension on display\n");
  } else {
    XScreenSaverInfo* info = XScreenSaverAllocInfo();
    if (!info) {
      fprintf(stderr, "%s: Out of memory\n", argv[0]);
      return 1;
    }
    XScreenSaverQueryInfo(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
                          GDK_ROOT_WINDOW(), info);

    const char* state;
    const char* til_or_since = nullptr;
    switch (info->state) {
    case ScreenSaverOff:
      state = "Off";
      til_or_since = "XScreenSaver will activate after another %lu seconds idle time\n";
      break;
    case ScreenSaverOn:
      state = "On";
      if (info->til_or_since) {
        til_or_since = "XScreenSaver idle timer activated %lu seconds ago\n";
      } else {
        til_or_since = "XScreenSaver idle activation is disabled\n";
      }
      break;
    case ScreenSaverDisabled:
      state = "Disabled";
      break;
    default:
      state = "unknown";
    }

    const char* kind;
    switch (info->kind) {
    case ScreenSaverBlanked:
      kind = "Blanked";
      break;
    case ScreenSaverInternal:
      state = "Internal";
      break;
    case ScreenSaverExternal:
      state = "External";
      break;
    default:
      state = "unknown";
    }

    fprintf(stderr, "XScreenSaver state: %s\n", state);

    if (til_or_since) {
      fprintf(stderr, "XScreenSaver kind: %s\n", kind);
      fprintf(stderr, til_or_since, info->til_or_since / 1000);
    }

    fprintf(stderr, "User input has been idle for %lu seconds\n", info->idle / 1000);

    XFree(info);
  }
#endif

  GdkPixbuf* screenshot = nullptr;
  GdkWindow* window = gdk_get_default_root_window();
#if (MOZ_WIDGET_GTK == 2)
  screenshot = gdk_pixbuf_get_from_drawable(nullptr, window, nullptr,
                                            0, 0, 0, 0,
                                            gdk_screen_width(),
                                            gdk_screen_height());
#else
  screenshot = gdk_pixbuf_get_from_window(window, 0, 0,
                                          gdk_window_get_width(window),
                                          gdk_window_get_height(window));
#endif
  if (!screenshot) {
    fprintf(stderr, "%s: failed to create screenshot GdkPixbuf\n", argv[0]);
    return 1;
  }

  GError* error = nullptr;
  if (argc > 1) {
    gdk_pixbuf_save(screenshot, argv[1], "png", &error, nullptr);
  } else {
    gdk_pixbuf_save_to_callback(screenshot, save_to_stdout, nullptr,
                                "png", &error, nullptr);
  }
  if (error) {
    fprintf(stderr, "%s: failed to write screenshot as png: %s\n",
            argv[0], error->message);
    return error->code;
  }

  return 0;
}
Пример #16
0
//! Draws the square (x, y). On the board it is shown at (real_x, real_y)
void board_refresh_cell_real (int x, int y, int real_x, int real_y)
{
	GdkGC *gc;
	int parity = (board_wid * board_heit + x + y + 1) % 2;
	int thepiece;
	if (opt_quiet) return;
	if (!cur_pos.board) return;
	gc = board_area->style->bg_gc[GTK_STATE_NORMAL];
	gdk_gc_set_clip_mask (gc, NULL);
	gdk_gc_set_clip_origin (gc, real_x * cell_size, real_y * cell_size);
	thepiece = cur_pos.board[y * board_wid + x] -1 + num_pieces * parity;
	if ((cur_pos.render[y * board_wid + x] & 0xFF) == RENDER_REPLACE)
		thepiece = (cur_pos.render[y * board_wid + x] >> 8) -1 + num_pieces * parity;
	if ((cur_pos.board[y * board_wid + x] != 0
			|| (cur_pos.render[y * board_wid + x] & 0xFF) == RENDER_REPLACE)
			&& !board_suspended)
	{
		/* FIXME: current impl is that if bgimage is set then bgcolor is irrelevant. Maybe we should change it so that bgimage is layered on top of bgcolor */
		if (board_bgimage)
		{
			gdk_draw_pixmap (board_area->window,
					gc, (GdkDrawable *) board_bgimage,
					real_x * cell_size, real_y * cell_size,
					real_x * cell_size, real_y * cell_size,
					cell_size, cell_size
					);
			gdk_gc_set_clip_mask (gc, piece_masks [thepiece]);
			gdk_gc_set_clip_origin (gc, real_x * cell_size, real_y * cell_size);
		}
		gdk_draw_pixmap (board_area->window, 
				gc, (GdkDrawable *) pieces [thepiece],
				0, 0, real_x * cell_size, real_y * cell_size, 
				-1, -1);
	}
	else
	{
		if (board_bgimage)
		{
			gdk_draw_pixmap (board_area->window,
					gc, (GdkDrawable *) board_bgimage,
					real_x * cell_size, real_y * cell_size,
					real_x * cell_size, real_y * cell_size,
					cell_size, cell_size
					);
		}
		else
			gdk_draw_rectangle (board_area->window, board_gcs[parity], 1, 
					real_x * cell_size, real_y * cell_size,
					cell_size, cell_size);
	}

	if (cur_pos.render[y * board_wid + x] == RENDER_SHADE1			
			&& cur_pos.board[y * board_wid + x] != 0
		   	&& !board_suspended)
	{
#if GTK_MAJOR_VERSION > 1
		GdkPixbuf *pixbuf;
		int i;
		guchar *pixels;
		pixbuf = gdk_pixbuf_get_from_drawable (NULL, pieces[thepiece], NULL,
				0, 0, 0, 0, cell_size, cell_size);
		pixels = gdk_pixbuf_get_pixels (pixbuf);
		for (i=0; i<3*cell_size*cell_size; i++)
			pixels[i] = (pixels[i] + 127)/2;
		gdk_pixbuf_render_to_drawable (pixbuf, board_area->window, gc, 0, 0,
				real_x * cell_size, real_y * cell_size, cell_size, cell_size,
				GDK_RGB_DITHER_NONE, 0, 0);
		// FIXME: find out the  correct way to free it
		g_free (pixels);
		g_free (pixbuf);
#else
		fprintf (stderr, "Warning: RENDER_SHADE currently unimplemented in gtk1 version\n");
#endif
	}

	
	if (game_draw_cell_boundaries)
	{
		if (real_x > 0)
			gdk_draw_line (board_area->window, board_gcs[2],
				real_x * cell_size, real_y * cell_size,
				real_x * cell_size, (real_y + 1) * cell_size);
		if (real_y > 0)
			gdk_draw_line (board_area->window, board_gcs[2],
				real_x * cell_size, real_y * cell_size,
				(real_x + 1) * cell_size, real_y * cell_size);
	}
	
	// TODO: do HIGHLIGHT2 and 3 also
	if (cur_pos.render[y * board_wid + x] == RENDER_HIGHLIGHT1 && !board_suspended)
	{
		int incr = game_draw_cell_boundaries ? 1 : 0;
		gdk_draw_line (board_area->window, board_highlight_gcs[0],
			real_x * cell_size + incr, real_y * cell_size + incr,
			real_x * cell_size + incr, (real_y + 1) * cell_size - 1);
		gdk_draw_line (board_area->window, board_highlight_gcs[0],
			real_x * cell_size + incr, real_y * cell_size + incr,
			(real_x + 1) * cell_size - 1, real_y * cell_size + incr);
		gdk_draw_line (board_area->window, board_highlight_gcs[0],
			(real_x + 1) * cell_size - 1, real_y * cell_size + incr,
			(real_x + 1) * cell_size - 1, (real_y + 1) * cell_size - 1);
		gdk_draw_line (board_area->window, board_highlight_gcs[0],
			real_x * cell_size + incr, (real_y + 1) * cell_size - 1,
			(real_x + 1) * cell_size - 1, (real_y + 1) * cell_size - 1);
	}
	
	if (cur_pos.render[y * board_wid + x] == RENDER_BUTTONIZE && !board_suspended)
	{
		int incr = game_draw_cell_boundaries ? 1 : 0;
		gdk_draw_line (board_area->window, board_buttonize_gcs[0],
			real_x * cell_size + incr, real_y * cell_size + incr,
			real_x * cell_size + incr, (real_y + 1) * cell_size - 1);
		gdk_draw_line (board_area->window, board_buttonize_gcs[0],
			real_x * cell_size + incr, real_y * cell_size + incr,
			(real_x + 1) * cell_size - 1, real_y * cell_size + incr);
		gdk_draw_line (board_area->window, board_buttonize_gcs[1],
			(real_x + 1) * cell_size - 1, real_y * cell_size + incr,
			(real_x + 1) * cell_size - 1, (real_y + 1) * cell_size - 1);
		gdk_draw_line (board_area->window, board_buttonize_gcs[1],
			real_x * cell_size + incr, (real_y + 1) * cell_size - 1,
			(real_x + 1) * cell_size - 1, (real_y + 1) * cell_size - 1);
	}
	
}
Пример #17
0
void
pixmap_save_cb(GtkWidget *w, gpointer pixmap_ptr _U_)
{
	GtkWidget *save_as_w;
#if GTK_CHECK_VERSION(2,22,0)
	surface_info_t *surface_info = g_object_get_data(G_OBJECT(w), "surface-info");
#else
	GdkPixmap *pixmap = g_object_get_data(G_OBJECT(w), "pixmap");
#endif
	GdkPixbuf *pixbuf;
	GdkPixbufFormat *pixbuf_format;
	GtkWidget *main_vb, *save_as_type_hb, *type_lb, *type_cm;
	GSList *file_formats,*ffp;
	GdkWindow *parent;

	gchar *format_name;
	guint format_index = 0;
	guint default_index = 0;

	gchar *filename, *file_type;
	GError *error = NULL;
	gboolean ret;
	GtkWidget *msg_dialog;

#if GTK_CHECK_VERSION(2,22,0)
	pixbuf = gdk_pixbuf_get_from_surface (surface_info->surface,
		0, 0, surface_info->width, surface_info->height);
#else
	pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, NULL,
					      0, 0, 0, 0, -1, -1);
#endif
	if(!pixbuf) {
		simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
			      "%sCould not get image from graph%s",
			      simple_dialog_primary_start(),
			      simple_dialog_primary_end());
		return;
	}

	save_as_w = file_selection_new("Wireshark: Save Graph As ...",
				       FILE_SELECTION_SAVE);
	gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(save_as_w), TRUE);

	/* Container for each row of widgets */
	main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
	file_selection_set_extra_widget(save_as_w, main_vb);
	gtk_widget_show(main_vb);

	save_as_type_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0, FALSE);
	gtk_box_pack_start(GTK_BOX(main_vb), save_as_type_hb, FALSE, FALSE, 0);
	gtk_widget_show(save_as_type_hb);

	type_lb = gtk_label_new("File type: ");
	gtk_box_pack_start(GTK_BOX(save_as_type_hb), type_lb, FALSE, FALSE, 0);
	gtk_widget_show(type_lb);

	type_cm = gtk_combo_box_text_new();
	gtk_box_pack_start(GTK_BOX(save_as_type_hb), type_cm, FALSE, FALSE, 0);

	/* List all of the file formats the gdk-pixbuf library supports */
	file_formats = gdk_pixbuf_get_formats();
	ffp = file_formats;
	while(ffp) {
		pixbuf_format = ffp->data;
		if (gdk_pixbuf_format_is_writable(pixbuf_format)) {
			format_name = gdk_pixbuf_format_get_name(pixbuf_format);
			 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(type_cm),
						  format_name);
			if (!(g_ascii_strcasecmp(format_name, "png")))
				default_index = format_index;
			format_index++;
		}
		ffp = g_slist_next(ffp);
	}
	g_slist_free(file_formats);

	gtk_combo_box_set_active(GTK_COMBO_BOX(type_cm), default_index);
	gtk_widget_show(type_cm);

	gtk_widget_show(save_as_w);
	window_present(save_as_w);
	parent = gtk_widget_get_parent_window(w);
	gdk_window_set_transient_for(gtk_widget_get_window(save_as_w), parent);

	/*
	 * Loop until the user either selects a file or gives up.
	 */
	for (;;) {
		if (gtk_dialog_run(GTK_DIALOG(save_as_w)) != GTK_RESPONSE_ACCEPT) {
			/* They clicked "Cancel" or closed the dialog or.... */
			window_destroy(save_as_w);
			return;
		}

		filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(save_as_w));

		/* Perhaps the user specified a directory instead of a file.
		   Check whether they did. */
		if (test_for_directory(filename) == EISDIR) {
			/* It's a directory - set the file selection box to display that
			   directory, and leave the selection box displayed. */
			set_last_open_dir(filename);
			g_free(filename);
			file_selection_set_current_folder(save_as_w,
							  get_last_open_dir());
			gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(save_as_w), "");
			continue;
		}

		file_type = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(type_cm));
		ret = gdk_pixbuf_save(pixbuf, filename, file_type, &error, NULL);
		g_free(filename);
		g_free(file_type);

		if (!ret) {
			msg_dialog = gtk_message_dialog_new(GTK_WINDOW(save_as_w),
                                          GTK_DIALOG_DESTROY_WITH_PARENT,
                                          GTK_MESSAGE_ERROR,
                                          GTK_BUTTONS_OK,
                                          "%s", error->message);
			gtk_dialog_run(GTK_DIALOG(msg_dialog));
			gtk_widget_destroy(msg_dialog);
			continue;
		}

		window_destroy(save_as_w);
		return;
	}
}
Пример #18
0
void 
gp_image_set_diff_pixmap ( GpImage *image, GdkPixmap* pixmap, guint x_offset, guint y_offset )
{
	GdkPixbuf *pixbuf;
	GdkPixbuf *m_pixbuf;
	guchar *pixels, *m_pixels;
	guchar *p, *m_p;
	gint w, h;
	gint n_channels, rowstride;

	g_return_if_fail ( GP_IS_IMAGE (image) );
	

	pixbuf		=   image->priv->pixbuf;
	if(!gdk_pixbuf_get_has_alpha ( pixbuf ) )
	{  /*add alpha*/
		GdkPixbuf *tmp ;
		tmp = gdk_pixbuf_add_alpha(pixbuf, FALSE, 0, 0, 0);
		g_object_unref(pixbuf);
		pixbuf = tmp;
	}
	m_pixbuf	=   gdk_pixbuf_copy ( pixbuf );
	
	w			=   gdk_pixbuf_get_width		( pixbuf );
	h			=   gdk_pixbuf_get_height		( pixbuf );

	gdk_pixbuf_get_from_drawable (  m_pixbuf, 
               						pixmap,
               						gdk_drawable_get_colormap (pixmap),
               						x_offset,y_offset,
               						0,0,
              						w,h);
	
	n_channels  =   gdk_pixbuf_get_n_channels   ( pixbuf );
	rowstride   =   gdk_pixbuf_get_rowstride	( pixbuf );
	pixels		=   gdk_pixbuf_get_pixels		( pixbuf );
	m_pixels	=   gdk_pixbuf_get_pixels		( m_pixbuf );
	while (h--) 
	{
		guint   i = w;
		p   = pixels;
		m_p = m_pixels;
		while (i--) 
		{
			pixel_union *pu, *m_pu;

			pu = (pixel_union *)p;
			m_pu = (pixel_union *)m_p;
				
			if(pu->ui32 == m_pu->ui32)
			{
				p[0] = 0; 
				p[1] = 0; 
				p[2] = 0; 
				p[3] = 0; 
			}
			p   += n_channels;
			m_p += n_channels;
		}
		pixels		+= rowstride;
		m_pixels	+= rowstride;
	}
	g_object_unref (m_pixbuf);

	
}
Пример #19
0
GdkPixbuf*
gwy_graph_export_pixmap(GwyGraph *graph,
                        G_GNUC_UNUSED gboolean export_title,
                        G_GNUC_UNUSED gboolean export_axis,
                        G_GNUC_UNUSED gboolean export_labels)
{
    GdkColor color = { 0, 65535, 65535, 65535 };
    GdkPixbuf *pixbuf;
    GdkColormap *cmap;
    GdkGC *gc;
    GdkVisual *visual;
    GdkPixmap *pixmap;
    PangoLayout *layout;
    PangoContext *context;
    gint width, height, topheight, bottomheight, rightwidth, leftwidth;
    gint labelx, labely, labelw, labelh;

    width = (GTK_WIDGET(graph))->allocation.width;
    height = (GTK_WIDGET(graph))->allocation.height;

    topheight = (GTK_WIDGET(graph->axis[GTK_POS_TOP]))->allocation.height;
    bottomheight = (GTK_WIDGET(graph->axis[GTK_POS_BOTTOM]))->allocation.height;
    leftwidth = (GTK_WIDGET(graph->axis[GTK_POS_LEFT]))->allocation.width;
    rightwidth = (GTK_WIDGET(graph->axis[GTK_POS_RIGHT]))->allocation.width;

    labelx = (GTK_WIDGET(graph->area->lab))->allocation.x + leftwidth;
    labely = (GTK_WIDGET(graph->area->lab))->allocation.y + topheight;
    labelw = (GWY_GRAPH_LABEL(graph->area->lab))->reqwidth;
    labelh = (GWY_GRAPH_LABEL(graph->area->lab))->reqheight;

    visual = gdk_visual_get_best();
    cmap = gdk_colormap_new(visual, FALSE);

    pixmap = gdk_pixmap_new(NULL, width, height, visual->depth);
    gdk_drawable_set_colormap(pixmap, cmap);

    gc = gdk_gc_new(pixmap);
    gdk_gc_set_colormap(gc, cmap);

    gdk_gc_set_rgb_fg_color(gc, &color);
    gdk_draw_rectangle(pixmap, gc, TRUE, 0, 0, width, height);

    gwy_graph_area_draw_on_drawable(graph->area, pixmap, gc,
                                    leftwidth, topheight,
                                    width - leftwidth - rightwidth,
                                    height - topheight - bottomheight);

    /* Draw axes */
    gwy_axis_draw_on_drawable(graph->axis[GTK_POS_TOP], pixmap, gc,
                              leftwidth, 0,
                              width - leftwidth - rightwidth, topheight);
    gwy_axis_draw_on_drawable(graph->axis[GTK_POS_BOTTOM], pixmap, gc,
                              leftwidth, height - bottomheight,
                              width - leftwidth - rightwidth, bottomheight);
    gwy_axis_draw_on_drawable(graph->axis[GTK_POS_LEFT], pixmap, gc,
                              0, topheight,
                              leftwidth, height - topheight - bottomheight);
    gwy_axis_draw_on_drawable(graph->axis[GTK_POS_RIGHT], pixmap, gc,
                              width - rightwidth, topheight,
                              rightwidth, height - topheight - bottomheight);

    context = gdk_pango_context_get_for_screen(gdk_screen_get_default());
    pango_context_set_font_description(context, graph->area->lab->font_desc);
    layout = pango_layout_new(context);
    gwy_graph_label_draw_on_drawable(graph->area->lab, pixmap, gc, layout,
                                     labelx, labely, labelw, labelh);

    pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, cmap,
                                          0, 0, 0, 0,
                                          -1, -1);

    g_object_unref(pixmap);
    g_object_unref(layout);
    g_object_unref(context);
    g_object_unref(gc);
    g_object_unref(cmap);

    return pixbuf;
}
Пример #20
0
void DrawPrint( GnomePrintContext *gpc )
{
	int bl_width = 32;
	int bl_height = 32;
	int seq_size = 32;
	int the_width = RUNG_WIDTH*bl_width;
	int the_height = RUNG_HEIGHT*bl_height;
	int iCurrentLanguage = SectionArray[ InfosGene->CurrentSection ].Language;
	GdkPixmap *pixmap_for_print;
#ifdef SEQUENTIAL_SUPPORT
	if ( iCurrentLanguage==SECTION_IN_SEQUENTIAL )
	{
		the_width = SEQ_PAGE_WIDTH*seq_size;
		the_height = SEQ_PAGE_HEIGHT*seq_size;
	}
#endif

	pixmap_for_print = gdk_pixmap_new( drawing_area->window/*drawable*/,                                          the_width, the_height, -1/*depth*/ );
	if ( pixmap_for_print )
	{

		char TheEnd = FALSE;
		char NewPage = TRUE;
		int SizePageOffset = 800;
		int ScanRung = InfosGene->FirstRung;
		int PageNumber = 1;

		do
		{
			char Buffer[ LGT_LABEL+LGT_COMMENT+20 ];
			GdkPixbuf *pixbuf_for_print;

			if ( NewPage==TRUE )
			{
				gnome_print_beginpage( gpc, (guchar *)"1" );
				NewPage = FALSE;
				SizePageOffset = 800;

				sprintf(Buffer, "ClassicLadder" RELEASE_VER_STRING ".  Section:%s  -  Page:%d", SectionArray[ InfosGene->CurrentSection ].Name, PageNumber );
				gnome_print_moveto( gpc, 50, 20 );
				gnome_print_show( gpc, (guchar *)Buffer );

			}

			gdk_draw_rectangle (pixmap_for_print, drawing_area->style->white_gc, TRUE, 0, 0, the_width, the_height);

			if ( iCurrentLanguage==SECTION_IN_LADDER )
				DrawRung( pixmap_for_print, &RungArray[ ScanRung ], 0/*PosiY*/, bl_width, bl_height, DRAW_FOR_PRINT );
#ifdef SEQUENTIAL_SUPPORT
			if ( iCurrentLanguage==SECTION_IN_SEQUENTIAL )
			{
				DrawSequentialPage( pixmap_for_print, SectionArray[ InfosGene->CurrentSection ].SequentialPage, DRAW_FOR_PRINT );
				TheEnd = TRUE;
			}
#endif

			pixbuf_for_print = gdk_pixbuf_get_from_drawable( NULL /*GdkPixbuf *dest*/,
                                             pixmap_for_print,
                                             NULL /*cmap*/,
                                             0 /*src_x*/,
                                             0 /*src_y*/,
                                             0 /*dest_x*/,
                                             0 /*dest_y*/,
                                             the_width,
                                             the_height);
			if ( pixbuf_for_print )
			{
				guchar *raw_image;
				gint rowstride;

				if ( iCurrentLanguage==SECTION_IN_LADDER )
				{
					char BuffFormat[10] = "%s (%s)";
					if ( RungArray[ ScanRung ].Comment[0]=='\0' )
						strcpy( BuffFormat, "%s %s" );
					sprintf( Buffer, BuffFormat, RungArray[ ScanRung ].Label, RungArray[ ScanRung ].Comment );
					gnome_print_moveto( gpc, 50, SizePageOffset );
					SizePageOffset = SizePageOffset-20;
					gnome_print_show( gpc, (guchar *)Buffer );
				}

				raw_image = gdk_pixbuf_get_pixels( pixbuf_for_print );
				rowstride = gdk_pixbuf_get_rowstride( pixbuf_for_print );

				gnome_print_gsave( gpc );
				gnome_print_translate( gpc, 20, SizePageOffset-the_height+15 );
				gnome_print_scale( gpc, the_width, the_height );
				gnome_print_rgbimage( gpc, raw_image, the_width, the_height, rowstride);
				gnome_print_grestore( gpc );
				SizePageOffset = SizePageOffset-the_height-20;
				gdk_pixbuf_unref( pixbuf_for_print );

				if ( iCurrentLanguage==SECTION_IN_LADDER )
				{
					if ( ScanRung!=InfosGene->LastRung )
						ScanRung = RungArray[ ScanRung ].NextRung;
					else
						TheEnd = TRUE;
				}

				if ( SizePageOffset<200 || TheEnd )
				{
					NewPage = TRUE;
					PageNumber++;
					gnome_print_showpage ( gpc );
				}
			}
			else
			{
				printf( "Failed to create pixbuf_for_print\n" );
			}
		}
		while( !TheEnd );

		gdk_pixmap_unref( pixmap_for_print );

	}
	else
	{
		printf( "Failed to create pixmap_for_print\n" );
	}
}