Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Contributor 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
mesonium
gajim
Commits
4d650b6b
Commit
4d650b6b
authored
3 years ago
by
Philipp Hörist
Browse files
Options
Downloads
Patches
Plain Diff
Add ApplyButtonBox
parent
a1f58a5a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gajim/gtk/apply_button_box.py
+75
-0
75 additions, 0 deletions
gajim/gtk/apply_button_box.py
pyrightconfig.json
+1
-0
1 addition, 0 deletions
pyrightconfig.json
with
76 additions
and
0 deletions
gajim/gtk/apply_button_box.py
0 → 100644
+
75
−
0
View file @
4d650b6b
# This file is part of Gajim.
#
# Gajim is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation; version 3 only.
#
# Gajim is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
from
__future__
import
annotations
from
typing
import
Any
from
typing
import
Callable
from
gi.repository
import
Gtk
class
ApplyButtonBox
(
Gtk
.
Box
):
def
__init__
(
self
,
button_text
:
str
,
on_clicked
:
Callable
[[
Gtk
.
Button
],
Any
])
->
None
:
Gtk
.
Box
.
__init__
(
self
,
orientation
=
Gtk
.
Orientation
.
HORIZONTAL
,
spacing
=
6
)
self
.
_status_image
=
Gtk
.
Image
(
no_show_all
=
True
)
self
.
_spinner
=
Gtk
.
Spinner
(
no_show_all
=
True
)
self
.
_button
=
Gtk
.
Button
(
label
=
button_text
,
sensitive
=
False
)
self
.
_button
.
get_style_context
().
add_class
(
'
suggested-action
'
)
self
.
_button
.
connect
(
'
clicked
'
,
self
.
_on_clicked
)
self
.
_button
.
connect
(
'
clicked
'
,
on_clicked
)
self
.
add
(
self
.
_status_image
)
self
.
add
(
self
.
_spinner
)
self
.
add
(
self
.
_button
)
def
_on_clicked
(
self
,
button
:
Gtk
.
Button
)
->
None
:
button
.
set_sensitive
(
False
)
self
.
_spinner
.
show
()
self
.
_spinner
.
start
()
def
set_button_state
(
self
,
state
:
bool
)
->
None
:
if
state
:
self
.
_status_image
.
hide
()
self
.
_button
.
set_sensitive
(
state
)
def
set_success
(
self
)
->
None
:
self
.
_spinner
.
stop
()
self
.
_spinner
.
hide
()
self
.
_set_status_image
(
'
success
'
)
def
set_error
(
self
,
tooltip_text
:
str
):
self
.
_spinner
.
stop
()
self
.
_spinner
.
hide
()
self
.
_set_status_image
(
'
error
'
,
tooltip_text
)
self
.
_button
.
set_sensitive
(
True
)
def
_set_status_image
(
self
,
state
:
str
,
tooltip_text
:
str
=
''
)
->
None
:
icon_name
=
'
feather-check-symbolic
'
css_class
=
'
success-color
'
if
state
==
'
error
'
:
icon_name
=
'
dialog-warning-symbolic
'
css_class
=
'
warning-color
'
self
.
_status_image
.
set_from_icon_name
(
icon_name
,
Gtk
.
IconSize
.
MENU
)
self
.
_status_image
.
get_style_context
().
add_class
(
css_class
)
self
.
_status_image
.
set_tooltip_text
(
tooltip_text
)
self
.
_status_image
.
show
()
This diff is collapsed.
Click to expand it.
pyrightconfig.json
+
1
−
0
View file @
4d650b6b
...
...
@@ -24,6 +24,7 @@
"gajim/gtk/about.py"
,
"gajim/gtk/account_page.py"
,
"gajim/gtk/account_side_bar.py"
,
"gajim/gtk/apply_button_box.py"
,
"gajim/gtk/app_page.py"
,
"gajim/gtk/app_side_bar.py"
,
"gajim/gtk/application.py"
,
...
...
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