Esempio n. 1
0
        //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();
            }
        }
Esempio n. 2
0
        //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();
            }
        }
Esempio n. 3
0
        internal static bool ConfirmUserAction (int tracks_to_remove)
        {
            string header = String.Format (
                Catalog.GetPluralString (
                    // singular form unused b/c we know it's > 1, but we still need GetPlural
                    "The sync operation will remove one track from your device.",
                    "The sync operation will remove {0} tracks from your device.",
                    tracks_to_remove),
                tracks_to_remove);
            string message = Catalog.GetString ("Are you sure you want to continue?");

            var md = new HigMessageDialog (
                ServiceManager.Get<GtkElementsService> ().PrimaryWindow,
                DialogFlags.DestroyWithParent, MessageType.Warning,
                ButtonsType.None, header, message
            );
            md.AddButton ("gtk-cancel", ResponseType.No, true);
            md.AddButton (Catalog.GetString ("Remove tracks"), ResponseType.Yes, false);

            bool remove_tracks = false;
            ThreadAssist.BlockingProxyToMain (() => {
                try {
                    if (md.Run () == (int) ResponseType.Yes) {
                        remove_tracks = true;
                    }
                } finally {
                    md.Destroy ();
                }
            });
            return remove_tracks;
        }
Esempio n. 4
0
 public void PopupException(GalleryCommandException e, Gtk.Dialog d)
 {
     Log.DebugFormat ("{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 ();
 }
Esempio n. 5
0
        private void RateLimitedSync ()
        {
            syncing = true;

            bool sync_playlists = false;
            if (dap.SupportsPlaylists) {
                foreach (DapLibrarySync library_sync in library_syncs) {
                    if (library_sync.Library.SupportsPlaylists) {
                        sync_playlists = true;
                        break;
                    }
                }
            }

            if (sync_playlists) {
                dap.RemovePlaylists ();
            }

            foreach (DapLibrarySync library_sync in library_syncs) {
                try {
                    library_sync.Sync ();
                } catch (DapLibrarySync.PossibleUserErrorException e) {

                    string header = String.Format (
                        Catalog.GetPluralString (
                           // singular form unused b/c we know it's > 1, but we still need GetPlural
                           "The sync operation will remove one track from your device.",
                           "The sync operation will remove {0} tracks from your device.",
                           e.TracksToRemove),
                        e.TracksToRemove);
                    string message = Catalog.GetString ("Are you sure you want to continue?");

                    HigMessageDialog md = new HigMessageDialog (
                        ServiceManager.Get<GtkElementsService> ().PrimaryWindow,
                        DialogFlags.DestroyWithParent, MessageType.Warning,
                        ButtonsType.None, header, message
                    );
                    md.AddButton ("gtk-cancel", ResponseType.No, true);
                    md.AddButton (Catalog.GetString ("Remove tracks"), ResponseType.Yes, false);

                    bool remove_tracks = false;
                    ThreadAssist.BlockingProxyToMain (() => {
                        try {
                            if (md.Run () == (int) ResponseType.Yes) {
                                remove_tracks = true;
                            }
                        } finally {
                            md.Destroy ();
                        }
                    });

                    if (remove_tracks) {
                        library_sync.Sync (true);
                    }
                }
            }

            if (sync_playlists) {
                dap.SyncPlaylists ();
            }

            syncing = false;
        }
Esempio n. 6
0
        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);
            }
        }
