Changeset 863:4c7bfec09347 for src/mlx/gui
- Timestamp:
- 06/18/17 17:44:54 (7 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/common.py
r858 r863 637 637 #------------------------------------------------------------------------------ 638 638 639 def err roDialog(message, parent = None, secondary = None,639 def errorDialog(message, parent = None, secondary = None, 640 640 title = WINDOW_TITLE_BASE): 641 641 """Display an error dialog box with the given message.""" … … 655 655 def communicationErrorDialog(parent = None, title = WINDOW_TITLE_BASE): 656 656 """Display a communication error dialog.""" 657 err roDialog(xstr("error_communication"), parent = parent,657 errorDialog(xstr("error_communication"), parent = parent, 658 658 secondary = xstr("error_communication_secondary"), 659 659 title = title) -
src/mlx/gui/flight.py
r860 r863 1 # -*- encoding: utf-8 -*- 1 2 2 3 from mlx.gui.common import * … … 471 472 flightButtonBox.pack_start(alignment, False, False, 0) 472 473 473 saveButtonAlignment = gtk.Alignment(xscale=0.5, yscale=0.0, 474 xalign=0.0, yalign=0.0) 474 flightButtonWidthAlignment = gtk.Alignment(xscale=0.5, yscale=0.0, 475 xalign=0.0, yalign=0.0) 476 flightButtonWidthBox = gtk.VBox() 477 475 478 self._saveButton = gtk.Button(xstr("flightsel_save")) 476 479 self._saveButton.set_use_underline(True) … … 479 482 self._saveButton.connect("clicked", self._saveClicked) 480 483 481 saveButtonAlignment.add(self._saveButton) 482 483 flightButtonBox.pack_start(saveButtonAlignment, False, False, 4) 484 flightButtonWidthBox.pack_start(self._saveButton, True, True, 4) 485 486 self._printButton = gtk.Button(xstr("flightsel_print")) 487 self._printButton.set_use_underline(True) 488 self._printButton.set_sensitive(False) 489 self._printButton.set_tooltip_text(xstr("flightsel_print_tooltip")) 490 self._printButton.connect("clicked", self._printClicked) 491 492 flightButtonWidthBox.pack_start(self._printButton, True, True, 4) 493 494 495 flightButtonWidthAlignment.add(flightButtonWidthBox) 496 flightButtonBox.pack_start(flightButtonWidthAlignment, False, False, 0) 484 497 485 498 mainBox.pack_start(flightButtonBox, True, True, 0) … … 514 527 self._pendingFlightsWindow.connect("delete-event", 515 528 self._deletePendingFlightsWindow) 529 530 self._printSettings = None 516 531 517 532 def activate(self): … … 631 646 dialog.hide() 632 647 648 def _printClicked(self, button): 649 """Called when the Print briefing button is clicked.""" 650 wizard = self._wizard 651 flight = self._getSelectedFlight() 652 653 printOperation = gtk.PrintOperation() 654 if self._printSettings is not None: 655 printOperation.set_print_settings(self._printSettings) 656 657 printOperation.set_n_pages(1) 658 printOperation.set_show_progress(True) 659 printOperation.connect("draw_page", self._drawBriefing) 660 661 name = "MAVA Briefing %s %s %s" % (wizard.loginResult.pilotID, 662 flight.callsign, 663 flight.departureTime.strftime("%Y-%m-%d %H:%M")) 664 printOperation.set_job_name(name) 665 printOperation.set_export_filename(name) 666 printOperation.set_use_full_page(False) 667 668 result = printOperation.run(gtk.PRINT_OPERATION_ACTION_PRINT_DIALOG, 669 wizard.gui.mainWindow) 670 671 if result == gtk.PRINT_OPERATION_RESULT_APPLY: 672 self._printSettings = printOperation.get_print_settings() 673 elif result == gtk.PRINT_OPERATION_RESULT_ERROR: 674 errorDialog(xstr("flightsel_print_failed", 675 wizard.gui.mainWindow, 676 secondary = printOperation.get_error())) 677 678 def _drawBriefing(self, printOperation, context, pageNumber): 679 """Draw the briefing.""" 680 wizard = self._wizard 681 loginResult = wizard.loginResult 682 flight=self._getSelectedFlight() 683 684 print "DPI", context.get_dpi_x(), context.get_dpi_y() 685 686 scale = context.get_dpi_x() / 72.0 687 688 cr = context.get_cairo_context() 689 cr.set_antialias(cairo.ANTIALIAS_GRAY) 690 691 cr.set_source_rgb(0.0, 0.0, 0.0) 692 cr.set_line_width(2.0 * scale) 693 cr.rectangle(0, 0, context.get_width(), context.get_height()) 694 cr.stroke() 695 696 layout = cr.create_layout() 697 layout.set_text(u"Malév VA official briefing") 698 font = pango.FontDescription("sans") 699 font.set_size(int(32 * scale * pango.SCALE)) 700 font.set_weight(pango.WEIGHT_NORMAL) 701 layout.set_font_description(font) 702 703 (_ink, (x0, y0, x1, y1)) = layout.get_extents() 704 width = float(x1 + 1 - x0) / pango.SCALE 705 706 y = 25 * scale 707 708 cr.move_to((context.get_width() - width)/2.0, y) 709 cr.set_line_width(0.1 * scale) 710 cr.layout_path(layout) 711 cr.stroke_preserve() 712 cr.fill() 713 714 y += float(y1 + 1 - y0) / pango.SCALE 715 y += 6 * scale 716 717 layout = cr.create_layout() 718 layout.set_text(u"%s (%s) részére" % 719 (loginResult.pilotName, loginResult.pilotID)) 720 font = pango.FontDescription("sans") 721 font.set_size(int(16 * scale * pango.SCALE)) 722 font.set_weight(450) 723 layout.set_font_description(font) 724 (_ink, (x0, y0, x1, y1)) = layout.get_extents() 725 width = float(x1 + 1 - x0) / pango.SCALE 726 727 cr.move_to((context.get_width() - width)/2.0, y) 728 cr.set_line_width(0.1 * scale) 729 cr.layout_path(layout) 730 cr.stroke_preserve() 731 cr.fill() 732 733 y += float(y1 + 1 - y0) / pango.SCALE 734 y += 4 * scale 735 736 cr.move_to(0, y) 737 cr.line_to(context.get_width(), y) 738 cr.set_line_width(1.0 * scale) 739 cr.stroke() 740 741 y += 20 * scale 742 743 font = pango.FontDescription("sans") 744 font.set_size(int(7 * scale * pango.SCALE)) 745 font.set_weight(150) 746 747 table = [] 748 table.append(("Flight", flight.callsign)) 749 table.append(("Date", flight.date)) 750 table.append(("Aircraft", 751 aircraftNames[flight.aircraftType] + ", Lajstrom: " + 752 flight.tailNumber)) 753 table.append(("DOW", 754 str(acft.getClass(flight.aircraftType).dow) + " kgs")) 755 table.append(("From", flight.departureICAO)) 756 table.append(("To", flight.arrivalICAO)) 757 table.append(("ETD (UTC)", flight.departureTime.strftime("%H:%M:%S"))) 758 table.append(("ETA (UTC)", flight.arrivalTime.strftime("%H:%M:%S"))) 759 table.append(("Crew", str(flight.numCrew))) 760 table.append(("Pass", str(flight.numPassengers))) 761 table.append(("Bag", str(flight.bagWeight))) 762 table.append(("Mail", str(flight.mailWeight))) 763 table.append(("Route", flight.route)) 764 765 tableY = y 766 tableX = 15 * scale 767 labelFill = 5 * scale 768 labelValueFill = 25 * scale 769 valueFill = 5 * scale 770 labelX = tableX + labelFill 771 tableWidth = context.get_width() * 55 / 100 - tableX 772 773 labelLayouts = [] 774 maxLabelWidth = 0 775 totalHeight = 0 776 for (label, value) in table: 777 labelLayout = cr.create_layout() 778 labelLayout.set_text(label) 779 labelLayout.set_font_description(font) 780 781 (_ink, (x0, y0, x1, y1)) = labelLayout.get_extents() 782 maxLabelWidth = max(maxLabelWidth, x1 + 1 - x0) 783 labelHeight = y1 + 1 - y0 784 785 valueLayout = cr.create_layout() 786 valueLayout.set_text(value) 787 valueLayout.set_font_description(font) 788 789 labelLayouts.append((labelLayout, valueLayout, labelHeight)) 790 791 maxLabelWidth = maxLabelWidth / pango.SCALE 792 793 valueX = labelX + labelValueFill + maxLabelWidth 794 795 layouts = [] 796 valueWidth = tableWidth - \ 797 (labelFill + maxLabelWidth + labelValueFill + valueFill) 798 for (labelLayout, valueLayout, labelHeight) in labelLayouts: 799 valueLayout.set_width(int(valueWidth * pango.SCALE)) 800 801 (_ink, (x0, y0, x1, y1)) = valueLayout.get_extents() 802 valueHeight = y1 + 1 - y0 803 804 height = float(max(labelHeight, valueHeight))/pango.SCALE 805 layouts.append((labelLayout, valueLayout, height)) 806 807 rowIndex = 0 808 for (labelLayout, valueLayout, height) in layouts: 809 if (rowIndex%2)==0: 810 cr.set_source_rgb(0.85, 0.85, 0.85) 811 else: 812 cr.set_source_rgb(0.9, 0.9, 0.9) 813 814 cr.rectangle(tableX, y-2*scale, tableWidth, height + 4 * scale) 815 cr.fill() 816 817 cr.set_source_rgb(0.0, 0.0, 0.0) 818 819 cr.move_to(labelX, y) 820 cr.set_line_width(0.1) 821 cr.layout_path(labelLayout) 822 cr.stroke_preserve() 823 cr.fill() 824 825 cr.move_to(valueX, y) 826 cr.set_line_width(0.1) 827 cr.layout_path(valueLayout) 828 cr.stroke_preserve() 829 cr.fill() 830 831 y += height 832 y += 4 * scale 833 834 rowIndex += 1 835 836 cr.set_source_rgb(0.0, 0.0, 0.0) 837 cr.set_line_width(1.0 * scale) 838 cr.rectangle(tableX, tableY - 2 * scale, tableWidth, y - tableY) 839 cr.stroke() 840 841 cr.move_to(valueX - 5 * scale, tableY - 2 * scale) 842 cr.line_to(valueX - 5 * scale, y - 2 * scale) 843 cr.stroke() 844 633 845 def _refreshClicked(self, button): 634 846 """Called when the refresh button is clicked.""" … … 645 857 """Called when the selection is changed.""" 646 858 self._saveButton.set_sensitive(len(indexes)==1) 859 self._printButton.set_sensitive(len(indexes)==1) 647 860 self._updateNextButton() 648 861
Note:
See TracChangeset
for help on using the changeset viewer.