<commit_before>/*
* this file is part of the oxygen gtk engine
* Copyright (c) 2010 <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 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License  along  with  this library;  if not,  write to  the Free
* Software Foundation, Inc., 51  Franklin St, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/

#include "oxygentaboptions.h"
#include "oxygenstyleoptions.h"

#include <gtk/gtk.h>
#include <cmath>
namespace Oxygen
{

    //______________________________________________________________________
    TabOptions tabOptions( GtkWidget* widget, GtkStateType state, int x, int y )
    {

        TabOptions out( None );
        if( state != GTK_STATE_ACTIVE ) out |= CurrentTab;

        // try detect if tab is first or last
        if( GTK_IS_NOTEBOOK( widget ) )
        {

            GtkNotebook* notebook = GTK_NOTEBOOK( widget );

            int tabIndex;
            int minDistance( -1 );
            for( int i = 0; i < gtk_notebook_get_n_pages( notebook ); i++ )
            {

                // retrieve page and tab label
                GtkWidget* page( gtk_notebook_get_nth_page( notebook, i ) );
                GtkWidget* tabLabel( gtk_notebook_get_tab_label( notebook, page ) );

                // get allocted size
                const GtkAllocation& allocation( tabLabel->allocation );
                int distance = std::abs( double(allocation.x - x) ) + std::abs( double(allocation.y - y) );
                if( minDistance < 0 || distance < minDistance )
                {
                    minDistance = distance;
                    tabIndex = i;
                }
            }

            if( tabIndex == 0 ) out |= FirstTab;
            else if( tabIndex == gtk_notebook_get_n_pages( notebook ) - 1 ) out |= LastTab;

        }

        return out;
    }

<commit_msg>Some code cleanup<commit_after>/*
* this file is part of the oxygen gtk engine
* Copyright (c) 2010 <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 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License  along  with  this library;  if not,  write to  the Free
* Software Foundation, Inc., 51  Franklin St, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/

#include "oxygentaboptions.h"
#include "oxygenstyleoptions.h"

#include <gtk/gtk.h>
#include <cmath>
namespace Oxygen
{

    //______________________________________________________________________
    TabOptions tabOptions( GtkWidget* widget, GtkStateType state, int x, int y )
    {

        TabOptions out( None );
        if( state != GTK_STATE_ACTIVE ) out |= CurrentTab;

        // try detect if tab is first or last
        if( !GTK_IS_NOTEBOOK( widget ) ) return out;
        GtkNotebook* notebook = GTK_NOTEBOOK( widget );

        int tabIndex;
        int minDistance( -1 );
        for( int i = 0; i < gtk_notebook_get_n_pages( notebook ); i++ )
        {

            // retrieve page and tab label
            GtkWidget* page( gtk_notebook_get_nth_page( notebook, i ) );
            GtkWidget* tabLabel( gtk_notebook_get_tab_label( notebook, page ) );

            // get allocted size
            const GtkAllocation& allocation( tabLabel->allocation );
            int distance = std::abs( double(allocation.x - x) ) + std::abs( double(allocation.y - y) );
            if( minDistance < 0 || distance < minDistance )
            {
                minDistance = distance;
                tabIndex = i;
            }
        }

        if( tabIndex == 0 ) out |= FirstTab;
        else if( tabIndex == gtk_notebook_get_n_pages( notebook ) - 1 ) out |= LastTab;

        return out;
    }


{'fraction_non_alphanumeric': 0.08381939943832362, 'fraction_numerical': 0.009073233959818535, 'mean_word_length': 2.391941391941392, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 15, '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': '4705892', 'n_tokens_mistral': 1358, 'n_tokens_neox': 1289, 'n_words': 486}