コード例 #1
0
ファイル: scrolled_window.py プロジェクト: netphi/deepin-ui
 def set_vadjustment(self, adj):
     remove_signal_id(self.v_value_change_id)
     remove_signal_id(self.v_change_id)
     
     self.vadjustment = adj
     v_value_change_handler_id = self.vadjustment.connect('value-changed', self.vadjustment_changed)
     v_change_handler_id = self.vadjustment.connect('changed', self.update_scrollbar)
     self.v_value_change_id = (self.vadjustment, v_value_change_handler_id)
     self.v_change_id = (self.vadjustment, v_change_handler_id)
コード例 #2
0
    def set_vadjustment(self, adj):
        '''
        Sets the gtk.Adjustment for the vertical scrollbar.

        @param adj: vertical scroll adjustment
        '''
        remove_signal_id(self.v_value_change_id)
        remove_signal_id(self.v_change_id)

        self.vadjustment = adj
        v_value_change_handler_id = self.vadjustment.connect('value-changed', self.vadjustment_changed)
        v_change_handler_id = self.vadjustment.connect('changed', self.update_scrollbar)
        self.v_value_change_id = (self.vadjustment, v_value_change_handler_id)
        self.v_change_id = (self.vadjustment, v_change_handler_id)
コード例 #3
0
    def set_hadjustment(self, adj):
        '''
        Sets the gtk.Adjustment for the horizontal scrollbar.

        @param adj: horizontal scroll adjustment
        '''
        remove_signal_id(self.h_value_change_id)
        remove_signal_id(self.h_change_id)

        self.hadjustment = adj
        h_value_change_handler_id = self.hadjustment.connect('value-changed', self.hadjustment_changed)
        h_change_handler_id = self.hadjustment.connect('changed', self.update_scrollbar)
        self.h_value_change_id = (self.hadjustment, h_value_change_handler_id)
        self.h_change_id = (self.hadjustment, h_change_handler_id)
コード例 #4
0
    def set_vadjustment(self, adj):
        '''
        Sets the gtk.Adjustment for the vertical scrollbar.

        @param adj: vertical scroll adjustment
        '''
        remove_signal_id(self.v_value_change_id)
        remove_signal_id(self.v_change_id)

        self.vadjustment = adj
        v_value_change_handler_id = self.vadjustment.connect(
            'value-changed', self.vadjustment_changed)
        v_change_handler_id = self.vadjustment.connect('changed',
                                                       self.update_scrollbar)
        self.v_value_change_id = (self.vadjustment, v_value_change_handler_id)
        self.v_change_id = (self.vadjustment, v_change_handler_id)
コード例 #5
0
    def set_hadjustment(self, adj):
        '''
        Sets the gtk.Adjustment for the horizontal scrollbar.

        @param adj: horizontal scroll adjustment
        '''
        remove_signal_id(self.h_value_change_id)
        remove_signal_id(self.h_change_id)

        self.hadjustment = adj
        h_value_change_handler_id = self.hadjustment.connect(
            'value-changed', self.hadjustment_changed)
        h_change_handler_id = self.hadjustment.connect('changed',
                                                       self.update_scrollbar)
        self.h_value_change_id = (self.hadjustment, h_value_change_handler_id)
        self.h_change_id = (self.hadjustment, h_change_handler_id)
コード例 #6
0
ファイル: osd_tooltip.py プロジェクト: netphi/deepin-ui
 def hide_immediately(self):
     '''Hide immediately.'''
     # Remove callback.
     remove_signal_id(self.configure_event_callback_id)
     remove_signal_id(self.destroy_callback_id)
     remove_signal_id(self.focus_out_callback_id)
     remove_timeout_id(self.start_hide_callback_id)
     
     self.hide_all()
