<commit_before>/*
 * gui.vala
 *
 * Copyright (c) 2011 <NAME>
 * Distributed under the New BSD License; see ../LICENSE for details.
 */
using Gee;
namespace XSIRC {
	public class GUI : Object {
		public static const string link_regex = "([a-z]+://[a-zA-Z0-9\\-.]+(:[0-9]+)?(/[a-zA-Z0-9\\-_$.+\\[\\]!*\\(),;:@&=?/~#%]+)?)";
		// GUI proper
		public Gtk.Window main_window {get; private set;}
		public Gtk.TreeView user_list {get; private set;}
		public Gtk.Label user_count {get; private set;}
		public Gtk.Label nickname {get; private set;}
		private Gtk.VBox user_list_box;
		private Gtk.Label no_servers_warning = new Gtk.Label(_("No servers! Connect to a server using Ctrl-Shift-O, or open the network list with Ctrl-N."));
		public Gtk.Notebook servers_notebook {get; private set;}
		public Gtk.Label nickname_label {get; private set;}
		public IRCEntry text_entry {get; private set;}
		public Gtk.Entry topic_view {get; private set;}
		//public View system_view {get; private set;}
		public bool has_quit {get; private set;}
		private const Gtk.ActionEntry[] menu_actions = {
			// Client
			{"ClientMenu",null,N_("_Client")},
			{"Networks",Gtk.Stock.NETWORK,N_("Networks list"),"<control>N",null,open_network_list_cb},
			{"Connect",Gtk.Stock.CONNECT,N_("_Connect..."),"<control><shift>O",N_("Connect to a server."),connect_server_cb},
			{"DisconnectAll",Gtk.Stock.DISCONNECT,N_("_Disconnect all"),null,null,disconnect_all_cb},
			{"ReconnectAll",Gtk.Stock.NETWORK,N_("_Reconnect all"),null,null,reconnect_all_cb},
			{"OpenLastLink",null,N_("_Open last link"),"F2",null,open_last_link_cb},
			{"OpenSLastLink",null,N_("O_pen sec-to-last link"),"<control>F2",null,open_sl_link_cb},
			{"Exit",Gtk.Stock.QUIT,null,null,null,quit_client_cb},
			// Edit
			{"EditMenu",null,N_("_Edit")},
			{"Bold",Gtk.Stock.BOLD,null,"<control>B",null,bold_cb},
			{"Italic",Gtk.Stock.ITALIC,null,"<control>I",null,italic_cb},
			{"Underlined",Gtk.Stock.UNDERLINE,null,"<control>U",null,underlined_cb},
			{"Color",Gtk.Stock.COLOR_PICKER,N_("_Color"),"<control>K",null,color_cb},
			{"RemoveFormatting",Gtk.Stock.CLEAR,N_("_Remove formatting"),"<control>R",null,remove_cb},
			// Settings
			{"SettingsMenu",null,N_("Se_ttings")},
			{"Preferences",Gtk.Stock.PREFERENCES,null,"<control><alt>P",null,spawn_preferences_cb},
			// View
			{"ViewMenu",null,N_("_View")},
			{"PrevServer",Gtk.Stock.GOTO_FIRST,N_("Previous server"),"<control><alt>comma",null,previous_server_cb},
			{"NextServer",Gtk.Stock.GOTO_LAST,N_("Next server"),"<control><alt>period",null,next_server_cb},
			{"PrevView",Gtk.Stock.GO_BACK,N_("Previous view"),"<control>comma",null,previous_view_cb},
			{"NextView",Gtk.Stock.GO_FORWARD,N_("Next view"),"<control>period",null,next_view_cb},
			{"CloseView",Gtk.Stock.CLOSE,N_("_Close view"),"<control>w",null,close_view_cb},
			{"RejoinChannel",Gtk.Stock.REFRESH,N_("Re_join channel"),null,null,rejoin_chan_cb},
			{"OpenView",Gtk.Stock.OPEN,N_("_Open view..."),"<control>o",null,open_view_cb},
			// These names never see the light of day, so there's no need to translate them
			{"View1",null,"View 1","<alt>1",null,change_view_cb},
			{"View2",null,"View 2","<alt>2",null,change_view_cb},
			{"View3",null,"View 3","<alt>3",null,change_view_cb},
			{"View4",null,"View 4","<alt>4",null,change_view_cb},
			{"View5",null,"View 5","<alt>5",null,change_view_cb},
			{"View6",null,"View 6","<alt>6",null,change_view_cb},
			{"View7",null,"View 7","<alt>7",null,change_view_cb},
			{"View8",null,"View 8","<alt>8",null,change_view_cb},
			{"View9",null,"View 9","<alt>9",null,change_view_cb},
			{"View10",null,"View 10","<alt>0",null,change_view_cb},
			// Server
			{"ServerMenu",null,N_("_Server")},
			{"Disconnect",Gtk.Stock.DISCONNECT,N_("_Disconnect"),"<control><shift>d",null,disconnect_server_cb},
			{"Reconnect",Gtk.Stock.CONNECT,N_("_Reconnect"),"<control><shift>r",null,reconnect_server_cb},
			{"CloseServer",Gtk.Stock.CLOSE,N_("_Close"),"<control><shift>w",null,close_server_cb},
			{"RejoinAll",Gtk.Stock.REFRESH,N_("Re_join all"),null,null,rejoin_all_cb},
			{"GoAway",null,N_("_Mark as away"),"<control><shift>a",null,go_away_cb},
			// Help
			{"HelpMenu",null,N_("_Help")},
			{"HelpContents",Gtk.Stock.HELP,N_("_Online help"),"F1",null,spawn_help_cb},
			{"About",Gtk.Stock.ABOUT,null,null,null,spawn_about_cb}
		};
		public Gtk.UIManager menu_ui {get; private set;}
		private string menu_ui_xml = """
<ui>
	<menubar name="MainMenu">
		<menu action="ClientMenu">
			<menuitem action="Networks"/>
			<menuitem action="Connect"/>
			<separator/>
			<menuitem action="DisconnectAll"/>
			<menuitem action="ReconnectAll"/>
			<separator/>
			<menuitem action="OpenLastLink"/>
			<menuitem action="OpenSLastLink"/>
			<separator/>
			<menuitem action="Exit"/>
		</menu>
		<menu action="EditMenu">
			<menuitem action="Bold"/>
			<menuitem action="Italic"/>
			<menuitem action="Underlined"/>
			<menuitem action="Color"/>
			<menuitem action="RemoveFormatting"/>
		</menu>
		<menu action="ViewMenu">
			<menuitem action="PrevServer"/>
			<menuitem action="NextServer"/>
			<separator/>
			<menuitem action="PrevView"/>
			<menuitem action="NextView"/>
			<menuitem action="CloseView"/>
			<menuitem action="RejoinChannel"/>
			<menuitem action="OpenView"/>
			<separator/>
			<menuitem action="View1"/>
			<menuitem action="View2"/>
			<menuitem action="View3"/>
			<menuitem action="View4"/>
			<menuitem action="View5"/>
			<menuitem action="View6"/>
			<menuitem action="View7"/>
			<menuitem action="View8"/>
			<menuitem action="View9"/>
			<menuitem action="View10"/>
		</menu>
		<menu action="ServerMenu">
			<menuitem action="Disconnect"/>
			<menuitem action="Reconnect"/>
			<menuitem action="CloseServer"/>
			<menuitem action="RejoinAll"/>
			<separator/>
			<menuitem action="GoAway"/>
		</menu>
		<menu action="SettingsMenu">
			<menuitem action="Preferences"/>
		</menu>
		<menu action="HelpMenu">
			<menuitem action="HelpContents"/>
			<menuitem action="About"/>
		</menu>
	</menubar>
</ui>""";
		private bool gui_updated = true;
		//private unowned Thread server_threads;
		public Mutex gui_mutex = new Mutex();
		private PrefDialog preferences_dialog = null;
		private NetworkList network_dialog = null;
		private Gtk.VBox server_vbox;
		private Gtk.HBox main_hbox;
		private Gtk.ScrolledWindow user_list_container;
		
