|
2 | 2 | * ROM Properties Page shell extension. (GTK+ common) * |
3 | 3 | * OptionsMenuButton.cpp: Options menu GtkMenuButton container. * |
4 | 4 | * * |
5 | | - * Copyright (c) 2017-2025 by David Korth. * |
| 5 | + * Copyright (c) 2017-202 by David Korth. * |
6 | 6 | * SPDX-License-Identifier: GPL-2.0-or-later * |
7 | 7 | ***************************************************************************/ |
8 | 8 |
|
|
13 | 13 | #include "RpGtkCpp.hpp" |
14 | 14 |
|
15 | 15 | // librpbase |
| 16 | +#include "librpbase/OptionsMenuButton_data.inc.h" |
16 | 17 | using LibRpBase::RomData; |
17 | 18 |
|
18 | 19 | // C++ STL classes |
@@ -137,18 +138,6 @@ struct _RpOptionsMenuButton { |
137 | 138 | G_DEFINE_TYPE_EXTENDED(RpOptionsMenuButton, rp_options_menu_button, |
138 | 139 | GTK_TYPE_SUPER, static_cast<GTypeFlags>(0), {}); |
139 | 140 |
|
140 | | -/** Standard actions. **/ |
141 | | -struct option_menu_action_t { |
142 | | - const char *desc; |
143 | | - int id; |
144 | | -}; |
145 | | -static const array<option_menu_action_t, 4> stdacts = {{ |
146 | | - {NOP_C_("OptionsMenuButton|StdActs", "Export to Text..."), OPTION_EXPORT_TEXT}, |
147 | | - {NOP_C_("OptionsMenuButton|StdActs", "Export to JSON..."), OPTION_EXPORT_JSON}, |
148 | | - {NOP_C_("OptionsMenuButton|StdActs", "Copy as Text"), OPTION_COPY_TEXT}, |
149 | | - {NOP_C_("OptionsMenuButton|StdActs", "Copy as JSON"), OPTION_COPY_JSON}, |
150 | | -}}; |
151 | | - |
152 | 141 | static void |
153 | 142 | rp_options_menu_button_class_init(RpOptionsMenuButtonClass *klass) |
154 | 143 | { |
@@ -556,7 +545,7 @@ rp_options_menu_button_reinit_menu(RpOptionsMenuButton *widget, |
556 | 545 |
|
557 | 546 | GMenu *const menuStdActs = g_menu_new(); |
558 | 547 | g_menu_append_section(menuModel, nullptr, G_MENU_MODEL(menuStdActs)); |
559 | | - for (const option_menu_action_t &p : stdacts) { |
| 548 | + for (const option_menu_action_t &p : OptionsMenuButton_stdacts) { |
560 | 549 | // Create the action. |
561 | 550 | GSimpleAction *const action = g_simple_action_new( |
562 | 551 | fmt::to_string(p.id).c_str(), nullptr); |
@@ -602,7 +591,7 @@ rp_options_menu_button_reinit_menu(RpOptionsMenuButton *widget, |
602 | 591 | GtkWidget *const menuOptions = gtk_menu_new(); |
603 | 592 | gtk_widget_set_name(menuOptions, "menuOptions"); |
604 | 593 |
|
605 | | - for (const option_menu_action_t &p : stdacts) { |
| 594 | + for (const option_menu_action_t &p : OptionsMenuButton_stdacts) { |
606 | 595 | GtkWidget *const menuItem = gtk_menu_item_new_with_label( |
607 | 596 | pgettext_expr("RomDataView|Options", p.desc)); |
608 | 597 | // NOTE: No name for this GtkWidget. |
@@ -706,7 +695,7 @@ rp_options_menu_button_update_op(RpOptionsMenuButton *widget, |
706 | 695 | GList *l = gtk_container_get_children(GTK_CONTAINER(widget->menuOptions)); |
707 | 696 |
|
708 | 697 | // Skip the standard actions and separator. |
709 | | - for (size_t i = 0; i < (stdacts.size()+1) && l != nullptr; i++) { |
| 698 | + for (size_t i = 0; i < (ARRAY_SIZE(OptionsMenuButton_stdacts)+1) && l != nullptr; i++) { |
710 | 699 | l = l->next; |
711 | 700 | } |
712 | 701 |
|
|
0 commit comments