From 38406e39d60e253b60f6f82239baf747f20c952d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Sun, 24 Sep 2017 10:54:21 +0200 Subject: [PATCH] Remove BigAvatarWindow --- gajim/chat_control.py | 96 ------------------------------------------- gajim/dialogs.py | 40 ------------------ 2 files changed, 136 deletions(-) diff --git a/gajim/chat_control.py b/gajim/chat_control.py index 31bed9b40..a00f6b81b 100644 --- a/gajim/chat_control.py +++ b/gajim/chat_control.py @@ -184,11 +184,6 @@ class ChatControl(ChatControlBase): self._pep_images['location'] = self.xml.get_object('location_image') self.update_all_pep_types() - # keep timeout id and window obj for possible big avatar - # it is on enter-notify and leave-notify so no need to be - # per jid - self.show_bigger_avatar_timeout_id = None - self.bigger_avatar_window = None self.show_avatar() # Hook up signals @@ -199,13 +194,6 @@ class ChatControl(ChatControlBase): widget = self.xml.get_object('avatar_eventbox') widget.set_property('height-request', AvatarSize.CHAT) - id_ = widget.connect('enter-notify-event', - self.on_avatar_eventbox_enter_notify_event) - self.handlers[id_] = widget - - id_ = widget.connect('leave-notify-event', - self.on_avatar_eventbox_leave_notify_event) - self.handlers[id_] = widget id_ = widget.connect('button-press-event', self.on_avatar_eventbox_button_press_event) @@ -576,38 +564,6 @@ class ChatControl(ChatControlBase): # Save volume to config app.config.set('audio_output_volume', value) - def on_avatar_eventbox_enter_notify_event(self, widget, event): - """ - Enter the eventbox area so we under conditions add a timeout to show a - bigger avatar after 0.5 sec - """ - avatar_pixbuf = app.interface.get_avatar(self.account, self.contact.jid) - if avatar_pixbuf is None: - return - avatar_w = avatar_pixbuf.get_width() - avatar_h = avatar_pixbuf.get_height() - - scaled_buf = self.xml.get_object('avatar_image').get_pixbuf() - scaled_buf_w = scaled_buf.get_width() - scaled_buf_h = scaled_buf.get_height() - - # do we have something bigger to show? - if avatar_w > scaled_buf_w or avatar_h > scaled_buf_h: - # wait for 0.5 sec in case we leave earlier - if self.show_bigger_avatar_timeout_id is not None: - GLib.source_remove(self.show_bigger_avatar_timeout_id) - self.show_bigger_avatar_timeout_id = GLib.timeout_add(500, - self.show_bigger_avatar, widget, avatar_pixbuf) - - def on_avatar_eventbox_leave_notify_event(self, widget, event): - """ - Left the eventbox area that holds the avatar img - """ - # did we add a timeout? if yes remove it - if self.show_bigger_avatar_timeout_id is not None: - GLib.source_remove(self.show_bigger_avatar_timeout_id) - self.show_bigger_avatar_timeout_id = None - def on_avatar_eventbox_button_press_event(self, widget, event): """ If right-clicked, show popup @@ -1229,9 +1185,6 @@ class ChatControl(ChatControlBase): if self.session: self.session.control = None - # Remove bigger avatar window - if self.bigger_avatar_window: - self.bigger_avatar_window.destroy() # Clean events app.events.remove_events(self.account, self.get_full_jid(), types=['printed_' + self.type_id, self.type_id]) @@ -1315,15 +1268,6 @@ class ChatControl(ChatControlBase): return self.print_conversation(_('Pong! (%s s.)') % obj.seconds, 'status') - def set_control_active(self, state): - ChatControlBase.set_control_active(self, state) - # Hide bigger avatar window - if self.bigger_avatar_window: - self.bigger_avatar_window.destroy() - self.bigger_avatar_window = None - # Re-show the small avatar - self.show_avatar() - def show_avatar(self): if not app.config.get('show_avatar_in_chat'): return @@ -1502,46 +1446,6 @@ class ChatControl(ChatControlBase): elif typ == 'pm': control.remove_contact(nick) - def show_bigger_avatar(self, small_avatar, avatar_pixbuf): - """ - Resize the avatar, if needed, so it has at max half the screen size and - shows it - """ - # Hide the small avatar - image = self.xml.get_object('avatar_image') - image.hide() - - screen_w = Gdk.Screen.width() - screen_h = Gdk.Screen.height() - avatar_w = avatar_pixbuf.get_width() - avatar_h = avatar_pixbuf.get_height() - half_scr_w = screen_w / 2 - half_scr_h = screen_h / 2 - if avatar_w > half_scr_w: - avatar_w = half_scr_w - if avatar_h > half_scr_h: - avatar_h = half_scr_h - # we should make the cursor visible - # gtk+ doesn't make use of the motion notify on gtkwindow by default - # so this line adds that - - alloc = small_avatar.get_allocation() - # make the bigger avatar window show up centered - small_avatar_x, small_avatar_y = alloc.x, alloc.y - translated_coordinates = small_avatar.translate_coordinates( - app.interface.roster.window, 0, 0) - if translated_coordinates: - small_avatar_x, small_avatar_y = translated_coordinates - roster_x, roster_y = self.parent_win.window.get_window().get_origin()[1:] - center_x = roster_x + small_avatar_x + (alloc.width / 2) - center_y = roster_y + small_avatar_y + (alloc.height / 2) - pos_x, pos_y = center_x - (avatar_w / 2), center_y - (avatar_h / 2) - - dialogs.BigAvatarWindow(avatar_pixbuf, pos_x, pos_y, avatar_w, - avatar_h, self.show_avatar) - - self.show_bigger_avatar_timeout_id = None - def _on_send_file_menuitem_activate(self, widget): self._on_send_file() diff --git a/gajim/dialogs.py b/gajim/dialogs.py index cb9d12cad..ce48f6571 100644 --- a/gajim/dialogs.py +++ b/gajim/dialogs.py @@ -5198,43 +5198,3 @@ class SSLErrorDialog(ConfirmationDialogDoubleCheck): def on_cert_clicked(self, button): d = CertificatDialog(self, self.account, self.cert) - - -class BigAvatarWindow(Gtk.Window): - def __init__(self, avatar, pos_x, pos_y, width, height, callback): - super(BigAvatarWindow, self).__init__(type=Gtk.WindowType.POPUP) - self.set_events(Gdk.EventMask.POINTER_MOTION_MASK) - self.avatar = avatar - self.callback = callback - self.screen = self.get_screen() - self.visual = self.screen.get_rgba_visual() - if self.visual is not None and self.screen.is_composited(): - self.set_visual(self.visual) - self.set_app_paintable(True) - self.set_size_request(width, height) - self.move(pos_x, pos_y) - # we should hide the window - self.connect('leave_notify_event', self._on_window_avatar_leave_notify) - self.connect('motion-notify-event', self._on_window_motion_notify) - self.realize() - # make the cursor invisible so we can see the image - self.get_window().set_cursor( - Gdk.Cursor.new(Gdk.CursorType.BLANK_CURSOR)) - self.add(Gtk.Image.new_from_pixbuf(self.avatar)) - self.show_all() - - def _on_window_avatar_leave_notify(self, widget, event): - """ - Just left the popup window that holds avatar - """ - self.destroy() - self.bigger_avatar_window = None - # Re-show the small avatar - self.callback() - - def _on_window_motion_notify(self, widget, event): - """ - Just moved the mouse so show the cursor - """ - cursor = gtkgui_helpers.get_cursor('LEFT_PTR') - self.get_window().set_cursor(cursor)