def release_item(self, event):
     if is_left_button(event):
         cell = self.get_cell_with_event(event)
         if cell is not None:
             (release_row, release_column, offset_x, offset_y) = cell
             
             if release_row is not None:
                 if self.double_click_row == release_row:
                     self.visible_items[release_row].double_click(release_column, offset_x, offset_y)
                     self.emit("double-click", self.visible_items[release_row], release_column)
                 elif self.single_click_row == release_row:
                     self.visible_items[release_row].single_click(release_column, offset_x, offset_y)
                     self.emit("single-click-item", self.visible_items[release_row], release_column, offset_x, offset_y)
             
             if self.start_drag and self.is_in_visible_area(event):
                 self.drag_select_items_at_cursor()
                 
             self.double_click_row = None    
             self.single_click_row = None    
             self.start_drag = False
             
             # Disable select rows when press_in_select_rows valid after button release.
             if self.press_in_select_rows:
                 self.set_select_rows([self.press_in_select_rows])
                 self.start_select_row = self.press_in_select_rows
                 self.press_in_select_rows = None
             
             self.set_drag_row(None)
Exemple #2
0
 def button_press_icon_view(self, widget, event):
     '''
     Internal callback for `button-press-event` signal.
     '''
     # Grab focus when button press, otherwise key-press signal can't response.
     self.grab_focus()
     
     if len(self.items) > 0 and is_left_button(event):
         index_info = self.icon_view_get_event_index(event)
         
         if index_info:
             (row_index, column_index, item_index, offset_x, offset_y) = index_info
             self.emit("button-press-item", self.items[item_index], offset_x - self.padding_x, offset_y - self.padding_y)
             
             if is_double_click(event):
                 if index_info:
                     self.double_click_item = index_info[2]
                 else:
                     self.double_click_item = None
             elif is_single_click(event):
                 if index_info:
                     self.single_click_item = index_info[2]
                 else:
                     self.single_click_item = None
                     
             # Set highlight.
             if index_info:
                 self.clear_highlight()
                     
                 self.set_highlight(self.items[index_info[2]])
Exemple #3
0
    def button_release_icon_view(self, widget, event):
        '''
        Internal callback for `button-release-event` signal.
        '''
        if len(self.items) > 0:
            index_info = self.icon_view_get_event_index(event)
            if index_info:
                (row_index, column_index, item_index, offset_x,
                 offset_y) = index_info

                if is_left_button(event):
                    self.emit("button-release-item", self.items[item_index],
                              offset_x - self.padding_x,
                              offset_y - self.padding_y)

                    if self.double_click_item == item_index:
                        self.emit("double-click-item",
                                  self.items[self.double_click_item],
                                  offset_x - self.padding_x,
                                  offset_y - self.padding_y)
                    elif self.single_click_item == item_index:
                        self.emit("single-click-item",
                                  self.items[self.single_click_item],
                                  offset_x - self.padding_x,
                                  offset_y - self.padding_y)
                elif is_right_button(event):
                    if self.right_click_item == item_index:
                        self.emit("right-click-item",
                                  self.items[self.right_click_item],
                                  event.x_root, event.y_root)

            self.double_click_item = None
            self.single_click_item = None
            self.right_click_item = None
Exemple #4
0
    def release_item(self, event):
        if is_left_button(event):
            cell = self.get_cell_with_event(event)
            if cell is not None:
                (release_row, release_column, offset_x, offset_y) = cell

                if release_row is not None:
                    if self.double_click_row == release_row:
                        self.visible_items[release_row].double_click(
                            release_column, offset_x, offset_y)
                        self.emit("double-click",
                                  self.visible_items[release_row],
                                  release_column)
                    elif self.single_click_row == release_row:
                        self.visible_items[release_row].single_click(
                            release_column, offset_x, offset_y)
                        self.emit("single-click-item",
                                  self.visible_items[release_row],
                                  release_column, offset_x, offset_y)

                if self.start_drag and self.is_in_visible_area(event):
                    self.drag_select_items_at_cursor()

                self.double_click_row = None
                self.single_click_row = None
                self.start_drag = False

                # Disable select rows when press_in_select_rows valid after button release.
                if self.press_in_select_rows:
                    self.set_select_rows([self.press_in_select_rows])
                    self.start_select_row = self.press_in_select_rows
                    self.press_in_select_rows = None

                self.set_drag_row(None)
