Exemplo n.º 1
0
    def build_dialog(self):
        content_grid = Gtk.Grid()
        content_grid.set_margin_left(12)
        content_grid.set_margin_right(12)
        content_grid.set_margin_top(12)
        content_grid.set_margin_bottom(12)
        content_grid.set_row_spacing(6)
        content_grid.set_column_spacing(12)

        # subgrid
        subgrid = Gtk.Grid()
        subgrid.set_margin_left(0)
        subgrid.set_margin_right(0)
        subgrid.set_margin_top(0)
        subgrid.set_margin_bottom(0)
        subgrid.set_row_spacing(6)
        subgrid.set_column_spacing(12)

        # subgrid upper row
        filename_label = Util.create_simple_label("Filename:")
        self._filename_entry = Gtk.Entry()

        # subgrid filetype combobox
        self._compress_list_store = self.create_compress_list_store()
        self._compress_type_combo = Gtk.ComboBox.new_with_model(self._compress_list_store)
        self._compress_type_combo.set_active(0)
        renderer_text = Gtk.CellRendererText()
        self._compress_type_combo.pack_start(renderer_text, True)
        self._compress_type_combo.add_attribute(renderer_text, "text", 0)

        subgrid.attach(filename_label, 0, 0, 1, 1)
        subgrid.attach(self._filename_entry, 1, 0, 1, 1)
        subgrid.attach(self._compress_type_combo, 2, 0, 1, 1)

        # subgrid bottom row
        location_label = Util.create_simple_label("Location:")
        self.create_filechooser_dialog()
        self._select_location_button = Gtk.FileChooserButton.new_with_dialog(self._dialog)
        self._select_location_button.set_current_folder(os.path.dirname(self._filepath))
        subgrid.attach(location_label, 0, 1, 1, 1)
        subgrid.attach(self._select_location_button, 1, 1, 2, 1)


        # create button box
        buttonbox = Gtk.ButtonBox(Gtk.Orientation.HORIZONTAL)
        buttonbox.set_layout(Gtk.ButtonBoxStyle.END)
        cancel_button = Gtk.Button.new_from_stock(Gtk.STOCK_CANCEL)
        create_button = Gtk.Button.new_with_label("Create")
        cancel_button.connect("clicked", self.on_cancel_clicked)
        create_button.connect("clicked", self.on_create_clicked)
        buttonbox.pack_end(cancel_button, False, False, 0)
        buttonbox.pack_end(create_button, False, False, 0)

        content_grid.attach(subgrid, 0, 0, 1, 1)
        content_grid.attach(buttonbox, 0, 1, 1, 1)

        self.add(content_grid)
        self.show_all()