Beispiel #1
0
    def setup_widgets(self):
        self.messages.set_columns([
            Column('id', data_type=int, sorted=True, visible=False),
            Column('action', data_type=int, format_func=self._format_action,
                   format_func_data=True),
            Column('received', data_type=str, visible=False),
            Column('discards', data_type=int),
            Column('sender', data_type=str),
            Column('domain', data_type=str, visible=False),
            Column('subject', expand=True, data_type=str),
        ])
        self.messages.set_cell_data_func(self._on_messages__cell_data_func)

        # Install a Control-Q handler that forcefully exits
        # the program without saving any kind of state
        def event_handler(event):
            if event.type == gdk.KEY_PRESS:
                if event.keyval == gtk.keysyms.q:
                    self.quit()
                elif event.keyval == gtk.keysyms.p:
                    self.submit()
                elif self.msg and event.keyval == gtk.keysyms.a:
                    self.approve(self.msg)
                elif self.msg and event.keyval == gtk.keysyms.d:
                    self.discard(self.msg)
                elif self.msg and event.keyval == gtk.keysyms.s:
                    self.skip(self.msg)
            gtk.main_do_event(event)
        gdk.event_handler_set(event_handler)
Beispiel #2
0
    def setup_widgets(self):
        self.messages.set_columns([
            Column('id', data_type=int, sorted=True, visible=False),
            Column('action',
                   data_type=int,
                   format_func=self._format_action,
                   format_func_data=True),
            Column('received', data_type=str, visible=False),
            Column('discards', data_type=int),
            Column('sender', data_type=str),
            Column('domain', data_type=str, visible=False),
            Column('subject', expand=True, data_type=str),
        ])
        self.messages.set_cell_data_func(self._on_messages__cell_data_func)

        # Install a Control-Q handler that forcefully exits
        # the program without saving any kind of state
        def event_handler(event):
            if event.type == gdk.KEY_PRESS:
                if event.keyval == gtk.keysyms.q:
                    self.quit()
                elif event.keyval == gtk.keysyms.p:
                    self.submit()
                elif self.msg and event.keyval == gtk.keysyms.a:
                    self.approve(self.msg)
                elif self.msg and event.keyval == gtk.keysyms.d:
                    self.discard(self.msg)
                elif self.msg and event.keyval == gtk.keysyms.s:
                    self.skip(self.msg)
            gtk.main_do_event(event)

        gdk.event_handler_set(event_handler)
Beispiel #3
0
 def registerEventHandler(self):
     """
     Registers the method self.eventHandler as the function that
     will receive all GDK events.  This allows us to snoop on GDK.
     """
     if not event_handler_set:
         raise NotImplementedError
     else:
         gobject.idle_add(self.idleHandler)
         event_handler_set(self.eventHandler)
Beispiel #4
0
    def _setup_gtk(self):
        import gtk
        from kiwi.environ import environ

        # Total madness to make sure we can draw treeview lines,
        # this affects the GtkTreeView::grid-line-pattern style property
        #
        # Two bytes are sent in, see gtk_tree_view_set_grid_lines in gtktreeview.c
        # Byte 1 should be as high as possible, gtk+ 0x7F appears to be
        #        the highest allowed for Gtk+ 2.22 while 0xFF worked in
        #        earlier versions
        # Byte 2 should ideally be allowed to be 0, but neither C nor Python
        #        allows that.
        #
        data = environ.get_resource_string("stoq", "misc", "stoq.gtkrc")
        data = data.replace('\\x7f\\x01', '\x7f\x01')

        gtk.rc_parse_string(data)

        # Creating a button as a temporary workaround for bug
        # https://bugzilla.gnome.org/show_bug.cgi?id=632538, until gtk 3.0
        gtk.Button()
        settings = gtk.settings_get_default()
        settings.props.gtk_button_images = True

        from stoqlib.lib.environment import is_developer_mode
        if is_developer_mode() and gtk.gtk_version[0] == 2:
            from gtk import gdk

            # Install a Control-Q handler that forcefully exits
            # the program without saving any kind of state
            def event_handler(event):
                if (event.type == gdk.KEY_PRESS
                        and event.state & gdk.CONTROL_MASK
                        and event.keyval == gtk.keysyms.q):
                    os._exit(0)
                gtk.main_do_event(event)

            gdk.event_handler_set(event_handler)
