2022-01-20 18:27:56 +00:00
|
|
|
// This file Copyright © 2007-2022 Mnemosyne LLC.
|
|
|
|
// It may be used under GPLv2 (SPDX: GPL-2.0), GPLv3 (SPDX: GPL-3.0),
|
|
|
|
// or any future license endorsed by Mnemosyne LLC.
|
|
|
|
// License text can be found in the licenses/ folder.
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
#include <libtransmission/tr-macros.h>
|
|
|
|
|
2021-11-01 00:11:23 +00:00
|
|
|
#include "HigWorkarea.h"
|
|
|
|
#include "Utils.h"
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
HigWorkarea::HigWorkarea()
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2021-10-18 20:22:31 +00:00
|
|
|
set_border_width(GUI_PAD_BIG);
|
|
|
|
set_row_spacing(GUI_PAD);
|
|
|
|
set_column_spacing(GUI_PAD_BIG);
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
void HigWorkarea::add_section_divider(guint& row)
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2021-10-18 20:22:31 +00:00
|
|
|
auto* w = Gtk::make_managed<Gtk::Fixed>();
|
|
|
|
w->set_size_request(0U, 6U);
|
|
|
|
attach(*w, 0, row, 2, 1);
|
|
|
|
++row;
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
void HigWorkarea::add_section_title_widget(guint& row, Gtk::Widget& w)
|
2008-06-02 04:41:55 +00:00
|
|
|
{
|
2021-10-18 20:22:31 +00:00
|
|
|
w.set_hexpand(true);
|
|
|
|
attach(w, 0, row, 2, 1);
|
|
|
|
++row;
|
2008-06-02 04:41:55 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
void HigWorkarea::add_section_title(guint& row, Glib::ustring const& section_title)
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2021-10-18 20:22:31 +00:00
|
|
|
auto* l = Gtk::make_managed<Gtk::Label>(gtr_sprintf("<b>%s</b>", section_title));
|
|
|
|
l->set_halign(Gtk::ALIGN_START);
|
|
|
|
l->set_valign(Gtk::ALIGN_CENTER);
|
|
|
|
l->set_use_markup(true);
|
|
|
|
add_section_title_widget(row, *l);
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
void HigWorkarea::add_wide_control(guint& row, Gtk::Widget& w)
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2021-10-18 20:22:31 +00:00
|
|
|
w.set_hexpand(true);
|
|
|
|
w.set_margin_start(18);
|
|
|
|
attach(w, 0, row, 2, 1);
|
|
|
|
++row;
|
2007-12-13 19:54:24 +00:00
|
|
|
}
|
2019-07-14 21:30:14 +00:00
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
void HigWorkarea::add_wide_tall_control(guint& row, Gtk::Widget& w)
|
2009-10-28 03:54:36 +00:00
|
|
|
{
|
2021-10-18 20:22:31 +00:00
|
|
|
w.set_hexpand(true);
|
|
|
|
w.set_vexpand(true);
|
|
|
|
add_wide_control(row, w);
|
2009-10-28 03:54:36 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
Gtk::CheckButton* HigWorkarea::add_wide_checkbutton(guint& row, Glib::ustring const& mnemonic_string, bool is_active)
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2021-10-18 20:22:31 +00:00
|
|
|
auto* w = Gtk::make_managed<Gtk::CheckButton>(mnemonic_string, true);
|
|
|
|
w->set_active(is_active);
|
|
|
|
add_wide_control(row, *w);
|
2008-02-12 16:56:44 +00:00
|
|
|
return w;
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
void HigWorkarea::add_label_w(guint row, Gtk::Widget& w)
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2021-10-18 20:22:31 +00:00
|
|
|
w.set_margin_start(18);
|
2017-04-19 12:04:45 +00:00
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
if (auto* label = dynamic_cast<Gtk::Label*>(&w); label != nullptr)
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
2021-10-18 20:22:31 +00:00
|
|
|
label->set_halign(Gtk::ALIGN_START);
|
|
|
|
label->set_valign(Gtk::ALIGN_CENTER);
|
|
|
|
label->set_use_markup(true);
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
attach(w, 0, row, 1, 1);
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
void HigWorkarea::add_tall_control(guint row, Gtk::Widget& control)
|
2009-09-17 01:21:49 +00:00
|
|
|
{
|
2021-10-18 20:22:31 +00:00
|
|
|
if (auto* label = dynamic_cast<Gtk::Label*>(&control); label != nullptr)
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
2021-10-18 20:22:31 +00:00
|
|
|
label->set_halign(Gtk::ALIGN_START);
|
|
|
|
label->set_valign(Gtk::ALIGN_CENTER);
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
2009-09-17 01:21:49 +00:00
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
control.set_hexpand(true);
|
|
|
|
control.set_vexpand(true);
|
|
|
|
attach(control, 1, row, 1, 1);
|
2009-09-17 01:21:49 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
void HigWorkarea::add_control(guint row, Gtk::Widget& control)
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2021-10-18 20:22:31 +00:00
|
|
|
if (auto* label = dynamic_cast<Gtk::Label*>(&control); label != nullptr)
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
2021-10-18 20:22:31 +00:00
|
|
|
label->set_halign(Gtk::ALIGN_START);
|
|
|
|
label->set_valign(Gtk::ALIGN_CENTER);
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
2007-06-07 17:53:54 +00:00
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
control.set_hexpand(true);
|
|
|
|
attach(control, 1, row, 1, 1);
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
void HigWorkarea::add_row_w(guint& row, Gtk::Widget& label_widget, Gtk::Widget& control, Gtk::Widget* mnemonic)
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2021-10-18 20:22:31 +00:00
|
|
|
add_label_w(row, label_widget);
|
|
|
|
add_control(row, control);
|
2017-04-19 12:04:45 +00:00
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
if (auto* label = dynamic_cast<Gtk::Label*>(&label_widget); label != nullptr)
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
2021-10-18 20:22:31 +00:00
|
|
|
label->set_mnemonic_widget(mnemonic != nullptr ? *mnemonic : control);
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
++row;
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
Gtk::Label* HigWorkarea::add_row(guint& row, Glib::ustring const& mnemonic_string, Gtk::Widget& control, Gtk::Widget* mnemonic)
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2021-10-18 20:22:31 +00:00
|
|
|
auto* l = Gtk::make_managed<Gtk::Label>(mnemonic_string, true);
|
|
|
|
add_row_w(row, *l, control, mnemonic);
|
2008-02-12 16:56:44 +00:00
|
|
|
return l;
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
Gtk::Label* HigWorkarea::add_tall_row(
|
|
|
|
guint& row,
|
|
|
|
Glib::ustring const& mnemonic_string,
|
|
|
|
Gtk::Widget& control,
|
|
|
|
Gtk::Widget* mnemonic)
|
2009-09-17 01:21:49 +00:00
|
|
|
{
|
2021-10-18 20:22:31 +00:00
|
|
|
auto* l = Gtk::make_managed<Gtk::Label>(mnemonic_string, true);
|
|
|
|
auto* h = Gtk::make_managed<Gtk::Box>(Gtk::ORIENTATION_HORIZONTAL, 0);
|
|
|
|
auto* v = Gtk::make_managed<Gtk::Box>(Gtk::ORIENTATION_VERTICAL, 0);
|
|
|
|
h->pack_start(*l, false, false, 0);
|
|
|
|
v->pack_start(*h, false, false, GUI_PAD_SMALL);
|
2012-12-05 17:29:46 +00:00
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
add_label_w(row, *v);
|
|
|
|
add_tall_control(row, control);
|
2012-12-05 17:29:46 +00:00
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
l->set_mnemonic_widget(mnemonic ? *mnemonic : control);
|
2009-09-17 01:21:49 +00:00
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
++row;
|
2009-09-17 01:21:49 +00:00
|
|
|
return l;
|
|
|
|
}
|