Exemple #5
0
    def button_press_mac_entry(self, widget, event):
        self.draw_area.grab_focus()

        if event.x <= self.cursor_positions[0]:
            self.set_cursor_index(0)
        elif event.x >= self.cursor_positions[-1]:
            self.set_cursor_index(len(self.mac))
        else:
            ip_segment_distance = self.width / self.segment_number
            segment_index = int(event.x / ip_segment_distance)

            for (cursor_index, cursor_position) in enumerate(self.cursor_positions):
                if len(self.mac.split(self.segment_split_char)[segment_index]) == 0:
                    self.set_cursor_index(segment_index)
                    break
                elif cursor_position < event.x <= self.cursor_positions[cursor_index + 1]:
                    self.set_cursor_index(cursor_index)
                    break

        # Hide right menu immediately.
        self.right_menu.hide()

        if is_double_click(event):
            self.highlight_current_segment()
        elif is_left_button(event):
            self.clear_highlight_segment()
        elif is_right_button(event):
            x, y = self.window.get_root_origin()
            wx, wy = int(event.x), int(event.y)
            (offset_x, offset_y) = widget.translate_coordinates(self, 0, 0)
            (_, px, py, modifier) = widget.get_display().get_pointer()
            self.right_menu.show((px - offset_x, py - wy - offset_y + widget.allocation.height))

        self.queue_draw()
Exemple #6
0
 def press_progressbar(self, widget, event):
     if is_left_button(event):
         rect = widget.allocation
         lower_value = self.get_adjustment().get_lower()
         upper_value = self.get_adjustment().get_upper()
         point_height = self.point_dpixbuf.get_pixbuf().get_height()
         self.set_value(upper_value - ((event.y - point_height / 2) / (rect.height - point_height)) * (upper_value - lower_value) )
         self.queue_draw()
         
     return False    
 def __treeview_button_press_event(self, w, e):
     index = int(e.y / self.node_height)
     if is_left_button(e):
         if index < len(self.__nodes_list):
             node = self.__nodes_list[index]
             node.is_expanded = not node.is_expanded
             self.single_items = [node]
             self.tree_view_queue_draw_area()
             self.emit("treeview-press-event", self, node)
             return False
Exemple #8
0
 def button_press_textview(self, widget, event):
     '''Button press textview.'''
     # Get input focus.
     self.grab_focus()
     
     self.grab_focus_flag = True
     
     if is_left_button(event):
         self.left_click_flag = True
         self.left_click_coordindate = (event.x, event.y)
         
         self.drag_start_index = self.get_index_at_event(widget, event)
Exemple #9
0
 def handle_button_press(self, widget, event):
     '''Button press entry.'''
     # Get input focus.
     self.entry.grab_focus()
     self.shortcut_key_record = self.shortcut_key
     
     if is_left_button(event):
         self.entry.editable_flag = True
         self.emit("wait-key-input", self.shortcut_key)
         self.set_text(_("Please input new shortcuts"))
         self.entry.editable_flag = False
         
         self.entry.queue_draw()
Exemple #10
0
    def press_progressbar(self, widget, event):
        '''
        Internal callback for `button-press-event` signal.
        '''
        if is_left_button(event):
            rect = widget.allocation
            lower_value = self.get_adjustment().get_lower()
            upper_value = self.get_adjustment().get_upper()
            point_height = self.point_dpixbuf.get_pixbuf().get_height()
            self.set_value(upper_value - ((event.y - point_height / 2) / (rect.height - point_height)) * (upper_value - lower_value) )
            self.queue_draw()

        return False
Exemple #11
0
 def __treeview_button_press_event(self, w, e):
     index = int(e.y / self.node_height)
     if is_left_button(e):
         if index < len(self.__nodes_list):
             node = self.__nodes_list[index]
             node.is_expanded = not node.is_expanded
             self.single_items = [node]
             self.tree_view_queue_draw_area()
             self.emit("treeview-press-event", self, node)
             if is_double_click(e):
                 self.double_items = [node]
                 self.emit("treeview-double-event", self, node)
             return False
Exemple #12
0
 def press_volume_progressbar(self, widget, event):
     '''Press volume progressbar.'''
     # Init.
     if is_left_button(event):
         rect = widget.allocation
         lower = self.get_adjustment().get_lower()
         upper = self.get_adjustment().get_upper()
         point_width = self.point_dpixbuf.get_pixbuf().get_width()
         
         # Set value.
         self.set_value(lower + ((event.x - point_width / 2)  / (rect.width - point_width)) * (upper - lower))
         self.queue_draw()
     
     return False
