Commit b0640ec8 authored by Melroy van den Berg's avatar Melroy van den Berg

Small fix + auto indent

parent 156381a3
Pipeline #3069 passed with stages
in 17 seconds
/**
* Copyright (c) 2019 WineGUI
* Copyright (c) 2019-2021 WineGUI
*
* \file about_dialog.cc
* \brief The About dialog
......@@ -24,22 +24,23 @@
/**
* \brief Contructor
*/
AboutDialog::AboutDialog(Gtk::Window& parent) {
// Set logo
logo.set(Helper::GetImageLocation("logo.png"));
// Set version
std::vector<Glib::ustring> devs;
devs.push_back("Melroy van den Berg <melroy@melroy.org>");
AboutDialog::AboutDialog(Gtk::Window &parent)
{
// Set logo
logo.set(Helper::GetImageLocation("logo.png"));
// Set version
std::vector<Glib::ustring> devs;
devs.push_back("Melroy van den Berg <melroy@melroy.org>");
set_transient_for(parent);
set_program_name("WineGui");
set_comments("The most user-friendly WINE manager.");
set_logo(logo.get_pixbuf());
set_authors(devs);
set_artists(devs);
set_version(VERSION);
set_copyright("Copyright © 2019-2020 Melroy van den Berg");
set_license_type(Gtk::LICENSE_AGPL_3_0);
set_transient_for(parent);
set_program_name("WineGui");
set_comments("The most user-friendly WINE manager.");
set_logo(logo.get_pixbuf());
set_authors(devs);
set_artists(devs);
set_version(VERSION);
set_copyright("Copyright © 2019-2020 Melroy van den Berg");
set_license_type(Gtk::LICENSE_AGPL_3_0);
}
AboutDialog::~AboutDialog() {}
......@@ -58,6 +59,7 @@ void AboutDialog::hide_dialog(__attribute__((unused)) int response)
* \brief Retrieve the app version
* \return Version number
*/
std::string AboutDialog::GetVersion() {
return VERSION;
std::string AboutDialog::GetVersion()
{
return VERSION;
}
/**
* Copyright (c) 2019 WineGUI
* Copyright (c) 2019-2021 WineGUI
*
* \file bottle_item.cc
* \brief Wine Bottle Item
......@@ -25,133 +25,135 @@
/**
* \brief Default contructor
*/
BottleItem::BottleItem() {
// Gui will be created during the copy contructor called by Gtk
BottleItem::BottleItem()
{
// Gui will be created during the copy contructor called by Gtk
}
/**
* \brief Copy contructor, used by GTK+
*/
BottleItem::BottleItem(const BottleItem& bottleItem) : BottleItem() {
if ( this != &bottleItem ) {
_name = bottleItem.name();
_is_status_ok = bottleItem.status();
_win = bottleItem.windows();
_bit = bottleItem.bit();
_wine_version = bottleItem.wine_version();
_wine_location = bottleItem.wine_location();
_wine_c_drive = bottleItem.wine_c_drive();
_wine_last_changed = bottleItem.wine_last_changed();
_audio_driver = bottleItem.audio_driver();
_virtual_desktop = bottleItem.virtual_desktop();
}
CreateUI();
BottleItem::BottleItem(const BottleItem &bottleItem) : BottleItem()
{
if (this != &bottleItem)
{
_name = bottleItem.name();
_is_status_ok = bottleItem.status();
_win = bottleItem.windows();
_bit = bottleItem.bit();
_wine_version = bottleItem.wine_version();
_wine_location = bottleItem.wine_location();
_wine_c_drive = bottleItem.wine_c_drive();
_wine_last_changed = bottleItem.wine_last_changed();
_audio_driver = bottleItem.audio_driver();
_virtual_desktop = bottleItem.virtual_desktop();
}
CreateUI();
}
/**
* \brief Contruct a new Wine Bottle Item with limited inputs
*/
BottleItem::BottleItem(
Glib::ustring name,
Glib::ustring wine_version,
Glib::ustring wine_location,
Glib::ustring wine_c_drive,
Glib::ustring wine_last_changed)
:
_name(name),
_is_status_ok(true),
_win(BottleTypes::Windows::WindowsXP),
_bit(BottleTypes::Bit::win32),
_wine_version(wine_version),
_wine_location(wine_location),
_wine_c_drive(wine_c_drive),
_wine_last_changed(wine_last_changed),
_audio_driver(BottleTypes::AudioDriver::pulseaudio),
_virtual_desktop("disabled")
{
// Gui will be created during the copy contructor called by Gtk
};
Glib::ustring name,
Glib::ustring wine_version,
Glib::ustring wine_location,
Glib::ustring wine_c_drive,
Glib::ustring wine_last_changed)
: _name(name),
_is_status_ok(true),
_win(BottleTypes::Windows::WindowsXP),
_bit(BottleTypes::Bit::win32),
_wine_version(wine_version),
_wine_location(wine_location),
_wine_c_drive(wine_c_drive),
_wine_last_changed(wine_last_changed),
_audio_driver(BottleTypes::AudioDriver::pulseaudio),
_virtual_desktop("disabled"){
// Gui will be created during the copy contructor called by Gtk
};
/**
* \brief Contruct a new Wine Bottle Item
*/
BottleItem::BottleItem(
Glib::ustring name,
bool status,
BottleTypes::Windows win,
BottleTypes::Bit bit,
Glib::ustring wine_version,
Glib::ustring wine_location,
Glib::ustring wine_c_drive,
Glib::ustring wine_last_changed,
BottleTypes::AudioDriver audio_driver,
Glib::ustring virtual_desktop)
:
_name(name),
_is_status_ok(status),
_win(win),
_bit(bit),
_wine_version(wine_version),
_wine_location(wine_location),
_wine_c_drive(wine_c_drive),
_wine_last_changed(wine_last_changed),
_audio_driver(audio_driver),
_virtual_desktop(virtual_desktop)
{
// Gui will be created during the copy contructor called by Gtk
};
Glib::ustring name,
bool status,
BottleTypes::Windows win,
BottleTypes::Bit bit,
Glib::ustring wine_version,
Glib::ustring wine_location,
Glib::ustring wine_c_drive,
Glib::ustring wine_last_changed,
BottleTypes::AudioDriver audio_driver,
Glib::ustring virtual_desktop)
: _name(name),
_is_status_ok(status),
_win(win),
_bit(bit),
_wine_version(wine_version),
_wine_location(wine_location),
_wine_c_drive(wine_c_drive),
_wine_last_changed(wine_last_changed),
_audio_driver(audio_driver),
_virtual_desktop(virtual_desktop){
// Gui will be created during the copy contructor called by Gtk
};
void BottleItem::CreateUI()
{
// To lower case
std::string windows = BottleItem::str_tolower(BottleTypes::toString(this->windows()));
// Remove spaces
windows.erase(std::remove_if (
std::begin(windows), std::end(windows),
[l = std::locale{}](auto ch) { return std::isspace(ch, l); }
), end(windows));
Glib::ustring bit = BottleTypes::toString(this->bit());
Glib::ustring filename = windows + "_" + bit + ".png";
Glib::ustring name = this->name();
bool status = this->status();
// To lower case
std::string windows = BottleItem::str_tolower(BottleTypes::toString(this->windows()));
// Remove spaces
windows.erase(std::remove_if(
std::begin(windows), std::end(windows),
[l = std::locale{}](auto ch) { return std::isspace(ch, l); }),
end(windows));
Glib::ustring bit = BottleTypes::toString(this->bit());
Glib::ustring filename = windows + "_" + bit + ".png";
Glib::ustring name = this->name();
bool status = this->status();
// Set left side of the GUI
image.set(Helper::GetImageLocation("windows/" + filename));
image.set_margin_top(8);
image.set_margin_end(8);
image.set_margin_bottom(8);
image.set_margin_start(8);
// Set left side of the GUI
image.set(Helper::GetImageLocation("windows/" + filename));
image.set_margin_top(8);
image.set_margin_end(8);
image.set_margin_bottom(8);
image.set_margin_start(8);
name_label.set_xalign(0.0);
name_label.set_markup("<span size=\"medium\"><b>" + name + "</b></span>");
name_label.set_xalign(0.0);
name_label.set_markup("<span size=\"medium\"><b>" + name + "</b></span>");
Glib::ustring status_text = "Ready";
if (status) {
status_icon.set(Helper::GetImageLocation("ready.png"));
} else {
status_text = "Not Ready";
status_icon.set(Helper::GetImageLocation("not_ready.png"));
}
status_icon.set_size_request(2, -1);
status_icon.set_halign(Gtk::Align::ALIGN_START);
Glib::ustring status_text = "Ready";
if (status)
{
status_icon.set(Helper::GetImageLocation("ready.png"));
}
else
{
status_text = "Not Ready";
status_icon.set(Helper::GetImageLocation("not_ready.png"));
}
status_icon.set_size_request(2, -1);
status_icon.set_halign(Gtk::Align::ALIGN_START);
status_label.set_text(status_text);
status_label.set_xalign(0.0);
status_label.set_text(status_text);
status_label.set_xalign(0.0);
grid.set_column_spacing(8);
grid.set_row_spacing(5);
grid.set_border_width(4);
grid.set_column_spacing(8);
grid.set_row_spacing(5);
grid.set_border_width(4);
grid.attach(image, 0, 0, 1, 2);
// Agh, stupid GTK! Width 2 would be enough, add 8 extra = 10
// I can't control the gtk grid cell width
grid.attach_next_to(name_label, image, Gtk::PositionType::POS_RIGHT, 10, 1);
grid.attach(image, 0, 0, 1, 2);
// Agh, stupid GTK! Width 2 would be enough, add 8 extra = 10
// I can't control the gtk grid cell width
grid.attach_next_to(name_label, image, Gtk::PositionType::POS_RIGHT, 10, 1);
grid.attach(status_icon, 1, 1, 1, 1);
grid.attach_next_to(status_label, status_icon, Gtk::PositionType::POS_RIGHT, 1, 1);
grid.attach(status_icon, 1, 1, 1, 1);
grid.attach_next_to(status_label, status_icon, Gtk::PositionType::POS_RIGHT, 1, 1);
// Finally at the grid to the ListBoxRow
add(grid);
// Finally at the grid to the ListBoxRow
add(grid);
}
/**
......@@ -159,9 +161,9 @@ void BottleItem::CreateUI()
* \param[in] string that needs lower case
* \return lower case string
*/
std::string BottleItem::str_tolower(std::string s) {
std::transform(s.begin(), s.end(), s.begin(),
[](unsigned char c){ return std::tolower(c); }
);
return s;
std::string BottleItem::str_tolower(std::string s)
{
std::transform(s.begin(), s.end(), s.begin(),
[](unsigned char c) { return std::tolower(c); });
return s;
}
This diff is collapsed.
/**
* Copyright (c) 2020 WineGUI
* Copyright (c) 2020-2021 WineGUI
*
* \file busy_dialog.cc
* \brief GTK+ Busy dialog
......@@ -24,31 +24,31 @@
* \brief Constructor
* \param parent Reference to parent GTK+ Window
*/
BusyDialog::BusyDialog(Gtk::Window& parent)
: Gtk::Dialog("Applying Changes"),
defaultParent(parent)
BusyDialog::BusyDialog(Gtk::Window &parent)
: Gtk::Dialog("Applying Changes"),
defaultParent(parent)
{
set_transient_for(parent);
set_default_size(400, 120);
set_modal(true);
set_deletable(false);
set_transient_for(parent);
set_default_size(400, 120);
set_modal(true);
set_deletable(false);
heading_label.set_markup("<big><b>Installing software</b></big>");
heading_label.set_alignment(0.0);
message_label.set_alignment(0.0);
loading_bar.set_pulse_step(0.3);
heading_label.set_markup("<big><b>Installing software</b></big>");
heading_label.set_alignment(0.0);
message_label.set_alignment(0.0);
loading_bar.set_pulse_step(0.3);
Gtk::Box* box = get_vbox();
box->set_margin_top(10);
box->set_margin_right(10);
box->set_margin_bottom(10);
box->set_margin_left(10);
Gtk::Box *box = get_vbox();
box->set_margin_top(10);
box->set_margin_right(10);
box->set_margin_bottom(10);
box->set_margin_left(10);
box->pack_start(heading_label, false, false);
box->pack_start(message_label, true, false);
box->pack_start(loading_bar, true, false);
show_all_children();
box->pack_start(heading_label, false, false);
box->pack_start(message_label, true, false);
box->pack_start(loading_bar, true, false);
show_all_children();
}
/**
......@@ -60,9 +60,9 @@ BusyDialog::~BusyDialog() {}
* \brief Set busy message
* \param[in] message - Message
*/
void BusyDialog::SetMessage(const Glib::ustring& message)
void BusyDialog::SetMessage(const Glib::ustring &message)
{
this->message_label.set_text(message + " Please wait...");
this->message_label.set_text(message + " Please wait...");
}
/**
......@@ -70,15 +70,16 @@ void BusyDialog::SetMessage(const Glib::ustring& message)
*/
void BusyDialog::show()
{
if (!timer.empty() && timer.connected()) {
timer.disconnect();
}
if (!timer.empty() && timer.connected())
{
timer.disconnect();
}
int time_interval = 200;
timer = Glib::signal_timeout().connect(
sigc::mem_fun(*this, &BusyDialog::Pulsing),
time_interval);
Gtk::Dialog::show();
int time_interval = 200;
timer = Glib::signal_timeout().connect(
sigc::mem_fun(*this, &BusyDialog::Pulsing),
time_interval);
Gtk::Dialog::show();
}
/**
......@@ -86,14 +87,15 @@ void BusyDialog::show()
*/
void BusyDialog::close()
{
// Reset default parent
set_transient_for(defaultParent);
// Stop pulsing timer
if (!timer.empty() && timer.connected()) {
timer.disconnect();
}
Gtk::Dialog::close();
// Reset default parent
set_transient_for(defaultParent);
// Stop pulsing timer
if (!timer.empty() && timer.connected())
{
timer.disconnect();
}
Gtk::Dialog::close();
}
/**
......@@ -101,6 +103,6 @@ void BusyDialog::close()
*/
bool BusyDialog::Pulsing()
{
loading_bar.pulse();
return true;
loading_bar.pulse();
return true;
}
/**
* Copyright (c) 2020 WineGUI
* Copyright (c) 2020-2021 WineGUI
*
* \file settings_window.cc
* \brief Setting GTK+ Window class
......@@ -25,19 +25,17 @@
* \brief Constructor
* \param parent Reference to parent GTK+ Window
*/
EditWindow::EditWindow(Gtk::Window& parent)
:
save_button("Save"),
delete_button("Delete Machine"),
wine_config_button("WineCfg"),
activeBottle(nullptr)
EditWindow::EditWindow(Gtk::Window &parent)
: save_button("Save"),
delete_button("Delete Machine"),
wine_config_button("WineCfg"),
activeBottle(nullptr)
{
set_transient_for(parent);
set_default_size(750, 540);
set_modal(true);
set_transient_for(parent);
set_default_size(750, 540);
set_modal(true);
show_all_children();
show_all_children();
}
/**
......@@ -48,22 +46,23 @@ EditWindow::~EditWindow() {}
/**
* \brief Same as show() but will also update the Window title
*/
void EditWindow::Show() {
if (activeBottle != nullptr)
set_title("Edit Machine - " + activeBottle->name());
else
set_title("Edit Machine (Unknown machine)");
// Call parent show
Gtk::Widget::show();
void EditWindow::Show()
{
if (activeBottle != nullptr)
set_title("Edit Machine - " + activeBottle->name());
else
set_title("Edit Machine (Unknown machine)");
// Call parent show
Gtk::Widget::show();
}
/**
* \brief Signal handler when a new bottle is set in the main window
* \param[in] bottle - New bottle
*/
void EditWindow::SetActiveBottle(BottleItem* bottle)
void EditWindow::SetActiveBottle(BottleItem *bottle)
{
this->activeBottle = bottle;
this->activeBottle = bottle;
}
/**
......@@ -71,5 +70,5 @@ void EditWindow::SetActiveBottle(BottleItem* bottle)
*/
void EditWindow::ResetActiveBottle()
{
this->activeBottle = nullptr;
this->activeBottle = nullptr;
}
\ No newline at end of file
This diff is collapsed.
/**
* Copyright (c) 2019 WineGUI
* Copyright (c) 2019-2021 WineGUI
*
* \file main.cc
* \brief Main, where it all starts
......@@ -31,7 +31,7 @@
#include <iostream>
// Prototype
static MainWindow& setupApplication();
static MainWindow &setupApplication();
/**
* \brief The beginning, start the main loop
......@@ -39,46 +39,50 @@ static MainWindow& setupApplication();
*/
int main(int argc, char *argv[])
{
if (argc > 1) {
for (int i = 1; i < argc; ++i) {
std::string arg = argv[i];
if (arg == "--version") {
// Retrieve version and print it
std::string version = AboutDialog::GetVersion();
std::cout << version << std::endl;
return 0;
}
if (argc > 1)
{
for (int i = 1; i < argc; ++i)
{
std::string arg = argv[i];
if (arg == "--version")
{
// Retrieve version and print it
std::string version = AboutDialog::GetVersion();
std::cout << version << std::endl;
return 0;
}
}
std::cerr << "Error: Parameter not understood (only --version is an accepted parameter)!" << std::endl;
return 1;
}
else
{
auto app = Gtk::Application::create("org.melroy.winegui");
// Setup
MainWindow &mainWindow = setupApplication();
// Start main loop of GTK
return app->run(mainWindow, argc, argv);
}
std::cerr << "Error: Parameter not understood (only --version is an accepted parameter)!" << std::endl;
return 1;
}
else
{
auto app = Gtk::Application::create("org.melroy.winegui");
// Setup
MainWindow& mainWindow = setupApplication();
// Start main loop of GTK
return app->run(mainWindow, argc, argv);
}
}
static MainWindow& setupApplication() {
// Constructing the top level objects:
static Menu menu;
static MainWindow mainWindow(menu);
static PreferencesWindow preferencesWindow(mainWindow);
static AboutDialog about(mainWindow);
static EditWindow editWindow(mainWindow);
static SettingsWindow settingsWindow(mainWindow);
static BottleManager manager(mainWindow);
static SignalDispatcher signalDispatcher(manager, menu, preferencesWindow, about, editWindow, settingsWindow);
static MainWindow &setupApplication()
{
// Constructing the top level objects:
static Menu menu;
static MainWindow mainWindow(menu);
static PreferencesWindow preferencesWindow(mainWindow);
static AboutDialog about(mainWindow);
static EditWindow editWindow(mainWindow);
static SettingsWindow settingsWindow(mainWindow);
static BottleManager manager(mainWindow);
static SignalDispatcher signalDispatcher(manager, menu, preferencesWindow, about, editWindow, settingsWindow);
signalDispatcher.SetMainWindow(&mainWindow);
// Do all the signal connections of the life-time of the app
signalDispatcher.DispatchSignals();
signalDispatcher.SetMainWindow(&mainWindow);
// Do all the signal connections of the life-time of the app
signalDispatcher.DispatchSignals();
// Call the Bottle Manager prepare method,
// it will prepare Winetricks & retrieve Wine Bottles
manager.Prepare();
return mainWindow;
// Call the Bottle Manager prepare method,
// it will prepare Winetricks & retrieve Wine Bottles
manager.Prepare();