<commit_before>/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * Copyright (C) 2009, Nokia
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA.
 *
 * Author: <NAME> <<EMAIL>>
 */

using Gtk;
using GLib;
using Tracker;

public static Config config = null;
public static IconConfig icon_config = null;

public const string HOME_STRING = "$HOME";

public static Window window;
public static CheckButton checkbutton_enable_index_on_battery_first_time;
public static CheckButton checkbutton_enable_index_on_battery;
public static SpinButton spinbutton_delay;
public static CheckButton checkbutton_enable_monitoring;
public static CheckButton checkbutton_index_mounted_directories;
public static CheckButton checkbutton_index_removable_media;
public static CheckButton checkbutton_index_optical_discs;
public static Scale hscale_disk_space_limit;
public static Scale hscale_throttle;
public static ListStore liststore_index_recursively;
public static ListStore liststore_index_single;
public static ListStore liststore_ignored_directories;
public static ListStore liststore_ignored_files;
public static ListStore liststore_gnored_directories_with_content;
public static TreeView treeview_index_recursively;
public static TreeView treeview_index_single;
public static TreeView treeview_ignored_directories;
public static TreeView treeview_ignored_directories_with_content;
public static TreeView treeview_ignored_files;
public static ToggleButton togglebutton_home;
public static RadioButton radiobutton_display_never;
public static RadioButton radiobutton_display_active;
public static RadioButton radiobutton_display_always;

public static void radiobutton_visibility_toggled_cb (RadioButton source) {
	if (radiobutton_display_never.active) {
		icon_config.visibility = 0;
	} else if (radiobutton_display_active.active) {
		icon_config.visibility = 1;
	} else {
		icon_config.visibility = 2;
	}
}

public static void initialize_visibility_radiobutton () {
	if (icon_config.visibility == 0) {
		radiobutton_display_never.active = true;
	} else if (icon_config.visibility == 1) {
		radiobutton_display_active.active = true;
	} else {
		radiobutton_display_always.active = true;
	}
}

public static void spinbutton_delay_value_changed_cb (SpinButton source) {
	config.initial_sleep = source.get_value_as_int ();
}

public static void checkbutton_enable_monitoring_toggled_cb (CheckButton source) {
	config.enable_monitors = source.active;
}

public static void checkbutton_enable_index_on_battery_toggled_cb (CheckButton source) {
	config.index_on_battery = source.active;
	checkbutton_enable_index_on_battery_first_time.set_sensitive (!source.active);
}

public static void checkbutton_enable_index_on_battery_first_time_toggled_cb (CheckButton source) {
	config.index_on_battery_first_time = source.active;
}

public static void checkbutton_index_mounted_directories_toggled_cb (CheckButton source) {
	config.index_mounted_directories = source.active;
}

public static void checkbutton_index_removable_media_toggled_cb (CheckButton source) {
	config.index_removable_devices = source.active;
	checkbutton_index_optical_discs.set_sensitive (source.active);
}

public static void checkbutton_index_optical_discs_toggled_cb (CheckButton source) {
	config.index_optical_discs = source.active;
}

public static string hscale_disk_space_limit_format_value_cb (Scale source, double value) {
	if (((int) value) == -1) {
		return _("Disabled");
	}

	return _("%d%%").printf ((int) value);
}

public static string hscale_throttle_format_value_cb (Scale source, double value) {
	return _("%d/20").printf ((int) value);
}

public static void add_freevalue (ListStore model) {
	Dialog dialog;
	Entry entry;
	Container content_area;

	dialog = new Dialog.with_buttons (_("Enter value"),
	                                  window,
	                                  DialogFlags.DESTROY_WITH_PARENT,
	                                  STOCK_CANCEL, ResponseType.CANCEL,
	                                  STOCK_OK, ResponseType.ACCEPT);

	content_area = (Container) dialog.get_content_area ();
	entry = new Entry ();
	entry.show ();
	content_area.add (entry);

	if (dialog.run () == ResponseType.ACCEPT) {
		string text = entry.get_text ();

		if (text != null && text != "") {
			TreeIter iter;
			model.append (out iter);
			var v = Value (typeof (string));
			v.set_string (text);
			model.set_value (iter, 0, v);
		}
	}

	dialog.destroy ();
}


