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
World
eolie
Commits
d57b49ba
Commit
d57b49ba
authored
Nov 16, 2017
by
Cédric Bellegarde
Browse files
Load profiles from disk
parent
a67985ce
Changes
3
Hide whitespace changes
Inline
Side-by-side
eolie/application.py
View file @
d57b49ba
...
...
@@ -23,6 +23,7 @@ from pickle import dump, load
from
urllib.parse
import
urlparse
from
getpass
import
getuser
from
time
import
time
import
json
from
eolie.settings
import
Settings
,
SettingsDialog
from
eolie.window
import
Window
...
...
@@ -40,6 +41,7 @@ from eolie.menu_pages import PagesMenu
from
eolie.helper_dbus
import
DBusHelper
from
eolie.helper_task
import
TaskHelper
from
eolie.define
import
EOLIE_DATA_PATH
,
TimeSpan
,
TimeSpanValues
,
LoadingType
from
eolie.define
import
PROFILES
from
eolie.utils
import
is_unity
,
wanted_loading_type
...
...
@@ -216,6 +218,26 @@ class Application(Gtk.Application):
self
.
__unity
.
set_property
(
"progress"
,
fraction
)
self
.
__unity
.
set_property
(
"progress_visible"
,
fraction
!=
1.0
)
def
set_profiles
(
self
):
"""
Set profiles
"""
try
:
f
=
Gio
.
File
.
new_for_path
(
EOLIE_DATA_PATH
+
"/profiles.json"
)
if
f
.
query_exists
():
(
status
,
contents
,
tag
)
=
f
.
load_contents
(
None
)
self
.
__profiles
=
json
.
loads
(
contents
.
decode
(
"utf-8"
))
else
:
content
=
json
.
dumps
(
PROFILES
)
f
.
replace_contents
(
content
.
encode
(
"utf-8"
),
None
,
False
,
Gio
.
FileCreateFlags
.
REPLACE_DESTINATION
,
None
)
self
.
__profiles
=
PROFILES
except
Exception
as
e
:
print
(
"Application::set_profiles():"
,
e
)
def
quit
(
self
,
vacuum
=
False
):
"""
Quit application
...
...
@@ -244,6 +266,14 @@ class Application(Gtk.Application):
else
:
Gio
.
Application
.
quit
(
self
)
@
property
def
profiles
(
self
):
"""
Get profiles
@return {}
"""
return
self
.
__profiles
@
property
def
start_page
(
self
):
"""
...
...
@@ -382,19 +412,7 @@ class Application(Gtk.Application):
pass
# Init profiles
f
=
Gio
.
File
.
new_for_path
(
EOLIE_DATA_PATH
+
"/profiles.json"
)
if
not
f
.
query_exists
():
try
:
import
json
from
eolie.define
import
PROFILES
content
=
json
.
dumps
(
PROFILES
)
f
.
replace_contents
(
content
.
encode
(
"utf-8"
),
None
,
False
,
Gio
.
FileCreateFlags
.
REPLACE_DESTINATION
,
None
)
except
Exception
as
e
:
print
(
"Application::__init():"
,
e
)
self
.
set_profiles
()
shortcut_action
=
Gio
.
SimpleAction
.
new
(
'shortcut'
,
GLib
.
VariantType
.
new
(
's'
))
...
...
eolie/dialog_cookies.py
View file @
d57b49ba
...
...
@@ -227,14 +227,15 @@ class CookiesDialog:
request
=
"DELETE FROM moz_cookies WHERE "
filters
=
()
for
row
in
rows
:
request
+=
"host=?
AND
"
request
+=
"host=?
OR
"
filters
+=
(
row
.
item
.
name
,)
request
+=
"
1
"
request
+=
"
0
"
sql
=
sqlite3
.
connect
(
path
,
600.0
)
sql
.
execute
(
request
,
filters
)
sql
.
commit
()
except
Exception
as
e
:
print
(
"CookiesDialog::_on_dialog_response():"
,
e
)
El
().
set_profiles
()
def
_on_entry_changed
(
self
,
entry
):
"""
...
...
@@ -361,12 +362,7 @@ class CookiesDialog:
"""
# Load user profiles
try
:
f
=
Gio
.
File
.
new_for_path
(
EOLIE_DATA_PATH
+
"/profiles.json"
)
if
f
.
query_exists
():
(
status
,
contents
,
tag
)
=
f
.
load_contents
(
None
)
profiles
=
json
.
loads
(
contents
.
decode
(
"utf-8"
))
self
.
__add_profiles
(
profiles
)
self
.
__add_profiles
(
El
().
profiles
)
except
Exception
as
e
:
print
(
"DialogSearchEngine::__populate():"
,
e
)
...
...
eolie/utils.py
View file @
d57b49ba
...
...
@@ -18,7 +18,7 @@ import cairo
from
random
import
choice
from
base64
import
b64encode
from
eolie.define
import
El
,
ArtSize
,
LoadingType
,
PROFILES
from
eolie.define
import
El
,
ArtSize
,
LoadingType
def
name_from_profile_id
(
id
):
...
...
@@ -27,8 +27,8 @@ def name_from_profile_id(id):
@param id as str
@return str
"""
if
id
in
PROFILES
.
keys
()
and
id
!=
"default"
:
return
"%s> "
%
PROFILES
[
id
]
if
id
in
El
().
profiles
.
keys
()
and
id
!=
"default"
:
return
"%s> "
%
El
().
profiles
[
id
]
else
:
return
""
...
...
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