public RatingFilterDialog(FSpot.PhotoQuery query, Gtk.Window parent_window)
            : base("RatingFilterDialog.ui", "rating_filter_dialog")
        {
            this.query = query;
            this.parent_window = parent_window;
            TransientFor = parent_window;
            DefaultResponse = ResponseType.Ok;
            ok_button.GrabFocus ();

            if (query.RatingRange != null) {
                minrating_value = (int) query.RatingRange.MinRating;
                maxrating_value = (int) query.RatingRange.MaxRating;
            }
            minrating = new Rating (minrating_value);
            maxrating = new Rating (maxrating_value);
            minrating_hbox.PackStart (minrating, false, false, 0);
            maxrating_hbox.PackStart (maxrating, false, false, 0);

            ResponseType response = (ResponseType) Run ();

            if (response == ResponseType.Ok) {
                query.RatingRange = new RatingRange ((uint) minrating.Value, (uint) maxrating.Value);
            }

            Destroy ();
        }
        public QueryWidget(PhotoQuery query, Db db, TagSelectionWidget selector)
        {
            tips.Enable();

            this.query     = query;
            query.Changed += HandleChanged;

            Gtk.HSeparator sep = new Gtk.HSeparator();
            sep.Show();
            this.PackStart(sep, false, false, 0);

            Gtk.HBox hbox = new Gtk.HBox();
            hbox.Show();
            this.PackStart(hbox, false, false, 0);

            label = new Gtk.Label(Catalog.GetString("Find: "));
            label.Show();
            label.Ypad = 9;
            hbox.PackStart(label, false, false, 0);

            untagged         = new Gtk.Label(Catalog.GetString("Untagged photos"));
            untagged.Visible = false;
            hbox.PackStart(untagged, false, false, 0);

            comma_label         = new Gtk.Label(", ");
            comma_label.Visible = false;
            hbox.PackStart(comma_label, false, false, 0);

            rollfilter         = new Gtk.Label(Catalog.GetString("Import roll"));
            rollfilter.Visible = false;
            hbox.PackStart(rollfilter, false, false, 0);

            logic_widget = new LogicWidget(query, db.Tags, selector);
            logic_widget.Show();
            hbox.PackStart(logic_widget, true, true, 0);

            warning_box = new Gtk.HBox();
            warning_box.PackStart(new Gtk.Label(System.String.Empty));

            Gtk.Image warning_image = new Gtk.Image("gtk-info", Gtk.IconSize.Button);
            warning_image.Show();
            warning_box.PackStart(warning_image, false, false, 0);

            clear_button = new Gtk.Button();
            clear_button.Add(new Gtk.Image("gtk-close", Gtk.IconSize.Button));
            clear_button.Clicked += HandleClearButtonClicked;
            clear_button.Relief   = Gtk.ReliefStyle.None;
            hbox.PackEnd(clear_button, false, false, 0);
            tips.SetTip(clear_button, Catalog.GetString("Clear search"), null);

            Gtk.Label warning = new Gtk.Label(Catalog.GetString("No matching photos found"));
            warning_box.PackStart(warning, false, false, 0);
            warning_box.ShowAll();
            warning_box.Spacing = 6;
            warning_box.Visible = false;

            hbox.PackEnd(warning_box, false, false, 0);

            warning_box.Visible = false;
        }
		public QueryWidget (PhotoQuery query, Db db, TagSelectionWidget selector)
		{
			tips.Enable ();

			this.query = query;
			query.Changed += HandleChanged;

			Gtk.HSeparator sep = new Gtk.HSeparator ();
			sep.Show ();
			this.PackStart (sep, false, false, 0);
			
			Gtk.HBox hbox = new Gtk.HBox ();
			hbox.Show ();
			this.PackStart (hbox, false, false, 0);
			
			label = new Gtk.Label (Catalog.GetString ("Find: "));
			label.Show ();
			label.Ypad = 9;
			hbox.PackStart (label, false, false, 0);

			untagged = new Gtk.Label (Catalog.GetString ("Untagged photos"));
			untagged.Visible = false;
			hbox.PackStart (untagged, false, false, 0);

			comma_label = new Gtk.Label (", ");
			comma_label.Visible = false;
			hbox.PackStart (comma_label, false, false, 0);

			rollfilter = new Gtk.Label (Catalog.GetString ("Import roll"));	
			rollfilter.Visible = false;
			hbox.PackStart (rollfilter, false, false, 0);

			logic_widget = new LogicWidget (query, db.Tags, selector);
			logic_widget.Show ();
			hbox.PackStart (logic_widget, true, true, 0);

			warning_box = new Gtk.HBox ();
			warning_box.PackStart (new Gtk.Label (System.String.Empty));
			
			Gtk.Image warning_image = new Gtk.Image ("gtk-info", Gtk.IconSize.Button);
			warning_image.Show ();
			warning_box.PackStart (warning_image, false, false, 0);
			
			clear_button = new Gtk.Button ();
			clear_button.Add (new Gtk.Image ("gtk-close", Gtk.IconSize.Button));
			clear_button.Clicked += HandleClearButtonClicked;
			clear_button.Relief = Gtk.ReliefStyle.None;
			hbox.PackEnd (clear_button, false, false, 0);
			tips.SetTip (clear_button, Catalog.GetString("Clear search"), null);

			Gtk.Label warning = new Gtk.Label (Catalog.GetString ("No matching photos found"));
			warning_box.PackStart (warning, false, false, 0);
			warning_box.ShowAll ();
			warning_box.Spacing = 6;
			warning_box.Visible = false;

			hbox.PackEnd (warning_box, false, false, 0);
			
			warning_box.Visible = false;
		}
Exemple #4
0
        protected GroupAdaptor(PhotoQuery query, bool order_ascending)
        {
            this.order_ascending = order_ascending;
            this.query = query;
            this.query.Changed += HandleQueryChanged;

            Reload ();
        }
Exemple #5
0
        protected GroupAdaptor(PhotoQuery query, bool order_ascending)
        {
            this.order_ascending = order_ascending;
            this.query           = query;
            this.query.Changed  += HandleQueryChanged;

            Reload();
        }
        public FolderQueryWidget(PhotoQuery query)
        {
            folderSet  = new FolderSet();
            this.query = query;

            query.SetCondition(folderSet);

            Drag.DestSet(this, DestDefaults.All, folderQueryWidgetSourceTable, Gdk.DragAction.Copy | Gdk.DragAction.Move);
        }
Exemple #7
0
        private void HandleVersionChanged(InfoBox box, IPhotoVersion version)
        {
            IPhotoVersionable versionable = item.Current as IPhotoVersionable;
            PhotoQuery        q           = item.Collection as PhotoQuery;

            if (versionable != null && q != null)
            {
                versionable.SetDefaultVersion(version);
                q.Commit(item.Index);
            }
        }
        private void HandleVersionIdChanged(InfoBox box, uint version_id)
        {
            Photo      p = item.Current as Photo;
            PhotoQuery q = item.Collection as PhotoQuery;

            if (p != null && q != null)
            {
                p.DefaultVersionId = version_id;
                q.Commit(item.Index);
            }
        }
        public SimpleCalendar(PhotoQuery query)
        {
            this.parent_query     = query;
            parent_query.Changed += ParentChanged;

            this.query          = new PhotoQuery(parent_query.Store);
            this.query.Changed += Changed;

            ParentChanged(parent_query);
            this.Month = System.DateTime.Now;
        }
Exemple #10
0
        public FolderQueryWidget(PhotoQuery query)
        {
            folder_set = new FolderSet ();
            this.query = query;

            query.SetCondition (folder_set);

            Drag.DestSet (this, DestDefaults.All,
                          folder_query_widget_source_table,
                          Gdk.DragAction.Copy | Gdk.DragAction.Move);
        }
		public SimpleCalendar (PhotoQuery query)
		{
			this.parent_query = query;
			parent_query.Changed += ParentChanged;

			this.query = new PhotoQuery (parent_query.Store);
			this.query.Changed += Changed;

			ParentChanged (parent_query);
			this.Month = System.DateTime.Now;
		}
Exemple #12
0
        public void Commit()
        {
            PhotoQuery q = item.Collection as PhotoQuery;

            if (photo != null && q != null)
            {
                photo.DefaultVersionId = version;
                q.Commit(item.Index);
            }
            else
            {
                item.Collection.MarkChanged(item.Index);
            }
        }
Exemple #13
0
        public LogicWidget(PhotoQuery query, TagStore tag_store)
        {
            //SetFlag (WidgetFlags.NoWindow);
            this.query = query;

            CanFocus  = true;
            Sensitive = true;

            Init();

            tag_store.ItemsChanged += HandleTagChanged;
            tag_store.ItemsRemoved += HandleTagDeleted;

            Show();

            logic_widget = this;
        }
        private void HandleDesaturateButtonClicked(object sender, EventArgs args)
        {
            PhotoQuery pq = query as PhotoQuery;

            if (pq == null)
            {
                return;
            }

            try {
                FSpot.Desaturate desaturate = new FSpot.Desaturate((Photo)View.Item.Current);
                desaturate.Pixbuf = View.CompletePixbuf();
                desaturate.Adjust();
                pq.Commit(Item.Index);
            } catch (System.Exception e) {
                ShowError(e, (Photo)View.Item.Current);
            }
        }
Exemple #15
0
        public LogicWidget(PhotoQuery query, TagStore tag_store, TagSelectionWidget selector) : base()
        {
            //SetFlag (WidgetFlags.NoWindow);
            this.query = query;
            this.tag_selection_widget = selector;

            CanFocus  = true;
            Sensitive = true;

            Literal.Tips = tips;

            tips.Enable();

            Init();

            tag_store.ItemsChanged += HandleTagChanged;
            tag_store.ItemsRemoved += HandleTagDeleted;

            Show();

            logic_widget = this;
        }
Exemple #16
0
 public TimeAdaptor(PhotoQuery query)
     : base(query)
 {
 }
Exemple #17
0
        public QueryWidget(PhotoQuery query, Db db) : base(new HBox())
        {
            box             = Child as HBox;
            box.Spacing     = 6;
            box.BorderWidth = 2;

            this.query     = query;
            query.Changed += HandleChanged;

            label = new Gtk.Label(Catalog.GetString("Find: "));
            label.Show();
            label.Ypad = 9;
            box.PackStart(label, false, false, 0);

            untagged         = new Gtk.Label(Catalog.GetString("Untagged photos"));
            untagged.Visible = false;
            box.PackStart(untagged, false, false, 0);

            comma1_label         = new Gtk.Label(", ");
            comma1_label.Visible = false;
            box.PackStart(comma1_label, false, false, 0);

            rated         = new Gtk.Label(Catalog.GetString("Rated photos"));
            rated.Visible = false;
            box.PackStart(rated, false, false, 0);

            comma2_label         = new Gtk.Label(", ");
            comma2_label.Visible = false;
            box.PackStart(comma2_label, false, false, 0);

            // Note for translators: 'Import roll' is no command, it means 'Roll that has been imported'
            rollfilter         = new Gtk.Label(Catalog.GetString("Import roll"));
            rollfilter.Visible = false;
            box.PackStart(rollfilter, false, false, 0);

            folder_query_widget         = new FolderQueryWidget(query);
            folder_query_widget.Visible = false;
            box.PackStart(folder_query_widget, false, false, 0);

            logic_widget = new LogicWidget(query, db.Tags);
            logic_widget.Show();
            box.PackStart(logic_widget, true, true, 0);

            warning_box = new Gtk.HBox();
            warning_box.PackStart(new Gtk.Label(System.String.Empty));

            Gtk.Image warning_image = new Gtk.Image("gtk-info", Gtk.IconSize.Button);
            warning_image.Show();
            warning_box.PackStart(warning_image, false, false, 0);

            clear_button = new Gtk.Button();
            clear_button.Add(new Gtk.Image("gtk-close", Gtk.IconSize.Button));
            clear_button.Clicked    += HandleClearButtonClicked;
            clear_button.Relief      = Gtk.ReliefStyle.None;
            clear_button.TooltipText = Catalog.GetString("Clear search");
            box.PackEnd(clear_button, false, false, 0);

            refresh_button = new Gtk.Button();
            refresh_button.Add(new Gtk.Image("gtk-refresh", Gtk.IconSize.Button));
            refresh_button.Clicked    += HandleRefreshButtonClicked;
            refresh_button.Relief      = Gtk.ReliefStyle.None;
            refresh_button.TooltipText = Catalog.GetString("Refresh search");
            box.PackEnd(refresh_button, false, false, 0);

            Gtk.Label warning = new Gtk.Label(Catalog.GetString("No matching photos found"));
            warning_box.PackStart(warning, false, false, 0);
            warning_box.ShowAll();
            warning_box.Spacing = 6;
            warning_box.Visible = false;

            box.PackEnd(warning_box, false, false, 0);

            warning_box.Visible = false;
        }
		public DirectoryAdaptor (PhotoQuery query)
			: base (query)
		{ }
