Beispiel #1
0
    def __init__(self, session, on_send_message, on_cycle_history,
                 on_drag_data_received, send_typing_notification):
        '''constructor'''
        TextBox.__init__(self, session.config, on_drag_data_received)
        self.on_send_message = on_send_message
        self.on_cycle_history = on_cycle_history
        self.send_typing_notification = send_typing_notification
        self._tag = None
        self._textbox.connect('key-press-event', self._on_key_press_event)
        self._buffer.connect('changed', self.on_changed_event)
        self.session = session

        self.changed = False
        self.parse_timeout = None
        self.typing_timeout = None
        self.invisible_tag = gtk.TextTag()
        self.invisible_tag.set_property('invisible', True)
        self._buffer.get_tag_table().add(self.invisible_tag)

        self.spell_checker = None

        #FIXME: gtk2 only as there isn't gtk3 package yet
        if not check_gtk3() and self.config.b_enable_spell_check:
            try:
                import gtkspell
                spell_lang = self.config.get_or_set("spell_lang", "en")
                self.spell_checker = gtkspell.Spell(self._textbox, spell_lang)
            except Exception, e:
                log.warning("Could not load spell-check: %s" % e)
Beispiel #2
0
    def _drag_data_received(self, treeview, context, posx, posy, \
                            selection, info, timestamp):
        '''method called on an image dragged to the view'''
        if check_gtk3():
            urls = selection.get_data().split('\n')
        else:
            urls = selection.data.split('\n')
        for url in urls:
            path = url.replace('file://', '')
            path = path.replace('\r', '')

            # the '\x00' value makes an error
            path = path.replace(chr(0), '')

            path = MarkupParser.urllib.url2pathname(path)

            # this seems to be an error on ntpath but we take care :S
            try:
                if os.path.exists(path):
                    self.on_drag_data_accepted(path,
                        gtk.gdk.PixbufAnimation(path).is_static_image())
            except TypeError, error:
                if self.on_drag_data_accepted is None:
                    print _("Could not add picture:\n %s") % \
                        _("Drag and drop to this IconView is not allowed.")
                else:
                    print _("Could not add picture:\n %s") % (str(error),)
Beispiel #3
0
    def _drag_data_received(self, treeview, context, posx, posy, \
                            selection, info, timestamp):
        '''method called on an image dragged to the view'''
        if check_gtk3():
            urls = selection.get_data().split('\n')
        else:
            urls = selection.data.split('\n')
        for url in urls:
            path = url.replace('file://', '')
            path = path.replace('\r', '')

            # the '\x00' value makes an error
            path = path.replace(chr(0), '')

            path = MarkupParser.urllib.url2pathname(path)

            # this seems to be an error on ntpath but we take care :S
            try:
                if os.path.exists(path):
                    self.on_drag_data_accepted(
                        path,
                        gtk.gdk.PixbufAnimation(path).is_static_image())
            except TypeError, error:
                if self.on_drag_data_accepted is None:
                    print _("Could not add picture:\n %s") % \
                        _("Drag and drop to this IconView is not allowed.")
                else:
                    print _("Could not add picture:\n %s") % (str(error), )
Beispiel #4
0
    def draw_avatar(self, context, pixbuf, xpos, ypos, dimension, position,
                    radius, alpha):
        '''draw the avatar'''
        context.save()
        context.set_antialias(cairo.ANTIALIAS_SUBPIXEL)
        context.translate(xpos, ypos)

        pix_width = pixbuf.get_width()
        pix_height = pixbuf.get_height()

        if (pix_width > dimension) or (pix_height > dimension):
            scale_factor = float(dimension) / max(pix_width, pix_height)
        else:
            scale_factor = 1

        scale_width = pix_width * scale_factor
        scale_height = pix_height * scale_factor

        #tranlate position
        self.translate_key_postion(context, position, dimension, dimension,
                                   scale_width, scale_height)

        if radius > 0:
            self.rounded_rectangle(context, 0, 0, scale_width, scale_height,
                                   dimension * radius)
            context.clip()

        context.scale(scale_factor, scale_factor)
        if not check_gtk3():
            context.set_source_pixbuf(pixbuf, 0, 0)
        else:
            gtk.gdk.cairo_set_source_pixbuf(context, pixbuf, 0, 0)

        context.paint_with_alpha(alpha)
        context.restore()
Beispiel #5
0
    def __init__(self, session, on_send_message, on_cycle_history,
                on_drag_data_received, send_typing_notification):
        '''constructor'''
        TextBox.__init__(self, session.config, on_drag_data_received)
        self.on_send_message = on_send_message
        self.on_cycle_history = on_cycle_history
        self.send_typing_notification = send_typing_notification
        self._tag = None
        self._textbox.connect('key-press-event', self._on_key_press_event)
        self._buffer.connect('changed', self.on_changed_event)
        self.session = session

        self.changed = False
        self.parse_timeout = None
        self.typing_timeout = None
        self.invisible_tag = gtk.TextTag()
        self.invisible_tag.set_property('invisible', True)
        self._buffer.get_tag_table().add(self.invisible_tag)

        self.spell_checker = None

        #FIXME: gtk2 only as there isn't gtk3 package yet
        if not check_gtk3() and self.config.b_enable_spell_check:
            try:
                import gtkspell
                spell_lang = self.config.get_or_set("spell_lang", "en")
                self.spell_checker = gtkspell.Spell(self._textbox, spell_lang)
            except Exception, e:
                log.warning("Could not load spell-check: %s" % e)
Beispiel #6
0
    def draw_avatar(self, context, pixbuf, xpos, ypos, dimension,
                    position, radius, alpha):
        '''draw the avatar'''
        context.save()
        context.set_antialias(cairo.ANTIALIAS_SUBPIXEL)
        context.translate(xpos, ypos)

        pix_width = pixbuf.get_width()
        pix_height = pixbuf.get_height()

        if (pix_width != dimension) or (pix_height != dimension):
            scale_factor = float(dimension) / max (pix_width, pix_height)
        else:
            scale_factor = 1

        scale_width = pix_width * scale_factor
        scale_height = pix_height * scale_factor

        #tranlate position
        self.translate_key_postion(context, position, dimension,
                dimension, scale_width, scale_height)

        if radius > 0 :
            self.rounded_rectangle(context, 0, 0, scale_width,
                    scale_height, dimension * radius)
            context.clip()

        context.scale(scale_factor, scale_factor)
        if not check_gtk3():
            context.set_source_pixbuf(pixbuf, 0, 0)
        else:
            gtk.gdk.cairo_set_source_pixbuf(context, pixbuf, 0, 0)

        context.paint_with_alpha(alpha)
        context.restore()
Beispiel #7
0
    def do_draw (self, ctx):
        if not self._pixbuf:
            return False

        cell_area = self.get_allocation()
        if not check_gtk3():
            cell_x, cell_y, cell_width, cell_height = cell_area
        else:
            cell_x = 0
            cell_width = cell_area.width
            cell_y = 0
            cell_height = cell_area.height

        if self.in_animation:
            self.draw_avatar(ctx, self._pixbuf, cell_x,
                cell_y, self._dimension, self._key_position, self._radius_factor,
                1 - (float(self.current_frame) / self.total_frames))
            self.draw_avatar(ctx, self.transition_pixbuf,
                cell_x, cell_y, self._dimension, self._key_position, self._radius_factor,
                (float(self.current_frame) / self.total_frames))
        else:
            self.draw_avatar(ctx, self._pixbuf, cell_x,
                cell_y, self._dimension, self._key_position, self._radius_factor, 1)

        return False
