Add annotations
- Add a gtk/types modules - Add a gtk/const module to prevent circular imports
This commit is contained in:
parent
4aca59051f
commit
95bd86320b
|
@ -0,0 +1,19 @@
|
||||||
|
# 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/>.
|
||||||
|
|
||||||
|
# Constants for the gtk module
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
Filter = namedtuple('Filter', 'name pattern default')
|
|
@ -18,7 +18,6 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from collections import namedtuple
|
|
||||||
|
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
from gi.repository import GdkPixbuf
|
from gi.repository import GdkPixbuf
|
||||||
|
@ -26,11 +25,11 @@ from gi.repository import GObject
|
||||||
|
|
||||||
from gajim.common import app
|
from gajim.common import app
|
||||||
from gajim.common.i18n import _
|
from gajim.common.i18n import _
|
||||||
|
from gajim.gtk.const import Filter
|
||||||
Filter = namedtuple('Filter', 'name pattern default')
|
from gajim.gtk.types import FilterList # pylint: disable=unused-import
|
||||||
|
|
||||||
|
|
||||||
def _require_native():
|
def _require_native() -> bool:
|
||||||
if app.is_flatpak():
|
if app.is_flatpak():
|
||||||
return True
|
return True
|
||||||
if sys.platform in ('win32', 'darwin'):
|
if sys.platform in ('win32', 'darwin'):
|
||||||
|
@ -85,7 +84,7 @@ class BaseFileChooser:
|
||||||
class BaseFileOpenDialog:
|
class BaseFileOpenDialog:
|
||||||
|
|
||||||
_title = _('Choose File to Send…')
|
_title = _('Choose File to Send…')
|
||||||
_filters = [Filter(_('All files'), '*', True)]
|
_filters = [Filter(_('All files'), '*', True)] # type: FilterList
|
||||||
|
|
||||||
|
|
||||||
class BaseAvatarChooserDialog:
|
class BaseAvatarChooserDialog:
|
||||||
|
@ -96,7 +95,7 @@ class BaseAvatarChooserDialog:
|
||||||
if _require_native():
|
if _require_native():
|
||||||
_filters = [Filter(_('PNG files'), '*.png', True),
|
_filters = [Filter(_('PNG files'), '*.png', True),
|
||||||
Filter(_('JPEG files'), '*.jp*g', False),
|
Filter(_('JPEG files'), '*.jp*g', False),
|
||||||
Filter(_('SVG files'), '*.svg', False)]
|
Filter(_('SVG files'), '*.svg', False)] # type: FilterList
|
||||||
else:
|
else:
|
||||||
_filters = [Filter(_('Images'), ['image/png',
|
_filters = [Filter(_('Images'), ['image/png',
|
||||||
'image/jpeg',
|
'image/jpeg',
|
||||||
|
@ -106,7 +105,7 @@ class BaseAvatarChooserDialog:
|
||||||
class NativeFileChooserDialog(Gtk.FileChooserNative, BaseFileChooser):
|
class NativeFileChooserDialog(Gtk.FileChooserNative, BaseFileChooser):
|
||||||
|
|
||||||
_title = ''
|
_title = ''
|
||||||
_filters = []
|
_filters = [] # type: FilterList
|
||||||
_action = Gtk.FileChooserAction.OPEN
|
_action = Gtk.FileChooserAction.OPEN
|
||||||
|
|
||||||
def __init__(self, accept_cb, cancel_cb=None, transient_for=None,
|
def __init__(self, accept_cb, cancel_cb=None, transient_for=None,
|
||||||
|
@ -161,7 +160,7 @@ class NativeAvatarChooserDialog(BaseAvatarChooserDialog, NativeFileChooserDialog
|
||||||
class GtkFileChooserDialog(Gtk.FileChooserDialog, BaseFileChooser):
|
class GtkFileChooserDialog(Gtk.FileChooserDialog, BaseFileChooser):
|
||||||
|
|
||||||
_title = ''
|
_title = ''
|
||||||
_filters = []
|
_filters = [] # type: FilterList
|
||||||
_action = Gtk.FileChooserAction.OPEN
|
_action = Gtk.FileChooserAction.OPEN
|
||||||
_preivew_size = (200, 200)
|
_preivew_size = (200, 200)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
# 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/>.
|
||||||
|
|
||||||
|
# Types for typechecking
|
||||||
|
|
||||||
|
from typing import ClassVar
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
from gajim.gtk.const import Filter
|
||||||
|
|
||||||
|
FilterList = ClassVar[List[Filter]]
|
Loading…
Reference in New Issue