<commit_before>/*
 Copyright (C) 2007-2009 <NAME> <<EMAIL>>

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

 See the file COPYING for the full license text.
*/

#include "katze-preferences.h"

#if HAVE_CONFIG_H
    #include <config.h>
#endif

#if HAVE_HILDON
    #include "katze-scrolled.h"
    #include <hildon/hildon.h>
#endif

#include <string.h>
#include <glib/gi18n.h>

struct _KatzePreferencesPrivate
{
    #if HAVE_HILDON
    GtkWidget* scrolled;
    GtkSizeGroup* sizegroup;
    GtkSizeGroup* sizegroup2;
    GtkWidget* box;
    GtkWidget* hbox;
    #else
    GtkWidget* notebook;
    GtkWidget* toolbar;
    GtkWidget* toolbutton;
    GtkSizeGroup* sizegroup;
    GtkSizeGroup* sizegroup2;
    GtkWidget* page;
    GtkWidget* frame;
    GtkWidget* box;
    GtkWidget* hbox;
    #endif
};

G_DEFINE_TYPE (KatzePreferences, katze_preferences, GTK_TYPE_DIALOG);

static void
katze_preferences_finalize (GObject* object);

static void
katze_preferences_class_init (KatzePreferencesClass* class)
{
    GObjectClass* gobject_class = G_OBJECT_CLASS (class);
    gobject_class->finalize = katze_preferences_finalize;

    g_type_class_add_private (class, sizeof (KatzePreferencesPrivate));
}

static void
katze_preferences_response_cb (KatzePreferences* preferences,
                               gint              response)
{
    if (response == GTK_RESPONSE_CLOSE || response == GTK_RESPONSE_APPLY)
        gtk_widget_destroy (GTK_WIDGET (preferences));
}

#ifdef HAVE_HILDON_2_2
static void
katze_preferences_size_request_cb (KatzePreferences* preferences,
                                   GtkRequisition*   requisition)
{
    GdkScreen* screen = gtk_widget_get_screen (GTK_WIDGET (preferences));
    if (gdk_screen_get_height (screen) > gdk_screen_get_width (screen))
        gtk_widget_hide (gtk_dialog_get_action_area (GTK_DIALOG (preferences)));
    else
        gtk_widget_show (gtk_dialog_get_action_area (GTK_DIALOG (preferences)));
}
#endif

static void
katze_preferences_init (KatzePreferences* preferences)
{
    KatzePreferencesPrivate* priv;
    gchar* dialog_title;

    preferences->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE ((preferences),
        KATZE_TYPE_PREFERENCES, KatzePreferencesPrivate);

    dialog_title = g_strdup_printf (_("Preferences for %s"),
                                    g_get_application_name ());
    g_object_set (preferences,
                  "icon-name", GTK_STOCK_PREFERENCES,
                  "title", dialog_title,
#if !GTK_CHECK_VERSION (3, 0, 0)
                  "has-separator", FALSE,
#endif
                  NULL);
    g_free (dialog_title);

    #if !HAVE_OSX
    gtk_dialog_add_buttons (GTK_DIALOG (preferences),
        GTK_STOCK_HELP, GTK_RESPONSE_HELP,
        #if HAVE_HILDON
        GTK_STOCK_SAVE, GTK_RESPONSE_APPLY,
        #else
        GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
        #endif
        NULL);
    #endif

    g_object_connect (preferences,
        "signal::response", katze_preferences_response_cb, NULL,
        NULL);

    #ifdef HAVE_HILDON_2_2
    katze_preferences_size_request_cb (preferences, NULL);
    g_object_connect (preferences,
        "signal::size-request", katze_preferences_size_request_cb, NULL,
        NULL);
    #endif
}

static void
katze_preferences_finalize (GObject* object)
{
    G_OBJECT_CLASS (katze_preferences_parent_class)->finalize (object);
}

/**
 * katze_preferences_new:
 * @parent: the parent window, or %NULL
 *
 * Creates a new preferences dialog.<commit_msg>Add help_button class to help in preferences<commit_after>/*
 Copyright (C) 2007-2009 <NAME> <<EMAIL>>

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

 See the file COPYING for the full license text.
*/

#include "katze-preferences.h"

#if HAVE_CONFIG_H
    #include <config.h>
#endif