Beispiel #8
0
    def __init__(self, label, path_list, on_remove_cb, on_accept_cb,
                 iconv_type, on_drag_data_accepted):
        gtk.HBox.__init__(self)
        self.set_spacing(4)

        self.on_remove_cb = on_remove_cb
        self.on_accept_cb = on_accept_cb
        self.on_drag_data_accepted = on_drag_data_accepted
        self.iconv_type = iconv_type

        self.model = gtk.ListStore(gtk.gdk.Pixbuf, str)
        self.iconview = gtk.IconView(self.model)
        #FIXME: gtk3
        if not check_gtk3():
            self.iconview.enable_model_drag_dest([('text/uri-list', 0, 0)],
                                    gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_COPY)
            self.iconview.connect("drag-data-received", self._drag_data_received)
        self.iconview.set_pixbuf_column(0)
        self.iconview.connect("item-activated", self._on_icon_activated)
        self.iconview.connect("button_press_event", self.pop_up)

        self.label = gtk.Label(label)

        self.scroll = gtk.ScrolledWindow()
        self.scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        self.scroll.set_shadow_type(gtk.SHADOW_IN)
        self.scroll.add(self.iconview)
        self.pack_start(self.scroll, True, True)

        self.stop = False
        # Start a new thread to fill the iconview with images from path_list
        thread.start_new_thread(self.fill, (path_list,))
Beispiel #9
0
    def do_draw(self, ctx):
        if not self._pixbuf:
            return False

        cell_area = self.get_allocation()
        if not check_gtk3():
            cell_x, cell_y, cell_width, cell_height = cell_area
        else:
            cell_x = 0
            cell_width = cell_area.width
            cell_y = 0
            cell_height = cell_area.height

        if self.in_animation:
            self.draw_avatar(
                ctx, self._pixbuf, cell_x, cell_y, self._dimension,
                self._key_position, self._radius_factor,
                1 - (float(self.current_frame) / self.total_frames))
            self.draw_avatar(ctx, self.transition_pixbuf, cell_x, cell_y,
                             self._dimension, self._key_position,
                             self._radius_factor,
                             (float(self.current_frame) / self.total_frames))
        else:
            self.draw_avatar(ctx, self._pixbuf, cell_x, cell_y,
                             self._dimension, self._key_position,
                             self._radius_factor, 1)

        return False
Beispiel #10
0
 def __init__(self, cell_dimension = 96, crossfade = True, cell_radius = 0.05,
              cell_key_position = gtk.gdk.GRAVITY_CENTER):
     gtk.Widget.__init__(self)
     AvatarManager.__init__(self, cell_dimension, cell_radius, crossfade,
         cell_key_position)
     if not check_gtk3():
         self.set_flags(self.flags() | gtk.NO_WINDOW)
     else:
         gtk.Widget.set_has_window(self, False)
Beispiel #11
0
    def __init__(self, cell_dimension=96, crossfade=True, cell_radius=0.05):
        gtk.Widget.__init__(self)
        AvatarManager.__init__(self, cell_dimension, cell_radius, crossfade)
        if not check_gtk3():
            self.set_flags(self.flags() | gtk.NO_WINDOW)
        else:
            gtk.Widget.set_has_window(self, False)

        self.blocked = False
Beispiel #12
0
    def __init__(self, cell_dimension = 96, crossfade = True, cell_radius = 0.05):
        gtk.Widget.__init__(self)
        AvatarManager.__init__(self, cell_dimension, cell_radius, crossfade)
        if not check_gtk3():
            self.set_flags(self.flags() | gtk.NO_WINDOW)
        else:
            gtk.Widget.set_has_window(self, False)

        self.blocked = False
Beispiel #13
0
    def __init__(self, w_parent, transfer):
        gtk.Window.__init__(self, gtk.WINDOW_POPUP)

        self.transfer = transfer

        self.set_name('gtk-tooltips')
        self.set_position(gtk.WIN_POS_MOUSE)
        self.set_resizable(False)
        self.set_border_width(4)
        self.set_app_paintable(True)

        self.image = gtk.Image()
        self.details = gtk.Label()
        self.details.set_alignment(0, 0)

        self.table = gtk.Table(3, 2, False)
        self.table.set_col_spacings(5)

        self.add_label(_('Status:'), 0, 1, 0, 1)
        self.add_label(_('Average speed:'), 0, 1, 1, 2)
        self.add_label(_('Time elapsed:'), 0, 1, 2, 3)
        self.add_label(_('Estimated time left:'), 0, 1, 3, 4)

        self.status = gtk.Label()
        self.speed = gtk.Label()
        self.elapsed = gtk.Label()
        self.etl = gtk.Label()

        self.add_label('', 1, 2, 0, 1, self.status)
        self.add_label('', 1, 2, 1, 2, self.speed)
        self.add_label('', 1, 2, 2, 3, self.elapsed)
        self.add_label('', 1, 2, 3, 4, self.etl)

        vbox = gtk.VBox(False, 5)
        vbox.pack_start(self.details, False, False)
        vbox.pack_start(self.table, False, False)

        hbox = gtk.HBox(False, 5)
        hbox.pack_start(self.image, False, False)
        hbox.pack_start(vbox, True, True)

        self.add(hbox)

        if not check_gtk3():
            self.connect('expose-event', self.on_expose_event)
        else:
            context = self.get_style_context()
            gtk.StyleContext.add_class(context, "tooltip")

        w_parent.connect('enter-notify-event', self.on_motion)
        w_parent.connect('leave-notify-event', self.on_leave)

        self.pointer_is_over_widget = False

        self.__fileprev = None
Beispiel #14
0
    def __init__(self):
        gobject.GObject.__init__(self)
        gtk.TextView.__init__(self)
        self.connect('key-press-event', self.on_key_press_event)

        if check_gtk3():
            targets = [gtk.TargetEntry.new('emesene-invite', 0, 3)]
        else:
            targets = [('emesene-invite', 0, 3)]

        self.drag_dest_set(0, targets, gtk.gdk.ACTION_DEFAULT)
Beispiel #15
0
    def __init__(self):
        gobject.GObject.__init__(self)
        gtk.TextView.__init__(self)
        self.connect('key-press-event', self.on_key_press_event)

        if check_gtk3():
            targets = [gtk.TargetEntry.new('emesene-invite', 0, 3)]
        else:
            targets = [('emesene-invite', 0, 3)]

        self.drag_dest_set(0, targets, gtk.gdk.ACTION_DEFAULT)
Beispiel #16
0
    def _on_status_change_succeed(self, stat):
        """
        change the icon in the tray according to user's state
        """
        if stat not in status.ALL or stat == -1:
            return

        if check_gtk3():
            self.unread_icon = self._get_numerable_icon_for_status(stat)
            self._update_numerable_icon(self.count)
        else:
            self.set_from_file(self.handler.theme.image_theme.status_icons_panel[stat])
Beispiel #17
0
    def _on_message_read(self, conv):
        """
        Stop tray blinking and resets the newest unread message reference
        """
        if check_gtk3():
            #XXX: we go back to 0 because we receive only one message read event
            if self.unread_count != 0:
                self.unread_count = 0
            self._update_numerable_icon(self.unread_count)
        else:
            self.set_blinking(False)

        self.last_new_message = None
