Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show quit and preference when no appmenu #514

Merged
merged 1 commit into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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