#if HAVE_HILDON
    #include "katze-scrolled.h"
    #include <hildon/hildon.h>
#endif

#include <string.h>
#include <glib/gi18n.h>

struct _KatzePreferencesPrivate
{
    #if HAVE_HILDON
    GtkWidget* scrolled;
    GtkSizeGroup* sizegroup;
    GtkSizeGroup* sizegroup2;
    GtkWidget* box;
    GtkWidget* hbox;
    #else
    GtkWidget* notebook;
    GtkWidget* toolbar;
    GtkWidget* toolbutton;
    GtkSizeGroup* sizegroup;
    GtkSizeGroup* sizegroup2;
    GtkWidget* page;
    GtkWidget* frame;
    GtkWidget* box;
    GtkWidget* hbox;
    #endif
};

G_DEFINE_TYPE (KatzePreferences, katze_preferences, GTK_TYPE_DIALOG);

static void
katze_preferences_finalize (GObject* object);

static void
katze_preferences_class_init (KatzePreferencesClass* class)
{
    GObjectClass* gobject_class = G_OBJECT_CLASS (class);
    gobject_class->finalize = katze_preferences_finalize;

    g_type_class_add_private (class, sizeof (KatzePreferencesPrivate));
}

static void
katze_preferences_response_cb (KatzePreferences* preferences,
                               gint              response)
{
    if (response == GTK_RESPONSE_CLOSE || response == GTK_RESPONSE_APPLY)
        gtk_widget_destroy (GTK_WIDGET (preferences));
}

#ifdef HAVE_HILDON_2_2
static void
katze_preferences_size_request_cb (KatzePreferences* preferences,
                                   GtkRequisition*   requisition)
{
    GdkScreen* screen = gtk_widget_get_screen (GTK_WIDGET (preferences));
    if (gdk_screen_get_height (screen) > gdk_screen_get_width (screen))
        gtk_widget_hide (gtk_dialog_get_action_area (GTK_DIALOG (preferences)));
    else
        gtk_widget_show (gtk_dialog_get_action_area (GTK_DIALOG (preferences)));
}
#endif

static void
katze_preferences_init (KatzePreferences* preferences)
{
    KatzePreferencesPrivate* priv;
    gchar* dialog_title;

    preferences->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE ((preferences),
        KATZE_TYPE_PREFERENCES, KatzePreferencesPrivate);

    dialog_title = g_strdup_printf (_("Preferences for %s"),
                                    g_get_application_name ());
    g_object_set (preferences,
                  "icon-name", GTK_STOCK_PREFERENCES,
                  "title", dialog_title,
#if !GTK_CHECK_VERSION (3, 0, 0)
                  "has-separator", FALSE,
#endif
                  NULL);
    g_free (dialog_title);

    #if !HAVE_OSX
    gtk_dialog_add_buttons (GTK_DIALOG (preferences),
        GTK_STOCK_HELP, GTK_RESPONSE_HELP,
        NULL);
    #if GTK_CHECK_VERSION (3, 0, 0)
    gtk_style_context_add_class (gtk_widget_get_style_context (
        gtk_dialog_get_widget_for_response (GTK_DIALOG (preferences),
            GTK_RESPONSE_HELP)), "help_button");
    #endif

    gtk_dialog_add_buttons (GTK_DIALOG (preferences),
        #if HAVE_HILDON
        GTK_STOCK_SAVE, GTK_RESPONSE_APPLY,
        #else
        GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
        #endif
        NULL);
    #endif

    g_object_connect (preferences,
        "signal::response", katze_preferences_response_cb, NULL,
        NULL);

    #ifdef HAVE_HILDON_2_2
    katze_preferences_size_request_cb (preferences, NULL);
    g_object_connect (preferences,
        "signal::size-request", katze_preferences_size_request_cb, NULL,
        NULL);
    #endif
}

static void
katze_preferences_finalize (GObject* object)
{
    G_OBJECT_CLASS (katze_preferences_parent_class)->finalize (object);
}

/**
 * katze_preferences_new:
 * @parent: the parent window, or %NULL
 *
 * Creates a new preferences dialog.
{'fraction_non_alphanumeric': 0.0830848995463383, 'fraction_numerical': 0.005832793259883344, 'mean_word_length': 3.4549653579676676, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3187749', 'n_tokens_mistral': 2676, 'n_tokens_neox': 2576, 'n_words': 562}