Exemple #19
0
        public QueryWidget(PhotoQuery query, Db db)
            : base(new HBox())
        {
            box = Child as HBox;
            box.Spacing = 6;
            box.BorderWidth = 2;

            tips.Enable ();

            this.query = query;
            query.Changed += HandleChanged;

            label = new Gtk.Label (Catalog.GetString ("Find: "));
            label.Show ();
            label.Ypad = 9;
            box.PackStart (label, false, false, 0);

            untagged = new Gtk.Label (Catalog.GetString ("Untagged photos"));
            untagged.Visible = false;
            box.PackStart (untagged, false, false, 0);

            comma1_label = new Gtk.Label (", ");
            comma1_label.Visible = false;
            box.PackStart (comma1_label, false, false, 0);

            rated = new Gtk.Label (Catalog.GetString ("Rated photos"));
            rated.Visible = false;
            box.PackStart (rated, false, false, 0);

            comma2_label = new Gtk.Label (", ");
            comma2_label.Visible = false;
            box.PackStart (comma2_label, false, false, 0);

            // Note for translators: 'Import roll' is no command, it means 'Roll that has been imported'
            rollfilter = new Gtk.Label (Catalog.GetString ("Import roll"));
            rollfilter.Visible = false;
            box.PackStart (rollfilter, false, false, 0);

            folder_query_widget = new FolderQueryWidget (query);
            folder_query_widget.Visible = false;
            box.PackStart (folder_query_widget, false, false, 0);

            logic_widget = new LogicWidget (query, db.Tags);
            logic_widget.Show ();
            box.PackStart (logic_widget, true, true, 0);

            warning_box = new Gtk.HBox ();
            warning_box.PackStart (new Gtk.Label (System.String.Empty));

            Gtk.Image warning_image = new Gtk.Image ("gtk-info", Gtk.IconSize.Button);
            warning_image.Show ();
            warning_box.PackStart (warning_image, false, false, 0);

            clear_button = new Gtk.Button ();
            clear_button.Add (new Gtk.Image ("gtk-close", Gtk.IconSize.Button));
            clear_button.Clicked += HandleClearButtonClicked;
            clear_button.Relief = Gtk.ReliefStyle.None;
            box.PackEnd (clear_button, false, false, 0);
            tips.SetTip (clear_button, Catalog.GetString("Clear search"), null);

            refresh_button = new Gtk.Button ();
            refresh_button.Add (new Gtk.Image ("gtk-refresh", Gtk.IconSize.Button));
            refresh_button.Clicked += HandleRefreshButtonClicked;
            refresh_button.Relief = Gtk.ReliefStyle.None;
            box.PackEnd (refresh_button, false, false, 0);
            tips.SetTip (refresh_button, Catalog.GetString("Refresh search"), null);

            Gtk.Label warning = new Gtk.Label (Catalog.GetString ("No matching photos found"));
            warning_box.PackStart (warning, false, false, 0);
            warning_box.ShowAll ();
            warning_box.Spacing = 6;
            warning_box.Visible = false;

            box.PackEnd (warning_box, false, false, 0);

            warning_box.Visible = false;
        }
Exemple #20
0
 public PhotoLoader(PhotoQuery query)
 {
     this.query = query;
 }
Exemple #21
0
 public TimeAdaptor(PhotoQuery query, bool order_ascending)
     : base(query, order_ascending)
 {
 }
Exemple #22
0
 public DirectoryAdaptor(PhotoQuery query)
     : base(query)
 {
 }
