Exemplo n.º 1
0
static GdkPixbuf *
ev_document_misc_render_thumbnail_frame (GtkWidget *widget,
                                         int        width,
                                         int        height,
                                         gboolean   inverted_colors,
                                         GdkPixbuf *source_pixbuf)
{
        GtkStyleContext *context = gtk_widget_get_style_context (widget);
        GtkStateFlags    state = gtk_widget_get_state_flags (widget);
        int              width_r, height_r;
        int              width_f, height_f;
        cairo_surface_t *surface;
        cairo_t         *cr;
        GtkBorder        border = {0, };
        GdkPixbuf       *retval;

        if (source_pixbuf) {
                g_return_val_if_fail (GDK_IS_PIXBUF (source_pixbuf), NULL);

                width_r = gdk_pixbuf_get_width (source_pixbuf);
                height_r = gdk_pixbuf_get_height (source_pixbuf);
        } else {
                width_r = width;
                height_r = height;
        }

        gtk_style_context_save (context);

        gtk_style_context_add_class (context, "page-thumbnail");
        if (inverted_colors)
                gtk_style_context_add_class (context, "inverted");

        gtk_style_context_get_border (context, state, &border);
        width_f = width_r + border.left + border.right;
        height_f = height_r + border.top + border.bottom;

        surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
                                              width_f, height_f);
        cr = cairo_create (surface);
        if (source_pixbuf) {
                gdk_cairo_set_source_pixbuf (cr, source_pixbuf, border.left, border.top);
                cairo_paint (cr);
        } else {
                gtk_render_background (context, cr, 0, 0, width_f, height_f);
        }
        gtk_render_frame (context, cr, 0, 0, width_f, height_f);
        cairo_destroy (cr);

        gtk_style_context_restore (context);

        retval = gdk_pixbuf_get_from_surface (surface, 0, 0, width_f, height_f);
        cairo_surface_destroy (surface);

        return retval;
}
Exemplo n.º 2
0
/**
 * gimp_thumbnail_save_thumb_local:
 * @thumbnail: a #GimpThumbnail object
 * @pixbuf: a #GdkPixbuf representing the preview thumbnail
 * @software: a string describing the software saving the thumbnail
 * @error: return location for possible errors
 *
 * Saves a preview thumbnail for the image associated with @thumbnail
 * to the local thumbnail repository. Local thumbnails have been added
 * with version 0.7 of the spec.
 *
 * Please see also gimp_thumbnail_save_thumb(). The notes made there
 * apply here as well.
 *
 * Return value: %TRUE if a thumbnail was successfully written,
 *               %FALSE otherwise
 *
 * Since: 2.2
 **/
gboolean
gimp_thumbnail_save_thumb_local (GimpThumbnail  *thumbnail,
                                 GdkPixbuf      *pixbuf,
                                 const gchar    *software,
                                 GError        **error)
{
  GimpThumbSize  size;
  gchar         *name;
  gchar         *filename;
  gchar         *dirname;
  gboolean       success;

  g_return_val_if_fail (GIMP_IS_THUMBNAIL (thumbnail), FALSE);
  g_return_val_if_fail (thumbnail->image_uri != NULL, FALSE);
  g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), FALSE);
  g_return_val_if_fail (software != NULL, FALSE);
  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

  GIMP_THUMB_DEBUG_CALL (thumbnail);

  size = MAX (gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf));
  if (size < 1)
    return TRUE;

  filename = _gimp_thumb_filename_from_uri (thumbnail->image_uri);
  if (! filename)
    return TRUE;

  dirname = g_path_get_dirname (filename);
  g_free (filename);

  name = gimp_thumb_name_from_uri_local (thumbnail->image_uri, size);
  if (! name)
    {
      g_free (dirname);
      return TRUE;
    }

  if (! gimp_thumb_ensure_thumb_dir_local (dirname, size, error))
    {
      g_free (name);
      g_free (dirname);
      return FALSE;
    }

  g_free (dirname);

  success = gimp_thumbnail_save (thumbnail,
                                 size, name, pixbuf, software,
                                 error);
  g_free (name);

  return success;
}
Exemplo n.º 3
0
/**
 * gdl_dock_object_set_pixbuf:
 * @object: a #GdlDockObject
 * @icon: (allow-none): a icon or %NULL
 *
 * Set a icon for a dock object using a #GdkPixbuf.
 *
 * Since: 3.6
 */
