public static string GetMimeTypeFromFileData(Gnome.Vfs.Uri uri) { IntPtr raw_ret = gnome_vfs_get_mime_type_from_file_data(uri == null ? IntPtr.Zero : uri.Handle); string ret = GLib.Marshaller.Utf8PtrToString(raw_ret); return(ret); }
public static Gnome.Vfs.Result DirectoryForUriCancellable(Gnome.Vfs.Uri uri, uint perm, Gnome.Vfs.Context context) { int raw_ret = gnome_vfs_make_directory_for_uri_cancellable(uri == null ? IntPtr.Zero : uri.Handle, perm, context == null ? IntPtr.Zero : context.Handle); Gnome.Vfs.Result ret = (Gnome.Vfs.Result)raw_ret; return(ret); }
public static Gnome.Vfs.Result Uri(Gnome.Vfs.Handle handle, Gnome.Vfs.Uri uri, Gnome.Vfs.OpenMode open_mode, bool exclusive, uint perm) { int raw_ret = gnome_vfs_create_uri(handle == null ? IntPtr.Zero : handle.Handle, uri == null ? IntPtr.Zero : uri.Handle, (int)open_mode, exclusive, perm); Gnome.Vfs.Result ret = (Gnome.Vfs.Result)raw_ret; return(ret); }
public static Gnome.Vfs.Result DirectoryForUri(Gnome.Vfs.Uri uri, uint perm) { int raw_ret = gnome_vfs_make_directory_for_uri(uri == null ? IntPtr.Zero : uri.Handle, perm); Gnome.Vfs.Result ret = (Gnome.Vfs.Result)raw_ret; return(ret); }
public static Gnome.Vfs.Result SetFileInfoUri(Gnome.Vfs.Uri uri, Gnome.Vfs.FileInfo info, Gnome.Vfs.SetFileInfoMask mask) { int raw_ret = gnome_vfs_set_file_info_uri(uri == null ? IntPtr.Zero : uri.Handle, info == null ? IntPtr.Zero : info.Handle, (int)mask); Gnome.Vfs.Result ret = (Gnome.Vfs.Result)raw_ret; return(ret); }
public static string GetMimeTypeCommon(Gnome.Vfs.Uri uri) { IntPtr raw_ret = gnome_vfs_get_mime_type_common(uri == null ? IntPtr.Zero : uri.Handle); string ret = GLib.Marshaller.Utf8PtrToString(raw_ret); return(ret); }
public static Gnome.Vfs.Result GetVolumeFreeSpace(Gnome.Vfs.Uri vfs_uri, out long size) { int raw_ret = gnome_vfs_get_volume_free_space(vfs_uri == null ? IntPtr.Zero : vfs_uri.Handle, out size); Gnome.Vfs.Result ret = (Gnome.Vfs.Result)raw_ret; return(ret); }
public static Gnome.Vfs.Result SetFileInfoCancellable(Gnome.Vfs.Uri a, Gnome.Vfs.FileInfo info, Gnome.Vfs.SetFileInfoMask mask, Gnome.Vfs.Context context) { int raw_ret = gnome_vfs_set_file_info_cancellable(a == null ? IntPtr.Zero : a.Handle, info == null ? IntPtr.Zero : info.Handle, (int)mask, context == null ? IntPtr.Zero : context.Handle); Gnome.Vfs.Result ret = (Gnome.Vfs.Result)raw_ret; return(ret); }
public static Gnome.Vfs.Result RemoveDirectoryFromUri(Gnome.Vfs.Uri uri) { int raw_ret = gnome_vfs_remove_directory_from_uri(uri == null ? IntPtr.Zero : uri.Handle); Gnome.Vfs.Result ret = (Gnome.Vfs.Result)raw_ret; return(ret); }
public static Gnome.Vfs.Result UriCancellable(Gnome.Vfs.Uri uri, long length, Gnome.Vfs.Context context) { int raw_ret = gnome_vfs_truncate_uri_cancellable(uri == null ? IntPtr.Zero : uri.Handle, length, context == null ? IntPtr.Zero : context.Handle); Gnome.Vfs.Result ret = (Gnome.Vfs.Result)raw_ret; return(ret); }
public static Gnome.Vfs.Result GetFileInfoUri(Gnome.Vfs.Uri uri, Gnome.Vfs.FileInfo info, Gnome.Vfs.FileInfoOptions options) { int raw_ret = gnome_vfs_get_file_info_uri(uri == null ? IntPtr.Zero : uri.Handle, info == null ? IntPtr.Zero : info.Handle, (int)options); Gnome.Vfs.Result ret = (Gnome.Vfs.Result)raw_ret; return(ret); }
public static Gnome.Vfs.Result SameFsUrisCancellable(Gnome.Vfs.Uri a, Gnome.Vfs.Uri b, out bool same_fs_return, Gnome.Vfs.Context context) { int raw_ret = gnome_vfs_check_same_fs_uris_cancellable(a == null ? IntPtr.Zero : a.Handle, b == null ? IntPtr.Zero : b.Handle, out same_fs_return, context == null ? IntPtr.Zero : context.Handle); Gnome.Vfs.Result ret = (Gnome.Vfs.Result)raw_ret; return(ret); }
public static Gnome.Vfs.Result Uri(Gnome.Vfs.Uri uri, long length) { int raw_ret = gnome_vfs_truncate_uri(uri == null ? IntPtr.Zero : uri.Handle, length); Gnome.Vfs.Result ret = (Gnome.Vfs.Result)raw_ret; return(ret); }
public static Gnome.Vfs.Result UriCancellable(Gnome.Vfs.Handle handle, Gnome.Vfs.Uri uri, Gnome.Vfs.OpenMode open_mode, Gnome.Vfs.Context context) { int raw_ret = gnome_vfs_open_uri_cancellable(handle == null ? IntPtr.Zero : handle.Handle, uri == null ? IntPtr.Zero : uri.Handle, (int)open_mode, context == null ? IntPtr.Zero : context.Handle); Gnome.Vfs.Result ret = (Gnome.Vfs.Result)raw_ret; return(ret); }
public static Gnome.Vfs.Result SameFsUris(Gnome.Vfs.Uri source_uri, Gnome.Vfs.Uri target_uri, out bool same_fs_return) { int raw_ret = gnome_vfs_check_same_fs_uris(source_uri == null ? IntPtr.Zero : source_uri.Handle, target_uri == null ? IntPtr.Zero : target_uri.Handle, out same_fs_return); Gnome.Vfs.Result ret = (Gnome.Vfs.Result)raw_ret; return(ret); }
public static Gnome.Vfs.Result Uri(Gnome.Vfs.Handle handle, Gnome.Vfs.Uri uri, Gnome.Vfs.OpenMode open_mode) { int raw_ret = gnome_vfs_open_uri(handle == null ? IntPtr.Zero : handle.Handle, uri == null ? IntPtr.Zero : uri.Handle, (int)open_mode); Gnome.Vfs.Result ret = (Gnome.Vfs.Result)raw_ret; return(ret); }
public static Gnome.Vfs.Result UriCancellable(Gnome.Vfs.Uri old, Gnome.Vfs.Uri _new, bool force_replace, Gnome.Vfs.Context context) { int raw_ret = gnome_vfs_move_uri_cancellable(old == null ? IntPtr.Zero : old.Handle, _new == null ? IntPtr.Zero : _new.Handle, force_replace, context == null ? IntPtr.Zero : context.Handle); Gnome.Vfs.Result ret = (Gnome.Vfs.Result)raw_ret; return(ret); }
public static Gnome.Vfs.Result Uri(Gnome.Vfs.Uri old_uri, Gnome.Vfs.Uri new_uri, bool force_replace) { int raw_ret = gnome_vfs_move_uri(old_uri == null ? IntPtr.Zero : old_uri.Handle, new_uri == null ? IntPtr.Zero : new_uri.Handle, force_replace); Gnome.Vfs.Result ret = (Gnome.Vfs.Result)raw_ret; return(ret); }
public static Gnome.Vfs.Result GetFileInfoUriCancellable(Gnome.Vfs.Uri uri, Gnome.Vfs.FileInfo info, Gnome.Vfs.FileInfoOptions options, Gnome.Vfs.Context context) { int raw_ret = gnome_vfs_get_file_info_uri_cancellable(uri == null ? IntPtr.Zero : uri.Handle, info == null ? IntPtr.Zero : info.Handle, (int)options, context == null ? IntPtr.Zero : context.Handle); Gnome.Vfs.Result ret = (Gnome.Vfs.Result)raw_ret; return(ret); }
public static Gnome.Vfs.Uri UniqueName(Gnome.Vfs.Uri path, string shortname) #endif { int i = 1; #if GIO_2_16 GLib.File dest = FileFactory.NewForUri(new System.Uri(path, shortname)); #else Gnome.Vfs.Uri target = path.Clone(); Gnome.Vfs.Uri dest = target.AppendFileName(shortname); #endif while (dest.Exists) { string numbered_name = System.String.Format("{0}-{1}{2}", System.IO.Path.GetFileNameWithoutExtension(shortname), i++, System.IO.Path.GetExtension(shortname)); #if GIO_2_16 dest = FileFactory.NewForUri(new System.Uri(path, numbered_name)); #else dest = target.AppendFileName(numbered_name); #endif } return(dest); }
private void UpdateButtonSensitivity() { bool valid = photo_view.Item.IsValid; bool prev = valid && Item.Index > 0; bool next = valid && Item.Index < query.Count - 1; if (valid) { Gnome.Vfs.Uri vfs = new Gnome.Vfs.Uri(photo_view.Item.Current.DefaultVersionUri.ToString()); valid = vfs.Scheme == "file"; } display_previous_button.Sensitive = prev; display_next_button.Sensitive = next; if (valid && has_selection) { tips.SetTip(crop_button, Catalog.GetString("Crop photo to selected area"), String.Empty); tips.SetTip(redeye_button, Catalog.GetString("Remove redeye from selected area"), String.Empty); } else { tips.SetTip(crop_button, Catalog.GetString("Select an area to crop"), null); tips.SetTip(redeye_button, Catalog.GetString("Select an area to remove redeye"), null); } crop_button.Sensitive = valid; redeye_button.Sensitive = valid; color_button.Sensitive = valid; desaturate_button.Sensitive = valid; sepia_button.Sensitive = valid; }
public static Gnome.Vfs.Result FromUri(Gnome.Vfs.Uri uri) { int raw_ret = gnome_vfs_unlink_from_uri(uri == null ? IntPtr.Zero : uri.Handle); Gnome.Vfs.Result ret = (Gnome.Vfs.Result)raw_ret; return(ret); }
public static Gnome.Vfs.Result FromUriCancellable(Gnome.Vfs.Uri uri, Gnome.Vfs.Context context) { int raw_ret = gnome_vfs_unlink_from_uri_cancellable(uri == null ? IntPtr.Zero : uri.Handle, context == null ? IntPtr.Zero : context.Handle); Gnome.Vfs.Result ret = (Gnome.Vfs.Result)raw_ret; return(ret); }
public Gnome.Vfs.Uri Clone() { IntPtr raw_ret = gnome_vfs_uri_dup(Handle); Gnome.Vfs.Uri ret = raw_ret == IntPtr.Zero ? null : (Gnome.Vfs.Uri)GLib.Opaque.GetOpaque(raw_ret, typeof(Gnome.Vfs.Uri), false); return(ret); }
private void InfoLoaded(Gnome.Vfs.Result result, Gnome.Vfs.FileInfo [] info, uint entries_read) { if (result != Gnome.Vfs.Result.Ok && result != Gnome.Vfs.Result.ErrorEof) { return; } ArrayList items = new ArrayList(); for (int i = 0; i < entries_read; i++) { Gnome.Vfs.Uri vfs = new Gnome.Vfs.Uri(uri.ToString()); vfs = vfs.AppendFileName(info [i].Name); Uri file = new Uri(vfs.ToString()); System.Console.WriteLine("tesing uri = {0}", file.ToString()); if (FSpot.ImageFile.HasLoader(file)) { items.Add(new FileBrowsableItem(file)); } } Gtk.Application.Invoke(items, System.EventArgs.Empty, delegate(object sender, EventArgs args) { collection.Add(items.ToArray(typeof(FileBrowsableItem)) as FileBrowsableItem []); }); }
private static string GetExportUrl(ExportItem export) { switch (export.ExportType) { case ExportStore.FlickrExportType: string[] split_token = export.ExportToken.Split(':'); return(String.Format("http://www.{0}/photos/{1}/{2}/", split_token[2], split_token[0], split_token[3])); case ExportStore.FolderExportType: Gnome.Vfs.Uri uri = new Gnome.Vfs.Uri(export.ExportToken); return((uri.HasParent) ? uri.Parent.ToString() : export.ExportToken); case ExportStore.Gallery2ExportType: string[] split_item = export.ExportToken.Split(':'); return(String.Format("{0}:{1}?g2_itemId={2}", split_item[0], split_item[1], split_item[2])); case ExportStore.OldFolderExportType: //This is obsolete and meant to be removed once db reach rev4 case ExportStore.PicasaExportType: case ExportStore.SmugMugExportType: return(export.ExportToken); default: return(null); } }
public bool IsParent(Gnome.Vfs.Uri possible_child, bool recursive) { bool raw_ret = gnome_vfs_uri_is_parent(Handle, possible_child == null ? IntPtr.Zero : possible_child.Handle, recursive); bool ret = raw_ret; return(ret); }
public Gnome.Vfs.Uri AppendFileName(string filename) { IntPtr native_filename = GLib.Marshaller.StringToPtrGStrdup(filename); IntPtr raw_ret = gnome_vfs_uri_append_file_name(Handle, native_filename); Gnome.Vfs.Uri ret = raw_ret == IntPtr.Zero ? null : (Gnome.Vfs.Uri)GLib.Opaque.GetOpaque(raw_ret, typeof(Gnome.Vfs.Uri), false); GLib.Marshaller.Free(native_filename); return(ret); }
public Gnome.Vfs.Uri ResolveRelative(string relative_reference) { IntPtr native_relative_reference = GLib.Marshaller.StringToPtrGStrdup(relative_reference); IntPtr raw_ret = gnome_vfs_uri_resolve_relative(Handle, native_relative_reference); Gnome.Vfs.Uri ret = raw_ret == IntPtr.Zero ? null : (Gnome.Vfs.Uri)GLib.Opaque.GetOpaque(raw_ret, typeof(Gnome.Vfs.Uri), false); GLib.Marshaller.Free(native_relative_reference); return(ret); }
public Gnome.Vfs.Uri AppendPath(string path) { IntPtr native_path = GLib.Marshaller.StringToPtrGStrdup(path); IntPtr raw_ret = gnome_vfs_uri_append_path(Handle, native_path); Gnome.Vfs.Uri ret = raw_ret == IntPtr.Zero ? null : (Gnome.Vfs.Uri)GLib.Opaque.GetOpaque(raw_ret, typeof(Gnome.Vfs.Uri), false); GLib.Marshaller.Free(native_path); return(ret); }
//FIXME: rewrite this as a Filter public static Gnome.Vfs.Uri UniqueName (Gnome.Vfs.Uri path, string shortname) { int i = 1; Gnome.Vfs.Uri target = path.Clone(); Gnome.Vfs.Uri dest = target.AppendFileName(shortname); while (dest.Exists) { string numbered_name = System.String.Format ("{0}-{1}{2}", System.IO.Path.GetFileNameWithoutExtension (shortname), i++, System.IO.Path.GetExtension (shortname)); dest = target.AppendFileName(numbered_name); } return dest; }
//TODO: Allow DnD from outside. Don't now, how to receive the data dropped into the widget... protected virtual void OnTreeviewDocumentsDragDataReceived(object o, Gtk.DragDataReceivedArgs args) { bool success = false; try { // Gtk.Widget source = Gtk.Drag.GetSourceWidget (args.Context); switch (args.Info) { case 0: //uri-list string data = System.Text.Encoding.UTF8.GetString (args.SelectionData.Data); string [] uri_list = Regex.Split (data, "\r\n"); foreach (string u in uri_list) { if (!String.IsNullOrEmpty(u)) { Gnome.Vfs.Uri uri = new Gnome.Vfs.Uri(u); this.AppendFile(uri.Path.Replace("%20", " ")); } } success = true; break; case 1: //row dragged TreeIter sourceIter = new TreeIter(); TreeModel model; Gtk.TreeSelection selection = this.treeviewDocuments.Selection; //int row_pos = 0; if (selection.GetSelected (out model, out sourceIter)) { //TreePath[] paths = selection.GetSelectedRows (out model); //row_pos = paths[0].Indices[0]; } TreePath path; TreeViewDropPosition pos; bool dropInfo = treeviewDocuments.GetDestRowAtPos(args.X, args.Y, out path, out pos); if (dropInfo) { TreeIter iter; DocumentStore.GetIter(out iter, path); if (pos == TreeViewDropPosition.Before || pos == TreeViewDropPosition.IntoOrBefore) { DocumentStore.MoveBefore(sourceIter, iter); } else { DocumentStore.MoveAfter(sourceIter, iter); } } /* else { RemoveDocument(ref sourceIter); } */ success = true; break; } } catch (Exception err) { success = false; System.Console.WriteLine (Catalog.GetString("DragNDrop failed") + ": " + err.Message + "\n" + err.StackTrace ); } Gtk.Drag.Finish (args.Context, success, false, args.Time); }
void UpdateToolbar () { if (browse_button != null) { bool state = view_mode == ModeType.IconView; if (browse_button.Active != state) browse_button.Active = state; } if (edit_button != null) { bool state = view_mode == ModeType.PhotoView; if (edit_button.Active != state) edit_button.Active = state; } if (view_mode == ModeType.PhotoView) { display_previous_button.Visible = true; display_next_button.Visible = true; count_label.Visible = true; bool valid = photo_view.View.Item.IsValid; bool prev = valid && photo_view.View.Item.Index > 0; bool next = valid && photo_view.View.Item.Index < query.Count - 1; if (valid) { Gnome.Vfs.Uri vfs = new Gnome.Vfs.Uri (photo_view.View.Item.Current.DefaultVersionUri.ToString ()); valid = vfs.Scheme == "file"; } display_previous_button.Sensitive = prev; display_next_button.Sensitive = next; if (Query == null) count_label.Text = String.Empty; else // Note for translators: This indicates the current photo is photo {0} of {1} out of photos count_label.Text = String.Format (Catalog.GetString ("{0} of {1}"), Query.Count == 0 ? 0 : photo_view.View.Item.Index + 1, Query.Count == 0 ? 0 : Query.Count); } else { display_previous_button.Visible = false; display_next_button.Visible = false; count_label.Visible = false; } }
public void Transfer () { try { Gnome.Vfs.Result result = Gnome.Vfs.Result.Ok; if (clean) Clean (); foreach (IBrowsableItem photo in selection.Items) { //FIXME need to implement the uniquename as a filter using (Filters.FilterRequest request = new Filters.FilterRequest (photo.DefaultVersionUri)) { if (rotate) new Filters.OrientationFilter ().Convert (request); Gnome.Vfs.Uri source = new Gnome.Vfs.Uri (request.Current.ToString ()); Gnome.Vfs.Uri target = dest.Clone (); target = UniqueName (target, source.ExtractShortName ()); Gnome.Vfs.XferProgressCallback cb = new Gnome.Vfs.XferProgressCallback (Progress); progress_dialog.Message = System.String.Format (Catalog.GetString ("Transferring picture \"{0}\" To CD"), photo.Name); progress_dialog.Fraction = photo_index / (double) selection.Count; progress_dialog.ProgressText = System.String.Format (Catalog.GetString ("{0} of {1}"), photo_index, selection.Count); result = Gnome.Vfs.Xfer.XferUri (source, target, Gnome.Vfs.XferOptions.Default, Gnome.Vfs.XferErrorMode.Abort, Gnome.Vfs.XferOverwriteMode.Replace, cb); } photo_index++; } // FIXME the error dialog here is ugly and needs improvement when strings are not frozen. if (result == Gnome.Vfs.Result.Ok) { progress_dialog.Message = Catalog.GetString ("Done Sending Photos"); progress_dialog.Fraction = 1.0; progress_dialog.ProgressText = Catalog.GetString ("Transfer Complete"); progress_dialog.ButtonLabel = Gtk.Stock.Ok; progress_dialog.Hide (); system ("nautilus-cd-burner"); } else { throw new System.Exception (System.String.Format ("{0}{3}{1}{3}{2}", progress_dialog.Message, Catalog.GetString ("Error While Transferring"), result.ToString (), System.Environment.NewLine)); } } catch (System.Exception e) { progress_dialog.Message = e.ToString (); progress_dialog.ProgressText = Catalog.GetString ("Error Transferring"); return; } Gtk.Application.Invoke (this.Destroy); }
private void UpdateButtonSensitivity () { bool valid = photo_view.Item.IsValid; bool prev = valid && Item.Index > 0; bool next = valid && Item.Index < query.Count - 1; if (valid) { Gnome.Vfs.Uri vfs = new Gnome.Vfs.Uri (photo_view.Item.Current.DefaultVersionUri.ToString ()); valid = vfs.Scheme == "file"; } display_previous_button.Sensitive = prev; display_next_button.Sensitive = next; if (valid && has_selection) { tips.SetTip (crop_button, Catalog.GetString ("Crop photo to selected area"), String.Empty); tips.SetTip (redeye_button, Catalog.GetString ("Remove redeye from selected area"), String.Empty); } else { tips.SetTip (crop_button, Catalog.GetString ("Select an area to crop"), null); tips.SetTip (redeye_button, Catalog.GetString ("Select an area to remove redeye"), null); } crop_button.Sensitive = valid; redeye_button.Sensitive = valid; color_button.Sensitive = valid; desaturate_button.Sensitive = valid; sepia_button.Sensitive = valid; }
void zip () { Gnome.Vfs.Uri dest = new Gnome.Vfs.Uri (uri_chooser.Uri); Crc32 crc = new Crc32 (); string filedest = Gnome.Vfs.Uri.GetLocalPathFromUri (dest.ToString ()) + "/" + filename.Text; Console.WriteLine ("Creating zip file {0}", filedest); ZipOutputStream s = new ZipOutputStream (File.Create(filedest)); if (scale_check.Active) Console.WriteLine ("Scaling to {0}", scale_size.ValueAsInt); ProgressDialog progress_dialog = new ProgressDialog (Catalog.GetString ("Exporting files"), ProgressDialog.CancelButtonType.Stop, photos.Length, zipdiag); //Pack up for (int i = 0; i < photos.Length; i ++) { if (progress_dialog.Update (String.Format (Catalog.GetString ("Preparing photo \"{0}\""), photos[i].Name))) { progress_dialog.Destroy (); return; } string f = null; if (scale_check.Active) { FilterSet filters = new FilterSet (); filters.Add (new JpegFilter ()); filters.Add (new ResizeFilter ((uint) scale_size.ValueAsInt)); FilterRequest freq = new FilterRequest (photos [i].DefaultVersionUri); filters.Convert (freq); f = freq.Current.LocalPath; } else { f = photos [i].DefaultVersionUri.LocalPath; } FileStream fs = File.OpenRead (f); byte [] buffer = new byte [fs.Length]; fs.Read (buffer, 0, buffer.Length); ZipEntry entry = new ZipEntry (photos [i].Name); entry.DateTime = DateTime.Now; entry.Size = fs.Length; fs.Close (); crc.Reset (); crc.Update (buffer); entry.Crc = crc.Value; s.PutNextEntry (entry); s.Write (buffer, 0, buffer.Length); } s.Finish (); s.Close (); if (progress_dialog != null) progress_dialog.Destroy (); }
private void HandleResponse (object sender, Gtk.ResponseArgs args) { if (args.ResponseId != Gtk.ResponseType.Ok) { // FIXME this is to work around a bug in gtk+ where // the filesystem events are still listened to when // a FileChooserButton is destroyed but not finalized // and an event comes in that wants to update the child widgets. Dialog.Destroy (); uri_chooser.Dispose (); uri_chooser = null; return; } dest = new Gnome.Vfs.Uri (uri_chooser.Uri); open = open_check.Active; scale = scale_check.Active; rotate = rotate_check.Active; gallery_name = name_entry.Text; if (description_entry != null) description = description_entry.Text; if (scale) size = size_spin.ValueAsInt; command_thread = new System.Threading.Thread (new System.Threading.ThreadStart (Upload)); command_thread.Name = Catalog.GetString ("Transferring Pictures"); //FIXME: get the files/dirs count in a cleaner way than (* 5 + 2(zip) + 9) // selection * 5 (original, mq, lq, thumbs, comments) // 2: zipfiles // 9: directories + info.txt + .htaccess // this should actually be 1 anyway, because we transfer just one dir progress_dialog = new FSpot.ThreadProgressDialog (command_thread, 1); progress_dialog.Start (); }
/** FAST */ public static Gnome.Vfs.Uri[] StringsToUris(string[] src) { Gnome.Vfs.Vfs.Initialize (); Gnome.Vfs.Uri[] uris = new Gnome.Vfs.Uri[src.Length]; for (int i=0; i<src.Length; i++) uris[i] = new Gnome.Vfs.Uri(src[i]); return uris; }
public void Upload () { // FIXME use mkstemp Gnome.Vfs.Result result = Gnome.Vfs.Result.Ok; try { Dialog.Hide (); Gnome.Vfs.Uri source = new Gnome.Vfs.Uri (Path.Combine (gallery_path, gallery_name)); Gnome.Vfs.Uri target = dest.Clone(); target = target.AppendFileName(source.ExtractShortName ()); if (dest.IsLocal) gallery_path = Gnome.Vfs.Uri.GetLocalPathFromUri (dest.ToString ()); progress_dialog.Message = Catalog.GetString ("Building Gallery"); progress_dialog.Fraction = 0.0; FolderGallery gallery; if (static_radio.Active) { gallery = new HtmlGallery (selection, gallery_path, gallery_name); } else if (original_radio.Active) { gallery = new OriginalGallery (selection, gallery_path, gallery_name); } else { gallery = new FolderGallery (selection, gallery_path, gallery_name); } if (scale) { System.Console.WriteLine ("setting scale to {0}", size); gallery.SetScale (size); } else { System.Console.WriteLine ("Exporting full size image"); } if (rotate) { System.Console.WriteLine ("Exporting rotated image"); gallery.SetRotate(); } gallery.Description = description; gallery.GenerateLayout (); Filters.FilterSet filter_set = new Filters.FilterSet (); if (scale) filter_set.Add (new Filters.ResizeFilter ((uint) size)); else if (rotate) filter_set.Add (new Filters.OrientationFilter ()); filter_set.Add (new Filters.ChmodFilter ()); filter_set.Add (new Filters.UniqueNameFilter (gallery_path)); for (int photo_index = 0; photo_index < selection.Count; photo_index++) { try { progress_dialog.Message = System.String.Format (Catalog.GetString ("Uploading picture \"{0}\""), selection[photo_index].Name); progress_dialog.Fraction = photo_index / (double) selection.Count; gallery.ProcessImage (photo_index, filter_set); progress_dialog.ProgressText = System.String.Format (Catalog.GetString ("{0} of {1}"), photo_index, selection.Count); } catch (Exception e) { progress_dialog.Message = String.Format (Catalog.GetString ("Error uploading picture \"{0}\" to Gallery:{2}{1}"), selection[photo_index].Name, e.Message, Environment.NewLine); progress_dialog.ProgressText = Catalog.GetString ("Error"); if (progress_dialog.PerformRetrySkip ()) photo_index--; } } //create the zip tarballs for original if (gallery is OriginalGallery && (bool)Preferences.Get(Preferences.EXPORT_FOLDER_INCLUDE_TARBALLS)) (gallery as OriginalGallery).CreateZip (); // we've created the structure, now if the destination was local we are done // otherwise we xfer if (!dest.IsLocal) { Console.WriteLine(target); System.Console.WriteLine ("Xfering {0} to {1}", source.ToString (), target.ToString ()); result = Gnome.Vfs.Xfer.XferUri (source, target, Gnome.Vfs.XferOptions.Default, Gnome.Vfs.XferErrorMode.Abort, Gnome.Vfs.XferOverwriteMode.Replace, Progress); } if (result == Gnome.Vfs.Result.Ok) { progress_dialog.Message = Catalog.GetString ("Done Sending Photos"); progress_dialog.Fraction = 1.0; progress_dialog.ProgressText = Catalog.GetString ("Transfer Complete"); progress_dialog.ButtonLabel = Gtk.Stock.Ok; } else { progress_dialog.ProgressText = result.ToString (); progress_dialog.Message = Catalog.GetString ("Error While Transferring"); } if (open) { GnomeUtil.UrlShow (null, target.ToString ()); } // Save these settings for next time Preferences.Set (Preferences.EXPORT_FOLDER_SCALE, scale); Preferences.Set (Preferences.EXPORT_FOLDER_SIZE, size); Preferences.Set (Preferences.EXPORT_FOLDER_OPEN, open); Preferences.Set (Preferences.EXPORT_FOLDER_ROTATE, rotate); Preferences.Set (Preferences.EXPORT_FOLDER_METHOD, static_radio.Active ? "static" : original_radio.Active ? "original" : "folder" ); Preferences.Set (Preferences.EXPORT_FOLDER_URI, uri_chooser.Uri); } catch (System.Exception e) { // Console.WriteLine (e); progress_dialog.Message = e.ToString (); progress_dialog.ProgressText = Catalog.GetString ("Error Transferring"); } finally { // if the destination isn't local then we want to remove the temp directory we // created. if (!dest.IsLocal) System.IO.Directory.Delete (gallery_path, true); Gtk.Application.Invoke (delegate { Dialog.Destroy(); }); } }
private static string GetExportUrl (ExportItem export) { switch (export.ExportType) { case ExportStore.FlickrExportType: string[] split_token = export.ExportToken.Split (':'); return String.Format ("http://www.{0}/photos/{1}/{2}/", split_token[2], split_token[0], split_token[3]); case ExportStore.FolderExportType: Gnome.Vfs.Uri uri = new Gnome.Vfs.Uri (export.ExportToken); return (uri.HasParent) ? uri.Parent.ToString () : export.ExportToken; case ExportStore.Gallery2ExportType: string[] split_item = export.ExportToken.Split (':'); return String.Format ("{0}:{1}?g2_itemId={2}",split_item[0], split_item[1], split_item[2]); case ExportStore.OldFolderExportType: //This is obsolete and meant to be removed once db reach rev4 case ExportStore.PicasaExportType: case ExportStore.SmugMugExportType: return export.ExportToken; default: return null; } }
private void InfoLoaded (Gnome.Vfs.Result result, Gnome.Vfs.FileInfo []info, uint entries_read) { if (result != Gnome.Vfs.Result.Ok && result != Gnome.Vfs.Result.ErrorEof) return; ArrayList items = new ArrayList (); for (int i = 0; i < entries_read; i++) { Gnome.Vfs.Uri vfs = new Gnome.Vfs.Uri (uri.ToString ()); vfs = vfs.AppendFileName (info [i].Name); Uri file = new Uri (vfs.ToString ()); System.Console.WriteLine ("tesing uri = {0}", file.ToString ()); if (FSpot.ImageFile.HasLoader (file)) items.Add (new FileBrowsableItem (file)); } Gtk.Application.Invoke (items, System.EventArgs.Empty, delegate (object sender, EventArgs args) { collection.Add (items.ToArray (typeof (FileBrowsableItem)) as FileBrowsableItem []); }); }
public VfsStream (string text_uri, FileMode mode, bool async) { if (text_uri == null) throw new ArgumentNullException ("uri"); if (text_uri == "") throw new ArgumentNullException ("Uri is empty"); if (mode < FileMode.CreateNew || mode > FileMode.Append) throw new ArgumentOutOfRangeException ("mode"); if (text_uri.IndexOfAny (Path.InvalidPathChars) != -1) throw new ArgumentException ("Uri has invalid chars"); uri = new Gnome.Vfs.Uri (text_uri); if (mode == FileMode.Open && !uri.Exists) throw new FileNotFoundException ("Could not find uri \"" + text_uri + "\"."); if (mode == FileMode.CreateNew) { string dname = uri.ExtractDirname (); if (dname != "" && !new Uri (dname).Exists) throw new DirectoryNotFoundException ("Could not find a part of " + "the path \"" + dname + "\"."); } if (async) { callback = new AsyncCallback (OnAsyncCallback); readCallback = new AsyncReadCallback (OnAsyncReadCallback); writeCallback = new AsyncWriteCallback (OnAsyncWriteCallback); } OpenMode om = OpenMode.None; switch (mode) { case FileMode.CreateNew: case FileMode.Create: case FileMode.Truncate: case FileMode.Append: om = OpenMode.Write; access = FileAccess.Write; break; case FileMode.OpenOrCreate: if (uri.Exists) { om = OpenMode.Read; access = FileAccess.Read; } else { om = OpenMode.Write; access = FileAccess.Write; } break; case FileMode.Open: om = OpenMode.Read; access = FileAccess.Read; break; } /* 644 */ FilePermissions perms = FilePermissions.UserRead | FilePermissions.UserWrite | FilePermissions.GroupRead | FilePermissions.OtherRead; Result result; handle = null; switch (mode) { case FileMode.Append: if (uri.Exists) { if (async) { handle = Async.Open (uri, om, (int)Async.Priority.Default, callback); Wait (); Async.Seek (handle, SeekPosition.End, 0, callback); Wait (); } else { handle = Sync.Open (uri, om); result = Sync.Seek (handle, SeekPosition.End, 0); Vfs.ThrowException (uri, result); } } else { if (async) { handle = Async.Create (uri, om, true, perms, (int)Async.Priority.Default, callback); Wait (); } else { handle = Sync.Create (uri, om, true, perms); } } break; case FileMode.Create: if (uri.Exists) { if (async) { handle = Async.Open (uri, om, (int)Async.Priority.Default, callback); Wait (); } else { handle = Sync.Open (uri, om); result = uri.Truncate (0); Vfs.ThrowException (uri, result); } } else { handle = Sync.Create (uri, om, true, perms); } break; case FileMode.CreateNew: if (uri.Exists) { throw new IOException ("Uri \"" + text_uri + "\" already exists."); } else { if (async) { handle = Async.Create (uri, om, true, perms, (int)Async.Priority.Default, callback); Wait (); } else { handle = Sync.Create (uri, om, true, perms); } } break; case FileMode.Open: if (uri.Exists) { if (async) { handle = Async.Open (uri, om, (int)Async.Priority.Default, callback); Wait (); } else { handle = Sync.Open (uri, om); } } else { throw new FileNotFoundException (text_uri); } break; case FileMode.OpenOrCreate: if (uri.Exists) { if (async) { handle = Async.Open (uri, om, (int)Async.Priority.Default, callback); Wait (); } else { handle = Sync.Open (uri, om); } } else { if (async) { handle = Async.Create (uri, om, true, perms, (int)Async.Priority.Default, callback); Wait (); } else { handle = Sync.Create (uri, om, true, perms); } } break; case FileMode.Truncate: if (uri.Exists) { result = uri.Truncate (0); if (async) { handle = Async.Open (uri, om, (int)Async.Priority.Default, callback); Wait (); } else { handle = Sync.Open (uri, om); Vfs.ThrowException (uri, result); } } else { throw new FileNotFoundException (text_uri); } break; } this.mode = mode; this.canseek = true; this.async = async; }