Beispiel #18
0
    def set_from_file(self, filename, blocked=False):
        self.filename = filename
        self.blocked  = blocked
        if not gui.gtkui.utils.file_readable(filename):
            if self._dimension > 32:
                # use big fallback image
                self.filename = gui.theme.image_theme.user_def_imagetool
            else:
                self.filename = gui.theme.image_theme.user

        try:
            animation = gtk.gdk.PixbufAnimation(self.filename)
        except gobject.GError:
            animation = gtk.gdk.PixbufAnimation(gui.theme.image_theme.user)

        if animation.is_static_image() or self.blocked:
            static_image = animation.get_static_image()
            static_image = static_image.scale_simple(self._dimension,
                                                    self._dimension,
                                                    gtk.gdk.INTERP_BILINEAR)
        else:
            animation = utils.simple_animation_scale(self.filename,
                                                self._dimension,
                                                self._dimension)
            static_image = animation.get_static_image()

        if self.blocked:
            if self._dimension > 32:
                # use big fallback image
                pixbufblock = utils.gtk_pixbuf_load(gui.theme.image_theme.blocked_overlay_big,
                                                    (int(self._dimension * 0.5),
                                                     int(self._dimension * 0.5)))
            else:
                pixbufblock = utils.gtk_pixbuf_load(gui.theme.image_theme.blocked_overlay)

            output_pixbuf = utils.simple_images_overlap(static_image, pixbufblock,
                                                        -pixbufblock.props.width,
                                                        -pixbufblock.props.width)

            self.__set_from_pixbuf(output_pixbuf)
            self.current_animation = None
            return
        #FIXME: animations are broken on gtk3, use static pixbuf for now
        elif animation.is_static_image() or check_gtk3():
            self.__set_from_pixbuf(static_image)
            self.current_animation = None
            return

        self.current_animation = animation
        self._start_animation(animation)
Beispiel #19
0
    def _on_conv_message(self, cid, account, msgobj, cedict=None):
        """
        Blink tray icon and save newest unread message
        """

        conv_manager = self.handler.session.get_conversation_manager(cid, [account])

        if conv_manager and not conv_manager.is_active():
            if check_gtk3():
                self.unread_count += 1
                self._update_numerable_icon(self.unread_count)
            else:
                self.set_blinking(True)
            self.last_new_message = cid
Beispiel #20
0
    def __init__(self, main_transfer_bar, transfer):
        gtk.HBox.__init__(self)

        self.handler = gui.base.FileTransferHandler(main_transfer_bar.session, transfer)

        self.main_transfer_bar = main_transfer_bar
        self.transfer = transfer
        
        self.event_box = gtk.EventBox()
        self.progress = gtk.ProgressBar()
        if check_gtk3():
            self.progress.set_show_text(True)
            self.progress.set_text("")
        self.progress.set_ellipsize(pango.ELLIPSIZE_END)
        self.progress.add_events(gtk.gdk.BUTTON_PRESS_MASK)
        self.progress.connect('button-press-event', self._on_dbl_click_transfer)

        self.menu = gtk.Menu()

        img_file = gtk.image_new_from_stock(gtk.STOCK_FILE, \
                                        gtk.ICON_SIZE_BUTTON)
        img_dir = gtk.image_new_from_stock(gtk.STOCK_OPEN, \
                                        gtk.ICON_SIZE_BUTTON)

        m_open_file = gtk.ImageMenuItem(_('Open file'))
        m_open_file.connect('activate', self._on_menu_file_clicked)
        m_open_file.set_image(img_file)

        m_open_dir = gtk.ImageMenuItem(_('Open folder'))
        m_open_dir.connect('activate', self._on_menu_folder_clicked)
        m_open_dir.set_image(img_dir)

        self.menu.add(m_open_file)
        self.menu.add(m_open_dir)

        self.event_box.add(self.progress)
        self.pack_start(self.event_box, False, False)

        self.buttons = []
        self.show_all()
        self.tooltip = FileTransferTooltip(self.event_box, self.transfer)

        self.notifier = extension.get_default('notificationGUI')

        self.event_box.connect('event', self._on_progressbar_event)

        self.do_update_progress()
        self.on_transfer_state_changed()
Beispiel #21
0
    def _create_indicator(self,
                          subtype,
                          sender,
                          body,
                          extra_text='',
                          icid=None):
        """
        This creates a new indicator item, called by on_message, online & offline.
        """
        if indicate:
            ind = indicate.Indicator()

            #Get user icon.
            if hasattr(ind, 'set_property_icon'):
                contact = self.handler.session.contacts.safe_get(body)
                pixbuf = utils.safe_gtk_pixbuf_load(contact.picture or '',
                                                    (48, 48))
                if pixbuf is not None:
                    ind.set_property_icon("icon", pixbuf)

            ind.set_property("subtype", subtype)
            ind.set_property("sender", sender + extra_text)
            if icid is not None:
                ind.set_property("body", str(icid))
            else:
                ind.set_property("body", body)
            if check_gtk3():
                ind.set_property_time("time", GLib.TimeVal())
            else:
                ind.set_property_time("time", time.time())
            ind.set_property("draw-attention", "true")
            ind.connect("user-display", self._display)
            ind.show()

            # Add indicator to the dictionary
            if subtype == "im":
                self.indicator_dict[ind] = icid
                self.r_indicator_dict[icid] = ind

            for old_icid in self.indicator_dict.values():
                if old_icid not in self.handler.session.conversations.keys():
                    # workaround: kill the orphan indicator
                    ind = self.r_indicator_dict[old_icid]
                    del self.indicator_dict[ind]
                    del self.r_indicator_dict[old_icid]
        else:
            return
Beispiel #22
0
    def __init__(self):
        ''' init the class with some default vals '''
        gtk.Window.__init__(self, gtk.WINDOW_POPUP)

        self.set_name('gtk-tooltips')
        self.set_position(gtk.WIN_POS_MOUSE)
        self.set_resizable(False)
        self.set_border_width(4)
        self.set_app_paintable(True)

        if not check_gtk3():
            self.connect('expose-event', self.on_expose_event)
        else:
            context = self.get_style_context()
            gtk.StyleContext.add_class (context, "tooltip");

        self.label = gtk.Label('')
        self.label.set_line_wrap(True)
        self.label.set_alignment(0, 0.5)
        self.label.set_use_markup(True)
        self.label.show()

        Avatar = extension.get_default('avatar')
        self.image = Avatar(cell_dimension=96, crossfade = False, cell_radius = 0)
        self.data_string = '<span size="small">(%s)\n\n'
        self.data_string += _('Status') + ': %s\n'
        self.data_string += _('Blocked')+ ': %s\n'
        #self.data_string += _('Has you: %s')+ '\n'
        self.data_string += '</span>'
        
        self.yes_no = {True : _('Yes'), False : _('No')}
        
        hbox = gtk.HBox(spacing=6)
        vbox = gtk.VBox()
        hbox.pack_start(self.image)
        hbox.pack_start(vbox)
        vbox.pack_start(self.label)
        hbox.show_all()
        self.add(hbox)

        self.connect('delete-event', self.reset)

        self.tag = None
        self.path_array = None
Beispiel #23
0
    def __init__(self):
        ''' init the class with some default vals '''
        gtk.Window.__init__(self, gtk.WINDOW_POPUP)

        self.set_name('gtk-tooltips')
        self.set_position(gtk.WIN_POS_MOUSE)
        self.set_resizable(False)
        self.set_border_width(4)
        self.set_app_paintable(True)

        if not check_gtk3():
            self.connect('expose-event', self.on_expose_event)
        else:
            context = self.get_style_context()
            gtk.StyleContext.add_class(context, "tooltip")

        self.label = gtk.Label('')
        self.label.set_line_wrap(True)
        self.label.set_alignment(0, 0.5)
        self.label.set_use_markup(True)
        self.label.show()

        Avatar = extension.get_default('avatar')
        self.image = Avatar(cell_dimension=96, crossfade=False, cell_radius=0)
        self.data_string = '<span size="small">(%s)\n\n'
        self.data_string += _('Status') + ': %s\n'
        self.data_string += _('Blocked') + ': %s\n'
        #self.data_string += _('Has you: %s')+ '\n'
        self.data_string += '</span>'

        self.yes_no = {True: _('Yes'), False: _('No')}

        hbox = gtk.HBox(spacing=6)
        vbox = gtk.VBox()
        hbox.pack_start(self.image)
        hbox.pack_start(vbox)
        vbox.pack_start(self.label)
        hbox.show_all()
        self.add(hbox)

        self.connect('delete-event', self.reset)

        self.tag = None
        self.path_array = None
