-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathloading_window.py
97 lines (73 loc) · 2.93 KB
/
loading_window.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# -*- coding: utf-8 -*-
# processing_window.py
# Gtk.Window
#
# Copyright (C) 2014 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# the GNU General Public License v.2, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY expressed or implied, including the implied warranties 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 this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
# source code or documentation are not subject to the GNU General Public
# License and may only be used or replicated with the express permission of
# Red Hat, Inc.
#
# Red Hat Author(s): Vojtech Trefny <[email protected]>
#
# ---------------------------------------------------------------------------- #
import gi
gi.require_version("Gtk", "3.0")
gi.require_version("GLib", "2.0")
gi.require_version("Pango", "1.0")
from gi.repository import Gtk, GLib, Pango
from .i18n import _
# ---------------------------------------------------------------------------- #
class LoadingWindow(Gtk.Dialog):
""" Processing actions dialog
"""
def __init__(self, parent_window):
""" :param main_window: BlivetGUI main window
"""
Gtk.Dialog.__init__(self)
self.set_transient_for(parent_window)
self.set_title(_("Probing storage"))
self.set_border_width(8)
self.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
self.grid = Gtk.Grid(column_homogeneous=False, row_spacing=10, column_spacing=5)
self.grid.set_margin_bottom(12)
box = self.get_content_area()
box.add(self.grid)
self.pulse = True
self.label = Gtk.Label()
self.label.set_size_request(350, -1)
self.label.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
self.label.set_line_wrap(True)
self.label.set_text(_("Scanning storage configuration..."))
self.grid.attach(self.label, 0, 0, 3, 1)
self.progressbar = Gtk.ProgressBar()
self.grid.attach(self.progressbar, 0, 1, 3, 1)
self.timeout_id = GLib.timeout_add(50, self.on_timeout, None)
self.set_resizable(False)
self.show_all()
def stop(self):
self.destroy()
def start(self):
""" Start the dialog
"""
self.progressbar.set_fraction(0)
self.run()
self.destroy()
def on_timeout(self, _user_data):
""" Timeout function for progressbar pulsing
"""
if self.pulse:
self.progressbar.pulse()
return True
else:
return False