Skip to content

Commit

Permalink
Merge pull request #486 from iptux-src/lidaobing/issue485
Browse files Browse the repository at this point in the history
#485 close window
  • Loading branch information
lidaobing authored Oct 9, 2021
2 parents 90b712f + 70ff60d commit 050c7c5
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 13 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* [#481](https://github.com/iptux-src/iptux/issues/481) chatbox can remember the unsent text.
* [#482](https://github.com/iptux-src/iptux/issues/482) add "What's New" in the menu.
* [#485](https://github.com/iptux-src/iptux/issues/485) `<Primary>W` can close all kinds of windows.

# [0.8.3] (2021-10-07)

Expand Down
10 changes: 9 additions & 1 deletion src/iptux/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ void Application::onStartup(Application& self) {
G_ACTION_CALLBACK(onTransModelClear)),
makeActionEntry("about", G_ACTION_CALLBACK(onAbout)),
makeParamActionEntry("open-chat", G_ACTION_CALLBACK(onOpenChat), "s"),
makeActionEntry("window.close", G_ACTION_CALLBACK(onWindowClose)),
};

g_action_map_add_action_entries(G_ACTION_MAP(self.app), app_entries,
Expand All @@ -167,7 +168,7 @@ void Application::onStartup(Application& self) {
add_accelerator(self.app, "win.attach_file", "<Ctrl>S");
add_accelerator(self.app, "win.attach_folder", "<Ctrl>D");
add_accelerator(self.app, "win.request_shared_resources", "<Ctrl>R");
add_accelerator(self.app, "win.close", "<Primary>W");
add_accelerator(self.app, "app.window.close", "<Primary>W");
self.onConfigChanged();

#if SYSTEM_DARWIN
Expand Down Expand Up @@ -228,6 +229,13 @@ void Application::onTransModelClear(void*, void*, Application& self) {
self.getCoreThread()->clearFinishedTransTasks();
}

void Application::onWindowClose(void*, void*, Application& self) {
auto window = gtk_application_get_active_window(self.app);
if (window) {
gtk_window_close(window);
}
}

void Application::onAbout(void*, void*, Application& self) {
aboutDialogEntry(GTK_WINDOW(self.window->getWindow()));
}
Expand Down
1 change: 1 addition & 0 deletions src/iptux/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class Application {
static void onOpenChat(GSimpleAction* action,
GVariant* value,
Application& self);
static void onWindowClose(void*, void*, Application& self);
static gboolean onTransWindowDelete(Application& self);
};

Expand Down
1 change: 0 additions & 1 deletion src/iptux/DialogGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ GtkWindow* DialogGroup::CreateMainWindow() {
G_ACTION_CALLBACK(onClearChatHistory)),
makeActionEntry("attach_file", G_ACTION_CALLBACK(onAttachFile)),
makeActionEntry("attach_folder", G_ACTION_CALLBACK(onAttachFolder)),
makeActionEntry("close", G_ACTION_CALLBACK(onClose)),
makeStateActionEntry("sort_type", G_ACTION_CALLBACK(onSortType), "s",
"'ascending'"),
makeStateActionEntry("sort_by", G_ACTION_CALLBACK(onSortBy), "s",
Expand Down
3 changes: 0 additions & 3 deletions src/iptux/DialogGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ class DialogGroup : public DialogBase {
static void onAttachFolder(void*, void*, DialogGroup& self) {
DialogBase::AttachFolder(&self);
}
static void onClose(void*, void*, DialogGroup& self) {
gtk_widget_destroy(GTK_WIDGET(self.window));
}
static void onSortType(GSimpleAction* action,
GVariant* value,
DialogGroup& self);
Expand Down
1 change: 0 additions & 1 deletion src/iptux/DialogPeer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ void DialogPeer::init() {
makeActionEntry("attach_folder", G_ACTION_CALLBACK(onAttachFolder)),
makeActionEntry("clear_chat_history",
G_ACTION_CALLBACK(onClearChatHistory)),
makeActionEntry("close", G_ACTION_CALLBACK(onClose)),
makeActionEntry("refuse", G_ACTION_CALLBACK(onRefuse)),
makeActionEntry("refuse_all", G_ACTION_CALLBACK(onRefuseAll)),
makeActionEntry("insert_picture", G_ACTION_CALLBACK(onInsertPicture)),
Expand Down
3 changes: 0 additions & 3 deletions src/iptux/DialogPeer.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ class DialogPeer : public DialogBase {
static void onSendMessage(void*, void*, DialogPeer& self) {
DialogBase::SendMessage(&self);
}
static void onClose(void*, void*, DialogPeer& self) {
gtk_widget_destroy(GTK_WIDGET(self.window));
}
void onGroupInfoUpdated(GroupInfo* groupInfo);
static void onInputBufferChanged(GtkTextBuffer*, DialogPeer& self) {
self.refreshSendAction();
Expand Down
10 changes: 6 additions & 4 deletions src/iptux/resources/gtk/menus.ui
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@
<attribute name="label" translatable="yes">Send Message</attribute>
<attribute name="action">win.send_message</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Close Chat</attribute>
<attribute name="action">win.close</attribute>
</item>
</section>
</submenu>
<submenu>
Expand All @@ -120,6 +116,12 @@
<attribute name='action'>app.tools.open_system_log</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Close Window</attribute>
<attribute name="action">app.window.close</attribute>
</item>
</section>
</submenu>
<submenu>
<attribute name='label' translatable='yes'>_Help</attribute>
Expand Down

0 comments on commit 050c7c5

Please sign in to comment.