public static void add_dir (ListStore model)
{
	FileChooserDialog dialog = new FileChooserDialog (_("Select directory"), window,
	                                              FileChooserAction.SELECT_FOLDER,<commit_msg>tracker-preferences: improvements to the ignored_dirs gtkentry UI<commit_after>/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * Copyright (C) 2009, Nokia
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA.
 *
 * Author: <NAME> <<EMAIL>>
 */

using Gtk;
using GLib;
using Tracker;

public static Config config = null;
public static IconConfig icon_config = null;

public const string HOME_STRING = "$HOME";

public static Window window;
public static CheckButton checkbutton_enable_index_on_battery_first_time;
public static CheckButton checkbutton_enable_index_on_battery;
public static SpinButton spinbutton_delay;
public static CheckButton checkbutton_enable_monitoring;
public static CheckButton checkbutton_index_mounted_directories;
public static CheckButton checkbutton_index_removable_media;
public static CheckButton checkbutton_index_optical_discs;
public static Scale hscale_disk_space_limit;
public static Scale hscale_throttle;
public static ListStore liststore_index_recursively;
public static ListStore liststore_index_single;
public static ListStore liststore_ignored_directories;
public static ListStore liststore_ignored_files;
public static ListStore liststore_gnored_directories_with_content;
public static TreeView treeview_index_recursively;
public static TreeView treeview_index_single;
public static TreeView treeview_ignored_directories;
public static TreeView treeview_ignored_directories_with_content;
public static TreeView treeview_ignored_files;
public static ToggleButton togglebutton_home;
public static RadioButton radiobutton_display_never;
public static RadioButton radiobutton_display_active;
public static RadioButton radiobutton_display_always;

public static void radiobutton_visibility_toggled_cb (RadioButton source) {
	if (radiobutton_display_never.active) {
		icon_config.visibility = 0;
	} else if (radiobutton_display_active.active) {
		icon_config.visibility = 1;
	} else {
		icon_config.visibility = 2;
	}
}

public static void initialize_visibility_radiobutton () {
	if (icon_config.visibility == 0) {
		radiobutton_display_never.active = true;
	} else if (icon_config.visibility == 1) {
		radiobutton_display_active.active = true;
	} else {
		radiobutton_display_always.active = true;
	}
}

public static void spinbutton_delay_value_changed_cb (SpinButton source) {
	config.initial_sleep = source.get_value_as_int ();
}

public static void checkbutton_enable_monitoring_toggled_cb (CheckButton source) {
	config.enable_monitors = source.active;
}

public static void checkbutton_enable_index_on_battery_toggled_cb (CheckButton source) {
	config.index_on_battery = source.active;
	checkbutton_enable_index_on_battery_first_time.set_sensitive (!source.active);
}

public static void checkbutton_enable_index_on_battery_first_time_toggled_cb (CheckButton source) {
	config.index_on_battery_first_time = source.active;
}

public static void checkbutton_index_mounted_directories_toggled_cb (CheckButton source) {
	config.index_mounted_directories = source.active;
}

public static void checkbutton_index_removable_media_toggled_cb (CheckButton source) {
	config.index_removable_devices = source.active;
	checkbutton_index_optical_discs.set_sensitive (source.active);
}

public static void checkbutton_index_optical_discs_toggled_cb (CheckButton source) {
	config.index_optical_discs = source.active;
}

public static string hscale_disk_space_limit_format_value_cb (Scale source, double value) {
	if (((int) value) == -1) {
		return _("Disabled");
	}

	return _("%d%%").printf ((int) value);
}

public static string hscale_throttle_format_value_cb (Scale source, double value) {
	return _("%d/20").printf ((int) value);
}

public static void add_freevalue (ListStore model) {
	Dialog dialog;
	Entry entry;
	Container content_area;

	dialog = new Dialog.with_buttons (_("Enter value"),
	                                  window,
	                                  DialogFlags.DESTROY_WITH_PARENT | DialogFlags.NO_SEPARATOR,
	                                  STOCK_CANCEL, ResponseType.CANCEL,
	                                  STOCK_OK, ResponseType.ACCEPT);

	dialog.set_default_response(ResponseType.ACCEPT);
	content_area = (Container) dialog.get_content_area ();
	entry = new Entry ();
	entry.set_activates_default (true);
	entry.show ();
	content_area.add (entry);

	if (dialog.run () == ResponseType.ACCEPT) {
		string text = entry.get_text ();

		if (text != null && text != "") {
			TreeIter iter;
			model.append (out iter);
			var v = Value (typeof (string));
			v.set_string (text);
			model.set_value (iter, 0, v);
		}
	}

	dialog.destroy ();
}


public static void add_dir (ListStore model)
{
	FileChooserDialog dialog = new FileChooserDialog (_("Select directory"), window,
	                                              FileChooserAction.SELECT_FOLDER,
{'fraction_non_alphanumeric': 0.07444556915432042, 'fraction_numerical': 0.004969172724763044, 'mean_word_length': 4.877771768523527, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3427535', 'n_tokens_mistral': 3341, 'n_tokens_neox': 3160, 'n_words': 899}