		public class View {
			public string name;
			public Gtk.ScrolledWindow scrolled_window;
			public Gtk.TextView text_view;
			public Gtk.Label label;
			
			public View(string name) {
				this.name = name;
				
				label = new Gtk.Label(Markup.escape_text(name));
				label.use_markup = true;
				
				text_view = new Gtk.TextView();
				text_view.editable = false;
				text_view.cursor_visible = false;
				text_view.wrap_mode = Gtk.WrapMode.WORD;
				text_view.modify_font(Pango.FontDescription.from_string(Main.config.string["font"]));
				
				scrolled_window = new Gtk.ScrolledWindow(null,null);
				scrolled_window.vscrollbar_policy = Gtk.PolicyType.ALWAYS;
				scrolled_window.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
				scrolled_window.add(text_view);
			}
			
			public void add_text(string what) {
				string text;
				if(Main.config.bool["show_timestamps"]) {
					text = Main.gui.timestamp() + " "+what+"\n";
				} else {<commit_msg>Added indentation to wrapped lines<commit_after>/*
 * gui.vala
 *
 * Copyright (c) 2011 <NAME>
 * Distributed under the New BSD License; see ../LICENSE for details.
 */
using Gee;
namespace XSIRC {
	public class GUI : Object {
		public static const string link_regex = "([a-z]+://[a-zA-Z0-9\\-.]+(:[0-9]+)?(/[a-zA-Z0-9\\-_$.+\\[\\]!*\\(),;:@&=?/~#%]+)?)";
		// GUI proper
		public Gtk.Window main_window {get; private set;}
		public Gtk.TreeView user_list {get; private set;}
		public Gtk.Label user_count {get; private set;}
		public Gtk.Label nickname {get; private set;}
		private Gtk.VBox user_list_box;
		private Gtk.Label no_servers_warning = new Gtk.Label(_("No servers! Connect to a server using Ctrl-Shift-O, or open the network list with Ctrl-N."));
		public Gtk.Notebook servers_notebook {get; private set;}
		public Gtk.Label nickname_label {get; private set;}
		public IRCEntry text_entry {get; private set;}
		public Gtk.Entry topic_view {get; private set;}
		//public View system_view {get; private set;}
		public bool has_quit {get; private set;}
		private const Gtk.ActionEntry[] menu_actions = {
			// Client
			{"ClientMenu",null,N_("_Client")},
			{"Networks",Gtk.Stock.NETWORK,N_("Networks list"),"<control>N",null,open_network_list_cb},
			{"Connect",Gtk.Stock.CONNECT,N_("_Connect..."),"<control><shift>O",N_("Connect to a server."),connect_server_cb},
			{"DisconnectAll",Gtk.Stock.DISCONNECT,N_("_Disconnect all"),null,null,disconnect_all_cb},
			{"ReconnectAll",Gtk.Stock.NETWORK,N_("_Reconnect all"),null,null,reconnect_all_cb},
			{"OpenLastLink",null,N_("_Open last link"),"F2",null,open_last_link_cb},
			{"OpenSLastLink",null,N_("O_pen sec-to-last link"),"<control>F2",null,open_sl_link_cb},
			{"Exit",Gtk.Stock.QUIT,null,null,null,quit_client_cb},
			// Edit
			{"EditMenu",null,N_("_Edit")},
			{"Bold",Gtk.Stock.BOLD,null,"<control>B",null,bold_cb},
			{"Italic",Gtk.Stock.ITALIC,null,"<control>I",null,italic_cb},
			{"Underlined",Gtk.Stock.UNDERLINE,null,"<control>U",null,underlined_cb},
			{"Color",Gtk.Stock.COLOR_PICKER,N_("_Color"),"<control>K",null,color_cb},
			{"RemoveFormatting",Gtk.Stock.CLEAR,N_("_Remove formatting"),"<control>R",null,remove_cb},
			// Settings
			{"SettingsMenu",null,N_("Se_ttings")},
			{"Preferences",Gtk.Stock.PREFERENCES,null,"<control><alt>P",null,spawn_preferences_cb},
			// View
			{"ViewMenu",null,N_("_View")},
			{"PrevServer",Gtk.Stock.GOTO_FIRST,N_("Previous server"),"<control><alt>comma",null,previous_server_cb},
			{"NextServer",Gtk.Stock.GOTO_LAST,N_("Next server"),"<control><alt>period",null,next_server_cb},
			{"PrevView",Gtk.Stock.GO_BACK,N_("Previous view"),"<control>comma",null,previous_view_cb},
			{"NextView",Gtk.Stock.GO_FORWARD,N_("Next view"),"<control>period",null,next_view_cb},
			{"CloseView",Gtk.Stock.CLOSE,N_("_Close view"),"<control>w",null,close_view_cb},
			{"RejoinChannel",Gtk.Stock.REFRESH,N_("Re_join channel"),null,null,rejoin_chan_cb},
			{"OpenView",Gtk.Stock.OPEN,N_("_Open view..."),"<control>o",null,open_view_cb},
			// These names never see the light of day, so there's no need to translate them
			{"View1",null,"View 1","<alt>1",null,change_view_cb},
			{"View2",null,"View 2","<alt>2",null,change_view_cb},
			{"View3",null,"View 3","<alt>3",null,change_view_cb},
			{"View4",null,"View 4","<alt>4",null,change_view_cb},
			{"View5",null,"View 5","<alt>5",null,change_view_cb},
			{"View6",null,"View 6","<alt>6",null,change_view_cb},
			{"View7",null,"View 7","<alt>7",null,change_view_cb},
			{"View8",null,"View 8","<alt>8",null,change_view_cb},
			{"View9",null,"View 9","<alt>9",null,change_view_cb},
			{"View10",null,"View 10","<alt>0",null,change_view_cb},
			// Server
			{"ServerMenu",null,N_("_Server")},
			{"Disconnect",Gtk.Stock.DISCONNECT,N_("_Disconnect"),"<control><shift>d",null,disconnect_server_cb},
			{"Reconnect",Gtk.Stock.CONNECT,N_("_Reconnect"),"<control><shift>r",null,reconnect_server_cb},
			{"CloseServer",Gtk.Stock.CLOSE,N_("_Close"),"<control><shift>w",null,close_server_cb},
			{"RejoinAll",Gtk.Stock.REFRESH,N_("Re_join all"),null,null,rejoin_all_cb},
			{"GoAway",null,N_("_Mark as away"),"<control><shift>a",null,go_away_cb},
			// Help
			{"HelpMenu",null,N_("_Help")},
			{"HelpContents",Gtk.Stock.HELP,N_("_Online help"),"F1",null,spawn_help_cb},
			{"About",Gtk.Stock.ABOUT,null,null,null,spawn_about_cb}
		};
		public Gtk.UIManager menu_ui {get; private set;}
		private string menu_ui_xml = """
<ui>
	<menubar name="MainMenu">
		<menu action="ClientMenu">
			<menuitem action="Networks"/>
			<menuitem action="Connect"/>
			<separator/>
			<menuitem action="DisconnectAll"/>
			<menuitem action="ReconnectAll"/>
			<separator/>
			<menuitem action="OpenLastLink"/>
			<menuitem action="OpenSLastLink"/>
			<separator/>
			<menuitem action="Exit"/>
		</menu>
		<menu action="EditMenu">
			<menuitem action="Bold"/>
			<menuitem action="Italic"/>
			<menuitem action="Underlined"/>
			<menuitem action="Color"/>
			<menuitem action="RemoveFormatting"/>
		</menu>
		<menu action="ViewMenu">
			<menuitem action="PrevServer"/>
			<menuitem action="NextServer"/>
			<separator/>
			<menuitem action="PrevView"/>
			<menuitem action="NextView"/>
			<menuitem action="CloseView"/>
			<menuitem action="RejoinChannel"/>
			<menuitem action="OpenView"/>
			<separator/>
			<menuitem action="View1"/>
			<menuitem action="View2"/>
			<menuitem action="View3"/>
			<menuitem action="View4"/>
			<menuitem action="View5"/>
			<menuitem action="View6"/>
			<menuitem action="View7"/>
			<menuitem action="View8"/>
			<menuitem action="View9"/>
			<menuitem action="View10"/>
		</menu>
		<menu action="ServerMenu">
			<menuitem action="Disconnect"/>
			<menuitem action="Reconnect"/>
			<menuitem action="CloseServer"/>
			<menuitem action="RejoinAll"/>
			<separator/>
			<menuitem action="GoAway"/>
		</menu>
		<menu action="SettingsMenu">
			<menuitem action="Preferences"/>
		</menu>
		<menu action="HelpMenu">
			<menuitem action="HelpContents"/>
			<menuitem action="About"/>
		</menu>
	</menubar>
</ui>""";
		private bool gui_updated = true;
		//private unowned Thread server_threads;
		public Mutex gui_mutex = new Mutex();
		private PrefDialog preferences_dialog = null;
		private NetworkList network_dialog = null;
		private Gtk.VBox server_vbox;
		private Gtk.HBox main_hbox;
		private Gtk.ScrolledWindow user_list_container;
		
		public class View {
			public string name;
			public Gtk.ScrolledWindow scrolled_window;
			public Gtk.TextView text_view;
			public Gtk.Label label;
			
			public View(string name) {
				this.name = name;
				
				label = new Gtk.Label(Markup.escape_text(name));
				label.use_markup = true;
				
				text_view = new Gtk.TextView();
				text_view.editable = false;
				text_view.cursor_visible = false;
				text_view.wrap_mode = Gtk.WrapMode.WORD;
				text_view.modify_font(Pango.FontDescription.from_string(Main.config.string["font"]));
				text_view.indent = -20;
				
				scrolled_window = new Gtk.ScrolledWindow(null,null);
				scrolled_window.vscrollbar_policy = Gtk.PolicyType.ALWAYS;
				scrolled_window.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
				scrolled_window.add(text_view);
			}
			
			public void add_text(string what) {
				string text;
				if(Main.config.bool["show_timestamps"]) {
					text = Main.gui.timestamp() + " "+what+"\n";
				} else {
{'fraction_non_alphanumeric': 0.1857580919931857, 'fraction_numerical': 0.007768313458262351, 'mean_word_length': 5.375325803649001, 'pattern_counts': {'":': 0, '<': 197, '<?xml version=': 0, '>': 197, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '2072546', 'n_tokens_mistral': 6043, 'n_tokens_neox': 5372, 'n_words': 826}