Exemple #23
0
        void create_mosaics()
        {
            //Prepare the query
            Db db = App.Instance.Database;

            FSpot.PhotoQuery mini_query = new FSpot.PhotoQuery(db.Photos);
            Photo []         photos;

            if (tags_radio.Active)
            {
                //Build tag array
                List <Tag> taglist = new List <Tag> ();
                foreach (string tag_name in miniatures_tags.GetTypedTagNames())
                {
                    Tag t = db.Tags.GetTagByName(tag_name);
                    if (t != null)
                    {
                        taglist.Add(t);
                    }
                }
                mini_query.Terms = FSpot.OrTerm.FromTags(taglist.ToArray());
                photos           = mini_query.Photos;
            }
            else
            {
                photos = App.Instance.Organizer.Query.Photos;
            }

            if (photos.Length == 0)
            {
                //There is no photo for the selected tags! :(
                InfoDialog(Catalog.GetString("No photos for the selection"),
                           Catalog.GetString("The tags selected provided no pictures. Please select different tags"),
                           Gtk.MessageType.Error);
                return;
            }

            //Create minis
            ProgressDialog progress_dialog = null;

            progress_dialog = new ProgressDialog(Catalog.GetString("Creating miniatures"),
                                                 ProgressDialog.CancelButtonType.Stop,
                                                 photos.Length, metapixel_dialog);

            minidir_tmp = System.IO.Path.GetTempFileName();
            System.IO.File.Delete(minidir_tmp);
            System.IO.Directory.CreateDirectory(minidir_tmp);
            minidir_tmp += "/";

            //Call MetaPixel to create the minis
            foreach (Photo p in photos)
            {
                if (progress_dialog.Update(String.Format(Catalog.GetString("Preparing photo \"{0}\""), p.Name)))
                {
                    progress_dialog.Destroy();
                    DeleteTmp();
                    return;
                }
                //FIXME should switch to retry/skip
                if (!GLib.FileFactory.NewForUri(p.DefaultVersion.Uri).Exists)
                {
                    Log.WarningFormat(String.Format("Couldn't access photo {0} while creating miniatures", p.DefaultVersion.Uri.LocalPath));
                    continue;
                }
                //FIXME Check if the picture's format is supproted (jpg, gif)

                FilterSet filters = new FilterSet();
                filters.Add(new JpegFilter());
                FilterRequest freq = new FilterRequest(p.DefaultVersion.Uri);
                filters.Convert(freq);

                //We use photo id for minis, instead of photo names, to avoid duplicates
                string minifile        = minidir_tmp + p.Id.ToString() + System.IO.Path.GetExtension(p.DefaultVersion.Uri.ToString());
                string prepare_command = String.Format("--prepare -w {0} -h {1} {2} {3} {4}tables.mxt",
                                                       icon_x_size.Text,                         //Minis width
                                                       icon_y_size.Text,                         //Minis height
                                                       GLib.Shell.Quote(freq.Current.LocalPath), //Source image
                                                       GLib.Shell.Quote(minifile),               //Dest image
                                                       minidir_tmp);                             //Table file
                Log.Debug("Executing: metapixel " + prepare_command);

                System.Diagnostics.Process mp_prep = System.Diagnostics.Process.Start("metapixel", prepare_command);
                mp_prep.WaitForExit();
                if (!System.IO.File.Exists(minifile))
                {
                    Log.DebugFormat("No mini? No party! {0}", minifile);
                    continue;
                }
            }             //Finished preparing!
            if (progress_dialog != null)
            {
                progress_dialog.Destroy();
            }

            progress_dialog = null;
            progress_dialog = new ProgressDialog(Catalog.GetString("Creating photomosaics"),
                                                 ProgressDialog.CancelButtonType.Stop,
                                                 App.Instance.Organizer.SelectedPhotos().Length, metapixel_dialog);

            //Now create the mosaics!
            uint error_count = 0;

            foreach (Photo p in App.Instance.Organizer.SelectedPhotos())
            {
                if (progress_dialog.Update(String.Format(Catalog.GetString("Processing \"{0}\""), p.Name)))
                {
                    progress_dialog.Destroy();
                    DeleteTmp();
                    return;
                }
                //FIXME should switch to retry/skip
                if (!GLib.FileFactory.NewForUri(p.DefaultVersion.Uri).Exists)
                {
                    Log.WarningFormat(String.Format("Couldn't access photo {0} while creating mosaics", p.DefaultVersion.Uri.LocalPath));
                    error_count++;
                    continue;
                }

                //FIXME Check if the picture's format is supproted (jpg, gif)

                FilterSet filters = new FilterSet();
                filters.Add(new JpegFilter());
                FilterRequest freq = new FilterRequest(p.DefaultVersion.Uri);
                filters.Convert(freq);

                string     name   = GetVersionName(p);
                System.Uri mosaic = GetUriForVersionName(p, name);

                string mosaic_command = String.Format("--metapixel -l {0} {1} {2}",
                                                      minidir_tmp,
                                                      GLib.Shell.Quote(freq.Current.LocalPath),
                                                      GLib.Shell.Quote(mosaic.LocalPath));
                Log.Debug("Executing: metapixel " + mosaic_command);
                System.Diagnostics.Process mp_exe = System.Diagnostics.Process.Start("metapixel", mosaic_command);
                mp_exe.WaitForExit();
                if (!GLib.FileFactory.NewForUri(mosaic).Exists)
                {
                    Log.Warning("Error in processing image " + p.Name);
                    error_count++;
                    continue;
                }

                p.DefaultVersionId    = p.AddVersion(mosaic, name, true);
                p.Changes.DataChanged = true;
                Core.Database.Photos.Commit(p);
            }             //Finished creating mosaics
            if (progress_dialog != null)
            {
                progress_dialog.Destroy();
            }


            string final_message = "Your mosaics have been generated as new versions of the pictures you selected";

            if (error_count > 0)
            {
                final_message += String.Format(".\n{0} images out of {1} had errors",
                                               error_count, App.Instance.Organizer.SelectedPhotos().Length);
            }
            InfoDialog(Catalog.GetString("PhotoMosaics generated!"),
                       Catalog.GetString(final_message),
                       (error_count == 0 ? Gtk.MessageType.Info : Gtk.MessageType.Warning));
            DeleteTmp();
        }
		void DoMerge (PhotoQuery query, Roll [] rolls, bool copy)
		{
			tag_map = new Dictionary<uint, Tag> ();
			roll_map = new Dictionary<uint, uint> ();

			Log.Warning ("Merging tags");
			MergeTags (from_db.Tags.RootCategory);

			Log.Warning ("Creating the rolls");
			CreateRolls (rolls);

			Log.Warning ("Importing photos");
			ImportPhotos (query, copy);

		}
		void HandleResponse (object obj, ResponseArgs args) {
			if (args.ResponseId == ResponseType.Accept) {
				PhotoQuery query = new PhotoQuery (from_db.Photos);
				query.RollSet = mdd.ActiveRolls == null ? null : new RollSet (mdd.ActiveRolls);
				DoMerge (query, mdd.ActiveRolls, mdd.Copy);
			}
			mdd.Dialog.Destroy ();
		}
		public bool Execute (Tag t)
		{
			this.CreateDialog ("edit_icon_dialog");

			this.Dialog.Title = String.Format (Catalog.GetString ("Edit Icon for Tag {0}"), t.Name);

			PreviewPixbuf = t.Icon;

			query = new FSpot.PhotoQuery (db.Photos);
			
			if (db.Tags.Hidden != null)
				query.Terms = FSpot.OrTerm.FromTags (new Tag []{ t, db.Tags.Hidden });
			else 
				query.Terms = new FSpot.Literal (t);

			image_view = new FSpot.PhotoImageView (query);
			image_view.SelectionXyRatio = 1.0;
			image_view.SelectionChanged += HandleSelectionChanged;
			image_view.PhotoChanged += HandlePhotoChanged;

                        external_photo_chooser = new Gtk.FileChooserButton (Catalog.GetString ("Select Photo from file"),
                                                                 Gtk.FileChooserAction.Open);

			external_photo_chooser.Filter = new FileFilter();
			external_photo_chooser.Filter.AddPixbufFormats();
                        external_photo_chooser.LocalOnly = false;
                        external_photo_chooser_hbox.PackStart (external_photo_chooser);

    			Dialog.ShowAll ();
			external_photo_chooser.SelectionChanged += HandleExternalFileSelectionChanged;

			photo_scrolled_window.Add (image_view);

			if (query.Count > 0) {
				photo_spin_button.Wrap = true;
				photo_spin_button.Adjustment.Lower = 1.0;
				photo_spin_button.Adjustment.Upper = (double) query.Count;
				photo_spin_button.Adjustment.StepIncrement = 1.0;
				photo_spin_button.ValueChanged += HandleSpinButtonChanged;
				
				image_view.Item.Index = 0;
			} else {
				from_photo_label.Markup = String.Format (Catalog.GetString (
					"\n<b>From Photo</b>\n" +
					" You can use one of your library photos as an icon for this tag.\n" +
					" However, first you must have at least one photo associated\n" +
					" with this tag. Please tag a photo as '{0}' and return here\n" +
					" to use it as an icon."), t.Name); 
				photo_scrolled_window.Visible = false;
				photo_label.Visible = false;
				photo_spin_button.Visible = false;
			}			

			icon_store = new ListStore (typeof (string), typeof (Gdk.Pixbuf));

			icon_view = new Gtk.IconView (icon_store); 
			icon_view.PixbufColumn = 1;
			icon_view.SelectionMode = SelectionMode.Single;
			icon_view.SelectionChanged += HandleIconSelectionChanged;

			icon_scrolled_window.Add (icon_view);

			icon_view.Show();

			image_view.Show ();

			FSpot.Delay fill_delay = new FSpot.Delay (FillIconView);
			fill_delay.Start ();

			ResponseType response = (ResponseType) this.Dialog.Run ();
			bool success = false;

			if (response == ResponseType.Ok) {
				try {
					if (IconName != null) {
						t.ThemeIconName = IconName;
					} else {
						t.ThemeIconName = null;
						t.Icon = PreviewPixbuf_WithoutProfile;
					}
					//db.Tags.Commit (t);
					success = true;
				} catch (Exception ex) {
					// FIXME error dialog.
					Console.WriteLine ("error {0}", ex);
				}
			} else if (response == (ResponseType) (1)) {
				t.Icon = null;
				success = true;
			}
			
			this.Dialog.Destroy ();
			return success;
		}
	//
	// Constructor
	//
	public MainWindow (Db db)
	{
		this.db = db;

		if (Toplevel == null)
			Toplevel = this;

		Glade.XML gui = new Glade.XML (null, "f-spot.glade", "main_window", null);
		gui.Autoconnect (this);

		LoadPreference (Preferences.MAIN_WINDOW_WIDTH);
		LoadPreference (Preferences.MAIN_WINDOW_X);
		LoadPreference (Preferences.MAIN_WINDOW_MAXIMIZED);
		main_window.ShowAll ();

		LoadPreference (Preferences.SIDEBAR_POSITION);
		LoadPreference (Preferences.METADATA_EMBED_IN_IMAGE);
		
		slide_delay = new FSpot.Delay (new GLib.IdleHandler (SlideShow));
		
		toolbar = new Gtk.Toolbar ();
		toolbar_vbox.PackStart (toolbar);
	
		Widget import_button = GtkUtil.MakeToolbarButton (toolbar, "gtk-add", Catalog.GetString ("Import"), new System.EventHandler (HandleImportCommand));
		SetTip (import_button, Catalog.GetString ("Import photos"));
		toolbar.AppendSpace ();

		rl_button = GtkUtil.MakeToolbarButton (toolbar, "f-spot-rotate-270", new System.EventHandler (HandleRotate270Command));
		rr_button = GtkUtil.MakeToolbarButton (toolbar, "f-spot-rotate-90", new System.EventHandler (HandleRotate90Command));
		toolbar.AppendSpace ();
		
		// FIXME putting these two toggle buttons in a radio group would prevent
		// the two toggle sounds from being emitted every time you switch modes
		browse_button = GtkUtil.MakeToolbarToggleButton (toolbar, "f-spot-browse", 
								 new System.EventHandler (HandleToggleViewBrowse)) as ToggleButton;
		SetTip (browse_button, Catalog.GetString ("Browse many photos simultaneously"));
		edit_button = GtkUtil.MakeToolbarToggleButton (toolbar, "f-spot-edit-image", 
							       new System.EventHandler (HandleToggleViewPhoto)) as ToggleButton;
		SetTip (edit_button, Catalog.GetString ("View and edit a photo"));

		toolbar.AppendSpace ();

		Widget fs_button = GtkUtil.MakeToolbarButton (toolbar, "f-spot-fullscreen", new System.EventHandler (HandleViewFullscreen));
		SetTip (fs_button, Catalog.GetString ("View photos fullscreen"));
		
		Widget ss_button = GtkUtil.MakeToolbarButton (toolbar, "f-spot-slideshow", new System.EventHandler (HandleViewSlideShow));
		SetTip (ss_button, Catalog.GetString ("View photos in a slideshow"));

		tag_selection_widget = new TagSelectionWidget (db.Tags);
		tag_selection_scrolled.Add (tag_selection_widget);
		
		tag_selection_widget.Selection.Changed += HandleTagSelectionChanged;
		tag_selection_widget.DragDataGet += HandleTagSelectionDragDataGet;
		tag_selection_widget.DragDrop += HandleTagSelectionDragDrop;
		tag_selection_widget.DragBegin += HandleTagSelectionDragBegin;
		tag_selection_widget.KeyPressEvent += HandleTagSelectionKeyPress;
		Gtk.Drag.SourceSet (tag_selection_widget, Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask,
				    tag_target_table, DragAction.Copy | DragAction.Move);

		tag_selection_widget.DragDataReceived += HandleTagSelectionDragDataReceived;
		tag_selection_widget.DragMotion += HandleTagSelectionDragMotion;
		Gtk.Drag.DestSet (tag_selection_widget, DestDefaults.All, tag_dest_target_table, 
				  DragAction.Copy | DragAction.Move ); 

		tag_selection_widget.ButtonPressEvent += HandleTagSelectionButtonPressEvent;
		tag_selection_widget.PopupMenu += HandleTagSelectionPopupMenu;
		tag_selection_widget.RowActivated += HandleTagSelectionRowActivated;
		
		LoadPreference (Preferences.TAG_ICON_SIZE);

		info_box = new InfoBox ();
		info_box.VersionIdChanged += HandleInfoBoxVersionIdChange;
		left_vbox.PackStart (info_box, false, true, 0);
		
		try {
			query = new FSpot.PhotoQuery (db.Photos);
		} catch (System.Exception e) {
			//FIXME assume any exception here is due to a corrupt db and handle that.
			RestoreDb (e);
			query = new FSpot.PhotoQuery (db.Photos);
		}

		UpdateStatusLabel ();
		query.Changed += HandleQueryChanged;

		db.Photos.ItemsChanged += HandleDbItemsChanged;
		db.Tags.ItemsChanged += HandleTagsChanged;
		db.Tags.ItemsAdded += HandleTagsChanged;
		db.Tags.ItemsRemoved += HandleTagsChanged;
#if SHOW_CALENDAR
		FSpot.SimpleCalendar cal = new FSpot.SimpleCalendar (query);
		cal.DaySelected += HandleCalendarDaySelected;
		left_vbox.PackStart (cal, false, true, 0);
#endif

		group_selector = new FSpot.GroupSelector ();
		group_selector.Adaptor = new FSpot.TimeAdaptor (query);

		group_selector.ShowAll ();
		
		if (zoom_scale != null) {
			zoom_scale.ValueChanged += HandleZoomScaleValueChanged;
		}

		view_vbox.PackStart (group_selector, false, false, 0);
		view_vbox.ReorderChild (group_selector, 0);

		find_bar = new FindBar (query, tag_selection_widget.Model);
		//find_bar = new FindBar (query, db.Tags);
		view_vbox.PackStart (find_bar, false, false, 0);
		main_window.KeyPressEvent += HandleKeyPressEvent;
		
		query_widget = new FSpot.QueryWidget (query, db, tag_selection_widget);
		query_widget.Logic.Changed += HandleQueryLogicChanged;
		view_vbox.PackStart (query_widget, false, false, 0);
		view_vbox.ReorderChild (query_widget, 1);

		icon_view = new QueryView (query);
		icon_view.ZoomChanged += HandleZoomChanged;
		LoadPreference (Preferences.ZOOM);
		LoadPreference (Preferences.SHOW_TAGS);
		LoadPreference (Preferences.SHOW_DATES);
		icon_view_scrolled.Add (icon_view);
		icon_view.DoubleClicked += HandleDoubleClicked;
		icon_view.Vadjustment.ValueChanged += HandleIconViewScroll;
		icon_view.GrabFocus ();

		new FSpot.PreviewPopup (icon_view);

		Gtk.Drag.SourceSet (icon_view, Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask,
				    icon_source_target_table, DragAction.Copy | DragAction.Move);
		
		icon_view.DragBegin += HandleIconViewDragBegin;
		icon_view.DragDataGet += HandleIconViewDragDataGet;

		near_image.SetFromStock ("f-spot-stock_near", IconSize.SmallToolbar);
		far_image.SetFromStock ("f-spot-stock_far", IconSize.SmallToolbar);

		PhotoTagMenu pmenu = new PhotoTagMenu ();
		pmenu.TagSelected += HandleRemoveTagMenuSelected;
		remove_tag.Submenu = pmenu;
		
		Gtk.Drag.DestSet (icon_view, DestDefaults.All, icon_dest_target_table, 
				  DragAction.Copy | DragAction.Move); 

		//		icon_view.DragLeave += new DragLeaveHandler (HandleIconViewDragLeave);
		icon_view.DragMotion += HandleIconViewDragMotion;
		icon_view.DragDrop += HandleIconViewDragDrop;
		icon_view.DragDataReceived += HandleIconViewDragDataReceived;
		icon_view.KeyPressEvent += HandleIconViewKeyPressEvent;

		photo_view = new PhotoView (query);
		photo_box.Add (photo_view);

		photo_view.ButtonPressEvent += HandlePhotoViewButtonPressEvent;
		photo_view.KeyPressEvent += HandlePhotoViewKeyPressEvent;
		photo_view.UpdateStarted += HandlePhotoViewUpdateStarted;
		photo_view.UpdateFinished += HandlePhotoViewUpdateFinished;

		photo_view.View.ZoomChanged += HandleZoomChanged;

		// Tag typing: focus the tag entry if the user starts typing a tag
		icon_view.KeyPressEvent += HandlePossibleTagTyping;
		photo_view.KeyPressEvent += HandlePossibleTagTyping;
		tag_entry = new TagEntry (db.Tags);
		tag_entry.KeyPressEvent += HandleTagEntryKeyPressEvent;
		tag_entry.TagsAttached += HandleTagEntryTagsAttached;
		tag_entry.TagsRemoved += HandleTagEntryRemoveTags;
		tag_entry.Activated += HandleTagEntryActivate;
		tag_entry_container.Add (tag_entry);

		Gtk.Drag.DestSet (photo_view, DestDefaults.All, tag_target_table, 
				  DragAction.Copy | DragAction.Move); 

		photo_view.DragMotion += HandlePhotoViewDragMotion;
		photo_view.DragDrop += HandlePhotoViewDragDrop;
		photo_view.DragDataReceived += HandlePhotoViewDragDataReceived;

		view_notebook.SwitchPage += HandleViewNotebookSwitchPage;
		group_selector.Adaptor.GlassSet += HandleAdaptorGlassSet;
		group_selector.Adaptor.Changed += HandleAdaptorChanged;
		LoadPreference (Preferences.GROUP_ADAPTOR);
		LoadPreference (Preferences.GROUP_ADAPTOR_ORDER_ASC);

		this.selection = new MainSelection (this);
		this.selection.Changed += HandleSelectionChanged;
		this.selection.ItemsChanged += HandleSelectionItemsChanged;

		UpdateMenus ();

		main_window.ShowAll ();

		tagbar.Hide ();
		find_bar.Hide ();

		UpdateFindByTagMenu ();

		LoadPreference (Preferences.SHOW_TOOLBAR);
		LoadPreference (Preferences.SHOW_SIDEBAR);
		LoadPreference (Preferences.SHOW_TIMELINE);
		
		Preferences.SettingChanged += OnPreferencesChanged;

		main_window.DeleteEvent += HandleDeleteEvent;
		
		query_widget.HandleChanged (query);
		query_widget.Hide ();

		// When the icon_view is loaded, set it's initial scroll position
		icon_view.SizeAllocated += HandleIconViewReady;

		export.Activated += HandleExportActivated;
		UpdateToolbar ();

		Banshee.Kernel.Scheduler.Resume ();
	}
		public bool Execute (Tag t)
		{
			this.CreateDialog ("edit_icon_dialog");

			this.Dialog.Title = String.Format (Catalog.GetString ("Edit Icon for Tag {0}"), t.Name);

			preview_image.Pixbuf = t.Icon;

			query = new FSpot.PhotoQuery (db.Photos);
			
			if (db.Tags.Hidden != null)
				query.Terms = FSpot.Query.OrTerm.FromTags (new Tag []{ t, db.Tags.Hidden });
			else 
				query.Terms = new FSpot.Query.Literal (t);

			image_view = new FSpot.PhotoImageView (query);
			image_view.SelectionXyRatio = 1.0;
			image_view.SelectionChanged += HandleSelectionChanged;
			image_view.PhotoChanged += HandlePhotoChanged;

			photo_scrolled_window.Add (image_view);

			if (query.Photos.Length > 0) {
				photo_spin_button.Wrap = true;
				photo_spin_button.Adjustment.Lower = 1.0;
				photo_spin_button.Adjustment.Upper = (double)query.Photos.Length;
				photo_spin_button.Adjustment.StepIncrement = 1.0;
				photo_spin_button.ValueChanged += HandleSpinButtonChanged;
				
				image_view.Item.Index = 0;
			} else {
				photo_spin_button.Sensitive = false;
				photo_spin_button.Value = 0.0;
			}			
			
			
			// FIXME this path choosing method is completely wrong/broken/evil it needs to be
			// based on real data but I want to get this release out.
			string theme_dir = System.IO.Path.Combine (FSpot.Defines.GNOME_ICON_THEME_PREFIX,
								   "share/icons/gnome/48x48/emblems");
			if (System.IO.Directory.Exists (theme_dir))
				icon_view = new IconView (new FSpot.DirectoryCollection (theme_dir));
			else if (System.IO.Directory.Exists ("/opt/gnome/share/icons/gnome/48x48/emblems"))
				icon_view = new IconView (new FSpot.DirectoryCollection ("/opt/gnome/share/icons/gnome/48x48/emblems"));
			else if (System.IO.Directory.Exists ("/usr/share/icons/gnome/48x48/emblems"))
				icon_view = new IconView (new FSpot.DirectoryCollection ("/usr/share/icons/gnome/48x48/emblems"));
			else // This will just load an empty collection if the directory doesn't exist.
				icon_view = new IconView (new FSpot.DirectoryCollection ("/usr/local/share/icons/gnome/48x48/emblems"));

			icon_scrolled_window.Add (icon_view);
			icon_view.ThumbnailWidth = 32;
			icon_view.DisplayTags = false;
			icon_view.DisplayDates = false;
			icon_view.Selection.Changed += HandleIconViewSelectionChanged;
			icon_view.Show();

			image_view.Show ();

			ResponseType response = (ResponseType) this.Dialog.Run ();
			bool success = false;

			if (response == ResponseType.Ok) {
				try {
					t.Icon = preview_image.Pixbuf;
					//db.Tags.Commit (t);
					success = true;
				} catch (Exception ex) {
					// FIXME error dialog.
					Console.WriteLine ("error {0}", ex);
				}
			}
			
			this.Dialog.Destroy ();
			return success;
		}
