added simple wait dialog

This commit is contained in:
DYefremov
2018-02-18 17:14:02 +03:00
parent 5a76601ae6
commit 25ee7f3538
6 changed files with 148 additions and 10 deletions

View File

@@ -1,24 +1,36 @@
""" Common module for showing dialogs """
from enum import Enum
from app.commons import run_idle
from . import Gtk, UI_RESOURCES_PATH
class DialogType(Enum):
INPUT = "input_dialog"
MESSAGE = ""
CHOOSER = "path_chooser_dialog"
ERROR = "error_dialog"
QUESTION = "question_dialog"
ABOUT = "about_dialog"
WAIT = "wait_dialog"
class WaitDialog:
def __init__(self, transient):
builder, dialog = get_dialog_from_xml(DialogType.WAIT, transient)
self._dialog = dialog
self._dialog.set_transient_for(transient)
def show(self):
self._dialog.show()
@run_idle
def hide(self):
self._dialog.hide()
def show_dialog(dialog_type: DialogType, transient, text=None, options=None, action_type=None, file_filter=None):
""" Shows dialogs by name """
builder = Gtk.Builder()
builder.add_from_file(UI_RESOURCES_PATH + "dialogs.glade")
dialog = builder.get_object(dialog_type.value)
dialog.set_transient_for(transient)
builder, dialog = get_dialog_from_xml(dialog_type, transient)
if dialog_type is DialogType.CHOOSER and options:
if action_type is not None:
@@ -58,6 +70,14 @@ def show_dialog(dialog_type: DialogType, transient, text=None, options=None, act
return response
def get_dialog_from_xml(dialog_type, transient):
builder = Gtk.Builder()
builder.add_from_file(UI_RESOURCES_PATH + "dialogs.glade")
dialog = builder.get_object(dialog_type.value)
dialog.set_transient_for(transient)
return builder, dialog
def get_chooser_dialog(transient, options, pattern, name):
file_filter = Gtk.FileFilter()
file_filter.add_pattern(pattern)