~ubuntu-branches/debian/sid/cheese/sid

« back to all changes in this revision

Viewing changes to src/cheese-thumb-view.c

  • Committer: Bazaar Package Importer
  • Author(s): Andrea Veri, Andrea Veri, Loïc Minier
  • Date: 2009-09-23 20:25:41 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20090923202541-q9lr8b7ykic314xy
Tags: 2.28.0.1-1
[ Andrea Veri ]
* New upstream release.
* debian/control:
  - Bumped Standards-version to 3.8.3. No changes needed.
  - libgtk2.0-dev bumped to >= 2.17.4 as per configure.ac
    requirements.
  - libgnome-desktop-dev bumped to >= 2.26.0 as per configure.ac
    requirements.
  - added a B-D on x11proto-core-dev needed from multimedia keys
    to work properly.
* debian/copyright:
  - added missing copyright holders.
* debian/patches:
  - removed as long as it has no patches in it.
* debian/rules:
  - simple-patchsys include removed, there are no patches to be
    applied.

[ Loïc Minier ]
* Bdep on rarian-compat instead of scrollkeeper.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright © 2007,2008 daniel g. siegel <dgsiegel@gmail.com>
 
2
 * Copyright © 2007,2008 daniel g. siegel <dgsiegel@gnome.org>
3
3
 * Copyright © 2007,2008 Jaap Haitsma <jaap@haitsma.org>
4
4
 * Copyright © 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
5
5
 *
33
33
 
34
34
#include "cheese-thumb-view.h"
35
35
 
 
36
#define THUMB_VIEW_MINIMUM_WIDTH  140
 
37
#define THUMB_VIEW_MINIMUM_HEIGHT 100
36
38
 
37
39
#define CHEESE_THUMB_VIEW_GET_PRIVATE(o) \
38
40
  (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHEESE_TYPE_THUMB_VIEW, CheeseThumbViewPrivate))
39
41
 
40
42
G_DEFINE_TYPE (CheeseThumbView, cheese_thumb_view, GTK_TYPE_ICON_VIEW);
41
43
 
42
 
 
43
44
typedef struct
44
45
{
45
46
  GtkListStore *store;
48
49
  GFileMonitor   *video_file_monitor;
49
50
  GnomeDesktopThumbnailFactory *factory;
50
51
  gboolean multiplex_thumbnail_generator;
 
52
  guint n_items;
51
53
} CheeseThumbViewPrivate;
52
54
 
53
55
enum
84
86
  CheeseThumbViewPrivate    *priv       = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
85
87
 
86
88
  GnomeDesktopThumbnailFactory *factory = priv->factory;
87
 
  GFile                 *file    = item->file;
88
 
  GtkTreeIter            iter    = item->iter;
89
 
  GdkPixbuf             *pixbuf  = NULL;
90
 
  GFileInfo             *info;
91
 
  char                  *thumb_loc;
92
 
  GTimeVal               mtime;
93
 
  char                  *mime_type;
94
 
  char                  *uri;
95
 
  char                  *filename;
 
89
  GFile                        *file    = item->file;
 
90
  GtkTreeIter                   iter    = item->iter;
 
91
  GdkPixbuf                    *pixbuf  = NULL;
 
92
  GFileInfo                    *info;
 
93
  char                         *thumb_loc;
 
94
  GTimeVal                      mtime;
 
95
  char                         *mime_type;
 
96
  char                         *uri;
 
97
  char                         *filename;
96
98
 
97
99
  info = g_file_query_info (file, "standard::content-type,time::modified", 0, NULL, NULL);
98
100
 
180
182
  GtkTreePath  *path;
181
183
  char         *filename, *basename, *col_filename;
182
184
  GError       *error = NULL;
183
 
  gboolean      skip = FALSE;
 
185
  gboolean      skip  = FALSE;
184
186
 
185
187
  CheeseThumbViewThreadData *data;
186
188
 
194
196
 
195
197
  if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->store), &iter))
196
198
  {
197
 
 
198
199
    /* check if the selected item is the first, else go through the store */
199
200
    gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter, THUMBNAIL_URL_COLUMN, &col_filename, -1);
200
201
    if (g_ascii_strcasecmp (col_filename, filename))
223
224
  {
224
225
    char *f;
225
226
 
226
 
    f = g_strdup_printf ("%s/pixmaps/cheese-%i.svg", PACKAGE_DATADIR, g_random_int_range (1, 4));
 
227
    f      = g_strdup_printf ("%s/pixmaps/cheese-%i.svg", PACKAGE_DATADIR, g_random_int_range (1, 4));
227
228
    pixbuf = gdk_pixbuf_new_from_file (f, NULL);
228
229
    g_free (f);
229
230
  }
394
395
 
395
396
    g_free (str);
396
397
  }
397
 
  gtk_selection_data_set (data, data->target, 8,
398
 
                          (guchar *) uris, strlen (uris));
 
398
  gtk_selection_data_set (data, gtk_selection_data_get_target (data),
 
399
                          8, (guchar *) uris, strlen (uris));
399
400
  g_free (uris);
400
401
  g_list_free (list);
401
402
}
537
538
static void
538
539
cheese_thumb_view_finalize (GObject *object)
539
540
{
540
 
  CheeseThumbView *thumb_view;
541
 
 
542
 
  thumb_view = CHEESE_THUMB_VIEW (object);
543
 
  CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
 
541
  CheeseThumbView        *thumb_view = CHEESE_THUMB_VIEW (object);
 
542
  CheeseThumbViewPrivate *priv       = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
544
543
 
545
544
  g_object_unref (priv->store);
546
545
  g_object_unref (priv->fileutil);
562
561
}
563
562
 
564
563
static void
 
564
cheese_thumb_view_row_inserted_cb (GtkTreeModel    *tree_model,
 
565
                                   GtkTreePath     *path,
 
566
                                   GtkTreeIter     *iter,
 
567
                                   CheeseThumbView *thumb_view)
 
568
{
 
569
  CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
 
570
 
 
571
  priv->n_items++;
 
572
  gtk_widget_set_size_request (GTK_WIDGET (thumb_view), -1, -1);
 
573
}
 
574
 
 
575
static void
 
576
cheese_thumb_view_row_deleted_cb (GtkTreeModel    *tree_model,
 
577
                                  GtkTreePath     *path,
 
578
                                  CheeseThumbView *thumb_view)
 
579
{
 
580
  CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
 
581
 
 
582
  priv->n_items--;
 
583
  if (priv->n_items == 0)
 
584
    gtk_widget_set_size_request (GTK_WIDGET (thumb_view),
 
585
                                 THUMB_VIEW_MINIMUM_WIDTH,
 
586
                                 THUMB_VIEW_MINIMUM_HEIGHT);
 
587
}
 
588
 
 
589
static void
565
590
cheese_thumb_view_init (CheeseThumbView *thumb_view)
566
591
{
567
592
  CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
568
593
 
569
594
  char *path_videos = NULL, *path_photos = NULL;
570
595
 
571
 
  GFile    *file;
572
 
  const int THUMB_VIEW_HEIGHT = 120;
 
596
  GFile *file;
573
597
 
574
598
  eog_thumbnail_init ();
575
599
 
576
 
  priv->store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
 
600
  priv->store   = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
 
601
  priv->n_items = 0;
 
602
 
 
603
  g_signal_connect (G_OBJECT (priv->store),
 
604
                    "row-inserted",
 
605
                    G_CALLBACK (cheese_thumb_view_row_inserted_cb),
 
606
                    thumb_view);
 
607
  g_signal_connect (G_OBJECT (priv->store),
 
608
                    "row-deleted",
 
609
                    G_CALLBACK (cheese_thumb_view_row_deleted_cb),
 
610
                    thumb_view);
577
611
 
578
612
  priv->fileutil = cheese_fileutil_new ();
579
613
 
580
614
  gtk_icon_view_set_model (GTK_ICON_VIEW (thumb_view), GTK_TREE_MODEL (priv->store));
581
615
 
582
 
  gtk_widget_set_size_request (GTK_WIDGET (thumb_view), -1, THUMB_VIEW_HEIGHT);
 
616
  gtk_widget_set_size_request (GTK_WIDGET (thumb_view),
 
617
                               THUMB_VIEW_MINIMUM_WIDTH,
 
618
                               THUMB_VIEW_MINIMUM_HEIGHT);
 
619
 
 
620
  gtk_icon_view_set_margin (GTK_ICON_VIEW (thumb_view), 0);
 
621
  gtk_icon_view_set_row_spacing (GTK_ICON_VIEW (thumb_view), 0);
 
622
  gtk_icon_view_set_column_spacing (GTK_ICON_VIEW (thumb_view), 0);
583
623
 
584
624
  path_videos = cheese_fileutil_get_video_path (priv->fileutil);
585
625
  path_photos = cheese_fileutil_get_photo_path (priv->fileutil);
608
648
  }
609
649
 
610
650
  gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (thumb_view), 0);
611
 
#ifdef HILDON
612
 
  gtk_icon_view_set_columns (GTK_ICON_VIEW (thumb_view), -1);
613
 
#else
 
651
 
614
652
  gtk_icon_view_set_columns (GTK_ICON_VIEW (thumb_view), G_MAXINT);
615
 
#endif
616
653
 
617
654
  gtk_icon_view_enable_model_drag_source (GTK_ICON_VIEW (thumb_view), GDK_BUTTON1_MASK,
618
655
                                          target_table, G_N_ELEMENTS (target_table),