<commit_before>using Gtk;
using Gdk;
using System;
using Mono.Unix;

using FSpot.Utils;
using FSpot.UI.Dialog;
using FSpot.Widgets;

namespace FSpot {
	public class SingleView {
		[Glade.Widget] Gtk.HBox toolbar_hbox;
		[Glade.Widget] Gtk.VBox info_vbox;
		[Glade.Widget] Gtk.ScrolledWindow image_scrolled;
		[Glade.Widget] Gtk.HPaned info_hpaned;

		Gtk.ScrolledWindow directory_scrolled;

		[Glade.Widget] Gtk.CheckMenuItem side_pane_item;
		[Glade.Widget] Gtk.CheckMenuItem toolbar_item;
		[Glade.Widget] Gtk.CheckMenuItem filenames_item;
		
		[Glade.Widget] Gtk.MenuItem zoom_in;
		[Glade.Widget] Gtk.MenuItem zoom_out;

		[Glade.Widget] Gtk.MenuItem export;

		[Glade.Widget] Gtk.Scale zoom_scale;

		[Glade.Widget] Label status_label;

		Sidebar sidebar;

		protected Glade.XML xml;
		private Gtk.Window window;
		PhotoImageView image_view;
		FSpot.Widgets.IconView directory_view;
		private Uri uri;
		
		InfoBox info_box;
		MetadataDisplay info_display;
		
		UriCollection collection;
		
		FullScreenView fsview;

		private static Gtk.Tooltips toolTips = new Gtk.Tooltips ();

		public SingleView () : this (FSpot.Global.HomeDirectory) {}


		public SingleView (string path) : this (UriUtils.PathToFileUri (path)) 
		{
		}

		public SingleView (Uri uri) : this (new Uri [] { uri })
		{
		}

		public SingleView (UriList list) : this (list.ToArray ())
		{
		}