Exemple #13
0
    def __listview_button_release_event(self, widget, event):
        #print "__listview_button_release_event..."
        self.__move_column_check = False  # 取消移动标题头.
        # 获取标题头触发的release事件返回的x索引.
        if is_left_button(event):
            # 列标头.
            if self.view == View.DETAILS:
                col_index, column_x, column_y = self.__get_columns_mouse_data(
                    event)
                if col_index != None:
                    self.__single_columns = self.columns[col_index]
                    if self.__single_columns_hd:
                        self.__single_columns_hd(self, self.__single_columns,
                                                 col_index, column_x, column_y)
            # 获取items触发的release事件返回的x,y索引.
            row_index, col_index, item_x, item_y = self.__get_items_mouse_data(
                event)
            #insert_index = self.__move_column_insert_index
            insert_index = row_index
            if not (None in [row_index]):
                # 发送信号.
                if self.__save_press_items_index == row_index:
                    if not self.__ctrl_check:
                        self.__single_items = []
                    # 判断是否重新选择了,如果是就消除掉.
                    if self.items[row_index] in self.__single_items:
                        self.__single_items.remove(self.items[row_index])
                    else:
                        self.__single_items.append(self.items[row_index])
                    if self.__single_items_hd:
                        self.__single_items_hd(self, self.__single_items,
                                               row_index, col_index, item_x,
                                               item_y)
            else:
                insert_index = len(self.items)

            if self.__move_items_check and self.__save_press_items_index != row_index:
                for insert_item in self.__single_items:
                    self.items.remove(insert_item)
                    self.items.add_insert(insert_index, insert_item)
            self.__save_press_items_check = False
            self.__drag_rect = (None, None, None)
            self.drag_preview_pixbuf = None
        elif is_right_button(event):
            row_index, col_index, item_x, item_y = self.__get_items_mouse_data(
                event)
            if self.__right_items_hd:
                self.__right_items_hd(self, event, row_index, col_index,
                                      item_x, item_y)
Exemple #14
0
 def button_release_icon_view(self, widget, event):
     '''Button release event handler.'''
     if len(self.items) > 0 and is_left_button(event):
         index_info = self.icon_view_get_event_index(event)
         if index_info:
             (row_index, column_index, item_index, offset_x, offset_y) = index_info
             
             self.emit("button-release-item", self.items[item_index], offset_x - self.padding_x, offset_y - self.padding_y)
             
             if self.double_click_item == item_index:
                 self.emit("double-click-item", self.items[self.double_click_item], offset_x - self.padding_x, offset_y - self.padding_y)
             elif self.single_click_item == item_index:
                 self.emit("single-click-item", self.items[self.single_click_item], offset_x - self.padding_x, offset_y - self.padding_y)
         
         self.double_click_item = None
         self.single_click_item = None
Exemple #15
0
 def button_press_label(self, widget, event):
     '''Button press label.'''
     if not self.enable_gaussian:
         # Get input focus.
         self.grab_focus()
     
         # Select all when double click left button.
         if is_double_click(event) and self.enable_double_click:
             self.double_click_flag = True
             self.select_all()
         # Change cursor when click left button.
         elif is_left_button(event):
             self.left_click_flag = True
             self.left_click_coordindate = (event.x, event.y)
             
             self.drag_start_index = self.get_index_at_event(widget, event)
