<commit_before>
# --------------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# <<EMAIL>> wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return -<NAME>
# --------------------------------------------------------------------------------

import os
import sys
import gtk
import gconf
import pango

DEFAULT = """\\documentclass{article}
\\begin{document}

\\noindent\huge{Welcome to Gummi} \\\\
\\\\
\\large	{You are using the svn version.\\\\
	I welcome your suggestions at:\\\\
	http://code.google.com/p/gummi\\\\
\\\\
\\end{document}"""

GCONFPATH = "/apps/gummi/"

class prefs:
	
	def __init__(self, parent):
		self.parent = parent
		self.gconf_client = gconf.client_get_default()		
		
		firstrun = self.gconf_client.get_string(GCONFPATH + "set_defaults")
		if firstrun is None:
			self.set_defaults()


	def get_config_value(self, type, item):
		if type == "string":
			configitem = self.gconf_client.get_string(GCONFPATH + item)
			return configitem
		if type == "list":
			configitem = self.gconf_client.get_list(GCONFPATH + item)
			return configitem
		if type == "bool":		
			configitem = self.gconf_client.get_bool(GCONFPATH + item)		
			return configitem


	def set_config_bool(self, item, value):
		self.gconf_client.set_bool(GCONFPATH + item, value)

	def set_config_string(self, item, value):
		self.gconf_client.set_string(GCONFPATH + item, value)

	def set_config_list(self, item, value):
		self.gconf_client.set_list(GCONFPATH + item, value)


	def create_gui(self):
		builder = gtk.Builder()	
		builder.add_from_file(self.parent.installdir + "/gui/prefs.xml")
		builder.connect_signals(self)

		self.prefwindow = builder.get_object("prefwindow")
		self.prefwindow.set_transient_for(self.parent.mainwindow)

		self.box = builder.get_object("hbox1")
		self.notebook = builder.get_object("notebook1")
		self.box.pack_start(self.notebook, expand=False)

		self.button_textwrap = builder.get_object("button_textwrap")
		self.button_wordwrap = builder.get_object("button_wordwrap")
		self.button_linenumbers = builder.get_object("button_linenumbers")
		self.button_highlighting = builder.get_object("button_highlighting")
		self.default_textfield = builder.get_object("default_textfield")

		self.default_textfield.modify_font(pango.FontDescription("monospace 10"))
		self.default_buffer = self.default_textfield.get_buffer()
		self.default_buffer.set_text(self.get_config_value("string", "tex_defaulttext"))

		self.check_current_setting(self.button_textwrap, "tex_textwrapping")
		self.check_current_setting(self.button_wordwrap, "tex_wordwrapping")
		self.check_current_setting(self.button_linenumbers, "tex_linenumbers")
		self.check_current_setting(self.button_highlighting, "tex_highlighting")

		self.button_textwrap.connect("toggled", self.toggle_button, "tex_textwrapping")
		self.button_wordwrap.connect("toggled", self.toggle_button, "tex_wordwrapping")
		self.button_linenumbers.connect("toggled", self.toggle_button, "tex_linenumbers")
		self.button_highlighting.connect("toggled", self.toggle_button, "tex_highlighting")
		<commit_msg>fixed a gtkwarning in preferences<commit_after>
# --------------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# <<EMAIL>> wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return -<NAME>
# --------------------------------------------------------------------------------

import os
import sys
import gtk
import gconf
import pango

DEFAULT = """\\documentclass{article}
\\begin{document}

\\noindent\huge{Welcome to Gummi} \\\\
\\\\
\\large	{You are using the svn version.\\\\
	I welcome your suggestions at:\\\\
	http://code.google.com/p/gummi\\\\
\\\\
\\end{document}"""

GCONFPATH = "/apps/gummi/"

class prefs:
	
	def __init__(self, parent):
		self.parent = parent
		self.gconf_client = gconf.client_get_default()		
		
		firstrun = self.gconf_client.get_string(GCONFPATH + "set_defaults")
		if firstrun is None:
			self.set_defaults()


	def get_config_value(self, type, item):
		if type == "string":
			configitem = self.gconf_client.get_string(GCONFPATH + item)
			return configitem
		if type == "list":
			configitem = self.gconf_client.get_list(GCONFPATH + item)
			return configitem
		if type == "bool":		
			configitem = self.gconf_client.get_bool(GCONFPATH + item)		
			return configitem


	def set_config_bool(self, item, value):
		self.gconf_client.set_bool(GCONFPATH + item, value)

	def set_config_string(self, item, value):
		self.gconf_client.set_string(GCONFPATH + item, value)

	def set_config_list(self, item, value):
		self.gconf_client.set_list(GCONFPATH + item, value)


	def create_gui(self):
		builder = gtk.Builder()	
		builder.add_from_file(self.parent.installdir + "/gui/prefs.xml")
		builder.connect_signals(self)

		self.prefwindow = builder.get_object("prefwindow")
		self.prefwindow.set_transient_for(self.parent.mainwindow)

		#self.box = builder.get_object("hbox1")
		self.notebook = builder.get_object("notebook1")
		#self.box.pack_start(self.notebook, expand=False)

		self.button_textwrap = builder.get_object("button_textwrap")
		self.button_wordwrap = builder.get_object("button_wordwrap")
		self.button_linenumbers = builder.get_object("button_linenumbers")
		self.button_highlighting = builder.get_object("button_highlighting")
		self.default_textfield = builder.get_object("default_textfield")

		self.default_textfield.modify_font(pango.FontDescription("monospace 10"))
		self.default_buffer = self.default_textfield.get_buffer()
		self.default_buffer.set_text(self.get_config_value("string", "tex_defaulttext"))

		self.check_current_setting(self.button_textwrap, "tex_textwrapping")
		self.check_current_setting(self.button_wordwrap, "tex_wordwrapping")
		self.check_current_setting(self.button_linenumbers, "tex_linenumbers")
		self.check_current_setting(self.button_highlighting, "tex_highlighting")

		self.button_textwrap.connect("toggled", self.toggle_button, "tex_textwrapping")
		self.button_wordwrap.connect("toggled", self.toggle_button, "tex_wordwrapping")
		self.button_linenumbers.connect("toggled", self.toggle_button, "tex_linenumbers")
		self.button_highlighting.connect("toggled", self.toggle_button, "tex_highlighting")
		
{'fraction_non_alphanumeric': 0.16432068543451653, 'fraction_numerical': 0.0018359853121175031, 'mean_word_length': 3.9711026615969582, 'pattern_counts': {'":': 6, '<': 9, '<?xml version=': 0, '>': 9, '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': '1946302', 'n_tokens_mistral': 2290, 'n_tokens_neox': 2115, 'n_words': 400}