		public SingleView (Uri [] uris) 
		{
			string glade_name = "single_view";
			this.uri = uris [0];
			
			System.Console.WriteLine ("uri = {0}", uri.ToString ());

			xml = new Glade.XML (null, "f-spot.glade", glade_name, "f-spot");
			xml.Autoconnect (this);
			window = (Gtk.Window) xml.GetWidget (glade_name);
		
			LoadPreference (Preferences.VIEWER_WIDTH);
			LoadPreference (Preferences.VIEWER_MAXIMIZED);

			Gtk.Toolbar toolbar = new Gtk.Toolbar ();
			toolbar_hbox.PackStart (toolbar);
		
			ToolButton rl_button = GtkUtil.ToolButtonFromTheme ("object-rotate-left", Catalog.GetString ("Rotate Left"), true);
			rl_button.Clicked += HandleRotate270Command;
			rl_button.SetTooltip (toolTips, Catalog.GetString ("Rotate photo left"), null);
			toolbar.Insert (rl_button, -1);

			ToolButton rr_button = GtkUtil.ToolButtonFromTheme ("object-rotate-right", Catalog.GetString ("Rotate Right"), true);
			rr_button.Clicked += HandleRotate90Command;
			rr_button.SetTooltip (toolTips, Catalog.GetString ("Rotate photo right"), null);
			toolbar.Insert (rr_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);

			collection = new UriCollection (uris);

			TargetEntry [] dest_table = {   new TargetEntry ("text/uri-list", 0, 0),
							new TargetEntry ("text/plain", 0, 1)};
			
			directory_view = new FSpot.Widgets.IconView (collection);
			directory_view.Selection.Changed += HandleSelectionChanged;
			directory_view.DragDataReceived += HandleDragDataReceived;
			Gtk.Drag.DestSet (directory_view, DestDefaults.All, dest_table, 
					DragAction.Copy | DragAction.Move); 
			directory_view.DisplayTags = false;
			directory_view.DisplayDates = false;
			directory_view.DisplayRatings = false;

			directory_scrolled = new ScrolledWindow();
			directory_scrolled.Add (directory_view);

			sidebar = new Sidebar ();

			info_vbox.Add (sidebar);
			sidebar.AppendPage (directory_scrolled, Catalog.GetString ("Folder"), "gtk-directory");

			info_display = new MetadataDisplay ();
			info_display.ParentSidebar = sidebar;
			sidebar.AppendPage (info_display, Catalog.GetString ("Exif"), "gtk-index");
 		
			info_box = new InfoBox ();
			info_box.ParentSidebar = sidebar;
			sidebar.AppendPage (info_box, Catalog.GetString ("Information"), "gtk-info");
			sidebar.CloseRequested += HandleHideSidePane;
			sidebar.Show ();

			ThumbnailGenerator.Default.OnPixbufLoaded += delegate { directory_view.QueueDraw (); };

			image_view = new PhotoImageView (collection);
			GtkUtil.ModifyColors (image_view);
			GtkUtil.ModifyColors (image_scrolled);
			image_view.ZoomChanged += HandleZoomChanged;
			image_view.Item.Changed += HandleItemChanged;
			image_view.ButtonPressEvent += HandleImageViewButtonPressEvent;
			image_view.DragDataReceived += HandleDragDataReceived;
			Gtk.Drag.DestSet (image_view, DestDefaults.All, dest_table,
					DragAction.Copy | DragAction.Move); 
			image_scrolled.Add (image_view);
			
			Window.ShowAll ();

			zoom_scale.ValueChanged += HandleZoomScaleValueChanged;
		
			LoadPreference (Preferences.VIEWER_SHOW_TOOLBAR);
 			LoadPreference (Preferences.VIEWER_INTERPOLATION);
			LoadPreference (Preferences.VIEWER_TRANSPARENCY);
			LoadPreference (Preferences.VIEWER_TRANS_COLOR);

			ShowSidebar = collection.Count > 1;

			LoadPreference (Preferences.VIEWER_SHOW_FILENAMES);

			Preferences.SettingChanged += OnPreferencesChanged;
			window.DeleteEvent += HandleDeleteEvent;
			
			collection.Changed += HandleCollectionChanged;

			// wrap the methods to fit to the delegate
			image_view.Item.Changed += delegate (BrowsablePointer pointer, BrowsablePointerChangedArgs old) {
															IBrowsableItem [] item = {pointer.Current};
															PhotoArray item_array = new PhotoArray (item);
															info_display.HandleSelectionChanged (item_array);
													};
			
			image_view.Item.Changed += delegate (BrowsablePointer pointer, BrowsablePointerChangedArgs old) {
															IBrowsableItem [] item = {pointer.Current};
															PhotoArray item_array = new PhotoArray (item);
															info_box.HandleSelectionChanged (item_array);
													};

			image_view.Item.Collection.ItemsChanged += info_box.HandleSelectionItemsChanged;
			image_view.Item.Collection.ItemsChanged += info_display.HandleSelectionItemsChanged;

			UpdateStatusLabel ();<commit_msg>temporary fix for --view mode crasher<commit_after>using Gtk;
using Gdk;
using System;
using Mono.Unix;

using FSpot.Utils;
using FSpot.UI.Dialog;
using FSpot.Widgets;

namespace FSpot {
	public class SingleView {
		[Glade.Widget] Gtk.HBox toolbar_hbox;
		[Glade.Widget] Gtk.VBox info_vbox;
		[Glade.Widget] Gtk.ScrolledWindow image_scrolled;
		[Glade.Widget] Gtk.HPaned info_hpaned;

		Gtk.ScrolledWindow directory_scrolled;

		[Glade.Widget] Gtk.CheckMenuItem side_pane_item;
		[Glade.Widget] Gtk.CheckMenuItem toolbar_item;
		[Glade.Widget] Gtk.CheckMenuItem filenames_item;
		
		[Glade.Widget] Gtk.MenuItem zoom_in;
		[Glade.Widget] Gtk.MenuItem zoom_out;

		[Glade.Widget] Gtk.MenuItem export;

		[Glade.Widget] Gtk.Scale zoom_scale;

		[Glade.Widget] Label status_label;

		Sidebar sidebar;

		protected Glade.XML xml;
		private Gtk.Window window;
		PhotoImageView image_view;
		FSpot.Widgets.IconView directory_view;
		private Uri uri;
		
		InfoBox info_box;
		MetadataDisplay info_display;
		
		UriCollection collection;
		
		FullScreenView fsview;

		private static Gtk.Tooltips toolTips = new Gtk.Tooltips ();

		public SingleView () : this (FSpot.Global.HomeDirectory) {}


		public SingleView (string path) : this (UriUtils.PathToFileUri (path)) 
		{
		}

		public SingleView (Uri uri) : this (new Uri [] { uri })
		{
		}

		public SingleView (UriList list) : this (list.ToArray ())
		{
		}

		public SingleView (Uri [] uris) 
		{
			string glade_name = "single_view";
			this.uri = uris [0];
			
			System.Console.WriteLine ("uri = {0}", uri.ToString ());

			xml = new Glade.XML (null, "f-spot.glade", glade_name, "f-spot");
			xml.Autoconnect (this);
			window = (Gtk.Window) xml.GetWidget (glade_name);
		
			LoadPreference (Preferences.VIEWER_WIDTH);
			LoadPreference (Preferences.VIEWER_MAXIMIZED);

			Gtk.Toolbar toolbar = new Gtk.Toolbar ();
			toolbar_hbox.PackStart (toolbar);
		
			ToolButton rl_button = GtkUtil.ToolButtonFromTheme ("object-rotate-left", Catalog.GetString ("Rotate Left"), true);
			rl_button.Clicked += HandleRotate270Command;
			rl_button.SetTooltip (toolTips, Catalog.GetString ("Rotate photo left"), null);
			toolbar.Insert (rl_button, -1);

			ToolButton rr_button = GtkUtil.ToolButtonFromTheme ("object-rotate-right", Catalog.GetString ("Rotate Right"), true);
			rr_button.Clicked += HandleRotate90Command;
			rr_button.SetTooltip (toolTips, Catalog.GetString ("Rotate photo right"), null);
			toolbar.Insert (rr_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);

			collection = new UriCollection (uris);

			TargetEntry [] dest_table = {   new TargetEntry ("text/uri-list", 0, 0),
							new TargetEntry ("text/plain", 0, 1)};
			
			directory_view = new FSpot.Widgets.IconView (collection);
			directory_view.Selection.Changed += HandleSelectionChanged;
			directory_view.DragDataReceived += HandleDragDataReceived;
			Gtk.Drag.DestSet (directory_view, DestDefaults.All, dest_table, 
					DragAction.Copy | DragAction.Move); 
			directory_view.DisplayTags = false;
			directory_view.DisplayDates = false;
			directory_view.DisplayRatings = false;

			directory_scrolled = new ScrolledWindow();
			directory_scrolled.Add (directory_view);

			sidebar = new Sidebar ();

			info_vbox.Add (sidebar);
			sidebar.AppendPage (directory_scrolled, Catalog.GetString ("Folder"), "gtk-directory");

			info_display = new MetadataDisplay ();
			info_display.ParentSidebar = sidebar;
			sidebar.AppendPage (info_display, Catalog.GetString ("Exif"), "gtk-index");
 		
			info_box = new InfoBox ();
			info_box.ParentSidebar = sidebar;
			sidebar.AppendPage (info_box, Catalog.GetString ("Information"), "gtk-info");
			sidebar.CloseRequested += HandleHideSidePane;
			sidebar.Show ();

			ThumbnailGenerator.Default.OnPixbufLoaded += delegate { directory_view.QueueDraw (); };

			image_view = new PhotoImageView (collection);
			GtkUtil.ModifyColors (image_view);
			GtkUtil.ModifyColors (image_scrolled);
			image_view.ZoomChanged += HandleZoomChanged;
			image_view.Item.Changed += HandleItemChanged;
			image_view.ButtonPressEvent += HandleImageViewButtonPressEvent;
			image_view.DragDataReceived += HandleDragDataReceived;
			Gtk.Drag.DestSet (image_view, DestDefaults.All, dest_table,
					DragAction.Copy | DragAction.Move); 
			image_scrolled.Add (image_view);
			
			Window.ShowAll ();

			zoom_scale.ValueChanged += HandleZoomScaleValueChanged;
		
			LoadPreference (Preferences.VIEWER_SHOW_TOOLBAR);
 			LoadPreference (Preferences.VIEWER_INTERPOLATION);
			LoadPreference (Preferences.VIEWER_TRANSPARENCY);
			LoadPreference (Preferences.VIEWER_TRANS_COLOR);

			ShowSidebar = collection.Count > 1;

			LoadPreference (Preferences.VIEWER_SHOW_FILENAMES);

			Preferences.SettingChanged += OnPreferencesChanged;
			window.DeleteEvent += HandleDeleteEvent;
			
			collection.Changed += HandleCollectionChanged;

			// wrap the methods to fit to the delegate
			image_view.Item.Changed += delegate (BrowsablePointer pointer, BrowsablePointerChangedArgs old) {
															IBrowsableItem [] item = {pointer.Current};
															PhotoArray item_array = new PhotoArray (item);
															//info_display.HandleSelectionChanged (item_array);
													};
			
			image_view.Item.Changed += delegate (BrowsablePointer pointer, BrowsablePointerChangedArgs old) {
															IBrowsableItem [] item = {pointer.Current};
															PhotoArray item_array = new PhotoArray (item);
															info_box.HandleSelectionChanged (item_array);
													};

			image_view.Item.Collection.ItemsChanged += info_box.HandleSelectionItemsChanged;
			image_view.Item.Collection.ItemsChanged += info_display.HandleSelectionItemsChanged;

			UpdateStatusLabel ();
{'fraction_non_alphanumeric': 0.1078805211312361, 'fraction_numerical': 0.0027009850651414044, 'mean_word_length': 4.289495798319328, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6371596', 'n_tokens_mistral': 4671, 'n_tokens_neox': 3856, 'n_words': 805}