Commit 45a200f7 authored by Philipp Hörist's avatar Philipp Hörist

Remove menu for saving avatar to harddisk

All avatars are available under ~/.cache/gajim/avatars
parent 9f59eb54
......@@ -142,13 +142,6 @@ class ChatControl(ChatControlBase):
self.show_avatar()
# Hook up signals
widget = self.xml.get_object('avatar_eventbox')
widget.set_property('height-request', AvatarSize.CHAT)
id_ = widget.connect('button-press-event',
self.on_avatar_eventbox_button_press_event)
self.handlers[id_] = widget
widget = self.xml.get_object('location_eventbox')
id_ = widget.connect('button-release-event',
self.on_location_eventbox_button_release_event)
......@@ -639,22 +632,6 @@ class ChatControl(ChatControlBase):
# Save volume to config
app.config.set('audio_output_volume', value)
def on_avatar_eventbox_button_press_event(self, widget, event):
"""
If right-clicked, show popup
"""
if event.button == 3: # right click
if self.TYPE_ID == message_control.TYPE_CHAT:
sha = app.contacts.get_avatar_sha(
self.account, self.contact.jid)
name = self.contact.get_shown_name()
else:
sha = self.gc_contact.avatar_sha
name = self.gc_contact.get_shown_name()
if sha is not None:
gui_menu_builder.show_save_as_menu(sha, name)
return True
def on_location_eventbox_button_release_event(self, widget, event):
if 'geoloc' in self.contact.pep:
location = self.contact.pep['geoloc'].data
......
......@@ -43,7 +43,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<signal name="button-press-event" handler="on_PHOTO_button_press_event" swapped="no"/>
<signal name="clicked" handler="_on_set_avatar_clicked" swapped="no"/>
<child>
<object class="GtkOverlay">
<property name="visible">True</property>
......@@ -108,7 +108,7 @@
<property name="halign">start</property>
<property name="valign">start</property>
<property name="use_underline">True</property>
<signal name="button-press-event" handler="on_PHOTO_button_press_event" swapped="no"/>
<signal name="clicked" handler="_on_set_avatar_clicked" swapped="no"/>
<child>
<object class="GtkBox">
<property name="visible">True</property>
......
......@@ -364,7 +364,6 @@
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="visible_window">False</property>
<signal name="button-press-event" handler="on_PHOTO_eventbox_button_press_event" swapped="no"/>
<child>
<object class="GtkImage" id="PHOTO_image">
<property name="can_focus">False</property>
......
......@@ -179,7 +179,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="visible_window">False</property>
<signal name="button-press-event" handler="on_PHOTO_eventbox_button_press_event" swapped="no"/>
<child>
<object class="GtkImage" id="PHOTO_image">
<property name="visible">True</property>
......
......@@ -144,12 +144,6 @@ class FileSaveDialog(NativeFileChooserDialog):
_action = Gtk.FileChooserAction.SAVE
class AvatarSaveDialog(FileSaveDialog):
if sys.platform == 'win32':
_filters = [Filter(_('Images'), '*.png;*.jpg;*.jpeg;*.svg', True)]
class NativeFileOpenDialog(BaseFileOpenDialog, NativeFileChooserDialog):
pass
......
......@@ -32,7 +32,6 @@ from gajim.common.const import AvatarSize
from gajim.common.helpers import event_filter
from gajim import gtkgui_helpers
from gajim.gui_menu_builder import show_save_as_menu
from gajim.gtk.dialogs import ErrorDialog
from gajim.gtk.dialogs import InformationDialog
......@@ -127,7 +126,7 @@ class ProfileWindow(Gtk.ApplicationWindow):
self.avatar_sha = None
self.avatar_mime_type = None
def on_set_avatar_button_clicked(self, widget):
def _on_set_avatar_clicked(self, _button):
def on_ok(path_to_file):
data, sha = app.interface.avatar_storage.prepare_for_publish(
path_to_file)
......@@ -153,20 +152,6 @@ class ProfileWindow(Gtk.ApplicationWindow):
AvatarChooserDialog(on_ok, transient_for=self)
def on_PHOTO_button_press_event(self, widget, event):
"""
If right-clicked, show popup
"""
if event.button == 3:
# right click
nick = app.config.get_per('accounts', self.account, 'name')
if self.avatar_sha is None:
return
show_save_as_menu(self.avatar_sha, nick)
elif event.button == 1: # left click
self.on_set_avatar_button_clicked(widget)
def on_BDAY_entry_focus_out_event(self, widget, event):
txt = widget.get_text()
if not txt:
......
......@@ -39,7 +39,6 @@ try:
except Exception:
pass
from gajim.common.i18n import _
from gajim.common import app
HAS_PYWIN32 = True
......@@ -148,70 +147,6 @@ def scale_pixbuf_from_data(data, size):
return scale_pixbuf(pixbuf, size)
def on_avatar_save_as_menuitem_activate(widget, avatar, default_name=''):
from gajim.gtk.dialogs import DialogButton
from gajim.gtk.dialogs import ErrorDialog
from gajim.gtk.dialogs import NewConfirmationDialog
from gajim.gtk.filechoosers import AvatarSaveDialog
def _on_save_avatar(file_path):
if os.path.exists(file_path):
# Check if we have write permissions
if not os.access(file_path, os.W_OK):
file_name = os.path.basename(file_path)
ErrorDialog(
_('Cannot overwrite existing file \'%s\'' % file_name),
_('A file with this name already exists and you do '
'not have permission to overwrite it.'))
return
app.config.set('last_save_dir', os.path.dirname(file_path))
if isinstance(avatar, str):
# We got a SHA
pixbuf = app.interface.avatar_storage.pixbuf_from_filename(avatar)
else:
# We got a pixbuf
pixbuf = avatar
extension = os.path.splitext(file_path)[1]
if not extension:
# Silently save as Jpeg image
image_format = 'png'
file_path += '.png'
else:
image_format = extension[1:] # remove leading dot
# Save image
try:
pixbuf.savev(file_path, image_format, [], [])
except Exception as error:
log.error('Error saving avatar: %s', error)
if os.path.exists(file_path):
os.remove(file_path)
new_file_path = '.'.join(file_path.split('.')[:-1]) + '.png'
def _on_ok(file_path, pixbuf):
pixbuf.savev(file_path, 'png', [], [])
NewConfirmationDialog(
_('Error While Saving'),
_('Extension not supported'),
_('Image cannot be saved in %(type)s format.\n'
'Save as %(new_filename)s?') % {
'type': image_format,
'new_filename': new_file_path},
[DialogButton.make('Cancel'),
DialogButton.make('OK',
text=_('_Save'),
callback=_on_ok,
args=[new_file_path,
pixbuf])]).show()
AvatarSaveDialog(_on_save_avatar,
path=app.config.get('last_save_dir'),
file_name='%s.png' % default_name,
transient_for=app.app.get_active_window())
def create_combobox(value_list, selected_value=None):
"""
Value_list is [(label1, value1)]
......
......@@ -509,18 +509,6 @@ def get_transport_menu(contact, account):
return menu
def show_save_as_menu(sha, name):
menu = Gtk.Menu()
menuitem = Gtk.MenuItem.new_with_mnemonic(_('Save _As'))
menuitem.connect(
'activate',
gtkgui_helpers.on_avatar_save_as_menuitem_activate, sha, name)
menu.append(menuitem)
menu.connect('selection-done', lambda w: w.destroy())
menu.show_all()
menu.popup_at_pointer()
def get_singlechat_menu(control_id, account, jid):
singlechat_menu = [
(_('Send File…'), [
......
......@@ -37,7 +37,6 @@ from nbxmpp.util import is_error_result
from nbxmpp.protocol import JID
from gajim import gtkgui_helpers
from gajim.gui_menu_builder import show_save_as_menu
from gajim.common import helpers
from gajim.common import app
from gajim.common import ged
......@@ -158,22 +157,6 @@ class VcardWindow:
def on_information_notebook_switch_page(self, widget, page, page_num):
GLib.idle_add(self.xml.get_object('close_button').grab_focus)
def on_PHOTO_eventbox_button_press_event(self, widget, event):
"""
If right-clicked, show popup
"""
if event.button == 3: # right click
if self.gc_contact:
sha = self.gc_contact.avatar_sha
name = self.gc_contact.get_shown_name()
else:
sha = app.contacts.get_avatar_sha(
self.account, self.contact.jid)
name = self.contact.get_shown_name()
if sha is None:
sha = self.avatar
show_save_as_menu(sha, name)
def set_value(self, entry_name, value):
try:
widget = self.xml.get_object(entry_name)
......@@ -499,14 +482,6 @@ class ZeroconfVcardWindow:
if event.keyval == Gdk.KEY_Escape:
self.window.destroy()
def on_PHOTO_eventbox_button_press_event(self, widget, event):
"""
If right-clicked, show popup
"""
if event.button == 3: # right click
show_save_as_menu(self.contact.avatar_sha,
self.contact.get_shown_name())
def set_value(self, entry_name, value):
try:
if value and entry_name == 'URL_label':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment