Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Briar GTK
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
briar
Briar GTK
Commits
09eafd1c
Commit
09eafd1c
authored
5 years ago
by
Nico
Browse files
Options
Downloads
Patches
Plain Diff
Rework window and startup_container to make them more clean
parent
c163231d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#3680
passed
5 years ago
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/briar/gtk/containers/startup.py
+7
-12
7 additions, 12 deletions
src/briar/gtk/containers/startup.py
src/briar/gtk/window.py
+18
-13
18 additions, 13 deletions
src/briar/gtk/window.py
with
25 additions
and
25 deletions
src/briar/gtk/containers/startup.py
+
7
−
12
View file @
09eafd1c
...
...
@@ -2,7 +2,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
# License-Filename: LICENSE.md
from
gi.repository
import
GLib
,
GObject
,
Gtk
from
gi.repository
import
GLib
from
briar.gtk.container
import
Container
from
briar.gtk.define
import
App
...
...
@@ -13,7 +13,6 @@ class StartupContainer(Container):
def
__init__
(
self
):
super
().
__init__
()
self
.
_api
=
App
().
api
StartupContainer
.
_register_signals
()
self
.
_setup_view
()
# pylint: disable=unused-argument
...
...
@@ -29,18 +28,13 @@ class StartupContainer(Container):
"
password_confirm_entry
"
).
get_text
()
if
password
!=
password_confirm
:
raise
Exception
(
"
Passwords do not match
"
)
self
.
_api
.
register
((
self
.
username
,
password
),
self
.
_startup_finished
)
self
.
_api
.
register
((
self
.
username
,
password
),
StartupContainer
.
_startup_completed
)
# pylint: disable=unused-argument
def
on_login_pressed
(
self
,
button
):
password
=
self
.
builder
.
get_object
(
"
password_entry
"
).
get_text
()
self
.
_api
.
login
(
password
,
self
.
_startup_finished
)
@staticmethod
def
_register_signals
():
GObject
.
signal_new
(
"
briar_startup_completed
"
,
Gtk
.
Overlay
,
GObject
.
SignalFlags
.
RUN_LAST
,
GObject
.
TYPE_BOOLEAN
,
(
GObject
.
TYPE_STRING
,))
self
.
_api
.
login
(
password
,
StartupContainer
.
_startup_completed
)
def
_setup_view
(
self
):
self
.
set_hexpand
(
True
)
...
...
@@ -53,8 +47,9 @@ class StartupContainer(Container):
self
.
add
(
self
.
builder
.
get_object
(
"
login
"
))
self
.
builder
.
connect_signals
(
self
)
def
_startup_finished
(
self
,
succeeded
):
@staticmethod
def
_startup_completed
(
succeeded
):
if
succeeded
:
GLib
.
idle_add
(
self
.
emit
,
"
briar
_startup_completed
"
,
(
succeeded
,)
)
GLib
.
idle_add
(
App
().
window
.
on
_startup_completed
)
return
print
(
"
Startup failed
"
)
This diff is collapsed.
Click to expand it.
src/briar/gtk/window.py
+
18
−
13
View file @
09eafd1c
...
...
@@ -13,10 +13,10 @@ from briar.gtk.toolbar import Toolbar
class
Window
(
Gtk
.
ApplicationWindow
):
DEFAULT_WINDOW_SIZE
=
(
600
,
400
)
def
__init__
(
self
):
Gtk
.
ApplicationWindow
.
__init__
(
self
,
application
=
App
(),
title
=
APPLICATION_NAME
,
icon_name
=
APPLICATION_ID
)
self
.
_initialize_gtk_application_window
()
self
.
_setup_content
()
@property
...
...
@@ -27,18 +27,27 @@ class Window(Gtk.ApplicationWindow):
def
toolbar
(
self
):
return
self
.
_toolbar
def
_initialize_gtk_application_window
(
self
):
Gtk
.
ApplicationWindow
.
__init__
(
self
,
application
=
App
(),
title
=
APPLICATION_NAME
,
icon_name
=
APPLICATION_ID
)
def
_setup_content
(
self
):
self
.
_setup_size
(
(
600
,
400
))
# TODO: do properly (constants, save
)
self
.
_setup_size
(
self
.
DEFAULT_WINDOW_SIZE
)
self
.
_setup_toolbar
()
self
.
_setup_grid
()
self
.
_setup_startup_container
()
def
_setup_size
(
self
,
size
):
if
len
(
size
)
==
2
and
\
isinstance
(
size
[
0
],
int
)
and
\
isinstance
(
size
[
1
],
int
):
if
Window
.
_size_is_valid
(
size
):
self
.
resize
(
size
[
0
],
size
[
1
])
@staticmethod
def
_size_is_valid
(
size
):
return
len
(
size
)
==
2
and
\
isinstance
(
size
[
0
],
int
)
and
\
isinstance
(
size
[
1
],
int
)
def
_setup_toolbar
(
self
):
self
.
_toolbar
=
Toolbar
()
self
.
_toolbar
.
show
()
...
...
@@ -47,20 +56,15 @@ class Window(Gtk.ApplicationWindow):
def
_setup_grid
(
self
):
self
.
_grid
=
Gtk
.
Grid
()
self
.
_grid
.
set_orientation
(
Gtk
.
Orientation
.
HORIZONTAL
)
self
.
_grid
.
show
()
self
.
add
(
self
.
_grid
)
def
_setup_startup_container
(
self
):
self
.
_container
=
StartupContainer
()
self
.
_container
.
show
()
self
.
_container
.
connect
(
"
briar_startup_completed
"
,
self
.
_on_startup_completed
)
self
.
_grid
.
add
(
self
.
_container
)
# TODO: remove unused arguments
# pylint: disable=unused-argument
def
_on_startup_completed
(
self
,
inst
,
obj
):
def
on_startup_completed
(
self
):
self
.
_grid
.
destroy
()
self
.
_setup_grid
()
self
.
_setup_main_container
()
...
...
@@ -81,6 +85,7 @@ class Window(Gtk.ApplicationWindow):
self
.
_grid
.
add
(
self
.
_container
)
self
.
_toolbar
.
show_back_button
(
True
,
self
.
_back_to_main
)
# pylint: disable=unused-argument
def
_back_to_main
(
self
,
widget
):
self
.
_grid
.
destroy
()
self
.
_setup_grid
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment