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>
34
34
#include "cheese-thumb-view.h"
36
#define THUMB_VIEW_MINIMUM_WIDTH 140
37
#define THUMB_VIEW_MINIMUM_HEIGHT 100
37
39
#define CHEESE_THUMB_VIEW_GET_PRIVATE(o) \
38
40
(G_TYPE_INSTANCE_GET_PRIVATE ((o), CHEESE_TYPE_THUMB_VIEW, CheeseThumbViewPrivate))
40
42
G_DEFINE_TYPE (CheeseThumbView, cheese_thumb_view, GTK_TYPE_ICON_VIEW);
45
46
GtkListStore *store;
84
86
CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
86
88
GnomeDesktopThumbnailFactory *factory = priv->factory;
87
GFile *file = item->file;
88
GtkTreeIter iter = item->iter;
89
GdkPixbuf *pixbuf = NULL;
89
GFile *file = item->file;
90
GtkTreeIter iter = item->iter;
91
GdkPixbuf *pixbuf = NULL;
97
99
info = g_file_query_info (file, "standard::content-type,time::modified", 0, NULL, NULL);
195
197
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->store), &iter))
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))
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);
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));
400
401
g_list_free (list);
538
539
cheese_thumb_view_finalize (GObject *object)
540
CheeseThumbView *thumb_view;
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);
545
544
g_object_unref (priv->store);
546
545
g_object_unref (priv->fileutil);
564
cheese_thumb_view_row_inserted_cb (GtkTreeModel *tree_model,
567
CheeseThumbView *thumb_view)
569
CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
572
gtk_widget_set_size_request (GTK_WIDGET (thumb_view), -1, -1);
576
cheese_thumb_view_row_deleted_cb (GtkTreeModel *tree_model,
578
CheeseThumbView *thumb_view)
580
CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
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);
565
590
cheese_thumb_view_init (CheeseThumbView *thumb_view)
567
592
CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
569
594
char *path_videos = NULL, *path_photos = NULL;
572
const int THUMB_VIEW_HEIGHT = 120;
574
598
eog_thumbnail_init ();
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);
603
g_signal_connect (G_OBJECT (priv->store),
605
G_CALLBACK (cheese_thumb_view_row_inserted_cb),
607
g_signal_connect (G_OBJECT (priv->store),
609
G_CALLBACK (cheese_thumb_view_row_deleted_cb),
578
612
priv->fileutil = cheese_fileutil_new ();
580
614
gtk_icon_view_set_model (GTK_ICON_VIEW (thumb_view), GTK_TREE_MODEL (priv->store));
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);
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);
584
624
path_videos = cheese_fileutil_get_video_path (priv->fileutil);
585
625
path_photos = cheese_fileutil_get_photo_path (priv->fileutil);
610
650
gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (thumb_view), 0);
612
gtk_icon_view_set_columns (GTK_ICON_VIEW (thumb_view), -1);
614
652
gtk_icon_view_set_columns (GTK_ICON_VIEW (thumb_view), G_MAXINT);
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),