def __init__(self, app): View.__init__(self, app, 'Running…') # Public: The runner. self.runner = None self.last_paths = [] # Disable scrolling for the main view: self.scw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.NEVER) # Public flag for checking if the view is still # in running mode (thus en/disabling certain features) self.is_running = False self._script_generated = False self._is_filtered = False self.model = PathTreeModel([]) self.treeview = PathTreeView() self.treeview.set_model(self.model) self.treeview.get_selection().connect('changed', self.on_selection_changed) self.group_treeview = PathTreeView() self.group_treeview.set_vexpand(True) self.group_treeview.set_valign(Gtk.Align.FILL) # This is needed to make sure operations on the one update # the other. Internally the same nodes are updated, but it has # to be made sure that the models get updated. self.group_treeview.set_twin(self.treeview) self.treeview.set_twin(self.group_treeview) group_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) group_box.pack_start(scrolled(self.group_treeview), True, True, 0) group_box.pack_start(Gtk.HSeparator(), False, False, 0) self.group_revealer = Gtk.Revealer() self.group_revealer.set_vexpand(True) self.group_revealer.set_valign(Gtk.Align.FILL) self.group_revealer.add(group_box) self.group_revealer.set_no_show_all(True) self.group_revealer.set_size_request(-1, 70) for column in self.treeview.get_columns(): column.connect('clicked', lambda _: self.rerender_chart()) self.chart_stack = ChartStack() self.actionbar = ResultActionBar(self) self.actionbar.set_valign(Gtk.Align.END) self.actionbar.set_halign(Gtk.Align.FILL) # Right part of the view stats_box = Gtk.Paned(orientation=Gtk.Orientation.VERTICAL) stats_box.pack1(self.group_revealer, True, True) stats_box.pack2(self.chart_stack, True, True) stats_box.props.position = 200 # Separator container for separator|chart (could have used grid) separator = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL) right_pane = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) right_pane.pack_start(separator, False, False, 0) right_pane.pack_start(stats_box, True, True, 0) right_pane.set_size_request(100, -1) scw = scrolled(self.treeview) scw.set_size_request(200, -1) paned = Gtk.Paned(orientation=Gtk.Orientation.HORIZONTAL) paned.set_vexpand(True) paned.set_valign(Gtk.Align.FILL) paned.pack1(scw, True, True) paned.pack2(right_pane, True, True) paned.props.position = 720 paned.set_hexpand(True) grid = Gtk.Grid() grid.attach(paned, 0, 0, 1, 1) grid.attach(self.actionbar, 0, 1, 1, 1) self.add(grid) self.search_entry.connect('search-changed', self.on_search_changed) self.actionbar.connect('generate-all-script', self.on_generate_script) self.actionbar.connect('generate-filtered-script', self.on_generate_filtered_script) self.actionbar.connect('generate-selection-script', self.on_generate_selection_script) self._menu = None
def __init__(self, win): View.__init__(self, win) self._last_runner = None self.script = Script.create_dummy() control_grid = Gtk.Grid() control_grid.set_hexpand(False) control_grid.set_vexpand(False) control_grid.set_halign(Gtk.Align.CENTER) control_grid.set_valign(Gtk.Align.CENTER) self.info_label = Gtk.Label( use_markup=True, justify=Gtk.Justification.CENTER ) self.info_label.get_style_context().add_class( Gtk.STYLE_CLASS_DIM_LABEL ) self.set_info_review_text() self.icon_stack = _create_icon_stack() self.text_view, buffer_ = _create_source_view() self.text_view.set_name('ShredderScriptEditor') self.text_view.set_vexpand(True) self.text_view.set_valign(Gtk.Align.FILL) self.text_view.set_hexpand(True) self.text_view.set_halign(Gtk.Align.FILL) self.save_button = OverlaySaveButton() self.save_button.add(scrolled(self.text_view)) self.save_chooser = ScriptSaverDialog(self) def on_save_button_clicked(_): """Switch to the save dialog in the stack.""" self.set_search_mode(False) self.left_stack.set_visible_child_name('chooser') self.save_chooser.show_controls() self.set_info_help_text() self.set_correct_icon() self.run_button.set_sensitive(False) def on_save_clicked(_): """Switch back when the user has saved.""" self.left_stack.set_visible_child_name('script') self.set_info_review_text() self.set_correct_icon() self.run_button.set_sensitive(True) self.save_button.connect( 'save-clicked', on_save_button_clicked ) self.save_chooser.connect( 'saved', on_save_clicked ) buffer_.create_tag("original", weight=Pango.Weight.BOLD) buffer_.create_tag("normal") self.run_label = RunningLabel() self.run_label.set_hexpand(False) self.run_label.set_halign(Gtk.Align.FILL) self.left_stack = Gtk.Stack() self.left_stack.set_transition_type( Gtk.StackTransitionType.SLIDE_UP ) spinner = Gtk.Spinner() spinner.start() self.left_stack.add_named(spinner, 'loading') self.left_stack.add_named(self.save_button, 'script') self.left_stack.add_named(self.save_chooser, 'chooser') self.left_stack.add_named(scrolled(self.run_label), 'list') separator = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL) left_pane = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) left_pane.pack_start(self.left_stack, True, True, 0) left_pane.pack_start(separator, False, False, 0) self.run_button = RunButton( 'user-trash-symbolic', 'Run Script' ) self.run_button.button.connect('clicked', self.on_run_script_clicked) self.run_button.set_halign(Gtk.Align.CENTER) self.run_button.connect( 'notify::dry-run', lambda *_: self.set_correct_icon() ) control_grid.attach(self.info_label, 0, 0, 1, 1) control_grid.attach_next_to( self.run_button, self.info_label, Gtk.PositionType.BOTTOM, 1, 1 ) control_grid.attach_next_to( self.icon_stack, self.info_label, Gtk.PositionType.TOP, 1, 1 ) control_grid.set_border_width(15) self.stack = Gtk.Stack() self.stack.set_transition_type(Gtk.StackTransitionType.SLIDE_UP) self.stack.add_named(control_grid, 'danger') self.stack.add_named(_create_running_screen(), 'progressing') self.stack.add_named( _create_finished_screen(self._switch_back), 'finished' ) self.left_stack.set_visible_child_name('script') paned = Gtk.Paned() paned.pack1(left_pane, True, True) paned.pack2(self.stack, True, True) paned.props.position = 920 self.add(paned) self._last_search = None self.search_entry.connect( 'search-changed', self.on_search_changed ) try: self.search_entry.connect( 'next-match', self.on_search_changed ) except TypeError: LOGGER.warning('Old gtk version; skipping through matches will not work.')
def __init__(self, win): View.__init__(self, win) self._last_runner = None self.script = Script.create_dummy() control_grid = Gtk.Grid() control_grid.set_hexpand(False) control_grid.set_vexpand(False) control_grid.set_halign(Gtk.Align.CENTER) control_grid.set_valign(Gtk.Align.CENTER) self.info_label = Gtk.Label(use_markup=True, justify=Gtk.Justification.CENTER) self.info_label.get_style_context().add_class( Gtk.STYLE_CLASS_DIM_LABEL) self.set_info_review_text() self.icon_stack = _create_icon_stack() self.text_view, buffer_ = _create_source_view() self.text_view.set_name('ShredderScriptEditor') self.text_view.set_vexpand(True) self.text_view.set_valign(Gtk.Align.FILL) self.text_view.set_hexpand(True) self.text_view.set_halign(Gtk.Align.FILL) self.save_button = OverlaySaveButton() self.save_button.add(scrolled(self.text_view)) self.save_chooser = ScriptSaverDialog(self) def on_save_button_clicked(_): """Switch to the save dialog in the stack.""" self.set_search_mode(False) self.left_stack.set_visible_child_name('chooser') self.save_chooser.show_controls() self.set_info_help_text() self.set_correct_icon() self.run_button.set_sensitive(False) def on_save_clicked(_): """Switch back when the user has saved.""" self.left_stack.set_visible_child_name('script') self.set_info_review_text() self.set_correct_icon() self.run_button.set_sensitive(True) self.save_button.connect('save-clicked', on_save_button_clicked) self.save_chooser.connect('saved', on_save_clicked) buffer_.create_tag("original", weight=Pango.Weight.BOLD) buffer_.create_tag("normal") self.run_label = RunningLabel() self.run_label.set_hexpand(False) self.run_label.set_halign(Gtk.Align.FILL) self.left_stack = Gtk.Stack() self.left_stack.set_transition_type(Gtk.StackTransitionType.SLIDE_UP) spinner = Gtk.Spinner() spinner.start() self.left_stack.add_named(spinner, 'loading') self.left_stack.add_named(self.save_button, 'script') self.left_stack.add_named(self.save_chooser, 'chooser') self.left_stack.add_named(scrolled(self.run_label), 'list') separator = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL) left_pane = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) left_pane.pack_start(self.left_stack, True, True, 0) left_pane.pack_start(separator, False, False, 0) self.run_button = RunButton('user-trash-symbolic', 'Run Script') self.run_button.button.connect('clicked', self.on_run_script_clicked) self.run_button.set_halign(Gtk.Align.CENTER) self.run_button.connect('notify::dry-run', lambda *_: self.set_correct_icon()) control_grid.attach(self.info_label, 0, 0, 1, 1) control_grid.attach_next_to(self.run_button, self.info_label, Gtk.PositionType.BOTTOM, 1, 1) control_grid.attach_next_to(self.icon_stack, self.info_label, Gtk.PositionType.TOP, 1, 1) control_grid.set_border_width(15) self.stack = Gtk.Stack() self.stack.set_transition_type(Gtk.StackTransitionType.SLIDE_UP) self.stack.add_named(control_grid, 'danger') self.stack.add_named(_create_running_screen(), 'progressing') self.stack.add_named(_create_finished_screen(self._switch_back), 'finished') self.left_stack.set_visible_child_name('script') paned = Gtk.Paned() paned.pack1(left_pane, True, True) paned.pack2(self.stack, True, True) paned.props.position = 920 self.add(paned) self._last_search = None self.search_entry.connect('search-changed', self.on_search_changed) try: self.search_entry.connect('next-match', self.on_search_changed) except TypeError: LOGGER.warning( 'Old gtk version; skipping through matches will not work.')
def __init__(self, app): View.__init__(self, app, 'Running…') # Public: The runner. self.runner = None self.last_paths = [] # Disable scrolling for the main view: self.scw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.NEVER) # Public flag for checking if the view is still # in running mode (thus en/disabling certain features) self.is_running = False self._script_generated = False self.model = PathTreeModel([]) self.treeview = PathTreeView() self.treeview.set_model(self.model) self.treeview.get_selection().connect( 'changed', self.on_selection_changed ) self.group_treeview = PathTreeView() self.group_treeview.set_vexpand(True) self.group_treeview.set_valign(Gtk.Align.FILL) # This is needed to make sure operations on the one update # the other. Interally the same nodes are updated, but it has # to be made sure that the models get updated. self.group_treeview.set_twin(self.treeview) self.treeview.set_twin(self.group_treeview) group_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) group_box.pack_start(scrolled(self.group_treeview), True, True, 0) group_box.pack_start(Gtk.HSeparator(), False, False, 0) self.group_revealer = Gtk.Revealer() self.group_revealer.set_vexpand(True) self.group_revealer.set_valign(Gtk.Align.FILL) self.group_revealer.add(group_box) self.group_revealer.set_no_show_all(True) self.group_revealer.set_size_request(-1, 70) for column in self.treeview.get_columns(): column.connect( 'clicked', lambda _: self.rerender_chart() ) self.chart_stack = ChartStack() self.actionbar = ResultActionBar(self) self.actionbar.set_valign(Gtk.Align.END) self.actionbar.set_halign(Gtk.Align.FILL) # Right part of the view stats_box = Gtk.Paned(orientation=Gtk.Orientation.VERTICAL) stats_box.pack1(self.group_revealer, True, True) stats_box.pack2(self.chart_stack, True, True) stats_box.props.position = 200 # Separator container for separator|chart (could have used grid) separator = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL) right_pane = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) right_pane.pack_start(separator, False, False, 0) right_pane.pack_start(stats_box, True, True, 0) right_pane.set_size_request(100, -1) scw = scrolled(self.treeview) scw.set_size_request(200, -1) paned = Gtk.Paned(orientation=Gtk.Orientation.HORIZONTAL) paned.set_vexpand(True) paned.set_valign(Gtk.Align.FILL) paned.pack1(scw, True, True) paned.pack2(right_pane, True, True) paned.props.position = 720 paned.set_hexpand(True) grid = Gtk.Grid() grid.attach(paned, 0, 0, 1, 1) grid.attach(self.actionbar, 0, 1, 1, 1) self.add(grid) self.search_entry.connect( 'search-changed', self.on_search_changed ) self.actionbar.connect( 'generate-all-script', self.on_generate_script ) self.actionbar.connect( 'generate-filtered-script', self.on_generate_filtered_script ) self.actionbar.connect( 'generate-selection-script', self.on_generate_selection_script ) self._menu = None