self.generate_image_async(True)
def show_error_dialog(self, msg):
- lbl = "<b>Hob found an error</b>\n"
- dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_ERROR, msg)
+ lbl = "<b>Hob found an error</b>"
+ dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_ERROR, msg)
button = dialog.add_button("Close", gtk.RESPONSE_OK)
HobButton.style_button(button)
response = dialog.run()
dialog.destroy()
def show_network_error_dialog(self):
- lbl = "<b>Hob cannot connect to the network</b>\n"
- msg = "Please check your network connection. If you are using a proxy server, please make sure it is configured correctly."
- lbl = lbl + "%s\n\n" % glib.markup_escape_text(msg)
- dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_ERROR)
+ lbl = "<b>Hob cannot connect to the network</b>"
+ msg = msg + "Please check your network connection. If you are using a proxy server, please make sure it is configured correctly."
+ dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_ERROR, msg)
button = dialog.add_button("Close", gtk.RESPONSE_OK)
HobButton.style_button(button)
button = dialog.add_button("Proxy settings", gtk.RESPONSE_CANCEL)
self.build_failed()
def handler_no_provider_cb(self, running_build, msg):
- dialog = CrumbsMessageDialog(self, glib.markup_escape_text(msg), gtk.STOCK_DIALOG_INFO)
+ dialog = CrumbsMessageDialog(self, glib.markup_escape_text(msg), gtk.MESSAGE_INFO)
button = dialog.add_button("Close", gtk.RESPONSE_OK)
HobButton.style_button(button)
dialog.run()
def build_packages(self):
_, all_recipes = self.recipe_model.get_selected_recipes()
if not all_recipes:
- lbl = "<b>No selections made</b>\nYou have not made any selections"
- lbl = lbl + " so there isn't anything to bake at this time."
- dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
+ lbl = "<b>No selections made</b>"
+ msg = "You have not made any selections"
+ msg = msg + " so there isn't anything to bake at this time."
+ dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_INFO, msg)
button = dialog.add_button("Close", gtk.RESPONSE_OK)
HobButton.style_button(button)
dialog.run()
def build_image(self):
selected_packages = self.package_model.get_selected_packages()
if not selected_packages:
- lbl = "<b>No selections made</b>\nYou have not made any selections"
- lbl = lbl + " so there isn't anything to bake at this time."
- dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
+ lbl = "<b>No selections made</b>"
+ msg = "You have not made any selections"
+ msg = msg + " so there isn't anything to bake at this time."
+ dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_INFO, msg)
button = dialog.add_button("Close", gtk.RESPONSE_OK)
HobButton.style_button(button)
dialog.run()
# If no base image and no selected packages don't build anything
if not (selected_packages or selected_image != self.recipe_model.__custom_image__):
- lbl = "<b>No selections made</b>\nYou have not made any selections"
- lbl = lbl + " so there isn't anything to bake at this time."
- dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
+ lbl = "<b>No selections made</b>"
+ msg = "You have not made any selections"
+ msg = msg + " so there isn't anything to bake at this time."
+ dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_INFO, msg)
button = dialog.add_button("Close", gtk.RESPONSE_OK)
HobButton.style_button(button)
dialog.run()
response = dialog.run()
if response == gtk.RESPONSE_YES:
if not dialog.image_names:
- lbl = "<b>No selections made</b>\nYou have not made any selections"
- crumbs_dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
+ lbl = "<b>No selections made</b>"
+ msg = "You have not made any selections"
+ crumbs_dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_INFO, msg)
button = crumbs_dialog.add_button("Close", gtk.RESPONSE_OK)
HobButton.style_button(button)
crumbs_dialog.run()
def deploy_image(self, image_name):
if not image_name:
lbl = "<b>Please select an image to deploy.</b>"
- dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
+ dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_INFO)
button = dialog.add_button("Close", gtk.RESPONSE_OK)
HobButton.style_button(button)
dialog.run()
def runqemu_image(self, image_name, kernel_name):
if not image_name or not kernel_name:
lbl = "<b>Please select an %s to launch in QEMU.</b>" % ("kernel" if image_name else "image")
- dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
+ dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_INFO)
button = dialog.add_button("Close", gtk.RESPONSE_OK)
HobButton.style_button(button)
dialog.run()
cmdline += "runqemu " + kernel_path + " " + image_path + "\"\'"
subprocess.Popen(shlex.split(cmdline))
else:
- lbl = "<b>Path error</b>\nOne of your paths is wrong,"
- lbl = lbl + " please make sure the following paths exist:\n"
- lbl = lbl + "image path:" + image_path + "\n"
- lbl = lbl + "kernel path:" + kernel_path + "\n"
- lbl = lbl + "source environment path:" + source_env_path + "\n"
- lbl = lbl + "tmp path: " + tmp_path + "."
- lbl = lbl + "You may be missing either xterm or vte for terminal services."
- dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_ERROR)
+ lbl = "<b>Path error</b>"
+ msg = "One of your paths is wrong,"
+ msg = msg + " please make sure the following paths exist:\n"
+ msg = msg + "image path:" + image_path + "\n"
+ msg = msg + "kernel path:" + kernel_path + "\n"
+ msg = msg + "source environment path:" + source_env_path + "\n"
+ msg = msg + "tmp path: " + tmp_path + "."
+ msg = msg + "You may be missing either xterm or vte for terminal services."
+ dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_ERROR, msg)
button = dialog.add_button("Close", gtk.RESPONSE_OK)
HobButton.style_button(button)
dialog.run()
def stop_build(self):
if self.stopping:
- lbl = "<b>Force Stop build?</b>\nYou've already selected Stop once,"
- lbl = lbl + " would you like to 'Force Stop' the build?\n\n"
- lbl = lbl + "This will stop the build as quickly as possible but may"
- lbl = lbl + " well leave your build directory in an unusable state"
- lbl = lbl + " that requires manual steps to fix.\n"
- dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_WARNING)
+ lbl = "<b>Force Stop build?</b>"
+ msg = "You've already selected Stop once,"
+ msg = msg + " would you like to 'Force Stop' the build?\n\n"
+ msg = msg + "This will stop the build as quickly as possible but may"
+ msg = msg + " well leave your build directory in an unusable state"
+ msg = msg + " that requires manual steps to fix."
+ dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_WARNING, msg)
button = dialog.add_button("Cancel", gtk.RESPONSE_CANCEL)
HobAltButton.style_button(button)
button = dialog.add_button("Force Stop", gtk.RESPONSE_YES)
HobButton.style_button(button)
else:
- lbl = "<b>Stop build?</b>\n\nAre you sure you want to stop this"
- lbl = lbl + " build?\n\n'Stop' will stop the build as soon as all in"
- lbl = lbl + " progress build tasks are finished. However if a"
- lbl = lbl + " lengthy compilation phase is in progress this may take"
- lbl = lbl + " some time.\n\n"
- lbl = lbl + "'Force Stop' will stop the build as quickly as"
- lbl = lbl + " possible but may well leave your build directory in an"
- lbl = lbl + " unusable state that requires manual steps to fix."
- dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_WARNING)
+ lbl = "<b>Stop build?</b>"
+ msg = "Are you sure you want to stop this"
+ msg = msg + " build?\n\n'Stop' will stop the build as soon as all in"
+ msg = msg + " progress build tasks are finished. However if a"
+ msg = msg + " lengthy compilation phase is in progress this may take"
+ msg = msg + " some time.\n\n"
+ msg = msg + "'Force Stop' will stop the build as quickly as"
+ msg = msg + " possible but may well leave your build directory in an"
+ msg = msg + " unusable state that requires manual steps to fix."
+ dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_WARNING, msg)
button = dialog.add_button("Cancel", gtk.RESPONSE_CANCEL)
HobAltButton.style_button(button)
button = dialog.add_button("Force stop", gtk.RESPONSE_YES)
In summary: spacing = 12px, border-width = 6px
"""
-class CrumbsMessageDialog(CrumbsDialog):
+class CrumbsMessageDialog(gtk.MessageDialog):
"""
A GNOME HIG compliant dialog widget.
Add buttons with gtk.Dialog.add_button or gtk.Dialog.add_buttons
"""
- def __init__(self, parent=None, label="", icon=gtk.STOCK_INFO, msg=""):
- super(CrumbsMessageDialog, self).__init__("", parent, gtk.DIALOG_MODAL)
+ def __init__(self, parent = None, label="", dialog_type = gtk.MESSAGE_QUESTION, msg=""):
+ super(CrumbsMessageDialog, self).__init__(None,
+ gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+ dialog_type,
+ gtk.BUTTONS_NONE,
+ None)
- self.set_border_width(6)
- self.vbox.set_property("spacing", 12)
- self.action_area.set_property("spacing", 12)
- self.action_area.set_property("border-width", 6)
+ self.set_skip_taskbar_hint(False)
- first_column = gtk.HBox(spacing=12)
- first_column.set_property("border-width", 6)
- first_column.show()
- self.vbox.add(first_column)
+ self.set_markup(label)
- self.icon = gtk.Image()
- # We have our own Info icon which should be used in preference of the stock icon
- self.icon_chk = HobIconChecker()
- self.icon.set_from_stock(self.icon_chk.check_stock_icon(icon), gtk.ICON_SIZE_DIALOG)
- self.icon.set_property("yalign", 0.00)
- self.icon.show()
- first_column.pack_start(self.icon, expand=False, fill=True, padding=0)
-
- if 0 <= len(msg) < 200:
- lbl = label + "%s" % glib.markup_escape_text(msg)
- self.label_short = gtk.Label()
- self.label_short.set_use_markup(True)
- self.label_short.set_line_wrap(True)
- self.label_short.set_markup(lbl)
- self.label_short.set_property("yalign", 0.00)
- self.label_short.show()
- first_column.add(self.label_short)
+ if 0 <= len(msg) < 300:
+ self.format_secondary_markup(msg)
else:
- second_row = gtk.VBox(spacing=12)
- second_row.set_property("border-width", 6)
- self.label_long = gtk.Label()
- self.label_long.set_use_markup(True)
- self.label_long.set_line_wrap(True)
- self.label_long.set_markup(label)
- self.label_long.set_alignment(0.0, 0.0)
- second_row.pack_start(self.label_long, expand=False, fill=False, padding=0)
- self.label_long.show()
+ vbox = self.get_message_area()
+ vbox.set_border_width(1)
+ vbox.set_property("spacing", 12)
self.textWindow = gtk.ScrolledWindow()
self.textWindow.set_shadow_type(gtk.SHADOW_IN)
self.textWindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self.msgView.set_buffer(self.buf)
self.textWindow.add(self.msgView)
self.msgView.show()
- second_row.add(self.textWindow)
+ vbox.add(self.textWindow)
self.textWindow.show()
- first_column.add(second_row)
- second_row.show()