cheese r665 - in branches/cheese-vala: . src
- From: jhaitsma svn gnome org
- To: svn-commits-list gnome org
- Subject: cheese r665 - in branches/cheese-vala: . src
- Date: Sun, 20 Apr 2008 01:09:24 +0100 (BST)
Author: jhaitsma
Date: Sun Apr 20 00:09:24 2008
New Revision: 665
URL: http://svn.gnome.org/viewvc/cheese?rev=665&view=rev
Log:
More work on thumb-view
Modified:
branches/cheese-vala/ (props changed)
branches/cheese-vala/configure.ac
branches/cheese-vala/src/Makefile.am
branches/cheese-vala/src/cheese-thumb-view.vala
branches/cheese-vala/src/cheese-window.vala
Modified: branches/cheese-vala/configure.ac
==============================================================================
--- branches/cheese-vala/configure.ac (original)
+++ branches/cheese-vala/configure.ac Sun Apr 20 00:09:24 2008
@@ -74,6 +74,7 @@
DBUS_GLIB_REQUIRED=0.7
LIBRSVG_REQUIRED=2.18.0
PANGOCAIRO_REQUIRED=1.18.0
+GEE_REQUIRED=0.1.0
PKG_CHECK_MODULES(CHEESE, \
glib-2.0 >= $GLIB_REQUIRED \
@@ -91,6 +92,7 @@
dbus-glib-1 >= $DBUS_GLIB_REQUIRED \
pangocairo >= $PANGOCAIRO_REQUIRED \
librsvg-2.0 >= $LIBRSVG_REQUIRED \
+ gee-1.0 >= $GEE_REQUIRED \
xxf86vm)
AC_SUBST(CHEESE_CFLAGS)
Modified: branches/cheese-vala/src/Makefile.am
==============================================================================
--- branches/cheese-vala/src/Makefile.am (original)
+++ branches/cheese-vala/src/Makefile.am Sun Apr 20 00:09:24 2008
@@ -1,5 +1,4 @@
VALA_CFLAGS = \
- -g \
--thread \
--vapidir ../vapi \
--pkg config \
@@ -7,7 +6,10 @@
--pkg gtk+-2.0 \
--pkg gstreamer-0.10 \
--pkg gconf-2.0 \
- --pkg gio-2.0
+ --pkg gio-2.0 \
+ --pkg gee-1.0 \
+ --pkg libgnomeui-2.0 \
+ --pkg gdk-pixbuf-2.0
AM_CPPFLAGS = \
-DBINDIR=\"$(bindir)\" \
Modified: branches/cheese-vala/src/cheese-thumb-view.vala
==============================================================================
--- branches/cheese-vala/src/cheese-thumb-view.vala (original)
+++ branches/cheese-vala/src/cheese-thumb-view.vala Sun Apr 20 00:09:24 2008
@@ -22,16 +22,143 @@
using GLib;
using Gtk;
using Gdk;
+using Gee;
+using Gnome;
public class Cheese.ThumbView : IconView {
const int THUMB_VIEW_HEIGHT = 120;
ListStore store;
FileMonitor dir_monitor;
+ ThumbnailFactory thumbnail_factory;
+
+ enum Target {
+ PLAIN,
+ PLAIN_UTF8,
+ URILIST
+ }
+ enum Column {
+ PIXBUF,
+ URL
+ }
+ const TargetEntry[] target_entries = {
+ { "text/uri-list", 0, Target.URILIST }
+ };
+
public string media_dir {get; construct;}
+ void append_thumb (File file) {
+ FileInfo file_info;
+ Pixbuf pixbuf;
+ TreeIter iter;
+
+ try {
+ file_info = file.query_info ("standard::content-type,time::modified",
+ FileQueryInfoFlags.NONE, null);
+ } catch (Error e) {
+ error (e.message);
+ return;
+ }
+
+ TimeVal mtime;
+ file_info.get_modification_time (mtime);
+
+ var uri = file.get_uri();
+ var mime_type = file_info.get_content_type ();
+ var thumb_location = thumbnail_factory.lookup (uri, mtime.tv_sec);
+
+ if (thumb_location == null) {
+ pixbuf = thumbnail_factory.generate_thumbnail (uri, mime_type);
+ if (pixbuf == null) {
+ error ("Could not create thumbnail for %s (%s)", uri, mime_type);
+ return;
+ }
+ thumbnail_factory.save_thumbnail (pixbuf, uri, mtime.tv_sec);
+ } else {
+ pixbuf = new Pixbuf.from_file (thumb_location);
+ if (pixbuf == null) {
+ error ("Could not load thumbnail %s for %s", thumb_location, uri);
+ return;
+ }
+ }
+
+/* eog_thumbnail_add_frame (&pixbuf); */
+ store.append (out iter);
+ store.set (iter, Column.PIXBUF, pixbuf, Column.URL, file.get_path ());
+
+ var path = store.get_path (iter);
+ scroll_to_path (path, true, 1.0f, 0.5f);
+ }
+
+ void remove_thumb (File file) {
+ TreeIter iter;
+ TreeModel model = store;
+ store.get_iter_first (out iter);
+
+ /* check if the selected item is the first, else go through the store */
+ string path;
+ store.get (iter, Column.URL, path);
+
+ var filename = file.get_path ();
+ if (filename != path) {
+ while (store.iter_next (ref iter)) {
+ store.get (iter, Column.URL, path);
+ if (filename == path)
+ break;
+ }
+ }
+ if (store.remove (iter)) {
+ var path = store.get_path (iter);
+ select_path (path);
+ }
+ }
+
+ ArrayList <string> get_all_thumbs () {
+ return null;
+ }
+
+ ArrayList <string> get_selected_thumbs () {
+ return null;
+ }
+
+ void on_file_changed (FileMonitor sender, File file, File other_file, FileMonitorEvent event_type) {
+ switch (event_type) {
+ case FileMonitorEvent.DELETED:
+ remove_thumb (file);
+ break;
+ case FileMonitorEvent.CREATED:
+ append_thumb (file);
+ break;
+ default:
+ break;
+ }
+ }
+
+ void on_drag_data_get (DragContext drag_context, SelectionData data, uint info, uint time) {
+
+ }
+
+ void load_existing_thumbs () {
+ store.clear (); // FIXME: is this necessary
+ try {
+ string name;
+
+ var dir = Dir.open (media_dir);
+ while ((name = dir.read_name ()) != null) {
+ if (name.has_suffix ("jpg") || name.has_suffix ("ogg") || name.has_suffix ("ogv")) {
+ var filename = Path.build_filename (media_dir, name);
+ var file = File.new_for_path (filename);
+ append_thumb (file);
+ }
+ }
+
+ } catch (FileError e) {
+ error (e.message);
+ // FIXME
+ }
+ }
construct {
store = new ListStore (2, typeof (Pixbuf), typeof (string));
set_model (store);
@@ -39,8 +166,18 @@
var dir = File.new_for_path (media_dir);
dir_monitor = FileMonitor.directory (dir, 0, null);
+ dir_monitor.changed += on_file_changed;
set_pixbuf_column (0);
set_columns (int.MAX);
+
+ enable_model_drag_source (ModifierType.BUTTON1_MASK, target_entries, DragAction.COPY);
+ drag_data_get += on_drag_data_get;
+
+ store.set_sort_column_id (Column.URL, SortType.ASCENDING);
+
+ thumbnail_factory = new ThumbnailFactory (ThumbnailSize.NORMAL);
+ // FIXME: move from here
+ load_existing_thumbs ();
}
public ThumbView (string media_dir) {
this.media_dir = media_dir;
Modified: branches/cheese-vala/src/cheese-window.vala
==============================================================================
--- branches/cheese-vala/src/cheese-window.vala (original)
+++ branches/cheese-vala/src/cheese-window.vala Sun Apr 20 00:09:24 2008
@@ -437,10 +437,6 @@
window.destroy += Gtk.main_quit;
-/*
- g_signal_connect (cheese_window->window, "delete_event",
- G_CALLBACK(cheese_window_delete_event_cb), NULL);
-*/
take_picture.clicked += on_action_button;
button_effects.clicked += on_effects_button;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]