mirror of
https://github.com/gryf/pygtktalog.git
synced 2025-12-17 11:30:19 +01:00
* Dialgos code clean up.
* Added support for secondary text in dialogs.
This commit is contained in:
@@ -7,14 +7,15 @@ class Qst(object):
|
|||||||
if "OK" button pressed, return "True"
|
if "OK" button pressed, return "True"
|
||||||
"Cancel" button return "False"
|
"Cancel" button return "False"
|
||||||
"""
|
"""
|
||||||
def __init__(self, title="", message=""):
|
def __init__(self, title="", message="", secondarymsg=""):
|
||||||
self.dialog = gtk.MessageDialog(
|
self.dialog = gtk.MessageDialog(
|
||||||
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
|
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||||
type = gtk.MESSAGE_QUESTION,
|
type = gtk.MESSAGE_QUESTION,
|
||||||
buttons = gtk.BUTTONS_OK_CANCEL,
|
buttons = gtk.BUTTONS_OK_CANCEL,
|
||||||
|
message_format = message,
|
||||||
)
|
)
|
||||||
self.dialog.set_title(title)
|
self.dialog.set_title(title)
|
||||||
self.dialog.set_markup(message)
|
self.dialog.format_secondary_text(secondarymsg)
|
||||||
def run(self):
|
def run(self):
|
||||||
retval = self.dialog.run()
|
retval = self.dialog.run()
|
||||||
self.dialog.destroy()
|
self.dialog.destroy()
|
||||||
@@ -24,14 +25,15 @@ class Qst(object):
|
|||||||
|
|
||||||
class Inf(object):
|
class Inf(object):
|
||||||
"""Show simple dialog for notices"""
|
"""Show simple dialog for notices"""
|
||||||
def __init__(self, title="", message=""):
|
def __init__(self, title="", message="", secondarymsg=""):
|
||||||
self.dialog = gtk.MessageDialog(
|
self.dialog = gtk.MessageDialog(
|
||||||
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
|
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||||
type = gtk.MESSAGE_INFO,
|
type = gtk.MESSAGE_INFO,
|
||||||
buttons = gtk.BUTTONS_OK,
|
buttons = gtk.BUTTONS_OK,
|
||||||
|
message_format = message,
|
||||||
)
|
)
|
||||||
self.dialog.set_title(title)
|
self.dialog.set_title(title)
|
||||||
self.dialog.set_markup(message)
|
self.dialog.format_secondary_text(secondarymsg)
|
||||||
self.dialog.connect('response', lambda dialog, response: self.ret(response))
|
self.dialog.connect('response', lambda dialog, response: self.ret(response))
|
||||||
self.dialog.show()
|
self.dialog.show()
|
||||||
def ret(self,result):
|
def ret(self,result):
|
||||||
@@ -40,14 +42,15 @@ class Inf(object):
|
|||||||
|
|
||||||
class Wrn(object):
|
class Wrn(object):
|
||||||
"""Show simple dialog for warnings"""
|
"""Show simple dialog for warnings"""
|
||||||
def __init__(self, title="", message=""):
|
def __init__(self, title="", message="", secondarymsg=""):
|
||||||
self.dialog = gtk.MessageDialog(
|
self.dialog = gtk.MessageDialog(
|
||||||
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
|
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||||
type = gtk.MESSAGE_WARNING,
|
type = gtk.MESSAGE_WARNING,
|
||||||
buttons = gtk.BUTTONS_CLOSE,
|
buttons = gtk.BUTTONS_CLOSE,
|
||||||
|
message_format = message,
|
||||||
)
|
)
|
||||||
self.dialog.set_title(title)
|
self.dialog.set_title(title)
|
||||||
self.dialog.set_markup(message)
|
self.dialog.format_secondary_text(secondarymsg)
|
||||||
self.dialog.connect('response', lambda dialog, response: self.ret(response))
|
self.dialog.connect('response', lambda dialog, response: self.ret(response))
|
||||||
self.dialog.show()
|
self.dialog.show()
|
||||||
def ret(self,result):
|
def ret(self,result):
|
||||||
@@ -56,14 +59,15 @@ class Wrn(object):
|
|||||||
|
|
||||||
class Err(object):
|
class Err(object):
|
||||||
"""Show simple dialog for errors"""
|
"""Show simple dialog for errors"""
|
||||||
def __init__(self, title="", message=""):
|
def __init__(self, title="", message="", secondarymsg=""):
|
||||||
self.dialog = gtk.MessageDialog(
|
self.dialog = gtk.MessageDialog(
|
||||||
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
|
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||||
type = gtk.MESSAGE_ERROR,
|
type = gtk.MESSAGE_ERROR,
|
||||||
buttons = gtk.BUTTONS_CLOSE,
|
buttons = gtk.BUTTONS_CLOSE,
|
||||||
|
message_format = message,
|
||||||
)
|
)
|
||||||
self.dialog.set_title(title)
|
self.dialog.set_title(title)
|
||||||
self.dialog.set_markup(message)
|
self.dialog.format_secondary_text(secondarymsg)
|
||||||
self.dialog.connect('response', lambda dialog, response: self.ret(response))
|
self.dialog.connect('response', lambda dialog, response: self.ret(response))
|
||||||
self.dialog.run()
|
self.dialog.run()
|
||||||
def ret(self,result):
|
def ret(self,result):
|
||||||
@@ -141,7 +145,7 @@ class PointDirectoryToAdd(object):
|
|||||||
result = dialog.run()
|
result = dialog.run()
|
||||||
while ch:
|
while ch:
|
||||||
if result == gtk.RESPONSE_OK and (self.volname.get_text()=='' or self.directory.get_text() == ''):
|
if result == gtk.RESPONSE_OK and (self.volname.get_text()=='' or self.directory.get_text() == ''):
|
||||||
a = Err("Error - pyGTKtalog","Cannot add directory without path and disc label.")
|
a = Err("Error - pyGTKtalog","There are fields needed to be filled.","Cannot add directory without path and disc label.")
|
||||||
ch = True
|
ch = True
|
||||||
result = dialog.run()
|
result = dialog.run()
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user