/** * fm_launch_paths * @ctx: (allow-none): a launch context * @paths: (element-type FmPath): files to launch * @launcher: #FmFileLauncher with callbacks * @user_data: data supplied for callbacks * * Launches files using callbacks in @launcher. * * Returns: %TRUE in case of success. * * Since: 0.1.0 */ gboolean fm_launch_paths(GAppLaunchContext* ctx, GList* paths, FmFileLauncher* launcher, gpointer user_data) { FmFileInfoJob* job = fm_file_info_job_new(NULL, 0); GList* l; QueryErrorData data; gboolean ret; for(l=paths;l;l=l->next) fm_file_info_job_add(job, (FmPath*)l->data); data.ctx = ctx; data.launcher = launcher; data.user_data = user_data; g_signal_connect(job, "error", G_CALLBACK(on_query_target_info_error), &data); ret = fm_job_run_sync_with_mainloop(FM_JOB(job)); g_signal_handlers_disconnect_by_func(job, on_query_target_info_error, &data); if(ret) { GList* file_infos = fm_file_info_list_peek_head_link(job->file_infos); if(file_infos) ret = fm_launch_files(ctx, file_infos, launcher, user_data); else ret = FALSE; } g_object_unref(job); return ret; }
static FmFileInfo *_fetch_file_info_for_shortcut(const char *target, GAppLaunchContext* ctx, FmFileLauncher* launcher, gpointer user_data) { FmFileInfoJob *job; QueryErrorData data; FmFileInfo *fi; FmPath *path; job = fm_file_info_job_new(NULL, 0); /* bug #3614794: the shortcut target is a commandline argument */ path = fm_path_new_for_commandline_arg(target); fm_file_info_job_add(job, path); fm_path_unref(path); data.ctx = ctx; data.launcher = launcher; data.user_data = user_data; g_signal_connect(job, "error", G_CALLBACK(on_query_target_info_error), &data); fi = NULL; if (fm_job_run_sync_with_mainloop(FM_JOB(job))) fi = fm_file_info_ref(fm_file_info_list_peek_head(job->file_infos)); g_signal_handlers_disconnect_by_func(job, on_query_target_info_error, &data); g_object_unref(job); return fi; }
gboolean fm_launch_paths(GAppLaunchContext* ctx, GList* paths, FmFileLauncher* launcher, gpointer user_data) { FmJob* job = fm_file_info_job_new(NULL); GList* l; gboolean ret; for(l=paths;l;l=l->next) fm_file_info_job_add(FM_FILE_INFO_JOB(job), (FmPath*)l->data); ret = fm_job_run_sync_with_mainloop(job); if(ret) { GList* file_infos = fm_list_peek_head_link(FM_FILE_INFO_JOB(job)->file_infos); if(file_infos) ret = fm_launch_files(ctx, file_infos, launcher, user_data); else ret = FALSE; } g_object_unref(job); return ret; }
void SidePane::initDirTree() { // TODO DirTreeModel* model = new DirTreeModel(view_); FmFileInfoJob* job = fm_file_info_job_new(NULL, FM_FILE_INFO_JOB_NONE); model->setShowHidden(showHidden_); GList* l; /* query FmFileInfo for home dir and root dir, and then, * add them to dir tree model */ fm_file_info_job_add(job, fm_path_get_home()); fm_file_info_job_add(job, fm_path_get_root()); /* FIXME: maybe it's cleaner to use run_async here? */ fm_job_run_sync_with_mainloop(FM_JOB(job)); for(l = fm_file_info_list_peek_head_link(job->file_infos); l; l = l->next) { FmFileInfo* fi = FM_FILE_INFO(l->data); model->addRoot(fi); } g_object_unref(job); static_cast<DirTreeView*>(view_)->setModel(model); }