Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
GNOME
Epiphany
Commits
6cfc45ed
Verified
Commit
6cfc45ed
authored
Jul 24, 2018
by
Adrián Pérez de Castro
Browse files
Add reader mode options in Preferences dialog
parent
301ac606
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/prefs-dialog.c
View file @
6cfc45ed
...
...
@@ -33,6 +33,7 @@
#include
"ephy-flatpak-utils.h"
#include
"ephy-gui.h"
#include
"ephy-langs.h"
#include
"ephy-lib-type-builtins.h"
#include
"ephy-prefs.h"
#include
"ephy-search-engine-dialog.h"
#include
"ephy-session.h"
...
...
@@ -93,7 +94,7 @@ struct _PrefsDialog {
GtkWidget
*
enable_plugins_checkbutton
;
GtkWidget
*
enable_safe_browsing_checkbutton
;
/* fonts */
/* fonts
& style
*/
GtkWidget
*
use_gnome_fonts_checkbutton
;
GtkWidget
*
custom_fonts_table
;
GtkWidget
*
sans_fontbutton
;
...
...
@@ -101,6 +102,8 @@ struct _PrefsDialog {
GtkWidget
*
mono_fontbutton
;
GtkWidget
*
css_checkbox
;
GtkWidget
*
css_edit_button
;
GtkWidget
*
reader_mode_font_style
;
GtkWidget
*
reader_mode_color_scheme
;
/* stored data */
GtkWidget
*
always
;
...
...
@@ -958,7 +961,7 @@ prefs_dialog_class_init (PrefsDialogClass *klass)
gtk_widget_class_bind_template_child
(
widget_class
,
PrefsDialog
,
download_button_label
);
gtk_widget_class_bind_template_child
(
widget_class
,
PrefsDialog
,
download_box
);
/* fonts */
/* fonts
& style
*/
gtk_widget_class_bind_template_child
(
widget_class
,
PrefsDialog
,
use_gnome_fonts_checkbutton
);
gtk_widget_class_bind_template_child
(
widget_class
,
PrefsDialog
,
custom_fonts_table
);
gtk_widget_class_bind_template_child
(
widget_class
,
PrefsDialog
,
sans_fontbutton
);
...
...
@@ -966,6 +969,8 @@ prefs_dialog_class_init (PrefsDialogClass *klass)
gtk_widget_class_bind_template_child
(
widget_class
,
PrefsDialog
,
mono_fontbutton
);
gtk_widget_class_bind_template_child
(
widget_class
,
PrefsDialog
,
css_checkbox
);
gtk_widget_class_bind_template_child
(
widget_class
,
PrefsDialog
,
css_edit_button
);
gtk_widget_class_bind_template_child
(
widget_class
,
PrefsDialog
,
reader_mode_font_style
);
gtk_widget_class_bind_template_child
(
widget_class
,
PrefsDialog
,
reader_mode_color_scheme
);
/* stored data */
gtk_widget_class_bind_template_child
(
widget_class
,
PrefsDialog
,
always
);
...
...
@@ -1984,12 +1989,124 @@ setup_general_page (PrefsDialog *dialog)
create_download_path_button
(
dialog
);
}
enum
{
ENUM_MODEL_COLUMN_LABEL
,
ENUM_MODEL_COLUMN_NICK
,
ENUM_MODEL_N_COLUMNS
,
};
typedef
struct
{
gint
value
;
const
char
*
label
;
}
EnumModelItem
;
static
GtkTreeModel
*
enum_model_new
(
GType
enum_type
,
gsize
n_items
,
const
EnumModelItem
*
items
)
{
GtkListStore
*
model
;
GEnumClass
*
enum_class
;
gsize
i
;
enum_class
=
g_type_class_ref
(
enum_type
);
model
=
gtk_list_store_new
(
ENUM_MODEL_N_COLUMNS
,
G_TYPE_STRING
,
G_TYPE_STRING
);
for
(
i
=
0
;
i
<
n_items
;
i
++
)
{
GtkTreeIter
iter
;
const
char
*
nick
;
guint
j
;
nick
=
NULL
;
for
(
j
=
0
;
j
<
enum_class
->
n_values
;
j
++
)
{
if
(
enum_class
->
values
[
j
].
value
==
items
[
i
].
value
)
{
nick
=
enum_class
->
values
[
j
].
value_nick
;
break
;
}
}
g_assert
(
nick
!=
NULL
);
gtk_list_store_append
(
model
,
&
iter
);
gtk_list_store_set
(
model
,
&
iter
,
ENUM_MODEL_COLUMN_LABEL
,
_
(
items
[
i
].
label
),
ENUM_MODEL_COLUMN_NICK
,
nick
,
-
1
);
}
g_type_class_unref
(
enum_class
);
return
GTK_TREE_MODEL
(
model
);
}
static
void
enum_model_attach
(
GtkTreeModel
*
model
,
GtkComboBox
*
combobox
,
GSettings
*
settings
,
const
char
*
key
)
{
GtkCellRenderer
*
renderer
;
gtk_cell_layout_clear
(
GTK_CELL_LAYOUT
(
combobox
));
gtk_combo_box_set_model
(
combobox
,
model
);
gtk_combo_box_set_id_column
(
combobox
,
ENUM_MODEL_COLUMN_NICK
);
g_settings_bind
(
settings
,
key
,
combobox
,
"active-id"
,
G_SETTINGS_BIND_DEFAULT
);
renderer
=
gtk_cell_renderer_text_new
();
gtk_cell_layout_pack_start
(
GTK_CELL_LAYOUT
(
combobox
),
renderer
,
FALSE
);
gtk_cell_layout_add_attribute
(
GTK_CELL_LAYOUT
(
combobox
),
renderer
,
"text"
,
ENUM_MODEL_COLUMN_LABEL
);
}
static
const
EnumModelItem
reader_font_style_items
[]
=
{
{
EPHY_PREFS_READER_FONT_STYLE_SANS
,
N_
(
"Sans"
)
},
{
EPHY_PREFS_READER_FONT_STYLE_SERIF
,
N_
(
"Serif"
)
},
};
static
const
EnumModelItem
reader_color_scheme_items
[]
=
{
{
EPHY_PREFS_READER_COLORS_LIGHT
,
N_
(
"Light"
)
},
{
EPHY_PREFS_READER_COLORS_DARK
,
N_
(
"Dark"
)
},
};
static
void
setup_fonts_page
(
PrefsDialog
*
dialog
)
{
GSettings
*
web_settings
;
GSettings
*
reader_settings
;
GtkTreeModel
*
model
;
web_settings
=
ephy_settings_get
(
EPHY_PREFS_WEB_SCHEMA
);
reader_settings
=
ephy_settings_get
(
EPHY_PREFS_READER_SCHEMA
);
model
=
enum_model_new
(
EPHY_TYPE_PREFS_READER_FONT_STYLE
,
G_N_ELEMENTS
(
reader_font_style_items
),
reader_font_style_items
);
enum_model_attach
(
model
,
GTK_COMBO_BOX
(
dialog
->
reader_mode_font_style
),
reader_settings
,
EPHY_PREFS_READER_FONT_STYLE
);
g_object_unref
(
model
);
model
=
enum_model_new
(
EPHY_TYPE_PREFS_READER_COLOR_SCHEME
,
G_N_ELEMENTS
(
reader_color_scheme_items
),
reader_color_scheme_items
);
enum_model_attach
(
model
,
GTK_COMBO_BOX
(
dialog
->
reader_mode_color_scheme
),
reader_settings
,
EPHY_PREFS_READER_COLOR_SCHEME
);
g_object_unref
(
model
);
g_settings_bind
(
web_settings
,
EPHY_PREFS_WEB_USE_GNOME_FONTS
,
...
...
@@ -2027,6 +2144,7 @@ setup_fonts_page (PrefsDialog *dialog)
dialog
->
css_edit_button
,
"sensitive"
,
G_SETTINGS_BIND_GET
);
g_signal_connect
(
dialog
->
css_edit_button
,
"clicked"
,
G_CALLBACK
(
css_edit_button_clicked_cb
),
...
...
src/resources/gtk/prefs-dialog.ui
View file @
6cfc45ed
...
...
@@ -265,7 +265,7 @@
</attributes>
</object>
</child>
<child>
<child>
<object
class=
"GtkButton"
id=
"search_engine_dialog_button"
>
<property
name=
"label"
translatable=
"yes"
>
_Manage Search Engines
</property>
<property
name=
"visible"
>
True
</property>
...
...
@@ -275,21 +275,21 @@
</child>
</object>
</child>
<child>
<object
class=
"GtkLabel"
>
<child>
<object
class=
"GtkLabel"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"margin_left"
>
12
</property>
<property
name=
"margin_left"
>
12
</property>
<property
name=
"halign"
>
start
</property>
<property
name=
"label"
translatable=
"yes"
>
You can select different search engines to use.
</property>
<attributes>
</attributes>
</object>
<packing>
<property
name=
"expand"
>
False
</property>
<property
name=
"fill"
>
False
</property>
<property
name=
"position"
>
1
</property>
</packing>
</child>
<packing>
<property
name=
"expand"
>
False
</property>
<property
name=
"fill"
>
False
</property>
<property
name=
"position"
>
1
</property>
</packing>
</child>
</object>
</child>
<child>
...
...
@@ -538,6 +538,100 @@
</child>
</object>
</child>
<child>
<object
class=
"GtkBox"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"orientation"
>
vertical
</property>
<property
name=
"spacing"
>
6
</property>
<property
name=
"margin-top"
>
12
</property>
<child>
<object
class=
"GtkLabel"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"halign"
>
start
</property>
<property
name=
"margin_top"
>
6
</property>
<property
name=
"label"
translatable=
"yes"
>
Reader Mode
</property>
<attributes>
<attribute
name=
"weight"
value=
"bold"
/>
</attributes>
</object>
<packing>
<property
name=
"expand"
>
False
</property>
<property
name=
"fill"
>
True
</property>
<property
name=
"position"
>
0
</property>
</packing>
</child>
<child>
<object
class=
"GtkGrid"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"margin_left"
>
12
</property>
<property
name=
"row_spacing"
>
6
</property>
<property
name=
"hexpand"
>
True
</property>
<property
name=
"column_spacing"
>
12
</property>
<child>
<object
class=
"GtkLabel"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"halign"
>
start
</property>
<property
name=
"valign"
>
center
</property>
<property
name=
"margin_left"
>
12
</property>
<property
name=
"label"
translatable=
"yes"
>
Font style:
</property>
</object>
<packing>
<property
name=
"left_attach"
>
0
</property>
<property
name=
"top_attach"
>
0
</property>
</packing>
</child>
<child>
<object
class=
"GtkLabel"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"halign"
>
start
</property>
<property
name=
"valign"
>
center
</property>
<property
name=
"margin_left"
>
12
</property>
<property
name=
"label"
translatable=
"yes"
>
Color scheme:
</property>
</object>
<packing>
<property
name=
"left_attach"
>
0
</property>
<property
name=
"top_attach"
>
1
</property>
</packing>
</child>
<child>
<object
class=
"GtkComboBox"
id=
"reader_mode_font_style"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"hexpand"
>
True
</property>
</object>
<packing>
<property
name=
"left_attach"
>
1
</property>
<property
name=
"top_attach"
>
0
</property>
</packing>
</child>
<child>
<object
class=
"GtkComboBox"
id=
"reader_mode_color_scheme"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"hexpand"
>
True
</property>
</object>
<packing>
<property
name=
"left_attach"
>
1
</property>
<property
name=
"top_attach"
>
1
</property>
</packing>
</child>
</object>
<packing>
<property
name=
"expand"
>
False
</property>
<property
name=
"fill"
>
True
</property>
<property
name=
"position"
>
1
</property>
</packing>
</child>
</object>
<packing>
<property
name=
"expand"
>
False
</property>
<property
name=
"fill"
>
True
</property>
<property
name=
"position"
>
2
</property>
</packing>
</child>
</object>
</child>
</object>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment