Beispiel #1
0
static void export_gpx_button_clicked(GtkWidget *widget, gpointer data)
{
	GtkTreeIter iter;
	char *file = get_selected_file(&iter);
	if (file) {
		export_gpx(file);
	} else {
		info_dialog("Export .gpx file: no file selected!");
	}
}
Beispiel #2
0
static void replay_button_clicked(GtkWidget *widget, gpointer data)
{
	GtkTreeIter iter;
	char *file = get_selected_file(&iter);
	if (file) {
		if (replay_file_path)
			free(replay_file_path);

		replay_file = file;
		replay_file_path = get_full_path(NULL, 256, file);

		switch_to_main_view(CTX_ID_TRACK_REPLAY);
	} else {
		info_dialog("Replay: no file selected!");
	}
}
Beispiel #3
0
static void delete_button_clicked(GtkWidget *widget, gpointer data)
{
	GtkTreeIter iter;
	char *file = get_selected_file(&iter);
	if (file) {
		char buf[64];
		snprintf(buf, sizeof(buf), "Delete file:\n\n%s", file);
		if (confirm_dialog(buf)) {
			gtk_list_store_remove (filelist_store, &iter);
			char buf[256];
			char *path = get_full_path(buf, sizeof(buf), file);
			unlink(path);
		}
	} else {
		info_dialog("Delete: no file selected!");
	}
}
/*****
* Main window dialog box procedure
*****/
long FAR PASCAL _export
WndProc(HWND hwnd, UINT message, UINT wParam, LONG lParam)
{
	HBRUSH hbrush;

	switch (message)
	{
		case WM_CREATE:
			file_sel_changed = 0;
			/* attach keyboard interface */
			if((myhookproc = SetWindowsHookEx(WH_KEYBOARD,
				(HOOKPROC)KeyboardProc, hInst,
				GetCurrentTask())) == NULL)
				ErrHandler(NULL, R_ERROR, RB_OK1, "Winfflow "
					"Error: failed to set keyboard hook.\n"
					"Keyboard interface not installed.");
			return FALSE;
		/* following four cases ctl3d specific */
		case WM_SYSCOLORCHANGE:
			Ctl3dColorChange();
			return FALSE;
		case WM_SETTEXT:
		case WM_NCPAINT:
		case WM_NCACTIVATE:
			SetWindowLong(hwnd, DWL_MSGRESULT,
				Ctl3dDlgFramePaint(hwnd, message, wParam, 
				lParam));
			return TRUE;
		/*
		* paint window background with a brush provided by the response
		* to the WM_CTLCOLOR message
		*/
		case WM_ERASEBKGND:
		{
			RECT lprc;
			HDC hdc = (HDC)wParam;

			if(hwnd != hWndMain)
				return TRUE;
			if(!background_brush)
				return TRUE;
			UnrealizeObject(background_brush);
			GetClientRect(hwnd, &lprc);
			SetBrushOrg(hdc, 0, 0);
			SelectObject(hdc, background_brush);
			FillRect(hdc, &lprc, background_brush);
			return TRUE;
		}
		case WM_SIZE:
			switch(wParam)
			{
				case SIZE_MAXIMIZED:
				case SIZE_RESTORED:
					if(!block_resize)
						DoResize(hwnd, 0);
					return FALSE;
				default:
					break;
			}
			break;
		case WM_COMMAND:
		switch(GET_COMMAND_ID)
		{
			case IDC_MAIN_ABOUT:
				DisplayDialog(hwnd, hInst,WINFFLOW_ABOUT_DIALOG,
					AboutProc);
				break;
			/* add files to the listbox */
			case IDC_MAIN_ADD:
				get_fortran_files(hwnd);
				break;

			/* double click will edit selected file */
			case IDC_MAIN_LISTBOX:
				if(GET_COMMAND_CMD == LBN_DBLCLK)
					get_selected_file(hwnd, 
						IDC_MAIN_LISTBOX);
				break;

			/* remove/edit selected file */
			case IDC_MAIN_EDIT:
			case IDC_MAIN_REMOVE:
				get_selected_file(hwnd, GET_COMMAND_ID);
				break;
			case IDC_MAIN_REMOVE_ALL:
				SendDlgItemMessage(hwnd, IDC_MAIN_LISTBOX, 
					LB_RESETCONTENT, 0, 0L);
				destroy_filelist();
				break;
			/* settings */
			case IDC_MAIN_SETTINGS:
				DisplayDialog(hwnd, hInst,
					WINFFLOW_SETTINGS_DIALOG,
					(FARPROC)SettingsProc);
				break;

			/* scan the files */
			case IDOK:
				/*
				* scan the files when the selection has changed,
				* there is no current flowgraph or when the 
				* previous scan has been aborted
				*/
				if(file_sel_changed || flow == NULL ||
					yylex_abort)
				{
					/* pick up files */
					if(!get_files_to_scan(hwnd))
						break;
					generate_flowgraph();
				}
				/* hide main window */
				ShowWindow(hWndMain, SW_HIDE);
				/* display selector dialog box */
				DisplayDialog(hwnd, hInst,
					WINFFLOW_OUTPUTSELECTOR_DIALOG,
					(FARPROC)SelectorProc);
				/* display main window again */
				ShowWindow(hWndMain, SW_RESTORE);
				break;
			case IDCANCEL:
				/* save the filelist */
				save_ini_file_data(hwnd);
				SendMessage(hWndMain, WM_CLOSE, 0, 0L);
				break;
			case IDHELP:
				WinHelp(hWndMain, "winfflow.hlp", 
					HELP_CONTEXT, WINFFLOW_MAIN_DIALOG);
				break;
		} return(FALSE);
		case WM_SYSCOMMAND:
			if(GET_COMMAND_ID == SC_CLOSE)	/* Get the close item */
			{
				SendMessage(hWndMain, WM_CLOSE, 0, 0L);
				return FALSE;
			}
			break;
		case WM_CLOSE:
			UnregisterResize(hwnd);
			DestroyWindow(hwnd);
			return FALSE;
		case WM_DESTROY:
			PostQuitMessage (0) ;
			return FALSE;
/* Ctl3d specific code */
#ifdef WIN32
		case WM_CTLCOLORBTN:
		case WM_CTLCOLORDLG:
		case WM_CTLCOLOREDIT:
		case WM_CTLCOLORLISTBOX:
		case WM_CTLCOLORMSGBOX:
		case WM_CTLCOLORSCROLLBAR:
		case WM_CTLCOLORSTATIC:
#else
		case WM_CTLCOLOR:
#endif
			hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
			if (hbrush != (HBRUSH) FALSE)
			{
				/* save this brush */
				background_brush = hbrush;
				return hbrush;
			}
			/* fall through */
		default:
			break;
	 }
	 return (DefWindowProc (hwnd, message, wParam, lParam));
}