void
gdl_dock_object_set_pixbuf (GdlDockObject *object,
                            GdkPixbuf *icon)
{
    g_return_if_fail (GDL_IS_DOCK_OBJECT (object));
    g_return_if_fail (icon == NULL || GDK_IS_PIXBUF (icon));

    object->priv->pixbuf_icon =icon;

    g_object_notify_by_pspec (G_OBJECT (object), properties[PROP_PIXBUF_ICON]);
}
Exemplo n.º 4
0
void zbar_gtk_release_pixbuf (zbar_image_t *img)
{
    GdkPixbuf *pixbuf = zbar_image_get_userdata(img);
    g_assert(GDK_IS_PIXBUF(pixbuf));

    /* remove reference */
    zbar_image_set_userdata(img, NULL);

    /* release reference to associated pixbuf and it's data */
    g_object_unref(pixbuf);
}
Exemplo n.º 5
0
/**
 * gwy_gl_material_sample_to_pixbuf:
 * @gl_material: A GL material to sample.
 * @pixbuf: A pixbuf to sample gl_material to (in horizontal direction).
 *
 * Samples GL material to a provided pixbuf.
 **/
void
gwy_gl_material_sample_to_pixbuf(GwyGLMaterial *gl_material,
                                 GdkPixbuf *pixbuf)
{
    GwyGLMaterial *glm = gl_material;
    gint width, height, rowstride, i, j, bpp;
    gboolean has_alpha;
    guchar *row, *pdata;
    guchar alpha;
    gdouble p, q;

    g_return_if_fail(GWY_IS_GL_MATERIAL(gl_material));
    g_return_if_fail(GDK_IS_PIXBUF(pixbuf));

    width = gdk_pixbuf_get_width(pixbuf);
    height = gdk_pixbuf_get_height(pixbuf);
    rowstride = gdk_pixbuf_get_rowstride(pixbuf);
    has_alpha = gdk_pixbuf_get_has_alpha(pixbuf);
    pdata = gdk_pixbuf_get_pixels(pixbuf);
    bpp = 3 + (has_alpha ? 1 : 0);

    q = (width == 1) ? 0.0 : 1.0/(width - 1.0);
    p = (height == 1) ? 0.0 : 1.0/(height - 1.0);
    alpha = (guchar)CLAMP(MAX_CVAL*glm->ambient.a, 0.0, 255.0);

    for (j = 0; j < width; j++) {
        gdouble VRp = j*q*(2.0 - j*q);
        gdouble s = pow(VRp, 128.0*glm->shininess);
        GwyRGBA s0;

        s0.r = glm->emission.r + 0.3*glm->ambient.r + glm->specular.r*s;
        s0.g = glm->emission.g + 0.3*glm->ambient.g + glm->specular.g*s;
        s0.b = glm->emission.b + 0.3*glm->ambient.b + glm->specular.b*s;

        for (i = 0; i < height; i++) {
            gdouble LNp = 1.0 - i*p;
            gdouble v;

            row = pdata + i*rowstride + j*bpp;

            v = s0.r + glm->diffuse.r*LNp;
            *(row++) = (guchar)CLAMP(MAX_CVAL*v, 0.0, 255.0);

            v = s0.g + glm->diffuse.g*LNp;
            *(row++) = (guchar)CLAMP(MAX_CVAL*v, 0.0, 255.0);

            v = s0.b + glm->diffuse.b*LNp;
            *(row++) = (guchar)CLAMP(MAX_CVAL*v, 0.0, 255.0);

            if (has_alpha)
                *(row++) = alpha;
        }
    }
}
Exemplo n.º 6
0
/**
 * gdk_pixbuf_fill:
 * @pixbuf: a #GdkPixbuf
 * @pixel: RGBA pixel to clear to
 *         (0xffffffff is opaque white, 0x00000000 transparent black)
 *
 * Clears a pixbuf to the given RGBA value, converting the RGBA value into
 * the pixbuf's pixel format. The alpha will be ignored if the pixbuf
 * doesn't have an alpha channel.
 * 
 **/
void
gdk_pixbuf_fill (GdkPixbuf *pixbuf,
                 guint32    pixel)
{
        guchar *pixels;
        guint r, g, b, a;
        guchar *p;
        guint w, h;

        g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
        g_return_if_fail (pixbuf->pixels || pixbuf->bytes);

        if (pixbuf->width == 0 || pixbuf->height == 0)
                return;

        /* Force an implicit copy */
        pixels = gdk_pixbuf_get_pixels (pixbuf);

        r = (pixel & 0xff000000) >> 24;
        g = (pixel & 0x00ff0000) >> 16;
        b = (pixel & 0x0000ff00) >> 8;
        a = (pixel & 0x000000ff);

        h = pixbuf->height;
        
        while (h--) {
                w = pixbuf->width;
                p = pixels;

                switch (pixbuf->n_channels) {
                case 3:
                        while (w--) {
                                p[0] = r;
                                p[1] = g;
                                p[2] = b;
                                p += 3;
                        }
                        break;
                case 4:
                        while (w--) {
                                p[0] = r;
                                p[1] = g;
                                p[2] = b;
                                p[3] = a;
                                p += 4;
                        }
                        break;
                default:
                        break;
                }
                
                pixels += pixbuf->rowstride;
        }
}
Exemplo n.º 7
0
/**
 * gdk_pixbuf_remove_option:
 * @pixbuf: a #GdkPixbuf
 * @key: a nul-terminated string representing the key to remove.
 *
 * Remove the key/value pair option attached to a #GdkPixbuf.
 *
 * Return value: %TRUE if an option was removed, %FALSE if not.
 *
 * Since: 2.36
 **/