Exemple #29
0
        public bool Execute(Tag t)
        {
            this.CreateDialog("edit_icon_dialog");

            this.Dialog.Title = String.Format(Catalog.GetString("Edit Icon for Tag {0}"), t.Name);

            preview_image.Pixbuf = t.Icon;

            query = new FSpot.PhotoQuery(db.Photos);

            if (db.Tags.Hidden != null)
            {
                query.Terms = FSpot.Query.OrTerm.FromTags(new Tag [] { t, db.Tags.Hidden });
            }
            else
            {
                query.Terms = new FSpot.Query.Literal(t);
            }

            image_view = new FSpot.PhotoImageView(query);
            image_view.SelectionXyRatio  = 1.0;
            image_view.SelectionChanged += HandleSelectionChanged;
            image_view.PhotoChanged     += HandlePhotoChanged;

            photo_scrolled_window.Add(image_view);

            if (query.Photos.Length > 0)
            {
                photo_spin_button.Wrap                     = true;
                photo_spin_button.Adjustment.Lower         = 1.0;
                photo_spin_button.Adjustment.Upper         = (double)query.Photos.Length;
                photo_spin_button.Adjustment.StepIncrement = 1.0;
                photo_spin_button.ValueChanged            += HandleSpinButtonChanged;

                image_view.Item.Index = 0;
            }
            else
            {
                photo_spin_button.Sensitive = false;
                photo_spin_button.Value     = 0.0;
            }


            // FIXME this path choosing method is completely wrong/broken/evil it needs to be
            // based on real data but I want to get this release out.
            string theme_dir = System.IO.Path.Combine(FSpot.Defines.GNOME_ICON_THEME_PREFIX,
                                                      "share/icons/gnome/48x48/emblems");

            if (System.IO.Directory.Exists(theme_dir))
            {
                icon_view = new IconView(new FSpot.DirectoryCollection(theme_dir));
            }
            else if (System.IO.Directory.Exists("/opt/gnome/share/icons/gnome/48x48/emblems"))
            {
                icon_view = new IconView(new FSpot.DirectoryCollection("/opt/gnome/share/icons/gnome/48x48/emblems"));
            }
            else if (System.IO.Directory.Exists("/usr/share/icons/gnome/48x48/emblems"))
            {
                icon_view = new IconView(new FSpot.DirectoryCollection("/usr/share/icons/gnome/48x48/emblems"));
            }
            else             // This will just load an empty collection if the directory doesn't exist.
            {
                icon_view = new IconView(new FSpot.DirectoryCollection("/usr/local/share/icons/gnome/48x48/emblems"));
            }

            icon_scrolled_window.Add(icon_view);
            icon_view.ThumbnailWidth     = 32;
            icon_view.DisplayTags        = false;
            icon_view.DisplayDates       = false;
            icon_view.Selection.Changed += HandleIconViewSelectionChanged;
            icon_view.Show();

            image_view.Show();

            ResponseType response = (ResponseType)this.Dialog.Run();
            bool         success  = false;

            if (response == ResponseType.Ok)
            {
                try {
                    t.Icon = preview_image.Pixbuf;
                    //db.Tags.Commit (t);
                    success = true;
                } catch (Exception ex) {
                    // FIXME error dialog.
                    Console.WriteLine("error {0}", ex);
                }
            }

            this.Dialog.Destroy();
            return(success);
        }
