Refactor "Save as" menu
This commit is contained in:
parent
2c6b2e0bb4
commit
c08f752d89
4 changed files with 20 additions and 47 deletions
|
@ -568,8 +568,6 @@ class ChatControl(ChatControlBase):
|
||||||
If right-clicked, show popup
|
If right-clicked, show popup
|
||||||
"""
|
"""
|
||||||
if event.button == 3: # right click
|
if event.button == 3: # right click
|
||||||
menu = Gtk.Menu()
|
|
||||||
menuitem = Gtk.MenuItem.new_with_mnemonic(_('Save _As'))
|
|
||||||
if self.TYPE_ID == message_control.TYPE_CHAT:
|
if self.TYPE_ID == message_control.TYPE_CHAT:
|
||||||
sha = app.contacts.get_avatar_sha(
|
sha = app.contacts.get_avatar_sha(
|
||||||
self.account, self.contact.jid)
|
self.account, self.contact.jid)
|
||||||
|
@ -577,16 +575,7 @@ class ChatControl(ChatControlBase):
|
||||||
else:
|
else:
|
||||||
sha = self.gc_contact.avatar_sha
|
sha = self.gc_contact.avatar_sha
|
||||||
name = self.gc_contact.get_shown_name()
|
name = self.gc_contact.get_shown_name()
|
||||||
id_ = menuitem.connect('activate',
|
gui_menu_builder.show_save_as_menu(sha, name)
|
||||||
gtkgui_helpers.on_avatar_save_as_menuitem_activate, sha, name)
|
|
||||||
self.handlers[id_] = menuitem
|
|
||||||
menu.append(menuitem)
|
|
||||||
menu.show_all()
|
|
||||||
menu.connect('selection-done', lambda w: w.destroy())
|
|
||||||
# show the menu
|
|
||||||
menu.show_all()
|
|
||||||
menu.attach_to_widget(widget, None)
|
|
||||||
menu.popup(None, None, None, None, event.button, event.time)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def on_location_eventbox_button_release_event(self, widget, event):
|
def on_location_eventbox_button_release_event(self, widget, event):
|
||||||
|
|
|
@ -31,6 +31,7 @@ from gajim.common.i18n import _
|
||||||
from gajim.common.const import AvatarSize
|
from gajim.common.const import AvatarSize
|
||||||
|
|
||||||
from gajim import gtkgui_helpers
|
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 ErrorDialog
|
||||||
from gajim.gtk.dialogs import InformationDialog
|
from gajim.gtk.dialogs import InformationDialog
|
||||||
|
@ -154,25 +155,13 @@ class ProfileWindow(Gtk.ApplicationWindow):
|
||||||
"""
|
"""
|
||||||
If right-clicked, show popup
|
If right-clicked, show popup
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if event.button == 3:
|
if event.button == 3:
|
||||||
# right click
|
# right click
|
||||||
menu = Gtk.Menu()
|
|
||||||
|
|
||||||
nick = app.config.get_per('accounts', self.account, 'name')
|
nick = app.config.get_per('accounts', self.account, 'name')
|
||||||
if self.avatar_sha is None:
|
if self.avatar_sha is None:
|
||||||
return
|
return
|
||||||
menuitem = Gtk.MenuItem.new_with_mnemonic(_('Save _As'))
|
show_save_as_menu(self.avatar_sha, nick)
|
||||||
menuitem.connect(
|
|
||||||
'activate',
|
|
||||||
gtkgui_helpers.on_avatar_save_as_menuitem_activate,
|
|
||||||
self.avatar_sha, nick)
|
|
||||||
menu.append(menuitem)
|
|
||||||
menu.connect('selection-done', lambda w: w.destroy())
|
|
||||||
# show the menu
|
|
||||||
menu.show_all()
|
|
||||||
menu.attach_to_widget(widget, None)
|
|
||||||
menu.popup(None, None, None, None, event.button, event.time)
|
|
||||||
elif event.button == 1: # left click
|
elif event.button == 1: # left click
|
||||||
self.on_set_avatar_button_clicked(widget)
|
self.on_set_avatar_button_clicked(widget)
|
||||||
|
|
||||||
|
|
|
@ -596,6 +596,18 @@ def get_transport_menu(contact, account):
|
||||||
return menu
|
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):
|
def get_singlechat_menu(control_id):
|
||||||
singlechat_menu = [
|
singlechat_menu = [
|
||||||
(_('Send File…'), [
|
(_('Send File…'), [
|
||||||
|
|
|
@ -34,6 +34,7 @@ from gi.repository import GLib
|
||||||
from gi.repository import Gdk
|
from gi.repository import Gdk
|
||||||
|
|
||||||
from gajim import gtkgui_helpers
|
from gajim import gtkgui_helpers
|
||||||
|
from gajim.gui_menu_builder import show_save_as_menu
|
||||||
from gajim.common import helpers
|
from gajim.common import helpers
|
||||||
from gajim.common import app
|
from gajim.common import app
|
||||||
from gajim.common import ged
|
from gajim.common import ged
|
||||||
|
@ -160,8 +161,6 @@ class VcardWindow:
|
||||||
If right-clicked, show popup
|
If right-clicked, show popup
|
||||||
"""
|
"""
|
||||||
if event.button == 3: # right click
|
if event.button == 3: # right click
|
||||||
menu = Gtk.Menu()
|
|
||||||
menuitem = Gtk.MenuItem.new_with_mnemonic(_('Save _As'))
|
|
||||||
if self.gc_contact:
|
if self.gc_contact:
|
||||||
sha = self.gc_contact.avatar_sha
|
sha = self.gc_contact.avatar_sha
|
||||||
name = self.gc_contact.get_shown_name()
|
name = self.gc_contact.get_shown_name()
|
||||||
|
@ -171,14 +170,7 @@ class VcardWindow:
|
||||||
name = self.contact.get_shown_name()
|
name = self.contact.get_shown_name()
|
||||||
if sha is None:
|
if sha is None:
|
||||||
sha = self.avatar
|
sha = self.avatar
|
||||||
menuitem.connect('activate',
|
show_save_as_menu(sha, name)
|
||||||
gtkgui_helpers.on_avatar_save_as_menuitem_activate, sha, name)
|
|
||||||
menu.append(menuitem)
|
|
||||||
menu.connect('selection-done', lambda w: w.destroy())
|
|
||||||
# show the menu
|
|
||||||
menu.show_all()
|
|
||||||
menu.attach_to_widget(widget, None)
|
|
||||||
menu.popup(None, None, None, None, event.button, event.time)
|
|
||||||
|
|
||||||
def set_value(self, entry_name, value):
|
def set_value(self, entry_name, value):
|
||||||
try:
|
try:
|
||||||
|
@ -512,17 +504,8 @@ class ZeroconfVcardWindow:
|
||||||
If right-clicked, show popup
|
If right-clicked, show popup
|
||||||
"""
|
"""
|
||||||
if event.button == 3: # right click
|
if event.button == 3: # right click
|
||||||
menu = Gtk.Menu()
|
show_save_as_menu(self.contact.avatar_sha,
|
||||||
menuitem = Gtk.MenuItem.new_with_mnemonic(_('Save _As'))
|
self.contact.get_shown_name())
|
||||||
menuitem.connect('activate',
|
|
||||||
gtkgui_helpers.on_avatar_save_as_menuitem_activate,
|
|
||||||
self.contact.avatar_sha, self.contact.get_shown_name())
|
|
||||||
menu.append(menuitem)
|
|
||||||
menu.connect('selection-done', lambda w: w.destroy())
|
|
||||||
# show the menu
|
|
||||||
menu.show_all()
|
|
||||||
menu.attach_to_widget(widget, None)
|
|
||||||
menu.popup(None, None, None, None, event.button, event.time)
|
|
||||||
|
|
||||||
def set_value(self, entry_name, value):
|
def set_value(self, entry_name, value):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Reference in a new issue