示例#1
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]])
示例#2
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()
示例#3
0
 def press_notify_function(self, event):    
     temp_press_height = self.press_height
     self.press_height = event.y
     index_len = len(self.tree_list)
     index = int(self.press_height / self.height)
     
     if index_len > index:
         if is_single_click(event) and event.button == 1:
             self.highlight_index = index
             self.press_draw_bool = True
         
             if self.tree_list[index].child_items:        
                 self.tree_list[index].show_child_items_bool = not self.tree_list[index].show_child_items_bool 
                 self.sort()
                 self.queue_draw()
         
         if is_single_click(event) and event.button == 1:
             self.emit("single-click-item", self.tree_list[index].tree_view_item)
         elif is_double_click(event):    
             self.emit("double-click-item", self.tree_list[index].tree_view_item)
         elif is_right_button(event):    
             self.press_height = self.highlight_index * self.height
             self.emit("right-press-item", self.tree_list[index].tree_view_item, int(event.x_root), int(event.y_root), index)
             
     else:
         self.press_height = temp_press_height
         if is_right_button(event):    
             self.press_height = self.highlight_index * self.height
             self.emit("right-press-item", event, int(event.x_root), int(event.y_root), -1)
示例#4
0
    def double_click_window(self, widget, event):
        '''
        Double click event handler of the window. It will maximize the window.

        @param widget: A widget of type gtk.Widget.
        @param event: A event of type gtk.gdk.Event.
        @return: Always return False.
        '''
        if is_double_click(event):
            self.toggle_max_window()
            
        return False    
示例#5
0
    def double_click_window(self, widget, event):
        '''
        Double click event handler of the window. It will maximize the window.

        @param widget: A widget of type gtk.Widget.
        @param event: A event of type gtk.gdk.Event.
        @return: Always return False.
        '''
        if is_double_click(event):
            self.toggle_max_window()

        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)
             if is_double_click(e):
                 self.double_items = [node]
                 self.emit("treeview-double-event", self, node)
             return False
示例#7
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
示例#8
0
文件: label.py 项目: netphi/deepin-ui
 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)
示例#9
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.
示例#10
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]])
示例#11
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)
示例#12
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.
示例#14
0
文件: net.py 项目: masums/deepin-ui
    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()
示例#15
0
文件: entry.py 项目: netphi/deepin-ui
 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)
示例#16
0
 def double_click_window(self, widget, event):
     '''Handle double click on window.'''
     if is_double_click(event):
         self.toggle_max_window()
         
     return False