Exemple #30
0
        //
        // Constructor
        //
        public MainWindow(Db db)
        {
            foreach (ServiceNode service in AddinManager.GetExtensionNodes ("/FSpot/Services")) {
                try {
                    service.Initialize ();
                    service.Start ();
                } catch (Exception e) {
                    Log.Warning ("Something went wrong while starting the {0} extension.", service.Id);
                    Log.DebugException (e);
                }
            }

            #if GSD_2_24
            Log.Information ("Hack for gnome-settings-daemon engaged");
            int max_age, max_size;
            if (Preferences.TryGet<int> (Preferences.GSD_THUMBS_MAX_AGE, out max_age)) {
                if (max_age < 0)
                    Log.Debug ("maximum_age check already disabled, good");
                else if (max_age == 0)
                    Log.Warning ("maximum_age is 0 (tin-hat mode), not overriding");
                else if (max_age < 180) {
                    Log.Debug ("Setting maximum_age to a saner value");
                    Preferences.Set (Preferences.GSD_THUMBS_MAX_AGE, 180);
                }
            }

            if (Preferences.TryGet<int> (Preferences.GSD_THUMBS_MAX_SIZE, out max_size)) {
                int count = App.Instance.Database.Photos.Count ("photos");
                // average thumbs are taking 70K, so this will push the threshold
                //if f-spot takes more than 70% of the thumbs space
                int size = count / 10;
                if (max_size < 0)
                    Log.Debug ("maximum_size check already disabled, good");
                else if (max_size == 0)
                    Log.Warning ("maximum_size is 0 (tin-hat mode), not overriding");
                else if (max_size < size) {
                    Log.Debug ("Setting maximum_size to a saner value ({0}MB), according to your db size", size);
                    Preferences.Set (Preferences.GSD_THUMBS_MAX_SIZE, size);
                }
            }

            #endif
            Database = db;

            if (Toplevel == null)
                Toplevel = this;

            GtkBeans.Builder builder = new GtkBeans.Builder ("main_window.ui");
            builder.Autoconnect (this);

            //Set the global DefaultColormap. Allows transparency according
            //to the theme (work on murrine engine)
            Gdk.Colormap colormap = ((Widget)main_window).Screen.RgbaColormap;
            if (colormap == null) {
                Log.Debug ("Your screen doesn't support alpha channels!");
                colormap = ((Widget)main_window).Screen.RgbColormap;
            }
            Gtk.Widget.DefaultColormap = colormap;

            LoadPreference (Preferences.MAIN_WINDOW_WIDTH);
            LoadPreference (Preferences.MAIN_WINDOW_X);
            LoadPreference (Preferences.MAIN_WINDOW_MAXIMIZED);
            main_window.ShowAll ();

            LoadPreference (Preferences.SIDEBAR_POSITION);
            LoadPreference (Preferences.METADATA_EMBED_IN_IMAGE);

            pagesetup_menu_item.Activated += HandlePageSetupActivated;

            toolbar = new Gtk.Toolbar ();
            toolbar_vbox.PackStart (toolbar);

            ToolButton import_button = GtkUtil.ToolButtonFromTheme ("gtk-add", Catalog.GetString ("Import"), true);
            import_button.Clicked += HandleImportCommand;
            import_button.SetTooltip (ToolTips, Catalog.GetString ("Import new images"), null);
            toolbar.Insert (import_button, -1);

            toolbar.Insert (new SeparatorToolItem (), -1);

            rl_button = GtkUtil.ToolButtonFromTheme ("object-rotate-left", Catalog.GetString ("Rotate Left"), false);
            rl_button.Clicked += HandleRotate270Command;
            toolbar.Insert (rl_button, -1);

            rr_button = GtkUtil.ToolButtonFromTheme ("object-rotate-right", Catalog.GetString ("Rotate Right"), false);
            rr_button.Clicked += HandleRotate90Command;
            toolbar.Insert (rr_button, -1);

            toolbar.Insert (new SeparatorToolItem (), -1);

            browse_button = new ToggleToolButton ();
            browse_button.Label = Catalog.GetString ("Browse");
            browse_button.IconName = "mode-browse";
            browse_button.IsImportant = true;
            browse_button.Toggled += HandleToggleViewBrowse;
            browse_button.SetTooltip (ToolTips, Catalog.GetString ("Browse many photos simultaneously"), null);
            toolbar.Insert (browse_button, -1);

            edit_button = new ToggleToolButton ();
            edit_button.Label = Catalog.GetString ("Edit Image");
            edit_button.IconName = "mode-image-edit";
            edit_button.IsImportant = true;
            edit_button.Toggled += HandleToggleViewPhoto;
            edit_button.SetTooltip (ToolTips, Catalog.GetString ("View and edit a photo"), null);
            toolbar.Insert (edit_button, -1);

            toolbar.Insert (new SeparatorToolItem (), -1);

            ToolButton fs_button = GtkUtil.ToolButtonFromTheme ("view-fullscreen", Catalog.GetString ("Fullscreen"), false);
            fs_button.Clicked += HandleViewFullscreen;
            fs_button.SetTooltip (ToolTips, Catalog.GetString ("View photos fullscreen"), null);
            toolbar.Insert (fs_button, -1);

            ToolButton ss_button = GtkUtil.ToolButtonFromTheme ("media-playback-start", Catalog.GetString ("Slideshow"), false);
            ss_button.Clicked += HandleViewSlideShow;
            ss_button.SetTooltip (ToolTips, Catalog.GetString ("View photos in a slideshow"), null);
            toolbar.Insert (ss_button, -1);

            SeparatorToolItem white_space = new SeparatorToolItem ();
            white_space.Draw = false;
            white_space.Expand = true;
            toolbar.Insert (white_space, -1);

            ToolItem label_item = new ToolItem ();
            count_label = new Label (String.Empty);
            label_item.Child = count_label;
            toolbar.Insert (label_item, -1);

            display_previous_button = new ToolButton (Stock.GoBack);
            toolbar.Insert (display_previous_button, -1);
            display_previous_button.SetTooltip (ToolTips, Catalog.GetString ("Previous photo"), String.Empty);
            display_previous_button.Clicked += new EventHandler (HandleDisplayPreviousButtonClicked);

            display_next_button = new ToolButton (Stock.GoForward);
            toolbar.Insert (display_next_button, -1);
            display_next_button.SetTooltip (ToolTips, Catalog.GetString ("Next photo"), String.Empty);
            display_next_button.Clicked += new EventHandler (HandleDisplayNextButtonClicked);

            Sidebar = new Sidebar ();
            ViewModeChanged += Sidebar.HandleMainWindowViewModeChanged;
            sidebar_vbox.Add (Sidebar);

            tag_selection_scrolled = new ScrolledWindow ();
            tag_selection_scrolled.ShadowType = ShadowType.In;

            tag_selection_widget = new TagSelectionWidget (Database.Tags);
            tag_selection_scrolled.Add (tag_selection_widget);

            Sidebar.AppendPage (tag_selection_scrolled, Catalog.GetString ("Tags"), "tag");

            AddinManager.AddExtensionNodeHandler ("/FSpot/Sidebar", OnSidebarExtensionChanged);

            Sidebar.Context = ViewContext.Library;

            Sidebar.CloseRequested += HideSidebar;
            Sidebar.Show ();

            InfoBox = new InfoBox ();
            ViewModeChanged += InfoBox.HandleMainWindowViewModeChanged;
            InfoBox.VersionIdChanged += delegate (InfoBox box, uint version_id) { UpdateForVersionIdChange (version_id);};
            sidebar_vbox.PackEnd (InfoBox, false, false, 0);

            InfoBox.Context = ViewContext.Library;

            tag_selection_widget.Selection.Changed += HandleTagSelectionChanged;
            tag_selection_widget.KeyPressEvent += HandleTagSelectionKeyPress;
            tag_selection_widget.ButtonPressEvent += HandleTagSelectionButtonPressEvent;
            tag_selection_widget.PopupMenu += HandleTagSelectionPopupMenu;
            tag_selection_widget.RowActivated += HandleTagSelectionRowActivated;

            LoadPreference (Preferences.TAG_ICON_SIZE);

            try {
                query = new FSpot.PhotoQuery (Database.Photos);
            } catch (System.Exception e) {
                //FIXME assume any exception here is due to a corrupt db and handle that.
                new RepairDbDialog (e, Database.Repair (), main_window);
                query = new FSpot.PhotoQuery (Database.Photos);
            }

            UpdateStatusLabel ();
            query.Changed += HandleQueryChanged;

            Database.Photos.ItemsChanged += HandleDbItemsChanged;
            Database.Tags.ItemsChanged += HandleTagsChanged;
            Database.Tags.ItemsAdded += HandleTagsChanged;
            Database.Tags.ItemsRemoved += HandleTagsChanged;
            #if SHOW_CALENDAR
            FSpot.SimpleCalendar cal = new FSpot.SimpleCalendar (query);
            cal.DaySelected += HandleCalendarDaySelected;
            left_vbox.PackStart (cal, false, true, 0);
            #endif

            group_selector = new FSpot.GroupSelector ();
            group_selector.Adaptor = new FSpot.TimeAdaptor (query, Preferences.Get<bool> (Preferences.GROUP_ADAPTOR_ORDER_ASC));

            group_selector.ShowAll ();

            if (zoom_scale != null) {
                zoom_scale.ValueChanged += HandleZoomScaleValueChanged;
            }

            view_vbox.PackStart (group_selector, false, false, 0);
            view_vbox.ReorderChild (group_selector, 0);

            find_bar = new FindBar (query, tag_selection_widget.Model);
            view_vbox.PackStart (find_bar, false, false, 0);
            view_vbox.ReorderChild (find_bar, 1);
            main_window.KeyPressEvent += HandleKeyPressEvent;

            query_widget = new FSpot.QueryWidget (query, Database);
            query_widget.Logic.Changed += HandleQueryLogicChanged;
            view_vbox.PackStart (query_widget, false, false, 0);
            view_vbox.ReorderChild (query_widget, 2);

            icon_view = new QueryView (query);
            icon_view.ZoomChanged += HandleZoomChanged;
            LoadPreference (Preferences.ZOOM);
            LoadPreference (Preferences.SHOW_TAGS);
            LoadPreference (Preferences.SHOW_DATES);
            LoadPreference (Preferences.SHOW_RATINGS);
            icon_view_scrolled.Add (icon_view);
            icon_view.DoubleClicked += HandleDoubleClicked;
            icon_view.Vadjustment.ValueChanged += HandleIconViewScroll;
            icon_view.GrabFocus ();

            new FSpot.PreviewPopup (icon_view);

            Gtk.Drag.SourceSet (icon_view, Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask,
                        icon_source_target_table, DragAction.Copy | DragAction.Move);

            icon_view.DragBegin += HandleIconViewDragBegin;
            icon_view.DragDataGet += HandleIconViewDragDataGet;

            TagMenu tag_menu = new TagMenu (null, Database.Tags);
            tag_menu.NewTagHandler += delegate { HandleCreateTagAndAttach (this, null); };
            tag_menu.TagSelected += HandleAttachTagMenuSelected;
            tag_menu.Populate();
            (uimanager.GetWidget("/ui/menubar1/edit2/attach_tag") as MenuItem).Submenu = tag_menu;

            PhotoTagMenu pmenu = new PhotoTagMenu ();
            pmenu.TagSelected += HandleRemoveTagMenuSelected;
            (uimanager.GetWidget("/ui/menubar1/edit2/remove_tag") as MenuItem).Submenu = pmenu;

            Gtk.Drag.DestSet (icon_view, DestDefaults.All, icon_dest_target_table,
                      DragAction.Copy | DragAction.Move);

            //		icon_view.DragLeave += new DragLeaveHandler (HandleIconViewDragLeave);
            icon_view.DragMotion += HandleIconViewDragMotion;
            icon_view.DragDrop += HandleIconViewDragDrop;
            icon_view.DragDataReceived += HandleIconViewDragDataReceived;
            icon_view.KeyPressEvent += HandleIconViewKeyPressEvent;

            photo_view = new PhotoView (query);
            photo_box.Add (photo_view);

            photo_view.DoubleClicked += HandleDoubleClicked;
            photo_view.KeyPressEvent += HandlePhotoViewKeyPressEvent;
            photo_view.UpdateStarted += HandlePhotoViewUpdateStarted;
            photo_view.UpdateFinished += HandlePhotoViewUpdateFinished;

            photo_view.View.ZoomChanged += HandleZoomChanged;

            // Tag typing: focus the tag entry if the user starts typing a tag
            icon_view.KeyPressEvent += HandlePossibleTagTyping;
            photo_view.KeyPressEvent += HandlePossibleTagTyping;
            tag_entry = new TagEntry (Database.Tags);
            tag_entry.KeyPressEvent += HandleTagEntryKeyPressEvent;
            tag_entry.TagsAttached += HandleTagEntryTagsAttached;
            tag_entry.TagsRemoved += HandleTagEntryRemoveTags;
            tag_entry.Activated += HandleTagEntryActivate;
            tag_entry_container.Add (tag_entry);

            Gtk.Drag.DestSet (photo_view, DestDefaults.All, tag_target_table,
                      DragAction.Copy | DragAction.Move);

            photo_view.DragMotion += HandlePhotoViewDragMotion;
            photo_view.DragDrop += HandlePhotoViewDragDrop;
            photo_view.DragDataReceived += HandlePhotoViewDragDataReceived;

            view_notebook.SwitchPage += HandleViewNotebookSwitchPage;
            group_selector.Adaptor.GlassSet += HandleAdaptorGlassSet;
            group_selector.Adaptor.Changed += HandleAdaptorChanged;
            LoadPreference (Preferences.GROUP_ADAPTOR_ORDER_ASC);
            LoadPreference (Preferences.FILMSTRIP_ORIENTATION);

            Selection = new MainSelection (this);
            Selection.Changed += HandleSelectionChanged;
            Selection.ItemsChanged += HandleSelectionItemsChanged;
            Selection.Changed += Sidebar.HandleSelectionChanged;
            Selection.ItemsChanged += Sidebar.HandleSelectionItemsChanged;

            Mono.Addins.AddinManager.ExtensionChanged += PopulateExtendableMenus;
            PopulateExtendableMenus (null, null);

            UpdateMenus ();

            main_window.ShowAll ();

            tagbar.Hide ();
            find_bar.Hide ();

            UpdateFindByTagMenu ();

            LoadPreference (Preferences.SHOW_TOOLBAR);
            LoadPreference (Preferences.SHOW_SIDEBAR);
            LoadPreference (Preferences.SHOW_TIMELINE);
            LoadPreference (Preferences.SHOW_FILMSTRIP);

            LoadPreference (Preferences.GNOME_MAILTO_ENABLED);

            Preferences.SettingChanged += OnPreferencesChanged;

            main_window.DeleteEvent += HandleDeleteEvent;

            query_widget.HandleChanged (query);
            query_widget.Close ();

            // When the icon_view is loaded, set it's initial scroll position
            icon_view.SizeAllocated += HandleIconViewReady;

            export.Activated += HandleExportActivated;
            UpdateToolbar ();

            (uimanager.GetWidget("/ui/menubar1/file1/close1") as MenuItem).Hide ();

            Banshee.Kernel.Scheduler.Resume ();
        }