gboolean
gdk_pixbuf_remove_option (GdkPixbuf   *pixbuf,
                          const gchar *key)
{
        GQuark  quark;
        gchar **options;
        guint n;
        GPtrArray *array;
        gboolean found;

        g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), FALSE);
        g_return_val_if_fail (key != NULL, FALSE);

        quark = g_quark_from_static_string ("gdk_pixbuf_options");

        options = g_object_get_qdata (G_OBJECT (pixbuf), quark);
        if (!options)
                return FALSE;

        g_object_steal_qdata (G_OBJECT (pixbuf), quark);

        /* There's at least a nul-terminator */
        array = g_ptr_array_new_full (1, g_free);

        found = FALSE;
        for (n = 0; options[2*n]; n++) {
                if (strcmp (options[2*n], key) != 0) {
                        g_ptr_array_add (array, g_strdup (options[2*n]));   /* key */
                        g_ptr_array_add (array, g_strdup (options[2*n+1])); /* value */
                } else {
                        found = TRUE;
                }
        }

        if (array->len == 0) {
                g_ptr_array_unref (array);
                g_strfreev (options);
                return found;
        }

        if (!found) {
                g_ptr_array_free (array, TRUE);
                g_object_set_qdata_full (G_OBJECT (pixbuf), quark,
                                         options, (GDestroyNotify) g_strfreev);
                return FALSE;
        }

        g_ptr_array_add (array, NULL);
        g_object_set_qdata_full (G_OBJECT (pixbuf), quark,
                                 g_ptr_array_free (array, FALSE), (GDestroyNotify) g_strfreev);
        g_strfreev (options);

        return TRUE;
}
Exemplo n.º 8
0
/** 
 * Adds an image to the current clip.
 * TODO: should be moved out of here, to application. 
 */
void Pipeline::grab_frame()
{
    GdkPixbuf* pixbuf;
    g_object_get(G_OBJECT(gdkpixbufsink_), "last-pixbuf", &pixbuf, NULL);
    if (! GDK_IS_PIXBUF(pixbuf))
    {
        std::cout << "No picture yet to grab!" << std::endl;
    } else {
        save_image_to_current_clip(pixbuf);
    }
    g_object_unref(pixbuf);
}
Exemplo n.º 9
0
/**
 * gdk_pixbuf_read_pixel_bytes:
 * @pixbuf: A pixbuf
 *
 * Returns: (transfer full): A new reference to a read-only copy of
 * the pixel data.  Note that for mutable pixbufs, this function will
 * incur a one-time copy of the pixel data for conversion into the
 * returned #GBytes.
 *
 * Since: 2.32
 */