Beispiel #24
0
    def _create_indicator(self, subtype, sender, body,
                          extra_text = '', icid=None):
        """
        This creates a new indicator item, called by on_message, online & offline.
        """
        if indicate:
            ind = indicate.Indicator()
    
            #Get user icon.
            if hasattr(ind, 'set_property_icon'):
                contact = self.handler.session.contacts.safe_get(body)
                pixbuf = utils.safe_gtk_pixbuf_load(contact.picture or '', (48, 48))
                if pixbuf is not None:
                    ind.set_property_icon("icon", pixbuf)

            ind.set_property("subtype", subtype)
            ind.set_property("sender", sender + extra_text)
            if icid is not None:
                ind.set_property("body", str(icid))
            else:
                ind.set_property("body", body)
            if check_gtk3():
                ind.set_property_time("time", GLib.TimeVal())
            else:
                ind.set_property_time("time", time.time())
            ind.set_property("draw-attention", "true")
            ind.connect("user-display", self._display)
            ind.show()

            # Add indicator to the dictionary
            if subtype == "im":
                self.indicator_dict[ind] = icid
                self.r_indicator_dict[icid] = ind

            for old_icid in self.indicator_dict.values():
                if old_icid not in self.handler.session.conversations.keys():
                    # workaround: kill the orphan indicator
                    ind = self.r_indicator_dict[old_icid]
                    del self.indicator_dict[ind]
                    del self.r_indicator_dict[old_icid]
        else:
            return
Beispiel #25
0
    def _on_activate(self, trayicon):
        """
        callback called when the status icon is activated
        (includes clicking the icon)
        """
        if check_gtk3():
            unread = self.unread_count != 0
        else:
            unread = self.get_blinking()

        if self.last_new_message is not None and unread:
            # show the tab with the latest message
            cid = self.last_new_message
            conv_manager = self.handler.session.get_conversation_manager(cid)

            if conv_manager:
                conversation = conv_manager.has_similar_conversation(cid)
                conv_manager.present(conversation)
        else:
            self.handler.on_hide_show_mainwindow(self.main_window)
Beispiel #26
0
    def __init__(self, label, path_list, on_remove_cb, on_accept_cb,
                 iconv_type, on_drag_data_accepted):
        gtk.HBox.__init__(self)
        self.set_spacing(4)

        self.on_remove_cb = on_remove_cb
        self.on_accept_cb = on_accept_cb
        self.on_drag_data_accepted = on_drag_data_accepted
        self.iconv_type = iconv_type

        self.model = gtk.ListStore(gtk.gdk.Pixbuf, str)
        self.iconview = gtk.IconView(self.model)

        if not check_gtk3():
            target = ('text/uri-list', 0, 0)
        else:
            #FIXME: this is not working in gtk3
            target = gtk.TargetEntry.new('text/uri-list', 0, 0)

        self.iconview.enable_model_drag_dest([target], gtk.gdk.ACTION_DEFAULT
                                             | gtk.gdk.ACTION_COPY)
        self.iconview.connect("drag-data-received", self._drag_data_received)
        self.iconview.set_pixbuf_column(0)
        self.iconview.connect("item-activated", self._on_icon_activated)
        self.iconview.connect("button_press_event", self.pop_up)

        self.label = gtk.Label(label)

        self.scroll = gtk.ScrolledWindow()
        self.scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        self.scroll.set_shadow_type(gtk.SHADOW_IN)
        self.scroll.add(self.iconview)
        self.pack_start(self.scroll, True, True)

        self.stop = False
        # Start a new thread to fill the iconview with images from path_list
        thread.start_new_thread(self.fill, (path_list, ))
Beispiel #27
0
#    along with emesene; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import sys
import gtk
import gobject
import extension

import utils

from gui.gtkui import check_gtk3

CLOSE_ON_LEFT = 0

#FIXME: find correct GSettings value and replace this in gtk3
if not check_gtk3():
    try:
        import gconf
        gclient = gconf.client_get_default()
        val = gclient.get("/apps/metacity/general/button_layout")
        if val.get_string().startswith("close"):
            CLOSE_ON_LEFT = 1
    except:
        pass

if sys.platform == 'darwin':
    CLOSE_ON_LEFT = 1

class TabWidget(gtk.HBox):
    '''a widget that is placed on the tab on a notebook'''
    NAME = 'Tab Widget'
Beispiel #28
0
 def check_visible(self):
     if not check_gtk3():
         return self.flags() & gtk.VISIBLE
     else:
         return self.get_visible()
Beispiel #29
0
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with emesene; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import gtk
import gobject
import logging
log = logging.getLogger('gtkui.AdiumTextBox')

#check for webkit gi package
from gui.gtkui import check_gtk3
try:
    if check_gtk3():
        import gi.pygtkcompat
        gi.pygtkcompat.enable_webkit(version='3.0')
except ValueError:
    raise ImportError

import webkit
import base64
import xml.sax.saxutils

import e3
import gui
from gui.base import Plus
import utils
import Queue
Beispiel #30
0
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import os
import time
import gui.gtkui.utils as utils
import e3

from gui.gtkui import check_gtk3

def enable_indicate():
	import sys
	from gi.repository import Indicate
	sys.modules['indicate'] = Indicate
	Indicate.indicate_server_ref_default = Indicate.Server.ref_default

if check_gtk3():
	enable_indicate()

import indicate
import gui

class MessagingMenu(gui.BaseTray):
    """
    A widget that implements the messaging menu for ubuntu
    """
    NAME = 'Messaging Menu'
    DESCRIPTION = 'The Ayatana Messaging Menu extension'
    AUTHOR = 'Cando, Tom Cowell'
    WEBSITE = 'www.emesene.org'

    def __init__ (self, handler, main_window=None):
