<commit_before>/* gnome-property-entries.h - Property entries.

   Copyright (C) 1998 <NAME>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public License
   as published by the Free Software Foundation; either version 2, or
   (at your option) any later version.

   This program 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
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
   02111-1307, USA.
*/

#include <config.h>
#include <gnome.h>
#include "gnome-properties.h"

#include <gdk/gdkprivate.h>

/* =======================================================================
 * Font properties object.
 * =======================================================================
 */

typedef struct
{
	GdkFont **font_ptr;
	gchar **font_name_ptr;
	GdkFont *font;
	gchar *font_name;
} FontProperties;

typedef struct
{
	GtkWidget *entry;
	const gchar *label;
	GnomePropertyObject *object;
} FontCbData;

/* Properties callbacks. */

static void
_property_entry_font_load_temp (GnomePropertyObject *object)
{
	FontProperties *prop_ptr = object->prop_data;
	FontProperties *temp_ptr = object->temp_data;

	temp_ptr->font_name_ptr = &temp_ptr->font_name;
	temp_ptr->font_ptr = &temp_ptr->font;

	temp_ptr->font_name = g_strdup (*(prop_ptr->font_name_ptr));
	temp_ptr->font = *(prop_ptr->font_ptr);
	
	if (temp_ptr->font)
		gdk_font_ref (temp_ptr->font);
}

static gint
_property_entry_font_save_temp (GnomePropertyObject *object)
{
	FontProperties *prop_ptr = object->prop_data;
	FontProperties *temp_ptr = object->temp_data;

	g_free (*(prop_ptr->font_name_ptr));

	if (*(prop_ptr->font_ptr))
		gdk_font_unref (*(prop_ptr->font_ptr));

	*(prop_ptr->font_name_ptr) = g_strdup (temp_ptr->font_name);
	*(prop_ptr->font_ptr) = temp_ptr->font;

	if (*(prop_ptr->font_ptr))
		gdk_font_ref (*(prop_ptr->font_ptr));

	return FALSE;
}

static void
_property_entry_font_discard_temp (GnomePropertyObject *object)
{
	FontProperties *prop_ptr = object->prop_data;
	FontProperties *temp_ptr = object->temp_data;

	g_free (temp_ptr->font_name);

	if (temp_ptr->font)
		gdk_font_unref (temp_ptr->font);
}

/* The font was changed. */

static gint
_property_entry_font_apply (GtkFontSelectionDialog *fontsel)
{
	FontCbData *cb_data;
	FontProperties *temp_ptr;
	GtkWidget *entry;
	gchar *font_name;
	GdkFont *font;

	font_name = gtk_font_selection_dialog_get_font_name (fontsel);

	if (font_name == NULL) {
		gdk_beep ();
		return FALSE;
	}

	/* Make sure it is a valid font. */

	font = gdk_font_load (font_name);
	
	if (!font) {
		g_free (font_name);
		gdk_beep ();
		return FALSE;
	}

	cb_data = gtk_object_get_data (GTK_OBJECT (fontsel), "cb_data");
	temp_ptr = cb_data->object->temp_data;

	g_free (*(temp_ptr->font_name_ptr));
	if (*(temp_ptr->font_ptr))
		gdk_font_unref ((*temp_ptr->font_ptr));
	
	*(temp_ptr->font_name_ptr) = g_strdup (font_name);
	*(temp_ptr->font_ptr) = font;

	fprintf (stderr, "font_apply: %s\n", font_name);

	gtk_entry_set_text (GTK_ENTRY (cb_data->entry), font_name);

	gnome_property_object_changed (cb_data->object->user_data);

	return TRUE;
}

/* Callbacks for the Font selection dialog box. */

static void
_property_entry_font_cancel_cb (GtkWidget *widget, GtkWidget *fontsel)
{
	gtk_widget_destroy (fontsel);
}

static void
_property_entry_font_ok_cb (GtkWidget *widget, GtkWidget *fontsel)
{
	if (_property_entry_font_apply (GTK_FONT_SELECTION_DIALOG (fontsel)))
		gtk_widget_destroy (fontsel);
}

/* Font name entry was changed. */