GBytes *
gdk_pixbuf_read_pixel_bytes (const GdkPixbuf  *pixbuf)
{
        g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);

        if (pixbuf->bytes) {
                return g_bytes_ref (pixbuf->bytes);
        } else {
                return g_bytes_new (pixbuf->pixels,
                                    gdk_pixbuf_get_byte_length (pixbuf));
        }
}
Exemplo n.º 10
0
void
moko_contacts_get_photo (MokoContacts *contacts, MokoContact *m_contact)
{
  MokoContactsPrivate *priv;
  EContact *e_contact;
  EContactPhoto *photo;
  GError *err = NULL;
  GdkPixbufLoader *loader;
  
  g_return_if_fail (MOKO_IS_CONTACTS (contacts));
  g_return_if_fail (m_contact);
  priv = contacts->priv;
  
  if (!e_book_get_contact (priv->book, m_contact->uid, &e_contact, &err))
  {
    g_warning ("%s\n", err->message);
    m_contact->photo = gdk_pixbuf_new_from_file (PKGDATADIR"/person.png", NULL);
    if (m_contact->photo)
      g_object_ref (m_contact->photo); 
    return;
  }
  
  photo = e_contact_get (e_contact, E_CONTACT_PHOTO);
  if (!photo)
  {
    m_contact->photo = gdk_pixbuf_new_from_file (PKGDATADIR"/person.png", NULL);
    if (m_contact->photo)
      g_object_ref (m_contact->photo);
    return;
 
  }
  
  loader = gdk_pixbuf_loader_new ();
  gdk_pixbuf_loader_write (loader, 
                           photo->data.inlined.data,
                           photo->data.inlined.length,
                           NULL);
  gdk_pixbuf_loader_close (loader, NULL);
  m_contact->photo = gdk_pixbuf_loader_get_pixbuf (loader);

  if (GDK_IS_PIXBUF (m_contact->photo))
    g_object_ref (m_contact->photo);
  else 
  {
    m_contact->photo = gdk_pixbuf_new_from_file (PKGDATADIR"/person.png", NULL);
    if (m_contact->photo)
      g_object_ref (m_contact->photo); 
  }

  g_object_unref (loader);
  e_contact_photo_free (photo);
}
Exemplo n.º 11
0
/**
 * gtk_selection_data_set_pixbuf:
 * @selection_data: a #GtkSelectionData
 * @pixbuf: a #GdkPixbuf
 * 
 * Sets the contents of the selection from a #GdkPixbuf
 * The pixbuf is converted to the form determined by
 * @selection_data->target.
 * 
 * Returns: %TRUE if the selection was successfully set,
 *   otherwise %FALSE.
 **/
gboolean
gtk_selection_data_set_pixbuf (GtkSelectionData *selection_data,
			       GdkPixbuf        *pixbuf)
{
  GSList *formats, *f;
  gchar **mimes, **m;
  GdkAtom atom;
  gboolean result;
  gchar *str, *type;
  gsize len;

  g_return_val_if_fail (selection_data != NULL, FALSE);
  g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), FALSE);

  formats = gdk_pixbuf_get_formats ();

  for (f = formats; f; f = f->next)
    {
      GdkPixbufFormat *fmt = f->data;

      mimes = gdk_pixbuf_format_get_mime_types (fmt);
      for (m = mimes; *m; m++)
	{
	  atom = g_intern_string (*m);
	  if (selection_data->target == atom)
	    {
	      str = NULL;
	      type = gdk_pixbuf_format_get_name (fmt);
	      result = gdk_pixbuf_save_to_buffer (pixbuf, &str, &len,
						  type, NULL,
                                                  ((strcmp (type, "png") == 0) ?
                                                   "compression" : NULL), "2",
                                                  NULL);
	      if (result)
		gtk_selection_data_set (selection_data,
					atom, 8, (guchar *)str, len);
	      g_free (type);
	      g_free (str);
	      g_strfreev (mimes);
	      g_slist_free (formats);

	      return result;
	    }
	}

      g_strfreev (mimes);
    }

  g_slist_free (formats);
 
  return FALSE;
}
Exemplo n.º 12
0
/**
 * gdk_pixbuf_read_pixels:
 * @pixbuf: A pixbuf
 *
 * Returns a read-only pointer to the raw pixel data; must not be
 * modified.  This function allows skipping the implicit copy that
 * must be made if gdk_pixbuf_get_pixels() is called on a read-only
 * pixbuf.
 *
 * Since: 2.32
 */