Beispiel #5
0
    def _setup_gtk(self):
        import gtk
        from kiwi.environ import environ

        gtk.gdk.threads_init()
        # Total madness to make sure we can draw treeview lines,
        # this affects the GtkTreeView::grid-line-pattern style property
        #
        # Two bytes are sent in, see gtk_tree_view_set_grid_lines in gtktreeview.c
        # Byte 1 should be as high as possible, gtk+ 0x7F appears to be
        #        the highest allowed for Gtk+ 2.22 while 0xFF worked in
        #        earlier versions
        # Byte 2 should ideally be allowed to be 0, but neither C nor Python
        #        allows that.
        #
        data = environ.get_resource_string("stoq", "misc", "stoq.gtkrc")
        data = data.replace('\\x7f\\x01', '\x7f\x01')

        gtk.rc_parse_string(data)

        # Creating a button as a temporary workaround for bug
        # https://bugzilla.gnome.org/show_bug.cgi?id=632538, until gtk 3.0
        gtk.Button()
        settings = gtk.settings_get_default()
        settings.props.gtk_button_images = True

        from stoqlib.lib.environment import is_developer_mode
        if is_developer_mode() and gtk.gtk_version[0] == 2:
            from gtk import gdk

            # Install a Control-Q handler that forcefully exits
            # the program without saving any kind of state
            def event_handler(event):
                if (event.type == gdk.KEY_PRESS and
                    event.state & gdk.CONTROL_MASK and
                    event.keyval == gtk.keysyms.q):
                    os._exit(0)
                gtk.main_do_event(event)
            gdk.event_handler_set(event_handler)
Beispiel #6
0
 def register_event_handler(self):
     if not event_handler_set:
         raise NotImplementedError
     event_handler_set(self._event_handler)
Beispiel #7
0
    return widget is different every time be invoked.

    @param widget: Gtk.Widget instance.
    @param need: whether alwasy update.
    '''
    set_value(widget, {"always_update" : need})
    return always_update

#------------------------this is global effect function---------------------
def disable_all(is_disable):
    '''
    '''
    count = TooltipInfo.enable_count
    if is_disable:
        if count > 0:
            TooltipInfo.enable_count = -count
    else:
        if count < 0:
            TooltipInfo.enable_count = -count


def tooltip_handler(event):
    gtk.main_do_event(event)
    if event.type == gdk.MOTION_NOTIFY:
        # print "leave", time.time()
        update_tooltip()
    elif event.type == gdk.LEAVE_NOTIFY:
        # print "leave", time.time()
        hide_tooltip()
gdk.event_handler_set(tooltip_handler)
Beispiel #8
0
    @param need: whether alwasy update.
    '''
    set_value(widget, {"always_update": need})
    return always_update


#------------------------this is global effect function---------------------
def disable_all(is_disable):
    '''
    '''
    count = TooltipInfo.enable_count
    if is_disable:
        if count > 0:
            TooltipInfo.enable_count = -count
    else:
        if count < 0:
            TooltipInfo.enable_count = -count


def tooltip_handler(event):
    gtk.main_do_event(event)
    if event.type == gdk.MOTION_NOTIFY:
        # print "leave", time.time()
        update_tooltip()
    elif event.type == gdk.LEAVE_NOTIFY:
        # print "leave", time.time()
        hide_tooltip()


gdk.event_handler_set(tooltip_handler)
Beispiel #9
0
 def register_event_handler(self):
     if not event_handler_set:
         raise NotImplementedError
     event_handler_set(self._event_handler)
Beispiel #10
0
 def __init__(self):
     gdk.event_handler_set(self._filter_callback)
     glib.timeout_add_seconds(1, self._increase_idle)
     self._idle = 0
Beispiel #11
0
 def __init__(self):
     gdk.event_handler_set(self._filter_callback)
     glib.timeout_add_seconds(1, self._increase_idle)
     self._idle = 0