<commit_before>/* -*- Mode: C++; indent-tabs-mode:nil; c-basic-offset:4; -*- */

/*
 *  gtkmm-utils - tile.cc
 *
 *  Copyright (C) 2007 <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 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; if not, write to the
 * Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#include <gdk/gdkkeysyms.h>
#include "tile.h"

namespace Gtk {

namespace Util {

/* Tile::Private */

class Tile::Private
{
public:
    explicit Private(const Glib::ustring& title,
                     const Glib::ustring& summary,
                     bool pack_center,
                     bool paint_white);
    ~Private() {}

    void set_title(const Glib::ustring& title);
    void set_summary(const Glib::ustring& summary);

    // Signals
    SignalSelection signal_focus_in_;
    SignalSelection signal_focus_out_;
    SignalSelection signal_selected_;
    SignalSelection signal_unselected_;
    SignalActivated signal_activated_;

    // Widgets
    Gtk::HBox  root_hbox_;
    Gtk::Image image_;
    Gtk::VBox  content_vbox_;
    Gtk::HBox  title_hbox_;
    Gtk::Label title_label_;
    Gtk::HBox  summary_hbox_;
    Gtk::Label summary_label_;

    // Data members
    Glib::ustring title_;
    Glib::ustring summary_;
    bool          pack_center_;
    bool          paint_white_;

private:
    Private(const Private& );
    Private& operator=(const Private& );
};

Tile::Private::Private(const Glib::ustring& title,
                       const Glib::ustring& summary,
                       bool pack_center,
                       bool paint_white)
    :
    root_hbox_(false, 10),
    image_(),
    content_vbox_(),
    title_hbox_(),
    title_label_(),
    summary_hbox_(),
    summary_label_(),
    pack_center_(pack_center),
    paint_white_(paint_white)
{
    // set up root hbox
    root_hbox_.set_border_width(5);

    // pack illustration image
    image_.show();
    root_hbox_.pack_start(image_, false, false);

    // prepare vbox to appear on the right hand side of the image
    content_vbox_.set_border_width(5);
    content_vbox_.set_spacing(4);

    // set up the title label
    set_title(title);

    // The way we currently pack the widgets, the ellipsize-ing has no effect.
    //title_label_.set_ellipsize(Pango::ELLIPSIZE_END);
    //title_label_.set_max_width_chars(10);
    title_label_.modify_fg(Gtk::STATE_NORMAL,
                           root_hbox_.get_style()->get_fg(
                               Gtk::STATE_INSENSITIVE));

    if (pack_center_) {
        content_vbox_.pack_start(title_label_, false, false);
     }
     else {
         // We achieve left-alignedness by packing a widget in a HBox.
         content_vbox_.pack_start(title_hbox_, false, false);
         title_hbox_.pack_start(title_label_, false, false);
     }

    // set up the summary label
    set_summary(summary);
    //summary_label_.set_ellipsize(Pango::ELLIPSIZE_END);
    //summary_label_.set_max_width_chars(100);
    summary_label_.modify_fg(Gtk::STATE_NORMAL,
                             root_hbox_.get_style()->get_fg(
                                 Gtk::STATE_INSENSITIVE));
    if (pack_center_) {
        content_vbox_.pack_start(summary_label_, false, false);
    }
    else {
        content_vbox_.pack_start(summary_hbox_, false, false);
        summary_hbox_.pack_start(summary_label_, false, false);
     }

    // wrap up
    content_vbox_.show_all();
    root_hbox_.pack_start(content_vbox_, pack_center_, pack_center_);
}

void
Tile::Private::set_title(const Glib::ustring& title)
{
    title_ = title;
    title_label_.set_markup("<span weight=\"bold\">" +
                            Glib::Markup::escape_text(title_) +
                            "</span>");
}

void<commit_msg>Make sure the text in labels is always left-aligned.<commit_after>/* -*- Mode: C++; indent-tabs-mode:nil; c-basic-offset:4; -*- */

/*
 *  gtkmm-utils - tile.cc
 *
 *  Copyright (C) 2007 <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 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; if not, write to the
 * Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#include <gdk/gdkkeysyms.h>
#include "tile.h"

namespace Gtk {

namespace Util {

/* Tile::Private */

class Tile::Private
{
public:
    explicit Private(const Glib::ustring& title,
                     const Glib::ustring& summary,
                     bool pack_center,
                     bool paint_white);
    ~Private() {}

    void set_title(const Glib::ustring& title);
    void set_summary(const Glib::ustring& summary);

    // Signals
    SignalSelection signal_focus_in_;
    SignalSelection signal_focus_out_;
    SignalSelection signal_selected_;
    SignalSelection signal_unselected_;
    SignalActivated signal_activated_;

    // Widgets
    Gtk::HBox  root_hbox_;
    Gtk::Image image_;
    Gtk::VBox  content_vbox_;
    Gtk::HBox  title_hbox_;
    Gtk::Label title_label_;
    Gtk::HBox  summary_hbox_;
    Gtk::Label summary_label_;

    // Data members
    Glib::ustring title_;
    Glib::ustring summary_;
    bool          pack_center_;
    bool          paint_white_;

private:
    Private(const Private& );
    Private& operator=(const Private& );
};

Tile::Private::Private(const Glib::ustring& title,
                       const Glib::ustring& summary,
                       bool pack_center,
                       bool paint_white)
    :
    root_hbox_(false, 10),
    image_(),
    content_vbox_(),
    title_hbox_(),
    title_label_(),
    summary_hbox_(),
    summary_label_(),
    pack_center_(pack_center),
    paint_white_(paint_white)
{
    // set up root hbox
    root_hbox_.set_border_width(5);

    // pack illustration image
    image_.show();
    root_hbox_.pack_start(image_, false, false);

    // prepare vbox to appear on the right hand side of the image
    content_vbox_.set_border_width(5);
    content_vbox_.set_spacing(4);

    // set up the title label
    set_title(title);

    title_label_.set_alignment(0.0);
    title_label_.modify_fg(Gtk::STATE_NORMAL,
                           root_hbox_.get_style()->get_fg(
                               Gtk::STATE_INSENSITIVE));

    if (pack_center_) {
        content_vbox_.pack_start(title_label_, false, false);
     }
     else {
         // We achieve left-alignedness by packing a widget in a HBox.
         content_vbox_.pack_start(title_hbox_, false, false);
         title_hbox_.pack_start(title_label_, false, false);
     }

    // set up the summary label
    set_summary(summary);
    summary_label_.set_alignment(0.0);
    summary_label_.modify_fg(Gtk::STATE_NORMAL,
                             root_hbox_.get_style()->get_fg(
                                 Gtk::STATE_INSENSITIVE));
    if (pack_center_) {
        content_vbox_.pack_start(summary_label_, false, false);
    }
    else {
        content_vbox_.pack_start(summary_hbox_, false, false);
        summary_hbox_.pack_start(summary_label_, false, false);
     }

    // wrap up
    content_vbox_.show_all();
    root_hbox_.pack_start(content_vbox_, pack_center_, pack_center_);
}

void
Tile::Private::set_title(const Glib::ustring& title)
{
    title_ = title;
    title_label_.set_markup("<span weight=\"bold\">" +
                            Glib::Markup::escape_text(title_) +
                            "</span>");
}

void
{'fraction_non_alphanumeric': 0.09892701332390048, 'fraction_numerical': 0.00624926305860158, 'mean_word_length': 2.624786324786325, 'pattern_counts': {'":': 0, '<': 11, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1261298', 'n_tokens_mistral': 2592, 'n_tokens_neox': 2518, 'n_words': 657}