<commit_before>/*
 * panel-separator.c: panel "Separator" module
 *
 * Copyright (C) 2005 <NAME> <<EMAIL>>
 *
 * This program 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 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
 * General Public License for more details.
 *
 * You should have received a copy of the GNU 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.
 *
 * Authors:
 *      <NAME> <<EMAIL>>
 */

#include <config.h>

#include "panel-separator.h"
#include "panel-background.h"
#include "panel-profile.h"

#define SEPARATOR_SIZE 10

#define PANEL_SEPARATOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_SEPARATOR, PanelSeparatorPrivate))

struct _PanelSeparatorPrivate {
	AppletInfo     *info;
	PanelWidget    *panel;

	GtkOrientation  orientation;
};

G_DEFINE_TYPE (PanelSeparator, panel_separator, GTK_TYPE_EVENT_BOX)

static gboolean
panel_separator_draw (GtkWidget *widget,
                      cairo_t   *cr)
{
        PanelSeparator  *separator = PANEL_SEPARATOR (widget);
        GdkWindow       *window;
        GtkStyleContext *context;
        GtkStateFlags    state;
        GtkBorder        padding;
        int              width, height;

        if (GTK_WIDGET_CLASS (panel_separator_parent_class)->draw)
                GTK_WIDGET_CLASS (panel_separator_parent_class)->draw (widget, cr);

	window = gtk_widget_get_window (widget);
        state = gtk_widget_get_state_flags (widget);
        width = gtk_widget_get_allocated_width (widget);
        height = gtk_widget_get_allocated_height (widget);

        context = gtk_widget_get_style_context (widget);
        gtk_style_context_get_padding (context, state, &padding);

        gtk_style_context_save (context);
        gtk_style_context_set_state (context, state);

        cairo_save (cr);
	if (separator->priv->orientation == GTK_ORIENTATION_HORIZONTAL) {
                gtk_render_line (context, cr,
                                 (width - padding.left) / 2, 0,
                                 (width - padding.left) / 2, height - 1);
	} else {
                gtk_render_line (context, cr,
                                 0, (height - padding.top) / 2,
                                 width - 1, (height - padding.top) / 2);
	}
        cairo_restore (cr);

        gtk_style_context_restore (context);

	return FALSE;
}

static void
panel_separator_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width)
{
	PanelSeparator *separator;
	int             size;

	separator = PANEL_SEPARATOR (widget);

	size = panel_toplevel_get_size (separator->priv->panel->toplevel);

	if (separator->priv->orientation == GTK_ORIENTATION_VERTICAL)
		*minimal_width = *natural_width = size;
	else
		*minimal_width = *natural_width = SEPARATOR_SIZE;
}

static void
panel_separator_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height)
{
	PanelSeparator *separator;
	int             size;

	separator = PANEL_SEPARATOR (widget);

	size = panel_toplevel_get_size (separator->priv->panel->toplevel);

	if (separator->priv->orientation == GTK_ORIENTATION_VERTICAL)
		*minimal_height = *natural_height = SEPARATOR_SIZE;
	else
		*minimal_height = *natural_height = size;
}

static void
panel_separator_size_allocate (GtkWidget     *widget,
			       GtkAllocation *allocation)
{
	GtkAllocation    old_allocation;
	GtkAllocation    widget_allocation;
	PanelBackground *background;

	gtk_widget_get_allocation (widget, &widget_allocation);
<commit_msg>panel: Draw the separator line where it should<commit_after>/*
 * panel-separator.c: panel "Separator" module
 *
 * Copyright (C) 2005 <NAME> <<EMAIL>>
 *
 * This program 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 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
 * General Public License for more details.
 *
 * You should have received a copy of the GNU 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.
 *
 * Authors:
 *      <NAME> <<EMAIL>>
 */

#include <config.h>

#include "panel-separator.h"
#include "panel-background.h"
#include "panel-profile.h"

#define SEPARATOR_SIZE 10

#define PANEL_SEPARATOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_SEPARATOR, PanelSeparatorPrivate))

struct _PanelSeparatorPrivate {
	AppletInfo     *info;
	PanelWidget    *panel;

	GtkOrientation  orientation;
};

G_DEFINE_TYPE (PanelSeparator, panel_separator, GTK_TYPE_EVENT_BOX)

static gboolean
panel_separator_draw (GtkWidget *widget,
                      cairo_t   *cr)
{
        PanelSeparator  *separator = PANEL_SEPARATOR (widget);
        GdkWindow       *window;
        GtkStyleContext *context;
        GtkStateFlags    state;
        GtkBorder        padding;
        int              width, height;

        if (GTK_WIDGET_CLASS (panel_separator_parent_class)->draw)
                GTK_WIDGET_CLASS (panel_separator_parent_class)->draw (widget, cr);

	window = gtk_widget_get_window (widget);
        state = gtk_widget_get_state_flags (widget);
        width = gtk_widget_get_allocated_width (widget);
        height = gtk_widget_get_allocated_height (widget);

        context = gtk_widget_get_style_context (widget);
        gtk_style_context_get_padding (context, state, &padding);

        gtk_style_context_save (context);
        gtk_style_context_set_state (context, state);

        cairo_save (cr);
	if (separator->priv->orientation == GTK_ORIENTATION_HORIZONTAL) {
                int x;

                x= (width - padding.left - padding.right) / 2 + padding.left;
                x = MIN (x, width - padding.right);

                gtk_render_line (context, cr,
                                 x, padding.top,
                                 x, height - padding.bottom);
	} else {
                int y;

                y = (height - padding.top - padding.bottom) / 2 + padding.top;
                y = MIN (y, height - padding.bottom);

                gtk_render_line (context, cr,
                                 padding.left, y,
                                 width - padding.right, y);
	}
        cairo_restore (cr);

        gtk_style_context_restore (context);

	return FALSE;
}

static void
panel_separator_get_preferred_width (GtkWidget *widget,
				     gint      *minimal_width,
				     gint      *natural_width)
{
	PanelSeparator *separator;
	int             size;

	separator = PANEL_SEPARATOR (widget);

	size = panel_toplevel_get_size (separator->priv->panel->toplevel);

	if (separator->priv->orientation == GTK_ORIENTATION_VERTICAL)
		*minimal_width = *natural_width = size;
	else
		*minimal_width = *natural_width = SEPARATOR_SIZE;
}

static void
panel_separator_get_preferred_height (GtkWidget *widget,
				      gint      *minimal_height,
				      gint      *natural_height)
{
	PanelSeparator *separator;
	int             size;

	separator = PANEL_SEPARATOR (widget);

	size = panel_toplevel_get_size (separator->priv->panel->toplevel);

	if (separator->priv->orientation == GTK_ORIENTATION_VERTICAL)
		*minimal_height = *natural_height = SEPARATOR_SIZE;
	else
		*minimal_height = *natural_height = size;
}

static void
panel_separator_size_allocate (GtkWidget     *widget,
			       GtkAllocation *allocation)
{
	GtkAllocation    old_allocation;
	GtkAllocation    widget_allocation;
	PanelBackground *background;

	gtk_widget_get_allocation (widget, &widget_allocation);

{'fraction_non_alphanumeric': 0.08585613950108985, 'fraction_numerical': 0.006296924194720271, 'mean_word_length': 2.984081041968162, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '217448', 'n_tokens_mistral': 2644, 'n_tokens_neox': 2452, 'n_words': 659}