Exemple #31
0
        void create_mosaics()
        {
            //Prepare the query
            Db db = App.Instance.Database;
            FSpot.PhotoQuery mini_query = new FSpot.PhotoQuery (db.Photos);
            Photo [] photos;

            if (tags_radio.Active) {
                //Build tag array
                List<Tag> taglist = new List<Tag> ();
                foreach (string tag_name in miniatures_tags.GetTypedTagNames ()) {
                    Tag t = db.Tags.GetTagByName (tag_name);
                    if (t != null)
                        taglist.Add(t);
                }
                mini_query.Terms = FSpot.OrTerm.FromTags (taglist.ToArray ());
                photos = mini_query.Photos;
            } else {
                photos = App.Instance.Organizer.Query.Photos;
            }

            if (photos.Length == 0) {
                //There is no photo for the selected tags! :(
                InfoDialog (Catalog.GetString ("No photos for the selection"),
                        Catalog.GetString ("The tags selected provided no pictures. Please select different tags"),
                        Gtk.MessageType.Error);
                return;
            }

            //Create minis
            ProgressDialog progress_dialog = null;
            progress_dialog = new ProgressDialog (Catalog.GetString ("Creating miniatures"),
                                  ProgressDialog.CancelButtonType.Stop,
                                  photos.Length, metapixel_dialog);

            minidir_tmp = System.IO.Path.GetTempFileName ();
            System.IO.File.Delete (minidir_tmp);
            System.IO.Directory.CreateDirectory (minidir_tmp);
            minidir_tmp += "/";

            //Call MetaPixel to create the minis
            foreach (Photo p in photos) {
                if (progress_dialog.Update (String.Format (Catalog.GetString ("Preparing photo \"{0}\""), p.Name))) {
                    progress_dialog.Destroy ();
                    DeleteTmp ();
                    return;
                }
                //FIXME should switch to retry/skip
                if (!GLib.FileFactory.NewForUri (p.DefaultVersion.Uri).Exists) {
                    Log.WarningFormat (String.Format ("Couldn't access photo {0} while creating miniatures", p.DefaultVersion.Uri.LocalPath));
                    continue;
                }
                //FIXME Check if the picture's format is supproted (jpg, gif)

                FilterSet filters = new FilterSet ();
                filters.Add (new JpegFilter ());
                FilterRequest freq = new FilterRequest (p.DefaultVersion.Uri);
                filters.Convert (freq);

                //We use photo id for minis, instead of photo names, to avoid duplicates
                string minifile = minidir_tmp + p.Id.ToString() + System.IO.Path.GetExtension (p.DefaultVersion.Uri.ToString ());
                string prepare_command = String.Format ("--prepare -w {0} -h {1} {2} {3} {4}tables.mxt",
                                    icon_x_size.Text, //Minis width
                                    icon_y_size.Text, //Minis height
                                    GLib.Shell.Quote (freq.Current.LocalPath), //Source image
                                    GLib.Shell.Quote (minifile),  //Dest image
                                    minidir_tmp);  //Table file
                Log.Debug ("Executing: metapixel " + prepare_command);

                System.Diagnostics.Process mp_prep = System.Diagnostics.Process.Start ("metapixel", prepare_command);
                mp_prep.WaitForExit ();
                if (!System.IO.File.Exists (minifile)) {
                    Log.DebugFormat ("No mini? No party! {0}", minifile);
                    continue;
                }

            } //Finished preparing!
            if (progress_dialog != null)
                progress_dialog.Destroy ();

            progress_dialog = null;
            progress_dialog = new ProgressDialog (Catalog.GetString ("Creating photomosaics"),
                                  ProgressDialog.CancelButtonType.Stop,
                                  App.Instance.Organizer.SelectedPhotos ().Length, metapixel_dialog);

            //Now create the mosaics!
            uint error_count = 0;
            foreach (Photo p in App.Instance.Organizer.SelectedPhotos ()) {
                if (progress_dialog.Update (String.Format (Catalog.GetString ("Processing \"{0}\""), p.Name))) {
                    progress_dialog.Destroy ();
                    DeleteTmp ();
                    return;
                }
                //FIXME should switch to retry/skip
                if (!GLib.FileFactory.NewForUri (p.DefaultVersion.Uri).Exists) {
                    Log.WarningFormat (String.Format ("Couldn't access photo {0} while creating mosaics", p.DefaultVersion.Uri.LocalPath));
                    error_count ++;
                    continue;
                }

                //FIXME Check if the picture's format is supproted (jpg, gif)

                FilterSet filters = new FilterSet ();
                filters.Add (new JpegFilter ());
                FilterRequest freq = new FilterRequest (p.DefaultVersion.Uri);
                filters.Convert (freq);

                string name = GetVersionName (p);
                System.Uri mosaic = GetUriForVersionName (p, name);

                string mosaic_command = String.Format ("--metapixel -l {0} {1} {2}",
                                    minidir_tmp,
                                    GLib.Shell.Quote (freq.Current.LocalPath),
                                    GLib.Shell.Quote (mosaic.LocalPath));
                Log.Debug ("Executing: metapixel " + mosaic_command);
                System.Diagnostics.Process mp_exe = System.Diagnostics.Process.Start ("metapixel", mosaic_command);
                mp_exe.WaitForExit ();
                if (!GLib.FileFactory.NewForUri (mosaic).Exists) {
                    Log.Warning ("Error in processing image " + p.Name);
                    error_count ++;
                    continue;
                }

                p.DefaultVersionId = p.AddVersion (mosaic, name, true);
                p.Changes.DataChanged = true;
                Core.Database.Photos.Commit (p);

            } //Finished creating mosaics
            if (progress_dialog != null)
                progress_dialog.Destroy ();

            string final_message = "Your mosaics have been generated as new versions of the pictures you selected";
            if (error_count > 0)
                final_message += String.Format (".\n{0} images out of {1} had errors",
                            error_count, App.Instance.Organizer.SelectedPhotos ().Length);
            InfoDialog (Catalog.GetString ("PhotoMosaics generated!"),
                    Catalog.GetString (final_message),
                    (error_count == 0 ? Gtk.MessageType.Info : Gtk.MessageType.Warning));
            DeleteTmp ();
        }
 public PhotoLoader(PhotoQuery query)
 {
     this.query = query;
 }
		void ImportPhotos (PhotoQuery query, bool copy)
		{
			foreach (Photo p in query.Photos)
				ImportPhoto (p, copy);
		}
Exemple #34
0
		private Photo[] mosaicStones() {
			if (config.tags_radio_button) {
				Db db = MainWindow.Toplevel.Database;
				FSpot.PhotoQuery mini_query = new FSpot.PhotoQuery (db.Photos);
				mini_query.Terms = FSpot.OrTerm.FromTags (tags(db));
				Photo [] photos = mini_query.Photos;
				if(photos.Length == 0) {
					throw new ExtensionException("No photos in current selection.");
				}
				return photos;
			} else {
				return MainWindow.Toplevel.Query.Photos;
			}
		}
		public TimeAdaptor (PhotoQuery query) 
			: base (query)
		{ }
Exemple #36
0
 public DirectoryAdaptor(PhotoQuery query, bool order_ascending)
     : base(query, order_ascending)
 {
 }
 public Set(FSpot.PhotoQuery query, Gtk.Window parent_window)
 {
     this.query         = query;
     this.parent_window = parent_window;
 }
        public bool Execute(Tag t)
        {
            this.CreateDialog("edit_icon_dialog");

            this.Dialog.Title = String.Format(Catalog.GetString("Edit Icon for Tag {0}"), t.Name);

            PreviewPixbuf = t.Icon;

            query = new FSpot.PhotoQuery(db.Photos);

            if (db.Tags.Hidden != null)
            {
                query.Terms = FSpot.OrTerm.FromTags(new Tag [] { t, db.Tags.Hidden });
            }
            else
            {
                query.Terms = new FSpot.Literal(t);
            }

            image_view = new FSpot.PhotoImageView(query);
            image_view.SelectionXyRatio  = 1.0;
            image_view.SelectionChanged += HandleSelectionChanged;
            image_view.PhotoChanged     += HandlePhotoChanged;

            external_photo_chooser = new Gtk.FileChooserButton(Catalog.GetString("Select Photo from file"),
                                                               Gtk.FileChooserAction.Open);

            external_photo_chooser.Filter = new FileFilter();
            external_photo_chooser.Filter.AddPixbufFormats();
            external_photo_chooser.LocalOnly = false;
            external_photo_chooser_hbox.PackStart(external_photo_chooser);

            Dialog.ShowAll();
            external_photo_chooser.SelectionChanged += HandleExternalFileSelectionChanged;

            photo_scrolled_window.Add(image_view);

            if (query.Count > 0)
            {
                photo_spin_button.Wrap                     = true;
                photo_spin_button.Adjustment.Lower         = 1.0;
                photo_spin_button.Adjustment.Upper         = (double)query.Count;
                photo_spin_button.Adjustment.StepIncrement = 1.0;
                photo_spin_button.ValueChanged            += HandleSpinButtonChanged;

                image_view.Item.Index = 0;
            }
            else
            {
                from_photo_label.Markup = String.Format(Catalog.GetString(
                                                            "\n<b>From Photo</b>\n" +
                                                            " You can use one of your library photos as an icon for this tag.\n" +
                                                            " However, first you must have at least one photo associated\n" +
                                                            " with this tag. Please tag a photo as '{0}' and return here\n" +
                                                            " to use it as an icon."), t.Name);
                photo_scrolled_window.Visible = false;
                photo_label.Visible           = false;
                photo_spin_button.Visible     = false;
            }

            icon_store = new ListStore(typeof(string), typeof(Gdk.Pixbuf));

            icon_view = new Gtk.IconView(icon_store);
            icon_view.PixbufColumn      = 1;
            icon_view.SelectionMode     = SelectionMode.Single;
            icon_view.SelectionChanged += HandleIconSelectionChanged;

            icon_scrolled_window.Add(icon_view);

            icon_view.Show();

            image_view.Show();

            FSpot.Delay fill_delay = new FSpot.Delay(FillIconView);
            fill_delay.Start();

            ResponseType response = (ResponseType)this.Dialog.Run();
            bool         success  = false;

            if (response == ResponseType.Ok)
            {
                try {
                    if (IconName != null)
                    {
                        t.ThemeIconName = IconName;
                    }
                    else
                    {
                        t.ThemeIconName = null;
                        t.Icon          = PreviewPixbuf_WithoutProfile;
                    }
                    //db.Tags.Commit (t);
                    success = true;
                } catch (Exception ex) {
                    // FIXME error dialog.
                    Console.WriteLine("error {0}", ex);
                }
            }
            else if (response == (ResponseType)(1))
            {
                t.Icon  = null;
                success = true;
            }

            this.Dialog.Destroy();
            return(success);
        }
Exemple #39
0
 public TimeAdaptor(PhotoQuery query, bool order_ascending) : base(query, order_ascending)
 {
 }