Beispiel #31
0
class Avatar(gtk.Widget, AvatarManager):
    """AvatarWidget """

    __gproperties__ = {
        'dimension':
        (gobject.TYPE_FLOAT, 'cell dimensions', 'height width of cell', 0.0,
         128.0, 32.0, gobject.PARAM_READWRITE),
        'radius-factor': (gobject.TYPE_FLOAT, 'radius of pixbuf',
                          '0.0 to 0.5 with 0.1 = 10% of dimension', 0.0, 0.5,
                          0.11, gobject.PARAM_READWRITE),
        'pixbuf':
        (gtk.gdk.Pixbuf, 'Pixbuf', 'normal pixbuf', gobject.PARAM_READWRITE),
        'pixbuf-animation': (gtk.gdk.Pixbuf, 'Pixbuf', 'pixbuf from animation',
                             gobject.PARAM_READWRITE),
        'crossfade': (bool, 'animate by crossfade if true', '', True,
                      gobject.PARAM_READWRITE)
    }

    if not check_gtk3():
        __gsignals__ = {'size_request': 'override', 'expose-event': 'override'}

    def __init__(self, cell_dimension=96, crossfade=True, cell_radius=0.05):
        gtk.Widget.__init__(self)
        AvatarManager.__init__(self, cell_dimension, cell_radius, crossfade)
        if not check_gtk3():
            self.set_flags(self.flags() | gtk.NO_WINDOW)
        else:
            gtk.Widget.set_has_window(self, False)

        self.blocked = False

    def animate_callback(self):
        if self.current_frame > self.total_frames:
            self.in_animation = False
            self._pixbuf = self.transition_pixbuf

            if self.current_animation:
                self._start_animation(self.current_animation)
            return False
        else:

            if self.anim_source is not None:
                gobject.source_remove(self.anim_source)
                self.anim_source = None
            self.current_frame += 1
            self.queue_draw()
            return True

    def __set_from_pixbuf(self, pixbuf):
        self.set_property('pixbuf', pixbuf)
        self.queue_draw()

    def __set_from_pixbuf_animation(self, pixbuf):
        self.set_property('pixbuf-animation', pixbuf)
        self.queue_draw()

    #
    #public methods
    #
    def set_from_file(self, filename, blocked=False):
        self.filename = filename
        self.blocked = blocked
        if not gui.gtkui.utils.file_readable(filename):
            if self._dimension > 32:
                # use big fallback image
                self.filename = gui.theme.image_theme.user_def_imagetool
            else:
                self.filename = gui.theme.image_theme.user

        try:
            animation = gtk.gdk.PixbufAnimation(self.filename)
        except gobject.GError:
            animation = gtk.gdk.PixbufAnimation(gui.theme.image_theme.user)

        if animation.is_static_image() or self.blocked:
            static_image = animation.get_static_image()
            static_image = static_image.scale_simple(self._dimension,
                                                     self._dimension,
                                                     gtk.gdk.INTERP_BILINEAR)
        else:
            animation = utils.simple_animation_scale(self.filename,
                                                     self._dimension,
                                                     self._dimension)
            static_image = animation.get_static_image()

        if self.blocked:
            if self._dimension > 32:
                # use big fallback image
                pixbufblock = utils.gtk_pixbuf_load(
                    gui.theme.image_theme.blocked_overlay_big,
                    (int(self._dimension * 0.5), int(self._dimension * 0.5)))
            else:
                pixbufblock = utils.gtk_pixbuf_load(
                    gui.theme.image_theme.blocked_overlay)

            output_pixbuf = utils.simple_images_overlap(
                static_image, pixbufblock, -pixbufblock.props.width,
                -pixbufblock.props.width)

            self.__set_from_pixbuf(output_pixbuf)
            self.current_animation = None
            return
        elif animation.is_static_image():
            self.__set_from_pixbuf(static_image)
            self.current_animation = None
            return

        self.current_animation = animation
        self._start_animation(animation)

    def set_from_image(self, image):
        if image.get_storage_type() == gtk.IMAGE_PIXBUF:
            self.__set_from_pixbuf(image.get_pixbuf())
            self.current_animation = None
            return
        elif image.get_storage_type() == gtk.IMAGE_ANIMATION:
            self.current_animation = image.get_animation()
            self._start_animation(image.get_animation())

    def set_from_pixbuf(self, pixbuf):
        if isinstance(pixbuf, gtk.gdk.Pixbuf):
            self.__set_from_pixbuf(pixbuf)
            self.current_animation = None
            return
        elif isinstance(pixbuf, gtk.gdk.PixbufAnimation):
            self.current_animation = pixbuf
            self._start_animation(pixbuf)

    def stop(self):
        '''stop the animation'''
        if self.anim_source is not None:
            gobject.source_remove(self.anim_source)
            self.anim_source = None

    #
    #end of public methods
    #

    if check_gtk3():

        def _start_animation(self, animation):
            #this is broken on some version of gtk3, use static pixbuf for those cases
            try:
                iteran = animation.get_iter(None)
            except TypeError:
                self.__set_from_pixbuf(animation.get_static_image())
                return

            #we don't need to resize here!
            self.__set_from_pixbuf(iteran.get_pixbuf())

            if self.anim_source is None:
                self.anim_source = gobject.timeout_add(iteran.get_delay_time(),
                                                       self._advance, iteran)

        def _advance(self, iteran):
            iteran.advance(None)
            self.__set_from_pixbuf_animation(iteran.get_pixbuf())
            self.anim_source = gobject.timeout_add(iteran.get_delay_time(),
                                                   self._advance, iteran)
            return False
    else:

        def _start_animation(self, animation):
            iteran = animation.get_iter()
            #we don't need to resize here!
            self.__set_from_pixbuf(iteran.get_pixbuf())

            if self.anim_source is None:
                self.anim_source = gobject.timeout_add(iteran.get_delay_time(),
                                                       self._advance, iteran)

        def _advance(self, iteran):
            iteran.advance()
            self.__set_from_pixbuf_animation(iteran.get_pixbuf())
            self.anim_source = gobject.timeout_add(iteran.get_delay_time(),
                                                   self._advance, iteran)
            return False

    def do_draw(self, ctx):
        if not self._pixbuf:
            return False

        cell_area = self.get_allocation()
        if not check_gtk3():
            cell_x, cell_y, cell_width, cell_height = cell_area
        else:
            cell_x = 0
            cell_y = 0

        if self.in_animation:
            self.draw_avatar(
                ctx, self._pixbuf, cell_x, cell_y, self._dimension,
                self._radius_factor,
                1 - (float(self.current_frame) / self.total_frames))
            self.draw_avatar(ctx, self.transition_pixbuf, cell_x, cell_y,
                             self._dimension, self._radius_factor,
                             (float(self.current_frame) / self.total_frames))
        else:
            self.draw_avatar(ctx, self._pixbuf, cell_x, cell_y,
                             self._dimension, self._radius_factor, 1)

        return False

    if not check_gtk3():

        def do_size_request(self, requisition):
            requisition.width = self._dimension
            requisition.height = self._dimension

        def do_expose_event(self, evnt):
            ctx = evnt.window.cairo_create()
            self.do_draw(ctx)
    else:

        def do_get_preferred_width(self):
            min_width = self._dimension
            natural_width = self._dimension
            return min_width, natural_width

        def do_get_preferred_height(self):
            min_height = self._dimension
            natural_height = self._dimension
            return min_height, natural_height
Beispiel #32
0
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with emesene; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import sys
import gtk
import gobject

import utils

from gui.gtkui import check_gtk3

if check_gtk3():
    import TinyButtonNew as TinyButton
else:
    import TinyButton

if check_gtk3():
    import RenderersNew as Renderers
else:
    import Renderers

CLOSE_ON_LEFT = 0

#FIXME: find correct GSettings value and replace this in gtk3
if not check_gtk3():
    try:
        import gconf
