void DoOpenFile(HANDLE aDlg) { LONG_PTR itemID=Info.SendDlgMessage(aDlg,DM_GETFOCUS,0,0); FarDialogItem DialogItem; Info.SendDlgMessage(aDlg,DM_GETDLGITEMSHORT,itemID,&DialogItem); if(DialogItem.Type==DI_EDIT) { TCHAR filename[MAX_PATH]; size_t dirSize=Info.PanelControl(PANEL_ACTIVE,FCTL_GETPANELDIRECTORY,0,NULL); FarPanelDirectory* dirInfo=(FarPanelDirectory*)malloc(dirSize); if(dirInfo) { dirInfo->StructSize=sizeof(FarPanelDirectory); Info.PanelControl(PANEL_ACTIVE,FCTL_GETPANELDIRECTORY,dirSize,dirInfo); size_t dirNameSize=(_tcslen(dirInfo->Name)+1); TCHAR* path=(TCHAR*)malloc((dirNameSize+1)*sizeof(TCHAR)); if(path) { memcpy(path,dirInfo->Name,dirNameSize*sizeof(TCHAR)); FSF.AddEndSlash(path); if(open_file_dialog(path,filename)) { Info.SendDlgMessage(aDlg,DM_SETTEXTPTR,itemID,filename); COORD Pos={0,0}; Info.SendDlgMessage(aDlg,DM_SETCURSORPOS,itemID,&Pos); Pos.X=(short)lstrlen(filename); Info.SendDlgMessage(aDlg,DM_SETCURSORPOS,itemID,&Pos); } free(path); } free(dirInfo); } } }
script_dialoges_handler::script_dialoges_handler(QObject *par) : abstract_scriptable_object("gui", par), m_tmp_num(0), m_tmp_str() { connect(this,SIGNAL(open_numeric_dialog()),event_manager::get_instance(),SIGNAL(open_numeric_dialog())); connect(this,SIGNAL(open_string_dialog()),event_manager::get_instance(),SIGNAL(open_string_dialog())); connect(this,SIGNAL(open_file_dialog()),event_manager::get_instance(),SIGNAL(open_file_dialog())); connect(this,SIGNAL(open_info_dialog(QString)),event_manager::get_instance(),SIGNAL(open_info_dialog(QString))); connect(this,SIGNAL(open_plot_dialog()),event_manager::get_instance(),SIGNAL(open_plot_dialog())); connect(event_manager::get_instance(), SIGNAL(dialog_finished(double)),this,SLOT(slot_dialog_finished(double))); connect(event_manager::get_instance(), SIGNAL(dialog_finished(QString)),this,SLOT(slot_dialog_finished(QString))); connect(event_manager::get_instance(), SIGNAL(dialog_finished()),this,SIGNAL(dialog_finished())); connect(event_manager::get_instance(), SIGNAL(application_aboutToQuit()),this,SIGNAL(dialog_finished())); }
QString script_dialoges_handler::showFileDialog() { m_tmp_str=""; QEventLoop loop; connect(this,SIGNAL(dialog_finished()),&loop, SLOT(quit())); emit open_file_dialog(); loop.exec(); return m_tmp_str; }
bool choose(boost::filesystem::path& result) { std::wstring retval; if (!open_file_dialog(NULL, L"war3.exe\0war3.exe\0", NULL, &retval)) { return false; } result = boost::filesystem::path(retval).parent_path(); return true; }
/** * Shows default first window of Ezeedo */ void activate (GtkApplication *app, gpointer user_data) { // get ezeedo from user data ezeedo_wrapper_structure *ezeedo; ezeedo = user_data; // define widgets GtkWidget *window; GtkWidget *todo_showall; GtkWidget *todo_contexts; GtkWidget *todo_projects; GtkWidget *donelist; GtkWidget *todolist; // initialize textlist and add to ezeedo wrapper structure textlist_container *main_textlist = calloc (1, sizeof(textlist_container)); ezeedo->textlist = main_textlist; // initialize tasklist and add to ezeedo wrapper structure tasklist_container *main_tasklist = calloc (1, sizeof(tasklist_container)); ezeedo->tasklist = main_tasklist; // initialize context_list and add to ezeedo wrapper structure category_container *context_list = calloc (1, sizeof(category_container)); ezeedo->context_list = context_list; // initialize project_list and add to ezeedo wrapper structure category_container *project_list = calloc (1, sizeof(category_container)); ezeedo->project_list = project_list; // initialize tasks store and add to ezeedo wrapper structure GtkListStore *tasks_store = create_tasks_store (); ezeedo->tasks_store = tasks_store; // create main window for application window = create_mainwindow (ezeedo); // get todotxt file from gsettings store GSettings *settings; gchar *todotxt_file; settings = g_settings_new ("org.y20k.ezeedo"); todotxt_file = g_settings_get_string (settings, "todo-txt-file"); g_object_unref (settings); // if not in gsettings store get todotxt file from file chooser if (strlen(todotxt_file) == 0) { todotxt_file = open_file_dialog (G_APPLICATION(ezeedo->application)); // quit application if open file dialog returns NULL if (todotxt_file == NULL) { char text[INFODIALOGLENGTH]; snprintf (text, INFODIALOGLENGTH,"File chooser returned NULL."); show_info (GTK_WIDGET(window), text, true); terminate (ezeedo); } else { save_file_name_location (todotxt_file); } } // open todo.txt file and load it line by line into a raw text list gboolean file_loaded = load_tasklist_file (todotxt_file, main_textlist); if (!file_loaded) { char text[INFODIALOGLENGTH]; snprintf (text, INFODIALOGLENGTH,"Could not load file:\n%s", todotxt_file); show_info (GTK_WIDGET(window), text, true); select_and_save_file (NULL, GTK_APPLICATION(ezeedo->application)); } // parse the raw textlist and load it into the main tasklist and sort it gboolean textlist_parsed = parse_textlist (main_textlist, main_tasklist, context_list, project_list); if (!textlist_parsed) { char text[INFODIALOGLENGTH]; snprintf (text, INFODIALOGLENGTH,"Could not parse file:\n%s", todotxt_file); show_info (GTK_WIDGET(window), text, true); select_and_save_file (NULL, GTK_APPLICATION(ezeedo->application)); } sort_tasklist (main_tasklist); // fill tasks store fill_tasks_store (ezeedo); GtkTreeModel *filter_todo; filter_todo = gtk_tree_model_filter_new (GTK_TREE_MODEL(ezeedo->tasks_store), NULL); gtk_tree_model_filter_set_visible_column (GTK_TREE_MODEL_FILTER(filter_todo), TASK_NOTCOMPLETED); GtkTreeModel *filter_done; filter_done = gtk_tree_model_filter_new (GTK_TREE_MODEL(ezeedo->tasks_store), NULL ); gtk_tree_model_filter_set_visible_column (GTK_TREE_MODEL_FILTER(filter_done), TASK_COMPLETED); // create todolist widget and add to ezeedo wrapper structure todolist = build_tasklist (ezeedo, GTK_TREE_MODEL(filter_todo)); gtk_container_add (GTK_CONTAINER (ezeedo->todolist_box), todolist); ezeedo->todolist = todolist; /* note to self: better use show_tasklist show_tasklist (ezeedo, CATEGORYLIST_ALL -1);*/ // create donelist and add to ezeedo wrapper structure donelist = build_tasklist (ezeedo, GTK_TREE_MODEL(filter_done)); gtk_container_add (GTK_CONTAINER (ezeedo->donelist_box), donelist); ezeedo->donelist = donelist; // create showall and add to ezeedo wrapper structure todo_showall = build_show_all (ezeedo); gtk_container_add (GTK_CONTAINER(ezeedo->categories_box), todo_showall); ezeedo->todo_showall = todo_showall; // create contexts and add to ezeedo wrapper structure GtkTreeModel *filter_contexts; filter_contexts = fill_category_store (ezeedo, ezeedo->context_list, CATEGORYLIST_CONTEXTS); todo_contexts = build_categorylist (ezeedo, GTK_TREE_MODEL(filter_contexts), "Contexts"); gtk_container_add (GTK_CONTAINER(ezeedo->categories_box), todo_contexts); ezeedo->todo_contexts = todo_contexts; // create projects and add to ezeedo wrapper structure GtkTreeModel *filter_projects; filter_projects = fill_category_store (ezeedo, ezeedo->project_list, CATEGORYLIST_PROJECTS); todo_projects = build_categorylist (ezeedo, GTK_TREE_MODEL(filter_projects), "Projects"); gtk_widget_set_vexpand (todo_projects, true); gtk_container_add (GTK_CONTAINER(ezeedo->categories_box), todo_projects); ezeedo->todo_projects = todo_projects; // show main window gtk_widget_show_all (window); return; }