Exemple #16
0
    def __listview_button_press_event(self, widget, event):
        if is_left_button(event):
            if self.view == View.DETAILS:
                move_index, move_check = self.__get_columns_mouse_data(
                    event, move_check=True)
                if move_check and move_index != None:
                    self.__move_column_check = move_check
                    self.__save_move_column_index = move_index
                    self.__save_move_column_x = int(event.x)
            # 移动items.
            move_index, move_check = self.__get_items_mouse_data(
                event, move_check=True)
            # 按下items.
            press_index, press_check = move_index, move_check
            if press_check and press_index != None:
                self.__save_press_items_index = press_index
                self.__save_press_items_check = press_check
                self.__save_press_items_y = int(event.y)

            if move_index != None and move_check and self.__drag_items_check:
                for item in self.__single_items:
                    if item == self.items[move_index]:
                        self.__move_items_check = move_check
                        self.__save_move_items_index = move_index
                        self.__save_move_items_x = int(event.x)
                        break
                else:
                    self.__move_items_check = False

        # 判断双击的区域.
        if is_double_click(event):
            row_index, col_index, item_x, item_y = self.__get_items_mouse_data(
                event)
            if not (None in [row_index]):
                self.__double_items = self.items[row_index]
                # 发送信号.
                if self.__double_items_hd:
                    self.__double_items_hd(self, self.__double_items,
                                           row_index, col_index, item_x,
                                           item_y)
                self.on_queue_draw_area()
        else:
            row_index, col_index, item_x, item_y = self.__get_items_mouse_data(
                event)
            #print "press_event:", row_index
            self.__save_press_move_item_num = row_index  # 保存按下的items row.
 def __listview_button_release_event(self, widget, event):
     #print "__listview_button_release_event..."
     self.__move_column_check = False # 取消移动标题头.
     # 获取标题头触发的release事件返回的x索引.
     if is_left_button(event):
         # 列标头.
         if self.view == View.DETAILS:
             col_index, column_x, column_y =  self.__get_columns_mouse_data(event)
             if col_index != None: 
                 self.__single_columns = self.columns[col_index]
                 if self.__single_columns_hd:
                     self.__single_columns_hd(self, self.__single_columns, col_index, column_x, column_y)
         # 获取items触发的release事件返回的x,y索引.
         row_index, col_index, item_x, item_y = self.__get_items_mouse_data(event)
         #insert_index = self.__move_column_insert_index
         insert_index = row_index
         if not (None in [row_index]):
             # 发送信号.
             if self.__save_press_items_index == row_index:
                 if not self.__ctrl_check:
                     self.__single_items = []
                 # 判断是否重新选择了,如果是就消除掉.
                 if self.items[row_index] in self.__single_items:
                    self.__single_items.remove(self.items[row_index]) 
                 else:
                     self.__single_items.append(self.items[row_index])
                 if self.__single_items_hd:
                     self.__single_items_hd(self, self.__single_items, row_index, col_index, item_x, item_y)
         else:
             insert_index = len(self.items)
         
         if self.__move_items_check and self.__save_press_items_index != row_index:
             for insert_item in self.__single_items:
                 self.items.remove(insert_item)
                 self.items.add_insert(insert_index, insert_item)
         self.__save_press_items_check = False
         self.__drag_rect = (None, None, None)
         self.drag_preview_pixbuf = None
     elif is_right_button(event):
         row_index, col_index, item_x, item_y = self.__get_items_mouse_data(event)
         if self.__right_items_hd:
             self.__right_items_hd(self, event, row_index, col_index, item_x, item_y)
Exemple #18
0
    def button_press_icon_view(self, widget, event):
        '''
        Internal callback for `button-press-event` signal.
        '''
        # Grab focus when button press, otherwise key-press signal can't response.
        self.grab_focus()

        if len(self.items) > 0:

            index_info = self.icon_view_get_event_index(event)

            if index_info:
                (row_index, column_index, item_index, offset_x,
                 offset_y) = index_info

                if is_left_button(event):
                    self.emit("button-press-item", self.items[item_index],
                              offset_x - self.padding_x,
                              offset_y - self.padding_y)
                    if is_double_click(event):
                        if index_info:
                            self.double_click_item = index_info[2]
                        else:
                            self.double_click_item = None

                    elif is_single_click(event):
                        if index_info:
                            self.single_click_item = index_info[2]
                        else:
                            self.single_click_item = None

                elif is_right_button(event):
                    if index_info:
                        self.right_click_item = index_info[2]
                    else:
                        self.right_click_item = None

                # Set highlight.
                if index_info:
                    self.clear_highlight()

                    self.set_highlight(self.items[index_info[2]])
Exemple #19
0
    def button_press_label(self, widget, event):
        '''
        Internal callback for `button-press-event` signal.

        @param widget: Label widget.
        @param event: Button press event.
        '''
        if not self.enable_gaussian:
            # Get input focus.
            self.grab_focus()

            # Select all when double click left button.
            if is_double_click(event) and self.enable_double_click:
                self.double_click_flag = True
                self.select_all()
            # Change cursor when click left button.
            elif is_left_button(event):
                self.left_click_flag = True
                self.left_click_coordindate = (event.x, event.y)

                self.drag_start_index = self.get_index_at_event(widget, event)