Exemple #40
0
		//
		// Constructor
		//
		public MainWindow (Db db)
		{
			foreach (ServiceNode service in AddinManager.GetExtensionNodes ("/FSpot/Services")) {
				try {
					service.Initialize ();
					service.Start ();
				} catch (Exception e) {
					Log.WarningFormat ("Something went wrong while starting the {0} extension.", service.Id);
					Log.DebugException (e);
				}
			}

			Database = db;

			GtkBeans.Builder builder = new GtkBeans.Builder ("main_window.ui");
			builder.Autoconnect (this);

			//Set the global DefaultColormap. Allows transparency according
			//to the theme (work on murrine engine)
			Gdk.Colormap colormap = ((Widget)main_window).Screen.RgbaColormap;
			if (colormap == null) {
				Log.Debug ("Your screen doesn't support alpha channels!");
				colormap = ((Widget)main_window).Screen.RgbColormap;
			}
			Gtk.Widget.DefaultColormap = colormap;

			LoadPreference (Preferences.MAIN_WINDOW_WIDTH);
			LoadPreference (Preferences.MAIN_WINDOW_X);
			LoadPreference (Preferences.MAIN_WINDOW_MAXIMIZED);
			main_window.ShowAll ();

			LoadPreference (Preferences.SIDEBAR_POSITION);
			LoadPreference (Preferences.METADATA_EMBED_IN_IMAGE);

			pagesetup_menu_item.Activated += HandlePageSetupActivated;

			toolbar = new Gtk.Toolbar ();
			toolbar_vbox.PackStart (toolbar);

			ToolButton import_button = GtkUtil.ToolButtonFromTheme ("gtk-add", Catalog.GetString ("Import Photos…"), true);
			import_button.Clicked += (o, args) => StartImport (null);
			import_button.TooltipText = Catalog.GetString ("Import new photos");
			toolbar.Insert (import_button, -1);

			toolbar.Insert (new SeparatorToolItem (), -1);

			rl_button = GtkUtil.ToolButtonFromTheme ("object-rotate-left", Catalog.GetString ("Rotate Left"), false);
			rl_button.Clicked += HandleRotate270Command;
			toolbar.Insert (rl_button, -1);

			rr_button = GtkUtil.ToolButtonFromTheme ("object-rotate-right", Catalog.GetString ("Rotate Right"), false);
			rr_button.Clicked += HandleRotate90Command;
			toolbar.Insert (rr_button, -1);

			toolbar.Insert (new SeparatorToolItem (), -1);

			browse_button = new ToggleToolButton ();
			browse_button.Label = Catalog.GetString ("Browsing");
			browse_button.IconName = "mode-browse";
			browse_button.IsImportant = true;
			browse_button.Toggled += HandleToggleViewBrowse;
			browse_button.TooltipText = Catalog.GetString ("Browse your photo library");
			toolbar.Insert (browse_button, -1);

			edit_button = new ToggleToolButton ();
			edit_button.Label = Catalog.GetString ("Editing");
			edit_button.IconName = "mode-image-edit";
			edit_button.IsImportant = true;
			edit_button.Toggled += HandleToggleViewPhoto;
			edit_button.TooltipText = Catalog.GetString ("Edit your photos");
			toolbar.Insert (edit_button, -1);

			toolbar.Insert (new SeparatorToolItem (), -1);

			ToolButton fs_button = GtkUtil.ToolButtonFromTheme ("view-fullscreen", Catalog.GetString ("Fullscreen"), false);
			fs_button.Clicked += HandleViewFullscreen;
			fs_button.TooltipText = Catalog.GetString ("View photos fullscreen");
			toolbar.Insert (fs_button, -1);

			ToolButton ss_button = GtkUtil.ToolButtonFromTheme ("media-playback-start", Catalog.GetString ("Slideshow"), false);
			ss_button.Clicked += HandleViewSlideShow;
			ss_button.TooltipText = Catalog.GetString ("View photos in a slideshow");
			toolbar.Insert (ss_button, -1);

			SeparatorToolItem white_space = new SeparatorToolItem ();
			white_space.Draw = false;
			white_space.Expand = true;
			toolbar.Insert (white_space, -1);

			ToolItem label_item = new ToolItem ();
			count_label = new Label (String.Empty);
			label_item.Child = count_label;
			toolbar.Insert (label_item, -1);

			display_previous_button = new ToolButton (Stock.GoBack);
			toolbar.Insert (display_previous_button, -1);
			display_previous_button.TooltipText = Catalog.GetString ("Previous photo");
			display_previous_button.Clicked += new EventHandler (HandleDisplayPreviousButtonClicked);

			display_next_button = new ToolButton (Stock.GoForward);
			toolbar.Insert (display_next_button, -1);
			display_next_button.TooltipText = Catalog.GetString ("Next photo");
			display_next_button.Clicked += new EventHandler (HandleDisplayNextButtonClicked);

			Sidebar = new Sidebar ();
			ViewModeChanged += Sidebar.HandleMainWindowViewModeChanged;
			sidebar_vbox.Add (Sidebar);

			tag_selection_scrolled = new Gtk.ScrolledWindow ();
			tag_selection_scrolled.ShadowType = ShadowType.In;

			tag_selection_widget = new TagSelectionWidget (Database.Tags);
			tag_selection_scrolled.Add (tag_selection_widget);

			Sidebar.AppendPage (tag_selection_scrolled, Catalog.GetString ("Tags"), "tag");

			AddinManager.AddExtensionNodeHandler ("/FSpot/Sidebar", OnSidebarExtensionChanged);

			Sidebar.Context = ViewContext.Library;

			Sidebar.CloseRequested += HideSidebar;
			Sidebar.Show ();

			InfoBox = new InfoBox ();
			ViewModeChanged += InfoBox.HandleMainWindowViewModeChanged;
			InfoBox.VersionChanged += delegate (InfoBox box, IPhotoVersion version) {
				UpdateForVersionChange (version);
			};
			sidebar_vbox.PackEnd (InfoBox, false, false, 0);

			InfoBox.Context = ViewContext.Library;

			tag_selection_widget.Selection.Changed += HandleTagSelectionChanged;
			tag_selection_widget.KeyPressEvent += HandleTagSelectionKeyPress;
			tag_selection_widget.ButtonPressEvent += HandleTagSelectionButtonPressEvent;
			tag_selection_widget.PopupMenu += HandleTagSelectionPopupMenu;
			tag_selection_widget.RowActivated += HandleTagSelectionRowActivated;

			LoadPreference (Preferences.TAG_ICON_SIZE);

			try {
				query = new PhotoQuery (Database.Photos);
			} catch (System.Exception e) {
				//FIXME assume any exception here is due to a corrupt db and handle that.
				new RepairDbDialog (e, Database.Repair (), main_window);
				query = new PhotoQuery (Database.Photos);
			}

			UpdateStatusLabel ();
			query.Changed += HandleQueryChanged;

			Database.Photos.ItemsChanged += HandleDbItemsChanged;
			Database.Tags.ItemsChanged += HandleTagsChanged;
			Database.Tags.ItemsAdded += HandleTagsChanged;
			Database.Tags.ItemsRemoved += HandleTagsChanged;

			group_selector = new GroupSelector ();
			group_selector.Adaptor = new TimeAdaptor (query, Preferences.Get<bool> (Preferences.GROUP_ADAPTOR_ORDER_ASC));

			group_selector.ShowAll ();

			if (zoom_scale != null) {
				zoom_scale.ValueChanged += HandleZoomScaleValueChanged;
			}

			view_vbox.PackStart (group_selector, false, false, 0);
			view_vbox.ReorderChild (group_selector, 0);

			find_bar = new FindBar (query, tag_selection_widget.Model);
			view_vbox.PackStart (find_bar, false, false, 0);
			view_vbox.ReorderChild (find_bar, 1);
			main_window.KeyPressEvent += HandleKeyPressEvent;

			query_widget = new QueryWidget (query, Database);
			query_widget.Logic.Changed += HandleQueryLogicChanged;
			view_vbox.PackStart (query_widget, false, false, 0);
			view_vbox.ReorderChild (query_widget, 2);

			MenuItem findByTag = uimanager.GetWidget ("/ui/menubar1/find/find_by_tag") as MenuItem;
			query_widget.Hidden += delegate {
				((Gtk.Label)findByTag.Child).TextWithMnemonic = Catalog.GetString ("Show _Find Bar");
			};
			query_widget.Shown += delegate {
				((Gtk.Label)findByTag.Child).TextWithMnemonic = Catalog.GetString ("Hide _Find Bar");
			};

			icon_view = new QueryView (query);
			icon_view.ZoomChanged += HandleZoomChanged;
			LoadPreference (Preferences.ZOOM);
			LoadPreference (Preferences.SHOW_TAGS);
			LoadPreference (Preferences.SHOW_DATES);
			LoadPreference (Preferences.SHOW_RATINGS);
			icon_view_scrolled.Add (icon_view);
			icon_view.DoubleClicked += HandleDoubleClicked;
			icon_view.Vadjustment.ValueChanged += HandleIconViewScroll;
			icon_view.GrabFocus ();

			preview_popup = new PreviewPopup (icon_view);

			icon_view.DragBegin += HandleIconViewDragBegin;
			icon_view.DragEnd += HandleIconViewDragEnd;
			icon_view.DragDataGet += HandleIconViewDragDataGet;
			icon_view.DragMotion += HandleIconViewDragMotion;
			icon_view.DragDrop += HandleIconViewDragDrop;
			// StartDrag is fired by IconView
			icon_view.StartDrag += HandleIconViewStartDrag;

			TagMenu tag_menu = new TagMenu (null, Database.Tags);
			tag_menu.NewTagHandler += delegate {
				HandleCreateTagAndAttach (this, null);
			};
			tag_menu.TagSelected += HandleAttachTagMenuSelected;
			tag_menu.Populate ();
			(uimanager.GetWidget ("/ui/menubar1/edit2/attach_tag") as MenuItem).Submenu = tag_menu;

			PhotoTagMenu pmenu = new PhotoTagMenu ();
			pmenu.TagSelected += HandleRemoveTagMenuSelected;
			(uimanager.GetWidget ("/ui/menubar1/edit2/remove_tag") as MenuItem).Submenu = pmenu;

			Gtk.Drag.DestSet (icon_view, DestDefaults.All, (TargetEntry[])iconDestTargetList,
				DragAction.Copy | DragAction.Move);

			icon_view.DragDataReceived += HandleIconViewDragDataReceived;
			icon_view.KeyPressEvent += HandleIconViewKeyPressEvent;

			photo_view = new PhotoView (query);
			photo_box.Add (photo_view);

			photo_view.DoubleClicked += HandleDoubleClicked;
			photo_view.KeyPressEvent += HandlePhotoViewKeyPressEvent;
			photo_view.UpdateStarted += HandlePhotoViewUpdateStarted;
			photo_view.UpdateFinished += HandlePhotoViewUpdateFinished;

			photo_view.View.ZoomChanged += HandleZoomChanged;

			// Tag typing: focus the tag entry if the user starts typing a tag
			icon_view.KeyPressEvent += HandlePossibleTagTyping;
			photo_view.KeyPressEvent += HandlePossibleTagTyping;
			tag_entry = new TagEntry (Database.Tags);
			tag_entry.KeyPressEvent += HandleTagEntryKeyPressEvent;
			tag_entry.TagsAttached += HandleTagEntryTagsAttached;
			tag_entry.TagsRemoved += HandleTagEntryRemoveTags;
			tag_entry.Activated += HandleTagEntryActivate;
			tag_entry_container.Add (tag_entry);

			Gtk.Drag.DestSet (photo_view, DestDefaults.All, tag_target_table,
				DragAction.Copy | DragAction.Move);

			photo_view.DragMotion += HandlePhotoViewDragMotion;
			photo_view.DragDrop += HandlePhotoViewDragDrop;
			photo_view.DragDataReceived += HandlePhotoViewDragDataReceived;

			view_notebook.SwitchPage += HandleViewNotebookSwitchPage;
			group_selector.Adaptor.GlassSet += HandleAdaptorGlassSet;
			group_selector.Adaptor.Changed += HandleAdaptorChanged;
			LoadPreference (Preferences.GROUP_ADAPTOR_ORDER_ASC);
			LoadPreference (Preferences.FILMSTRIP_ORIENTATION);

			Selection = new MainSelection (this);
			Selection.Changed += HandleSelectionChanged;
			Selection.ItemsChanged += HandleSelectionItemsChanged;
			Selection.Changed += Sidebar.HandleSelectionChanged;
			Selection.ItemsChanged += Sidebar.HandleSelectionItemsChanged;

			AddinManager.ExtensionChanged += PopulateExtendableMenus;
			PopulateExtendableMenus (null, null);

			UpdateMenus ();

			main_window.ShowAll ();

			tagbar.Hide ();
			find_bar.Hide ();

			UpdateFindByTagMenu ();

			LoadPreference (Preferences.SHOW_TOOLBAR);
			LoadPreference (Preferences.SHOW_SIDEBAR);
			LoadPreference (Preferences.SHOW_TIMELINE);
			LoadPreference (Preferences.SHOW_FILMSTRIP);

			LoadPreference (Preferences.GNOME_MAILTO_ENABLED);

			Preferences.SettingChanged += OnPreferencesChanged;

			main_window.DeleteEvent += HandleDeleteEvent;

			// When the icon_view is loaded, set it's initial scroll position
			icon_view.SizeAllocated += HandleIconViewReady;

			export.Activated += HandleExportActivated;
			UpdateToolbar ();

			(uimanager.GetWidget ("/ui/menubar1/file1/close1") as MenuItem).Hide ();

			Banshee.Kernel.Scheduler.Resume ();
		}
		public Set (FSpot.PhotoQuery query, Gtk.Window parent_window)
		{
			this.query = query;
			this.parent_window = parent_window;
		}
	//
	// Constructor
	//
	public MainWindow (Db db)
	{
		this.db = db;

		if (Toplevel == null)
			Toplevel = this;

		Glade.XML gui = new Glade.XML (null, "f-spot.glade", "main_window", "f-spot");
		gui.Autoconnect (this);

		LoadPreference (Preferences.MAIN_WINDOW_WIDTH);
		LoadPreference (Preferences.MAIN_WINDOW_X);
		LoadPreference (Preferences.MAIN_WINDOW_MAXIMIZED);
		main_window.ShowAll ();

		LoadPreference (Preferences.SIDEBAR_POSITION);
		LoadPreference (Preferences.METADATA_EMBED_IN_IMAGE);

		LoadPreference (Preferences.COLOR_MANAGEMENT_ENABLED);
 		LoadPreference (Preferences.COLOR_MANAGEMENT_USE_X_PROFILE);
 		FSpot.ColorManagement.LoadSettings();
	
#if GTK_2_10
		pagesetup_menu_item.Activated += HandlePageSetupActivated;
#else
		pagesetup_menu_item.Visible = false;
#endif
		toolbar = new Gtk.Toolbar ();
		toolbar_vbox.PackStart (toolbar);

		ToolButton import_button = GtkUtil.ToolButtonFromTheme ("gtk-add", Catalog.GetString ("Import"), false);
		import_button.Clicked += HandleImportCommand;
		import_button.SetTooltip (ToolTips, Catalog.GetString ("Import new images"), null);
		toolbar.Insert (import_button, -1);
	
		toolbar.Insert (new SeparatorToolItem (), -1);

		ToolButton rl_button = GtkUtil.ToolButtonFromTheme ("object-rotate-left", Catalog.GetString ("Rotate Left"), true);
		rl_button.Clicked += HandleRotate270Command;
		toolbar.Insert (rl_button, -1);

		ToolButton rr_button = GtkUtil.ToolButtonFromTheme ("object-rotate-right", Catalog.GetString ("Rotate Right"), true);
		rr_button.Clicked += HandleRotate90Command;
		toolbar.Insert (rr_button, -1);

		toolbar.Insert (new SeparatorToolItem (), -1);

		browse_button = new ToggleToolButton ();
		browse_button.Label = Catalog.GetString ("Browse");
		browse_button.IconName = "mode-browse";
		browse_button.IsImportant = true;
		browse_button.Toggled += HandleToggleViewBrowse;
		browse_button.SetTooltip (ToolTips, Catalog.GetString ("Browse many photos simultaneously"), null);
		toolbar.Insert (browse_button, -1);

		edit_button = new ToggleToolButton ();
		edit_button.Label = Catalog.GetString ("Edit Image");
		edit_button.IconName = "mode-image-edit";
		edit_button.IsImportant = true;
		edit_button.Toggled += HandleToggleViewPhoto;
		edit_button.SetTooltip (ToolTips, Catalog.GetString ("View and edit a photo"), null);
		toolbar.Insert (edit_button, -1);

		toolbar.Insert (new SeparatorToolItem (), -1);

		ToolButton fs_button = GtkUtil.ToolButtonFromTheme ("view-fullscreen", Catalog.GetString ("Fullscreen"), true);
		fs_button.Clicked += HandleViewFullscreen;
		fs_button.SetTooltip (ToolTips, Catalog.GetString ("View photos fullscreen"), null);
		toolbar.Insert (fs_button, -1);

		ToolButton ss_button = GtkUtil.ToolButtonFromTheme ("media-playback-start", Catalog.GetString ("Slideshow"), true);
		ss_button.Clicked += HandleViewSlideShow;
		ss_button.SetTooltip (ToolTips, Catalog.GetString ("View photos in a slideshow"), null);
		toolbar.Insert (ss_button, -1);

		SeparatorToolItem white_space = new SeparatorToolItem ();
		white_space.Draw = false;
		white_space.Expand = true;
		toolbar.Insert (white_space, -1);

		ToolItem label_item = new ToolItem ();
		count_label = new Label (String.Empty);
		label_item.Child = count_label;
		toolbar.Insert (label_item, -1);

		display_previous_button = new ToolButton (Stock.GoBack);
		toolbar.Insert (display_previous_button, -1);
		display_previous_button.SetTooltip (ToolTips, Catalog.GetString ("Previous photo"), String.Empty);
		display_previous_button.Clicked += new EventHandler (HandleDisplayPreviousButtonClicked);

		display_next_button = new ToolButton (Stock.GoForward);
		toolbar.Insert (display_next_button, -1);
		display_next_button.SetTooltip (ToolTips, Catalog.GetString ("Next photo"), String.Empty);
		display_next_button.Clicked += new EventHandler (HandleDisplayNextButtonClicked);

		sidebar = new Sidebar ();
		ViewModeChanged += sidebar.HandleMainWindowViewModeChanged;
		sidebar_vbox.Add (sidebar);

		tag_selection_scrolled = new ScrolledWindow ();
		tag_selection_scrolled.ShadowType = ShadowType.In;
		
		tag_selection_widget = new TagSelectionWidget (db.Tags);
		tag_selection_scrolled.Add (tag_selection_widget);

		sidebar.AppendPage (tag_selection_scrolled, Catalog.GetString ("Tags"), "tag");

		AddinManager.AddExtensionNodeHandler ("/FSpot/Sidebar", OnSidebarExtensionChanged);

		sidebar.Context = ViewContext.Library;
 		
		sidebar.CloseRequested += HideSidebar;
		sidebar.Show ();

		info_box = new InfoBox ();
		ViewModeChanged += info_box.HandleMainWindowViewModeChanged;
		info_box.VersionIdChanged += delegate (InfoBox box, uint version_id) { UpdateForVersionIdChange (version_id);};
		sidebar_vbox.PackEnd (info_box, false, false, 0);

		info_box.Context = ViewContext.Library;
		
		tag_selection_widget.Selection.Changed += HandleTagSelectionChanged;
		tag_selection_widget.DragDataGet += HandleTagSelectionDragDataGet;
		tag_selection_widget.DragDrop += HandleTagSelectionDragDrop;
		tag_selection_widget.DragBegin += HandleTagSelectionDragBegin;
		tag_selection_widget.KeyPressEvent += HandleTagSelectionKeyPress;
		Gtk.Drag.SourceSet (tag_selection_widget, Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask,
				    tag_target_table, DragAction.Copy | DragAction.Move);

		tag_selection_widget.DragDataReceived += HandleTagSelectionDragDataReceived;
		tag_selection_widget.DragMotion += HandleTagSelectionDragMotion;
		Gtk.Drag.DestSet (tag_selection_widget, DestDefaults.All, tag_dest_target_table, 
				  DragAction.Copy | DragAction.Move ); 

		tag_selection_widget.ButtonPressEvent += HandleTagSelectionButtonPressEvent;
		tag_selection_widget.PopupMenu += HandleTagSelectionPopupMenu;
		tag_selection_widget.RowActivated += HandleTagSelectionRowActivated;
		
		LoadPreference (Preferences.TAG_ICON_SIZE);
		
		try {
			query = new FSpot.PhotoQuery (db.Photos);
		} catch (System.Exception e) {
			//FIXME assume any exception here is due to a corrupt db and handle that.
			new RepairDbDialog (e, db.Repair (), main_window);
			query = new FSpot.PhotoQuery (db.Photos);
		}

		UpdateStatusLabel ();
		query.Changed += HandleQueryChanged;

		db.Photos.ItemsChanged += HandleDbItemsChanged;
		db.Tags.ItemsChanged += HandleTagsChanged;
		db.Tags.ItemsAdded += HandleTagsChanged;
		db.Tags.ItemsRemoved += HandleTagsChanged;
#if SHOW_CALENDAR
		FSpot.SimpleCalendar cal = new FSpot.SimpleCalendar (query);
		cal.DaySelected += HandleCalendarDaySelected;
		left_vbox.PackStart (cal, false, true, 0);
#endif

		group_selector = new FSpot.GroupSelector ();
		group_selector.Adaptor = new FSpot.TimeAdaptor (query, Preferences.Get<bool> (Preferences.GROUP_ADAPTOR_ORDER_ASC));

		group_selector.ShowAll ();
		
		if (zoom_scale != null) {
			zoom_scale.ValueChanged += HandleZoomScaleValueChanged;
		}

		view_vbox.PackStart (group_selector, false, false, 0);
		view_vbox.ReorderChild (group_selector, 0);

		find_bar = new FindBar (query, tag_selection_widget.Model);
		view_vbox.PackStart (find_bar, false, false, 0);
		view_vbox.ReorderChild (find_bar, 1);
		main_window.KeyPressEvent += HandleKeyPressEvent;
		
		query_widget = new FSpot.QueryWidget (query, db, tag_selection_widget);
		query_widget.Logic.Changed += HandleQueryLogicChanged;
		view_vbox.PackStart (query_widget, false, false, 0);
		view_vbox.ReorderChild (query_widget, 2);

		icon_view = new QueryView (query);
		icon_view.ZoomChanged += HandleZoomChanged;
		LoadPreference (Preferences.ZOOM);
		LoadPreference (Preferences.SHOW_TAGS);
		LoadPreference (Preferences.SHOW_DATES);
		LoadPreference (Preferences.SHOW_RATINGS);
		icon_view_scrolled.Add (icon_view);
		icon_view.DoubleClicked += HandleDoubleClicked;
		icon_view.Vadjustment.ValueChanged += HandleIconViewScroll;
		icon_view.GrabFocus ();

		new FSpot.PreviewPopup (icon_view);

		Gtk.Drag.SourceSet (icon_view, Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask,
				    icon_source_target_table, DragAction.Copy | DragAction.Move);
		
		icon_view.DragBegin += HandleIconViewDragBegin;
		icon_view.DragDataGet += HandleIconViewDragDataGet;

		TagMenu tag_menu = new TagMenu (null, Database.Tags);
		tag_menu.NewTagHandler += delegate { HandleCreateTagAndAttach (this, null); };
		tag_menu.TagSelected += HandleAttachTagMenuSelected;
		tag_menu.Populate();
		attach_tag.Submenu = tag_menu;
		
		PhotoTagMenu pmenu = new PhotoTagMenu ();
		pmenu.TagSelected += HandleRemoveTagMenuSelected;
		remove_tag.Submenu = pmenu;
		
		Gtk.Drag.DestSet (icon_view, DestDefaults.All, icon_dest_target_table, 
				  DragAction.Copy | DragAction.Move); 

		//		icon_view.DragLeave += new DragLeaveHandler (HandleIconViewDragLeave);
		icon_view.DragMotion += HandleIconViewDragMotion;
		icon_view.DragDrop += HandleIconViewDragDrop;
		icon_view.DragDataReceived += HandleIconViewDragDataReceived;
		icon_view.KeyPressEvent += HandleIconViewKeyPressEvent;

		photo_view = new PhotoView (query);
		photo_box.Add (photo_view);

		photo_view.DoubleClicked += HandleDoubleClicked;
		photo_view.KeyPressEvent += HandlePhotoViewKeyPressEvent;
		photo_view.UpdateStarted += HandlePhotoViewUpdateStarted;
		photo_view.UpdateFinished += HandlePhotoViewUpdateFinished;

		photo_view.View.ZoomChanged += HandleZoomChanged;

		// Tag typing: focus the tag entry if the user starts typing a tag
		icon_view.KeyPressEvent += HandlePossibleTagTyping;
		photo_view.KeyPressEvent += HandlePossibleTagTyping;
		tag_entry = new TagEntry (db.Tags);
		tag_entry.KeyPressEvent += HandleTagEntryKeyPressEvent;
		tag_entry.TagsAttached += HandleTagEntryTagsAttached;
		tag_entry.TagsRemoved += HandleTagEntryRemoveTags;
		tag_entry.Activated += HandleTagEntryActivate;
		tag_entry_container.Add (tag_entry);

		Gtk.Drag.DestSet (photo_view, DestDefaults.All, tag_target_table, 
				  DragAction.Copy | DragAction.Move); 

		photo_view.DragMotion += HandlePhotoViewDragMotion;
		photo_view.DragDrop += HandlePhotoViewDragDrop;
		photo_view.DragDataReceived += HandlePhotoViewDragDataReceived;

		view_notebook.SwitchPage += HandleViewNotebookSwitchPage;
		group_selector.Adaptor.GlassSet += HandleAdaptorGlassSet;
		group_selector.Adaptor.Changed += HandleAdaptorChanged;
		LoadPreference (Preferences.GROUP_ADAPTOR);
		LoadPreference (Preferences.GROUP_ADAPTOR_ORDER_ASC);

		this.selection = new MainSelection (this);
		this.selection.Changed += HandleSelectionChanged;
		this.selection.ItemsChanged += HandleSelectionItemsChanged;
		this.selection.Changed += sidebar.HandleSelectionChanged;
		this.selection.ItemsChanged += sidebar.HandleSelectionItemsChanged;

		Mono.Addins.AddinManager.ExtensionChanged += PopulateExtendableMenus;
		PopulateExtendableMenus (null, null);

		UpdateMenus ();

		main_window.ShowAll ();

		tagbar.Hide ();
		find_bar.Hide ();

		UpdateFindByTagMenu ();

		LoadPreference (Preferences.SHOW_TOOLBAR);
		LoadPreference (Preferences.SHOW_SIDEBAR);
		LoadPreference (Preferences.SHOW_TIMELINE);
		LoadPreference (Preferences.SHOW_FILMSTRIP);

		LoadPreference (Preferences.GNOME_MAILTO_ENABLED);
		
		Preferences.SettingChanged += OnPreferencesChanged;

		main_window.DeleteEvent += HandleDeleteEvent;
		
		query_widget.HandleChanged (query);
		query_widget.Hide ();

		// When the icon_view is loaded, set it's initial scroll position
		icon_view.SizeAllocated += HandleIconViewReady;

		export.Activated += HandleExportActivated;
		UpdateToolbar ();

		Banshee.Kernel.Scheduler.Resume ();
	}
Exemple #43
0
        public LogicWidget(PhotoQuery query, TagStore tag_store)
            : base()
        {
            //SetFlag (WidgetFlags.NoWindow);
            this.query = query;

            CanFocus = true;
            Sensitive = true;

            Literal.Tips = tips;

            tips.Enable ();

            Init ();

            tag_store.ItemsChanged += HandleTagChanged;
            tag_store.ItemsRemoved += HandleTagDeleted;

            Show ();

            logic_widget = this;
        }
	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 ();
			}
		}
	}