const guint8*
gdk_pixbuf_read_pixels (const GdkPixbuf  *pixbuf)
{
	g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
        
        if (pixbuf->bytes) {
                gsize len;
                /* Ignore len; callers know the size via other variables */
                return g_bytes_get_data (pixbuf->bytes, &len);
        } else {
                return pixbuf->pixels;
        }
}
Exemplo n.º 13
0
void HudIconTextureSource::ColorForIcon(GdkPixbuf* pixbuf)
{
  if (GDK_IS_PIXBUF(pixbuf))
  {
    unsigned int width = gdk_pixbuf_get_width(pixbuf);
    unsigned int height = gdk_pixbuf_get_height(pixbuf);
    unsigned int row_bytes = gdk_pixbuf_get_rowstride(pixbuf);
    
    long int rtotal = 0, gtotal = 0, btotal = 0;
    float total = 0.0f;
    
    guchar* img = gdk_pixbuf_get_pixels(pixbuf);
    
    for (unsigned int i = 0; i < width; i++)
    {
      for (unsigned int j = 0; j < height; j++)
      {
        guchar* pixels = img + (j * row_bytes + i * 4);
        guchar r = *(pixels + 0);
        guchar g = *(pixels + 1);
        guchar b = *(pixels + 2);
        guchar a = *(pixels + 3);
        
        float saturation = (MAX(r, MAX(g, b)) - MIN(r, MIN(g, b))) / 255.0f;
        float relevance = .1 + .9 * (a / 255.0f) * saturation;
        
        rtotal += (guchar)(r * relevance);
        gtotal += (guchar)(g * relevance);
        btotal += (guchar)(b * relevance);
        
        total += relevance * 255;
      }
    }
    
    nux::color::RedGreenBlue rgb(rtotal / total,
                                 gtotal / total,
                                 btotal / total);
    nux::color::HueSaturationValue hsv(rgb);
    
    if (hsv.saturation > 0.15f)
      hsv.saturation = 0.65f;
    
    hsv.value = 0.90f;
    bg_color = nux::Color(nux::color::RedGreenBlue(hsv));
  }
  else
  {
    LOG_ERROR(logger) << "Pixbuf (" << pixbuf << ") passed is non valid";
    bg_color = nux::Color(255,255,255,255);
  }
}
Exemplo n.º 14
0
static void
astro_contact_row_set_icon (AstroContactRow *row, GdkPixbuf *icon)
{
  AstroContactRowPrivate *priv;

  g_return_if_fail (ASTRO_IS_CONTACT_ROW (row));
  g_return_if_fail (GDK_IS_PIXBUF (icon));
  priv = row->priv;

  priv->icon = icon;

  g_object_set (G_OBJECT (priv->texture), "pixbuf", icon, NULL);
  clutter_actor_set_size (priv->texture, ICON_SIZE, ICON_SIZE);
}
Exemplo n.º 15
0
/**
 * gdk_pixbuf_get_pixels_with_length: (rename-to gdk_pixbuf_get_pixels)
 * @pixbuf: A pixbuf.
 * @length: (out): The length of the binary data.
 *
 * Queries a pointer to the pixel data of a pixbuf.
 *
 * Return value: (array length=length): A pointer to the pixbuf's
 * pixel data.  Please see the section on [image data][image-data]
 * for information about how the pixel data is stored in memory.
 *
 * This function will cause an implicit copy of the pixbuf data if the
 * pixbuf was created from read-only data.
 *
 * Since: 2.26
 */
guchar *
gdk_pixbuf_get_pixels_with_length (const GdkPixbuf *pixbuf,
                                   guint           *length)
{
	g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);

        downgrade_to_pixels (pixbuf);
        g_assert (pixbuf->storage == STORAGE_PIXELS);

        if (length)
                *length = gdk_pixbuf_get_byte_length (pixbuf);

	return pixbuf->s.pixels.pixels;
}
Exemplo n.º 16
0
static void gx_knob_size_request (GtkWidget *widget, GtkRequisition *requisition)
{
	g_assert(GX_IS_KNOB(widget));
	GdkPixbuf *pb = gtk_widget_render_icon(widget, get_stock_id(widget), GtkIconSize(-1), NULL);
	if (GDK_IS_PIXBUF (pb)) {
		gint fcount;
		GdkRectangle rect;
		get_image_dimensions (widget, pb, &rect, &fcount);
		requisition->width = rect.width;
		requisition->height = rect.height;
		_gx_regler_calc_size_request(GX_REGLER(widget), requisition);
		g_object_unref(pb);
	}
}
Exemplo n.º 17
0
/**
 * gdk_pixbuf_composite:
 * @src: a #GdkPixbuf
 * @dest: the #GdkPixbuf into which to render the results
 * @dest_x: the left coordinate for region to render
 * @dest_y: the top coordinate for region to render
 * @dest_width: the width of the region to render
 * @dest_height: the height of the region to render
 * @offset_x: the offset in the X direction (currently rounded to an integer)
 * @offset_y: the offset in the Y direction (currently rounded to an integer)
 * @scale_x: the scale factor in the X direction
 * @scale_y: the scale factor in the Y direction
 * @interp_type: the interpolation type for the transformation.
 * @overall_alpha: overall alpha for source image (0..255)
 * 
 * Creates a transformation of the source image @src by scaling by
 * @scale_x and @scale_y then translating by @offset_x and @offset_y.
 * This gives an image in the coordinates of the destination pixbuf.
 * The rectangle (@dest_x, @dest_y, @dest_width, @dest_height)
 * is then composited onto the corresponding rectangle of the
 * original destination image.
 * 
 * When the destination rectangle contains parts not in the source 
 * image, the data at the edges of the source image is replicated
 * to infinity. 
 *
 * ![](composite.png)
 */