Beispiel #33
0
    def __init__(self, handler, config):
        """
        constructor

        handler -- e3common.Handler.OptionsHandler
        """
        gtk.Menu.__init__(self)
        self.handler = handler

        if not check_gtk3():
            self.by_status = gtk.RadioMenuItem(None, _('Order by _status'))
            self.by_group = gtk.RadioMenuItem(self.by_status,
                                              _('Order by _group'))
        else:
            self.by_status = gtk.RadioMenuItem(_('Order by _status'))
            self.by_status.set_use_underline(True)
            self.by_group = gtk.RadioMenuItem.new_with_mnemonic_from_widget(
                self.by_status, _('Order by _group'))
        self.by_group.set_active(config.b_order_by_group)
        self.by_status.set_active(not config.b_order_by_group)

        self.show_menu = gtk.MenuItem(_('Show...'))
        self.show_submenu = gtk.Menu()

        self.show_offline = gtk.CheckMenuItem(_('Show _offline contacts'))
        self.show_offline.set_active(config.b_show_offline)
        self.group_offline = gtk.CheckMenuItem(_('G_roup offline contacts'))
        self.group_offline.set_active(config.b_group_offline)
        self.show_empty_groups = gtk.CheckMenuItem(_('Show _empty groups'))
        self.show_empty_groups.set_active(config.b_show_empty_groups)
        self.show_blocked = gtk.CheckMenuItem(_('Show _blocked contacts'))
        self.show_blocked.set_active(config.b_show_blocked)
        self.order_by_name = gtk.CheckMenuItem(_('Sort by name'))
        self.order_by_name.set_active(config.b_order_by_name)

        self.preferences = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES)
        self.preferences.connect(
            'activate', lambda *args: self.handler.on_preferences_selected())

        self.by_status.connect(
            'toggled', lambda *args: self.handler.on_order_by_status_toggled(
                self.by_status.get_active()))
        self.by_group.connect(
            'toggled', lambda *args: self.handler.on_order_by_group_toggled(
                self.by_group.get_active()))
        self.show_empty_groups.connect(
            'toggled', lambda *args: self.handler.on_show_empty_groups_toggled(
                self.show_empty_groups.get_active()))
        self.show_offline.connect(
            'toggled', lambda *args: self.handler.on_show_offline_toggled(
                self.show_offline.get_active()))
        self.group_offline.connect(
            'toggled', lambda *args: self.handler.on_group_offline_toggled(
                self.group_offline.get_active()))
        self.show_blocked.connect(
            'toggled', lambda *args: self.handler.on_show_blocked_toggled(
                self.show_blocked.get_active()))
        self.order_by_name.connect(
            'toggled', lambda *args: self.handler.on_order_by_name_toggled(
                self.order_by_name.get_active()))

        self.show_menu.set_submenu(self.show_submenu)
        self.show_submenu.append(self.show_offline)

        self.append(self.by_status)
        self.append(self.by_group)
        self.append(gtk.SeparatorMenuItem())
        self.append(self.show_menu)
        self.show_submenu.append(self.show_empty_groups)
        self.show_submenu.append(self.show_blocked)
        self.show_submenu.append(self.order_by_name)
        self.append(self.group_offline)
        self.append(gtk.SeparatorMenuItem())
        self.append(self.preferences)
Beispiel #34
0
    def __init__(self, session, members):
        gtk.VBox.__init__(self)
        self.set_border_width(2)
        self.session = session
        self.members = members

        self._first = None
        self._last = None
        self._first_alig = gtk.Alignment(xalign=0.5, yalign=0.0, xscale=1.0,
            yscale=0.0)
        self._last_alig = None
        self._last_alig = gtk.Alignment(xalign=0.5, yalign=1.0, xscale=1.0,
            yscale=0.0)
        
        self.pack_start(self._first_alig)
        self.pack_end(self._last_alig)

        Avatar = extension.get_default('avatar')

        avatar_size = self.session.config.get_or_set('i_conv_avatar_size', 64)

        self.avatarBox = gtk.EventBox()
        self.avatarBox.set_events(gtk.gdk.BUTTON_PRESS_MASK)
        if self.session.session_has_service(e3.Session.SERVICE_PROFILE_PICTURE):
            self.avatarBox.connect('button-press-event', self._on_avatar_click)
            self.avatarBox.set_tooltip_text(_('Click here to set your avatar'))

        self.avatar = Avatar(cell_dimension=avatar_size)
        self.avatarBox.add(self.avatar)

        self.avatarBox.set_border_width(4)

        self.his_avatarBox = gtk.EventBox()
        self.his_avatarBox.set_events(gtk.gdk.BUTTON_PRESS_MASK)
        self.his_avatarBox.connect('button-press-event', self._on_his_avatar_click)

        self.his_avatar = Avatar(cell_dimension=avatar_size)
        self.his_avatarBox.add(self.his_avatar)

        self.his_avatarBox.set_tooltip_text(_('Click to see informations'))
        self.his_avatarBox.set_border_width(4)

        if check_gtk3():
            #In gtk3 eventbox renders background, so make it transparent
            prov = gtk.CssProvider()
            prov.load_from_data("* {\n"
                "background-color: transparent;\n"
                "}");

            context = self.his_avatarBox.get_style_context()
            context.add_provider(prov, 600) #GTK_STYLE_PROVIDER_PRIORITY_APPLICATION
            context.save()

            context = self.avatarBox.get_style_context()
            context.add_provider(prov, 600) #GTK_STYLE_PROVIDER_PRIORITY_APPLICATION
            context.save()

        last_avatar = self.session.config.last_avatar
        if self.session.config_dir.file_readable(last_avatar):
            my_picture = last_avatar
        else:
            my_picture = gui.theme.image_theme.user

        his_picture = gui.theme.image_theme.user
        if members is not None:
            account = members[0]
            contact = self.session.contacts.safe_get(account)

            if contact.picture:
                his_picture = contact.picture

        self.first = self.his_avatarBox
        self.his_avatar.set_from_file(his_picture)

        self.last = self.avatarBox
        self.avatar.set_from_file(my_picture)

        self.index = 0 # used for the rotate picture function
        self.timer = None

        if len(members) > 1:
            self.timer = glib.timeout_add_seconds(5, self.rotate_picture)
