Exemplo n.º 1
0
 def _select_in_combobox_where_callback(self, cb: Gtk.ComboBox, callback: Callable[[Mapping], bool]):
     l_iter = cb.get_model().get_iter_first()
     while l_iter is not None:
         if callback(cb.get_model()[l_iter]):
             cb.set_active_iter(l_iter)
             return
         l_iter = cb.get_model().iter_next(l_iter)
 def on_input_purpose_combobox_changed(self, widget: Gtk.ComboBox) -> None:
     '''
     The combobox to choose the input purpose has been changed.
     '''
     tree_iter = widget.get_active_iter()
     if tree_iter is not None:
         model = widget.get_model()
         self._input_purpose = model[tree_iter][1]
         if not self._input_purpose in list(itb_util.InputPurpose):
             LOGGER.info('self._input_purpose = %s (Unknown)',
                         self._input_purpose)
             return
         for input_purpose in list(itb_util.InputPurpose):
             if self._input_purpose == input_purpose:
                 LOGGER.info('self._input_purpose = %s (%s)',
                             self._input_purpose, str(input_purpose))
                 self._test_entry.set_input_purpose(self._input_purpose)
                 self._test_text_view.set_input_purpose(self._input_purpose)
                 input_purpose_entry = (
                     self._test_entry.get_input_purpose())
                 input_purpose_text_view = (
                     self._test_text_view.get_input_purpose())
                 LOGGER.info('Input purpose changed to %s (%s)',
                             input_purpose_entry, str(input_purpose_entry))
                 if input_purpose_entry != input_purpose_text_view:
                     LOGGER.error(
                         'input_purpose_entry != '
                         'input_purpose_text_view: %s %s',
                         input_purpose_entry, input_purpose_text_view)
                 if input_purpose_entry != self._input_purpose:
                     LOGGER.error(
                         'input_purpose_entry != '
                         'self._input_purpose: %s %s', input_purpose_entry,
                         self._input_purpose)
Exemplo n.º 3
0
 def on_cb_reference_changed(self, cb: Gtk.ComboBox):
     assert self._markers
     model, cbiter = cb.get_model(), cb.get_active_iter()
     if model is not None and cbiter is not None and cbiter != []:
         if self.dialog_drawer:
             self.dialog_drawer.set_editing(self._markers[model[cbiter][0]],
                                            hide=self._edited_marker)
Exemplo n.º 4
0
 def on_cb_map_changed(self, cb: Gtk.ComboBox):
     assert self.builder
     model, cbiter = cb.get_model(), cb.get_active_iter()
     if model is not None and cbiter is not None and cbiter != []:
         self._change_map_bg(model[cbiter][0],
                             self.builder.get_object('diag_draw'),
                             self.dialog_drawer)
Exemplo n.º 5
0
 def on_webcam_combobox_changed(self, combo: Gtk.ComboBox):
     if not self.gst_pipeline:
         return
     liter = combo.get_active_iter()
     if not liter:
         return
     model = combo.get_model()
     path, name, source_type = model[liter]
     logger.debug('Picked {} {} ({})', path, name, source_type)
     app_sink = self.gst_pipeline.get_by_name(self.APPSINK_NAME)
     app_sink.set_emit_signals(False)
     self.detach_gstreamer_sink_from_window()
     self.gst_pipeline.remove(app_sink)
     ppl_source = self.gst_pipeline.get_by_name(self.GST_SOURCE_NAME)
     ppl_source.set_state(Gst.State.NULL)
     self.gst_pipeline.remove(ppl_source)
     self.build_gstreamer_pipeline(source_type)
     self.attach_gstreamer_sink_to_window()
     ppl_source = self.gst_pipeline.get_by_name(self.GST_SOURCE_NAME)
     if source_type == 'pipewiresrc':
         logger.debug('Change pipewiresrc path to {}', path)
         ppl_source.set_property('path', path)
     else:
         logger.debug('Change v4l2src device to {}', path)
         ppl_source.set_property('device', path)
     self.gst_pipeline.set_state(Gst.State.PLAYING)
     app_sink = self.gst_pipeline.get_by_name(self.APPSINK_NAME)
     app_sink.set_emit_signals(True)
Exemplo n.º 6
0
 def _update_from_cb(self, w: Gtk.ComboBox):
     attr_name = Gtk.Buildable.get_name(w)[3:]
     val = w.get_model()[w.get_active_iter()][0]
     current_val = getattr(self.move, attr_name)
     if isinstance(current_val, Enum):
         enum_class = current_val.__class__
         val = enum_class(val)
     setattr(self.move, attr_name, val)
Exemplo n.º 7
0
 def _update_from_cb(self, w: Gtk.ComboBox):
     attr_name = Gtk.Buildable.get_name(w)[3:]
     val = w.get_model()[w.get_active_iter()][0]
     current_val = getattr(self.item_p, attr_name)
     if isinstance(current_val, Enum) and not isinstance(current_val, UseType) and not isinstance(current_val, MappaItemCategory):
         enum_class = current_val.__class__
         val = enum_class(val)
     setattr(self.item_p, attr_name, val)
Exemplo n.º 8
0
    def on_output_type_changed(self, combo_box: Gtk.ComboBox) -> None:
        output_type_iter = combo_box.get_active_iter()
        output_type_model = combo_box.get_model()
        output_type = output_type_model[output_type_iter][0]

        if output_type == "Animation":
            self.end_frame_entry.set_sensitive(True)
        elif output_type == "Single frame":
            self.end_frame_entry.set_sensitive(False)
Exemplo n.º 9
0
 def on_cb_main_menu_music_changed(self, widget: Gtk.ComboBox, *args):
     model, cbiter = widget.get_model(), widget.get_active_iter()
     if model is not None and cbiter is not None and cbiter != []:
         static_data = self.module.project.get_rom_module().get_static_data()
         self.module.project.modify_binary(BinaryName.OVERLAY_00, lambda bin: (
             self.module.project.modify_binary(BinaryName.OVERLAY_09, lambda bin2: (
                 HardcodedMainMenuMusic.set_main_menu_music(model[cbiter][0], bin, static_data, bin2)
             ))
         ))
         self.module.mark_misc_settings_as_modified()
Exemplo n.º 10
0
 def on_webcam_combobox_changed(self, combo: Gtk.ComboBox):
     liter = combo.get_active_iter()
     if not liter:
         return
     model = combo.get_model()
     path, name = model[liter]
     logger.debug('{} {}', path, name)
     ppl_source = self.gst_pipeline.get_by_name(self.GST_SOURCE_NAME)
     self.gst_pipeline.set_state(Gst.State.NULL)
     ppl_source.set_property('device', path)
     self.gst_pipeline.set_state(Gst.State.PLAYING)
Exemplo n.º 11
0
 def on_adapter_selected(self, cb_adapters: Gtk.ComboBox) -> None:
     logging.info("selected")
     tree_iter = cb_adapters.get_active_iter()
     if tree_iter:
         adapter_path = cb_adapters.get_model().get_value(tree_iter, 1)
         if self.List.Adapter:
             if self.List.Adapter.get_object_path() != adapter_path:
                 # Stop discovering on previous adapter
                 self.List.Adapter.stop_discovery()
                 self.List.set_adapter(os.path.basename(adapter_path))
                 # Start discovery on selected adapter
                 self.List.Adapter.start_discovery()
Exemplo n.º 12
0
 def on_tool_choose_map_bg_cb_changed(self, w: Gtk.ComboBox):
     model, cbiter = w.get_model(), w.get_active_iter()
     if model is not None and cbiter is not None and cbiter != []:
         item_id = model[cbiter][0]
         self.mapbg_id = item_id
         bma = self.map_bg_module.get_bma(item_id)
         bpl = self.map_bg_module.get_bpl(item_id)
         bpc = self.map_bg_module.get_bpc(item_id)
         bpas = self.map_bg_module.get_bpas(item_id)
         self._map_bg_surface = pil_to_cairo_surface(
             bma.to_pil(bpc, bpl, bpas, False, False, single_frame=True)[0].convert('RGBA')
         )
         bma_width = bma.map_width_camera * BPC_TILE_DIM
         bma_height = bma.map_height_camera * BPC_TILE_DIM
         if self.drawer:
             self._set_drawer_bg(self._map_bg_surface, bma_width, bma_height)
Exemplo n.º 13
0
 def combo_box_changed(self, combo: Gtk.ComboBox) -> None:
     model = combo.get_model()
     if len(model) > 0:
         row = combo.get_model()[combo.get_active()][:]
         self.emit('changed', row[FileGroupComboBox.COLUMN_GROUP],
                   row[FileGroupComboBox.COLUMN_MIME])
Exemplo n.º 14
0
 def on_sector_chooser_changed (self: 'Handler', combobox: Gtk.ComboBox,
                                user_data: Any = None) -> None:
     value = combobox.get_model ().get (combobox.get_active_iter (), 0)[0]
     print ("Sector chooser changed to '{}'".format (value))
Exemplo n.º 15
0
 def on_sector_chooser_changed(self: 'Handler',
                               combobox: Gtk.ComboBox,
                               user_data: Any = None) -> None:
     value = combobox.get_model().get(combobox.get_active_iter(), 0)[0]
     print("Sector chooser changed to '{}'".format(value))