static void
_property_entry_font_entry_cb (GtkWidget *widget, FontCbData *cb_data)
{
	GtkWidget *entry = cb_data->entry;<commit_msg>Removed a forgotten debugging statement.<commit_after>/* gnome-property-entries.h - Property entries.

   Copyright (C) 1998 <NAME>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public License
   as published by the Free Software Foundation; either version 2, or
   (at your option) any later version.

   This program 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
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
   02111-1307, USA.
*/

#include <config.h>
#include <gnome.h>
#include "gnome-properties.h"

#include <gdk/gdkprivate.h>

/* =======================================================================
 * Font properties object.
 * =======================================================================
 */

typedef struct
{
	GdkFont **font_ptr;
	gchar **font_name_ptr;
	GdkFont *font;
	gchar *font_name;
} FontProperties;

typedef struct
{
	GtkWidget *entry;
	const gchar *label;
	GnomePropertyObject *object;
} FontCbData;

/* Properties callbacks. */

static void
_property_entry_font_load_temp (GnomePropertyObject *object)
{
	FontProperties *prop_ptr = object->prop_data;
	FontProperties *temp_ptr = object->temp_data;

	temp_ptr->font_name_ptr = &temp_ptr->font_name;
	temp_ptr->font_ptr = &temp_ptr->font;

	temp_ptr->font_name = g_strdup (*(prop_ptr->font_name_ptr));
	temp_ptr->font = *(prop_ptr->font_ptr);
	
	if (temp_ptr->font)
		gdk_font_ref (temp_ptr->font);
}

static gint
_property_entry_font_save_temp (GnomePropertyObject *object)
{
	FontProperties *prop_ptr = object->prop_data;
	FontProperties *temp_ptr = object->temp_data;

	g_free (*(prop_ptr->font_name_ptr));

	if (*(prop_ptr->font_ptr))
		gdk_font_unref (*(prop_ptr->font_ptr));

	*(prop_ptr->font_name_ptr) = g_strdup (temp_ptr->font_name);
	*(prop_ptr->font_ptr) = temp_ptr->font;

	if (*(prop_ptr->font_ptr))
		gdk_font_ref (*(prop_ptr->font_ptr));

	return FALSE;
}

static void
_property_entry_font_discard_temp (GnomePropertyObject *object)
{
	FontProperties *prop_ptr = object->prop_data;
	FontProperties *temp_ptr = object->temp_data;

	g_free (temp_ptr->font_name);

	if (temp_ptr->font)
		gdk_font_unref (temp_ptr->font);
}

/* The font was changed. */

static gint
_property_entry_font_apply (GtkFontSelectionDialog *fontsel)
{
	FontCbData *cb_data;
	FontProperties *temp_ptr;
	GtkWidget *entry;
	gchar *font_name;
	GdkFont *font;

	font_name = gtk_font_selection_dialog_get_font_name (fontsel);

	if (font_name == NULL) {
		gdk_beep ();
		return FALSE;
	}

	/* Make sure it is a valid font. */

	font = gdk_font_load (font_name);
	
	if (!font) {
		g_free (font_name);
		gdk_beep ();
		return FALSE;
	}

	cb_data = gtk_object_get_data (GTK_OBJECT (fontsel), "cb_data");
	temp_ptr = cb_data->object->temp_data;

	g_free (*(temp_ptr->font_name_ptr));
	if (*(temp_ptr->font_ptr))
		gdk_font_unref ((*temp_ptr->font_ptr));
	
	*(temp_ptr->font_name_ptr) = g_strdup (font_name);
	*(temp_ptr->font_ptr) = font;

	gtk_entry_set_text (GTK_ENTRY (cb_data->entry), font_name);

	gnome_property_object_changed (cb_data->object->user_data);

	return TRUE;
}

/* Callbacks for the Font selection dialog box. */

static void
_property_entry_font_cancel_cb (GtkWidget *widget, GtkWidget *fontsel)
{
	gtk_widget_destroy (fontsel);
}

static void
_property_entry_font_ok_cb (GtkWidget *widget, GtkWidget *fontsel)
{
	if (_property_entry_font_apply (GTK_FONT_SELECTION_DIALOG (fontsel)))
		gtk_widget_destroy (fontsel);
}

/* Font name entry was changed. */

static void
_property_entry_font_entry_cb (GtkWidget *widget, FontCbData *cb_data)
{
	GtkWidget *entry = cb_data->entry;
{'fraction_non_alphanumeric': 0.14294662991731397, 'fraction_numerical': 0.00476071160110248, 'mean_word_length': 5.1979813664596275, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 89, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '2252635', 'n_tokens_mistral': 2902, 'n_tokens_neox': 2749, 'n_words': 686}