コード例 #7
0
ファイル: osd_tooltip.py プロジェクト: chenzhiwei/deepin-ui
    def show(self, text):
        '''
        Show.

        @param text: OSD tooltip text.
        '''
        # Remove callback.j
        remove_signal_id(self.configure_event_callback_id)
        remove_signal_id(self.destroy_callback_id)
        remove_signal_id(self.focus_out_callback_id)
        remove_timeout_id(self.start_hide_callback_id)

        # Update text.
        self.text = text

        # Get tooltip size.
        (tooltip_width, tooltip_height) = get_content_size(
            self.text,
            self.text_size + self.border_radious * 2,
            self.text_font)
        self.tooltip_width = tooltip_width * 2
        self.tooltip_height = tooltip_height

        # Move tooltip to given position.
        (monitor_x, monitor_y) = self.monitor_widget.window.get_origin()
        self.tooltip_x = monitor_x + self.offset_x
        self.tooltip_y = monitor_y + self.offset_y

        # Monitor configure-event signal.
        self.monitor_window = self.monitor_widget.get_toplevel()
        configure_event_handler_id = self.monitor_window.connect("configure-event", self.handle_configure_event)
        self.configure_event_callback_id = (self.monitor_window, configure_event_handler_id)
        destroy_handler_id = self.monitor_window.connect("destroy", lambda w: self.hide_immediately())
        self.destroy_callback_id = (self.monitor_window, destroy_handler_id)
        focus_out_handler_id = self.monitor_window.connect("focus-out-event", lambda w, e: self.hide_immediately())
        self.focus_out_callback_id = (self.monitor_window, focus_out_handler_id)

        # Save monitor window position.
        rect = self.monitor_window.allocation
        (monitor_window_x, monitor_window_y) = self.monitor_window.window.get_origin()
        monitor_window_width, monitor_window_height = rect.width, rect.height
        self.monitor_window_x = monitor_window_x
        self.monitor_window_y = monitor_window_y
        self.monitor_window_width = monitor_window_width
        self.monitor_window_height = monitor_window_height

        # Show.
        self.set_opacity(1)
        self.show_all()

        self.start_hide_callback_id = gobject.timeout_add(
            self.start_hide_delay,
            lambda : Animation(self, "opacity", self.hide_time, [1, 0],
                           stop_callback=self.hide_immediately).start())

        self.queue_draw()       # make sure redraw
コード例 #8
0
ファイル: osd_tooltip.py プロジェクト: masums/deepin-ui
    def hide_immediately(self):
        '''
        Hide immediately.
        '''
        # Remove callback.
        remove_signal_id(self.configure_event_callback_id)
        remove_signal_id(self.destroy_callback_id)
        remove_signal_id(self.focus_out_callback_id)
        remove_timeout_id(self.start_hide_callback_id)

        self.hide_all()
コード例 #9
0
ファイル: osd_tooltip.py プロジェクト: masums/deepin-ui
    def show(self, text):
        '''
        Show.

        @param text: OSD tooltip text.
        '''
        # Remove callback.j
        remove_signal_id(self.configure_event_callback_id)
        remove_signal_id(self.destroy_callback_id)
        remove_signal_id(self.focus_out_callback_id)
        remove_timeout_id(self.start_hide_callback_id)

        # Update text.
        self.text = text

        # Get tooltip size.
        (tooltip_width, tooltip_height) = get_content_size(
            self.text, self.text_size + self.border_radious * 2,
            self.text_font)
        self.tooltip_width = tooltip_width * 2
        self.tooltip_height = tooltip_height

        # Move tooltip to given position.
        (monitor_x, monitor_y) = self.monitor_widget.window.get_origin()
        self.tooltip_x = monitor_x + self.offset_x
        self.tooltip_y = monitor_y + self.offset_y

        # Monitor configure-event signal.
        self.monitor_window = self.monitor_widget.get_toplevel()
        configure_event_handler_id = self.monitor_window.connect(
            "configure-event", self.handle_configure_event)
        self.configure_event_callback_id = (self.monitor_window,
                                            configure_event_handler_id)
        destroy_handler_id = self.monitor_window.connect(
            "destroy", lambda w: self.hide_immediately())
        self.destroy_callback_id = (self.monitor_window, destroy_handler_id)
        focus_out_handler_id = self.monitor_window.connect(
            "focus-out-event", lambda w, e: self.hide_immediately())
        self.focus_out_callback_id = (self.monitor_window,
                                      focus_out_handler_id)

        # Save monitor window position.
        rect = self.monitor_window.allocation
        (monitor_window_x,
         monitor_window_y) = self.monitor_window.window.get_origin()
        monitor_window_width, monitor_window_height = rect.width, rect.height
        self.monitor_window_x = monitor_window_x
        self.monitor_window_y = monitor_window_y
        self.monitor_window_width = monitor_window_width
        self.monitor_window_height = monitor_window_height

        # Show.
        self.set_opacity(1)
        self.show_all()

        self.start_hide_callback_id = gobject.timeout_add(
            self.start_hide_delay,
            lambda: Animation(self,
                              "opacity",
                              self.hide_time, [1, 0],
                              stop_callback=self.hide_immediately).start())

        self.queue_draw()  # make sure redraw