~ubuntu-branches/ubuntu/intrepid/gnome-screensaver/intrepid

« back to all changes in this revision

Viewing changes to savers/gste-slideshow.c

  • Committer: Bazaar Package Importer
  • Author(s): Oliver Grawert
  • Date: 2007-08-28 10:46:56 UTC
  • mfrom: (1.1.23 upstream)
  • Revision ID: james.westby@ubuntu.com-20070828104656-o344j3i010yny3fv
Tags: 2.19.7-0ubuntu1
* New upstream release
 * Remove last bits of libgnomeui. Based on patch from
   Jani Monoses <jani@ubuntu.com> Fixes #463754.
 * Initialize XWindowAttributes before calling XGetWindowAttributes.
   Based on patch from Rodrigo Moya <rodrigo@novell.com>
 * Compare strstr with NULL.  Add some more debug in dialog
   response handling.
 * keyboard indicator is not a GtkMisc.  Noticed in bug #258221
 * On CK Lock emit lock signal instead of setting active directly.
 * MAINTAINERS: Add userid.
 * Add Xext explicitly to ALL_X_LIBS.  May fix #437225
 * Prevent critical errors with null pixbuf.  Patch from Frederic
   Crozat <fcrozat@mandriva.com>
 * Add --no-stretch option to slideshow engine.  Patch from
   Frederic Crozat <fcrozat@mandriva.com>
 * Misc fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
        int             window_width;
72
72
        int             window_height;
73
73
        PangoColor     *background_color;
 
74
        gboolean        no_stretch_hint;
74
75
 
75
76
        guint           timeout_id;
76
77
 
82
83
        PROP_0,
83
84
        PROP_IMAGES_LOCATION,
84
85
        PROP_SORT_IMAGES,
85
 
        PROP_SOLID_BACKGROUND
 
86
        PROP_SOLID_BACKGROUND,
 
87
        PROP_NO_STRETCH_HINT
86
88
};
87
89
 
88
90
#define GSTE_SLIDESHOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSTE_TYPE_SLIDESHOW, GSTESlideshowPrivate))
436
438
static GdkPixbuf *
437
439
scale_pixbuf (GdkPixbuf *pixbuf,
438
440
              int        max_width,
439
 
              int        max_height)
 
441
              int        max_height,
 
442
              gboolean   no_stretch_hint)
440
443
{
441
444
        int        pw;
442
445
        int        ph;
443
446
        float      scale_factor_x = 1.0;
444
447
        float      scale_factor_y = 1.0;
445
448
        float      scale_factor = 1.0;
446
 
        GdkPixbuf *scaled = NULL;
447
449
 
448
450
        pw = gdk_pixbuf_get_width (pixbuf);
449
451
        ph = gdk_pixbuf_get_height (pixbuf);
464
466
                scale_factor = scale_factor_x;
465
467
        }
466
468
 
467
 
        if (1) {
 
469
        /* always scale down, allow to disable scaling up */
 
470
        if (scale_factor < 1.0 || !no_stretch_hint) {
468
471
                int scale_x = (int) (pw * scale_factor);
469
472
                int scale_y = (int) (ph * scale_factor);
470
473
 
471
 
                scaled = gdk_pixbuf_scale_simple (pixbuf,
472
 
                                                  scale_x,
473
 
                                                  scale_y,
474
 
                                                  GDK_INTERP_BILINEAR);
 
474
                return gdk_pixbuf_scale_simple (pixbuf,
 
475
                                                scale_x,
 
476
                                                scale_y,
 
477
                                                GDK_INTERP_BILINEAR);
 
478
        } else {
 
479
                return g_object_ref (pixbuf);
475
480
        }
476
 
 
477
 
        return scaled;
478
481
}
479
482
 
480
483
static void
554
557
 
555
558
        pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
556
559
 
557
 
        transformed_pixbuf = gdk_pixbuf_apply_embedded_orientation (pixbuf);
558
 
 
559
 
        g_object_unref (pixbuf);
 
560
        if (pixbuf != NULL) {
 
561
                transformed_pixbuf = gdk_pixbuf_apply_embedded_orientation (pixbuf);
 
562
                g_object_unref (pixbuf);
 
563
        } else {
 
564
                transformed_pixbuf = NULL;
 
565
        }
560
566
 
561
567
        g_free (filename);
562
568
        show->priv->filename_list = g_slist_delete_link (show->priv->filename_list, l);
600
606
        pixbuf = get_pixbuf_from_location (show, location);
601
607
 
602
608
        if (pixbuf != NULL) {
603
 
                scaled = scale_pixbuf (pixbuf, width, height);
 
609
                scaled = scale_pixbuf (pixbuf, width, height, show->priv->no_stretch_hint);
604
610
                g_object_unref (pixbuf);
605
611
        }
606
612
 
682
688
}
683
689
 
684
690
void
 
691
gste_slideshow_set_no_stretch_hint (GSTESlideshow *show,
 
692
                                     gboolean       no_stretch_hint)
 
693
{
 
694
        g_return_if_fail (GSTE_IS_SLIDESHOW (show));
 
695
 
 
696
        show->priv->no_stretch_hint = no_stretch_hint;
 
697
}
 
698
 
 
699
void
685
700
gste_slideshow_set_background_color (GSTESlideshow *show,
686
701
                                     const char    *background_color)
687
702
{
722
737
        case PROP_SOLID_BACKGROUND:
723
738
                gste_slideshow_set_background_color (self, g_value_get_string (value));
724
739
                break;
 
740
        case PROP_NO_STRETCH_HINT:
 
741
                gste_slideshow_set_no_stretch_hint (self, g_value_get_boolean (value));
 
742
                break;
725
743
        default:
726
744
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
727
745
                break;
753
771
                        g_free (color);
754
772
                        break;
755
773
                }
 
774
        case PROP_NO_STRETCH_HINT:
 
775
                g_value_set_boolean (value, self->priv->no_stretch_hint);
 
776
                break;
756
777
        default:
757
778
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
758
779
                break;
873
894
                                                              NULL,
874
895
                                                              NULL,
875
896
                                                              G_PARAM_READWRITE));
 
897
        g_object_class_install_property (object_class,
 
898
                                         PROP_NO_STRETCH_HINT,
 
899
                                         g_param_spec_boolean ("no-stretch",
 
900
                                                               NULL,
 
901
                                                               NULL,
 
902
                                                               FALSE,
 
903
                                                               G_PARAM_READWRITE));
876
904
}
877
905
 
878
906
static void