Merge branch '45-increase-default-margins' into 'main'

Introducing reader view

Closes #45

See merge request libreweb/browser!29
master
Melroy van den Berg 2022-02-28 23:00:36 +00:00
commit ed1e8dbe6b
4 changed files with 238 additions and 69 deletions

View File

@ -33,8 +33,8 @@ Draw::Draw(MiddlewareInterface& middleware)
{
this->disableEdit();
set_top_margin(12);
set_left_margin(20); // fallback
set_right_margin(20); // fallback
set_left_margin(10); // fallback
set_right_margin(10); // fallback
set_bottom_margin(0);
set_indent(0); // fallback
set_monospace(false);
@ -343,6 +343,14 @@ void Draw::newDocument()
this->redoPool.clear();
this->clear();
// Set margins to defaults in editor mode
set_left_margin(10);
set_right_margin(10);
// Set indent to zero
set_indent(0);
// Reset word wrapping to default
set_wrap_mode(Gtk::WRAP_WORD_CHAR);
enableEdit();
grab_focus(); // Claim focus on text view
}
@ -738,7 +746,6 @@ void Draw::insert_image()
buffer->end_user_action();
}
// TODO: set_monospace(true)
void Draw::make_code()
{
Gtk::TextBuffer::iterator start, end;

View File

@ -31,8 +31,9 @@ MainWindow::MainWindow(const std::string& timeout)
: m_accelGroup(Gtk::AccelGroup::create()),
m_settings(),
m_brightnessAdjustment(Gtk::Adjustment::create(1.0, 0.0, 1.0, 0.05, 0.1)),
m_maxContentWidthAdjustment(Gtk::Adjustment::create(700, 0, 99999, 10, 20)),
m_spacingAdjustment(Gtk::Adjustment::create(0, -10, 10, 1, 2)),
m_marginsAdjustment(Gtk::Adjustment::create(20, 0, 1000, 10, 20)),
m_marginsAdjustment(Gtk::Adjustment::create(10, 0, 1000, 10, 20)),
m_indentAdjustment(Gtk::Adjustment::create(0, 0, 1000, 5, 10)),
m_drawCSSProvider(Gtk::CssProvider::create()),
m_menu(m_accelGroup),
@ -89,11 +90,13 @@ MainWindow::MainWindow(const std::string& timeout)
m_networkOutcomingLabel("Outcoming"),
m_networkKiloBytesLabel("Kilobytes/s"),
m_fontLabel("Font"),
m_maxContentWidthLabel("Content width"),
m_spacingLabel("Spacing"),
m_marginsLabel("Margins"),
m_indentLabel("Indent"),
m_textWrappingLabel("Wrapping"),
m_themeLabel("Dark Theme"),
m_readerViewLabel("Reader View"),
m_iconThemeLabel("Active Theme"),
// Private members
middleware_(*this, timeout),
@ -104,9 +107,15 @@ MainWindow::MainWindow(const std::string& timeout)
fontFamily_("Sans"),
defaultFontSize_(10),
currentFontSize_(10),
positionDividerDraw_(-1),
contentMargin_(20),
contentMaxWidth_(700),
fontSpacing_(0),
indent_(0),
wrapMode_(Gtk::WRAP_WORD_CHAR),
brightnessScale_(1.0),
useDarkTheme_(false),
isReaderViewEnabled_(true),
currentHistoryIndex_(0)
{
set_title(appName_);
@ -362,39 +371,65 @@ void MainWindow::loadStoredSettings()
set_default_size(m_settings->get_int("width"), m_settings->get_int("height"));
if (m_settings->get_boolean("maximized"))
maximize();
positionDividerDraw_ = m_settings->get_int("position-divider-draw");
m_panedDraw.set_position(positionDividerDraw_);
fontFamily_ = m_settings->get_string("font-family");
currentFontSize_ = defaultFontSize_ = m_settings->get_int("font-size");
m_fontButton.set_font_name(fontFamily_ + " " + std::to_string(currentFontSize_));
contentMaxWidth_ = m_settings->get_int("max-content-width");
fontSpacing_ = m_settings->get_int("spacing");
int margins = m_settings->get_int("margins");
int indent = m_settings->get_int("indent");
contentMargin_ = m_settings->get_int("margins");
indent_ = m_settings->get_int("indent");
wrapMode_ = static_cast<Gtk::WrapMode>(m_settings->get_enum("wrap-mode"));
m_maxContentWidthAdjustment->set_value(contentMaxWidth_);
m_spacingAdjustment->set_value(fontSpacing_);
m_marginsAdjustment->set_value(margins);
m_indentAdjustment->set_value(indent);
m_draw_primary.set_left_margin(margins);
m_draw_primary.set_right_margin(margins);
m_draw_primary.set_indent(indent);
m_marginsAdjustment->set_value(contentMargin_);
m_indentAdjustment->set_value(indent_);
m_draw_primary.set_indent(indent_);
int tocDividerPosition = m_settings->get_int("position-divider-toc");
m_panedRoot.set_position(tocDividerPosition);
iconTheme_ = m_settings->get_string("icon-theme");
useCurrentGTKIconTheme_ = m_settings->get_boolean("icon-gtk-theme");
brightnessScale_ = m_settings->get_double("brightness");
useDarkTheme_ = m_settings->get_boolean("dark-theme");
isReaderViewEnabled_ = m_settings->get_boolean("reader-view");
switch (wrapMode_)
{
case Gtk::WRAP_NONE:
m_wrapNone.set_active(true);
break;
case Gtk::WRAP_CHAR:
m_wrapChar.set_active(true);
break;
case Gtk::WRAP_WORD:
m_wrapWord.set_active(true);
break;
case Gtk::WRAP_WORD_CHAR:
m_wrapWordChar.set_active(true);
break;
default:
m_wrapWordChar.set_active(true);
}
}
else
{
std::cerr << "ERROR: Gsettings schema file could not be found!" << std::endl;
// Select default fallback wrap mode
m_wrapWordChar.set_active(true);
// Fallback adjustment controls
int margins = m_draw_primary.get_margin_left();
int indent = m_draw_primary.get_indent();
m_spacingAdjustment->set_value(0);
m_marginsAdjustment->set_value(margins);
m_indentAdjustment->set_value(indent);
m_maxContentWidthAdjustment->set_value(contentMaxWidth_);
m_spacingAdjustment->set_value(fontSpacing_);
m_marginsAdjustment->set_value(contentMaxWidth_);
m_indentAdjustment->set_value(indent_);
// Fallback ToC paned divider
m_panedRoot.set_position(300);
}
// Apply settings that needs to be applied now
// Note: margins are getting automatically applied (on resize),
// and some other attributes are part of CSS.
m_draw_primary.set_indent(indent_);
m_draw_primary.set_wrap_mode(wrapMode_);
}
/**
@ -793,11 +828,9 @@ void MainWindow::initSettingsPopover()
m_scaleSettingsBrightness.signal_value_changed().connect(sigc::mem_fun(this, &MainWindow::on_brightness_changed));
m_hboxSetingsBrightness.pack_start(m_brightnessImage, false, false);
m_hboxSetingsBrightness.pack_end(m_scaleSettingsBrightness);
// Dark theme switch
m_themeSwitch.set_active(useDarkTheme_); // Override with current dark theme preference
// Settings buttons
m_wrapWordChar.set_active(true); // Default wrapping mode
// Settings labels / buttons
m_fontLabel.set_tooltip_text("Font familiy");
m_maxContentWidthLabel.set_tooltip_text("Max content width");
m_spacingLabel.set_tooltip_text("Text spacing");
m_marginsLabel.set_tooltip_text("Text margins");
m_indentLabel.set_tooltip_text("Text indentation");
@ -806,21 +839,31 @@ void MainWindow::initSettingsPopover()
m_wrapChar.set_tooltip_text("Character wrapping");
m_wrapWord.set_tooltip_text("Word wrapping");
m_wrapWordChar.set_tooltip_text("Word wrapping (+ character)");
m_maxContentWidthSpinButton.set_adjustment(m_maxContentWidthAdjustment);
m_spacingSpinButton.set_adjustment(m_spacingAdjustment);
m_marginsSpinButton.set_adjustment(m_marginsAdjustment);
m_indentSpinButton.set_adjustment(m_indentAdjustment);
m_fontLabel.set_xalign(1);
m_maxContentWidthLabel.set_xalign(1);
m_spacingLabel.set_xalign(1);
m_marginsLabel.set_xalign(1);
m_indentLabel.set_xalign(1);
m_textWrappingLabel.set_xalign(1);
m_themeLabel.set_xalign(1);
m_readerViewLabel.set_xalign(1);
m_fontLabel.get_style_context()->add_class("dim-label");
m_maxContentWidthLabel.get_style_context()->add_class("dim-label");
m_spacingLabel.get_style_context()->add_class("dim-label");
m_marginsLabel.get_style_context()->add_class("dim-label");
m_indentLabel.get_style_context()->add_class("dim-label");
m_textWrappingLabel.get_style_context()->add_class("dim-label");
m_themeLabel.get_style_context()->add_class("dim-label");
m_readerViewLabel.get_style_context()->add_class("dim-label");
// Dark theme switch
m_themeSwitch.set_active(useDarkTheme_); // Override with current dark theme preference
// Reader view switch
m_readerViewSwitch.set_active(isReaderViewEnabled_);
// Settings grid
m_settingsGrid.set_margin_start(6);
m_settingsGrid.set_margin_top(6);
m_settingsGrid.set_margin_bottom(6);
@ -828,19 +871,23 @@ void MainWindow::initSettingsPopover()
m_settingsGrid.set_column_spacing(10);
m_settingsGrid.attach(m_fontLabel, 0, 0, 1);
m_settingsGrid.attach(m_fontButton, 1, 0, 2);
m_settingsGrid.attach(m_spacingLabel, 0, 1, 1);
m_settingsGrid.attach(m_spacingSpinButton, 1, 1, 2);
m_settingsGrid.attach(m_marginsLabel, 0, 2, 1);
m_settingsGrid.attach(m_marginsSpinButton, 1, 2, 2);
m_settingsGrid.attach(m_indentLabel, 0, 3, 1);
m_settingsGrid.attach(m_indentSpinButton, 1, 3, 2);
m_settingsGrid.attach(m_textWrappingLabel, 0, 4, 1);
m_settingsGrid.attach(m_wrapNone, 1, 4, 1);
m_settingsGrid.attach(m_wrapChar, 2, 4, 1);
m_settingsGrid.attach(m_wrapWord, 1, 5, 1);
m_settingsGrid.attach(m_wrapWordChar, 2, 5, 1);
m_settingsGrid.attach(m_themeLabel, 0, 6, 1);
m_settingsGrid.attach(m_themeSwitch, 1, 6, 2);
m_settingsGrid.attach(m_maxContentWidthLabel, 0, 1, 1);
m_settingsGrid.attach(m_maxContentWidthSpinButton, 1, 1, 2);
m_settingsGrid.attach(m_spacingLabel, 0, 2, 1);
m_settingsGrid.attach(m_spacingSpinButton, 1, 2, 2);
m_settingsGrid.attach(m_marginsLabel, 0, 3, 1);
m_settingsGrid.attach(m_marginsSpinButton, 1, 3, 2);
m_settingsGrid.attach(m_indentLabel, 0, 4, 1);
m_settingsGrid.attach(m_indentSpinButton, 1, 4, 2);
m_settingsGrid.attach(m_textWrappingLabel, 0, 5, 1);
m_settingsGrid.attach(m_wrapNone, 1, 5, 1);
m_settingsGrid.attach(m_wrapChar, 2, 5, 1);
m_settingsGrid.attach(m_wrapWord, 1, 6, 1);
m_settingsGrid.attach(m_wrapWordChar, 2, 6, 1);
m_settingsGrid.attach(m_themeLabel, 0, 7, 1);
m_settingsGrid.attach(m_themeSwitch, 1, 7, 2);
m_settingsGrid.attach(m_readerViewLabel, 0, 8, 1);
m_settingsGrid.attach(m_readerViewSwitch, 1, 8, 2);
// Icon theme (+ submenu)
m_iconThemeButton.set_label("Icon Theme");
m_iconThemeButton.property_menu_name() = "icon-theme";
@ -908,6 +955,8 @@ void MainWindow::initSignals()
{
// Window signals
signal_delete_event().connect(sigc::mem_fun(this, &MainWindow::delete_window));
m_draw_primary.signal_size_allocate().connect(sigc::mem_fun(this, &MainWindow::on_size_alloc));
// Table of contents
m_closeTocWindowButton.signal_clicked().connect(sigc::mem_fun(m_vboxToc, &Gtk::Widget::hide));
tocTreeView.signal_row_activated().connect(sigc::mem_fun(this, &MainWindow::on_toc_row_activated));
@ -978,6 +1027,7 @@ void MainWindow::initSignals()
m_zoomRestoreButton.signal_clicked().connect(sigc::mem_fun(this, &MainWindow::on_zoom_restore));
m_zoomInButton.signal_clicked().connect(sigc::mem_fun(this, &MainWindow::on_zoom_in));
m_fontButton.signal_font_set().connect(sigc::mem_fun(this, &MainWindow::on_font_set));
m_maxContentWidthSpinButton.signal_value_changed().connect(sigc::mem_fun(this, &MainWindow::on_max_content_width_changed));
m_spacingSpinButton.signal_value_changed().connect(sigc::mem_fun(this, &MainWindow::on_spacing_changed));
m_marginsSpinButton.signal_value_changed().connect(sigc::mem_fun(this, &MainWindow::on_margins_changed));
m_indentSpinButton.signal_value_changed().connect(sigc::mem_fun(this, &MainWindow::on_indent_changed));
@ -986,6 +1036,7 @@ void MainWindow::initSignals()
m_wrapWord.signal_toggled().connect(sigc::bind(sigc::mem_fun(this, &MainWindow::on_wrap_toggled), Gtk::WrapMode::WRAP_WORD));
m_wrapWordChar.signal_toggled().connect(sigc::bind(sigc::mem_fun(this, &MainWindow::on_wrap_toggled), Gtk::WrapMode::WRAP_WORD_CHAR));
m_themeSwitch.property_active().signal_changed().connect(sigc::mem_fun(this, &MainWindow::on_theme_changed));
m_readerViewSwitch.property_active().signal_changed().connect(sigc::mem_fun(this, &MainWindow::on_reader_view_changed));
m_iconThemeListBox.signal_row_activated().connect(sigc::mem_fun(this, &MainWindow::on_icon_theme_activated));
m_aboutButton.signal_clicked().connect(sigc::mem_fun(m_about, &About::show_about));
}
@ -1031,13 +1082,16 @@ bool MainWindow::delete_window(GdkEventAny* any_event __attribute__((unused)))
// m_settings->set_boolean("fullscreen", is_fullscreen());
m_settings->set_string("font-family", fontFamily_);
m_settings->set_int("font-size", currentFontSize_);
m_settings->set_int("spacing", m_spacingSpinButton.get_value_as_int());
m_settings->set_int("margins", m_marginsSpinButton.get_value_as_int());
m_settings->set_int("indent", m_indentSpinButton.get_value_as_int());
m_settings->set_int("max-content-width", contentMaxWidth_);
m_settings->set_int("spacing", fontSpacing_);
m_settings->set_int("margins", contentMargin_);
m_settings->set_int("indent", indent_);
m_settings->set_enum("wrap-mode", wrapMode_);
m_settings->set_string("icon-theme", iconTheme_);
m_settings->set_boolean("icon-gtk-theme", useCurrentGTKIconTheme_);
m_settings->set_double("brightness", brightnessScale_);
m_settings->set_boolean("dark-theme", useDarkTheme_);
m_settings->set_boolean("reader-view", isReaderViewEnabled_);
}
return false;
}
@ -1192,6 +1246,15 @@ void MainWindow::selectAll()
}
}
/**
* \brief Triggers when the textview widget changes size
*/
void MainWindow::on_size_alloc(__attribute__((unused)) Gdk::Rectangle& allocation)
{
if (!isEditorEnabled())
updateMargins();
}
/**
* \brief Triggered when user clicked on the column in ToC
*/
@ -1911,34 +1974,37 @@ bool MainWindow::isInstalled()
}
/**
* \brief Enable editor mode. Allowing to create or edit existing documents.
* \brief Enable editor mode. Allowing to create or edit existing documents
*/
void MainWindow::enableEdit()
{
// Inform the Draw class that we are creating a new document
// Inform the Draw class that we are creating a new document,
// will apply change some textview setting changes
m_draw_primary.newDocument();
// Show editor toolbars
m_hboxStandardEditorToolbar.show();
m_hboxFormattingEditorToolbar.show();
// Enable monospace in editor
m_draw_primary.set_monospace(true);
// Apply some settings from primary to secondary window
m_draw_secondary.set_indent(indent_);
m_draw_secondary.set_wrap_mode(wrapMode_);
m_draw_secondary.set_left_margin(contentMargin_);
m_draw_secondary.set_right_margin(contentMargin_);
// Determine position of divider between the primary and secondary windows
int location = 0;
int positionSettings = 42;
if (m_settings)
positionSettings = m_settings->get_int("position-divider-draw");
int currentWidth, _ = 0;
get_size(currentWidth, _);
// If position from settings is still default (42) or too big,
// let's calculate the paned divider location
if ((positionSettings == 42) || (positionSettings >= (currentWidth - 10)))
int currentWidth = get_width();
int maxWidth = currentWidth - 40;
// Recalculate the position divider if it's too big,
// or positionDividerDraw_ is still on default value
if ((m_panedDraw.get_position() >= maxWidth) || positionDividerDraw_ == -1)
{
location = static_cast<int>(currentWidth / 2.0);
int proposedPosition = positionDividerDraw_; // Try to first use the gsettings
if ((proposedPosition == -1) || (proposedPosition >= maxWidth))
{
proposedPosition = static_cast<int>(currentWidth / 2.0);
}
m_panedDraw.set_position(proposedPosition);
}
else
{
location = positionSettings;
}
m_panedDraw.set_position(location);
// Enabled secondary text view (on the right)
m_scrolledWindowSecondary.show();
// Disable "view source" menu item
@ -1954,7 +2020,7 @@ void MainWindow::enableEdit()
}
/**
* \brief Disable editor mode.
* \brief Disable editor mode
*/
void MainWindow::disableEdit()
{
@ -1965,6 +2031,11 @@ void MainWindow::disableEdit()
m_scrolledWindowSecondary.hide();
// Disconnect text changed signal
textChangedSignalHandler_.disconnect();
// Disable monospace
m_draw_primary.set_monospace(false);
// Re-apply settings on primary window
m_draw_primary.set_indent(indent_);
m_draw_primary.set_wrap_mode(wrapMode_);
// Show "view source" menu item again
m_draw_primary.setViewSourceMenuItem(true);
m_draw_secondary.clear();
@ -2019,6 +2090,42 @@ std::string MainWindow::getIconImageFromTheme(const std::string& iconName, const
}
}
/**
* \brief Calculate & update margins on primary draw
*/
void MainWindow::updateMargins()
{
if (isEditorEnabled())
{
m_draw_secondary.set_left_margin(contentMargin_);
m_draw_secondary.set_right_margin(contentMargin_);
}
else
{
if (isReaderViewEnabled_)
{
int width = m_draw_primary.get_width();
if (width > (contentMaxWidth_ + (2 * contentMargin_)))
{
// Calculate margins on the fly
int margin = (width - contentMaxWidth_) / 2;
m_draw_primary.set_left_margin(margin);
m_draw_primary.set_right_margin(margin);
}
else
{
m_draw_primary.set_left_margin(contentMargin_);
m_draw_primary.set_right_margin(contentMargin_);
}
}
else
{
m_draw_primary.set_left_margin(contentMargin_);
m_draw_primary.set_right_margin(contentMargin_);
}
}
}
/**
* \brief Update the CSS provider data
*/
@ -2164,26 +2271,41 @@ void MainWindow::on_font_set()
updateCSS();
}
void MainWindow::on_max_content_width_changed()
{
contentMaxWidth_ = m_maxContentWidthSpinButton.get_value_as_int();
if (!isEditorEnabled())
updateMargins();
}
void MainWindow::on_spacing_changed()
{
fontSpacing_ = m_spacingSpinButton.get_value_as_int(); // Letter spacing
fontSpacing_ = m_spacingSpinButton.get_value_as_int(); // Letter-spacing
updateCSS();
}
void MainWindow::on_margins_changed()
{
m_draw_primary.set_left_margin(m_marginsSpinButton.get_value_as_int());
m_draw_primary.set_right_margin(m_marginsSpinButton.get_value_as_int());
contentMargin_ = m_marginsSpinButton.get_value_as_int();
updateMargins();
}
void MainWindow::on_indent_changed()
{
m_draw_primary.set_indent(m_indentSpinButton.get_value_as_int());
indent_ = m_indentSpinButton.get_value_as_int();
if (isEditorEnabled())
m_draw_secondary.set_indent(indent_);
else
m_draw_primary.set_indent(indent_);
}
void MainWindow::on_wrap_toggled(Gtk::WrapMode mode)
{
m_draw_primary.set_wrap_mode(mode);
wrapMode_ = mode;
if (isEditorEnabled())
m_draw_secondary.set_wrap_mode(wrapMode_);
else
m_draw_primary.set_wrap_mode(wrapMode_);
}
void MainWindow::on_brightness_changed()
@ -2199,6 +2321,13 @@ void MainWindow::on_theme_changed()
setTheme();
}
void MainWindow::on_reader_view_changed()
{
isReaderViewEnabled_ = m_readerViewSwitch.get_active();
if (!isEditorEnabled())
updateMargins();
}
void MainWindow::on_icon_theme_activated(Gtk::ListBoxRow* row)
{
std::string themeName = static_cast<char*>(row->get_data("value"));

View File

@ -75,6 +75,7 @@ protected:
void paste();
void del();
void selectAll();
void on_size_alloc(Gdk::Rectangle& allocation);
void on_toc_row_activated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column);
void new_doc();
void open();
@ -107,21 +108,24 @@ protected:
void on_zoom_restore();
void on_zoom_in();
void on_font_set();
void on_max_content_width_changed();
void on_spacing_changed();
void on_margins_changed();
void on_indent_changed();
void on_wrap_toggled(Gtk::WrapMode mode);
void on_brightness_changed();
void on_theme_changed();
void on_reader_view_changed();
void on_icon_theme_activated(Gtk::ListBoxRow* row);
Glib::RefPtr<Gtk::AccelGroup> m_accelGroup; /*!< Accelerator group, used for keyboard shortcut bindings */
Glib::RefPtr<Gio::Settings> m_settings; /*!< Settings to store our preferences, even during restarts */
Glib::RefPtr<Gtk::Adjustment> m_brightnessAdjustment; /*!< Bridghtness adjustment settings */
Glib::RefPtr<Gtk::Adjustment> m_spacingAdjustment; /*!< Spacing adjustment settings */
Glib::RefPtr<Gtk::Adjustment> m_marginsAdjustment; /*!< Margins adjustment settings */
Glib::RefPtr<Gtk::Adjustment> m_indentAdjustment; /*!< Indent adjustment settings */
Glib::RefPtr<Gtk::CssProvider> m_drawCSSProvider; /*!< CSS Provider for draw textviews */
Glib::RefPtr<Gtk::AccelGroup> m_accelGroup; /*!< Accelerator group, used for keyboard shortcut bindings */
Glib::RefPtr<Gio::Settings> m_settings; /*!< Settings to store our preferences, even during restarts */
Glib::RefPtr<Gtk::Adjustment> m_brightnessAdjustment; /*!< Bridghtness adjustment settings */
Glib::RefPtr<Gtk::Adjustment> m_maxContentWidthAdjustment; /*!< max content width adjustment settings */
Glib::RefPtr<Gtk::Adjustment> m_spacingAdjustment; /*!< Spacing adjustment settings */
Glib::RefPtr<Gtk::Adjustment> m_marginsAdjustment; /*!< Margins adjustment settings */
Glib::RefPtr<Gtk::Adjustment> m_indentAdjustment; /*!< Indent adjustment settings */
Glib::RefPtr<Gtk::CssProvider> m_drawCSSProvider; /*!< CSS Provider for draw textviews */
// Child widgets
Menu m_menu;
@ -159,6 +163,7 @@ protected:
Gtk::Button m_zoomRestoreButton;
Gtk::Button m_zoomInButton;
Gtk::FontButton m_fontButton;
Gtk::SpinButton m_maxContentWidthSpinButton;
Gtk::SpinButton m_spacingSpinButton;
Gtk::SpinButton m_marginsSpinButton;
Gtk::SpinButton m_indentSpinButton;
@ -243,6 +248,7 @@ protected:
Gtk::PopoverMenu m_settingsPopover;
Gtk::ModelButton m_copyIDButton;
Gtk::ModelButton m_copyPublicKeyButton;
Gtk::Switch m_readerViewSwitch;
Gtk::Switch m_themeSwitch;
Gtk::Label m_tableOfContentsLabel;
Gtk::Label m_networkHeadingLabel;
@ -263,11 +269,13 @@ protected:
Gtk::Label m_networkOutcomingStatusLabel;
Gtk::Label m_networkKiloBytesLabel;
Gtk::Label m_fontLabel;
Gtk::Label m_maxContentWidthLabel;
Gtk::Label m_spacingLabel;
Gtk::Label m_marginsLabel;
Gtk::Label m_indentLabel;
Gtk::Label m_textWrappingLabel;
Gtk::Label m_themeLabel;
Gtk::Label m_readerViewLabel;
Gtk::Label m_iconThemeLabel;
std::unique_ptr<Gtk::MessageDialog> m_contentPublishedDialog;
Gtk::ScrolledWindow m_scrolledToc;
@ -297,9 +305,15 @@ private:
std::string fontFamily_;
int defaultFontSize_;
int currentFontSize_;
int positionDividerDraw_;
int contentMargin_;
int contentMaxWidth_;
int fontSpacing_;
int indent_;
Gtk::WrapMode wrapMode_;
double brightnessScale_;
bool useDarkTheme_;
bool isReaderViewEnabled_;
std::string currentFileSavedPath_;
std::size_t currentHistoryIndex_;
std::vector<std::string> history_;
@ -322,6 +336,7 @@ private:
void disableEdit();
bool isEditorEnabled();
std::string getIconImageFromTheme(const std::string& iconName, const std::string& typeofIcon);
void updateMargins();
void updateCSS();
void showNotification(const Glib::ustring& title, const Glib::ustring& message = "");
};

