public CameraFileSelectionDialog(GPhotoCamera cam, Db datab)
 {
     camera        = cam;
     db            = datab;
     saved_files   = null;
     selected_tags = null;
 }
		public CameraFileSelectionDialog (GPhotoCamera cam, Db datab)
		{
			camera = cam;
			db = datab;
			saved_files = null;
			selected_tags = null;
		}
        public CameraSource(GPhotoCamera cam, int index)
        {
            this.cam         = cam;
            this.CameraIndex = index;

#if LONG_NAMES
            this.Name = String.Format("{0} ({1})", cam.CameraList.GetName(index), cam.CameraList.GetValue(index));
#else
            this.Name = String.Format("{0}", cam.CameraList.GetName(index));
#endif
            this.Icon = PixbufUtils.LoadThemeIcon("gnome-dev-camera", 32);
            if (this.Icon == null)
            {
                this.Icon = PixbufUtils.LoadThemeIcon("gnome-dev-media-cf", 32);
            }
        }
        public CameraSource(GPhotoCamera cam, int index)
        {
            this.cam         = cam;
            this.CameraIndex = index;

#if LONG_NAMES
            this.Name = String.Format("{0} ({1})", cam.CameraList.GetName(index), cam.CameraList.GetValue(index));
#else
            this.Name = String.Format("{0}", cam.CameraList.GetName(index));
#endif
            this.Icon = GtkUtil.TryLoadIcon(FSpot.Global.IconTheme, "camera-photo", 32, (Gtk.IconLookupFlags) 0);
            if (this.Icon == null)
            {
                this.Icon = GtkUtil.TryLoadIcon(FSpot.Global.IconTheme, "media-flash", 32, (Gtk.IconLookupFlags) 0);
            }
        }
		public SourceMenu (ImportCommand command) {
			this.command = command;
			source_count = 0;
			
			SourceItem item = new SourceItem (new BrowseSource ());
			item.Activated += HandleActivated;
			this.Append (item);
			this.Append (new Gtk.SeparatorMenuItem ());

			// Add external hard drives to the menu
			foreach (Gnome.Vfs.Volume vol in monitor.MountedVolumes) {
				 if (!vol.IsUserVisible || vol.DeviceType == Gnome.Vfs.DeviceType.Unknown)
					 continue;
				
				 System.Console.WriteLine ("{0} - {1} - {2} {3} {4} {5} {6}",
							  vol.DisplayName, 
							  vol.Icon, 
							  vol.VolumeType.ToString (), 
							  vol.ActivationUri, 
							  vol.IsUserVisible,
							  vol.IsMounted,
							  vol.DeviceType);
				 
				 if (vol.Drive != null)
					 System.Console.WriteLine (vol.Drive.DeviceType.ToString ());

				 ImportSource source = new VolumeSource (vol);
				 item = new SourceItem (source);
				 item.Activated += HandleActivated;
				 this.Append (item);
				 source_count++;

			}


			GPhotoCamera cam = new GPhotoCamera ();
			cam.DetectCameras ();
			int camera_count = cam.CameraList.Count ();

			if (camera_count > 0) {
				source_count += camera_count;
				for (int i = 0; i < camera_count; i++) {
					string handle = cam.CameraList.GetValue (i);
					if (camera_count == 1 || handle != "usb:") {
						if (handle.StartsWith ("disk:")) {
							string path = handle.Substring ("disk:".Length);

							if (FindItemPosition (path) != -1)
								continue;
						}
			
						ImportSource source = new CameraSource (cam, i);
						item = new SourceItem (source);
						item.Activated += HandleActivated;
						this.Append (item);
					}
				}
			} else {
				ImportSource source = new BrowseSource (Catalog.GetString ("(No Cameras Detected)"),
									"emblem-camera");
				item = new SourceItem (source);
				item.Activated += HandleActivated;
				item.Sensitive = false;
				this.Append (item);
			}
			/*
			this.Append (new Gtk.SeparatorMenuItem ());
			
			foreach (Gnome.Vfs.Drive drive in monitor.ConnectedDrives) {
				ImportSource source = new DriveSource (drive);
				
				Gtk.ImageMenuItem item = new SourceItem (source);
				item.Sensitive = drive.IsMounted;
				this.Append (item);
			}
			*/

			this.ShowAll ();
		}
		public CameraSource (GPhotoCamera cam, int index)
		{
			this.cam = cam;
			this.CameraIndex = index;

#if LONG_NAMES
			this.Name = String.Format ("{0} ({1})", cam.CameraList.GetName (index), cam.CameraList.GetValue (index));
#else
			this.Name = String.Format ("{0}", cam.CameraList.GetName (index));
#endif
			this.Icon = PixbufUtils.LoadThemeIcon ("gnome-dev-camera", 32);
			if (this.Icon == null)
				this.Icon = PixbufUtils.LoadThemeIcon ("gnome-dev-media-cf", 32);
		}
        public SourceMenu(ImportCommand command)
        {
            this.command = command;
            source_count = 0;

            SourceItem item = new SourceItem(new BrowseSource());

            item.Activated += HandleActivated;
            this.Append(item);
            this.Append(new Gtk.SeparatorMenuItem());

            // Add external hard drives to the menu
            foreach (Gnome.Vfs.Volume vol in monitor.MountedVolumes)
            {
                if (!vol.IsUserVisible || vol.DeviceType == Gnome.Vfs.DeviceType.Unknown)
                {
                    continue;
                }

                System.Console.WriteLine("{0} - {1} - {2} {3} {4} {5} {6}",
                                         vol.DisplayName,
                                         vol.Icon,
                                         vol.VolumeType.ToString(),
                                         vol.ActivationUri,
                                         vol.IsUserVisible,
                                         vol.IsMounted,
                                         vol.DeviceType);

                if (vol.Drive != null)
                {
                    System.Console.WriteLine(vol.Drive.DeviceType.ToString());
                }

                ImportSource source = new VolumeSource(vol);
                item            = new SourceItem(source);
                item.Activated += HandleActivated;
                this.Append(item);
                source_count++;
            }


            GPhotoCamera cam = new GPhotoCamera();

            cam.DetectCameras();
            int camera_count = cam.CameraList.Count();

            if (camera_count > 0)
            {
                source_count += camera_count;
                for (int i = 0; i < camera_count; i++)
                {
                    string handle = cam.CameraList.GetValue(i);
                    if (camera_count == 1 || handle != "usb:")
                    {
                        if (handle.StartsWith("disk:"))
                        {
                            string path = handle.Substring("disk:".Length);

                            if (FindItemPosition(path) != -1)
                            {
                                continue;
                            }
                        }

                        ImportSource source = new CameraSource(cam, i);
                        item            = new SourceItem(source);
                        item.Activated += HandleActivated;
                        this.Append(item);
                    }
                }
            }
            else
            {
                ImportSource source = new BrowseSource(Catalog.GetString("(No Cameras Detected)"),
                                                       "emblem-camera");
                item            = new SourceItem(source);
                item.Activated += HandleActivated;
                item.Sensitive  = false;
                this.Append(item);
            }

            /*
             * this.Append (new Gtk.SeparatorMenuItem ());
             *
             * foreach (Gnome.Vfs.Drive drive in monitor.ConnectedDrives) {
             *      ImportSource source = new DriveSource (drive);
             *
             *      Gtk.ImageMenuItem item = new SourceItem (source);
             *      item.Sensitive = drive.IsMounted;
             *      this.Append (item);
             * }
             */

            this.ShowAll();
        }
	public void ImportCamera (string camera_device)
	{
		GPhotoCamera cam = new GPhotoCamera();

		try {
			int num_cameras = cam.DetectCameras();
			int selected_cam = 0;

			if (num_cameras < 1) {
				HigMessageDialog md = new HigMessageDialog (main_window, DialogFlags.DestroyWithParent, 
					MessageType.Warning, ButtonsType.Ok, 
					Catalog.GetString ("No cameras detected."),
					Catalog.GetString ("F-Spot was unable to find any cameras attached to this system." + 
								      "  Double check that the camera is connected and has power")); 

				md.Run ();
				md.Destroy ();
				return;
			} else if (num_cameras == 1) {
				selected_cam = 0;
			} else {
				bool found = false;
				if (camera_device != null) {
					string port = camera_device.Remove (0, "gphoto2:".Length);
					for (int i = 0; i < num_cameras; i++)
						if (cam.CameraList.GetValue (i) == port) {
							selected_cam = i;
							found = true;
							break;
						}
				}
				
				if (!found) {
					FSpot.CameraSelectionDialog camselect = new FSpot.CameraSelectionDialog (cam.CameraList);
					selected_cam = camselect.Run ();
				}
			}

			if (selected_cam >= 0) {
				cam.SelectCamera (selected_cam);	
				cam.InitializeCamera ();

				FSpot.CameraFileSelectionDialog selector = new FSpot.CameraFileSelectionDialog (cam, db);
				if (selector.Run() > 0)
					query.RollSet = new RollSet (db.Rolls.GetRolls (1)[0]);
				UpdateQuery ();
			}
		}
		catch (GPhotoException ge) {
			System.Console.WriteLine (ge.ToString ());
			HigMessageDialog md = new HigMessageDialog (main_window, DialogFlags.DestroyWithParent, 
				MessageType.Error, ButtonsType.Ok, 
				Catalog.GetString ("Error connecting to camera"),
				String.Format (Catalog.GetString ("Received error \"{0}\" while connecting to camera"), 
				ge.Message));

			md.Run ();
			md.Destroy ();
		} finally {
			cam.ReleaseGPhotoResources ();
		}
	}
		public CameraSource (GPhotoCamera cam, int index)
		{
			this.cam = cam;
			this.CameraIndex = index;

#if LONG_NAMES
			this.Name = String.Format ("{0} ({1})", cam.CameraList.GetName (index), cam.CameraList.GetValue (index));
#else
			this.Name = String.Format ("{0}", cam.CameraList.GetName (index));
#endif
			this.Icon = GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "camera-photo", 32, (Gtk.IconLookupFlags)0);
			if (this.Icon == null)
				this.Icon = GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "media-flash", 32, (Gtk.IconLookupFlags)0);
		}