2 #include <gio/gdesktopappinfo.h>
6 print (const gchar *str)
8 g_print ("%s\n", str ? str : "nil");
12 print_app_list (GList *list)
16 GAppInfo *info = list->data;
17 print (g_app_info_get_id (info));
18 list = g_list_delete_link (list, list);
19 g_object_unref (info);
24 main (int argc, char **argv)
26 setlocale (LC_ALL, "");
30 else if (g_str_equal (argv[1], "list"))
34 all = g_app_info_get_all ();
35 for (i = all; i; i = i->next)
36 g_print ("%s%s", g_app_info_get_id (i->data), i->next ? " " : "\n");
37 g_list_free_full (all, g_object_unref);
39 else if (g_str_equal (argv[1], "search"))
44 results = g_desktop_app_info_search (argv[2]);
45 for (i = 0; results[i]; i++)
47 for (j = 0; results[i][j]; j++)
48 g_print ("%s%s", j ? " " : "", results[i][j]);
50 g_strfreev (results[i]);
54 else if (g_str_equal (argv[1], "implementations"))
58 results = g_desktop_app_info_get_implementations (argv[2]);
59 print_app_list (results);
61 else if (g_str_equal (argv[1], "show-info"))
65 info = (GAppInfo *) g_desktop_app_info_new (argv[2]);
68 print (g_app_info_get_id (info));
69 print (g_app_info_get_name (info));
70 print (g_app_info_get_display_name (info));
71 print (g_app_info_get_description (info));
72 g_object_unref (info);
75 else if (g_str_equal (argv[1], "default-for-type"))
79 info = g_app_info_get_default_for_type (argv[2], FALSE);
83 print (g_app_info_get_id (info));
84 g_object_unref (info);
87 else if (g_str_equal (argv[1], "recommended-for-type"))
91 list = g_app_info_get_recommended_for_type (argv[2]);
92 print_app_list (list);
94 else if (g_str_equal (argv[1], "all-for-type"))
98 list = g_app_info_get_all_for_type (argv[2]);
99 print_app_list (list);
102 else if (g_str_equal (argv[1], "fallback-for-type"))
106 list = g_app_info_get_fallback_for_type (argv[2]);
107 print_app_list (list);
110 else if (g_str_equal (argv[1], "should-show"))
114 info = (GAppInfo *) g_desktop_app_info_new (argv[2]);
117 g_print ("%s\n", g_app_info_should_show (info) ? "true" : "false");
118 g_object_unref (info);