Exemple #20
0
    def button_press_label(self, widget, event):
        '''
        Internal callback for `button-press-event` signal.

        @param widget: Label widget.
        @param event: Button press event.
        '''
        if not self.enable_gaussian:
            # Get input focus.
            self.grab_focus()

            # Select all when double click left button.
            if is_double_click(event) and self.enable_double_click:
                self.double_click_flag = True
                self.select_all()
            # Change cursor when click left button.
            elif is_left_button(event):
                self.left_click_flag = True
                self.left_click_coordindate = (event.x, event.y)

                self.drag_start_index = self.get_index_at_event(widget, event)
 def __listview_button_press_event(self, widget, event):
     if is_left_button(event):
         if self.view == View.DETAILS:
             move_index, move_check =  self.__get_columns_mouse_data(event, move_check=True)
             if move_check and move_index != None:
                 self.__move_column_check  = move_check
                 self.__save_move_column_index  = move_index
                 self.__save_move_column_x = int(event.x)
         # 移动items.
         move_index, move_check = self.__get_items_mouse_data(event, move_check=True)
         # 按下items.
         press_index, press_check = move_index, move_check
         if press_check and press_index != None:
             self.__save_press_items_index = press_index
             self.__save_press_items_check = press_check
             self.__save_press_items_y     = int(event.y)
         
         if move_index != None and move_check:
             for item in self.__single_items:
                 if item == self.items[move_index]:
                     self.__move_items_check      = move_check
                     self.__save_move_items_index = move_index
                     self.__save_move_items_x     = int(event.x)
                     break
             else:
                 self.__move_items_check = False
         
     # 判断双击的区域.
     if is_double_click(event):
         row_index, col_index, item_x, item_y = self.__get_items_mouse_data(event)
         if not (None in [row_index]):
             self.__double_items = self.items[row_index]
             # 发送信号.
             if self.__double_items_hd:
                 self.__double_items_hd(self, self.__double_items, row_index, col_index, item_x, item_y)
             self.on_queue_draw_area()
     else:
         row_index, col_index, item_x, item_y = self.__get_items_mouse_data(event)
         #print "press_event:", row_index
         self.__save_press_move_item_num = row_index # 保存按下的items row.
Exemple #22
0
    def button_press_mac_entry(self, widget, event):
        self.draw_area.grab_focus()

        if event.x <= self.cursor_positions[0]:
            self.set_cursor_index(0)
        elif event.x >= self.cursor_positions[-1]:
            self.set_cursor_index(len(self.mac))
        else:
            ip_segment_distance = self.width / self.segment_number
            segment_index = int(event.x / ip_segment_distance)

            for (cursor_index,
                 cursor_position) in enumerate(self.cursor_positions):
                if len(self.mac.split(
                        self.segment_split_char)[segment_index]) == 0:
                    self.set_cursor_index(segment_index)
                    break
                elif cursor_position < event.x <= self.cursor_positions[
                        cursor_index + 1]:
                    self.set_cursor_index(cursor_index)
                    break

        # Hide right menu immediately.
        self.right_menu.hide()

        if is_double_click(event):
            self.highlight_current_segment()
        elif is_left_button(event):
            self.clear_highlight_segment()
        elif is_right_button(event):
            x, y = self.window.get_root_origin()
            wx, wy = int(event.x), int(event.y)
            (offset_x, offset_y) = widget.translate_coordinates(self, 0, 0)
            (_, px, py, modifier) = widget.get_display().get_pointer()
            self.right_menu.show(
                (px - offset_x, py - wy - offset_y + widget.allocation.height))

        self.queue_draw()
Exemple #23
0
 def button_release_icon_view(self, widget, event):
     '''
     Internal callback for `button-release-event` signal.
     '''
     if len(self.items) > 0:
         index_info = self.icon_view_get_event_index(event)
         if index_info:
             (row_index, column_index, item_index, offset_x, offset_y) = index_info
             
             if is_left_button(event):
                 self.emit("button-release-item", self.items[item_index], offset_x - self.padding_x, offset_y - self.padding_y)
                 
                 if self.double_click_item == item_index:
                     self.emit("double-click-item", self.items[self.double_click_item], offset_x - self.padding_x, offset_y - self.padding_y)
                 elif self.single_click_item == item_index:
                     self.emit("single-click-item", self.items[self.single_click_item], offset_x - self.padding_x, offset_y - self.padding_y)
             elif is_right_button(event):        
                 if self.right_click_item == item_index:    
                     self.emit("right-click-item", self.items[self.right_click_item], event.x_root, event.y_root)
         
         self.double_click_item = None
         self.single_click_item = None
         self.right_click_item = None
Exemple #24
0
 def handle_button_press(self, widget, event):
     '''Handle button press.'''
     # Get input focus.
     self.grab_focus()
     
     # Hide right menu immediately.
     self.right_menu.hide()
     
     # Select all when double click left button.
     if is_double_click(event):
         self.double_click_flag = True
         self.select_all()
     # Show right menu when click right button.
     elif is_right_button(event):
         if self.right_menu_visible_flag:
             (wx, wy) = self.window.get_root_origin()
             (cx, cy, modifier) = self.window.get_pointer()
             self.right_menu.show((cx + wx, cy + wy))
     # Change cursor when click left button.
     elif is_left_button(event):
         self.left_click_flag = True
         self.left_click_coordindate = (event.x, event.y)
         
         self.drag_start_index = self.get_index_at_event(widget, event)