View File

@ -1,5 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<enum id="org.libreweb.wrapmode.enum">
<value nick="WRAP_NONE" value="0"/>
<value nick="WRAP_CHAR" value="1"/>
<value nick="WRAP_WORD" value="2"/>
<value nick="WRAP_WORD_CHAR" value="3"/>
</enum>
<schema path="/org/libreweb/browser/" id="org.libreweb.browser">
<key name="width" type="i">
<default>1000</default>
@ -33,18 +39,26 @@
<default>10</default>
<summary>Font size</summary>
</key>
<key name="max-content-width" type="i">
<default>700</default>
<summary>Max document content width</summary>
</key>
<key name="spacing" type="i">
<default>0</default>
<summary>Font spacing</summary>
</key>
<key name="margins" type="i">
<default>20</default>
<default>10</default>
<summary>Text margins</summary>
</key>
<key name="indent" type="i">
<default>0</default>
<summary>Text indent</summary>
</key>
<key name="wrap-mode" enum="org.libreweb.wrapmode.enum">
<default>"WRAP_CHAR"</default>
<summary>Word wrapping mode</summary>
</key>
<key name="icon-theme" type="s">
<default>"flat"</default>
<summary>Icon theme</summary>
@ -61,5 +75,9 @@
<default>false</default>
<summary>Prefer dark theme</summary>
</key>
<key name="reader-view" type="b">
<default>true</default>
<summary>Is reader view enabled</summary>
</key>
</schema>
</schemalist>