Beispiel #35
0
    def draw(self):
        '''draw the toolbar'''
        toolbar_small = self.handler.session.config.get_or_set(
                                                'b_toolbar_small',
                                                False)

        if toolbar_small:
            size = gtk.ICON_SIZE_MENU
        else:
            size = gtk.ICON_SIZE_LARGE_TOOLBAR

        if check_gtk3():
            context = self.get_style_context()
            gtk.StyleContext.add_class (context, "inline-toolbar")

        self.settings = self.get_settings()
        self.settings.set_long_property('gtk-toolbar-icon-size', size,
                                        'ConversationToolbar.py:37')

        # check if we have theme-specific toolbar-icons

        image_theme = gui.theme.image_theme
        if image_theme.has_custom_toolbar_icons():
            theme_tool_font = utils.gtk_ico_image_load(image_theme.tool_font, size)
            theme_tool_font_color = utils.gtk_ico_image_load(image_theme.tool_font_color, size)
            theme_tool_emotes = utils.gtk_ico_image_load(image_theme.tool_emotes, size)
            theme_tool_nudge = utils.gtk_ico_image_load(image_theme.tool_nudge, size)
            theme_tool_invite = utils.gtk_ico_image_load(image_theme.tool_invite, size)
            theme_tool_clean = utils.gtk_ico_image_load(image_theme.tool_clean, size)
            theme_tool_file_transfer = utils.gtk_ico_image_load(image_theme.tool_file_transfer, size)
            self.theme_tool_block = utils.gtk_ico_image_load(image_theme.tool_block, size)
            self.theme_tool_unblock = utils.gtk_ico_image_load(image_theme.tool_unblock, size)
        else:
            theme_tool_font = gtk.STOCK_SELECT_FONT
            theme_tool_font_color = gtk.STOCK_SELECT_COLOR

            emote_theme = gui.theme.emote_theme

            theme_tool_emotes = utils.gtk_ico_image_load(emote_theme.emote_to_path(':D', True), size)
            theme_tool_nudge = utils.gtk_ico_image_load(emote_theme.emote_to_path(':S', True), size)
            theme_tool_invite = gtk.STOCK_ADD
            theme_tool_clean = gtk.STOCK_CLEAR
            theme_tool_file_transfer = gtk.STOCK_GO_UP
            self.theme_tool_block = gtk.STOCK_STOP
            self.theme_tool_unblock = gtk.STOCK_YES

        if self.session.config.b_avatar_on_left == self.session.config.b_show_info:
            theme_tool_toggle_avatar = gtk.STOCK_GO_BACK
        else:
            theme_tool_toggle_avatar = gtk.STOCK_GO_FORWARD

        theme_tool_call = utils.gtk_ico_image_load(image_theme.call, size)
        theme_tool_video = utils.gtk_ico_image_load(image_theme.video, size)
        theme_tool_av = utils.gtk_ico_image_load(image_theme.av, size)

        self.font = gtk.ToolButton(theme_tool_font)
        self.font.set_label(_('Select font'))
        self.font.set_tooltip_text(_('Select font'))
        self.font.connect('clicked',
            lambda *args: self.handler.on_font_selected())

        self.color = gtk.ToolButton(theme_tool_font_color)
        self.color.set_label(_('Select font color'))
        self.color.set_tooltip_text(_('Select font color'))
        self.color.connect('clicked',
            lambda *args: self.handler.on_color_selected())

        self.emotes = gtk.ToolButton()
        self.emotes.set_icon_widget(theme_tool_emotes)
        self.emotes.set_label(_('Send an emoticon'))
        self.emotes.set_tooltip_text(_('Send an emoticon'))
        self.emotes.connect('clicked',
            lambda *args: self.handler.on_emotes_selected())

        self.nudge = gtk.ToolButton()
        self.nudge.set_icon_widget(theme_tool_nudge)
        self.nudge.set_label(_('Request attention'))
        self.nudge.set_tooltip_text(_('Request attention'))
        self.nudge.connect('clicked',
            lambda *args: self.handler.on_notify_attention_selected())

        self.invite = gtk.ToolButton(theme_tool_invite)
        self.invite.set_label(_('Invite a buddy'))
        self.invite.set_tooltip_text(_('Invite a buddy'))
        self.invite.connect('clicked',
            lambda *args: self.handler.on_invite_selected())

        self.clean = gtk.ToolButton(theme_tool_clean)
        self.clean.set_label(_('Clean the conversation'))
        self.clean.set_tooltip_text(_('Clean the conversation'))
        self.clean.connect('clicked',
            lambda *args: self.handler.on_clean_selected())

        self.invite_file_transfer = gtk.ToolButton(theme_tool_file_transfer)
        self.invite_file_transfer.set_label(_('Send a file'))
        self.invite_file_transfer.set_tooltip_text(_('Send a file'))
        self.invite_file_transfer.connect('clicked',
            lambda *args: self.handler.on_invite_file_transfer_selected())

        self.ublock = gtk.ToolButton(self.theme_tool_block)
        self.ublock.set_label(_('Block/Unblock contact'))
        self.ublock.set_tooltip_text(_('Block/Unblock contact'))
        self.ublock.connect('clicked',
            lambda *args: self.handler.on_ublock_selected())

        self.toggle_avatar = gtk.ToolButton(theme_tool_toggle_avatar)
        self.toggle_avatar.set_label(_('Hide/Show avatar'))
        if self.handler.session.config.b_show_info:
            self.toggle_avatar.set_tooltip_text(_('Hide avatar'))
        else:
            self.toggle_avatar.set_tooltip_text(_('Show avatar'))
        self.toggle_avatar.connect('clicked',
            lambda *args: self.handler.on_toggle_avatar_selected())

        self.invite_video_call = gtk.ToolButton(theme_tool_video)
        self.invite_video_call.set_label(_('Video Call'))
        self.invite_video_call.set_tooltip_text(_('Video Call'))
        self.invite_video_call.connect('clicked',
            lambda *args: self.handler.on_invite_video_call_selected())

        self.invite_audio_call = gtk.ToolButton(theme_tool_call)
        self.invite_audio_call.set_label(_('Voice Call'))
        self.invite_audio_call.set_tooltip_text(_('Voice Call'))
        self.invite_audio_call.connect('clicked',
            lambda *args: self.handler.on_invite_voice_call_selected())

        self.invite_av_call = gtk.ToolButton(theme_tool_av)
        self.invite_av_call.set_label(_('Audio/Video Call'))
        self.invite_av_call.set_tooltip_text(_('Audio/Video Call'))
        self.invite_av_call.connect('clicked',
            lambda *args: self.handler.on_invite_av_call_selected())

        self.add(self.font)
        self.add(self.color)
        self.add(gtk.SeparatorToolItem())

        self.add(self.emotes)
        self.add(self.nudge)

        if self.handler.session_service_supported(e3.Session.SERVICE_CONTACT_INVITE):
            self.add(gtk.SeparatorToolItem())
            self.add(self.invite)
        if self.handler.session_service_supported(e3.Session.SERVICE_FILETRANSFER):
            self.add(self.invite_file_transfer)
        self.add(gtk.SeparatorToolItem())

        if self.handler.session_service_supported(e3.Session.SERVICE_CALLS):
            self.add(self.invite_video_call)
            self.add(self.invite_audio_call)
            self.add(self.invite_av_call)
            self.add(gtk.SeparatorToolItem())

        self.add(self.clean)
        if self.handler.session_service_supported(e3.Session.SERVICE_CONTACT_BLOCK):
            self.add(self.ublock)
        self.add(gtk.SeparatorToolItem())
        self.add(self.toggle_avatar)
Beispiel #36
0
    def __init__(self, session, cid, update_win, tab_label, members=None):
        '''constructor'''
        gtk.VBox.__init__(self)
        gui.Conversation.__init__(self, session, cid, update_win, members)
        self.set_border_width(2)

        self.typing_timeout = None
        self.tab_label = tab_label

        self._header_visible = session.config.b_show_header
        self._image_visible = session.config.b_show_info
        self._toolbar_visible = session.config.b_show_toolbar

        self.panel = gtk.VPaned()

        self.show_avatar_in_taskbar = self.session.config.get_or_set(
                                                    'b_show_avatar_in_taskbar',
                                                    True)

        Header = extension.get_default('conversation header')
        OutputText = extension.get_default('conversation output')
        InputText = extension.get_default('conversation input')
        ContactInfo = extension.get_default('conversation info')
        ConversationToolbar = extension.get_default(
            'conversation toolbar')
        TransfersBar = extension.get_default('filetransfer pool')
        CallWidget = extension.get_default('call widget')

        self.below_conversation = None
        BelowConversation = extension.get_default('below conversation')
        if BelowConversation is not None:
            self.below_conversation = BelowConversation(self, session)

        self.header = Header(session, members)
        toolbar_handler = gui.base.ConversationToolbarHandler(self.session,
            gui.theme, self)
        self.toolbar = ConversationToolbar(toolbar_handler, self.session)
        self.toolbar.set_property('can-focus', False)
        outputview_handler = gui.base.OutputViewHandler(self)
        self.output = OutputText(self.session.config, outputview_handler)
        if self.session.conversation_start_locked:
            self.output.lock()

        self.output.set_size_request(-1, 30)
        self.input = InputText(self.session, self._on_send_message,
                               self.cycle_history, self.on_drag_data_received,
                               self._send_typing_notification)
        self.output.set_size_request(-1, 25)
        self.input.set_size_request(-1, 25)
        self.info = ContactInfo(self.session, self.members)
        self.transfers_bar = TransfersBar(self.session)
        self.call_widget = CallWidget(self.session)

        frame_input = gtk.Frame()
        frame_input.set_shadow_type(gtk.SHADOW_IN)

        input_box = gtk.VBox()
        input_box.pack_start(self.toolbar, False)
        input_box.pack_start(self.input, True, True)

        frame_input.add(input_box)

        self.panel.pack1(self.output, True, False)
        self.panel.pack2(frame_input, False, False)

        if not check_gtk3():
            self.panel_signal_id = self.panel.connect_after('expose-event',
                    self.update_panel_position)
        else:
            self.panel_signal_id = self.panel.connect_after('draw',
                    self.update_panel_position)
        self.panel.connect('button-release-event', self.on_input_panel_resize)

        self.hbox = gtk.HBox()
        if self.session.config.get_or_set('b_avatar_on_left', False):
            self.hbox.pack_start(self.info, False)
            self.hbox.pack_start(self.panel, True, True)
        else:
            self.hbox.pack_start(self.panel, True, True)
            self.hbox.pack_start(self.info, False)

        self.pack_start(self.header, False)
        self.pack_start(self.hbox, True, True)
        self.pack_start(self.transfers_bar, False)
        if self.below_conversation is not None:
            self.pack_start(self.below_conversation, False)

        if len(self.members) == 0:
            self.header.information = ('connecting', 'creating conversation')
        else:
            #update adium theme header/footer
            account = self.members[0]
            contact = self.session.contacts.safe_get(account)
            his_picture = contact.picture or utils.path_to_url(os.path.abspath(gui.theme.image_theme.user))
            nick = contact.nick
            display_name = contact.display_name
            self.set_sensitive(not contact.blocked, True)
            my_picture = self.session.contacts.me.picture or utils.path_to_url(os.path.abspath(gui.theme.image_theme.user))
            self.output.clear(account, nick, display_name, 
                              my_picture, his_picture)

        self._load_style()
        self.subscribe_signals()
        extension.subscribe(self.on_below_conversation_changed, 'below conversation')
        extension.subscribe(self.on_conversation_info_extension_changed, 'conversation info')

        self.tab_index = -1 # used to select an existing conversation
