1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-21 23:32:35 +00:00

Feature/default focus (#7102)

* Setting default focus in Open URL and Add Tracker dialog box

* Additional cleanup to remove duplication of responsibility in setting focus

* Removing now un-necessary code in TorrentUrlChooserDialog.ui

* Using activates-default property to enable default action in torrent url chooser and tracker adder

* removing un-necessary focus

* Adding missing property to the accept buttons.

* Removing unintended whitespace change in
TorrentUrlChooserDialog

* Use `True` instead of `1` for booleans (GTK3)
This commit is contained in:
cloppingemu 2024-12-13 10:03:28 +11:00 committed by GitHub
parent 31a63f0045
commit bb6c6dd4ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 20 additions and 9 deletions

View file

@ -2341,6 +2341,13 @@ AddTrackerDialog::AddTrackerDialog(
set_title(fmt::format(_("{torrent_name} - Add Tracker"), fmt::arg("torrent_name", tr_torrentName(torrent))));
set_transient_for(parent);
auto* const accept = get_widget_for_response(TR_GTK_RESPONSE_TYPE(ACCEPT));
#if GTKMM_CHECK_VERSION(4, 0, 0)
set_default_widget(*accept);
#else
set_default(*accept);
#endif
gtr_paste_clipboard_url_into_entry(*url_entry_);
}

View file

@ -427,16 +427,14 @@ TorrentUrlChooserDialog::TorrentUrlChooserDialog(
set_transient_for(parent);
auto* const e = gtr_get_widget<Gtk::Entry>(builder, "url_entry");
auto* const accept = get_widget_for_response(TR_GTK_RESPONSE_TYPE(ACCEPT));
gtr_paste_clipboard_url_into_entry(*e);
signal_response().connect([this, e, core](int response) { onOpenURLResponse(response, *e, core); });
#if GTKMM_CHECK_VERSION(4, 0, 0)
set_default_widget(*accept);
#else
set_default(*accept);
#endif
if (e->get_text_length() == 0)
{
e->grab_focus();
}
else
{
get_widget_for_response(TR_GTK_RESPONSE_TYPE(ACCEPT))->grab_focus();
}
signal_response().connect([this, e, core](int response) { onOpenURLResponse(response, *e, core); });
}

View file

@ -34,6 +34,7 @@
<property name="label" translatable="yes">_Add</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="can-default">True</property>
<property name="receives-default">True</property>
<property name="use-underline">True</property>
</object>
@ -94,6 +95,7 @@
<property name="width-request">400</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="activates-default">True</property>
<property name="hexpand">True</property>
</object>
<packing>

View file

@ -34,6 +34,7 @@
<property name="label" translatable="yes">_Open</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="can-default">True</property>
<property name="receives-default">True</property>
<property name="use-underline">True</property>
</object>
@ -94,6 +95,7 @@
<property name="width-request">400</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="activates-default">True</property>
<property name="hexpand">True</property>
</object>
<packing>

View file

@ -42,6 +42,7 @@
<object class="GtkEntry" id="url_entry">
<property name="width-request">400</property>
<property name="focusable">1</property>
<property name="activates-default">1</property>
<property name="hexpand">1</property>
<layout>
<property name="column">1</property>

View file

@ -42,6 +42,7 @@
<object class="GtkEntry" id="url_entry">
<property name="width-request">400</property>
<property name="focusable">1</property>
<property name="activates-default">1</property>
<property name="hexpand">1</property>
<layout>
<property name="column">1</property>