Skip to content

Commit

Permalink
Merge pull request #514 from iptux-src/issue_513
Browse files Browse the repository at this point in the history
show quit and preference when no appmenu
  • Loading branch information
lidaobing authored Jun 16, 2023
2 parents cd1f016 + 98b4a3b commit 0768065
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 8 deletions.
25 changes: 19 additions & 6 deletions src/iptux/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,25 @@ void Application::onStartup(Application& self) {

g_action_map_add_action_entries(G_ACTION_MAP(self.app), app_entries,
G_N_ELEMENTS(app_entries), &self);
auto app_menu =
G_MENU_MODEL(gtk_builder_get_object(self.menuBuilder, "appmenu"));
gtk_application_set_app_menu(GTK_APPLICATION(self.app), app_menu);
auto menubar =
G_MENU_MODEL(gtk_builder_get_object(self.menuBuilder, "menubar"));
gtk_application_set_menubar(GTK_APPLICATION(self.app), menubar);

bool use_app_menu = true;
#if SYSTEM_DARWIN
#else
use_app_menu = gtk_application_prefers_app_menu(self.app);
#endif

if(use_app_menu) {
auto app_menu =
G_MENU_MODEL(gtk_builder_get_object(self.menuBuilder, "appmenu"));
gtk_application_set_app_menu(GTK_APPLICATION(self.app), app_menu);
auto menubar =
G_MENU_MODEL(gtk_builder_get_object(self.menuBuilder, "menubar-when-app-menu"));
gtk_application_set_menubar(GTK_APPLICATION(self.app), menubar);
} else {
auto menubar =
G_MENU_MODEL(gtk_builder_get_object(self.menuBuilder, "menubar-when-no-app-menu"));
gtk_application_set_menubar(GTK_APPLICATION(self.app), menubar);
}

add_accelerator(self.app, "app.quit", "<Primary>Q");
add_accelerator(self.app, "win.refresh", "F5");
Expand Down
2 changes: 1 addition & 1 deletion src/iptux/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ GtkWidget* MainWindow::CreateAllArea() {
auto menuButton = gtk_builder_get_object(builder, "menu_button");
gtk_menu_button_set_menu_model(
GTK_MENU_BUTTON(menuButton),
G_MENU_MODEL(gtk_builder_get_object(app->getMenuBuilder(), "menubar")));
G_MENU_MODEL(gtk_builder_get_object(app->getMenuBuilder(), "menubar-when-no-app-menu")));
#endif

gtk_box_pack_start(GTK_BOX(box), CreateToolBar(), FALSE, FALSE, 0);
Expand Down
143 changes: 142 additions & 1 deletion src/iptux/resources/gtk/menus.ui
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</item>
</section>
</menu>
<menu id='menubar'>
<menu id='menubar-when-app-menu'>
<submenu>
<attribute name='label' translatable='yes'>_File</attribute>
<item>
Expand Down Expand Up @@ -141,6 +141,147 @@
</section>
</submenu>
</menu>
<menu id='menubar-when-no-app-menu'>
<section>
<submenu>
<attribute name='label' translatable='yes'>_File</attribute>
<item>
<attribute name='label' translatable='yes'>_Detect</attribute>
<attribute name='action'>win.detect</attribute>
</item>
<item>
<attribute name='label' translatable='yes'>_Find</attribute>
<attribute name='action'>win.find</attribute>
</item>
</submenu>
<submenu>
<attribute name='label' translatable='yes'>_View</attribute>
<section>
<submenu>
<attribute name='label' translatable='yes'>Sort</attribute>
<section>
<item>
<attribute name='label' translatable='yes'>By Nickname</attribute>
<attribute name='action'>win.sort_by</attribute>
<attribute name='target'>nickname</attribute>
</item>
<item>
<attribute name='label' translatable='yes'>By IP</attribute>
<attribute name='action'>win.sort_by</attribute>
<attribute name='target'>ip</attribute>
</item>
</section>
<section>
<item>
<attribute name='label' translatable='yes'>Ascending</attribute>
<attribute name='action'>win.sort_type</attribute>
<attribute name='target'>ascending</attribute>
</item>
<item>
<attribute name='label' translatable='yes'>Descending</attribute>
<attribute name='action'>win.sort_type</attribute>
<attribute name='target'>descending</attribute>
</item>
</section>
</submenu>
<item>
<attribute name='label' translatable='yes'>_Refresh</attribute>
<attribute name='action'>win.refresh</attribute>
<attribute name='icon'>view-refresh-symbolic</attribute>
</item>
</section>
</submenu>
<submenu>
<attribute name='label' translatable='yes'>_Chat</attribute>
<section>
<item>
<attribute name='label' translatable='yes'>Insert Picture</attribute>
<attribute name='action'>win.insert_picture</attribute>
<attribute name='icon'>insert-image-symbolic</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Attach File</attribute>
<attribute name="action">win.attach_file</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Attach Folder</attribute>
<attribute name="action">win.attach_folder</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Request Shared Resources</attribute>
<attribute name="action">win.request_shared_resources</attribute>
</item>
<item>
<attribute name='label' translatable='yes'>Clear Chat History</attribute>
<attribute name='action'>win.clear_chat_history</attribute>
<attribute name='icon'>edit-clear-all-symbolic</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Send Message</attribute>
<attribute name="action">win.send_message</attribute>
</item>
</section>
</submenu>
<submenu>
<attribute name='label' translatable='yes'>_Window</attribute>
<section>
<item>
<attribute name="label" translatable="yes">_Transmission</attribute>
<attribute name="action">app.tools.transmission</attribute>
</item>
<item>
<attribute name='label' translatable='yes'>_Shared Management</attribute>
<attribute name='action'>app.tools.shared_management</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Chat Log</attribute>
<attribute name="action">app.tools.open_chat_log</attribute>
</item>
<item>
<attribute name='label' translatable='yes'>_System Log</attribute>
<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>
<section>
<item>
<attribute name="label" translatable="yes">_About</attribute>
<attribute name="action">app.about</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Report Bug</attribute>
<attribute name="action">app.help.report_bug</attribute>
</item>
<item>
<attribute name="label" translatable="yes">What's New</attribute>
<attribute name="action">app.help.whats_new</attribute>
</item>
</section>
</submenu>
</section>
<section>
<item>
<attribute name="label" translatable="yes">_Preferences</attribute>
<attribute name="action">app.preferences</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="action">app.quit</attribute>
</item>
</section>
</menu>
<menu id="trans-popup">
<section>
<item>
Expand Down

0 comments on commit 0768065

Please sign in to comment.