Beispiel #37
0
 def count_changed(self, count):
     '''method called when unread message count changes'''
     if check_gtk3():
         self._update_numerable_icon(count)
     else:
         self.set_blinking((count != 0))
Beispiel #38
0
    def __init__(self, handler, config):
        """
        constructor

        handler -- e3common.Handler.OptionsHandler
        """
        gtk.Menu.__init__(self)

        if not check_gtk3():
            self.by_status = gtk.RadioMenuItem(None, _('Order by _status'))
            self.by_group = gtk.RadioMenuItem(self.by_status, _('Order by _group'))
        else:
            self.by_status = gtk.RadioMenuItem(_('Order by _status'))
            self.by_status.set_use_underline(True)
            self.by_group = gtk.RadioMenuItem.new_with_mnemonic_from_widget(self.by_status, _('Order by _group'))
        self.by_group.set_active(config.b_order_by_group)
        self.by_status.set_active(not config.b_order_by_group)

        show_menu = gtk.MenuItem(_('Show...'))
        show_submenu = gtk.Menu()

        self.show_offline = gtk.CheckMenuItem(_('Show _offline contacts'))
        self.show_offline.set_active(config.b_show_offline)
        self.group_offline = gtk.CheckMenuItem(_('G_roup offline contacts'))
        self.group_offline.set_active(config.b_group_offline)
        self.show_empty_groups = gtk.CheckMenuItem(_('Show _empty groups'))
        self.show_empty_groups.set_active(config.b_show_empty_groups)
        self.show_blocked = gtk.CheckMenuItem(_('Show _blocked contacts'))
        self.show_blocked.set_active(config.b_show_blocked)
        self.sort_by_name = gtk.CheckMenuItem(_('Sort contacts by _name'))
        self.sort_by_name.set_active(config.b_order_by_name)

        preferences = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES)
        preferences.connect('activate',
            lambda *args: handler.on_preferences_selected())

        self.by_status.connect('toggled',
            lambda *args: handler.on_order_by_status_toggled(
                self.by_status.get_active()))
        self.by_group.connect('toggled',
            lambda *args: handler.on_order_by_group_toggled(
                self.by_group.get_active()))
        self.show_empty_groups.connect('toggled',
            lambda *args: handler.on_show_empty_groups_toggled(
                self.show_empty_groups.get_active()))
        self.show_offline.connect('toggled',
            lambda *args: handler.on_show_offline_toggled(
                self.show_offline.get_active()))
        self.group_offline.connect('toggled',
            lambda *args: handler.on_group_offline_toggled(
                self.group_offline.get_active()))
        self.show_blocked.connect('toggled',
            lambda *args: handler.on_show_blocked_toggled(
                self.show_blocked.get_active()))
        self.sort_by_name.connect('toggled',
            lambda *args: handler.on_order_by_name_toggled(
                self.sort_by_name.get_active()))

        show_menu.set_submenu(show_submenu)
        show_submenu.append(self.show_offline)
        show_submenu.append(self.show_blocked)
        show_submenu.append(self.show_empty_groups)

        self.append(self.by_status)
        self.append(self.by_group)
        self.append(gtk.SeparatorMenuItem())
        self.append(show_menu)
        self.append(self.sort_by_name)
        self.append(self.group_offline)
        self.append(gtk.SeparatorMenuItem())
        self.append(preferences)
Beispiel #39
0
    def __init__(self, session, members):
        gtk.VBox.__init__(self)
        self.set_border_width(2)
        self.session = session
        self.members = members

        self._first = None
        self._last = None
        self._first_alig = gtk.Alignment(xalign=0.5,
                                         yalign=0.0,
                                         xscale=1.0,
                                         yscale=0.0)
        self._last_alig = None
        self._last_alig = gtk.Alignment(xalign=0.5,
                                        yalign=1.0,
                                        xscale=1.0,
                                        yscale=0.0)

        self.pack_start(self._first_alig)
        self.pack_end(self._last_alig)

        Avatar = extension.get_default('avatar')
        avatar_size = self.session.config.get_or_set('i_conv_avatar_size', 64)

        self.avatarBox = gtk.EventBox()
        self.avatarBox.set_events(gtk.gdk.BUTTON_PRESS_MASK)
        if self.session.session_has_service(
                e3.Session.SERVICE_PROFILE_PICTURE):
            self.avatarBox.connect('button-press-event', self._on_avatar_click)
            self.avatarBox.set_tooltip_text(_('Click here to set your avatar'))

        self.avatar = Avatar(cell_dimension=avatar_size)
        self.avatarBox.add(self.avatar)

        self.avatarBox.set_border_width(4)

        self.his_avatarBox = gtk.EventBox()
        self.his_avatarBox.set_events(gtk.gdk.BUTTON_PRESS_MASK)
        self.his_avatarBox.connect('button-press-event',
                                   self._on_his_avatar_click)

        self.his_avatar = Avatar(cell_dimension=avatar_size)
        self.his_avatarBox.add(self.his_avatar)

        self.his_avatarBox.set_tooltip_text(_('Click to see informations'))
        self.his_avatarBox.set_border_width(4)

        if check_gtk3():
            #In gtk3 eventbox renders background, so make it transparent
            prov = gtk.CssProvider()
            prov.load_from_data("* {\n"
                                "background-color: transparent;\n"
                                "}")

            context = self.his_avatarBox.get_style_context()
            context.add_provider(prov,
                                 600)  #GTK_STYLE_PROVIDER_PRIORITY_APPLICATION
            context.save()

            context = self.avatarBox.get_style_context()
            context.add_provider(prov,
                                 600)  #GTK_STYLE_PROVIDER_PRIORITY_APPLICATION
            context.save()

        # Obtains his picture and details.
        contact = self.session.contacts.safe_get(None)
        if members is not None:
            account = members[0]
            contact = self.session.contacts.safe_get(account)

        self.first = self.his_avatarBox
        self.his_avatar.set_from_file(contact.picture, contact.blocked)
        self.last = self.avatarBox
        self.avatar.set_from_file(self.session.config.last_avatar)

        self.index = 0  # used for the rotate picture function
        self.timer = None

        if len(members) > 1:
            self.timer = glib.timeout_add_seconds(5, self.rotate_picture)