void
gdk_pixbuf_composite (const GdkPixbuf *src,
		      GdkPixbuf       *dest,
		      int              dest_x,
		      int              dest_y,
		      int              dest_width,
		      int              dest_height,
		      double           offset_x,
		      double           offset_y,
		      double           scale_x,
		      double           scale_y,
		      GdkInterpType    interp_type,
		      int              overall_alpha)
{
  const guint8 *src_pixels;
  guint8 *dest_pixels;

  g_return_if_fail (GDK_IS_PIXBUF (src));
  g_return_if_fail (GDK_IS_PIXBUF (dest));
  g_return_if_fail (dest_x >= 0 && dest_x + dest_width <= dest->width);
  g_return_if_fail (dest_y >= 0 && dest_y + dest_height <= dest->height);
  g_return_if_fail (overall_alpha >= 0 && overall_alpha <= 255);

  offset_x = floor (offset_x + 0.5);
  offset_y = floor (offset_y + 0.5);

  /* Force an implicit copy */
  dest_pixels = gdk_pixbuf_get_pixels (dest);
  src_pixels = gdk_pixbuf_read_pixels (src);

  _pixops_composite (dest_pixels, dest->width, dest->height, dest->rowstride,
                     dest->n_channels, dest->has_alpha, src_pixels,
                     src->width, src->height, src->rowstride, src->n_channels,
                     src->has_alpha, dest_x, dest_y, dest_width, dest_height,
                     offset_x, offset_y, scale_x, scale_y,
                     (PixopsInterpType)interp_type, overall_alpha);
}
Exemplo n.º 18
0
void
moko_talking_outgoing_call (MokoTalking      *talking,
                            const gchar      *number,
                            MokoContactEntry *entry)
{
  MokoTalkingPrivate *priv;
  gchar *markup = NULL;

  moko_talking_reset_ui (talking);

  g_return_if_fail (MOKO_IS_TALKING (talking));
  priv = talking->priv;

  gtk_widget_hide (priv->incoming_bar);
  gtk_widget_show_all (priv->main_bar);

  if ( HEADSET_STATUS_IN == moko_headset_status_get() )
    moko_sound_profile_set(SOUND_PROFILE_GSM_HEADSET);
  else
    moko_sound_profile_set(SOUND_PROFILE_GSM_HANDSET);

  if (entry)
    markup = g_strdup_printf ("<b>%s</b>\n%s", entry->contact->name, number);
  else
    markup = g_strdup (number);

  gtk_window_set_title (GTK_WINDOW (priv->window), "Dialing");
  gtk_label_set_text (GTK_LABEL (priv->title), "Outgoing Call");
  gtk_label_set_text (GTK_LABEL (priv->duration), "");

  gtk_label_set_markup (GTK_LABEL (priv->status), markup);

  if (entry && GDK_IS_PIXBUF (entry->contact->photo))
    gtk_image_set_from_pixbuf (GTK_IMAGE (priv->person), entry->contact->photo);
  else
    gtk_image_set_from_file (GTK_IMAGE (priv->person),
                             PKGDATADIR"/unknown.png");
  if (priv->timeout)
    g_source_remove (priv->timeout);
  priv->timeout = g_timeout_add (1000,
                                 (GSourceFunc)outgoing_timeout,
                                 (gpointer)talking);

  g_free (markup);
  priv->call_direction = CALL_DIRECTION_OUTGOING;

  gtk_window_present (GTK_WINDOW (priv->window));
  gtk_window_deiconify (GTK_WINDOW (priv->window));
}
/**
 * photos_print_preview_new_with_pixbuf:
 * @pixbuf: a #GdkPixbuf
 *
 * Creates a new #PhotosPrintPreview widget, and sets the #GdkPixbuf to preview
 * on it.
 *
 * Returns: A new #PhotosPrintPreview widget.
 **/
GtkWidget *
photos_print_preview_new_with_pixbuf (GdkPixbuf *pixbuf)
{
	PhotosPrintPreview *preview;

	g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);

	preview = PHOTOS_PRINT_PREVIEW (photos_print_preview_new ());

	preview->priv->pixbuf = g_object_ref (pixbuf);

	update_relative_sizes (preview);

	return GTK_WIDGET (preview);
}
Exemplo n.º 20
0
/**
 * gimp_pixbuf_get_format:
 * @pixbuf: a #GdkPixbuf
 *
 * Returns the Babl format that corresponds to the @pixbuf's pixel format.
 *
 * Return value: the @pixbuf's pixel format
 *
 * Since: GIMP 2.10
 **/
