MaskedPixmap* masked_pixmap_new(GdkPixbuf *full_size) { //printf("masked_pixmap_new()...\n"); g_return_val_if_fail(full_size != NULL, NULL); GdkPixbuf* src_pixbuf = scale_pixbuf(full_size, HUGE_WIDTH, HUGE_HEIGHT); g_return_val_if_fail(src_pixbuf != NULL, NULL); GdkPixbuf* normal_pixbuf = scale_pixbuf(src_pixbuf, ICON_WIDTH, ICON_HEIGHT); g_return_val_if_fail(normal_pixbuf != NULL, NULL); //small pixbuf added by Tim - where does rox do this? GdkPixbuf* small_pixbuf = scale_pixbuf(src_pixbuf, SMALL_WIDTH, SMALL_HEIGHT); g_return_val_if_fail(small_pixbuf, NULL); MaskedPixmap* mp = g_object_new(masked_pixmap_get_type(), NULL); mp->src_pixbuf = src_pixbuf; mp->pixbuf = normal_pixbuf; //mp->pixbuf_lit = create_spotlight_pixbuf(normal_pixbuf, 0x000099, 128); mp->sm_pixbuf = small_pixbuf; mp->width = gdk_pixbuf_get_width (normal_pixbuf); mp->height = gdk_pixbuf_get_height(normal_pixbuf); mp->sm_width = gdk_pixbuf_get_width (small_pixbuf); mp->sm_height = gdk_pixbuf_get_height(small_pixbuf); return mp; }
static void save_pixbuf (GdkPixbuf *pixbuf, const char *path, const char *video_path, int size, gboolean is_still) { GdkPixbuf *with_holes; GError *err = NULL; gboolean ret; /* If we're outputting a gallery or a raw image without a size, * don't scale the pixbuf or add borders */ if (gallery != -1 || (raw_output != FALSE && size == -1)) with_holes = g_object_ref (pixbuf); else if (raw_output != FALSE) with_holes = scale_pixbuf (pixbuf, size, TRUE); else with_holes = scale_pixbuf (pixbuf, size, is_still); ret = gdk_pixbuf_save (with_holes, path, "jpeg", &err, NULL); if (ret == FALSE) { if (err != NULL) { g_print ("totem-video-thumbnailer couldn't write the thumbnail '%s' for video '%s': %s\n", path, video_path, err->message); g_error_free (err); } else { g_print ("totem-video-thumbnailer couldn't write the thumbnail '%s' for video '%s'\n", path, video_path); } g_object_unref (with_holes); return; } g_object_unref (with_holes); }
static void save_pixbuf (GdkPixbuf *pixbuf, const char *path, const char *video_path, int size, gboolean is_still) { int width, height; GdkPixbuf *with_holes; GError *err = NULL; gboolean ret; height = gdk_pixbuf_get_height (pixbuf); width = gdk_pixbuf_get_width (pixbuf); /* If we're outputting a gallery or a raw image without a size, * don't scale the pixbuf or add borders */ if (gallery != -1 || (raw_output != FALSE && size == -1)) with_holes = g_object_ref (pixbuf); else if (raw_output != FALSE) with_holes = scale_pixbuf (pixbuf, size, TRUE); else with_holes = scale_pixbuf (pixbuf, size, is_still); if (jpeg_output == FALSE) { char *a_width, *a_height; a_width = g_strdup_printf ("%d", width); a_height = g_strdup_printf ("%d", height); ret = gdk_pixbuf_save (with_holes, path, "png", &err, "tEXt::Thumb::Image::Width", a_width, "tEXt::Thumb::Image::Height", a_height, NULL); } else { ret = gdk_pixbuf_save (with_holes, path, "jpeg", &err, NULL); } if (ret == FALSE) { if (err != NULL) { g_print ("totem-video-thumbnailer couldn't write the thumbnail '%s' for video '%s': %s\n", path, video_path, err->message); g_error_free (err); } else { g_print ("totem-video-thumbnailer couldn't write the thumbnail '%s' for video '%s'\n", path, video_path); } g_object_unref (with_holes); return; } #ifdef THUMB_DEBUG show_pixbuf (with_holes); #endif g_object_unref (with_holes); }
void set_notification_icon(GtkWindow* nw, GdkPixbuf* pixbuf) { WindowData* windata = g_object_get_data(G_OBJECT(nw), "windata"); g_assert(windata != NULL); GdkPixbuf* scaled = NULL; if (pixbuf != NULL) { scaled = scale_pixbuf(pixbuf, MAX_ICON_SIZE, MAX_ICON_SIZE, TRUE); } gtk_image_set_from_pixbuf(GTK_IMAGE(windata->icon), scaled); if (scaled != NULL) { int pixbuf_width = gdk_pixbuf_get_width(scaled); gtk_widget_show(windata->icon); gtk_widget_set_size_request(windata->iconbox, MAX(BODY_X_OFFSET, pixbuf_width), -1); g_object_unref(scaled); } else { gtk_widget_hide(windata->icon); gtk_widget_set_size_request(windata->iconbox, BODY_X_OFFSET, -1); } update_content_hbox_visibility(windata); }
void set_progressbar_image (GtkWindow *nw, GdkPixbuf *pixbuf) { WindowData *windata; GdkPixbuf *scaled; windata = g_object_get_data (G_OBJECT (nw), "windata"); g_assert (windata != NULL); scaled = NULL; if (pixbuf != NULL) { scaled = scale_pixbuf (pixbuf, MAX_PROGRESSBAR_SIZE, MAX_PROGRESSBAR_SIZE, TRUE); } gtk_image_set_from_pixbuf (GTK_IMAGE (windata->progressbar), scaled); if (scaled != NULL) { int pixbuf_width = gdk_pixbuf_get_width (scaled); gtk_widget_show (windata->icon); gtk_widget_set_size_request (windata->progressbarbox, MAX (BODY_X_OFFSET, pixbuf_width), -1); g_object_unref (scaled); } else { gtk_widget_hide (windata->icon); gtk_widget_set_size_request (windata->progressbarbox, BODY_X_OFFSET, -1); } }
static void set_face_from_filename (const char *filename) { GtkWidget *image; GdkPixbuf *pixbuf; GdkPixbuf *scaled; image = glade_xml_get_widget (xml, "face_image"); pixbuf = gdk_pixbuf_new_from_file (filename, NULL); scaled = scale_pixbuf (pixbuf); g_object_unref (pixbuf); pixbuf = scaled; if (! pixbuf) return; if (gdk_pixbuf_save (pixbuf, photofile, "png", NULL, NULL) != TRUE) { GtkWidget *d; char *tmp = g_filename_to_utf8 (photofile, -1, NULL, NULL, NULL); char *msg; msg = g_strdup_printf (_("File %s cannot be opened for " "writing."), tmp); d = hig_dialog_new (NULL /* parent */, GTK_DIALOG_MODAL /* flags */, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Cannot open file"), msg); gtk_dialog_run (GTK_DIALOG (d)); gtk_widget_destroy (d); g_free (tmp); g_free (msg); } else { /* Change to g_chmod after glib 2.8 release */ g_chmod (photofile, 0644); } gtk_image_set_from_file (GTK_IMAGE (image), photofile); }
void pixmap_make_small(MaskedPixmap *mp) { dbg(0, "************************* never get here"); if (mp->sm_pixbuf) return; g_return_if_fail(mp->src_pixbuf != NULL); mp->sm_pixbuf = scale_pixbuf(mp->src_pixbuf, SMALL_WIDTH, SMALL_HEIGHT); if (!mp->sm_pixbuf) { mp->sm_pixbuf = mp->src_pixbuf; g_object_ref(mp->sm_pixbuf); } //mp->sm_pixbuf_lit = create_spotlight_pixbuf(mp->sm_pixbuf, 0x000099, 128); mp->sm_width = gdk_pixbuf_get_width(mp->sm_pixbuf); mp->sm_height = gdk_pixbuf_get_height(mp->sm_pixbuf); }