Philipp Hörist pushed to branch master at gajim / gajim

Commits:
6c43c0f4 by Philipp Hörist at 2018-10-12T22:33:33Z
Allow to load multiple widgets with get_builder()

- - - - -


2 changed files:

- gajim/gtk/util.py
- gajim/plugins/helpers.py


Changes:

=====================================
gajim/gtk/util.py
=====================================
@@ -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,
+                 widgets: 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 widgets is not None:
+                self._builder.add_objects_from_string(xml_text, widgets)
             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 widgets is not None:
+                self._builder.add_objects_from_file(file_path, widgets)
             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, widgets: List[str] = None) -> Builder:
+    return Builder(file_name, widgets)
 
 
 def load_icon(icon_name, widget, size=16, pixbuf=False,


=====================================
gajim/plugins/helpers.py
=====================================
@@ -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, widgets: List[str] = None) -> Builder:
     return Builder(file_name,
-                   widget,
+                   widgets,
                    domain=plugins_i18n.DOMAIN,
                    gettext_=plugins_i18n._)



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/commit/6c43c0f40844576859a0018c46ce5e1a43997207

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/commit/6c43c0f40844576859a0018c46ce5e1a43997207
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to