Philipp Hörist pushed to branch master at gajim / gajim
Commits: 6e7f53df by Philipp Hörist at 2019-04-20T06:37:48Z Remove unused code
- - - - - cc375071 by Philipp Hörist at 2019-04-20T07:47:34Z Add copy menu to Search dialog
- - - - -
6 changed files:
- gajim/app_actions.py - gajim/application.py - − gajim/data/gui/progress_dialog.ui - gajim/dialogs.py - gajim/gtk/search.py - gajim/gui_menu_builder.py
Changes:
===================================== gajim/app_actions.py ===================================== @@ -355,7 +355,7 @@ def open_link(_action, param): helpers.launch_browser_mailer(kind, link)
-def copy_link(_action, param): +def copy_text(_action, param): text = param.get_string() clip = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) clip.set_text(text, -1)
===================================== gajim/application.py ===================================== @@ -416,8 +416,8 @@ class GajimApplication(Gtk.Application): act.connect("activate", app_actions.on_add_contact_jid) self.add_action(act)
- act = Gio.SimpleAction.new('copy-link', GLib.VariantType.new('s')) - act.connect("activate", app_actions.copy_link) + act = Gio.SimpleAction.new('copy-text', GLib.VariantType.new('s')) + act.connect("activate", app_actions.copy_text) self.add_action(act)
act = Gio.SimpleAction.new('open-link', GLib.VariantType.new('as'))
===================================== gajim/data/gui/progress_dialog.ui deleted ===================================== @@ -1,74 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> -<interface> - <requires lib="gtk+" version="3.12"/> - <object class="GtkDialog" id="progress_dialog"> - <property name="can_focus">False</property> - <property name="type_hint">dialog</property> - <signal name="delete-event" handler="on_progress_dialog_delete_event" swapped="no"/> - <child internal-child="vbox"> - <object class="GtkBox" id="dialog-vbox"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> - <child internal-child="action_area"> - <object class="GtkButtonBox" id="dialog-action_area11"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="layout_style">end</property> - <child> - <object class="GtkButton" id="close_button"> - <property name="label">gtk-close</property> - <property name="visible">True</property> - <property name="sensitive">False</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="receives_default">False</property> - <property name="use_stock">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="pack_type">end</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="use_markup">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">2</property> - </packing> - </child> - <child> - <object class="GtkProgressBar" id="progressbar"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="pulse_step">0.10000000149</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">3</property> - </packing> - </child> - </object> - </child> - <action-widgets> - <action-widget response="-7">close_button</action-widget> - </action-widgets> - </object> -</interface>
===================================== gajim/dialogs.py ===================================== @@ -1159,35 +1159,6 @@ class RosterItemExchangeWindow: self.window.destroy()
-class ProgressDialog: - def __init__(self, title_text, during_text, messages_queue): - """ - During text is what to show during the procedure, messages_queue has the - message to show in the textview - """ - self.xml = get_builder('progress_dialog.ui') - self.dialog = self.xml.get_object('progress_dialog') - self.label = self.xml.get_object('label') - self.label.set_markup('<big>' + during_text + '</big>') - self.progressbar = self.xml.get_object('progressbar') - self.dialog.set_title(title_text) - self.dialog.set_default_size(450, 250) - self.window.set_position(Gtk.WindowPosition.CENTER_ON_PARENT) - self.dialog.show_all() - self.xml.connect_signals(self) - - self.update_progressbar_timeout_id = GLib.timeout_add(100, - self.update_progressbar) - - def update_progressbar(self): - if self.dialog: - self.progressbar.pulse() - return True # loop forever - return False - - def on_progress_dialog_delete_event(self, widget, event): - return True # WM's X button or Escape key should not destroy the window - class TransformChatToMUC: # Keep a reference on windows so garbage collector don't restroy them instances = [] # type: List[TransformChatToMUC]
===================================== gajim/gtk/search.py ===================================== @@ -26,6 +26,8 @@ from gajim.common.i18n import _
from gajim.common.modules import dataforms
+from gajim.gui_menu_builder import SearchMenu + from gajim.gtk.dataform import DataFormWidget from gajim.gtk.util import ensure_not_destroyed from gajim.gtk.util import find_widget @@ -259,6 +261,7 @@ class Completed(Gtk.Box): self._scrolled.get_style_context().add_class('search-scrolled') self._scrolled.set_no_show_all(True) self._treeview = None + self._menu = None self.add(self._label) self.add(self._scrolled) self.show_all() @@ -268,6 +271,7 @@ class Completed(Gtk.Box): self._scrolled.remove(self._treeview) self._treeview.destroy() self._treeview = None + self._menu = None self._label.hide() self._scrolled.hide()
@@ -303,6 +307,8 @@ class Completed(Gtk.Box): self._treeview.set_hexpand(True) self._treeview.set_vexpand(True) self._treeview.get_style_context().add_class('search-treeview') + self._treeview.connect('button-press-event', self._on_button_press) + self._menu = SearchMenu(self._treeview)
for field, counter in zip(form.reported.iter_fields(), itertools.count()): @@ -316,6 +322,19 @@ class Completed(Gtk.Box): self._scrolled.add(self._treeview) self._scrolled.show()
+ def _on_button_press(self, treeview, event): + if event.button != 3: + return + path, _column, _x, _y = treeview.get_path_at_pos(event.x, event.y) + if path is None: + return + store = treeview.get_model() + iter_ = store.get_iter(path) + column_values = store[iter_] + text = ' '.join(column_values) + self._menu.set_copy_text(text) + self._menu.popup_at_pointer() +
class Error(Gtk.Box):
===================================== gajim/gui_menu_builder.py ===================================== @@ -905,31 +905,31 @@ def get_conv_context_menu(account, kind, text): if kind == 'xmpp': if '?join' in text: context_menu = [ - ('copy-link', _('Copy JID')), + ('copy-text', _('Copy JID')), ('-join-groupchat', _('Join Groupchat')), ] else: context_menu = [ - ('copy-link', _('Copy JID')), + ('copy-text', _('Copy JID')), ('-start-chat', _('Start Chat')), ('-add-contact', _('Add to Roster…')), ]
elif kind == 'url': context_menu = [ - ('copy-link', _('Copy Link Location')), + ('copy-text', _('Copy Link Location')), ('open-link', _('Open Link in Browser')), ]
elif kind == 'mail': context_menu = [ - ('copy-link', _('Copy Email Address')), + ('copy-text', _('Copy Email Address')), ('open-link', _('Open Email Composer')), ]
elif kind == 'sth_at_sth': context_menu = [ - ('copy-link', _('Copy JID/Email')), + ('copy-text', _('Copy JID/Email')), ('open-link', _('Open Email Composer')), ('-start-chat', _('Start Chat')), ('-join-groupchat', _('Join Groupchat')), @@ -954,7 +954,7 @@ def get_conv_context_menu(account, kind, text):
if action == 'app.open-link': value = GLib.Variant.new_strv([kind, text]) - elif action == 'app.copy-link': + elif action == 'app.copy-text': value = GLib.Variant.new_string(text) else: value = GLib.Variant.new_strv([account, text]) @@ -964,6 +964,20 @@ def get_conv_context_menu(account, kind, text): return menu
+class SearchMenu(Gtk.Menu): + def __init__(self, treeview): + Gtk.Menu.__init__(self) + self._copy_item = Gtk.MenuItem(label=_('Copy')) + self._copy_item.set_action_name('app.copy-text') + self.set_copy_text('') + self._copy_item.show() + self.append(self._copy_item) + self.attach_to_widget(treeview, None) + + def set_copy_text(self, text): + self._copy_item.set_action_target_value(GLib.Variant('s', text)) + + def escape_mnemonic(label): if label is None: return
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/cbb1918bce8cd7fc70f2c8bb08c0e7cde3...