Esempio n. 1
0
 def load_file_event(self, widget, target, event):
     '''
     method called when 'load' button is pressed
     opens the gcompris file selector to load the music
     calls the general_load function
     '''
     gcompris.file_selector_load(self.gcomprisBoard,
                                        'comp', '.gcmusic',
                                        general_load, self.staff)
Esempio n. 2
0
    def tool_item_event(self, item, target, event, tool):

        if event.type == gtk.gdk.BUTTON_PRESS:
            if event.button == 1:
                gcompris.sound.play_ogg("sounds/bleep.wav")
                # Some button have instant effects
                if (self.tools[tool][0] == "SAVE"):
                    gcompris.file_selector_save(self.gcomprisBoard,
                                                self.selector_section,
                                                self.file_type, general_save,
                                                self)
                    return False

                elif (self.tools[tool][0] == "LOAD"):
                    gcompris.file_selector_load(self.gcomprisBoard,
                                                self.selector_section,
                                                self.file_type,
                                                general_restore, self)
                    return False

                elif (self.tools[tool][0] == "IMAGE"):
                    self.pos_x = gcompris.BOARD_WIDTH / 2
                    self.pos_y = gcompris.BOARD_HEIGHT / 2

                    gcompris.images_selector_start(self.gcomprisBoard,
                                                   "dataset", image_selected,
                                                   self)
                    return False

                elif (self.tools[tool][0] == "MOVIE"):
                    if not self.running:
                        self.deselect()

                        self.playing_start()
                        return False

                elif (self.tools[tool][0] != "SELECT"):
                    self.deselect()

                #
                # Normal case, tool button switch
                # -------------------------------

                # Deactivate old button
                self.old_tool_item.props.pixbuf = \
                    gcompris.utils.load_pixmap(self.tools[self.current_tool][1])

                # Activate new button
                self.current_tool = tool
                self.old_tool_item = item
                self.old_tool_item.props.pixbuf = \
                    gcompris.utils.load_pixmap(self.tools[self.current_tool][2])
                gcompris.set_cursor(self.tools[self.current_tool][3])
Esempio n. 3
0
  def tool_item_event(self, item, target, event, tool):

    if event.type == gtk.gdk.BUTTON_PRESS:
      if event.button == 1:
        gcompris.sound.play_ogg("sounds/bleep.wav")
        # Some button have instant effects
        if (self.tools[tool][0] == "SAVE"):
          gcompris.file_selector_save( self.gcomprisBoard,
                                       self.selector_section, self.file_type,
                                       general_save, self)
          return False

        elif (self.tools[tool][0] == "LOAD"):
          gcompris.file_selector_load( self.gcomprisBoard,
                                       self.selector_section, self.file_type,
                                       general_restore, self)
          return False

        elif (self.tools[tool][0] == "IMAGE"):
          self.pos_x = gcompris.BOARD_WIDTH/2
          self.pos_y = gcompris.BOARD_HEIGHT/2

          gcompris.images_selector_start(self.gcomprisBoard,
                                         "dataset",
                                         image_selected,
                                         self);
          return False

        elif (self.tools[tool][0] == "MOVIE"):
          if not self.running:
            self.deselect()

            self.playing_start()
            return False

        elif (self.tools[tool][0] != "SELECT"):
          self.deselect()

        #
        # Normal case, tool button switch
        # -------------------------------

        # Deactivate old button
        self.old_tool_item.props.pixbuf = \
            gcompris.utils.load_pixmap(self.tools[self.current_tool][1])

        # Activate new button
        self.current_tool = tool
        self.old_tool_item = item
        self.old_tool_item.props.pixbuf = \
            gcompris.utils.load_pixmap(self.tools[self.current_tool][2])
        gcompris.set_cursor(self.tools[self.current_tool][3]);
Esempio n. 4
0
  def key_press(self, keyval, commit_str, preedit_str):
    #
    # I suppose codec is the stdin one.
    #
    codec = sys.stdin.encoding

    # keyboard shortcuts
    if ( ((keyval == gtk.keysyms.F1)
         or (keyval == gtk.keysyms.l)) and not gcompris.sugar_detected() ):
      gcompris.file_selector_save( self.gcomprisBoard,
                                   self.selector_section, self.file_type,
                                   general_save, self)
    elif ( ((keyval == gtk.keysyms.F2)
           or (keyval == gtk.keysyms.s)) and not gcompris.sugar_detected() ):
      gcompris.file_selector_load( self.gcomprisBoard,
                                   self.selector_section, self.file_type,
                                   general_restore, self)
    elif (keyval == gtk.keysyms.Left):
      self.doc.timeline.previous()
      return True
    elif (keyval == gtk.keysyms.Right):
      self.doc.timeline.next()
      return True

    # Printing
    # Bruno we need a print button !
    #
    # was in anim1, but not print an animation is not interesting.
    elif (keyval == gtk.keysyms.F3):
      pass

    if (not self.selected):
      return False

    if (self.selected.type_name() == "GooCanvasText"):
      self.selected.key_press(keyval, commit_str, preedit_str)
      return True

    # Process shortcuts on non text items
    if ((keyval == gtk.keysyms.BackSpace) or
        (keyval == gtk.keysyms.Delete)):
      self.selected.delete()
      return True

    return False