Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
aad2e1d2
by Philipp Hörist at 2020-01-26T20:46:49+01:00
5 changed files:
- gajim/chat_control.py
- gajim/chat_control_base.py
- gajim/groupchat_control.py
- gajim/gtk/dataform.py
- gajim/message_window.py
Changes:
| ... | ... | @@ -340,6 +340,9 @@ class ChatControl(ChatControlBase): |
| 340 | 340 |
win.lookup_action(
|
| 341 | 341 |
'information-' + self.control_id).set_enabled(online)
|
| 342 | 342 |
|
| 343 |
+ def focus(self):
|
|
| 344 |
+ self.msg_textview.grab_focus()
|
|
| 345 |
+ |
|
| 343 | 346 |
def delegate_action(self, action):
|
| 344 | 347 |
res = super().delegate_action(action)
|
| 345 | 348 |
if res == Gdk.EVENT_STOP:
|
| ... | ... | @@ -332,6 +332,9 @@ class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper): |
| 332 | 332 |
"""
|
| 333 | 333 |
on_response_yes(self)
|
| 334 | 334 |
|
| 335 |
+ def focus(self):
|
|
| 336 |
+ raise NotImplementedError
|
|
| 337 |
+ |
|
| 335 | 338 |
def get_nb_unread(self):
|
| 336 | 339 |
jid = self.contact.jid
|
| 337 | 340 |
if self.resource:
|
| ... | ... | @@ -1899,6 +1899,23 @@ class GroupchatControl(ChatControlBase): |
| 1899 | 1899 |
|
| 1900 | 1900 |
return Gdk.EVENT_PROPAGATE
|
| 1901 | 1901 |
|
| 1902 |
+ def focus(self):
|
|
| 1903 |
+ page_name = self._get_current_page()
|
|
| 1904 |
+ if page_name == 'groupchat':
|
|
| 1905 |
+ self.msg_textview.grab_focus()
|
|
| 1906 |
+ elif page_name == 'password':
|
|
| 1907 |
+ self.xml.password_entry.grab_focus_without_selecting()
|
|
| 1908 |
+ elif page_name == 'nickname':
|
|
| 1909 |
+ self.xml.nickname_entry.grab_focus_without_selecting()
|
|
| 1910 |
+ elif page_name == 'rename':
|
|
| 1911 |
+ self.xml.name_entry.grab_focus_without_selecting()
|
|
| 1912 |
+ elif page_name == 'subject':
|
|
| 1913 |
+ self.xml.subject_textview.grab_focus()
|
|
| 1914 |
+ elif page_name == 'captcha':
|
|
| 1915 |
+ self._captcha_request.focus_first_entry()
|
|
| 1916 |
+ elif page_name == 'destroy':
|
|
| 1917 |
+ self.xml.destroy_reason_entry.grab_focus_without_selecting()
|
|
| 1918 |
+ |
|
| 1902 | 1919 |
def _start_private_message(self, nick):
|
| 1903 | 1920 |
gc_c = app.contacts.get_gc_contact(self.account, self.room_jid, nick)
|
| 1904 | 1921 |
nick_jid = gc_c.get_full_jid()
|
| ... | ... | @@ -69,7 +69,7 @@ class DataFormWidget(Gtk.ScrolledWindow): |
| 69 | 69 |
def focus_first_entry(self):
|
| 70 | 70 |
for widget in self._form_grid.get_children():
|
| 71 | 71 |
if isinstance(widget, Gtk.Entry):
|
| 72 |
- widget.grab_focus()
|
|
| 72 |
+ widget.grab_focus_without_selecting()
|
|
| 73 | 73 |
break
|
| 74 | 74 |
|
| 75 | 75 |
|
| ... | ... | @@ -451,7 +451,7 @@ class MessageWindow(EventHelper): |
| 451 | 451 |
# whether the tab is the active one.
|
| 452 | 452 |
self.show_title()
|
| 453 | 453 |
if self.get_num_controls() == 1:
|
| 454 |
- GLib.timeout_add(500, control.msg_textview.grab_focus)
|
|
| 454 |
+ GLib.timeout_add(500, control.focus)
|
|
| 455 | 455 |
|
| 456 | 456 |
def on_tab_eventbox_button_press_event(self, widget, event, child):
|
| 457 | 457 |
if event.button == 3: # right click
|
| ... | ... | @@ -463,7 +463,7 @@ class MessageWindow(EventHelper): |
| 463 | 463 |
self.remove_tab(ctrl, self.CLOSE_TAB_MIDDLE_CLICK)
|
| 464 | 464 |
else:
|
| 465 | 465 |
ctrl = self._widget_to_control(child)
|
| 466 |
- GLib.idle_add(ctrl.msg_textview.grab_focus)
|
|
| 466 |
+ GLib.idle_add(ctrl.focus)
|
|
| 467 | 467 |
|
| 468 | 468 |
def _on_close_button_clicked(self, button, control):
|
| 469 | 469 |
"""
|
| ... | ... | @@ -549,7 +549,7 @@ class MessageWindow(EventHelper): |
| 549 | 549 |
ctrl_page = self.notebook.page_num(ctrl.widget)
|
| 550 | 550 |
self.notebook.set_current_page(ctrl_page)
|
| 551 | 551 |
self.window.present()
|
| 552 |
- GLib.idle_add(ctrl.msg_textview.grab_focus)
|
|
| 552 |
+ GLib.idle_add(ctrl.focus)
|
|
| 553 | 553 |
|
| 554 | 554 |
def remove_tab(self, ctrl, method, reason=None, force=False):
|
| 555 | 555 |
"""
|
| ... | ... | @@ -825,7 +825,7 @@ class MessageWindow(EventHelper): |
| 825 | 825 |
|
| 826 | 826 |
control = self.get_active_control()
|
| 827 | 827 |
if isinstance(control, ChatControlBase):
|
| 828 |
- control.msg_textview.grab_focus()
|
|
| 828 |
+ control.focus()
|
|
| 829 | 829 |
|
| 830 | 830 |
def get_tab_at_xy(self, x, y):
|
| 831 | 831 |
"""
|