Esempio n. 7
0
        private void OnMerge (object o, EventArgs a)
        {
            var discs = library.BooksModel.SelectedItems.OrderBy (d => d.Title).ToList ();
            var author = DatabaseArtistInfo.Provider.FetchSingle ((discs[0] as DatabaseAlbumInfo).ArtistId);

            var dialog = new HigMessageDialog (
                ServiceManager.Get<GtkElementsService> ().PrimaryWindow,
                DialogFlags.DestroyWithParent, MessageType.Question, ButtonsType.OkCancel,

                String.Format (Catalog.GetPluralString (
                    "Merge the {0} selected discs into one book?",
                    "Merge the {0} selected discs into one book?",
                    discs.Count), discs.Count),

                Catalog.GetString (
                    "This will ensure the disc numbers are all " + 
                    "set properly, and then set the author and book title for all tracks " +
                    "on all these discs to the values below")
            );

            var table = new SimpleTable<int> ();

            var author_entry = new Entry () { Text = discs[0].ArtistName };
            table.AddRow (0,
                new Label (Catalog.GetString ("Author:")) { Xalign = 0 },
                author_entry
            );

            var trimmings = new char [] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ' ', '-' };
            var title_entry  = new Entry () { Text = discs[0].Title.Trim (trimmings) };
            table.AddRow (1,
                new Label (Catalog.GetString ("Book Title:")) { Xalign = 0 },
                title_entry
            );

            dialog.LabelVBox.PackStart (table, false, false, 0);

            dialog.ShowAll ();
            var response = dialog.Run ();
            string title = title_entry.Text;
            string author_name = author_entry.Text;
            dialog.Destroy ();

            if (response == (int)Gtk.ResponseType.Ok && !String.IsNullOrEmpty (title)) {
                if (author_name != author.Name) {
                    author = DatabaseArtistInfo.FindOrCreate (author_name, null);
                }
                var book = DatabaseAlbumInfo.FindOrCreate (author, title, null, false);

                int disc_num = 1;
                foreach (DatabaseAlbumInfo disc in discs) {
                    // Update the disc num/count field for all tracks on this 'book' (actually just one disc of a book)
                    ServiceManager.DbConnection.Execute (
                        @"UPDATE CoreTracks SET AlbumID = ?, Disc = ?, DiscCount = ?, DateUpdatedStamp = ?
                            WHERE PrimarySourceID = ? AND AlbumID = ?",
                        book.DbId, disc_num++, discs.Count, DateTime.Now,
                        library.DbId, disc.DbId
                    );
                }

                // Update the MetadataHash for all those tracks
                DatabaseTrackInfo.UpdateMetadataHash (
                    book.Title, author.Name,
                    String.Format ("PrimarySourceId = {0} AND AlbumID = {1}", library.DbId, book.DbId)
                );

                library.NotifyTracksChanged ();
            }
        }
Esempio n. 8
0
 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 ();
 }
Esempio n. 9
0
		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);

			// 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 (App.Instance.Organizer.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;
		}
Esempio n. 10
0
        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 (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) {
                        Log.Debug (e.Message);
                        Log.Debug (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.")));
                    Log.Exception (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));
                    Log.Exception (se);
                    md.Run ();
                    md.Destroy ();
                    return;
                }
            }
            add_dialog.Destroy ();
        }
Esempio n. 11
0
 //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();
      }
  }
Esempio n. 12
0
 //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();
      }
 }
Esempio n. 13
0
        private static bool ConfirmRemove (bool delete)
        {
            bool ret = false;
            string header = null;
            string message = null;
            string button_label = null;

            if (delete) {
                header = AddinManager.CurrentLocalizer.GetString (
                    "Are you sure you want to permanently delete the selected items?");
                message = AddinManager.CurrentLocalizer.GetString (
                    "If you delete the selection, it will be permanently lost.");
                button_label = "gtk-delete";
            } else {
                header = AddinManager.CurrentLocalizer.GetString (
                    "Remove selection from Library?");
                message = AddinManager.CurrentLocalizer.GetString (
                    "Are you sure you want to remove the selected items from your Library?");
                button_label = "gtk-remove";
            }

            HigMessageDialog md = new HigMessageDialog (ServiceManager.Get<GtkElementsService> ().PrimaryWindow,
                DialogFlags.DestroyWithParent, delete ? MessageType.Warning : MessageType.Question,
                ButtonsType.None, header, message);
            // Delete from Disk defaults to Cancel and the others to OK/Confirm.
            md.AddButton ("gtk-cancel", ResponseType.No, delete);
            md.AddButton (button_label, ResponseType.Yes, !delete);
            
            try {
                if (md.Run () == (int)ResponseType.Yes) {
                    ret = true;
                }
            } finally {
                md.Destroy ();
            }
            return ret;
        }
Esempio n. 14
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 ();
        }