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
Snippets
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
eta
gajim
Commits
0f0c0a6a
Commit
0f0c0a6a
authored
6 years ago
by
Philipp Hörist
Browse files
Options
Downloads
Patches
Plain Diff
Allow to load multiple widgets with get_builder()
parent
cc62761d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gajim/gtk/util.py
+10
-8
10 additions, 8 deletions
gajim/gtk/util.py
gajim/plugins/helpers.py
+4
-2
4 additions, 2 deletions
gajim/plugins/helpers.py
with
14 additions
and
10 deletions
gajim/gtk/util.py
+
10
−
8
View file @
0f0c0a6a
...
...
@@ -12,8 +12,10 @@
# You should have received a copy of the GNU General Public License
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
from
typing
import
Tuple
from
typing
import
Any
from
typing
import
List
from
typing
import
Tuple
import
os
import
sys
...
...
@@ -38,7 +40,7 @@ log = logging.getLogger('gajim.gtk.util')
class
Builder
:
def
__init__
(
self
,
filename
:
str
,
widget
:
str
=
None
,
widget
s
:
List
[
str
]
=
None
,
domain
:
str
=
None
,
gettext_
:
Any
=
None
)
->
None
:
self
.
_builder
=
Gtk
.
Builder
()
...
...
@@ -63,16 +65,16 @@ class Builder:
encoding
=
'
unicode
'
,
method
=
'
xml
'
)
if
widget
is
not
None
:
self
.
_builder
.
add_objects_from_string
(
xml_text
,
[
widget
]
)
if
widget
s
is
not
None
:
self
.
_builder
.
add_objects_from_string
(
xml_text
,
widget
s
)
else
:
# Workaround
# https://gitlab.gnome.org/GNOME/pygobject/issues/255
Gtk
.
Builder
.
__mro__
[
1
].
add_from_string
(
self
.
_builder
,
xml_text
,
len
(
xml_text
.
encode
(
"
utf-8
"
)))
else
:
if
widget
is
not
None
:
self
.
_builder
.
add_objects_from_file
(
file_path
,
[
widget
]
)
if
widget
s
is
not
None
:
self
.
_builder
.
add_objects_from_file
(
file_path
,
widget
s
)
else
:
self
.
_builder
.
add_from_file
(
file_path
)
...
...
@@ -83,8 +85,8 @@ class Builder:
return
self
.
_builder
.
get_object
(
name
)
def
get_builder
(
file_name
:
str
,
widget
:
str
=
None
)
->
Builder
:
return
Builder
(
file_name
,
widget
)
def
get_builder
(
file_name
:
str
,
widget
s
:
List
[
str
]
=
None
)
->
Builder
:
return
Builder
(
file_name
,
widget
s
)
def
load_icon
(
icon_name
,
widget
,
size
=
16
,
pixbuf
=
False
,
...
...
This diff is collapsed.
Click to expand it.
gajim/plugins/helpers.py
+
4
−
2
View file @
0f0c0a6a
...
...
@@ -23,6 +23,8 @@ Helper code related to plug-ins management system.
__all__
=
[
'
log
'
,
'
log_calls
'
,
'
Singleton
'
]
from
typing
import
List
import
logging
import
functools
...
...
@@ -135,8 +137,8 @@ class Singleton(type):
return
cls
.
instance
def
get_builder
(
file_name
:
str
,
widget
:
str
=
None
)
->
Builder
:
def
get_builder
(
file_name
:
str
,
widget
s
:
List
[
str
]
=
None
)
->
Builder
:
return
Builder
(
file_name
,
widget
,
widget
s
,
domain
=
plugins_i18n
.
DOMAIN
,
gettext_
=
plugins_i18n
.
_
)
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