X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=tests%2Ftestgmenu.c;h=2f0512896b64c7c8135164ef7656036201c597cb;hb=HEAD;hp=9fd5258cee8d4309b3da4f535ec646f9e3c78245;hpb=e7b6fa4449aade9f7a719b140204fe46a97b865f;p=~andy%2Fgtk diff --git a/tests/testgmenu.c b/tests/testgmenu.c index 9fd5258ce..2f0512896 100644 --- a/tests/testgmenu.c +++ b/tests/testgmenu.c @@ -13,9 +13,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * License along with this library. If not, see . */ #include @@ -165,8 +163,6 @@ item_activated (GtkWidget *w, else parameter = NULL; g_action_group_activate_action (a->group, a->name, parameter); - if (parameter) - g_variant_unref (parameter); } /* GtkMenu construction {{{2 */ @@ -391,77 +387,79 @@ menu_holder_get_menu (MenuHolder *holder) /* The example menu {{{1 */ static const gchar menu_markup[] = + "\n" "\n" "
\n" - " \n" - " '_Undo'\n" + " \n" + " undo\n" + " _Undo\n" + " \n" + " \n" + " Redo\n" + " redo\n" " \n" - " \n" "
\n" - "
\n" - "
\n" - " \n" - " \n" - " \n" + "
\n" + "
\n" + " Copy & Paste\n" + " \n" + " Cut\n" + " cut\n" + " \n" + " \n" + " Copy\n" + " copy\n" + " \n" + " \n" + " Paste\n" + " paste\n" + " \n" "
\n" "
\n" - " \n" - " \n" - " \n" - " \n" - " \n" + " \n" + " Bold\n" + " bold\n" + " \n" + " \n" + " Language\n" + " \n" + " Latin\n" + " lang\n" + " latin\n" + " \n" + " \n" + " Greek\n" + " lang\n" + " greek\n" + " \n" + " \n" + " Urdu\n" + " lang\n" + " urdu\n" + " \n" " \n" "
\n" - "
\n"; - -static void -start_element (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - gpointer user_data, - GError **error) -{ - if (strcmp (element_name, "menu") == 0) - g_menu_markup_parser_start_menu (context, "gtk30", NULL); -} - -static void -end_element (GMarkupParseContext *context, - const gchar *element_name, - gpointer user_data, - GError **error) -{ - GMenu **menu = user_data; - - if (strcmp (element_name, "menu") == 0) - *menu = g_menu_markup_parser_end_menu (context); -} - -static const GMarkupParser parser = { - start_element, end_element, NULL, NULL, NULL -}; + "\n" + "
\n"; static GMenuModel * get_model (void) { - GMarkupParseContext *context; - GMenu *menu = NULL; GError *error = NULL; + GtkBuilder *builder; + GMenuModel *menu; - context = g_markup_parse_context_new (&parser, 0, &menu, NULL); - if (!g_markup_parse_context_parse (context, menu_markup, -1, &error)) - { - g_warning ("menu parsing failed: %s\n", error->message); - exit (1); - } - g_markup_parse_context_free (context); - g_assert (menu); + builder = gtk_builder_new (); + gtk_builder_add_from_string (builder, menu_markup, -1, &error); + g_assert_no_error (error); + + menu = g_object_ref (gtk_builder_get_object (builder, "edit-menu")); + g_object_unref (builder); - return G_MENU_MODEL (menu); + return menu; } - /* The example actions {{{1 */ +/* The example actions {{{1 */ static void activate_action (GSimpleAction *action, GVariant *parameter, gpointer user_data) @@ -991,9 +989,9 @@ main (int argc, char *argv[]) if (do_import) { g_print ("Getting menus from the bus...\n"); - model = (GMenuModel*)g_menu_proxy_get (bus, BUS_NAME, OBJ_PATH); + model = (GMenuModel*)g_dbus_menu_model_get (bus, BUS_NAME, OBJ_PATH); g_print ("Getting actions from the bus...\n"); - group = (GActionGroup*)g_dbus_action_group_new_sync (bus, BUS_NAME, OBJ_PATH, 0, NULL, NULL); + group = (GActionGroup*)g_dbus_action_group_get (bus, BUS_NAME, OBJ_PATH); } else { @@ -1009,13 +1007,13 @@ main (int argc, char *argv[]) if (do_export) { g_print ("Exporting menus on the bus...\n"); - if (!g_menu_model_dbus_export_start (bus, OBJ_PATH, model, &error)) + if (!g_dbus_connection_export_menu_model (bus, OBJ_PATH, model, &error)) { g_warning ("Menu export failed: %s", error->message); exit (1); } g_print ("Exporting actions on the bus...\n"); - if (!g_action_group_dbus_export_start (bus, OBJ_PATH, group, &error)) + if (!g_dbus_connection_export_action_group (bus, OBJ_PATH, group, &error)) { g_warning ("Action export failed: %s", error->message); exit (1);