const Babl *
gimp_pixbuf_get_format (GdkPixbuf *pixbuf)
{
    g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);

    switch (gdk_pixbuf_get_n_channels (pixbuf))
    {
    case 3:
        return babl_format ("R'G'B' u8");
    case 4:
        return babl_format ("R'G'B'A u8");
    }

    g_return_val_if_reached (NULL);
}
Exemplo n.º 21
0
GtkCssImage *
_gtk_css_image_surface_new_for_pixbuf (GdkPixbuf *pixbuf)
{
  GtkCssImage *image;
  cairo_surface_t *surface;

  g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);

  surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, 1, NULL);

  image = _gtk_css_image_surface_new (surface);
  cairo_surface_destroy (surface);

  return image;
}
Exemplo n.º 22
0
/**
 * xfce_panel_image_set_from_pixbuf:
 * @image  : an #XfcePanelImage.
 * @pixbuf : a #GdkPixbuf, or %NULL.
 *
 * See xfce_panel_image_new_from_pixbuf() for details.
 *
 * Since: 4.8
 **/
void
xfce_panel_image_set_from_pixbuf (XfcePanelImage *image,
                                  GdkPixbuf      *pixbuf)
{
  g_return_if_fail (XFCE_IS_PANEL_IMAGE (image));
  g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf));

  xfce_panel_image_clear (image);

  /* set the new pixbuf, scale it to the maximum size if needed */
  image->priv->pixbuf = xfce_panel_image_scale_pixbuf (pixbuf,
      MAX_PIXBUF_SIZE, MAX_PIXBUF_SIZE);

  gtk_widget_queue_resize (GTK_WIDGET (image));
}
/**
 * eom_print_preview_new_with_pixbuf:
 * @pixbuf: a #GdkPixbuf
 *
 * Creates a new #EomPrintPreview widget, and sets the #GdkPixbuf to preview
 * on it.
 *
 * Returns: A new #EomPrintPreview widget.
 **/
GtkWidget *
eom_print_preview_new_with_pixbuf (GdkPixbuf *pixbuf)
{
	EomPrintPreview *preview;

	g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);

	preview = EOM_PRINT_PREVIEW (eom_print_preview_new ());

	preview->priv->image = g_object_ref (pixbuf);

	update_relative_sizes (preview);

	return GTK_WIDGET (preview);
}
Exemplo n.º 24
0
/**
 * gtk_tooltip_set_icon:
 * @tooltip: a #GtkTooltip
 * @pixbuf: (allow-none): a #GdkPixbuf, or %NULL
 *
 * Sets the icon of the tooltip (which is in front of the text) to be
 * @pixbuf.  If @pixbuf is %NULL, the image will be hidden.
 *
 * Since: 2.12
 */
void
gtk_tooltip_set_icon (GtkTooltip *tooltip,
		      GdkPixbuf  *pixbuf)
{
  g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
  if (pixbuf)
    g_return_if_fail (GDK_IS_PIXBUF (pixbuf));

  gtk_image_set_from_pixbuf (GTK_IMAGE (tooltip->image), pixbuf);

  if (pixbuf)
    gtk_widget_show (tooltip->image);
  else
    gtk_widget_hide (tooltip->image);
}
Exemplo n.º 25
0
static gboolean gx_knob_expose(GtkWidget *widget, GdkEventExpose *event)
{
	g_assert(GX_IS_KNOB(widget));
	GdkRectangle image_rect, value_rect;
	GdkPixbuf *pb = gtk_widget_render_icon(widget, get_stock_id(widget), GtkIconSize(-1), NULL);
	if (GDK_IS_PIXBUF (pb)) {
		gint fcount;
		get_image_dimensions (widget, pb, &image_rect, &fcount);
		gdouble knobstate = _gx_regler_get_step_pos(GX_REGLER(widget), 1);
		_gx_regler_get_positions(GX_REGLER(widget), &image_rect, &value_rect);
		_gx_knob_expose(widget, &image_rect, knobstate, pb, fcount, gtk_widget_has_focus(widget));
		_gx_regler_display_value(GX_REGLER(widget), &value_rect);
		g_object_unref(pb);
	}
	return FALSE;
}
Exemplo n.º 26
0
int
clip_GTK_DRAGSOURCESETICONPIXBUF(ClipMachine * cm)
{
        C_widget      *cwid = _fetch_cw_arg(cm);
        C_object   *cpixbuf = _fetch_cobject(cm, _clip_spar(cm, 2));

	CHECKCWID(cwid, GTK_IS_WIDGET);
	CHECKCOBJ(cpixbuf, GDK_IS_PIXBUF(cpixbuf->object));

        gtk_drag_source_set_icon_pixbuf(GTK_WIDGET(cwid->widget),
                GDK_PIXBUF(cpixbuf->object));

	return 0;
err:
	return 1;
}
Exemplo n.º 27
0
static void on_window_icon_changed (WnckWindow *window, TaskItem *item)
{
  TaskItemPrivate *priv;
  
  g_return_if_fail (TASK_IS_ITEM (item));
  
  priv = item->priv;
  
  if (GDK_IS_PIXBUF (priv->pixbuf))
  {
    g_object_unref (priv->pixbuf);
    priv->pixbuf = NULL;
  }
  
  gtk_widget_queue_draw (GTK_WIDGET (item));
}
void
empathy_smiley_manager_add_from_pixbuf (EmpathySmileyManager *manager,
					GdkPixbuf            *smiley,
					const gchar          *first_str,
					...)
{
	va_list var_args;

	g_return_if_fail (EMPATHY_IS_SMILEY_MANAGER (manager));
	g_return_if_fail (GDK_IS_PIXBUF (smiley));
	g_return_if_fail (!G_STR_EMPTY (first_str));

	va_start (var_args, first_str);
	smiley_manager_add_valist (manager, smiley, first_str, var_args);
	va_end (var_args);
}
Exemplo n.º 29
0
/**
 * gimp_layer_new_from_pixbuf:
 * @pixbuf:     The pixbuf to make the new layer from.
 * @dest_image: The image the new layer will be added to.
 * @format:     The #Babl format of the new layer.
 * @name:       The new layer's name.
 * @opacity:    The new layer's opacity.
 * @mode:       The new layer's mode.
 *
 * Copies %pixbuf to a layer taking into consideration the
 * possibility of transforming the contents to meet the requirements
 * of the target image type
 *
 * Return value: The new layer.
 **/
