[cheese/shareable-media] Add sharing videos and pictures support
- From: Patricia Santana Cruz <patriciasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese/shareable-media] Add sharing videos and pictures support
- Date: Thu, 22 Dec 2011 17:02:06 +0000 (UTC)
commit e4bc2b671501a52b0923d326554d3df5f6edc21a
Author: Patricia Santana Cruz <patriciasantanacruz gmail com>
Date: Thu Dec 22 16:56:26 2011 +0000
Add sharing videos and pictures support
Makefile.am | 1 +
data/cheese-actions.ui | 10 ++++++
src/cheese-shareable-media.vala | 41 ++++++++++++++++++++++++
src/cheese-window.vala | 66 +++++++++++++++++++++++++++++++++++++++
4 files changed, 118 insertions(+), 0 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 29c96ab..6b6db65 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -190,6 +190,7 @@ cheese_SOURCES = \
src/cheese-preferences.vala \
src/cheese-window.vala \
src/cheese-main.vala \
+ src/cheese-shareable-media.vala \
src/thumbview/cheese-thumb-view.c \
src/thumbview/cheese-thumbnail.c \
src/thumbview/eog-thumb-nav.c
diff --git a/data/cheese-actions.ui b/data/cheese-actions.ui
index 0ee570a..50d17e9 100644
--- a/data/cheese-actions.ui
+++ b/data/cheese-actions.ui
@@ -64,6 +64,14 @@
<accelerator key="O" modifiers="GDK_CONTROL_MASK"/>
</child>
<child>
+ <object class="GtkAction" id="share">
+ <property name="name">Share</property>
+ <property name="label" translatable="yes">Shareâ</property>
+ <signal name="activate" handler="cheese_main_window_on_files_share"/>
+ </object>
+ <accelerator key="H" modifiers="GDK_CONTROL_MASK"/>
+ </child>
+ <child>
<object class="GtkAction" id="save_as">
<property name="name">SaveAs</property>
<property name="label" translatable="yes">Save _Asâ</property>
@@ -253,6 +261,8 @@
<popup name="thumbnail_popup" id="thumbnail_popup">
<menuitem action="open"/>
<separator/>
+ <menuitem action="share"/>
+ <separator/>
<menuitem action="save_as"/>
<separator/>
<menuitem action="move_to_trash"/>
diff --git a/src/cheese-shareable-media.vala b/src/cheese-shareable-media.vala
new file mode 100644
index 0000000..d1dec06
--- /dev/null
+++ b/src/cheese-shareable-media.vala
@@ -0,0 +1,41 @@
+/* Used for sharing images or videos within different technologies
+ * through nautilus-sendto
+ */
+namespace ShareableMedia {
+ private const string SENDTO_EXEC = "nautilus-sendto";
+
+ public void files_share(Cheese.MainWindow mainWindow, GLib.List<GLib.File> files)
+ {
+ if (mainWindow == null)
+ stdout.printf ("Test: NULL mainWindow\n");
+
+ if (files.length () == 0)
+ return;
+
+ string[] argv = new string[files.length ()+ 1];
+ argv[0] = SENDTO_EXEC;
+
+ for (int i = 0; i < files.length (); i++)
+ {
+ argv[i + 1] = files<GLib.File>.nth (i).data.get_path ();
+ }
+
+ try {
+ mainWindow.set_busy_cursor();
+
+ Pid child_pid;
+ Process.spawn_async(
+ "/",
+ argv,
+ null,
+ SpawnFlags.SEARCH_PATH,
+ null,
+ out child_pid);
+
+ mainWindow.set_normal_cursor();
+ } catch (Error err) {
+ mainWindow.set_normal_cursor();
+ stdout.printf ("Unable to launch nautilus-sendto\n");
+ }
+ }
+}
diff --git a/src/cheese-window.vala b/src/cheese-window.vala
index d262215..46bcdb7 100644
--- a/src/cheese-window.vala
+++ b/src/cheese-window.vala
@@ -71,6 +71,7 @@ public class Cheese.MainWindow : Gtk.Window
private Clutter.Box current_effects_grid;
private int current_effects_page = 0;
+ private int busy_counter = 0;
private ArrayList<Clutter.Box> effects_grids;
private Gtk.Action take_photo_action;
@@ -341,6 +342,20 @@ public class Cheese.MainWindow : Gtk.Window
}
/**
+ * Share the selected file(s) in the thumbview.
+ *
+ * A dialog is shown to the user, where the technology for sharing the
+ * image or video can be selected.
+ *
+ * @param action the action that emitted the signal.
+ */
+ [CCode (instance_pos = -1)]
+ public void on_files_share (Gtk.Action action)
+ {
+ ShareableMedia.files_share(this, thumb_view.get_selected_images_list ());
+ }
+
+ /**
* Save the selected file in the thumbview to an alternate storage location.
*
* A file chooser dialog is shown to the user, asking where the file should
@@ -484,6 +499,56 @@ public class Cheese.MainWindow : Gtk.Window
}
/**
+ * Change cursor form to a watch when Cheese is busy doing a sharing
+ * operation.
+ */
+ public void set_busy_cursor()
+ {
+ if (busy_counter++ > 0)
+ return;
+
+ get_window().set_cursor(new Gdk.Cursor(Gdk.CursorType.WATCH));
+ spin_event_loop(10);
+ }
+
+ /**
+ * Change cursor form back to normal when Cheese is not any longer busy with a
+ * sharing operation.
+ */
+ public void set_normal_cursor()
+ {
+ if (busy_counter <= 0) {
+ busy_counter = 0;
+ return;
+ } else if (--busy_counter > 0) {
+ return;
+ }
+
+ get_window().set_cursor(new Gdk.Cursor(Gdk.CursorType.LEFT_PTR));
+ spin_event_loop(10);
+ }
+
+ // Testing
+ public bool spin_event_loop(int max = -1)
+ {
+ if (max == 0)
+ return true;
+
+ while (Gtk.events_pending())
+ {
+ if (Gtk.main_iteration())
+ return false;
+
+ if (max > 0)
+ {
+ if (--max <= 0)
+ break;
+ }
+ }
+ return true;
+ }
+
+ /**
* Make the media capture mode actions sensitive.
*/
private void enable_mode_change ()
@@ -1255,6 +1320,7 @@ public class Cheese.MainWindow : Gtk.Window
"help_contents",
"about",
"open",
+ "share",
"save_as",
"move_to_trash",
"delete",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]