public void Run(IBrowsableCollection selection) { dialog = new FacebookExportDialog (selection); if (selection.Items.Length > max_photos_per_album) { HigMessageDialog mbox = new HigMessageDialog (dialog, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("Too many images to export"), String.Format (Catalog.GetString ("Facebook only permits {0} photographs per album. Please refine your selection and try again."), max_photos_per_album)); mbox.Run (); mbox.Destroy (); return; } if (dialog.Run () != (int)ResponseType.Ok) { dialog.Destroy (); return; } if (dialog.Account != null) { dialog.Hide (); command_thread = new System.Threading.Thread (new System.Threading.ThreadStart (Upload)); command_thread.Name = Mono.Unix.Catalog.GetString ("Uploading Pictures"); progress_dialog = new ThreadProgressDialog (command_thread, selection.Items.Length); progress_dialog.Start (); } dialog.Destroy (); }
void HandleFileSet (object o, EventArgs e) { try { string tempfilename = System.IO.Path.GetTempFileName (); System.IO.File.Copy (mdd.FileChooser.Filename, tempfilename, true); from_db.Init (tempfilename, true); FillRolls (); mdd.Rolls = new_rolls; mdd.SetSensitive (); } catch (Exception ex) { string msg = Catalog.GetString ("Error opening the selected file"); string desc = String.Format (Catalog.GetString ("The file you selected is not a valid or supported database.\n\nReceived exception \"{0}\"."), ex.Message); HigMessageDialog md = new HigMessageDialog (mdd.Dialog, DialogFlags.DestroyWithParent, Gtk.MessageType.Error, ButtonsType.Ok, msg, desc); md.Run (); md.Destroy (); Log.Exception (ex); } }
private void HandleOkClicked (object sender, EventArgs args) { Photo photo = view.Item.Current as Photo; if (photo == null) return; try { Gdk.Pixbuf orig = view.Pixbuf; Gdk.Pixbuf final = PixbufUtils.UnsharpMask (orig, radius_spin.Value, amount_spin.Value, threshold_spin.Value); bool create_version = photo.DefaultVersion.IsProtected; photo.SaveVersion (final, create_version); } catch (System.Exception e) { string msg = Catalog.GetString ("Error saving sharpened photo"); string desc = String.Format (Catalog.GetString ("Received exception \"{0}\". Unable to save photo {1}"), e.Message, photo.Name); HigMessageDialog md = new HigMessageDialog (this, DialogFlags.DestroyWithParent, Gtk.MessageType.Error, ButtonsType.Ok, msg, desc); md.Run (); md.Destroy (); } Destroy (); }
//run and destroy a standard dialog public static Gtk.ResponseType RunHigMessageDialog(Gtk.Window parent, Gtk.DialogFlags flags, Gtk.MessageType type, Gtk.ButtonsType buttons, string header, string msg) { HigMessageDialog hmd = new HigMessageDialog(parent, flags, type, buttons, header, msg); try { return((Gtk.ResponseType)hmd.Run()); } finally { hmd.Destroy(); } }
//Run and destroy a standard confirmation dialog public static Gtk.ResponseType RunHigConfirmation(Gtk.Window parent, Gtk.DialogFlags flags, Gtk.MessageType type, string header, string msg, string ok_caption) { HigMessageDialog hmd = new HigMessageDialog(parent, flags, type, header, msg, ok_caption); try { return((Gtk.ResponseType)hmd.Run()); } finally { hmd.Destroy(); } }
public void Run (IBrowsableCollection p) { Console.WriteLine ("Executing ZipExport extension"); if (p.Count == 0) { HigMessageDialog md = new HigMessageDialog (MainWindow.Toplevel.Window, DialogFlags.DestroyWithParent, Gtk.MessageType.Error, ButtonsType.Ok, Catalog.GetString ("No selection available"), Catalog.GetString ("This tool requires an active selection. Please select one or more pictures and try again")); md.Run (); md.Destroy (); return; } photos = p.Items; ShowDialog (); }
void CreateTagIconFromExternalPhoto() { try { using (var img = App.Instance.Container.Resolve <IImageFileFactory> ().Create(new Uri(external_photo_chooser.Uri, true))) { using (Gdk.Pixbuf external_image = img.Load()) { PreviewPixbuf = PixbufUtils.TagIconFromPixbuf(external_image); } } } catch (Exception) { string caption = Strings.UnableToLoadImage; string message = string.Format(Strings.UnableToLoadPhotoAsIconForTheTag, external_photo_chooser.Uri); var md = new HigMessageDialog(this, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Close, caption, message); md.Run(); md.Destroy(); } }
void CreateTagIconFromExternalPhoto() { try { using (var img = ImageFile.Create(new SafeUri(external_photo_chooser.Uri, true))) { using (Gdk.Pixbuf external_image = img.Load()) { PreviewPixbuf = PixbufUtils.TagIconFromPixbuf(external_image); } } } catch (Exception) { string caption = Catalog.GetString("Unable to load image"); string message = String.Format(Catalog.GetString("Unable to load \"{0}\" as icon for the tag"), external_photo_chooser.Uri); HigMessageDialog md = new HigMessageDialog(this, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Close, caption, message); md.Run(); md.Destroy(); } }
protected void HandleAddResponse(object sender, Gtk.ResponseArgs args) { if (args.ResponseId == Gtk.ResponseType.Ok) { try { Uri uri = new Uri (url); if (uri.Scheme != Uri.UriSchemeHttp && uri.Scheme != Uri.UriSchemeHttps) throw new System.UriFormatException (); //Check for name uniqueness foreach (GalleryAccount acc in GalleryAccountManager.GetInstance ().GetAccounts ()) if (acc.Name == name) throw new ArgumentException ("name"); GalleryAccount created = new GalleryAccount (name, url, username, password); created.Connect (); GalleryAccountManager.GetInstance ().AddAccount (created); account = created; } catch (System.UriFormatException) { HigMessageDialog md = new HigMessageDialog (add_dialog, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("Invalid URL"), Catalog.GetString ("The gallery URL entry does not appear to be a valid URL")); md.Run (); md.Destroy (); return; } catch (GalleryRemote.GalleryException e) { HigMessageDialog md = new HigMessageDialog (add_dialog, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("Error while connecting to Gallery"), String.Format (Catalog.GetString ("The following error was encountered while attempting to log in: {0}"), e.Message)); if (e.ResponseText != null) { System.Console.WriteLine (e.Message); System.Console.WriteLine (e.ResponseText); } md.Run (); md.Destroy (); return; } catch (ArgumentException ae) { HigMessageDialog md = new HigMessageDialog (add_dialog, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("A Gallery with this name already exists"), String.Format (Catalog.GetString ("There is already a Gallery with the same name in your registered Galleries. Please choose a unique name."))); System.Console.WriteLine (ae); md.Run (); md.Destroy (); return; } catch (System.Net.WebException we) { HigMessageDialog md = new HigMessageDialog (add_dialog, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("Error while connecting to Gallery"), String.Format (Catalog.GetString ("The following error was encountered while attempting to log in: {0}"), we.Message)); md.Run (); md.Destroy (); return; } catch (System.Exception se) { HigMessageDialog md = new HigMessageDialog (add_dialog, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("Error while connecting to Gallery"), String.Format (Catalog.GetString ("The following error was encountered while attempting to log in: {0}"), se.Message)); Console.WriteLine (se); md.Run (); md.Destroy (); return; } } add_dialog.Destroy (); }
protected void HandleAddResponse(object sender, Gtk.ResponseArgs args) { if (args.ResponseId == Gtk.ResponseType.Ok) { if (!System.Text.RegularExpressions.Regex.IsMatch (name, "^[A-Za-z0-9_-]+$")) { HigMessageDialog md = new HigMessageDialog (add_album_dialog, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("Invalid Gallery name"), Catalog.GetString ("The gallery name contains invalid characters.\nOnly letters, numbers, - and _ are allowed")); md.Run (); md.Destroy (); return; } try { gallery.NewAlbum (parent, name, title, description); export.HandleAlbumAdded (title); } catch (GalleryCommandException e) { gallery.PopupException(e, add_album_dialog); return; } } add_album_dialog.Destroy (); }
public void HandleLoginClicked (object sender, EventArgs args) { account = new FacebookAccount(); Uri token = account.CreateToken (); GnomeUtil.UrlShow (token.ToString ()); HigMessageDialog mbox = new HigMessageDialog (Dialog, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, Catalog.GetString ("Waiting for authentication"), Catalog.GetString ("F-Spot will now launch your browser so that you can log into Facebook. Turn on the \"Save my login information\" checkbox on Facebook and F-Spot will log into Facebook automatically from now on.")); mbox.Run (); mbox.Destroy (); if (account.Authenticated == false) { HigMessageDialog error = new HigMessageDialog (Dialog, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("Error logging into Facebook"), Catalog.GetString ("There was a problem logging into Facebook. Check your credentials and try again.")); error.Run (); error.Destroy (); } else { login_button.Visible = false; logout_button.Visible = true; album_info_vbox.Sensitive = true; picture_info_vbox.Sensitive = true; User me = account.Facebook.GetLoggedInUser ().GetUserInfo (); // Note for translators: {0} and {1} are respectively firstname and surname of the user whoami_label.Text = String.Format (Catalog.GetString ("{0} {1} is logged into Facebook"), me.FirstName, me.LastName); Friend[] friend_list = account.Facebook.GetFriends (); long[] uids = new long [friend_list.Length]; for (int i = 0; i < friend_list.Length; i++) uids [i] = friend_list [i].UId; User[] infos = account.Facebook.GetUserInfo (uids, new string[] { "first_name", "last_name" }); friends = new Dictionary<long, User> (); foreach (User user in infos) friends.Add (user.UId, user); Album[] albums = account.Facebook.GetAlbums (); AlbumStore store = new AlbumStore (albums); existing_album_combobox.Model = store; existing_album_combobox.Active = 0; } }
protected void HandleAddResponse (object sender, Gtk.ResponseArgs args) { if (args.ResponseId == Gtk.ResponseType.Ok) { public_album = public_check.Active; try { picasa.CreateAlbum (System.Web.HttpUtility.HtmlEncode (title), description, public_album ? AlbumAccess.Public : AlbumAccess.Private); } catch (System.Exception e) { HigMessageDialog md = new HigMessageDialog (Dialog, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("Error while creating Album"), String.Format (Catalog.GetString ("The following error was encountered while attempting to create an album: {0}"), e.Message)); md.Run (); md.Destroy (); return; } export.HandleAlbumAdded (title); } Dialog.Destroy (); }
private void Login() { try { fr = new FlickrRemote (token, current_service); fr.TryWebLogin(); CurrentState = State.Connected; } catch (FlickrApiException e) { if (e.Code == 98) { Logout (); Login (); } else { HigMessageDialog md = new HigMessageDialog (Dialog, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("Unable to log on"), e.Message); md.Run (); md.Destroy (); CurrentState = State.Disconnected; } } }
private void InfoDialog (string title, string msg, Gtk.MessageType type) { HigMessageDialog md = new HigMessageDialog (MainWindow.Toplevel.Window, DialogFlags.DestroyWithParent, type, ButtonsType.Ok, title, msg); md.Run (); md.Destroy (); }
public void PopupException (GalleryCommandException e, Gtk.Dialog d) { System.Console.WriteLine(String.Format ("{0} : {1} ({2})", e.Message, e.ResponseText, e.Status)); HigMessageDialog md = new HigMessageDialog (d, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("Error while creating new album"), String.Format (Catalog.GetString ("The following error was encountered while attempting to perform the requested operation:\n{0} ({1})"), e.Message, e.Status)); md.Run (); md.Destroy (); }
void CreateTagIconFromExternalPhoto() { try { using (FSpot.ImageFile img = FSpot.ImageFile.Create (new Uri(external_photo_chooser.Uri))) { using (Gdk.Pixbuf external_image = img.Load ()) { PreviewPixbuf = PixbufUtils.TagIconFromPixbuf (external_image); } } } catch (Exception) { string caption = Catalog.GetString ("Unable to load image"); string message = String.Format (Catalog.GetString ("Unable to load \"{0}\" as icon for the tag"), external_photo_chooser.Uri.ToString ()); HigMessageDialog md = new HigMessageDialog (this, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Close, caption, message); md.Run(); md.Destroy(); } }
public void HandleOpenWith(object sender, ApplicationActivatedEventArgs e) { GLib.AppInfo application = e.AppInfo; Photo[] selected = SelectedPhotos (); if (selected == null || selected.Length < 1) return; string header = Catalog.GetPluralString ("Create New Version?", "Create New Versions?", selected.Length); string msg = String.Format (Catalog.GetPluralString ( "Before launching {1}, should F-Spot create a new version of the selected photo to preserve the original?", "Before launching {1}, should F-Spot create new versions of the selected photos to preserve the originals?", selected.Length), selected.Length, application.Name); // FIXME add cancel button? add help button? HigMessageDialog hmd = new HigMessageDialog(GetToplevel (sender), DialogFlags.DestroyWithParent, MessageType.Question, Gtk.ButtonsType.None, header, msg); hmd.AddButton (Gtk.Stock.No, Gtk.ResponseType.No, false); //hmd.AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, false); hmd.AddButton (Gtk.Stock.Yes, Gtk.ResponseType.Yes, true); bool support_xcf = false;; if (application.Id == "gimp.desktop") foreach (Gdk.PixbufFormat format in Gdk.Pixbuf.Formats) if (format.Name == "xcf") support_xcf = true; //This allows creating a version with a .xcf extension. //There's no need to convert the file to xcf file format, gimp will take care of this if (support_xcf) { CheckButton cb = new CheckButton (Catalog.GetString ("XCF version")); cb.Active = Preferences.Get<bool> (Preferences.EDIT_CREATE_XCF_VERSION); hmd.VBox.Add (cb); cb.Toggled += delegate (object s, EventArgs ea) { Preferences.Set (Preferences.EDIT_CREATE_XCF_VERSION, (s as CheckButton).Active); }; cb.Show (); } Gtk.ResponseType response = Gtk.ResponseType.Cancel; try { response = (Gtk.ResponseType) hmd.Run(); } finally { hmd.Destroy (); } bool create_xcf = false; if (support_xcf) create_xcf = Preferences.Get<bool> (Preferences.EDIT_CREATE_XCF_VERSION); Console.WriteLine ("XCF ? {0}", create_xcf); if (response == Gtk.ResponseType.Cancel) return; bool create_new_versions = (response == Gtk.ResponseType.Yes); ArrayList errors = new ArrayList (); GLib.List uri_list = new GLib.List (typeof (string)); foreach (Photo photo in selected) { try { if (create_new_versions) { uint version = photo.CreateNamedVersion (application.Name, create_xcf ? ".xcf" : null, photo.DefaultVersionId, true); photo.DefaultVersionId = version; } } catch (Exception ex) { errors.Add (new EditException (photo, ex)); } uri_list.Append (photo.DefaultVersionUri.ToString ()); } // FIXME need to clean up the error dialog here. if (errors.Count > 0) { Dialog md = new EditExceptionDialog (GetToplevel (sender), errors.ToArray (typeof (EditException)) as EditException []); md.Run (); md.Destroy (); } if (create_new_versions) Database.Photos.Commit (selected); try { application.LaunchUris (uri_list, null); } catch (System.Exception) { Log.Error ("Failed to lauch {0}", application.Name); } }
public void ImportCamera(string camera_device) { Log.Debug ("ImportCamera {0}", camera_device); GPhotoCamera cam = new GPhotoCamera(); try { int num_cameras = cam.DetectCameras(); int selected_cam = 0; if (num_cameras < 1) { HigMessageDialog md = new HigMessageDialog (main_window, DialogFlags.DestroyWithParent, MessageType.Warning, ButtonsType.Ok, Catalog.GetString ("No cameras detected."), Catalog.GetString ("F-Spot was unable to find any cameras attached to this system." + " Double check that the camera is connected and has power")); md.Run (); md.Destroy (); return; } else if (num_cameras == 1) { selected_cam = 0; } else { bool found = false; if (camera_device != null) for (int i = 0; i < num_cameras; i++) { if (camera_device.IndexOf (cam.CameraList.GetValue(i)) != 0) { selected_cam = i; found = true; break; } } if (!found) { FSpot.CameraSelectionDialog camselect = new FSpot.CameraSelectionDialog (cam.CameraList); selected_cam = camselect.Run (); } } if (selected_cam >= 0) { cam.SelectCamera (selected_cam); cam.InitializeCamera (); FSpot.CameraFileSelectionDialog selector = new FSpot.CameraFileSelectionDialog (cam, Database); if (selector.Run() > 0) query.RollSet = new RollSet (Database.Rolls.GetRolls (1)[0]); UpdateQuery (); } } catch (GPhotoException ge) { System.Console.WriteLine (ge.ToString ()); HigMessageDialog md = new HigMessageDialog (main_window, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Ok, Catalog.GetString ("Error connecting to camera"), String.Format (Catalog.GetString ("Received error \"{0}\" while connecting to camera"), ge.Message)); md.Run (); md.Destroy (); } finally { cam.ReleaseGPhotoResources (); } }
public void Run (IBrowsableCollection selection) { CreateDialog (); items = selection.Items; if (items.Length > 60) { HigMessageDialog mbox = new HigMessageDialog (Dialog, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("Too many images to export"), Catalog.GetString ("Facebook only permits 60 photographs per album. Please refine your selection and try again.")); mbox.Run (); mbox.Destroy (); return; } captions = new string [items.Length]; tags = new List<Mono.Facebook.Tag> [items.Length]; thumbnail_iconview = new FSpot.Widgets.IconView (selection); thumbnail_iconview.DisplayDates = false; thumbnail_iconview.DisplayTags = false; thumbnail_iconview.ButtonPressEvent += HandleThumbnailIconViewButtonPressEvent; thumbnail_iconview.KeyPressEvent += HandleThumbnailIconViewKeyPressEvent; thumbnail_iconview.Show (); thumbnails_scrolled_window.Add (thumbnail_iconview); login_button.Visible = true; login_button.Clicked += HandleLoginClicked; logout_button.Visible = false; logout_button.Clicked += HandleLogoutClicked; whoami_label.Text = Catalog.GetString ("You are not logged in."); album_info_vbox.Sensitive = false; picture_info_vbox.Sensitive = false; create_album_radiobutton.Toggled += HandleCreateAlbumToggled; create_album_radiobutton.Active = true; existing_album_radiobutton.Toggled += HandleExistingAlbumToggled; CellRendererText cell = new CellRendererText (); existing_album_combobox.PackStart (cell, false); tag_image_eventbox.ButtonPressEvent += HandleTagImageButtonPressEvent; Dialog.Response += HandleResponse; Dialog.Show (); }
//Run and destroy a standard confirmation dialog public static Gtk.ResponseType RunHigConfirmation(Gtk.Window parent, Gtk.DialogFlags flags, Gtk.MessageType type, string header, string msg, string ok_caption) { HigMessageDialog hmd = new HigMessageDialog(parent, flags, type, header, msg, ok_caption); try { return (Gtk.ResponseType)hmd.Run(); } finally { hmd.Destroy(); } }
//run and destroy a standard dialog public static Gtk.ResponseType RunHigMessageDialog(Gtk.Window parent, Gtk.DialogFlags flags, Gtk.MessageType type, Gtk.ButtonsType buttons, string header, string msg) { HigMessageDialog hmd = new HigMessageDialog(parent, flags, type, buttons, header, msg); try { return (Gtk.ResponseType)hmd.Run(); } finally { hmd.Destroy(); } }
private void Apply(Editor editor) { if (!SetupEditor (editor)) return; if (!editor.CanBeApplied) { string msg = Catalog.GetString ("No selection available"); string desc = Catalog.GetString ("This tool requires an active selection. Please select a region of the photo and try the operation again"); HigMessageDialog md = new HigMessageDialog (MainWindow.Toplevel.Window, DialogFlags.DestroyWithParent, Gtk.MessageType.Error, ButtonsType.Ok, msg, desc); md.Run (); md.Destroy (); return; } // TODO: Might need to do some nicer things for multiple selections (progress?) try { editor.Apply (); } catch (Exception e) { Log.DebugException (e); string msg = Catalog.GetPluralString ("Error saving adjusted photo", "Error saving adjusted photos", editor.State.Items.Length); string desc = String.Format (Catalog.GetString ("Received exception \"{0}\". Note that you have to develop RAW files into JPEG before you can edit them."), e.Message); HigMessageDialog md = new HigMessageDialog (MainWindow.Toplevel.Window, DialogFlags.DestroyWithParent, Gtk.MessageType.Error, ButtonsType.Ok, msg, desc); md.Run (); md.Destroy (); } ShowTools (); }
void DoLogin() { if (!account.Authenticated) { HigMessageDialog error = new HigMessageDialog (this, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("Error logging into Facebook"), Catalog.GetString ("There was a problem logging into Facebook. Check your credentials and try again.")); error.Run (); error.Destroy (); DoLogout (); } else { log_buttons_hbox.Sensitive = false; dialog_action_area.Sensitive = false; LoginProgress (0.0, Catalog.GetString ("Authorizing Session")); ThreadPool.QueueUserWorkItem (delegate { try { bool perm_offline = account.HasPermission("offline_access"); bool perm_upload = photo_perm_check.Active = account.HasPermission("photo_upload"); Gtk.Application.Invoke (delegate { offline_perm_check.Active = perm_offline; photo_perm_check.Active = perm_upload; LoginProgress (0.2, Catalog.GetString ("Session established, fetching user info...")); }); User me = account.Facebook.GetLoggedInUser ().GetUserInfo (); Gtk.Application.Invoke (delegate { LoginProgress (0.4, Catalog.GetString ("Session established, fetching friend list...")); }); Friend[] friend_list = account.Facebook.GetFriends (); long[] uids = new long [friend_list.Length]; for (int i = 0; i < friend_list.Length; i++) uids [i] = friend_list [i].UId; Gtk.Application.Invoke (delegate { LoginProgress (0.6, Catalog.GetString ("Session established, fetching friend details...")); }); User[] infos = account.Facebook.GetUserInfo (uids, new string[] { "first_name", "last_name" }); friends = new Dictionary<long, User> (); foreach (User user in infos) friends.Add (user.UId, user); Gtk.Application.Invoke (delegate { LoginProgress (0.8, Catalog.GetString ("Session established, fetching photo albums...")); }); Album[] albums = account.Facebook.GetAlbums (); Gtk.Application.Invoke (delegate { existing_album_combobox.Model = new AlbumStore (albums); existing_album_combobox.Active = 0; album_info_vbox.Sensitive = true; picture_info_vbox.Sensitive = true; permissions_hbox.Sensitive = true; login_button.Visible = false; logout_button.Visible = true; // Note for translators: {0} and {1} are respectively firstname and surname of the user LoginProgress (1.0, String.Format (Catalog.GetString ("{0} {1} is logged into Facebook"), me.FirstName, me.LastName)); }); } catch (FacebookException fe) { Log.DebugException (fe); Gtk.Application.Invoke (delegate { HigMessageDialog error = new HigMessageDialog (this, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("Facebook Connection Error"), String.Format (Catalog.GetString ("There was an error when downloading your information from Facebook.\n\nFacebook said: {0}"), fe.Message)); error.Run (); error.Destroy (); }); account.Deauthenticate (); DoLogout (); } finally { Gtk.Application.Invoke (delegate { log_buttons_hbox.Sensitive = true; dialog_action_area.Sensitive = true; }); } }); } }
private void ShowError (System.Exception e, Photo photo) { string msg = Catalog.GetString ("Error editing photo"); string desc = String.Format (Catalog.GetString ("Received exception \"{0}\". Unable to save photo {1}"), e.Message, photo.Name); HigMessageDialog md = new HigMessageDialog ((Gtk.Window)this.Toplevel, DialogFlags.DestroyWithParent, Gtk.MessageType.Error, ButtonsType.Ok, msg, desc); md.Run (); md.Destroy (); }
void Upload() { Album album = null; IBrowsableItem [] items = dialog.Items; string [] captions = dialog.Captions; dialog.StoreCaption (); if (dialog.CreateAlbum) { string name = dialog.AlbumName; if (String.IsNullOrEmpty (name)) { HigMessageDialog mbox = new HigMessageDialog (dialog, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("Album must have a name"), Catalog.GetString ("Please name your album or choose an existing album.")); mbox.Run (); mbox.Destroy (); return; } string description = dialog.AlbumDescription; string location = dialog.AlbumLocation; try { album = dialog.Account.Facebook.CreateAlbum (name, description, location); } catch (FacebookException fe) { HigMessageDialog mbox = new HigMessageDialog (dialog, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("Creating a new album failed"), String.Format (Catalog.GetString ("An error occurred creating a new album.\n\n{0}"), fe.Message)); mbox.Run (); mbox.Destroy (); return; } } else { album = dialog.ActiveAlbum; } long sent_bytes = 0; FilterSet filters = new FilterSet (); filters.Add (new JpegFilter ()); filters.Add (new ResizeFilter ((uint) size)); for (int i = 0; i < items.Length; i++) { try { IBrowsableItem item = items [i]; FileInfo file_info; Console.WriteLine ("uploading {0}", i); progress_dialog.Message = String.Format (Catalog.GetString ("Uploading picture \"{0}\" ({1} of {2})"), item.Name, i + 1, items.Length); progress_dialog.ProgressText = string.Empty; progress_dialog.Fraction = i / (double) items.Length; FilterRequest request = new FilterRequest (item.DefaultVersionUri); filters.Convert (request); file_info = new FileInfo (request.Current.LocalPath); album.Upload (captions [i] ?? "", request.Current.LocalPath); sent_bytes += file_info.Length; } catch (Exception e) { progress_dialog.Message = String.Format (Catalog.GetString ("Error Uploading To Facebook: {0}"), e.Message); progress_dialog.ProgressText = Catalog.GetString ("Error"); Console.WriteLine (e); if (progress_dialog.PerformRetrySkip ()) i--; } } progress_dialog.Message = Catalog.GetString ("Done Sending Photos"); progress_dialog.Fraction = 1.0; progress_dialog.ProgressText = Catalog.GetString ("Upload Complete"); progress_dialog.ButtonLabel = Gtk.Stock.Ok; var li = new LinkButton ("http://www.facebook.com/group.php?gid=158960179844&ref=mf", Catalog.GetString ("Visit F-Spot group on Facebook")); progress_dialog.VBoxPackEnd (li); li.ShowAll (); }
private void HandleResponse(object sender, Gtk.ResponseArgs args) { if (args.ResponseId != Gtk.ResponseType.Ok) { if (command_thread != null && command_thread.IsAlive) command_thread.Abort (); Dialog.Destroy (); return; } if (fr.CheckLogin() == null) { do_export_flickr.Sensitive = false; HigMessageDialog md = new HigMessageDialog (Dialog, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("Unable to log on."), string.Format (Catalog.GetString ("F-Spot was unable to log on to {0}. Make sure you have given the authentication using {0} web browser interface."), current_service.Name)); md.Run (); md.Destroy (); return; } fr.ExportTags = tag_check.Active; fr.ExportTagHierarchy = hierarchy_check.Active; fr.ExportIgnoreTopLevel = ignore_top_level_check.Active; open = open_check.Active; scale = scale_check.Active; copy_metadata = !meta_check.Active; is_public = public_radio.Active; is_family = family_check.Active; is_friend = friend_check.Active; if (scale) size = size_spin.ValueAsInt; command_thread = new Thread (new ThreadStart (Upload)); command_thread.Name = Catalog.GetString ("Uploading Pictures"); Dialog.Destroy (); progress_dialog = new ThreadProgressDialog (command_thread, selection.Count); progress_dialog.Start (); // Save these settings for next time Preferences.Set (SCALE_KEY, scale); Preferences.Set (SIZE_KEY, size); Preferences.Set (BROWSER_KEY, open); Preferences.Set (TAGS_KEY, tag_check.Active); Preferences.Set (STRIP_META_KEY, meta_check.Active); Preferences.Set (PUBLIC_KEY, public_radio.Active); Preferences.Set (FAMILY_KEY, family_check.Active); Preferences.Set (FRIENDS_KEY, friend_check.Active); Preferences.Set (TAG_HIERARCHY_KEY, hierarchy_check.Active); Preferences.Set (IGNORE_TOP_LEVEL_KEY, ignore_top_level_check.Active); Preferences.Set (current_service.PreferencePath, fr.Token); }
public bool GrantPermission(string permission, Window parent) { if (facebookSession.HasAppPermission(permission)) return true; Uri uri = facebookSession.GetGrantUri (permission); GtkBeans.Global.ShowUri (parent.Screen, uri.ToString ()); HigMessageDialog mbox = new HigMessageDialog (parent, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, Catalog.GetString ("Waiting for authorization"), Catalog.GetString ("F-Spot will now launch your browser so that you can enable the permission you just selected.\n\nOnce you are directed by Facebook to return to this application, click \"Ok\" below." )); mbox.Run (); mbox.Destroy (); return facebookSession.HasAppPermission(permission); }
private void InfoDialog(string title, string msg, Gtk.MessageType type) { HigMessageDialog md = new HigMessageDialog (App.Instance.Organizer.Window, DialogFlags.DestroyWithParent, type, ButtonsType.Ok, title, msg); md.Run (); md.Destroy (); }
public void HandleTagNameEdited(object sender, EditedArgs args) { args.RetVal = false; TreeIter iter; if (!Model.GetIterFromString (out iter, args.Path)) return; GLib.Value value = new GLib.Value (); Model.GetValue (iter, IdColumn, ref value); uint tag_id = (uint) value; Tag tag = tag_store.Get (tag_id) as Tag; // Ignore if it hasn't changed if (tag.Name == args.NewText) return; // Check that the tag doesn't already exist if (String.Compare (args.NewText, tag.Name, true) != 0 && tag_store.GetTagByName (args.NewText) != null) { HigMessageDialog md = new HigMessageDialog (MainWindow.Toplevel.Window, DialogFlags.DestroyWithParent, MessageType.Warning, ButtonsType.Ok, Catalog.GetString ("Error renaming tag"), Catalog.GetString ("This name is already in use")); md.Run (); md.Destroy (); this.GrabFocus (); return; } tag.Name = args.NewText; tag_store.Commit (tag, true); text_render.Edited -= HandleTagNameEdited; args.RetVal = true; return; }
public void HandleDeleteSelectedTagCommand(object sender, EventArgs args) { Tag [] tags = this.tag_selection_widget.TagHighlight; System.Array.Sort (tags, new TagRemoveComparer ()); //How many pictures are associated to these tags? Db db = MainWindow.Toplevel.Database; FSpot.PhotoQuery count_query = new FSpot.PhotoQuery(db.Photos); count_query.Terms = FSpot.OrTerm.FromTags(tags); int associated_photos = count_query.Count; string header; if (tags.Length == 1) header = String.Format (Catalog.GetString ("Delete tag \"{0}\"?"), tags [0].Name.Replace ("_", "__")); else header = String.Format (Catalog.GetString ("Delete the {0} selected tags?"), tags.Length); header = String.Format (header, tags.Length); string msg = String.Empty; if (associated_photos > 0) { string photodesc = Catalog.GetPluralString ("photo", "photos", associated_photos); msg = String.Format( Catalog.GetPluralString("If you delete this tag, the association with {0} {1} will be lost.", "If you delete these tags, the association with {0} {1} will be lost.", tags.Length), associated_photos, photodesc); } string ok_caption = Catalog.GetPluralString ("_Delete tag", "_Delete tags", tags.Length); if (ResponseType.Ok == HigMessageDialog.RunHigConfirmation(main_window, DialogFlags.DestroyWithParent, MessageType.Warning, header, msg, ok_caption)) { try { db.Photos.Remove (tags); } catch (InvalidTagOperationException e) { System.Console.WriteLine ("this is something or another"); // A Category is not empty. Can not delete it. string error_msg = Catalog.GetString ("Tag is not empty"); string error_desc = String.Format (Catalog.GetString ("Can not delete tags that have tags within them. " + "Please delete tags under \"{0}\" first"), e.Tag.Name.Replace ("_", "__")); HigMessageDialog md = new HigMessageDialog (main_window, DialogFlags.DestroyWithParent, Gtk.MessageType.Error, ButtonsType.Ok, error_msg, error_desc); md.Run (); md.Destroy (); } } }
private void Upload () { Album album = null; if (create_album_radiobutton.Active) { string name = album_name_entry.Text; if (name.Length == 0) { HigMessageDialog mbox = new HigMessageDialog (Dialog, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("Album must have a name"), Catalog.GetString ("Please name your album or choose an existing album.")); mbox.Run (); mbox.Destroy (); return; } string description = album_description_entry.Text; string location = album_location_entry.Text; try { album = account.Facebook.CreateAlbum (name, description, location); } catch (FacebookException fe) { HigMessageDialog mbox = new HigMessageDialog (Dialog, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("Creating a new album failed"), String.Format (Catalog.GetString ("An error occurred creating a new album.\n\n{0}"), fe.Message)); mbox.Run (); mbox.Destroy (); return; } } else { AlbumStore store = (AlbumStore) existing_album_combobox.Model; album = store.Albums [existing_album_combobox.Active]; } long sent_bytes = 0; FilterSet filters = new FilterSet (); filters.Add (new JpegFilter ()); filters.Add (new ResizeFilter ((uint) size)); for (int i = 0; i < items.Length; i++) { try { IBrowsableItem item = items [i]; FileInfo file_info; Console.WriteLine ("uploading {0}", i); progress_dialog.Message = String.Format (Catalog.GetString ("Uploading picture \"{0}\" ({1} of {2})"), item.Name, i + 1, items.Length); progress_dialog.ProgressText = string.Empty; progress_dialog.Fraction = i / (double) items.Length; FilterRequest request = new FilterRequest (item.DefaultVersionUri); filters.Convert (request); file_info = new FileInfo (request.Current.LocalPath); Mono.Facebook.Photo photo = album.Upload (captions [i] ?? "", request.Current.LocalPath); sent_bytes += file_info.Length; } catch (Exception e) { progress_dialog.Message = String.Format (Catalog.GetString ("Error Uploading To Facebook: {0}"), e.Message); progress_dialog.ProgressText = Catalog.GetString ("Error"); Console.WriteLine (e); if (progress_dialog.PerformRetrySkip ()) i--; } } progress_dialog.Message = Catalog.GetString ("Done Sending Photos"); progress_dialog.Fraction = 1.0; progress_dialog.ProgressText = Catalog.GetString ("Upload Complete"); progress_dialog.ButtonLabel = Gtk.Stock.Ok; Dialog.Destroy (); }
private void HandleResponse (object sender, Gtk.ResponseArgs args) { int size = 0; bool UserCancelled = false; bool rotate = true; // Lets remove the mail "create mail" dialog Dialog.Destroy(); if (args.ResponseId != Gtk.ResponseType.Ok) { return; } ProgressDialog progress_dialog = null; progress_dialog = new ProgressDialog (Catalog.GetString ("Preparing email"), ProgressDialog.CancelButtonType.Stop, selection.Count, parent_window); size = GetScaleSize(); // Which size should we scale to. 0 --> Original // evaluate mailto command and define attachment args for cli System.Text.StringBuilder attach_arg = new System.Text.StringBuilder (); switch (Preferences.Get<string> (Preferences.GNOME_MAILTO_COMMAND)) { case "thunderbird %s": case "mozilla-thunderbird %s": case "seamonkey -mail -compose %s": case "icedove %s": attach_arg.Append(","); break; case "kmail %s": attach_arg.Append(" --attach "); break; default: //evolution falls into default, since it supports mailto uri correctly attach_arg.Append("&attach="); break; } rotate = rotate_check.Active; // Should we automatically rotate original photos. Preferences.Set (Preferences.EXPORT_EMAIL_ROTATE, rotate); // Initiate storage for temporary files to be deleted later tmp_paths = new System.Collections.ArrayList(); // Create a tmp directory. tmp_mail_dir = System.IO.Path.GetTempFileName (); // Create a tmp file System.IO.File.Delete (tmp_mail_dir); // Delete above tmp file System.IO.Directory.CreateDirectory (tmp_mail_dir); // Create a directory with above tmp name System.Text.StringBuilder mail_attach = new System.Text.StringBuilder (); FilterSet filters = new FilterSet (); if (size != 0) filters.Add (new ResizeFilter ((uint) size)); else if (rotate) filters.Add (new OrientationFilter ()); filters.Add (new UniqueNameFilter (tmp_mail_dir)); for (int i = 0; i < selection.Count; i++) { Photo photo = selection [i] as Photo; if ( (photo != null) && (!UserCancelled) ) { if (progress_dialog != null) UserCancelled = progress_dialog.Update (String.Format (Catalog.GetString ("Exporting picture \"{0}\""), photo.Name)); if (UserCancelled) break; try { // Prepare a tmp_mail file name FilterRequest request = new FilterRequest (photo.DefaultVersionUri); filters.Convert (request); request.Preserve(request.Current); mail_attach.Append(attach_arg.ToString() + request.Current.ToString ()); // Mark the path for deletion tmp_paths.Add (request.Current.LocalPath); } catch (Exception e) { Console.WriteLine("Error preparing {0}: {1}", selection[photo_index].Name, e.Message); HigMessageDialog md = new HigMessageDialog (parent_window, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Close, Catalog.GetString("Error processing image"), String.Format(Catalog.GetString("An error occured while processing \"{0}\": {1}"), selection[photo_index].Name, e.Message)); md.Run(); md.Destroy(); UserCancelled = true; } } } // foreach if (progress_dialog != null) progress_dialog.Destroy (); // No need to keep this window if (UserCancelled) DeleteTempFile(); else { // Send the mail :) string mail_subject = Catalog.GetString("my photos"); switch (Preferences.Get<string> (Preferences.GNOME_MAILTO_COMMAND)) { // openSuSE case "thunderbird %s": System.Diagnostics.Process.Start("thunderbird", " -compose \"subject=" + mail_subject + ",attachment='" + mail_attach + "'\""); break; case "icedove %s": System.Diagnostics.Process.Start("icedove", " -compose \"subject=" + mail_subject + ",attachment='" + mail_attach + "'\""); break; case "mozilla-thunderbird %s": System.Diagnostics.Process.Start("mozilla-thunderbird", " -compose \"subject=" + mail_subject + ",attachment='" + mail_attach + "'\""); break; case "seamonkey -mail -compose %s": System.Diagnostics.Process.Start("seamonkey", " -mail -compose \"subject=" + mail_subject + ",attachment='" + mail_attach + "'\""); break; case "kmail %s": System.Diagnostics.Process.Start("kmail", " --composer --subject \"" + mail_subject + "\"" + mail_attach); break; default: GnomeUtil.UrlShow ("mailto:?subject=" + System.Web.HttpUtility.UrlEncode(mail_subject) + mail_attach); break; } // Check if we have any temporary files to be deleted if (tmp_paths.Count > 0) { // Fetch timeout value from preferences. In seconds. Needs to be multiplied with 1000 to get msec uint delete_timeout; delete_timeout = (uint) (Preferences.Get<int> (Preferences.EXPORT_EMAIL_DELETE_TIMEOUT_SEC)); delete_timeout = delete_timeout * 1000; // to get milliseconds. // Start a timer and when it occurs, delete the temp files. GLib.Timeout.Add (delete_timeout, new GLib.TimeoutHandler (DeleteTempFile)); } } }
public void HandleLoginClicked(object sender, EventArgs args) { if (!account.Authenticated) { Uri uri = account.GetLoginUri (); GtkBeans.Global.ShowUri (Screen, uri.ToString ()); HigMessageDialog mbox = new HigMessageDialog (this, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, Catalog.GetString ("Waiting for authentication"), Catalog.GetString ("F-Spot will now launch your browser so that you can log into Facebook.\n\nOnce you are directed by Facebook to return to this application, click \"Ok\" below. F-Spot will cache your session in gnome-keyring, if possible, and re-use it on future Facebook exports." )); mbox.Run (); mbox.Destroy (); LoginProgress (0.0, Catalog.GetString ("Authenticating...")); account.Authenticate (); } DoLogin (); }