diff options
author | Valentin Popa <valentin.popa@intel.com> | 2013-11-04 12:53:12 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-11-08 17:14:35 +0000 |
commit | a1ccb5e70523be6af7f4bcaabd728af1ddaf6dc5 (patch) | |
tree | c9d2c8d9f7f68d8f131002a204d37830b8351acc /lib | |
parent | f05f74e98b0dd567a8b0cb85dc8183716619991b (diff) | |
download | bitbake-a1ccb5e70523be6af7f4bcaabd728af1ddaf6dc5.tar.gz |
HOB: HIG compliant message dialogs
"More" HIG compliant dialogs for HOB.
Signed-off-by: Valentin Popa <valentin.popa@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/bb/ui/crumbs/builder.py | 92 | ||||
-rw-r--r-- | lib/bb/ui/crumbs/hig/advancedsettingsdialog.py | 5 | ||||
-rw-r--r-- | lib/bb/ui/crumbs/hig/crumbsmessagedialog.py | 55 | ||||
-rw-r--r-- | lib/bb/ui/crumbs/hig/deployimagedialog.py | 12 | ||||
-rw-r--r-- | lib/bb/ui/crumbs/hig/layerselectiondialog.py | 11 | ||||
-rw-r--r-- | lib/bb/ui/crumbs/hig/saveimagedialog.py | 5 | ||||
-rw-r--r-- | lib/bb/ui/crumbs/hig/simplesettingsdialog.py | 9 |
7 files changed, 87 insertions, 102 deletions
diff --git a/lib/bb/ui/crumbs/builder.py b/lib/bb/ui/crumbs/builder.py index de1458cbc..bbc01205d 100755 --- a/lib/bb/ui/crumbs/builder.py +++ b/lib/bb/ui/crumbs/builder.py @@ -794,8 +794,8 @@ class Builder(gtk.Window): 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() @@ -811,10 +811,9 @@ class Builder(gtk.Window): 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) @@ -1037,7 +1036,7 @@ class Builder(gtk.Window): 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() @@ -1100,9 +1099,10 @@ class Builder(gtk.Window): 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() @@ -1113,9 +1113,10 @@ class Builder(gtk.Window): 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() @@ -1129,9 +1130,10 @@ class Builder(gtk.Window): # 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() @@ -1215,8 +1217,9 @@ class Builder(gtk.Window): 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() @@ -1303,7 +1306,7 @@ class Builder(gtk.Window): 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() @@ -1350,7 +1353,7 @@ class Builder(gtk.Window): 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() @@ -1371,14 +1374,15 @@ class Builder(gtk.Window): 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() @@ -1398,26 +1402,28 @@ class Builder(gtk.Window): 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) diff --git a/lib/bb/ui/crumbs/hig/advancedsettingsdialog.py b/lib/bb/ui/crumbs/hig/advancedsettingsdialog.py index 5542471c7..e0b3553c2 100644 --- a/lib/bb/ui/crumbs/hig/advancedsettingsdialog.py +++ b/lib/bb/ui/crumbs/hig/advancedsettingsdialog.py @@ -183,8 +183,9 @@ class AdvancedSettingsDialog (CrumbsDialog, SettingsUIHelper): self.set_save_button_state() if self.get_num_checked_image_types() == 0: # Show an error dialog - lbl = "<b>Select an image type</b>\n\nYou need to select at least one image type." - dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_WARNING) + lbl = "<b>Select an image type</b>" + msg = "You need to select at least one image type." + dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_WARNING, msg) button = dialog.add_button("OK", gtk.RESPONSE_OK) HobButton.style_button(button) response = dialog.run() diff --git a/lib/bb/ui/crumbs/hig/crumbsmessagedialog.py b/lib/bb/ui/crumbs/hig/crumbsmessagedialog.py index 097ce7b02..3b998e463 100644 --- a/lib/bb/ui/crumbs/hig/crumbsmessagedialog.py +++ b/lib/bb/ui/crumbs/hig/crumbsmessagedialog.py @@ -31,51 +31,28 @@ BitBake GUI's 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) @@ -89,7 +66,5 @@ class CrumbsMessageDialog(CrumbsDialog): 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() diff --git a/lib/bb/ui/crumbs/hig/deployimagedialog.py b/lib/bb/ui/crumbs/hig/deployimagedialog.py index bc1efbbfa..f64fbd6ea 100644 --- a/lib/bb/ui/crumbs/hig/deployimagedialog.py +++ b/lib/bb/ui/crumbs/hig/deployimagedialog.py @@ -160,6 +160,7 @@ class DeployImageDialog (CrumbsDialog): def response_cb(self, dialog, response_id): if response_id == gtk.RESPONSE_YES: lbl = '' + msg = '' combo_item = self.usb_combo.get_active_text() if combo_item and combo_item != self.__dummy_usb__ and self.image_path: cmdline = bb.ui.crumbs.utils.which_terminal() @@ -172,15 +173,18 @@ class DeployImageDialog (CrumbsDialog): if int(tmpfile.readline().strip()) == 0: lbl = "<b>Deploy image successfully.</b>" else: - lbl = "<b>Failed to deploy image.</b>\nPlease check image <b>%s</b> exists and USB device <b>%s</b> is writable." % (self.image_path, combo_item) + lbl = "<b>Failed to deploy image.</b>" + msg = "Please check image <b>%s</b> exists and USB device <b>%s</b> is writable." % (self.image_path, combo_item) tmpfile.close() else: if not self.image_path: - lbl = "<b>No selection made.</b>\nYou have not selected an image to deploy." + lbl = "<b>No selection made.</b>" + msg = "You have not selected an image to deploy." else: - lbl = "<b>No selection made.</b>\nYou have not selected a USB device." + lbl = "<b>No selection made.</b>" + msg = "You have not selected a USB device." if len(lbl): - crumbs_dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO) + 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() diff --git a/lib/bb/ui/crumbs/hig/layerselectiondialog.py b/lib/bb/ui/crumbs/hig/layerselectiondialog.py index 783ee73c7..1d100c54f 100644 --- a/lib/bb/ui/crumbs/hig/layerselectiondialog.py +++ b/lib/bb/ui/crumbs/hig/layerselectiondialog.py @@ -92,7 +92,8 @@ class LayerSelectionDialog (CrumbsDialog): path = dialog.get_filename() dialog.destroy() - lbl = "<b>Error</b>\nUnable to load layer <i>%s</i> because " % path + lbl = "<b>Error</b>" + msg = "Unable to load layer <i>%s</i> because " % path if response == gtk.RESPONSE_YES: import os import os.path @@ -103,15 +104,15 @@ class LayerSelectionDialog (CrumbsDialog): it = layer_store.iter_next(it) if not path: - lbl += "it is an invalid path." + msg += "it is an invalid path." elif not os.path.exists(path+"/conf/layer.conf"): - lbl += "there is no layer.conf inside the directory." + msg += "there is no layer.conf inside the directory." elif path in layers: - lbl += "it is already in loaded layers." + msg += "it is already in loaded layers." else: layer_store.append([path]) return - dialog = CrumbsMessageDialog(parent, lbl) + dialog = CrumbsMessageDialog(parent, lbl, gtk.MESSAGE_ERROR, msg) dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_OK) response = dialog.run() dialog.destroy() diff --git a/lib/bb/ui/crumbs/hig/saveimagedialog.py b/lib/bb/ui/crumbs/hig/saveimagedialog.py index e940ceee4..4195f70e1 100644 --- a/lib/bb/ui/crumbs/hig/saveimagedialog.py +++ b/lib/bb/ui/crumbs/hig/saveimagedialog.py @@ -146,12 +146,11 @@ class SaveImageDialog (CrumbsDialog): self.show_invalid_input_error_dialog() def show_invalid_input_error_dialog(self): - lbl = "<b>Invalid characters in image recipe name</b>\n" + lbl = "<b>Invalid characters in image recipe name</b>" msg = "Image recipe names should be all lowercase and\n" msg += "include only alphanumeric characters. The only\n" msg += "special character you can use is the ASCII hyphen (-)." - lbl = lbl + "\n%s\n" % glib.markup_escape_text(msg) - dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_ERROR) + dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_ERROR, msg) button = dialog.add_button("Close", gtk.RESPONSE_OK) HobButton.style_button(button) diff --git a/lib/bb/ui/crumbs/hig/simplesettingsdialog.py b/lib/bb/ui/crumbs/hig/simplesettingsdialog.py index 4a7cfad52..ab5b614c8 100644 --- a/lib/bb/ui/crumbs/hig/simplesettingsdialog.py +++ b/lib/bb/ui/crumbs/hig/simplesettingsdialog.py @@ -212,13 +212,12 @@ class SimpleSettingsDialog (CrumbsDialog, SettingsUIHelper): def response_cb(self, dialog, response_id): if response_id == gtk.RESPONSE_YES: if self.proxy_checkbox.get_active(): - # Check that all proxy entries have a corresponding port + # Check that all proxy entries have a corresponding port for proxy, port in zip(self.all_proxy_addresses, self.all_proxy_ports): if proxy.get_text() and not port.get_text(): - lbl = "<b>Enter all port numbers</b>\n\n" - msg = "Proxy servers require a port number. Please make sure " - msg += "you have entered a port number for each proxy server." - dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_WARNING, msg) + lbl = "<b>Enter all port numbers</b>" + msg = "Proxy servers require a port number. Please make sure you have entered a port number for each proxy server." + dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_WARNING, msg) button = dialog.add_button("Close", gtk.RESPONSE_OK) HobButton.style_button(button) response = dialog.run() |