EphyWebApplication * ephy_web_application_for_profile_directory (const char *profile_dir) { EphyWebApplication *app; char *desktop_file_path; const char *id; GDesktopAppInfo *desktop_info; const char *exec; int argc; char **argv; GFile *file; GFileInfo *file_info; guint64 created; GDate *date; id = get_app_id_from_profile_directory (profile_dir); if (!id) return NULL; app = g_new0 (EphyWebApplication, 1); app->id = g_strdup (id); app->desktop_file = get_app_desktop_filename (id); desktop_file_path = g_build_filename (profile_dir, app->desktop_file, NULL); desktop_info = g_desktop_app_info_new_from_filename (desktop_file_path); if (!desktop_info) { ephy_web_application_free (app); g_free (desktop_file_path); return NULL; } app->name = g_strdup (g_app_info_get_name (G_APP_INFO (desktop_info))); app->icon_url = g_desktop_app_info_get_string (desktop_info, "Icon"); exec = g_app_info_get_commandline (G_APP_INFO (desktop_info)); if (g_shell_parse_argv (exec, &argc, &argv, NULL)) { app->url = g_strdup (argv[argc - 1]); g_strfreev (argv); } g_object_unref (desktop_info); file = g_file_new_for_path (desktop_file_path); /* FIXME: this should use TIME_CREATED but it does not seem to be working. */ file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_TIME_MODIFIED, 0, NULL, NULL); created = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED); date = g_date_new (); g_date_set_time_t (date, (time_t)created); g_date_strftime (app->install_date, 127, "%x", date); g_date_free (date); g_object_unref (file); g_object_unref (file_info); g_free (desktop_file_path); return app; }
/** * ephy_web_application_free_application_list: * @list: an #EphyWebApplication GList * * Frees a @list as given by ephy_web_application_get_application_list. **/ void ephy_web_application_free_application_list (GList *list) { GList *p; for (p = list; p; p = p->next) ephy_web_application_free ((EphyWebApplication*)p->data); g_list_free (list); }