GimpLayer *
gimp_layer_new_from_pixbuf (GdkPixbuf            *pixbuf,
                            GimpImage            *dest_image,
                            const Babl           *format,
                            const gchar          *name,
                            gdouble               opacity,
                            GimpLayerModeEffects  mode)
{
  GimpLayer        *layer;
  GeglBuffer       *buffer;
  guint8           *icc_data;
  gsize             icc_len;
  GimpColorProfile *profile = NULL;

  g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
  g_return_val_if_fail (GIMP_IS_IMAGE (dest_image), NULL);
  g_return_val_if_fail (format != NULL, NULL);

  layer = gimp_layer_new (dest_image,
                          gdk_pixbuf_get_width  (pixbuf),
                          gdk_pixbuf_get_height (pixbuf),
                          format, name, opacity, mode);

  buffer = gimp_pixbuf_create_buffer (pixbuf);

  icc_data = gimp_pixbuf_get_icc_profile (pixbuf, &icc_len);
  if (icc_data)
    {
      profile = gimp_color_profile_new_from_icc_profile (icc_data, icc_len,
                                                         NULL);
      g_free (icc_data);
    }

  if (! profile && gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB)
    {
      profile = gimp_color_profile_new_srgb ();
    }

  gimp_layer_new_convert_buffer (layer, buffer, profile, NULL);

  if (profile)
    g_object_unref (profile);

  g_object_unref (buffer);

  return layer;
}
Exemplo n.º 30
0
/**
 * gdk_pixbuf_flip:
 * @src: a #GdkPixbuf
 * @horizontal: %TRUE to flip horizontally, %FALSE to flip vertically
 *
 * Flips a pixbuf horizontally or vertically and returns the
 * result in a new pixbuf.
 *
 * Returns: (nullable) (transfer full): the new #GdkPixbuf, or %NULL
 * if not enough memory could be allocated for it.
 *
 * Since: 2.6
 */
GdkPixbuf *
gdk_pixbuf_flip (const GdkPixbuf *src,
		 gboolean         horizontal)
{
  const guint8 *src_pixels;
  guint8 *dest_pixels;
  GdkPixbuf *dest;
  const guchar *p;
  guchar *q;
  gint x, y;

  g_return_val_if_fail (GDK_IS_PIXBUF (src), NULL);
  dest = gdk_pixbuf_new (src->colorspace, 
			 src->has_alpha, 
			 src->bits_per_sample, 
			 src->width, 
			 src->height);
  if (!dest)
    return NULL;

  dest_pixels = gdk_pixbuf_get_pixels (dest);
  src_pixels = gdk_pixbuf_read_pixels (src);

  if (!horizontal) /* flip vertical */
    {
      for (y = 0; y < dest->height; y++)
	{
	  p = src_pixels + OFFSET (src, 0, y);
	  q = dest_pixels + OFFSET (dest, 0, dest->height - y - 1);
	  memcpy (q, p, dest->rowstride);
	}
    }
  else /* flip horizontal */
    {
      for (y = 0; y < dest->height; y++)
	{
	  for (x = 0; x < dest->width; x++)
	    {
	      p = src_pixels + OFFSET (src, x, y);
	      q = dest_pixels + OFFSET (dest, dest->width - x - 1, y);
	      memcpy (q, p, dest->n_channels);
	    }
	}
    }

  return dest;
}