Changeset 217209 in webkit
- Timestamp:
- May 22, 2017 12:50:44 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r217206 r217209 1 2017-05-22 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Add webkit_context_menu_item_new_from_gaction 4 https://bugs.webkit.org/show_bug.cgi?id=159631 5 6 Reviewed by Michael Catanzaro. 7 8 Add new API to create a WebKitContextMenuItem from a GAction and also to get the associated GAction. 9 10 * Shared/gtk/WebContextMenuItemGtk.cpp: 11 (WebKit::WebContextMenuItemGtk::WebContextMenuItemGtk): Add constructor that receives a GAction. 12 (WebKit::isGActionChecked): Helper to check if a stateful GAction is checked or not. 13 (WebKit::WebContextMenuItemGtk::createActionIfNeeded): When creating a GAction from a GtkAtion, use the 14 GtkAction name instead of adding a new one. Do not create the GAction if we already have one. 15 * Shared/gtk/WebContextMenuItemGtk.h: 16 (WebKit::WebContextMenuItemGtk::gAction): 17 (WebKit::WebContextMenuItemGtk::gActionTarget): 18 * UIProcess/API/gtk/WebKitContextMenuItem.cpp: 19 (webkit_context_menu_item_new_from_gaction): 20 (webkit_context_menu_item_get_gaction): 21 * UIProcess/API/gtk/WebKitContextMenuItem.h: 22 * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: Add new symbols. 23 * UIProcess/gtk/WebContextMenuProxyGtk.cpp: 24 (WebKit::contextMenuItemActivatedCallback): Update the state of the internal GAction in case of toggle menu items. 25 (WebKit::WebContextMenuProxyGtk::append): Pass the GAction target to g_menu_item_set_action_and_target_value. Do 26 not connect to activate signal of actions provided by the user. 27 1 28 2017-05-21 Carlos Garcia Campos <cgarcia@igalia.com> 2 29 -
trunk/Source/WebKit2/Shared/gtk/WebContextMenuItemGtk.cpp
r206505 r217209 135 135 : WebContextMenuItemData(ActionType, data.action(), data.title(), data.enabled(), false) 136 136 { 137 m_gAction = G_SIMPLE_ACTION(data.gAction());137 m_gAction = data.gAction(); 138 138 m_gtkAction = data.gtkAction(); 139 139 m_submenuItems = WTFMove(submenu); … … 148 148 } 149 149 150 static bool isGActionChecked(GAction* action) 151 { 152 if (!g_action_get_state_type(action)) 153 return false; 154 155 ASSERT(g_variant_type_equal(g_action_get_state_type(action), G_VARIANT_TYPE_BOOLEAN)); 156 GRefPtr<GVariant> state = adoptGRef(g_action_get_state(action)); 157 return g_variant_get_boolean(state.get()); 158 } 159 160 WebContextMenuItemGtk::WebContextMenuItemGtk(GAction* action, const String& title, GVariant* target) 161 : WebContextMenuItemData(g_action_get_state_type(action) ? CheckableActionType : ActionType, ContextMenuItemBaseApplicationTag, title, g_action_get_enabled(action), isGActionChecked(action)) 162 , m_gAction(action) 163 , m_gActionTarget(target) 164 { 165 createActionIfNeeded(); 166 } 167 150 168 WebContextMenuItemGtk::~WebContextMenuItemGtk() 151 169 { … … 158 176 159 177 static uint64_t actionID = 0; 160 GUniquePtr<char> actionName(g_strdup_printf("action-%" PRIu64, ++actionID)); 161 if (type() == CheckableActionType) 162 m_gAction = adoptGRef(g_simple_action_new_stateful(actionName.get(), nullptr, g_variant_new_boolean(checked()))); 163 else 164 m_gAction = adoptGRef(g_simple_action_new(actionName.get(), nullptr)); 165 g_simple_action_set_enabled(m_gAction.get(), enabled()); 178 if (!m_gAction) { 179 GUniquePtr<char> actionName; 180 if (m_gtkAction) 181 actionName.reset(g_strdup(gtk_action_get_name(m_gtkAction))); 182 else 183 actionName.reset(g_strdup_printf("action-%" PRIu64, ++actionID)); 184 if (type() == CheckableActionType) 185 m_gAction = adoptGRef(G_ACTION(g_simple_action_new_stateful(actionName.get(), nullptr, g_variant_new_boolean(checked())))); 186 else 187 m_gAction = adoptGRef(G_ACTION(g_simple_action_new(actionName.get(), nullptr))); 188 g_simple_action_set_enabled(G_SIMPLE_ACTION(m_gAction.get()), enabled()); 189 } 166 190 167 191 // Create the GtkAction for backwards compatibility only. 168 192 if (!m_gtkAction) { 169 193 if (type() == CheckableActionType) { 170 m_gtkAction = GTK_ACTION(gtk_toggle_action_new( actionName.get(), title().utf8().data(), nullptr, gtkStockIDFromContextMenuAction(action())));194 m_gtkAction = GTK_ACTION(gtk_toggle_action_new(g_action_get_name(m_gAction.get()), title().utf8().data(), nullptr, gtkStockIDFromContextMenuAction(action()))); 171 195 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(m_gtkAction), checked()); 172 196 } else 173 m_gtkAction = gtk_action_new( actionName.get(), title().utf8().data(), 0, gtkStockIDFromContextMenuAction(action()));197 m_gtkAction = gtk_action_new(g_action_get_name(m_gAction.get()), title().utf8().data(), 0, gtkStockIDFromContextMenuAction(action())); 174 198 gtk_action_set_sensitive(m_gtkAction, enabled()); 175 199 g_object_set_data_full(G_OBJECT(m_gAction.get()), "webkit-gtk-action", m_gtkAction, g_object_unref); -
trunk/Source/WebKit2/Shared/gtk/WebContextMenuItemGtk.h
r206505 r217209 33 33 typedef struct _GtkAction GtkAction; 34 34 typedef struct _GAction GAction; 35 typedef struct _GSimpleAction GSimpleAction;36 35 37 36 namespace WebKit { … … 44 43 WebContextMenuItemGtk(const WebContextMenuItemGtk&, Vector<WebContextMenuItemGtk>&& submenu); 45 44 WebContextMenuItemGtk(GtkAction*); 45 WebContextMenuItemGtk(GAction*, const String& title, GVariant* target = nullptr); 46 46 ~WebContextMenuItemGtk(); 47 47 … … 49 49 WebCore::ContextMenuItemType type() const { return m_submenuItems.isEmpty() ? WebContextMenuItemData::type() : WebCore::SubmenuType; } 50 50 GtkAction* gtkAction() const { return m_gtkAction; } 51 GAction* gAction() const { return reinterpret_cast<GAction*>(m_gAction.get()); } 51 GAction* gAction() const { return m_gAction.get(); } 52 GVariant* gActionTarget() const { return m_gActionTarget.get(); } 52 53 const Vector<WebContextMenuItemGtk>& submenuItems() const { return m_submenuItems; } 53 54 … … 55 56 void createActionIfNeeded(); 56 57 57 GRefPtr<GSimpleAction> m_gAction; 58 GRefPtr<GAction> m_gAction; 59 GRefPtr<GVariant> m_gActionTarget; 58 60 GtkAction* m_gtkAction { nullptr }; 59 61 Vector<WebContextMenuItemGtk> m_submenuItems; -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuItem.cpp
r213703 r217209 132 132 * 133 133 * Returns: the newly created #WebKitContextMenuItem object. 134 * 135 * Deprecated: 2.18: Use webkit_context_menu_item_new_from_gaction() instead. 134 136 */ 135 137 WebKitContextMenuItem* webkit_context_menu_item_new(GtkAction* action) … … 139 141 WebKitContextMenuItem* item = WEBKIT_CONTEXT_MENU_ITEM(g_object_new(WEBKIT_TYPE_CONTEXT_MENU_ITEM, nullptr)); 140 142 item->priv->menuItem = std::make_unique<WebContextMenuItemGtk>(action); 143 144 return item; 145 } 146 147 /** 148 * webkit_context_menu_item_new_from_gaction: 149 * @action: a #GAction 150 * @label: the menu item label text 151 * @target: (allow-none): a #GVariant to use as the action target 152 * 153 * Creates a new #WebKitContextMenuItem for the given @action and @label. On activation 154 * @target will be passed as parameter to the callback. 155 * 156 * Returns: the newly created #WebKitContextMenuItem object. 157 * 158 * Since: 2.18 159 */ 160 WebKitContextMenuItem* webkit_context_menu_item_new_from_gaction(GAction* action, const gchar* label, GVariant* target) 161 { 162 g_return_val_if_fail(G_IS_ACTION(action), nullptr); 163 g_return_val_if_fail(!g_action_get_state_type(action) || g_variant_type_equal(g_action_get_state_type(action), G_VARIANT_TYPE_BOOLEAN), nullptr); 164 g_return_val_if_fail(label, nullptr); 165 g_return_val_if_fail(!target || g_variant_is_of_type(target, g_action_get_parameter_type(action)), nullptr); 166 167 WebKitContextMenuItem* item = WEBKIT_CONTEXT_MENU_ITEM(g_object_new(WEBKIT_TYPE_CONTEXT_MENU_ITEM, nullptr)); 168 item->priv->menuItem = std::make_unique<WebContextMenuItemGtk>(action, String::fromUTF8(label), target); 141 169 142 170 return item; … … 236 264 * @item: a #WebKitContextMenuItem 237 265 * 238 * Gets the action associated to @item .266 * Gets the action associated to @item as a #GtkAction. 239 267 * 240 268 * Returns: (transfer none): the #GtkAction associated to the #WebKitContextMenuItem, 241 269 * or %NULL if @item is a separator. 270 * 271 * Deprecated: 2.18: Use webkit_context_menu_item_get_gaction() instead. 242 272 */ 243 273 GtkAction* webkit_context_menu_item_get_action(WebKitContextMenuItem* item) … … 246 276 247 277 return item->priv->menuItem->gtkAction(); 278 } 279 280 /** 281 * webkit_context_menu_item_get_gaction: 282 * @item: a #WebKitContextMenuItem 283 * 284 * Gets the action associated to @item as a #GAction. 285 * 286 * Returns: (transfer none): the #GAction associated to the #WebKitContextMenuItem, 287 * or %NULL if @item is a separator. 288 * 289 * Since: 2.18 290 */ 291 GAction* webkit_context_menu_item_get_gaction(WebKitContextMenuItem* item) 292 { 293 g_return_val_if_fail(WEBKIT_IS_CONTEXT_MENU_ITEM(item), nullptr); 294 295 return item->priv->menuItem->gAction(); 248 296 } 249 297 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuItem.h
r175694 r217209 61 61 webkit_context_menu_item_get_type (void); 62 62 63 WEBKIT_DEPRECATED_FOR(webkit_context_menu_item_new_from_gaction) WebKitContextMenuItem * 64 webkit_context_menu_item_new (GtkAction *action); 65 63 66 WEBKIT_API WebKitContextMenuItem * 64 webkit_context_menu_item_new (GtkAction *action); 67 webkit_context_menu_item_new_from_gaction (GAction *action, 68 const gchar *label, 69 GVariant *target); 65 70 66 71 WEBKIT_API WebKitContextMenuItem * … … 78 83 webkit_context_menu_item_new_separator (void); 79 84 80 WEBKIT_ APIGtkAction *85 WEBKIT_DEPRECATED_FOR(webkit_context_menu_item_get_gactionwebkit_context_menu_item_get_gaction) GtkAction * 81 86 webkit_context_menu_item_get_action (WebKitContextMenuItem *item); 87 88 WEBKIT_API GAction * 89 webkit_context_menu_item_get_gaction (WebKitContextMenuItem *item); 82 90 83 91 WEBKIT_API WebKitContextMenuAction -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt
r216006 r217209 1150 1150 WebKitContextMenuAction 1151 1151 webkit_context_menu_item_new 1152 webkit_context_menu_item_new_from_gaction 1152 1153 webkit_context_menu_item_new_from_stock_action 1153 1154 webkit_context_menu_item_new_from_stock_action_with_label … … 1155 1156 webkit_context_menu_item_new_separator 1156 1157 webkit_context_menu_item_get_action 1158 webkit_context_menu_item_get_gaction 1157 1159 webkit_context_menu_item_get_stock_action 1158 1160 webkit_context_menu_item_is_separator -
trunk/Source/WebKit2/UIProcess/gtk/WebContextMenuProxyGtk.cpp
r215190 r217209 58 58 String::fromUTF8(static_cast<const char*>(g_object_get_data(G_OBJECT(action), gContextMenuTitle))), g_action_get_enabled(action), 59 59 state ? g_variant_get_boolean(state.get()) : false); 60 if (isToggle) 61 g_action_change_state(action, g_variant_new_boolean(!g_variant_get_boolean(state.get()))); 60 62 page->contextMenuItemSelected(item); 61 63 } … … 78 80 GUniquePtr<char> actionName(g_strdup_printf("%s.%s", gContextMenuItemGroup, g_action_get_name(action))); 79 81 gMenuItem = adoptGRef(g_menu_item_new(menuItem.title().utf8().data(), nullptr)); 80 g_menu_item_set_action_and_target_value(gMenuItem.get(), actionName.get(), nullptr); 81 82 g_object_set_data(G_OBJECT(action), gContextMenuActionId, GINT_TO_POINTER(menuItem.action())); 83 g_object_set_data_full(G_OBJECT(action), gContextMenuTitle, g_strdup(menuItem.title().utf8().data()), g_free); 84 signalHandlerId = g_signal_connect(action, "activate", G_CALLBACK(contextMenuItemActivatedCallback), m_page); 85 m_signalHandlers.set(signalHandlerId, action); 82 g_menu_item_set_action_and_target_value(gMenuItem.get(), actionName.get(), menuItem.gActionTarget()); 83 84 if (menuItem.action() < ContextMenuItemBaseApplicationTag) { 85 g_object_set_data(G_OBJECT(action), gContextMenuActionId, GINT_TO_POINTER(menuItem.action())); 86 g_object_set_data_full(G_OBJECT(action), gContextMenuTitle, g_strdup(menuItem.title().utf8().data()), g_free); 87 signalHandlerId = g_signal_connect(action, "activate", G_CALLBACK(contextMenuItemActivatedCallback), m_page); 88 m_signalHandlers.set(signalHandlerId, action); 89 } 86 90 break; 87 91 } -
trunk/Tools/ChangeLog
r217203 r217209 1 2017-05-22 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Add webkit_context_menu_item_new_from_gaction 4 https://bugs.webkit.org/show_bug.cgi?id=159631 5 6 Reviewed by Michael Catanzaro. 7 8 Update context menu tests to check the new GAction API. 9 10 * TestWebKitAPI/Tests/WebKit2Gtk/TestContextMenu.cpp: 11 (testContextMenuPopulateMenu): 12 1 13 2017-05-21 Michael Catanzaro <mcatanzaro@igalia.com> 2 14 -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestContextMenu.cpp
r213278 r217209 137 137 assertObjectIsDeletedWhenTestFinishes(G_OBJECT(item)); 138 138 139 G_GNUC_BEGIN_IGNORE_DEPRECATIONS; 139 140 GtkAction* action = webkit_context_menu_item_get_action(item); 140 141 g_assert(GTK_IS_ACTION(action)); 142 G_GNUC_END_IGNORE_DEPRECATIONS; 143 144 GAction* gAction = webkit_context_menu_item_get_gaction(item); 145 g_assert(G_IS_ACTION(gAction)); 141 146 142 147 g_assert_cmpint(webkit_context_menu_item_get_stock_action(item), ==, stockAction); … … 155 160 assertObjectIsDeletedWhenTestFinishes(G_OBJECT(item)); 156 161 162 G_GNUC_BEGIN_IGNORE_DEPRECATIONS; 157 163 GtkAction* action = webkit_context_menu_item_get_action(item); 158 164 g_assert(GTK_IS_ACTION(action)); 165 G_GNUC_END_IGNORE_DEPRECATIONS; 166 167 GAction* gAction = webkit_context_menu_item_get_gaction(item); 168 g_assert(G_IS_ACTION(gAction)); 169 g_assert_cmpstr(gtk_action_get_name(action), ==, g_action_get_name(gAction)); 170 g_assert(gtk_action_get_sensitive(action) == g_action_get_enabled(gAction)); 171 if (GTK_IS_TOGGLE_ACTION(action)) { 172 g_assert(g_variant_type_equal(g_action_get_state_type(gAction), G_VARIANT_TYPE_BOOLEAN)); 173 GRefPtr<GVariant> state = adoptGRef(g_action_get_state(gAction)); 174 g_assert(gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)) == g_variant_get_boolean(state.get())); 175 } else 176 g_assert(!g_action_get_state_type(gAction)); 159 177 160 178 g_assert_cmpint(webkit_context_menu_item_get_stock_action(item), ==, WEBKIT_CONTEXT_MENU_ACTION_CUSTOM); … … 174 192 assertObjectIsDeletedWhenTestFinishes(G_OBJECT(item)); 175 193 194 G_GNUC_BEGIN_IGNORE_DEPRECATIONS; 176 195 GtkAction* action = webkit_context_menu_item_get_action(item); 177 196 g_assert(GTK_IS_ACTION(action)); 178 179 197 g_assert_cmpstr(gtk_action_get_label(action), ==, label); 198 G_GNUC_END_IGNORE_DEPRECATIONS; 199 200 GAction* gAction = webkit_context_menu_item_get_gaction(item); 201 g_assert(G_IS_ACTION(gAction)); 202 180 203 checkActionState(action, state); 181 204 … … 500 523 MAKE_GLIB_TEST_FIXTURE(ContextMenuCustomTest); 501 524 502 ContextMenuCustomTest()503 : m_itemToActivateLabel(0)504 , m_activated(false)505 , m_toggled(false)506 {507 }508 509 525 bool contextMenu(WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult* hitTestResult) 510 526 { 511 527 // Append our custom item to the default menu. 512 webkit_context_menu_append(contextMenu, webkit_context_menu_item_new(m_action.get())); 528 G_GNUC_BEGIN_IGNORE_DEPRECATIONS; 529 if (m_action) 530 webkit_context_menu_append(contextMenu, webkit_context_menu_item_new(m_action.get())); 531 else if (m_gAction) 532 webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_from_gaction(m_gAction.get(), m_gActionTitle.data(), m_expectedTarget.get())); 533 G_GNUC_END_IGNORE_DEPRECATIONS; 513 534 quitMainLoop(); 514 535 … … 534 555 GtkMenuItem* item = getMenuItem(menu, m_itemToActivateLabel); 535 556 gtk_menu_shell_activate_item(GTK_MENU_SHELL(menu), GTK_WIDGET(item), TRUE); 536 m_itemToActivateLabel = 0;557 m_itemToActivateLabel = nullptr; 537 558 } 538 559 … … 557 578 } 558 579 559 static void actionActivatedCallback(GtkAction*, ContextMenuCustomTest* test) 560 { 561 test->m_activated = true; 562 } 563 564 static void actionToggledCallback(GtkAction*, ContextMenuCustomTest* test) 580 static void actionActivatedCallback(ContextMenuCustomTest* test, GVariant* target) 581 { 582 if (test->m_gAction) { 583 if (g_action_get_state_type(test->m_gAction.get())) { 584 GRefPtr<GVariant> state = adoptGRef(g_action_get_state(test->m_gAction.get())); 585 g_action_change_state(test->m_gAction.get(), g_variant_new_boolean(!g_variant_get_boolean(state.get()))); 586 } else { 587 test->m_activated = true; 588 if (test->m_expectedTarget) 589 g_assert(g_variant_equal(test->m_expectedTarget.get(), target)); 590 else 591 g_assert(!target); 592 } 593 } else 594 test->m_activated = true; 595 } 596 597 static void actionToggledCallback(ContextMenuCustomTest* test) 565 598 { 566 599 test->m_toggled = true; … … 570 603 { 571 604 m_action = action; 605 m_gAction = nullptr; 606 m_expectedTarget = nullptr; 572 607 if (GTK_IS_TOGGLE_ACTION(action)) 573 g_signal_connect (action, "toggled", G_CALLBACK(actionToggledCallback), this);608 g_signal_connect_swapped(action, "toggled", G_CALLBACK(actionToggledCallback), this); 574 609 else 575 g_signal_connect(action, "activate", G_CALLBACK(actionActivatedCallback), this); 610 g_signal_connect_swapped(action, "activate", G_CALLBACK(actionActivatedCallback), this); 611 } 612 613 void setAction(GAction* action, const char* title, GVariant* target = nullptr) 614 { 615 m_gAction = action; 616 m_gActionTitle = title; 617 m_action = nullptr; 618 m_expectedTarget = target; 619 g_signal_connect_swapped(action, "activate", G_CALLBACK(actionActivatedCallback), this); 620 if (g_action_get_state_type(action)) 621 g_signal_connect_swapped(action, "change-state", G_CALLBACK(actionToggledCallback), this); 576 622 } 577 623 578 624 GRefPtr<GtkAction> m_action; 579 const char* m_itemToActivateLabel; 580 bool m_activated; 581 bool m_toggled; 625 GRefPtr<GAction> m_gAction; 626 CString m_gActionTitle; 627 GRefPtr<GVariant> m_expectedTarget; 628 const char* m_itemToActivateLabel { nullptr }; 629 bool m_activated { false }; 630 bool m_toggled { false }; 582 631 }; 583 632 … … 590 639 591 640 // Create a custom menu item. 592 GRefPtr<GtkAction> action = adoptGRef(gtk_action_new("WebKitGTK+CustomAction", "Custom _Action", 0, 0));641 GRefPtr<GtkAction> action = adoptGRef(gtk_action_new("WebKitGTK+CustomAction", "Custom _Action", nullptr, nullptr)); 593 642 test->setAction(action.get()); 594 643 test->showContextMenuAndWaitUntilFinished(); … … 598 647 599 648 // Create a custom toggle menu item. 600 GRefPtr<GtkAction> toggleAction = adoptGRef(GTK_ACTION(gtk_toggle_action_new("WebKitGTK+CustomToggleAction", "Custom _Toggle Action", 0, 0)));649 GRefPtr<GtkAction> toggleAction = adoptGRef(GTK_ACTION(gtk_toggle_action_new("WebKitGTK+CustomToggleAction", "Custom _Toggle Action", nullptr, nullptr))); 601 650 test->setAction(toggleAction.get()); 602 651 test->showContextMenuAndWaitUntilFinished(); … … 604 653 g_assert(!test->m_activated); 605 654 g_assert(test->m_toggled); 655 656 // Create a custom menu item using GAction. 657 GRefPtr<GAction> gAction = adoptGRef(G_ACTION(g_simple_action_new("WebKitGTK+CustomGAction", nullptr))); 658 test->setAction(gAction.get(), "Custom _GAction"); 659 test->showContextMenuAndWaitUntilFinished(); 660 test->activateCustomMenuItemAndWaitUntilActivated("Custom _GAction"); 661 g_assert(test->m_activated); 662 g_assert(!test->m_toggled); 663 664 // Create a custom toggle menu item using GAction. 665 GRefPtr<GAction> toggleGAction = adoptGRef(G_ACTION(g_simple_action_new_stateful("WebKitGTK+CustomToggleGAction", nullptr, g_variant_new_boolean(FALSE)))); 666 test->setAction(toggleGAction.get(), "Custom _Toggle GAction"); 667 test->showContextMenuAndWaitUntilFinished(); 668 test->toggleCustomMenuItemAndWaitUntilToggled("Custom _Toggle GAction"); 669 g_assert(!test->m_activated); 670 g_assert(test->m_toggled); 671 672 // Create a custom menu item using GAction with a target. 673 gAction = adoptGRef(G_ACTION(g_simple_action_new("WebKitGTK+CustomGActionWithTarget", G_VARIANT_TYPE_STRING))); 674 test->setAction(gAction.get(), "Custom _GAction With Target", g_variant_new_string("WebKitGTK+CustomGActionTarget")); 675 test->showContextMenuAndWaitUntilFinished(); 676 test->activateCustomMenuItemAndWaitUntilActivated("Custom _GAction With Target"); 677 g_assert(test->m_activated); 606 678 } 607 679 … … 622 694 623 695 // Add custom actions. 624 GRefPtr<GtkAction> action = adoptGRef(gtk_action_new("WebKitGTK+CustomAction", "Custom _Action", 0, 0)); 696 G_GNUC_BEGIN_IGNORE_DEPRECATIONS; 697 GRefPtr<GtkAction> action = adoptGRef(gtk_action_new("WebKitGTK+CustomAction", "Custom _Action", nullptr, nullptr)); 625 698 gtk_action_set_sensitive(action.get(), FALSE); 626 699 webkit_context_menu_insert(contextMenu, webkit_context_menu_item_new(action.get()), -1); 627 GRefPtr<GtkAction> toggleAction = adoptGRef(GTK_ACTION(gtk_toggle_action_new("WebKitGTK+CustomToggleAction", "Custom _Toggle Action", 0, 0)));700 GRefPtr<GtkAction> toggleAction = adoptGRef(GTK_ACTION(gtk_toggle_action_new("WebKitGTK+CustomToggleAction", "Custom _Toggle Action", nullptr, nullptr))); 628 701 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(toggleAction.get()), TRUE); 629 702 webkit_context_menu_append(contextMenu, webkit_context_menu_item_new(toggleAction.get())); 630 703 webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_separator()); 704 GRefPtr<GAction> gAction = adoptGRef(G_ACTION(g_simple_action_new("WebKitGTK+CustomGAction", nullptr))); 705 g_simple_action_set_enabled(G_SIMPLE_ACTION(gAction.get()), FALSE); 706 webkit_context_menu_insert(contextMenu, webkit_context_menu_item_new_from_gaction(gAction.get(), "Custom _GAction", nullptr), -1); 707 GRefPtr<GAction> toggleGAction = adoptGRef(G_ACTION(g_simple_action_new_stateful("WebKitGTK+CustomToggleGAction", nullptr, g_variant_new_boolean(TRUE)))); 708 webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_from_gaction(toggleGAction.get(), "Custom T_oggle GAction", nullptr)); 709 webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_separator()); 710 G_GNUC_END_IGNORE_DEPRECATIONS; 631 711 632 712 // Add a submenu. … … 661 741 iter = checkCurrentItemIsCustomActionAndGetNext(iter, "Custom _Action", Visible); 662 742 iter = checkCurrentItemIsCustomActionAndGetNext(iter, "Custom _Toggle Action", Visible | Enabled | Checked); 743 iter = checkCurrentItemIsSeparatorAndGetNext(iter); 744 iter = checkCurrentItemIsCustomActionAndGetNext(iter, "Custom _GAction", Visible); 745 iter = checkCurrentItemIsCustomActionAndGetNext(iter, "Custom T_oggle GAction", Visible | Enabled | Checked); 663 746 g_assert(!iter); 664 747
Note: See TracChangeset
for help on using the changeset viewer.