[cheese/three-point-oh] Added Save As functionality to selected thumbnails
- From: Yuvaraj Pandian <yuvipanda src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese/three-point-oh] Added Save As functionality to selected thumbnails
- Date: Sun, 11 Jul 2010 21:51:56 +0000 (UTC)
commit 17a58c90a693ee829d23411fd56bf67bff62df2f
Author: Yuvaraj Pandian T <yuvipanda gmail com>
Date: Mon Jul 12 03:20:07 2010 +0530
Added Save As functionality to selected thumbnails
Select thumbnail and press Ctrl-S. Popup menu still to be hooked.
Does minimal error handling
src/cheese-window.vala | 54 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 54 insertions(+), 0 deletions(-)
---
diff --git a/src/cheese-window.vala b/src/cheese-window.vala
index 6cb324c..4c7445a 100644
--- a/src/cheese-window.vala
+++ b/src/cheese-window.vala
@@ -130,6 +130,60 @@ public class Cheese.MainWindow : Gtk.Window
}
[CCode (instance_pos = -1)]
+ internal void on_file_save_as (Gtk.Action action)
+ {
+ string filename, basename;
+ FileChooserDialog save_as_dialog;
+ int response;
+
+ filename = thumb_view.get_selected_image ();
+ if (filename == null)
+ return; /* Nothing selected. */
+
+ save_as_dialog = new FileChooserDialog ("Save File",
+ this,
+ Gtk.FileChooserAction.SAVE,
+ Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+ Gtk.STOCK_SAVE, Gtk.ResponseType.ACCEPT,
+ null);
+
+ save_as_dialog.do_overwrite_confirmation = true;
+ basename = GLib.Filename.display_basename (filename);
+ save_as_dialog.set_current_name (basename);
+
+ response = save_as_dialog.run ();
+
+ save_as_dialog.hide ();
+ if (response == Gtk.ResponseType.ACCEPT)
+ {
+ string target_filename;
+ target_filename = save_as_dialog.get_filename ();
+
+ File src = File.new_for_path (filename);
+ File dest = File.new_for_path (target_filename);
+
+ try
+ {
+ src.copy (dest, FileCopyFlags.OVERWRITE, null, null);
+ }
+ catch (Error err)
+ {
+ MessageDialog error_dialog = new MessageDialog (this,
+ Gtk.DialogFlags.MODAL |
+ Gtk.DialogFlags.DESTROY_WITH_PARENT,
+ Gtk.MessageType.ERROR,
+ Gtk.ButtonsType.OK,
+ "Could not save %s",
+ target_filename);
+
+ error_dialog.run ();
+ error_dialog.destroy ();
+ }
+ }
+ save_as_dialog.destroy ();
+ }
+
+ [CCode (instance_pos = -1)]
internal void on_help_contents (Gtk.Action action)
{
Gdk.Screen screen;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]